source/page00/system.asm
author brandonlw
Tue, 20 May 2014 02:59:10 -0400
changeset 41 9ef17625274f
parent 40 ba7bd14b7d7b
child 42 adad2f097dcb
permissions -rw-r--r--
Finished _newContext and other page 0 cleanup. Still lots left to go...
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
     1
coorMon:
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
     2
		res		g_style_active, (iy+sGrFlags)
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
     3
		call	j_CursorOff
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
     4
		call	j_COORDISP
36
2fca899545cf Minor cleanup
brandonlw
parents: 34
diff changeset
     5
Mon:	call	j_RunIndicOff
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
     6
		call	j_CursorOn
36
2fca899545cf Minor cleanup
brandonlw
parents: 34
diff changeset
     7
		res		displayCoords, (iy+newDispF)
2fca899545cf Minor cleanup
brandonlw
parents: 34
diff changeset
     8
		bit		sendFinalPacketOnMon, (iy+linkFlags2)
2fca899545cf Minor cleanup
brandonlw
parents: 34
diff changeset
     9
		jr		z, Mon_NoPacketSend
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
    10
		di
36
2fca899545cf Minor cleanup
brandonlw
parents: 34
diff changeset
    11
		res		sendFinalPacketOnMon, (iy+linkFlags2)
2fca899545cf Minor cleanup
brandonlw
parents: 34
diff changeset
    12
		ld		hl, Mon_ResetIndicOnly
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
    13
		call	pushErrorHandleR
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
    14
		set		indicOnly, (iy+indicFlags)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
    15
		ld		a, (mcxCurApp)
36
2fca899545cf Minor cleanup
brandonlw
parents: 34
diff changeset
    16
		cp		kError
2fca899545cf Minor cleanup
brandonlw
parents: 34
diff changeset
    17
		jr		nz, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
    18
		ld		a, (errNo)
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
    19
		call	j_SendSkipExitPacket
36
2fca899545cf Minor cleanup
brandonlw
parents: 34
diff changeset
    20
		jr		Mon_LinkEnd
2fca899545cf Minor cleanup
brandonlw
parents: 34
diff changeset
    21
+:		call	j_SendAck
2fca899545cf Minor cleanup
brandonlw
parents: 34
diff changeset
    22
Mon_LinkEnd:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
    23
		call	popErrorHandleR
36
2fca899545cf Minor cleanup
brandonlw
parents: 34
diff changeset
    24
Mon_ResetIndicOnly:
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
    25
		res		indicOnly, (iy+indicFlags)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
    26
		ei
36
2fca899545cf Minor cleanup
brandonlw
parents: 34
diff changeset
    27
Mon_NoPacketSend:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
    28
		xor		a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
    29
		ld		(kbdKey), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
    30
		ld		(keyExtend), a
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
    31
		call	j_getkey
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
    32
monForceKey:
37
9cdbb6464f89 Renaming recall-related flags
brandonlw
parents: 36
diff changeset
    33
		res		recallingPrgmName, (iy+rclFlag2)
9cdbb6464f89 Renaming recall-related flags
brandonlw
parents: 36
diff changeset
    34
		res		recallingListName, (iy+rclFlag3)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
    35
		ld		(kbdKey), a
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    36
		bit		allowCursor, (iy+plotFlags)
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    37
		jr		z, {+}
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
    38
		res		curAble, (iy+curFlags)
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
    39
		bit		curOn, (iy+curFlags)
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
    40
		call	z, j_BLINKGCUR
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
    41
		ld		a, (kbdKey)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    42
		jr		{++}
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    43
+:		call	j_CursorOff
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    44
++:		call	j_RunIndicOn
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
    45
		or		a
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    46
		jr		nz, {++}
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    47
		;ON was pressed; now what?
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
    48
		bit		appWantIntrpt, (iy+appFlags)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    49
		jr		nz, {+}
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
    50
		res		onInterrupt, (iy+onFlags)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    51
		jr		jpCoorMon
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    52
+:		;Return kEnter instead
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    53
		ld		a, kEnter
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
    54
		jp		sendKPress
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    55
++:		cp		kVarx
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    56
		jr		nz, monNotVarKey
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    57
		ld		a, kTheta
27
5220b6f6c984 More page 0 cleanup.
brandonlw
parents: 26
diff changeset
    58
		call	IsFunctionMode
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    59
		jr		nz, {+}
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    60
		ld		a, kCapT
27
5220b6f6c984 More page 0 cleanup.
brandonlw
parents: 26
diff changeset
    61
		call	IsParametricMode
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    62
		jr		nz, {+}
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    63
		ld		a, kCapX
27
5220b6f6c984 More page 0 cleanup.
brandonlw
parents: 26
diff changeset
    64
		call	IsFuncMode
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    65
		jr		nz, {+}
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    66
		ld		a, kRecn
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
    67
		ld		(keyExtend), a
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    68
		ld		a, kExtendEcho
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    69
+:		ld		(kbdKey), a
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    70
monNotVarKey:
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    71
		res		appIgnoreKey, (iy+APIFlg)
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    72
		res		sendKeyStraightTocxMain, (iy+APIFlg)
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
    73
		bit		rawKeyHookActive, (iy+hookflags2)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    74
		jr		z, {+}
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
    75
		call	j_call_rawkey_hook
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    76
		bit		appIgnoreKey, (iy+APIFlg)
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    77
		jr		nz, jpCoorMon
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    78
		bit		sendKeyStraightTocxMain, (iy+APIFlg)
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    79
		jr		z, {+}
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
    80
		push	af
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    81
		jp		Mon_CallcxMain
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    82
+:		cp		kOff
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    83
		jr		z, {+}
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
    84
		call	j_PULLDOWNCHK
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    85
		jr		c, jpCoorMon
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
    86
		call	j_clrTR
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    87
		jr		c, jpCoorMon
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    88
		call	IsExternalApp
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    89
+:		jr		z, sendKPress
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    90
		cp		kDoug
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
    91
		jr		z, sendKPress
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    92
		cp		kListflag
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    93
		jr		z, sendKPress
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    94
		jr		Mon_Continue
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    95
-:		pop		hl
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
    96
		pop		bc
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    97
		djnz	{+}
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
    98
jpCoorMon:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
    99
		jp		coorMon
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   100
SendProgToEditTocxMain:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   101
		ld		b, 8
37
9cdbb6464f89 Renaming recall-related flags
brandonlw
parents: 36
diff changeset
   102
		ld		hl, progToEdit-1
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   103
+:		inc		hl
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   104
		ld		a, (hl)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   105
		or		a
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   106
		jr		z, jpCoorMon
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   107
		push	bc
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   108
		push	hl
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   109
		ld		d, 0
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   110
		ld		e, a
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
   111
		call	j_TokToKey
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   112
		call	cxMain
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   113
		res		onInterrupt, (iy+onFlags)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   114
		jr		{-}
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   115
Mon_Continue:
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   116
		cp		EchoStart
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   117
		jp		c, Mon_HandleNonEchoKey
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   118
		cp		kExtendEcho
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   119
		jr		z, sendKPress
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   120
		cp		kExtendEcho2
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   121
		jr		z, sendKPress
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   122
		cp		kExtendEcho3
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   123
		jr		nz, _isOtherKey
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   124
		ld		a, (keyExtend)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   125
		or		a
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   126
		jr		z, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   127
		cp		0Dh
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   128
		jr		c, _isValid3Key
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   129
		cp		8Ch
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   130
		jr		c, Mon_HandleOurselves
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   131
		cp		0A6h
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   132
		jr		nc, Mon_HandleOurselves
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   133
_isValid3Key:
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   134
		ld		a, kExtendEcho3
11
fea1578031ed Cleanup to page 0.
brandonlw
parents: 10
diff changeset
   135
		jr		sendKPress
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   136
+:		ld		a, (kbdKey)
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   137
_isOtherKey:
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   138
		cp		0EFh
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   139
		jr		nz, {+}
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   140
		ld		a, 0A6h
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   141
		jr		setKeyExtend
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   142
+:		cp		0F9h
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   143
		jr		c, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   144
		sub		14h
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   145
		jr		setKeyExtend
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   146
+:		cp		0F3h
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   147
		jr		c, sendKPress
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   148
		sub		7Ch
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   149
setKeyExtend:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   150
		ld		(keyExtend), a
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   151
		ld		a, kExtendEcho
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   152
sendKPress:
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   153
		cp		echoStart2
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   154
		jr		nz, {+}
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   155
		ld		a, kExtendEcho2
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   156
		jr		setKeyExtend
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   157
+:		cp		echoStart1+1
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   158
		jr		nz, {+}
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   159
		ld		a, 0FDh
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   160
		jr		setKeyExtend
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   161
sendKPress_NamedVar:
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   162
+:		cp		kDoug
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   163
		push	af
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   164
		jr		nz, {+}
37
9cdbb6464f89 Renaming recall-related flags
brandonlw
parents: 36
diff changeset
   165
		set		recallingPrgmName, (iy+rclFlag2)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   166
		ld		a, kExec
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   167
		jr		Mon_CallcxMain
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   168
+:		pop		af
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   169
		cp		kListflag
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   170
		push	af
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   171
		jr		nz, Mon_CallcxMain
37
9cdbb6464f89 Renaming recall-related flags
brandonlw
parents: 36
diff changeset
   172
		set		recallingListName, (iy+rclFlag3)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   173
		ld		a, kListName
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   174
Mon_CallcxMain:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   175
		call	cxMain
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   176
		res		onInterrupt, (iy+onFlags)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   177
		pop		af
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   178
		jp		z, SendProgToEditTocxMain
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   179
Mon_HandleOurselves:
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   180
		bit		enableQueue, (iy+rclFlag)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   181
		jr		z, Mon_Restart
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   182
		ld		de, (rclQueue)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   183
		ld		hl, (editCursor)
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   184
		bit		useRclQueueEnd, (iy+hookflags1)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   185
		jr		z, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   186
		ld		hl, (rclQueueEnd)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   187
		ex		de, hl
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   188
+:		call	CpHLDE
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   189
		jr		nc, Mon_DisableQueueRestart
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   190
		ld		a, (hl)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   191
		call	isPtrHLA2ByteTok
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   192
		ld		d, 0
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   193
		ld		e, a
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   194
		jr		nz, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   195
		ld		d, a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   196
		inc		hl
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   197
		ld		e, (hl)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   198
+:		bit		useRclQueueEnd, (iy+hookflags1)
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   199
		jr		z, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   200
		inc		hl
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   201
		ld		(rclQueue), hl
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   202
+:		call	j_TokToKey
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   203
jpSendKPress:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   204
		jr		sendKPress
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   205
Mon_DisableQueueRestart:
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   206
		res		enableQueue, (iy+rclFlag)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   207
		ld		hl, flags+textFlags
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   208
		ld		a, (promptIns)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   209
		res		textInsMode, (hl)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   210
		or		(hl)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   211
		ld		(hl), a
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   212
Mon_Restart:
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   213
		res		useRclQueueEnd, (iy+hookflags1)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   214
		jp		Mon
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   215
Mon_HandleNonEchoKey:
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   216
		cp		kApp
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   217
		jr		c, jpSendKPress
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   218
		cp		echoStart1
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   219
		jr		c, Mon_SwitchToStandardContext
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   220
		cp		kEval
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   221
		jr		nc, Mon_SwitchToGraphContextThenPressKey
39
4651e87022c7 Fix flag.
brandonlw
parents: 38
diff changeset
   222
		bit		prgmEdit, (iy+prgmFlags)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   223
		jr		nz, jpSendKPress
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   224
		cp		echoStart2
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   225
		jr		c, Mon_SwitchToGraphContextThenPressKey
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   226
		cp		kPen
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   227
		jr		z, Mon_SwitchToGraphContextThenPressKey
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   228
		cp		echoStart2
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   229
		jr		z, jpSendKPress
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   230
		ld		b, a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   231
		ld		a, (mcxCurApp)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   232
		cp		kGraph
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   233
		ld		a, b
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   234
		jr		nz, jpSendKPress
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   235
Mon_SwitchToGraphContextThenPressKey:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   236
		ld		b, a
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   237
		ld		a, kGraph
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   238
		jr		{+}
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   239
		push	af
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   240
Mon_SwitchToStandardContext:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   241
		ld		b, a
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   242
		cp		kNewApps
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   243
		jr		nz, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   244
		ld		a, (keyExtend)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   245
		add		a, b
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   246
		cp		echoStart1+1
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   247
		jr		nc, JForceCmdNoChar
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   248
		ld		b, a
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   249
+:		ld		c, a
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   250
		ld		a, (mcxCurApp)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   251
		cp		kPrgmInput
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   252
		jr		nz, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   253
		ld		a, b
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   254
		cp		appStart
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   255
		jr		z, JForceCmdNoChar
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   256
		ld		a, kPrgmInput
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   257
		jr		{++}
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   258
+:		cp		kError
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   259
		ld		a, c
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   260
		jr		nz, {++}
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   261
		cp		appStart
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   262
		jr		nz, Mon_Restart
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   263
++:		call	newContext0
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   264
		ld		a, b
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   265
		jp		sendKPress_NamedVar
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   266
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   267
JForceCmdNoChar:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   268
		xor		a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   269
JForceCmd:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   270
		ld		b, a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   271
		ld		sp, (onSP)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   272
		res		cmdExec, (iy+cmdFlags)
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   273
		call	SetFastSpeed
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   274
		ld		a, appStart
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   275
		call	newContext0
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   276
		ld		a, b
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   277
		cp		kExec
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   278
		jr		nz, {+}
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   279
		ld		a, kDoug
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   280
-:		jp		sendKPress
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   281
+:		cp		kListName
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   282
		jr		nz, {-}
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   283
		ld		a, kListflag
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   284
		jr		{-}
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   285
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   286
sysErrHandler:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   287
		ld		sp, (onSP)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   288
		ld		a, kError
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   289
		call	newContext
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   290
		jp		Mon
11
fea1578031ed Cleanup to page 0.
brandonlw
parents: 10
diff changeset
   291
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   292
#ifndef DEVIATE_FROM_ORIGINAL_FILE
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   293
;We don't need this, I don't think.
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   294
		ret
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   295
#endif
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   296
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   297
newContext:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   298
		ld		c, a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   299
		sub		a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   300
		ld		(kbdKey), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   301
		ld		b, a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   302
		in		a, (6)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   303
		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   304
		ld		a, c
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   305
		call	newContext0
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   306
		pop		af
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   307
OutPort6:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   308
		out		(6), a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   309
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   310
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   311
newContext0:
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   312
		res		appRetKeyOff, (iy+APIFlg)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   313
		ld		hl, mcxCurApp
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   314
		cp		(hl)
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   315
		jr		nz, newContext_Start
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   316
		cp		kGraph
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   317
		jr		nz, {+}
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   318
		;If you try to start the graph context again, just put it away
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   319
		push	bc
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
   320
		call	j_GRPUTAWAY
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   321
		pop		bc
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   322
		ret
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   323
+:		;We're allowed to re-start the homescreen context again
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   324
		cp		appStart
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   325
		jr		z, newContext_Start
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   326
		ld		b, kApp
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   327
		ret
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   328
newContext_Start:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   329
		push	bc
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   330
		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   331
		pop		af
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   332
		cp		kInputDone
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   333
		jr		nz, {+}
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   334
		ld		a, appStart
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   335
		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   336
		xor		a
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   337
		jr		newContext_Init
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   338
+:		push	af
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   339
		sub		appStart
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   340
		jr		nz, newContext_Init
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   341
		res		cmdExec, (iy+cmdFlags)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   342
newContext_Init:
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   343
		call	j_InitContextA
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   344
		pop		af
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   345
		push	hl
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   346
		push	af
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   347
		res		curLock, (iy+curFlags)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   348
		call	cxPPutAway2
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   349
		pop		af
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   350
		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   351
		ld		b, a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   352
		ld		a, (mcxCurApp)
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   353
		cp		kPrgmCr
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   354
		ld		a, b
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   355
		jr		z, _notProgramEditor
39
4651e87022c7 Fix flag.
brandonlw
parents: 38
diff changeset
   356
		bit		prgmEdit, (iy+prgmFlags)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   357
		jr		z, _notProgramEditor
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   358
		cp		kFormat
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   359
		jr		z, _skipPutAway
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   360
		cp		kMode
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   361
		jr		z, _skipPutAway
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   362
		cp		kTblSet
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   363
		jr		z, _skipPutAway
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   364
_notProgramEditor:
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   365
		;In program editor context, or
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   366
		;NOT in program editor, or
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   367
		;NOT in FORMAT, MODE, or TBL SET contexts
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   368
		call	j_RefreshSplitGraphTableFlags
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   369
		cp		kError
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   370
		jr		z, _skipPutAway
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   371
		call	call_cxPutAway
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   372
		call	IsExternalApp
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   373
		call	z, SetFastSpeed
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   374
_skipPutAway:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   375
		ld		a, (mcxCurApp)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   376
		pop		bc
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   377
		push	af
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   378
		push	bc
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   379
		cp		kError
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   380
		jr		nz, {+}
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
   381
		call	j_POPCX
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   382
		call	cxPutAway_NoPartial
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   383
		call	IsExternalApp
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   384
		call	z, SetFastSpeed
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   385
+:		ld		hl, mcxMain
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   386
		ld		de, mcxPrev
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   387
		ld		bc, 14
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   388
		ldir
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   389
		ld		a, (appFlagsAddr)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   390
		ld		(de), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   391
		pop		af
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   392
		push	af
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   393
		cp		kTable
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   394
		jr		nz, {+}
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   395
		call	j_SetVertSplitRedisplayFlags
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   396
		jr		newContext_Finish
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   397
+:		cp		kGraph
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   398
		call	z, j_SetVertSplitRedisplayFlags
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   399
		jr		z, {+}
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   400
		set		NEED_BUFCPY, (iy+VERTFLAG2)
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   401
		set		NEED_RETABLE, (iy+VERTFLAG2)
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   402
		jr		newContext_Finish
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   403
+:		call	ResetSplitOverride
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   404
		call	CheckSplitFlag
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   405
		jr		z, newContext_Finish
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   406
		ld		a, (mcxCurApp)
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
   407
		call	j_CompareContext
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   408
		jr		nz, newContext_Finish
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   409
		ld		a, appStart
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   410
		ld		(mcxCurApp), a
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   411
		ld		hl, j_InitHomescreenContext
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   412
		ld		a, (iy+shiftFlags)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   413
		push	af
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   414
		ld		a, appstart
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   415
		call	CallAppChangeRoutineHL
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   416
		call	cxPutAway
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   417
		pop		af
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   418
		ld		(iy+shiftFlags), a
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   419
newContext_Finish:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   420
		pop		af
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   421
		pop		bc
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   422
		cp		kPrgmEd
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   423
		jr		nz, _notPrgmEd
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   424
		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   425
		ld		a, b
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   426
		cp		kError
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   427
		jr		z, {+}
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   428
		set		promptEdit, (iy+promptFlags)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   429
+:		pop		af
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   430
_notPrgmEd:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   431
		pop		hl
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   432
		ld		(mcxCurApp), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   433
		pop		af
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   434
CallAppChangeRoutineHL:
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   435
		bit		appChangeHookActive, (iy+hookflags4)
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   436
		call	nz, j_call_appchange_hook
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   437
		push	af
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   438
		set		monAppInit, (iy+monFlags)
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   439
		call	jpHL
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   440
		res		monAppInit, (iy+monFlags)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   441
		pop		bc
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   442
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   443
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   444
ldHLind_AWord:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   445
		add		a, a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   446
		ld		e, a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   447
		ld		d, 0
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   448
		add		hl, de
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   449
		jp		ldHLind
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   450
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   451
cxPutAway:
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   452
		call	cxPPutAway2
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   453
cxPutAway_NoPartial:
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   454
		call	call_cxPutAway
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   455
ResetPromptEditFlag:
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   456
		res		promptEdit, (iy+promptFlags)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   457
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   458
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   459
cxPPutAway2:
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   460
		bit		nocxPutAway, (iy+contextFlags)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   461
		ret		nz
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   462
		push	hl
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   463
		ld		hl, (mcxPPutAway)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   464
		call	CallCxRoutineHL
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   465
		jr		{+}
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   466
call_cxPutAway:
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   467
		bit		nocxPutAway, (iy+contextFlags)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   468
		ret		nz
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   469
		push	hl
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   470
		ld		hl, (mcxPutAway)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   471
		call	CallCxRoutineHL
10
20102b43be54 Clean up boot.asm.
brandonlw
parents: 9
diff changeset
   472
		call	zero_basic_prog
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   473
+:		pop		hl
32
263488c56ee1 More cleanup.
brandonlw
parents: 31
diff changeset
   474
		jp		CancelAlpha
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   475
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   476
cxRedisp:
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   477
		ld		hl, (mcxRedisp)
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   478
		jr		CallCxRoutineHL
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   479
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   480
cxSizeWind:
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   481
		bit		monAppInit, (iy+monFlags)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   482
		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   483
		ld		a, (menuActive)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   484
		ld		b, a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   485
		ld		hl, (mcxSizeWind)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   486
		call	CallCxRoutineHL
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   487
		pop		af
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   488
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   489
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   490
cxErrEP:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   491
		ld		hl, (mcxErrorEP)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   492
CallCxRoutineHL:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   493
		in		a, (6)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   494
		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   495
		ld		a, (mcxPage)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   496
		call	OutPort6
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   497
		call	jpHL
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   498
		pop		af
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   499
		call	OutPort6
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   500
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   501
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   502
cxMain:	push	hl
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   503
		ld		hl, (mcxMain)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   504
		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   505
		ld		a, (mcxPage)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   506
		call	OutPort6
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   507
		pop		af
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   508
		call	jpHL
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   509
		pop		hl
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   510
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   511
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   512
jpHL:	jp		(hl)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   513
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   514
call_cxPrevRedisp:
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   515
		ld		a, (cxPrevPage)
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   516
		call	OutPort6
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   517
		ld		hl, (cxPrevRedisp)
40
ba7bd14b7d7b Minor cleanup
brandonlw
parents: 39
diff changeset
   518
		jr		jpHL
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   519
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   520
monErrHand:
26
fb2b0058e568 Fix hard-coded error handler address.
brandonlw
parents: 25
diff changeset
   521
		ld		hl, monErrHand
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   522
		call	pushErrorHandleR
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   523
		ld		a, kError
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   524
		call	newContext0
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   525
		jp		Mon
11
fea1578031ed Cleanup to page 0.
brandonlw
parents: 10
diff changeset
   526
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   527
#ifndef DEVIATE_FROM_ORIGINAL_FILE
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   528
;I don't think this is used *anywhere*.
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   529
		push	hl
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   530
		ld		hl, 100
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   531
		jr		AppInitEnoughMemHL
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   532
#endif
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   533
AppInitEnoughMem50:
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   534
		push	hl
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   535
		ld		hl, 50
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   536
AppInitEnoughMemHL:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   537
		call	EnoughMem
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   538
		jp		c, ErrMemory_NoGoTo
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   539
		pop		hl
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   540
AppInit:
26
fb2b0058e568 Fix hard-coded error handler address.
brandonlw
parents: 25
diff changeset
   541
		ld		de, mcxMain
fb2b0058e568 Fix hard-coded error handler address.
brandonlw
parents: 25
diff changeset
   542
		ld		bc, 12
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   543
		ldir
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   544
		ld		a, (hl)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   545
		ld		(appFlagsAddr), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   546
		in		a, (6)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   547
		ld		(mcxPage), a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   548
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   549
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   550
IsExternalApp:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   551
		ld		b, a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   552
		ld		a, (mcxCurApp)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   553
		cp		kExtApps
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   554
		ld		a, b
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   555
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   556
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   557
handleONKeyPress:
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   558
		;Switch to slow speed
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   559
		in		a, (2)
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   560
		and		80h
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   561
		jr		z, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   562
		in		a, (20h)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   563
		ld		e, a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   564
		xor		a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   565
		out		(20h), a
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   566
+:		ld		b, 0
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   567
debounceRestart:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   568
		ld		hl, 1016h
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   569
debounceLoop:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   570
		in		a, (4)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   571
		and		8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   572
		cp		b
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   573
		ld		b, a
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   574
		jr		nz, debounceRestart
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   575
		dec		hl
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   576
		ld		a, l
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   577
		or		h
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   578
		jr		nz, debounceLoop
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   579
		cp		b
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   580
		jr		z, ONKeyBeingPressed
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   581
		;ON key is being released
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   582
		in		a, (7)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   583
		ld		b, a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   584
		in		a, (2)
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   585
		and		80h
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   586
		jr		z, {+}
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   587
		;Restore previous speed
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   588
		ld		a, e
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   589
		out		(20h), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   590
		ld		a, b
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   591
		cp		81h
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   592
		jr		isRAMUnhooked
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   593
+:		ld		a, b
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   594
		and		4Fh
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   595
		cp		41h
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   596
isRAMUnhooked:
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   597
		jp		nz, RAMUnhookedWaitForPowerOn
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   598
		bit		onRunning, (iy+onFlags)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   599
		ret		nz
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   600
		;ON key being released and we're just off, so just return from the interrupt handler
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   601
		pop		hl
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   602
		sub		a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   603
		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   604
		ld		a, 8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   605
		out		(3), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   606
		pop		af
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   607
		out		(3), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   608
		ld		a, 11h
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   609
		jp		noSecondHardwareTimer
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   610
ONKeyBeingPressed:
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   611
		;Restore previous speed
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   612
		in		a, (2)
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   613
		and		80h
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   614
		jr		z, HandlePowerOnRequest
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   615
		ld		a, e
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   616
		out		(20h), a
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   617
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   618
.module	HandlePowerOnRequest
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   619
HandlePowerOnRequest:
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   620
		ld		a, 76h
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   621
		out		(4), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   622
		in		a, (2)
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   623
		and		80h
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   624
		jr		z, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   625
		in		a, (7)
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   626
		cp		81h
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   627
		jr		_isRAMUnhooked
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   628
+:		in		a, (7)
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   629
		and		4Fh
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   630
		cp		41h
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   631
_isRAMUnhooked:
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   632
		jp		nz, HookRAMAndPowerOn
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   633
		bit		shift2nd, (iy+shiftFlags)
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   634
		jp		z, HandleONPressed
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   635
		;2nd is being pressed, so we might be turning off
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   636
		bit		enableKeyEcho, (iy+hookflags1)
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   637
		jr		nz, {+}
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   638
		bit		appRetKeyOff, (iy+APIFlg)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   639
		jr		z, PowerOff
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   640
+:		set		kOffPressed, (iy+APIFlg)
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   641
		ret
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   642
.endmodule
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   643
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   644
.module	PowerOff
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   645
PowerOff:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   646
		ld		a, 8
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   647
		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   648
		ld		a, 8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   649
		out		(3), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   650
		pop		af
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   651
		out		(3), a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   652
		call	TurnOffLCD
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   653
		bit		resetOnPowerOn, (iy+selfTestFlag)
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   654
		jr		z, {+}
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   655
		;If above flag is set and APD is disabled, skip RAM checksum generation (forcing a reset)
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   656
		bit		apdAble, (iy+apdFlags)
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   657
		jr		z, _skipRAMChecksum
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   658
+:		call	SetFastSpeed
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   659
		call	PreviousContext_CloseAnyOpenMenu
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
   660
		call	j_hideCursor
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   661
		set		monAbandon, (iy+monFlags)
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   662
		ld		hl, lcdFlag
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   663
		set		powerLcdForGC, (hl)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   664
		call	forcecmd
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   665
		ld		hl, lcdFlag
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   666
		res		powerLcdForGC, (hl)
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   667
		res		monAbandon, (iy+monFlags)
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   668
		bit		alt_Off, (iy+hookflags1)
24
12b896331796 More cleanup.
brandonlw
parents: 23
diff changeset
   669
		call	nz, j_ExecuteOFFSCRPT
28
55da9f386e8e Lots of cleanup.
brandonlw
parents: 27
diff changeset
   670
_DoShutDown:
55da9f386e8e Lots of cleanup.
brandonlw
parents: 27
diff changeset
   671
		call	j_SetupDBusMem
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   672
		ld		a, 8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   673
		out		(3), a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   674
		call	TurnOffLCD
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   675
		ld		hl, flags+onFlags
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   676
		bit		onClearScrn, (hl)
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   677
		res		onClearScrn, (hl)
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
   678
		call	nz, j_ClrScrn
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   679
		call	calculateRAMChecksum
22
dea09e588bf1 Cleanup of page 0's boot.asm.
brandonlw
parents: 21
diff changeset
   680
		ld		(RAMChecksum), hl
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   681
_skipRAMChecksum:
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   682
		res		bPLinkOn, (iy+hookflags1)
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   683
		res		enableKeyEcho, (iy+hookflags1)
24
12b896331796 More cleanup.
brandonlw
parents: 23
diff changeset
   684
		ld		a, 36h
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   685
		out		(4), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   686
		ld		a, 11h
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   687
		out		(3), a
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   688
		res		shift2nd, (iy+shiftFlags)
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   689
		res		onRunning, (iy+onFlags)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   690
		ex		af, af'
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   691
		exx
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   692
		ei
22
dea09e588bf1 Cleanup of page 0's boot.asm.
brandonlw
parents: 21
diff changeset
   693
-:		halt
dea09e588bf1 Cleanup of page 0's boot.asm.
brandonlw
parents: 21
diff changeset
   694
		jr		{-}
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   695
.endmodule
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   696
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   697
HandleONPressed:
22
dea09e588bf1 Cleanup of page 0's boot.asm.
brandonlw
parents: 21
diff changeset
   698
		res		checkNoBatteriesNextTime, (iy+batteryFlags2)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   699
		call	ApdSetup
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   700
		bit		onRunning, (iy+onFlags)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   701
		jr		nz, SetOnInterruptFlag
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   702
HandleONPressed_WasOff:
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   703
		set		onRunning, (iy+onFlags)
22
dea09e588bf1 Cleanup of page 0's boot.asm.
brandonlw
parents: 21
diff changeset
   704
		ld		hl, flags+apdFlags
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   705
		bit		APDWarmStart, (hl)
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   706
		res		APDWarmStart, (hl)
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   707
		jr		nz, restoreToPoweredOn
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   708
		res		indicInUse, (iy+indicFlags)
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   709
		bit		resetOnPowerOn, (iy+selfTestFlag)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   710
		jr		z, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   711
		bit		2, (hl)
25
fab1bedd3281 Commit some experimental commented-out code for 84+CSE detection and booting
brandonlw
parents: 24
diff changeset
   712
		jp		z, resetRam
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   713
+:		ld		sp, (onSP)
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
   714
		call	j_resetStacks
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   715
		xor		a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   716
		ld		(MenuCurrent), a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   717
		call	refreshSystemRAM
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   718
		call	PowerOn
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   719
		call	j_SetExecutionPermissionsAndDeleteOldApps
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   720
		bit		cmdExec, (iy+cmdFlags)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   721
		call	nz, j_SetupLastEntryEditResetFlags
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   722
		ei
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   723
		jp		Mon
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   724
restoreToPoweredOn:
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   725
		bit		alt_On, (iy+hookflags1)
24
12b896331796 More cleanup.
brandonlw
parents: 23
diff changeset
   726
		call	nz, j_ExecuteONSCRPT
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   727
		ld		a, 8
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   728
		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   729
		ld		a, 8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   730
		out		(3), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   731
		pop		af
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   732
		out		(3), a
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
   733
		call	j_RstrOScreen
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   734
		pop		de
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   735
		pop		de
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   736
		pop		de
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   737
		set		APDRunning, (hl)
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   738
		call	PowerOn
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   739
		ex		af, af'
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   740
		exx
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   741
		ei
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   742
		reti
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   743
SetOnInterruptFlag:
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   744
		set		onInterrupt, (iy+onFlags)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   745
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   746
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   747
HookRAMAndPowerOn:
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   748
		ld		a, 76h
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   749
		out		(4), a
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   750
		ld		a, 0C0h
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   751
		out		(0), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   752
		in		a, (2)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   753
		and		80h
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   754
		ld		a, 41h
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   755
		jr		z, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   756
		ld		a, 1
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   757
		out		(20h), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   758
		xor		a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   759
		out		(0Fh), a
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   760
		ld		a, 81h
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   761
+:		out		(7), a
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   762
		xor		a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   763
		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   764
		ld		a, 8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   765
		out		(3), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   766
		pop		af
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   767
		out		(3), a
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   768
		ld		iy, flags
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   769
		call	NZIf83Plus
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   770
		call	z, j_ResetIOPorts
22
dea09e588bf1 Cleanup of page 0's boot.asm.
brandonlw
parents: 21
diff changeset
   771
		ld		hl, (RAMChecksum)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   772
		ld		de, 0A55Ah
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   773
		call	CpHLDE
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   774
		jp		z, doFunkyTurnOnFromA55AChecksum
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   775
		call	NZIf83Plus
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   776
		jr		z, {+}
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   777
		;The loading of B here is to see if the boot code sets it to 1.
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   778
		;This indicates a change in LCD hardware and requires a different contrast setting.
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   779
		ld		b, 0
11
fea1578031ed Cleanup to page 0.
brandonlw
parents: 10
diff changeset
   780
		B_CALL(_getHardwareVersion)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   781
		bit		0, b
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   782
		ld		a, 1Fh
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   783
		jr		z, {++}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   784
		ld		a, 1Ch
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   785
		jr		{++}
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   786
+:		ld		a, 17h
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   787
++:		ld		(contrast), a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   788
		call	calculateRAMChecksum
22
dea09e588bf1 Cleanup of page 0's boot.asm.
brandonlw
parents: 21
diff changeset
   789
		ld		de, (RAMChecksum)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   790
		call	CpHLDE
25
fab1bedd3281 Commit some experimental commented-out code for 84+CSE detection and booting
brandonlw
parents: 24
diff changeset
   791
		jr		nz, resetRam
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   792
		dec		de
22
dea09e588bf1 Cleanup of page 0's boot.asm.
brandonlw
parents: 21
diff changeset
   793
		ld		(RAMChecksum), de
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   794
		call	j_SetExecutionPermissions
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   795
		call	PreviousContext_CloseAnyOpenMenu
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   796
		ld		a, 0Bh
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   797
		out		(3), a
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   798
		res		apdWarmStart, (iy+apdFlags)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   799
		call	forcecmd
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   800
		jp		HandleONPressed_WasOff
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   801
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   802
resetRam:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   803
		di
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   804
		ld		hl, 8000h
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   805
		ld		de, 8001h
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   806
		ld		bc, 7FFFh
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   807
		ld		(hl), 0
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   808
		ldir
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   809
		ld		hl, 0109h
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   810
		ld		(localLanguage), hl
25
fab1bedd3281 Commit some experimental commented-out code for 84+CSE detection and booting
brandonlw
parents: 24
diff changeset
   811
;#ifdef DEVIATE_FROM_ORIGINAL_FILE
fab1bedd3281 Commit some experimental commented-out code for 84+CSE detection and booting
brandonlw
parents: 24
diff changeset
   812
;		call	NZIfColorModel
fab1bedd3281 Commit some experimental commented-out code for 84+CSE detection and booting
brandonlw
parents: 24
diff changeset
   813
;		jr		z, {+}
fab1bedd3281 Commit some experimental commented-out code for 84+CSE detection and booting
brandonlw
parents: 24
diff changeset
   814
;		set		0, (iy+asm_Flag3)
fab1bedd3281 Commit some experimental commented-out code for 84+CSE detection and booting
brandonlw
parents: 24
diff changeset
   815
;+:
fab1bedd3281 Commit some experimental commented-out code for 84+CSE detection and booting
brandonlw
parents: 24
diff changeset
   816
;#endif
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   817
page0_9DE:
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   818
		ld		a, 0C0h
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   819
		out		(0), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   820
		ld		sp, 0FFF7h
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   821
		call	Page0Call_3EBB
26
fb2b0058e568 Fix hard-coded error handler address.
brandonlw
parents: 25
diff changeset
   822
		ld		hl, monErrHand
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   823
		call	pushErrorHandleR
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   824
		ld		(onSP), sp
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   825
		call	Page0Call_3EC1
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   826
		jp		Page0Call_3EC7
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   827
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   828
page0_9F8:
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   829
		di
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   830
		ld		a, 0C0h	; ''
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   831
		out		(0), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   832
		ld		sp, 0FFF7h
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   833
		ld		hl, 8000h
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   834
		ld		de, 8001h
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   835
		ld		bc, 7FFFh
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   836
		ld		(hl), 0
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   837
		ldir
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   838
		ld		hl, 109h
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   839
		ld		(localLanguage), hl
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   840
		call	Page0Call_3EBB
26
fb2b0058e568 Fix hard-coded error handler address.
brandonlw
parents: 25
diff changeset
   841
		ld		hl, monErrHand
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   842
		call	pushErrorHandleR
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   843
		ld		(onSP), sp
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   844
		call	Page0Call_3EC1
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   845
		jp		Page0Call_3ECD
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   846
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   847
GetKey_ClearScrn_MonForceKey:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   848
		call	GetCSC
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   849
		set		onClearScrn, (iy+onFlags)
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
   850
		call	j_getkey
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
   851
		call	j_ClrScrn
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   852
		res		onClearScrn, (iy+onFlags)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   853
		jp		monForceKey
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   854
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   855
calculateRAMChecksum:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   856
		push	ix
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   857
		ld		ix, 9D95h
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   858
		ld		bc, 60DBh
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   859
		ld		hl, 11h
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   860
		ld		d, h
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   861
page0_A47:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   862
		ld		e, (ix+0)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   863
		inc		ix
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   864
		add		hl, de
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   865
		dec		bc
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   866
		ld		a, c
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   867
		or		b
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   868
		jr		nz, page0_A47
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   869
		ld		e, d
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   870
		ex		de, hl
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   871
		sbc		hl, de
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   872
		pop		ix
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   873
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   874
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   875
forcecmd:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   876
		call	CanAlphIns
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   877
		res		textInverse, (iy+textFlags)
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
   878
		call	j_Disp
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
   879
		res		cmdExec, (iy+cmdFlags)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   880
		ld		a, appStart
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   881
		jp		newContext0
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   882
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   883
bootCalc:
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   884
		call	SetSlowSpeed
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   885
		ld		a, 77h
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   886
		out		(4), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   887
		ld		b, 0
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   888
		ld		sp, 0FDFAh
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   889
page0_A78:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   890
		djnz	$
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   891
		ld		ix, 1
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   892
		add		ix, sp
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   893
		ld		sp, ix
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   894
		jr		nc, page0_A78
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   895
		ld		sp, 0FFC5h
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   896
		in		a, (2)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   897
		and		80h ; ''
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   898
		jr		z, page0_A91
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   899
		ld		a, 1
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   900
		out		(20h), a
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   901
page0_A91:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   902
		ld		a, 77h ; 'w'
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   903
		out		(4), a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   904
		im	1
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   905
		ld		a, 0C0h	; ''
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   906
		out		(0), a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   907
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   908
RAMUnhookedWaitForPowerOn:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   909
		ld		a, 37h ; '7'
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   910
		out		(4), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   911
		sub		a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   912
		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   913
		ld		a, 8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   914
		out		(3), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   915
		pop		af
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   916
		out		(3), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   917
		ld		a, 11h
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   918
		out		(3), a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   919
		ei
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   920
		halt
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   921
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   922
lcd_busy:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   923
		push	af
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   924
page0_AAF:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   925
		in		a, (2)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   926
		and		2
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   927
		jr		z, page0_AAF
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   928
		pop		af
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   929
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   930
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   931
page0_AB7:
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   932
TurnOffLCD:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   933
		ld		a, 2
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   934
page0_AB9:
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   935
		push	af
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   936
loop:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   937
		in		a, (2)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   938
		and		2
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   939
		jr		z, loop
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   940
		pop		af
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   941
		out		(10h), a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   942
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   943
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   944
page0_AC4:
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   945
smallDelay:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   946
		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   947
		inc		hl
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   948
		dec		hl
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   949
		pop		af
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   950
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   951
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   952
page0_AC9:
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   953
slowDelay:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   954
		ld		a, 0FFh
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   955
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   956
slowDelayA:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   957
		push	af
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   958
		call	forceSlowSpeed
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   959
		pop		af
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   960
delayLoop:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   961
		call	smallDelay
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   962
		dec		a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   963
		jr		nz, delayLoop
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   964
		call	restorePreviousSpeed
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   965
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   966
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   967
PowerOn:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   968
		ld		a, 0Bh
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   969
		out		(3), a
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
   970
		call	j_LCD_DRIVERON
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   971
		call	Chk_Batt_Low_2
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   972
		ret		nz
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   973
		call	refreshSystemRAM
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   974
		in		a, (2)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   975
		bit		0, a
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
   976
		jp		z, PowerOff._skipRAMChecksum
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   977
sub_AEF:
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   978
		call	j_ClearScreen_SetupAPDFromPowerOn
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   979
		call	forcecmd
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
   980
		jp		j_DisplayLowBattRecommendChange
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   981
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   982
Chk_Batt_Low_2:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   983
		call	refreshSystemRAM
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   984
Chk_Batt_Low:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   985
		ld		a, 76h ; 'v'
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   986
		out		(4), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   987
		ld		a, 0F6h	; '򧍊
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   988
		out		(4), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   989
		ld		b, 5
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
   990
longerDelay:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   991
		call	slowDelay
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
   992
		djnz	longerDelay
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   993
		set		5, (iy+18h)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   994
		in		a, (2)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   995
		bit		0, a
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   996
		jr		nz, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   997
		res		5, (iy+18h)
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
   998
+:		ld		a, 76h ; 'v'
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
   999
		out		(4), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1000
		ld		a, 0Ah
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1001
		call	slowDelayA
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1002
		ld		a, 76h ; 'v'
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1003
		out		(4), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1004
		bit		5, (iy+18h)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1005
		ret
24
12b896331796 More cleanup.
brandonlw
parents: 23
diff changeset
  1006
12b896331796 More cleanup.
brandonlw
parents: 23
diff changeset
  1007
.module	RefreshSystemRAM
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
  1008
refreshSystemRAM:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1009
		ld		bc, 2710h
24
12b896331796 More cleanup.
brandonlw
parents: 23
diff changeset
  1010
		ld		hl, ramStart
12b896331796 More cleanup.
brandonlw
parents: 23
diff changeset
  1011
-:		ld		a, (hl)
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1012
		ld		(hl), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1013
		dec		bc
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1014
		ld		a, b
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1015
		or		c
24
12b896331796 More cleanup.
brandonlw
parents: 23
diff changeset
  1016
		jr		nz, {-}
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1017
		ret
24
12b896331796 More cleanup.
brandonlw
parents: 23
diff changeset
  1018
.endmodule
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1019
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
  1020
doFunkyTurnOnFromA55AChecksum:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1021
		ld		hl, 0
22
dea09e588bf1 Cleanup of page 0's boot.asm.
brandonlw
parents: 21
diff changeset
  1022
		ld		(RAMChecksum), hl
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1023
		ld		sp, (onSP)
24
12b896331796 More cleanup.
brandonlw
parents: 23
diff changeset
  1024
		ld		iy, flags
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1025
		call	Page0Call_3EE5
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1026
		call	PreviousContext_CloseAnyOpenMenu
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1027
		call	forcecmd
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
  1028
		res		apdWarmStart, (iy+apdFlags)
38
a4c5f839b738 Cleanup of _Mon. This sucked a lot.
brandonlw
parents: 37
diff changeset
  1029
		bit		cmdExec, (iy+cmdFlags)
41
9ef17625274f Finished _newContext and other page 0 cleanup. Still lots left to go...
brandonlw
parents: 40
diff changeset
  1030
		call	nz, j_SetupLastEntryEditResetFlags
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1031
		ld		a, 0Bh
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1032
		out		(3), a
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
  1033
		call	j_LCD_DRIVERON
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
  1034
		set		onRunning, (iy+onFlags)
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1035
		call	Chk_Batt_Low_2
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1036
		call	z, sub_AEF
19
271dfee8e3ad Set all known flags -- I'm amazed this actually worked.
brandonlw
parents: 16
diff changeset
  1037
		bit		alt_On, (iy+hookflags1)
24
12b896331796 More cleanup.
brandonlw
parents: 23
diff changeset
  1038
		call	nz, j_ExecuteONSCRPT
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1039
		ei
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1040
		jp		Mon
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1041
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1042
PreviousContext_CloseAnyOpenMenu:
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1043
		call	IsInMenu
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1044
		jr		z, PreviousContext
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1045
		xor		a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1046
		ld		(MenuCurrent), a
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
  1047
		call	j_rstrpartial
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1048
PreviousContext:
16
27ca02d0d8aa Give meaningful names to the page 0 calls we know about so far.
brandonlw
parents: 13
diff changeset
  1049
		call	j_PrevContext
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1050
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1051
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1052
IsInMenu:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1053
		ld		b, a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1054
		ld		a, (MenuCurrent)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1055
		or		a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1056
		ld		a, b
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1057
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1058
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1059
SetSlowSpeed:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1060
		call	NZIf83Plus
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1061
		ret		nz
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1062
		jr		{+}
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
  1063
forceSlowSpeed:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1064
		call	NZIf83Plus
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1065
		ret		nz
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1066
		in		a, (20h)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1067
		ld		(oldSESpeed), a
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1068
+:		push	af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1069
		xor		a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1070
		out		(20h), a
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1071
		pop		af
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1072
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1073
7
89b82476a75f Get rid of (most) of the godawful IDA comments.
brandonlw
parents: 6
diff changeset
  1074
restorePreviousSpeed:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1075
		call	NZIf83Plus
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1076
		ret		nz
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1077
		ld		a, (oldSESpeed)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1078
		and		1
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1079
		out		(20h), a
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1080
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1081
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1082
SetExSpeed:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1083
		or		a
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1084
SetSpeed_NZForFast:
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1085
		jr		z, SetSlowSpeed
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1086
SetFastSpeed:
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1087
		push	af
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1088
		call	NZIf83Plus
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1089
		jr		nz, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1090
		ld		a, 1
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1091
		out		(20h), a
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1092
+:		pop		af
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1093
		ret
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1094
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1095
page0_BBD:
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1096
		pop		af
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1097
		push	hl
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1098
		ld		hl, SEspeed
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1099
		dec		(hl)
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1100
		pop		hl
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1101
		call	NZIf83Plus
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1102
		jr		nz, {+}
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1103
		and		1
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1104
		out		(20h), a
23
5252151efccf More cleanup
brandonlw
parents: 22
diff changeset
  1105
+:		pop		af
8
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1106
		pop		af
795326a8c258 More formatting cleanup.
brandonlw
parents: 7
diff changeset
  1107
		pop		af
4
59f60baeaf6a Initial commit
brandonlw
parents:
diff changeset
  1108
		ret