Cleanup of _Mon. This sucked a lot.
authorbrandonlw
Thu, 15 May 2014 05:17:30 -0400
changeset 38 a4c5f839b738
parent 37 9cdbb6464f89
child 39 4651e87022c7
Cleanup of _Mon. This sucked a lot.
source/page00/jump_table.asm
source/page00/math_var.asm
source/page00/system.asm
source/page01/initial.asm
source/page02/initial.asm
source/page03/initial.asm
source/page04/initial.asm
source/page05/initial.asm
source/page06/initial.asm
source/page07/initial.asm
source/page78/initial.asm
source/page79/initial.asm
source/page7B/initial.asm
source/ti83plus.inc
--- a/source/page00/jump_table.asm	Thu May 15 01:54:30 2014 -0400
+++ b/source/page00/jump_table.asm	Thu May 15 05:17:30 2014 -0400
@@ -2558,7 +2558,7 @@
 j_RunIndicOn:                         
 		call    sNameEq
 		.branch	 RunIndicOn
-j_call_rawkey_hook:                         
+j_call_rawkey_hook:
 		call    sNameEq
 		.branch	 call_rawkey_hook
 j_PULLDOWNCHK:                         
--- a/source/page00/math_var.asm	Thu May 15 01:54:30 2014 -0400
+++ b/source/page00/math_var.asm	Thu May 15 05:17:30 2014 -0400
@@ -2885,34 +2885,31 @@
 		bit		drawingGraph, (iy+graphFlags)
 		ret
 
-; =============== S U B	R O U T	I N E =======================================
-
-
-page0_172F:
+isPtrHLA2ByteTok:
 		ld		a, (hl)
-
 isA2ByteTok:
 		push	bc
 		push	hl
-		ld		hl, unk_173E
-		ld		bc, 0Ah
+		ld		hl, _2ByteTokTable
+		ld		bc, _2ByteTokTableEnd-_2ByteTokTable
 		or		a
 		cpir
 		pop		hl
 		pop		bc
 		ret
-unk_173E:
-		.db		5Ch	; \
-		.db		5Dh	; ]
-		.db		5Eh	; ^
-		.db		60h	; `
-		.db		61h	; a
-		.db		62h	; b
-		.db		63h	; c
-		.db		7Eh	; ~
-		.db		0BBh	; ۍ
-		.db		0AAh	; ʍ
-; ---------------------------------------------------------------------------
+_2ByteTokTable:
+		.db		5Ch
+		.db		5Dh
+		.db		5Eh
+		.db		60h
+		.db		61h
+		.db		62h
+		.db		63h
+		.db		7Eh
+		.db		0BBh
+		.db		0AAh
+_2ByteTokTableEnd:
+
 
 GETLASTENTRY:
 		ld		hl, 8E2Ah
--- a/source/page00/system.asm	Thu May 15 01:54:30 2014 -0400
+++ b/source/page00/system.asm	Thu May 15 05:17:30 2014 -0400
@@ -33,95 +33,77 @@
 		res		recallingPrgmName, (iy+rclFlag2)
 		res		recallingListName, (iy+rclFlag3)
 		ld		(kbdKey), a
-		bit		0, (iy+2)
-		jr		z, page0_433
+		bit		allowCursor, (iy+plotFlags)
+		jr		z, {+}
 		res		curAble, (iy+curFlags)
 		bit		curOn, (iy+curFlags)
 		call	z, j_BLINKGCUR
 		ld		a, (kbdKey)
-		jr		page0_436
-
-page0_433:
-		call	j_CursorOff
-page0_436:
-		call	j_RunIndicOn
+		jr		{++}
++:		call	j_CursorOff
+++:		call	j_RunIndicOn
 		or		a
-		jr		nz, page0_44D
+		jr		nz, {++}
+		;ON was pressed; now what?
 		bit		appWantIntrpt, (iy+appFlags)
-		jr		nz, page0_448
-
-page0_442:
+		jr		nz, {+}
 		res		onInterrupt, (iy+onFlags)
-		jr		page0_4B2
-
-page0_448:
-		ld		a, 5
+		jr		jpCoorMon
++:		;Return kEnter instead
+		ld		a, kEnter
 		jp		sendKPress
-
-page0_44D:
-		cp		0B4h ; 'ԧ
-		jr		nz, page0_470
-		ld		a, 0CCh	; '̧
+++:		cp		kVarx
+		jr		nz, monNotVarKey
+		ld		a, kTheta
 		call	IsFunctionMode
-		jr		nz, page0_46D
-		ld		a, 0ADh	; 'ͧ
-sub_45A:
+		jr		nz, {+}
+		ld		a, kCapT
 		call	IsParametricMode
-		jr		nz, page0_46D
-		ld		a, 0B1h	; 'ѧ
-page0_461:
+		jr		nz, {+}
+		ld		a, kCapX
 		call	IsFuncMode
-		jr		nz, page0_46D
-		ld		a, 0E8h	; '觍
+		jr		nz, {+}
+		ld		a, kRecn
 		ld		(keyExtend), a
-		ld		a, 0FEh
-page0_46D:
-		ld		(kbdKey), a
-page0_470:
-		res		1, (iy+28h)
-		res		2, (iy+28h)
+		ld		a, kExtendEcho
++:		ld		(kbdKey), a
+monNotVarKey:
+		res		appIgnoreKey, (iy+APIFlg)
+		res		sendKeyStraightTocxMain, (iy+APIFlg)
 		bit		rawKeyHookActive, (iy+hookflags2)
-		jr		z, page0_491
+		jr		z, {+}
 		call	j_call_rawkey_hook
-		bit		1, (iy+28h)
-		jr		nz, page0_4B2
-		bit		2, (iy+28h)
-		jr		z, page0_491
+		bit		appIgnoreKey, (iy+APIFlg)
+		jr		nz, jpCoorMon
+		bit		sendKeyStraightTocxMain, (iy+APIFlg)
+		jr		z, {+}
 		push	af
-		jp		page0_53E
-
-page0_491:
-		cp		3Fh ; '?'
-		jr		z, page0_4A2
+		jp		Mon_CallcxMain
++:		cp		kOff
+		jr		z, {+}
 		call	j_PULLDOWNCHK
-		jr		c, page0_4B2
+		jr		c, jpCoorMon
 		call	j_clrTR
-		jr		c, page0_4B2
-		call	page0_7DE
-page0_4A2:
-		jr		z, sendKPress
-		cp		28h ; '('
-		jr		z, sendKPress
-		cp		29h ; ')'
+		jr		c, jpCoorMon
+		call	IsExternalApp
++:		jr		z, sendKPress
+		cp		kDoug
 		jr		z, sendKPress
-		jr		page0_4D0
-
-page0_4AE:
-		pop		hl
+		cp		kListflag
+		jr		z, sendKPress
+		jr		Mon_Continue
+-:		pop		hl
 		pop		bc
-		djnz	page0_4BA
-
-page0_4B2:
+		djnz	{+}
+jpCoorMon:
 		jp		coorMon
-
-page0_4B5:
+SendProgToEditTocxMain:
 		ld		b, 8
 		ld		hl, progToEdit-1
-page0_4BA:
-		inc		hl
++:		inc		hl
 		ld		a, (hl)
 		or		a
-		jr		z, page0_4B2
+		jr		z, jpCoorMon
 		push	bc
 		push	hl
 		ld		d, 0
@@ -129,212 +111,188 @@
 		call	j_TokToKey
 		call	cxMain
 		res		onInterrupt, (iy+onFlags)
-		jr		page0_4AE
-
-page0_4D0:
-		cp		7Fh ; ''
-		jp		c, page0_595
-		cp		0FEh ; '򧍊
+		jr		{-}
+Mon_Continue:
+		cp		EchoStart
+		jp		c, Mon_HandleNonEchoKey
+		cp		kExtendEcho
 		jr		z, sendKPress
-		cp		0FCh ; '𧍊
+		cp		kExtendEcho2
 		jr		z, sendKPress
-		cp		0FBh ; '󧍊
-		jr		nz, page0_4FA
+		cp		kExtendEcho3
+		jr		nz, _isOtherKey
 		ld		a, (keyExtend)
 		or		a
-		jr		z, page0_4F7
+		jr		z, {+}
 		cp		0Dh
-		jr		c, page0_4F3
-		cp		8Ch ; '̧
-		jr		c, page0_549
-		cp		0A6h ; 'Ƨ
-		jr		nc, page0_549
-
-page0_4F3:
-		ld		a, 0FBh	;
+		jr		c, _isValid3Key
+		cp		8Ch
+		jr		c, Mon_HandleOurselves
+		cp		0A6h
+		jr		nc, Mon_HandleOurselves
+_isValid3Key:
+		ld		a, kExtendEcho3
 		jr		sendKPress
-
-page0_4F7:
-		ld		a, (kbdKey)
-page0_4FA:
-		cp		0EFh ; '留
-		jr		nz, page0_502
-		ld		a, 0A6h	; 'Ƨ
-		jr		page0_510
-
-page0_502:
-		cp		0F9h ; '񧍊
-		jr		c, page0_50A
++:		ld		a, (kbdKey)
+_isOtherKey:
+		cp		0EFh
+		jr		nz, {+}
+		ld		a, 0A6h
+		jr		setKeyExtend
++:		cp		0F9h
+		jr		c, {+}
 		sub		14h
-		jr		page0_510
-
-page0_50A:
-		cp		0F3h ; '󧍊
+		jr		setKeyExtend
++:		cp		0F3h
 		jr		c, sendKPress
-		sub		7Ch ; '|'
-page0_510:
+		sub		7Ch
+setKeyExtend:
 		ld		(keyExtend), a
-		ld		a, 0FEh	; '򧍊
+		ld		a, kExtendEcho
 sendKPress:
-		cp		69h ; 'i'
-		jr		nz, page0_51D
-		ld		a, 0FCh	; '𧍊
-		jr		page0_510
-
-page0_51D:
-		cp		5Bh ; '['
-		jr		nz, page0_525
-		ld		a, 0FDh	; '񧍊
-		jr		page0_510
-
-page0_525:
-		cp		28h ; '('
+		cp		echoStart2
+		jr		nz, {+}
+		ld		a, kExtendEcho2
+		jr		setKeyExtend
++:		cp		echoStart1+1
+		jr		nz, {+}
+		ld		a, 0FDh
+		jr		setKeyExtend
+sendKPress_NamedVar:
++:		cp		kDoug
 		push	af
-		jr		nz, page0_532
+		jr		nz, {+}
 		set		recallingPrgmName, (iy+rclFlag2)
-		ld		a, 0DAh	; 'ڧ
-		jr		page0_53E
-
-page0_532:
-		pop		af
-		cp		29h ; ')'
+		ld		a, kExec
+		jr		Mon_CallcxMain
++:		pop		af
+		cp		kListflag
 		push	af
-		jr		nz, page0_53E
+		jr		nz, Mon_CallcxMain
 		set		recallingListName, (iy+rclFlag3)
-		ld		a, 7Fh ; ''
-page0_53E:
+		ld		a, kListName
+Mon_CallcxMain:
 		call	cxMain
 		res		onInterrupt, (iy+onFlags)
 		pop		af
-		jp		z, page0_4B5
-page0_549:
+		jp		z, SendProgToEditTocxMain
+Mon_HandleOurselves:
 		bit		enableQueue, (iy+rclFlag)
-		jr		z, page0_58E
+		jr		z, Mon_Restart
 		ld		de, (rclQueue)
-page0_553:
 		ld		hl, (editCursor)
 		bit		useRclQueueEnd, (iy+hookflags1)
-		jr		z, page0_560
+		jr		z, {+}
 		ld		hl, (rclQueueEnd)
 		ex		de, hl
-page0_560:
-		call	CpHLDE
-		jr		nc, page0_580
++:		call	CpHLDE
+		jr		nc, Mon_DisableQueueRestart
 		ld		a, (hl)
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		ld		d, 0
 		ld		e, a
-		jr		nz, page0_571
+		jr		nz, {+}
 		ld		d, a
 		inc		hl
 		ld		e, (hl)
-page0_571:
-		bit		useRclQueueEnd, (iy+hookflags1)
-		jr		z, page0_57B
++:		bit		useRclQueueEnd, (iy+hookflags1)
+		jr		z, {+}
 		inc		hl
 		ld		(rclQueue), hl
-page0_57B:
-		call	j_TokToKey
-page0_57E:
++:		call	j_TokToKey
+jpSendKPress:
 		jr		sendKPress
-
-page0_580:
+Mon_DisableQueueRestart:
 		res		enableQueue, (iy+rclFlag)
-		ld		hl, 89F5h
+		ld		hl, flags+textFlags
 		ld		a, (promptIns)
-		res		4, (hl)
+		res		textInsMode, (hl)
 		or		(hl)
 		ld		(hl), a
-page0_58E:
+Mon_Restart:
 		res		useRclQueueEnd, (iy+hookflags1)
 		jp		Mon
-
-page0_595:
-		cp		27h ; '''
-		jr		c, page0_57E
-		cp		5Ah ; 'Z'
-		jr		c, page0_5C2
-		cp		75h ; 'u'
-		jr		nc, page0_5BC
+Mon_HandleNonEchoKey:
+		cp		kApp
+		jr		c, jpSendKPress
+		cp		echoStart1
+		jr		c, Mon_SwitchToStandardContext
+		cp		kEval
+		jr		nc, Mon_SwitchToGraphContextThenPressKey
 		bit		0, (iy+9)
-		jr		nz, page0_57E
-		cp		69h ; 'i'
-		jr		c, page0_5BC
-		cp		6Dh ; 'm'
-		jr		z, page0_5BC
-		cp		69h ; 'i'
-		jr		z, page0_57E
+		jr		nz, jpSendKPress
+		cp		echoStart2
+		jr		c, Mon_SwitchToGraphContextThenPressKey
+		cp		kPen
+		jr		z, Mon_SwitchToGraphContextThenPressKey
+		cp		echoStart2
+		jr		z, jpSendKPress
 		ld		b, a
 		ld		a, (mcxCurApp)
-		cp		44h ; 'D'
+		cp		kGraph
 		ld		a, b
-		jr		nz, page0_57E
-page0_5BC:
+		jr		nz, jpSendKPress
+Mon_SwitchToGraphContextThenPressKey:
 		ld		b, a
-		ld		a, 44h ; 'D'
-		jr		page0_5D0
-
+		ld		a, kGraph
+		jr		{+}
 		push	af
-page0_5C2:
+Mon_SwitchToStandardContext:
 		ld		b, a
-		cp		59h ; 'Y'
-		jr		nz, page0_5D0
+		cp		kNewApps
+		jr		nz, {+}
 		ld		a, (keyExtend)
 		add		a, b
-		cp		5Bh ; '['
+		cp		echoStart1+1
 		jr		nc, JForceCmdNoChar
 		ld		b, a
-page0_5D0:
-		ld		c, a
++:		ld		c, a
 		ld		a, (mcxCurApp)
-		cp		50h ; 'P'
-		jr		nz, page0_5E1
+		cp		kPrgmInput
+		jr		nz, {+}
 		ld		a, b
-		cp		40h ; '@'
+		cp		appStart
 		jr		z, JForceCmdNoChar
-		ld		a, 50h ; 'P'
-		jr		page0_5EA
-
-page0_5E1:
-		cp		52h ; 'R'
+		ld		a, kPrgmInput
+		jr		{++}
++:		cp		kError
 		ld		a, c
-		jr		nz, page0_5EA
-		cp		40h ; '@'
-		jr		nz, page0_58E
-page0_5EA:
-		call	newContext0
+		jr		nz, {++}
+		cp		appStart
+		jr		nz, Mon_Restart
+++:		call	newContext0
 		ld		a, b
-		jp		page0_525
+		jp		sendKPress_NamedVar
 
 JForceCmdNoChar:
 		xor		a
 JForceCmd:
 		ld		b, a
 		ld		sp, (onSP)
-		res		6, (iy+0Ch)
+		res		cmdExec, (iy+cmdFlags)
 		call	SetFastSpeed
-		ld		a, 40h ; '@'
+		ld		a, appStart
 		call	newContext0
 		ld		a, b
-		cp		0DAh ; 'ڧ
-		jr		nz, page0_60D
-		ld		a, 28h ; '('
-page0_60A:
-		jp		sendKPress
-
-page0_60D:
-		cp		7Fh ; ''
-		jr		nz, page0_60A
-		ld		a, 29h ; ')'
-		jr		page0_60A
+		cp		kExec
+		jr		nz, {+}
+		ld		a, kDoug
+-:		jp		sendKPress
++:		cp		kListName
+		jr		nz, {-}
+		ld		a, kListflag
+		jr		{-}
 
 sysErrHandler:
 		ld		sp, (onSP)
-		ld		a, 52h ; 'R'
+		ld		a, kError
 		call	newContext
 		jp		Mon
 
+#ifndef DEVIATE_FROM_ORIGINAL_FILE
+;We don't need this, I don't think.
 		ret
+#endif
 
 newContext:
 		ld		c, a
@@ -352,7 +310,7 @@
 
 newContext0:
 		res		appRetKeyOff, (iy+APIFlg)
-		ld		hl, 859Ah
+		ld		hl, mcxCurApp
 		cp		(hl)
 		jr		nz, page0_64E
 		cp		44h ; 'D'
@@ -362,13 +320,11 @@
 		call	j_GRPUTAWAY
 		pop		bc
 		ret
-
 page0_647:
 		cp		40h ; '@'
 		jr		z, page0_64E
 		ld		b, 27h ; '''
 		ret
-
 page0_64E:
 		push	bc
 		push	af
@@ -380,13 +336,12 @@
 		push	af
 		xor		a
 		jr		page0_664
-
 page0_65B:
 		push	af
 page0_65C:
 		sub		40h ; '@'
 		jr		nz, page0_664
-		res		6, (iy+0Ch)
+		res		cmdExec, (iy+cmdFlags)
 page0_664:
 		call	Page0Call_3F51
 		pop		af
@@ -414,7 +369,7 @@
 		cp		52h ; 'R'
 		jr		z, page0_69E
 		call	cxPPutAway
-		call	page0_7DE
+		call	IsExternalApp
 		call	z, SetFastSpeed
 page0_69E:
 		ld		a, (mcxCurApp)
@@ -425,7 +380,7 @@
 		jr		nz, page0_6B4
 		call	j_POPCX
 		call	sub_73D
-		call	page0_7DE
+		call	IsExternalApp
 		call	z, SetFastSpeed
 page0_6B4:
 		ld		hl, 858Dh
@@ -440,7 +395,6 @@
 		jr		nz, page0_6CE
 		call	Page0Call_3F63
 		jr		page0_707
-
 page0_6CE:
 		cp		44h ; 'D'
 		call	z, Page0Call_3F63
@@ -448,7 +402,6 @@
 		set		6, (iy+1Dh)
 		set		7, (iy+1Dh)
 		jr		page0_707
-
 page0_6DF:
 		call	page0_17DB
 		call	CheckSplitFlag
@@ -603,10 +556,10 @@
 		ld		(mcxPage), a
 		ret
 
-page0_7DE:
+IsExternalApp:
 		ld		b, a
 		ld		a, (mcxCurApp)
-		cp		58h ; 'X'
+		cp		kExtApps
 		ld		a, b
 		ret
 
@@ -774,7 +727,7 @@
 		call	refreshSystemRAM
 		call	sub_ADA
 		call	Page0Call_3E97
-		bit		6, (iy+0Ch)
+		bit		cmdExec, (iy+cmdFlags)
 		call	nz, Page0Call_3E9D
 		ei
 		jp		Mon
@@ -937,7 +890,7 @@
 		call	CanAlphIns
 		res		textInverse, (iy+textFlags)
 		call	j_Disp
-		res		6, (iy+0Ch)
+		res		cmdExec, (iy+cmdFlags)
 		ld		a, 40h ; '@'
 		jp		newContext0
 
@@ -1088,7 +1041,7 @@
 		call	PreviousContext_CloseAnyOpenMenu
 		call	forcecmd
 		res		apdWarmStart, (iy+apdFlags)
-		bit		6, (iy+0Ch)
+		bit		cmdExec, (iy+cmdFlags)
 		call	nz, Page0Call_3E9D
 		ld		a, 0Bh
 		out		(3), a
--- a/source/page01/initial.asm	Thu May 15 01:54:30 2014 -0400
+++ b/source/page01/initial.asm	Thu May 15 05:17:30 2014 -0400
@@ -6166,7 +6166,7 @@
 JForceGraphKey:
 		ld		b, a
 		ld		sp, (onSP)
-		res		6, (iy+0Ch)
+		res		cmdExec, (iy+cmdFlags)
 		ld		a, 44h ; 'D'
 		call	newContext0
 		jp		sendKPress
--- a/source/page02/initial.asm	Thu May 15 01:54:30 2014 -0400
+++ b/source/page02/initial.asm	Thu May 15 05:17:30 2014 -0400
@@ -2599,7 +2599,7 @@
 
 p02loc_4D42:
 		call	CMP_NUM_INIT
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		z, p02loc_4D58
 		call	IsRecursiveMode
 		jr		z, p02loc_4D58
@@ -2630,7 +2630,7 @@
 		jr		nz, p02loc_4D9C
 
 p02loc_4D7D:
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		z, p02loc_4D89
 		bit		webMode, (iy+seqFlags)
 		jr		nz, p02loc_4D95
@@ -5696,7 +5696,7 @@
 		or		c
 		jr		z, p02loc_5E53
 		dec		bc
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		jr		nz, p02loc_5E43
 		inc		hl
 		dec		de
@@ -6504,7 +6504,7 @@
 p02loc_628B:
 		pop		hl
 		ld		bc, (OP6M)
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		jr		nz, p02loc_6297
 		inc		hl
 		inc		bc
@@ -6647,7 +6647,7 @@
 		sbc		hl, de
 		pop		hl
 		jr		nc, p02loc_6367
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		jr		nz, p02loc_635F
 		inc		hl
 		inc		ix
@@ -7225,7 +7225,7 @@
 		jr		nz, p02loc_663A
 		call	IsRecursiveMode
 		jp		z, p02loc_66D3
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		nz, p02loc_663A
 		call	page0_172A
 		jp		z, p02loc_66D3
--- a/source/page03/initial.asm	Thu May 15 01:54:30 2014 -0400
+++ b/source/page03/initial.asm	Thu May 15 05:17:30 2014 -0400
@@ -1442,12 +1442,6 @@
 
 
 CallCommon:
-
-
-
-
-
-
 		cp		9
 		jr		nz, p03loc_482E
 		set		5, (iy+5)
--- a/source/page04/initial.asm	Thu May 15 01:54:30 2014 -0400
+++ b/source/page04/initial.asm	Thu May 15 05:17:30 2014 -0400
@@ -1136,7 +1136,7 @@
 
 CentCursor:
 		; Regraph+3Ap ...
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		ret		nz
 		push	hl
 		push	af
@@ -1359,7 +1359,7 @@
 
 p04loc_4652:
 		; ForceGraphKeypress+A6j
-		set		0, (iy+2)
+		set		allowCursor, (iy+plotFlags)
 		ld		a, 5
 		call	ForceGraphKeypress
 ; End of function ForceGraphKeypress
@@ -1457,7 +1457,7 @@
 ; START	OF FUNCTION CHUNK FOR ForceGraphKeypress
 
 p04loc_46FA:
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		nz, p04loc_4706
 		ld		hl, (freeSaveY)
 		ld		(curGY), hl
@@ -1470,7 +1470,7 @@
 		bit		graphHookActive, (iy+hookflags3)
 		call	nz, Page0Call_330F
 		ret		nz
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		z, p04loc_474E
 		ld		a, (curPlotNumber)
 		or		a
@@ -1482,7 +1482,7 @@
 		jr		z, p04loc_474E
 		ld		hl, (EQS)
 		ld		(FPS), hl
-		res		0, (iy+2)
+		res		allowCursor, (iy+plotFlags)
 		set		2, (iy+17h)
 		push	bc
 		push	af
@@ -1601,7 +1601,7 @@
 		ld		a, (curGStyle)
 		cp		4Dh ; 'M'
 		jr		z, p04loc_4811
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		z, p04loc_4817
 		cp		5
 		jr		z, p04loc_4811
@@ -1778,7 +1778,7 @@
 		ret		z
 		cp		5
 		jp		z, PutXY
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		z, p04loc_4948
 		ld		a, (curPlotNumber)
 		or		a
@@ -1851,7 +1851,7 @@
 		set		6, (iy+1Dh)
 		call	IsFunctionMode
 		jr		z, p04loc_498D
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		z, p04loc_498D
 		bit		3, (iy+2)
 		jr		z, p04loc_4983
@@ -1907,7 +1907,7 @@
 		call	j_StoR
 		call	PopRealO1
 		call	j_StoTheta
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jp		z, p04sub_7685
 		bit		3, (iy+2)
 		jr		z, p04loc_49FD
@@ -1928,7 +1928,7 @@
 ; ---------------------------------------------------------------------------
 
 p04loc_4A06:
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jp		z, PutXY
 		call	IsRecursiveMode
 		jr		z, p04loc_4A1F
@@ -1986,7 +1986,7 @@
 		; ForceGraphKeypress+23Ej
 		cp		5
 		jp		nz, p04loc_4ED0
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jp		z, p04loc_4DB3
 		call	j_CursorOff
 		ld		a, (curGStyle)
@@ -2976,7 +2976,6 @@
 		pop		hl
 
 p04loc_507D:
-		; p04sub_465B+A18j
 		res		6, (iy+17h)
 		ld		(curInc), hl
 		bit		2, (iy+17h)
@@ -2991,7 +2990,7 @@
 		call	j_CMPBOXINFO
 		xor		a
 		ld		(curPlotNumber), a
-		set		0, (iy+2)
+		set		allowCursor, (iy+plotFlags)
 		call	FNDSELEQ
 		bit		2, (iy+17h)
 		jr		z, p04loc_50DC
@@ -3126,7 +3125,7 @@
 		set		7, (iy+0)
 		ld		a, 0Bh
 		ld		(curGY2+1), a
-		bit		6, (iy+0Ch)
+		bit		cmdExec, (iy+cmdFlags)
 		jr		nz, p04loc_519C
 		call	IsOnInterruptSet
 		jr		z, p04loc_51A2
@@ -4940,7 +4939,7 @@
 p04sub_5CEA:
 		; ForceGraphKeypress+26Fp ...
 		push	af
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		z, p04loc_5D04
 		push	hl
 		push	de
@@ -4955,7 +4954,7 @@
 		pop		hl
 
 p04loc_5D04:
-		res		0, (iy+2)
+		res		allowCursor, (iy+plotFlags)
 		xor		a
 		ld		(curGStyle), a
 		res		graphCursor, (iy+graphFlags)
@@ -5716,7 +5715,7 @@
 		ld		b, a
 
 p04loc_61BB:
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		z, p04loc_61D3
 		bit		3, (iy+2)
 		jr		z, p04loc_61D3
@@ -5933,7 +5932,7 @@
 
 p04loc_62DF:
 		ld		a, (OP2M)
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		nz, p04loc_62FF
 		cp		6
 		jr		z, p04loc_62FF
@@ -6294,7 +6293,7 @@
 BLINKGCUR:
 		bit		graphCursor, (iy+graphFlags)
 		ret		z
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		nz, p04loc_64AB
 		ld		a, 5
 		bit		graphHookActive, (iy+hookflags3)
@@ -6316,7 +6315,7 @@
 ; ---------------------------------------------------------------------------
 
 NBCURSOR:
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		nz, p04loc_64CF
 		ld		a, 4
 		bit		graphHookActive, (iy+hookflags3)
@@ -6933,7 +6932,7 @@
 		res		6, (iy+18h)
 		res		7, (iy+0)
 		res		grfSChanged, (iy+sGrFlags)
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		nz, p04loc_67C6
 		ld		hl, 8D1Eh
 		ld		(hl), 0
@@ -8215,7 +8214,7 @@
 		jr		z, p04loc_707C
 		call	page0_172A
 		jr		nz, p04loc_7075
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		z, p04loc_707C
 
 p04loc_7075:
@@ -10216,11 +10215,10 @@
 
 
 PDspGrph:
-
 		res		plotLoc, (iy+plotFlags)
 		bit		graphDraw, (iy+graphFlags)
 		call	nz, Regraph
-		bit		6, (iy+0Ch)
+		bit		cmdExec, (iy+cmdFlags)
 		jr		z, p04loc_7ADA
 		call	Bit_VertSplit
 		jr		z, p04loc_7AD4
--- a/source/page05/initial.asm	Thu May 15 01:54:30 2014 -0400
+++ b/source/page05/initial.asm	Thu May 15 05:17:30 2014 -0400
@@ -5083,7 +5083,7 @@
 		call	j_ClrScrn
 
 p05loc_5BC3:
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		nz, p05sub_5BE9
 		bit		2, (iy+17h)
 		jr		nz, p05sub_5BE9
--- a/source/page06/initial.asm	Thu May 15 01:54:30 2014 -0400
+++ b/source/page06/initial.asm	Thu May 15 05:17:30 2014 -0400
@@ -139,7 +139,7 @@
 		ld		(mcxCurApp), a
 
 Page06_3A29:
-		res		6, (iy+0Ch)
+		res		cmdExec, (iy+cmdFlags)
 		set		grfSplitOverride, (iy+sGrFlags)
 		ld		hl, p06loc_4172
 		call	AppInit
@@ -339,7 +339,7 @@
 
 p06loc_426A:
 		ld		hl, (editTail)
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		jr		nz, p06loc_4273
 		dec		bc
 
@@ -508,7 +508,7 @@
 		jr		z, p06sub_4369
 		push	hl
 		dec		hl
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		pop		hl
 		jr		nz, p06sub_4369
 		push	hl
@@ -550,7 +550,7 @@
 		ld		de, (editBtm)
 		call	CpHLDE
 		ret		z
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		ld		d, 0
 		jr		nz, p06sub_4391
 		push	hl
@@ -786,7 +786,7 @@
 		; rclToQueue+F5p
 		ld		d, 0
 		ld		e, (hl)
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		ld		a, e
 		ret		nz
 		ld		d, a
@@ -1310,7 +1310,7 @@
 		jr		z, p06loc_46F4
 		push	hl
 		dec		hl
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		pop		hl
 		jr		nz, p06loc_46F4
 		dec		hl
@@ -1619,7 +1619,7 @@
 		dec		hl
 		push	hl
 		dec		hl
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		pop		hl
 		ld		d, 0
 		ld		e, (hl)
@@ -3006,7 +3006,7 @@
 		jr		z, p06loc_5204
 		pop		af
 		dec		hl
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		push	af
 		jr		z, p06loc_5204
 		inc		hl
@@ -3039,7 +3039,7 @@
 		jp		p, p06loc_524E
 		ld		(fmtLeft), hl
 		ld		hl, (chkDelPtr1)
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		ld		de, (fmtIndex)
 		dec		de
 		inc		hl
@@ -3080,7 +3080,7 @@
 		pop		hl
 		pop		bc
 		push	af
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		dec		bc
 		inc		hl
 		jr		nz, p06loc_528B
@@ -5243,7 +5243,7 @@
 		cp		4
 		jr		nz, locret_5F44
 		ld		a, 2Ah ; '*'
-		bit		6, (iy+0Ch)
+		bit		cmdExec, (iy+cmdFlags)
 		call	z, bufQueueChar
 		ld		c, (hl)
 		inc		hl
@@ -5264,7 +5264,7 @@
 
 p06loc_5F3B:
 		ld		a, 2Ah ; '*'
-		bit		6, (iy+0Ch)
+		bit		cmdExec, (iy+cmdFlags)
 		call	z, bufQueueChar
 
 locret_5F44:
--- a/source/page07/initial.asm	Thu May 15 01:54:30 2014 -0400
+++ b/source/page07/initial.asm	Thu May 15 05:17:30 2014 -0400
@@ -6473,7 +6473,7 @@
 		jr		nz, p07loc_5DB1
 		call	ZifRclHandler
 		jr		z, p07loc_5DA8
-		call	page0_7DE
+		call	IsExternalApp
 		call	z, cxPutAway2
 
 p07loc_5DA8:
@@ -9251,7 +9251,7 @@
 ; ---------------------------------------------------------------------------
 
 p07loc_6D49:
-		res		6, (iy+0Ch)
+		res		cmdExec, (iy+cmdFlags)
 		call	CleanAll
 		ld		a, (errNo)
 		cp		31h ; '1'
@@ -9353,7 +9353,7 @@
 		ld		sp, (onSP)
 		call	j_resetStacks
 		set		7, (iy+0Ch)
-		res		6, (iy+0Ch)
+		res		cmdExec, (iy+cmdFlags)
 		ld		a, (basic_prog+1)
 		cp		3Fh ; '?'
 		jr		z, p07loc_6E5A
@@ -10754,7 +10754,7 @@
 ; ---------------------------------------------------------------------------
 
 p07loc_7724:
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		ld		d, 0
 		ld		e, (hl)
 		inc		hl
--- a/source/page78/initial.asm	Thu May 15 01:54:30 2014 -0400
+++ b/source/page78/initial.asm	Thu May 15 05:17:30 2014 -0400
@@ -1670,7 +1670,7 @@
 		pop		af
 		call	j_GRDECODA
 		res		appCurGraphic, (iy+appFlags)
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jp		z, p78loc_4FEF
 		ld		a, (curGStyle)
 		sub		51h ; 'Q'
@@ -4006,18 +4006,6 @@
 
 
 ParseInpGraphReset:
-		; PARSE_FORMULA+24p
-
-
-
-
-
-
-
-
-
-
-
 		call	p78sub_5AC8
 		pop		bc
 		call	PUSH2BOPER
@@ -5403,7 +5391,7 @@
 		ret		nz
 		bit		drawingGraph, (iy+graphFlags)
 		ret		nz
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		ret		nz
 		call	IsRecursiveMode
 		call	nz, SetTblGraphDraw
@@ -6043,7 +6031,7 @@
 		ret		nz
 		call	page0_172A
 		ret		nz
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		ret		nz
 		jp		SetTblGraphDraw
 ; ---------------------------------------------------------------------------
@@ -6475,7 +6463,7 @@
 
 p78sub_66D9:
 		; p78sub_6984+146p
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		nz, p78loc_66E3
 		call	page0_172A
 		ret		z
@@ -6534,7 +6522,7 @@
 		or		h
 		jr		nz, p78loc_6758
 		ld		(unk_9810), de
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		z, p78loc_675E
 		bit		5, (iy+3)
 		jr		z, p78loc_6784
@@ -6550,7 +6538,7 @@
 p78loc_675E:
 		call	page0_172A
 		jr		z, p78loc_6784
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		nz, p78loc_6784
 		ld		hl, (unk_980E)
 		or		a
@@ -9764,7 +9752,7 @@
 p78loc_76FA:
 		bit		7, (iy+0Ch)
 		jp		nz, p78loc_77A6
-		bit		6, (iy+0Ch)
+		bit		cmdExec, (iy+cmdFlags)
 		ret		nz
 		res		0, (iy+9)
 		call	j_resetStacks
@@ -9821,7 +9809,7 @@
 		ld		hl, p78loc_7A99
 		ld		(mcxErrorEP), hl
 		call	j_RSTGFLAGS
-		res		6, (iy+0Ch)
+		res		cmdExec, (iy+cmdFlags)
 		call	j_CleanAll
 		call	j_DeleteTempPrograms
 		jr		p78loc_776B
@@ -10035,7 +10023,7 @@
 p78loc_7905:
 		sub		a
 		ld		(kbdGetKy), a
-		set		6, (iy+0Ch)
+		set		cmdExec, (iy+cmdFlags)
 		set		donePrgm, (iy+doneFlags)
 		call	p78loc_7B21
 		ei
@@ -10043,7 +10031,7 @@
 		bit		homescreenHookActive, (iy+hookflags2)
 		call	nz, Page0Call_2D51
 		call	z, ParseInpLastEnt
-		res		6, (iy+0Ch)
+		res		cmdExec, (iy+cmdFlags)
 		call	j_CleanAll
 		call	j_DeleteTempPrograms
 		ld		a, 0
@@ -10232,9 +10220,9 @@
 		call	j_disarmScroll
 		ret
 p78loc_7A7B:
-		bit		6, (iy+0Ch)
+		bit		cmdExec, (iy+cmdFlags)
 		call	z, j_CleanAll
-		bit		6, (iy+0Ch)
+		bit		cmdExec, (iy+cmdFlags)
 		call	z, j_DeleteTempPrograms
 		ld		a, (unk_89FA)
 		and		0E3h ; '�'
@@ -10306,7 +10294,7 @@
 		call	page0_165F
 		call	FINDPROGSYM
 		call	j_SetEmptyEditPtr
-		res		6, (iy+0Ch)
+		res		cmdExec, (iy+cmdFlags)
 		res		0, (iy+9)
 
 p78loc_7B21:
@@ -11063,7 +11051,7 @@
 		ret		z
 		sub		a
 		ld		(curGStyle), a
-		res		0, (iy+2)
+		res		allowCursor, (iy+plotFlags)
 		res		appCurGraphic, (iy+appFlags)
 		call	j_saveShadow2
 		call	j_rstrShadow2
--- a/source/page79/initial.asm	Thu May 15 01:54:30 2014 -0400
+++ b/source/page79/initial.asm	Thu May 15 05:17:30 2014 -0400
@@ -2442,7 +2442,7 @@
 p79loc_4FF2:
 		call	j_ZifRclHandler
 		jr		z, p79loc_4FFD
-		call	page0_7DE
+		call	IsExternalApp
 		call	z, cxPutAway2
 
 p79loc_4FFD:
@@ -4353,7 +4353,7 @@
 		jr		nz, p79loc_5AB7
 
 p79loc_5A99:
-		res		0, (iy+2)
+		res		allowCursor, (iy+plotFlags)
 		bit		editOpen, (iy+editFlags)
 		jr		z, p79loc_5AAE
 
@@ -4390,7 +4390,7 @@
 		jr		nz, p79loc_5AEA
 		bit		2, (iy+17h)
 		jr		nz, p79loc_5AEA
-		bit		0, (iy+2)
+		bit		allowCursor, (iy+plotFlags)
 		jr		nz, p79loc_5AEA
 		ld		a, (unk_85E5)
 		cp		2Fh ; '/'
@@ -4441,7 +4441,7 @@
 
 p79loc_5B28:
 		; p79sub_58B7+13Cj ...
-		call	page0_7DE
+		call	IsExternalApp
 		jr		nz, p79loc_5B38
 		call	p79sub_5C15
 		call	j_BCALL_4D6B
@@ -4472,7 +4472,7 @@
 		jr		z, p79loc_5B6E
 
 p79loc_5B5B:
-		call	page0_7DE
+		call	IsExternalApp
 		jr		z, p79loc_5B6B
 		call	p79sub_5BD3
 		jr		nc, p79loc_5B70
--- a/source/page7B/initial.asm	Thu May 15 01:54:30 2014 -0400
+++ b/source/page7B/initial.asm	Thu May 15 05:17:30 2014 -0400
@@ -1107,13 +1107,13 @@
 
 DialogKeyHook:
 		add		a, e
-		res		1, (iy+28h)
-		res		2, (iy+28h)
+		res		appIgnoreKey, (iy+APIFlg)
+		res		sendKeyStraightTocxMain, (iy+APIFlg)
 		bit		appAllowContext, (iy+APIFlg)
 		ret		nz
 		call	isContextKey
 		ret		nz
-		set		1, (iy+28h)
+		set		appIgnoreKey, (iy+APIFlg)
 		ret
 
 ; =============== S U B	R O U T	I N E =======================================
@@ -1849,7 +1849,7 @@
 		jr		z, p7Bloc_5AD9
 		push	hl
 		dec		hl
-		call	page0_172F
+		call	isPtrHLA2ByteTok
 		pop		hl
 		jr		nz, p7Bloc_5AD9
 		dec		hl
@@ -6012,7 +6012,7 @@
 		res		monAbandon, (iy+monFlags)
 		res		nocxPutAway, (iy+contextFlags)
 		ld		a, 58h ; 'X'
-		jp		page0_5C2
+		jp		Mon_SwitchToStandardContext
 ; ---------------------------------------------------------------------------
 
 p7Bloc_7088:
@@ -7108,12 +7108,12 @@
 ; ---------------------------------------------------------------------------
 
 SetIgnoreKey:
-		set		1, (iy+28h)
+		set		appIgnoreKey, (iy+APIFlg)
 		ret
 ; ---------------------------------------------------------------------------
 
 SetSendThisKeyBack:
-		set		2, (iy+28h)
+		set		sendKeyStraightTocxMain, (iy+APIFlg)
 		ld		(kbdKey), a
 		ret
 GetHookByte:
--- a/source/ti83plus.inc	Thu May 15 01:54:30 2014 -0400
+++ b/source/ti83plus.inc	Thu May 15 05:17:30 2014 -0400
@@ -2414,6 +2414,7 @@
 monAbandon		equ 4		;1=don't start any long process in put away (#715)
 ;----------------------------------------------------------------------
 plotFlags		equ 2h	;plot generation flags
+allowCursor		equ 0		;0=call _CursorOff in _Mon
 plotLoc 		equ 1		;0=bkup & display, 1=display only
 plotDisp		equ 2		;1=plot is in display, 0=text in display, this also indicates whether graph is being shown or not
 
@@ -2508,6 +2509,7 @@
 
 cmdFlags		equ 0Ch	;command editor flags
 cmdVirgin		equ 5		;1=nothing has been typed in cmd bfr
+cmdExec			equ 6		;1=parser is executing command
 ;----------------------------------------------------------------------
 appFlags		equ 0Dh	;application flags
 appWantIntrpt		equ 0		;1=want ON key interrupts
@@ -2652,12 +2654,12 @@
 ;----------------------------------------------------------------------
 ;There is a flag 27h.
 ;----------------------------------------------------------------------
-APIFlg			equ 28h
-appAllowContext	equ 0		;App wants context changes to happen
-;1 set to ignore a key after returning from rawkeyhook
-;2 set to send this key back?
-kOffPressed		equ 3		;key echo is enabled and kOff pressed
-appRunning		equ 4		;app is currently running
+APIFlg					equ 28h
+appAllowContext			equ 0	;App wants context changes to happen
+appIgnoreKey			equ 1 	;set to ignore a key after returning from rawkeyhook
+sendKeyStraightTocxMain	equ 2	;set to send this key straight to cxMain handler
+kOffPressed				equ 3	;key echo is enabled and kOff pressed
+appRunning				equ 4	;app is currently running
 ;5
 ;6
 appRetKeyOff	equ 7		;1 = GetKey returns kOff when [2nd]+[ON] pressed
@@ -3403,6 +3405,7 @@
 ;THERE ARE 2 OF THESE KEYS; BE CAREFUL WITH USAGE
 ;------------------------------------------------
 kExtendEcho2		equ 0FCh
+kExtendEcho3		equ 0FBh
 
 ;THIS KEY MEANS THAT THE KEY PRESS IS ONE THAT ECHOS
 ;INTO A BUFFER, AND IT IS A 2 BYTE KEY CODE, GO LOOK AT