source/page7B/initial.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...

p7Bsub_50EC:
		ld		hl, {+}
		call	AppInit
		ret
+:		.dw		page7B_512A
		.dw		page7B_57A1
		.dw		page7B_57A2
		.dw		page7B_51CA
		.dw		page7B_57B4
		.dw		page7B_51C9
		.db		0Ah

AppGetCbl:
		set		IDis95h, (iy+linkFlags)
		res		IDis82h, (iy+linkFlags)
		ld		a, (OP1+1)
		cp		5Dh ; ']'
		jr		z, p7Bloc_5117
		res		IDis95h, (iy+linkFlags)
		set		IDis82h, (iy+linkFlags)

p7Bloc_5117:
		di
		res		secondTimerEnabled, (iy+interruptFlags)
		ld		a, 15h
		ld		(sndRecState), a
		call	j_GETVARCMD
		ret
AppGetCalc:
		call	Page0Call_2D87
		jr		p7Bloc_5117

page7B_512A:
		cp		54h ; 'T'
		jp		z, p7Bsub_51D0
		cp		43h ; 'C'
		jp		z, p7Bsub_51D0
		cp		56h ; 'V'
		jp		z, p7Bsub_51D0
		ld		b, a
		ld		a, (unk_986F)
		cp		1
		ld		a, b
		ret		nz
		bit		5, (iy+2Dh)
		jp		nz, p7Bloc_543D
		push	af

p7Bloc_5149:
		pop		af
		call	isContextKey
		ret		z
		cp		3
		jr		z, p7Bloc_5180
		cp		4
		jr		z, p7Bloc_5180
		cp		5
		jr		z, p7Bloc_5180
		cp		40h ; '@'
		jr		z, p7Bloc_5162
		call	j_ProcessBufKeys
		ret
p7Bloc_5162:
		ld		hl, {+}
		call	pushErrorHandleR
		call	p7Bsub_51B4
		call	popErrorHandleR
+:		ld		a, 40h ; '@'
		ld		hl, 8025h
		call	p7Bsub_573A

p7Bloc_5176:
		ld		sp, (unk_801D)
		push	af
		call	j_RunIndicOff
		pop		af
		ret
; ---------------------------------------------------------------------------

p7Bloc_5180:
		push	af
		ld		hl, jErrorHandler
		call	pushErrorHandleR
		call	p7Bsub_51B4
		jr		z, p7Bloc_5191
		call	p7Bsub_51D0
		jr		p7Bloc_519E
; ---------------------------------------------------------------------------

p7Bloc_5191:
		ld		bc, (curRow)
		push	bc
		call	p7Bsub_5270
		pop		bc
		ld		(curRow), bc

p7Bloc_519E:
		call	popErrorHandleR
		call	j_releaseBuffer
		call	p7Bsub_51E6
		call	p7Bsub_536F
		pop		af
		jr		p7Bloc_5176
jErrorHandler:
		pop		af
		ld		a, 52h ; 'R'
		call	newContext
		ret

; =============== S U B	R O U T	I N E =======================================


p7Bsub_51B4:
		call	j_CloseEditEqu
		call	page0_166E
		call	j_ParseInp
		call	EOP1NotReal
		call	p7Bsub_5706
		push	af
		call	z, p7Bsub_56C5
		pop		af
		ret
; End of function p7Bsub_51B4

page7B_51C9:
		ret		nc
page7B_51CA:
		call	j_ZifRclHandler
		call	z, j_rstrUnderMenu

; =============== S U B	R O U T	I N E =======================================


p7Bsub_51D0:
		ld		bc, (curRow)
		push	bc
		call	p7Bsub_5582
		call	p7Bsub_5203
		call	p7Bsub_5591
		pop		bc
		ld		(curRow), bc
		jp		p7Bsub_536F
; End of function p7Bsub_51D0


; =============== S U B	R O U T	I N E =======================================


p7Bsub_51E6:
		set		appTextSave, (iy+appFlags)
		res		appAutoScroll, (iy+appFlags)
		res		textInsMode, (iy+textFlags)
		res		textInverse, (iy+textFlags)
		xor		a
		ld		(winLeft), a
		ld		a, 8
		ld		(winBtm), a
		call	RESETWINTOP
		ret
; End of function p7Bsub_51E6


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5203:
		res		0, (iy+2Eh)
		call	p7Bsub_51E6
		call	j_HomeUp
		ld		hl, ramCode
		xor		a
		ld		(unk_8006), a
		jr		p7Bloc_521E
; ---------------------------------------------------------------------------

p7Bloc_5216:
		ld		hl, 8006h
		inc		(hl)
		pop		hl
		call	p7Bsub_5381

p7Bloc_521E:
		ld		a, (hl)
		inc		hl
		push	hl
		or		a
		jr		nz, p7Bloc_522E
		pop		hl
		call	j_EraseEOW2
		ld		a, 1
		call	p7Bsub_5719
		ret
; ---------------------------------------------------------------------------

p7Bloc_522E:
		cp		6
		jr		z, p7Bloc_5216
		cp		1
		jr		nz, p7Bloc_5242

p7Bloc_5236:
		call	p7Bsub_5348
		ex		de, hl
		call	j_putpsb
		call	p7Bsub_5357
		jr		p7Bloc_5216
; ---------------------------------------------------------------------------

p7Bloc_5242:
		cp		4
		jr		z, p7Bloc_5236
		cp		3
		jr		nz, p7Bloc_524F
		call	p7Bsub_5275
		jr		p7Bloc_5216
; ---------------------------------------------------------------------------

p7Bloc_524F:
		cp		5
		jr		nz, p7Bloc_5259
		call	p7Bsub_525F
		dec		hl
		jr		p7Bloc_5236
; ---------------------------------------------------------------------------

p7Bloc_5259:
		call	p7Bsub_52B2
		jr		p7Bloc_5216
; End of function p7Bsub_5203


; =============== S U B	R O U T	I N E =======================================


p7Bsub_525E:
		inc		hl
; End of function p7Bsub_525E


; =============== S U B	R O U T	I N E =======================================


p7Bsub_525F:
		inc		hl
		xor		a
		ld		(curRow+1), a
		ld		a, (hl)
		add		a, 30h ; '0'
		call	j_PutC
		ld		a, 3Ah ; ':'
		call	j_PutC
		ret
; End of function p7Bsub_525F


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5270:
		call	p7Bsub_536F
		ret		z
		inc		hl
; End of function p7Bsub_5270


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5275:
		xor		a
		ld		(curRow+1), a
		inc		hl
		call	p7Bsub_5349
		ex		de, hl
		call	j_EraseEOL
		ld		a, (hl)
		neg
		add		a, 10h
		push	af
		call	j_putpsb
		call	p7Bsub_56B7
		ld		a, 10h
		call	j_FormEReal
		ld		hl, 848Dh
		pop		af
		cp		c
		jr		nc, p7Bloc_52A5
		ld		(hl), a
		ld		e, a
		ld		d, 0
		add		hl, de
		ld		a, 0CEh	; '�'
		ld		(hl), a
		sbc		hl, de
		jr		p7Bloc_52A6
; ---------------------------------------------------------------------------

p7Bloc_52A5:
		ld		(hl), c

p7Bloc_52A6:
		call	j_putpsb
		call	p7Bsub_5357
		ret
; End of function p7Bsub_5275


; =============== S U B	R O U T	I N E =======================================


p7Bsub_52AD:

		call	p7Bsub_536F
		ret		z
		inc		hl
; End of function p7Bsub_52AD


; =============== S U B	R O U T	I N E =======================================


p7Bsub_52B2:
		xor		a
		ld		(curRow+1), a
		dec		a
		ld		(unk_8019), a
		ld		a, (hl)
		inc		a
		inc		hl
		inc		hl

p7Bloc_52BE:
		dec		a
		jr		nz, p7Bloc_52C9
		ld		a, (curRow+1)
		or		a
		call	nz, p7Bsub_5357
		ret
; ---------------------------------------------------------------------------

p7Bloc_52C9:
		push	af
		call	p7Bsub_534A
		ex		de, hl
		push	de
		ld		a, (hl)
		ld		b, a
		ld		a, (curRow+1)
		add		a, b
		cp		11h
		jr		c, p7Bloc_52E1
		call	p7Bsub_5357
		call	p7Bsub_5328
		ld		a, (hl)
		inc		a

p7Bloc_52E1:
		push	af
		push	hl
		call	p7Bsub_5338
		bit		0, (iy+2Eh)
		jr		z, p7Bloc_52ED
		ld		b, a

p7Bloc_52ED:
		ld		hl, 8019h
		ld		a, (hl)
		inc		(hl)
		cp		b
		pop		hl
		jr		nz, p7Bloc_5304
		bit		0, (iy+2Eh)
		jr		z, p7Bloc_5300
		pop		af
		pop		af
		pop		af
		ret
; ---------------------------------------------------------------------------

p7Bloc_5300:
		set		textInverse, (iy+textFlags)

p7Bloc_5304:
		bit		0, (iy+2Eh)
		call	z, j_putpsb
		res		textInverse, (iy+textFlags)
		pop		af
		bit		0, (iy+2Eh)
		jr		z, p7Bloc_5319
		ld		(curRow+1), a

p7Bloc_5319:
		cp		10h
		jr		nc, p7Bloc_5324
		ld		a, (unk_8019)
		or		a
		call	nz, p7Bsub_5328

p7Bloc_5324:
		pop		hl
		pop		af
		jr		p7Bloc_52BE
; End of function p7Bsub_52B2


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5328:
		bit		0, (iy+2Eh)
		ld		a, 20h ; ' '
		call	z, j_PutMap
		push	hl
		ld		hl, curCol
		inc		(hl)
		pop		hl
		ret
; End of function p7Bsub_5328


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5338:
		ld		hl, 8009h
		ld		a, (unk_8006)
		ld		e, a
		ld		d, 0
		add		hl, de
		ld		b, (hl)
		ld		a, (unk_8007)
		ret
; End of function p7Bsub_5338


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5347:
		inc		hl
; End of function p7Bsub_5347


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5348:
		inc		hl
; End of function p7Bsub_5348


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5349:
		inc		hl
; End of function p7Bsub_5349


; =============== S U B	R O U T	I N E =======================================


p7Bsub_534A:
		push	hl
		call	ldHLind
		ld		de, ramCode
		add		hl, de
		ex		de, hl
		pop		hl
		inc		hl
		inc		hl
		ret
; End of function p7Bsub_534A


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5357:
		bit		0, (iy+2Eh)
		jr		nz, p7Bloc_5365
		ld		a, (curRow+1)
		cp		0Fh
		call	nz, j_EraseEOL

p7Bloc_5365:
		push	hl
		ld		hl, curRow
		inc		(hl)
		inc		hl
		xor		a
		ld		(hl), a
		pop		hl
		ret
; End of function p7Bsub_5357


; =============== S U B	R O U T	I N E =======================================


p7Bsub_536F:
		ld		a, (unk_8006)
		ld		b, a
; End of function p7Bsub_536F


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5373:
		ld		hl, ramCode

p7Bloc_5376:
		dec		b
		ld		a, (hl)
		ret		m
		or		a
		ret		z
		call	p7Bsub_5380
		jr		p7Bloc_5376
; End of function p7Bsub_5373


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5380:
		inc		hl
; End of function p7Bsub_5380


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5381:
		ld		a, (hl)
		sla	a
		add		a, 2
		ld		e, a
		ld		d, 0
		add		hl, de
		ret
; End of function p7Bsub_5381

; ---------------------------------------------------------------------------

DialogStartGetKey:
		ld		a, (hl)
		cp		3
		ret		z
		jr		p7Bloc_53ED
; ---------------------------------------------------------------------------

StartDialog_Override:
		call	SetDialogKeyOverride
		jr		p7Bloc_539F
; ---------------------------------------------------------------------------

StartDialog:
		xor		a

RestartDialog:
		ld		(unk_8033), a
		call	ResDialogKeyOverride
		jr		p7Bloc_539F

p7Bloc_539F:
		set		7, (iy+2Dh)
		xor		a
		ld		(unk_8006), a
		ld		hl, 0
		ld		(curRow), hl
		call	p7Bsub_51D0
		jr		p7Bloc_53C3
; ---------------------------------------------------------------------------

p7Bloc_53B2:
		ld		a, (curRow)
		add		a, b
		ld		(curRow), a
		call	p7Bsub_5380
		ld		a, (unk_8006)
		inc		a
		ld		(unk_8006), a

p7Bloc_53C3:
		ld		(unk_8036), hl
		call	p7Bsub_554B
		jr		z, p7Bloc_53B2
		push	af
		bit		7, (iy+2Dh)
		jr		z, p7Bloc_53E2
		push	hl
		ld		a, (unk_8033)
		ld		hl, 8006h
		cp		(hl)
		pop		hl
		jr		z, p7Bloc_53E2
		jr		c, p7Bloc_53E2
		pop		af
		jr		p7Bloc_53B2
; ---------------------------------------------------------------------------

p7Bloc_53E2:
		res		7, (iy+2Dh)
		pop		af
		or		a
		jr		nz, p7Bloc_53F3

p7Bloc_53EA:
		call	p7Bsub_5589

p7Bloc_53ED:
		call	p7Bsub_536F
		ld		(unk_8036), hl

p7Bloc_53F3:
		push	hl
		res		appCurWord, (iy+appFlags)
		cp		2
		jr		nz, p7Bloc_5402
		set		appCurWord, (iy+appFlags)
		jr		p7Bloc_5429
; ---------------------------------------------------------------------------

p7Bloc_5402:
		cp		3
		jr		nz, p7Bloc_540C
		pop		hl
		call	p7Bsub_5598
		jr		p7Bloc_544F
; ---------------------------------------------------------------------------

p7Bloc_540C:
		push	af
		xor		a
		ld		(curRow+1), a
		pop		af
		cp		4
		jr		z, p7Bloc_5425
		pop		hl
		push	hl
		set		textInverse, (iy+textFlags)
		call	p7Bsub_525E
		res		textInverse, (iy+textFlags)
		jr		p7Bloc_542C
; ---------------------------------------------------------------------------

p7Bloc_5425:
		set		appCurWord, (iy+appFlags)

p7Bloc_5429:
		call	j_CursorOn

p7Bloc_542C:
		call	j_getkey
		res		onInterrupt, (iy+onFlags)
		call	j_CursorOff
		pop		hl
		bit		5, (iy+2Dh)
		jr		z, ForceDialogKeypress

p7Bloc_543D:
		ld		hl, 801Fh
		push	hl
		jp		sFAIL
; ---------------------------------------------------------------------------

ForceDialogKeypress:
		push	af
		ld		hl, (unk_8036)
		ld		a, (hl)
		cp		3
		jp		z, p7Bloc_5149
		pop		af

p7Bloc_544F:
		call	isContextKey
		jr		z, p7Bloc_53ED
		cp		3
		jr		nz, p7Bloc_547F
		call	p7Bsub_55C5
		call	p7Bsub_557A

p7Bloc_545E:
		ld		a, (unk_8006)
		or		a
		jr		z, p7Bloc_53EA
		dec		a
		ld		(unk_8006), a
		call	p7Bsub_536F
		ld		(unk_8036), hl
		call	p7Bsub_554B
		push	af
		ld		a, (curRow)
		sub		b
		ld		(curRow), a
		pop		af
		jr		z, p7Bloc_545E
		jp		p7Bloc_53F3
; ---------------------------------------------------------------------------

p7Bloc_547F:
		cp		4
		jr		nz, p7Bloc_548F

p7Bloc_5483:
		call	p7Bsub_55C5
		call	p7Bsub_557A
		call	p7Bsub_5565
		jp		p7Bloc_53B2
; ---------------------------------------------------------------------------

p7Bloc_548F:
		cp		40h ; '@'
		jr		nz, p7Bloc_549B
		ld		hl, 8025h
		call	p7Bsub_573A
		inc		a
		ret
; ---------------------------------------------------------------------------

p7Bloc_549B:
		cp		5
		jr		nz, p7Bloc_54C4
		ld		a, (hl)
		cp		2
		jr		nz, p7Bloc_54B8
		call	p7Bsub_5338
		ld		(hl), a
		call	p7Bsub_5706
		jr		z, p7Bloc_54B3
		call	p7Bsub_51D0

p7Bloc_54B0:

		jp		p7Bloc_53ED
; ---------------------------------------------------------------------------

p7Bloc_54B3:
		call	p7Bsub_55D3
		jr		p7Bloc_54B0
; ---------------------------------------------------------------------------

p7Bloc_54B8:
		cp		3
		jr		z, p7Bloc_5483

p7Bloc_54BC:
		ld		hl, 8025h
		call	p7Bsub_573A
		xor		a
		ret
; ---------------------------------------------------------------------------

p7Bloc_54C4:
		cp		8Fh ; '�'
		jr		c, p7Bloc_54F0
		cp		96h ; '�'
		jr		nc, p7Bloc_54F0
		sub		8Eh ; '�'
		ld		b, a
		ld		hl, ramCode
		ld		c, 0
		jr		p7Bloc_54DA
; ---------------------------------------------------------------------------

p7Bloc_54D6:
		inc		c
		call	p7Bsub_5380

p7Bloc_54DA:
		ld		a, (hl)
		or		a
		jr		z, p7Bloc_54F0
		cp		5
		jr		nz, p7Bloc_54D6
		inc		hl
		inc		hl
		ld		a, (hl)
		dec		hl
		dec		hl
		cp		b
		jr		nz, p7Bloc_54D6
		ld		a, c
		ld		(unk_8006), a
		jr		p7Bloc_54BC
; ---------------------------------------------------------------------------

p7Bloc_54F0:
		cp		2
		jr		nz, p7Bloc_551B
		call	p7Bsub_55E3
		jr		nz, p7Bloc_5509
		ld		hl, 8009h
		ld		a, (hl)
		or		a
		jr		z, p7Bloc_5548
		dec		(hl)

p7Bloc_5501:
		xor		a
		ld		b, a
		call	p7Bsub_5719
		jp		StartDialog
; ---------------------------------------------------------------------------

p7Bloc_5509:
		ld		a, (hl)
		cp		2
		jr		nz, p7Bloc_5548
		ld		hl, 8007h
		ld		a, (hl)
		or		a
		jr		z, p7Bloc_5548
		dec		(hl)

p7Bloc_5516:
		call	p7Bsub_55D3
		jr		p7Bloc_5548
; ---------------------------------------------------------------------------

p7Bloc_551B:
		cp		1
		jr		nz, p7Bloc_5548
		call	p7Bsub_55E3
		jr		nz, p7Bloc_5534
		ld		a, (unk_8101)
		dec		a
		dec		a
		ld		b, a
		ld		hl, 8009h
		ld		a, (hl)
		cp		b
		jr		nc, p7Bloc_5548
		inc		(hl)
		jr		p7Bloc_5501
; ---------------------------------------------------------------------------

p7Bloc_5534:
		ld		a, (hl)
		cp		2
		jr		nz, p7Bloc_5548
		inc		hl
		ld		a, (hl)
		dec		a
		dec		a
		ld		b, a
		ld		hl, 8007h
		ld		a, (hl)
		cp		b
		jr		nc, p7Bloc_5548
		inc		(hl)
		jr		p7Bloc_5516
; ---------------------------------------------------------------------------

p7Bloc_5548:
		jp		p7Bloc_54B0

; =============== S U B	R O U T	I N E =======================================


p7Bsub_554B:
		ld		a, (unk_8006)
		or		a
		jr		nz, p7Bloc_555C
		call	p7Bsub_55E3
		jr		nz, p7Bloc_555C
		ld		a, (unk_8102)
		ld		b, a
		xor		a
		ret
; ---------------------------------------------------------------------------

p7Bloc_555C:
		ld		a, (hl)
		cp		2
		jr		nz, p7Bsub_5565
		xor		a
		ld		(unk_8007), a
; End of function p7Bsub_554B


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5565:
		inc		hl
		inc		hl
		ld		b, (hl)
		dec		hl
		dec		hl
		ld		a, (hl)
		cp		3
		jr		c, p7Bloc_5571
		ld		b, 1

p7Bloc_5571:
		cp		1
		ret		z
		cp		6
		ret		nz
		ld		b, 0
		ret
; End of function p7Bsub_5565


; =============== S U B	R O U T	I N E =======================================


p7Bsub_557A:
		ld		bc, (curRow)
		ld		(unk_801A), bc
; End of function p7Bsub_557A


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5582:
		ld		a, (unk_8006)
		ld		(unk_801C), a
		ret
; End of function p7Bsub_5582


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5589:
		; p7Bsub_5706+Bp
		ld		bc, (unk_801A)
		ld		(curRow), bc
; End of function p7Bsub_5589


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5591:
		ld		a, (unk_801C)
		ld		(unk_8006), a
		ret
; End of function p7Bsub_5591


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5598:
		call	p7Bsub_5347
		ld		a, (de)
		ld		(winLeftEdge), a
		ld		(curRow+1), a
		call	Page0Call_3753
		call	p7Bsub_56B7
		call	j_OP1toEdit
		call	j_BufToTop
		call	j_fdispEOL
		ld		a, 1
		ld		(unk_986F), a
		ld		a, 58h ; 'X'
		ld		(mcxCurApp), a
		ld		(unk_801D), sp
		call	Mon
		ld		a, 40h ; '@'
		ret
; End of function p7Bsub_5598


; =============== S U B	R O U T	I N E =======================================


p7Bsub_55C5:

		ld		a, (hl)
		cp		5
		ret		nz
		push	hl
		call	p7Bsub_525E
		xor		a
		ld		(curRow+1), a
		pop		hl
		ret
; End of function p7Bsub_55C5


; =============== S U B	R O U T	I N E =======================================


p7Bsub_55D3:

		ld		bc, (curRow)
		push	bc
		call	p7Bsub_52AD
		pop		bc
		ld		(curRow), bc
		jp		p7Bsub_536F
; End of function p7Bsub_55D3


; =============== S U B	R O U T	I N E =======================================


p7Bsub_55E3:
		push	de
		push	hl
		push	af
		ld		hl, ramCode
		ld		a, (hl)
		cp		2
		jr		nz, p7Bloc_55F3
		call	p7Bsub_5347
		ld		a, (de)
		or		a

p7Bloc_55F3:
		pop		hl
		ld		a, h
		pop		hl
		pop		de
		ret
; End of function p7Bsub_55E3

; ---------------------------------------------------------------------------

Page7B_310B:
		push	bc
		push	de
		push	hl
		ld		bc, (curRow)
		push	bc
		set		0, (iy+2Eh)
		push	af
		call	p7Bsub_536F
		ld		a, (hl)
		cp		4
		jr		nz, p7Bloc_5617
		call	p7Bsub_5347
		ex		de, hl
		res		0, (iy+2Eh)
		jr		p7Bloc_561A
; ---------------------------------------------------------------------------

p7Bloc_5617:
		call	p7Bsub_52AD

p7Bloc_561A:
		pop		af
		jr		nc, p7Bloc_562B
		ld		b, (hl)
		ld		a, 20h ; ' '
		set		textInverse, (iy+textFlags)

p7Bloc_5624:
		call	j_PutC
		djnz	p7Bloc_5624
		jr		p7Bloc_5646
; ---------------------------------------------------------------------------

p7Bloc_562B:
		push	hl
		bit		0, (iy+2Eh)
		jr		z, p7Bloc_563E
		call	p7Bsub_5338
		cp		b
		jr		nz, p7Bloc_563E
		set		textInverse, (iy+textFlags)
		jr		p7Bloc_5642
; ---------------------------------------------------------------------------

p7Bloc_563E:
		set		preClrForMode, (iy+newDispF)

p7Bloc_5642:
		pop		hl
		call	j_putpsb

p7Bloc_5646:
		pop		bc
		ld		(curRow), bc
		res		textInverse, (iy+textFlags)
		res		0, (iy+2Eh)
		pop		hl
		pop		de
		pop		bc
		ret
; ---------------------------------------------------------------------------

DialogInit:
		ld		(unk_8003), hl
		ld		hl, 8005h
		ld		(hl), a
		ld		hl, mcxMain
		ld		de, 8025h
		ld		bc, 0Eh
		ldir
		call	p7Bsub_50EC
		in		a, (6)
		ld		hl, DialogKeyHook
		call	SetGetKeyHook

ResDialogCallback:
		res		6, (iy+2Dh)
		ret
; ---------------------------------------------------------------------------

DialogKeyHook:
		add		a, e
		res		appIgnoreKey, (iy+APIFlg)
		res		sendKeyStraightTocxMain, (iy+APIFlg)
		bit		appAllowContext, (iy+APIFlg)
		ret		nz
		call	isContextKey
		ret		nz
		set		appIgnoreKey, (iy+APIFlg)
		ret

; =============== S U B	R O U T	I N E =======================================


SetDialogKeyOverride:
		ld		(unk_801F), hl
		ld		(unk_8021), a
		set		5, (iy+2Dh)
		ret
; End of function SetDialogKeyOverride


; =============== S U B	R O U T	I N E =======================================


ResDialogKeyOverride:
		res		5, (iy+2Dh)
		ret
; End of function ResDialogKeyOverride

; ---------------------------------------------------------------------------

CallDialogCallback:
		bit		6, (iy+2Dh)
		ret		z
		ld		hl, 8022h
		push	hl
		jp		sFAIL
; ---------------------------------------------------------------------------

SetDialogCallback:
		ld		(unk_8022), hl
		ld		(unk_8024), a
		set		6, (iy+2Dh)
		ret

; =============== S U B	R O U T	I N E =======================================


p7Bsub_56B7:
		call	p7Bsub_56D5
		jr		p7Bloc_56BF
; ---------------------------------------------------------------------------

GetDialogNumOP1:
		call	GetDialogNumHL

p7Bloc_56BF:
		rst		20h
		xor		a
		ld		(de), a
		inc		de
		ld		(de), a
		ret
; End of function p7Bsub_56B7


; =============== S U B	R O U T	I N E =======================================


p7Bsub_56C5:
		call	p7Bsub_56D5
		jr		p7Bloc_56CD
; ---------------------------------------------------------------------------

SetDialogNumOP1:
		call	GetDialogNumHL

p7Bloc_56CD:
		ex		de, hl
		ld		hl, OP1
		call	mov9B2
		ret
; End of function p7Bsub_56C5


; =============== S U B	R O U T	I N E =======================================


p7Bsub_56D5:
		ld		a, (unk_8006)
		ld		b, a
		call	p7Bsub_5373
		inc		hl
		inc		hl
		ld		a, (hl)

GetDialogNumHL:
		; p7Bsub_56C5:SetDialogNumOP1p
		ld		h, 0
		ld		l, a
		call	HLTimes9
		ld		de, 8038h
		add		hl, de
		ret
; End of function p7Bsub_56D5

; ---------------------------------------------------------------------------

CopyDialogNum:
		push	bc
		ld		a, b
		call	GetDialogNumOP1
		pop		bc
		ld		a, c
		jr		SetDialogNumOP1
; ---------------------------------------------------------------------------

ErrArgumentO123:
		call	cpop1op2
		jr		nc, p7Bloc_56FC

p7Bloc_56F8:
		jp		ErrArgument
; ---------------------------------------------------------------------------
		ret
; ---------------------------------------------------------------------------

p7Bloc_56FC:
		call	BCALL_4120
		call	cpop1op2
		ret		z
		jr		nc, p7Bloc_56F8
		ret

; =============== S U B	R O U T	I N E =======================================


p7Bsub_5706:
		call	p7Bsub_557A
		ld		a, (unk_8006)
		ld		b, a
		xor		a
		call	p7Bsub_5719
		call	p7Bsub_5589
		ld		a, (unk_8008)
		or		a
		ret
; End of function p7Bsub_5706


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5719:
		ld		(unk_8008), a
		ld		a, (unk_8005)
		or		a
		ret		z
		push	bc
		ld		hl, j_GetFirstInvalidAppPageToB
		ld		de, ramStart
		ld		bc, 3
		ldir
		pop		bc
		ld		a, (unk_8008)
		or		a
		call	ramStart
		ld		(unk_8008), a
		or		a
		ret
; End of function p7Bsub_5719


; =============== S U B	R O U T	I N E =======================================


p7Bsub_573A:
		ld		de, mcxMain
		ld		bc, 14
		ldir
		ret
isContextKey:
		push	hl
		push	bc
		ld		hl, contextKeyTable
		ld		bc, contextKeyTableEnd-contextKeyTable
		cpir
		pop		bc
		pop		hl
		ret
contextKeyTable:
		.db		30h
		.db		2Eh
		.db		2Fh
		.db		2Ch
		.db		2Dh
		.db		36h
		.db		44h
		.db		4Bh
		.db		57h
		.db		45h
		.db		48h
		.db		4Ah
		.db		49h
		.db		3Bh
		.db		53h
		.db		41h
		.db		42h
		.db		5Ah
contextKeyTableEnd:

Get_NumKey:
		call	HandleLinkKeyActivity
		call	GetCSC
		or		a
		jr		z, Get_NumKey
		ld		hl, Get_NumKeyTable
		ld		bc, 9
		cpir
		ret		z
		ld		hl, contrast
		cp		4
		jr		nz, p7Bloc_5783
		ld		a, (hl)
		cp		27h ; '''
		jr		nc, Get_NumKey
		inc		a
		jr		p7Bloc_578C
; ---------------------------------------------------------------------------

p7Bloc_5783:
		cp		1
		jr		nz, Get_NumKey
		ld		a, (hl)
		or		a
		jr		z, Get_NumKey
		dec		a

p7Bloc_578C:
		ld		(hl), a
		add		a, 0D8h	; '�'
		di
		call	lcd_busy
		out		(10h), a
		ei
		jr		Get_NumKey
; ---------------------------------------------------------------------------
Get_NumKeyTable:
		.db		14h
		.db		1Ch
		.db		24h
		.db		13h
		.db		1Bh
		.db		23h
		.db		12h
		.db		1Ah
		.db		22h

page7B_57A1:
		ret
page7B_57A2:
		ld		hl, 8025h
		call	p7Bsub_573A
		call	j_closeEditBuf
		call	j_resetStacks
		call	j_CleanAll
		jp		p7Bloc_70FF
page7B_57B4:
		call	p7Bsub_51D0
		jp		j_numError02_2
; ---------------------------------------------------------------------------

initsmalleditlinevar:
		ld		(iy+2Ah), 0
		set		3, (iy+2Ah)
		jr		p7Bloc_57D2
; ---------------------------------------------------------------------------

initsmalleditlineop1:
		ld		(iy+2Ah), 0
		set		4, (iy+2Ah)
		jr		p7Bloc_57D2
; ---------------------------------------------------------------------------

initsmalleditline:
		ld		(iy+2Ah), 0

p7Bloc_57D2:
		call	p7Bsub_58A0
		in		a, (6)
		ld		(appPage), a
		ld		hl, DoNothing
		ld		(appRawKeyHandle), hl
		ret
; ---------------------------------------------------------------------------

startsmalleditreturn:
		pop		hl
		ld		(unk_818B), hl
		pop		hl
		ld		(unk_818D), hl
		pop		hl
		ld		(unk_818F), hl
		jp		p7Bloc_5A45
; ---------------------------------------------------------------------------

startsmalledit:
		pop		hl
		ld		(unk_818B), hl
		pop		hl
		ld		(unk_818D), hl
		pop		hl
		ld		(unk_818F), hl
		ld		(sedMonSp), sp
		bit		6, (iy+2Bh)
		call	nz, BCALL_4DE6
		ei
		call	Mon
		ret
; ---------------------------------------------------------------------------
; START	OF FUNCTION CHUNK FOR p7Bsub_5935

p7Bloc_580C:
		bit		6, (iy+2Bh)
		ret		z
		call	BCALL_4DE6
		ei
		ret
; END OF FUNCTION CHUNK	FOR p7Bsub_5935

; =============== S U B	R O U T	I N E =======================================


p7Bsub_5816:
		res		6, (iy+2Bh)
		res		appTextSave, (iy+appFlags)
		push	hl
		ld		hl, 800h
		ld		(winTop), hl
		call	j_CursorOff
		res		textEraseBelow, (iy+textFlags)
		ld		hl, mcxMain
		ld		de, 817Ch
		ld		bc, 0Eh
		ldir
		ld		a, (appPage)
		ld		(unk_8197), a
		ld		hl, (appRawKeyHandle)
		ld		(unk_8195), hl
		pop		hl
		call	AppInit
		call	p7Bsub_588E
		ld		a, (penCol)
		ld		(unk_817B), a
		push	af
		call	OP1ToOP2
		res		1, (iy+0Eh)
		res		0, (iy+0Eh)
		set		6, (iy+5)
		call	j_createNumEditBuf
		ld		(editSym), hl
		call	j_SetEmptyEditPtr
		call	j_BufToTop
		bit		3, (iy+2Ah)
		jr		z, p7Bloc_5881
		call	OP2ToOP1
		rst		10h
		jr		c, p7Bloc_587F
		ex		de, hl

p7Bloc_5879:
		call	j_BCALL_4D3B
		call	j_BufToTop

p7Bloc_587F:
		pop		af
		ret
; ---------------------------------------------------------------------------

p7Bloc_5881:
		bit		4, (iy+2Ah)
		ld		a, 0
		ld		hl, OP2
		jr		nz, p7Bloc_5879
		jr		p7Bloc_587F
; End of function p7Bsub_5816


; =============== S U B	R O U T	I N E =======================================


p7Bsub_588E:

		ld		hl, (SmallEditColumnLeft)
		ld		(penCol), hl
		ld		hl, SmallEditPromptString
		ld		a, (hl)
		or		a
		ret		z
		ld		b, a
		inc		hl
		call	j_VPutSN
		ret
p7Bsub_58A0:
		ld		hl, MysteryContext
		call	p7Bsub_5816
		ld		b, a
		ld		a, (SmallEditColumnRight)
		sub		b
		inc		a
		ld		(unk_8198), a
		call	BCALL_4CCC
		res		5, (iy+5)
		call	p7Bsub_5BF3
		set		1, (iy+2Ah)
		ret
MysteryContext:
		.dw		BCALL_4CAB
		.dw		BCALL_4CE7
		.dw		ForceSmallEditReturn2
		.dw		BCALL_4CDE
		.dw		BCALL_4CC6
		.dw		BCALL_4D2C
		.db		08h

BCALL_4CAB:
		bit		6, (iy+2Bh)
		jr		z, p7Bloc_58E6
		cp		6
		jr		nc, p7Bloc_58E6
		ld		(kbdKey), a
		call	BCALL_4E25
		call	BCALL_4E22
		cp		28h ; '('
		jp		z, p7Bloc_580C
		ld		a, (kbdKey)

p7Bloc_58E6:
		cp		9
		jr		nz, p7Bloc_58FA
		set		5, (iy+5)
		call	CanAlphIns
		call	j_fDel
		call	p7Bsub_5BF3
		jp		p7Bloc_580C
; ---------------------------------------------------------------------------

p7Bloc_58FA:
		cp		5
		jp		nz, p7Bloc_591C

p7Bloc_58FF:
		or		a
		push	af
		call	IsEditEmpty
		jr		nz, p7Bloc_590B
		pop		af
		scf

p7Bloc_5908:
		jp		p7Bloc_5A45
; ---------------------------------------------------------------------------

p7Bloc_590B:
		call	j_closeeditbufnor
		call	page0_166E
		ld		a, (SmallEditCancelParse)
		cp		3
		call	nz, j_ParseInp
		pop		af
		jr		p7Bloc_5908
; ---------------------------------------------------------------------------

p7Bloc_591C:
		cp		4
		jr		z, p7Bloc_58FF
		cp		3
		jr		z, p7Bloc_58FF
		cp		40h ; '@'
		jr		z, p7Bloc_58FF
		cp		2
		jr		nz, p7Bloc_5984
		res		textInsMode, (iy+textFlags)
		call	j_BufLeft
		jr		z, p7Bloc_5969

; =============== S U B	R O U T	I N E =======================================


p7Bsub_5935:



		call	BCALL_4CF3
		res		textScrolled, (iy+textFlags)
		call	IsAtTop
		jp		z, p7Bloc_597E
		ld		hl, (editTail)
		call	j_BUFPEEK3
		call	p7Bsub_5C3D
		ld		a, (penCol)
		sub		b
		jr		c, p7Bloc_596C
		ld		hl, 817Bh
		cp		(hl)
		jr		c, p7Bloc_596C
		ld		hl, 819Ah
		cp		(hl)
		jr		nc, p7Bloc_5963
		bit		0, (iy+0Eh)
		jr		nz, p7Bloc_596C

p7Bloc_5963:
		ld		(penCol), a
		call	BCALL_4CCC

p7Bloc_5969:
		jp		p7Bloc_5A1A
; ---------------------------------------------------------------------------

p7Bloc_596C:
		call	p7Bsub_5B85
		ld		a, (unk_817B)
		add		a, 3
		ld		(penCol), a
		push	af
		call	BCALL_4CD2
		pop		af
		jr		p7Bloc_5963
; ---------------------------------------------------------------------------

p7Bloc_597E:
		call	Page0Call_37E3
		jp		p7Bloc_5A1A
; ---------------------------------------------------------------------------

p7Bloc_5984:
		cp		21h ; '!'
		jr		nz, p7Bloc_5996
		res		textInsMode, (iy+textFlags)
		call	j_BufLeft
		jr		z, p7Bloc_5969
		call	p7Bsub_5935
		ld		a, 0Ah

p7Bloc_5996:
		cp		1
		jp		nz, p7Bloc_5A23
		res		textInsMode, (iy+textFlags)
		call	j_BUFPEEK
		jp		z, p7Bloc_5A29
		call	p7Bsub_5C3D
		ld		hl, penCol
		add		a, (hl)
		push	af
		call	j_BufRight
		call	BCALL_4CF3
		ld		c, a
		ld		a, (SmallEditColumnRight)
		inc		a
		ld		b, a
		pop		af
		push	af
		add		a, c
		dec		a
		ld		hl, 8199h
		cp		b
		jr		nc, p7Bloc_59CC
		cp		(hl)
		jr		c, p7Bloc_5A16
		bit		1, (iy+0Eh)
		jr		z, p7Bloc_5A16

p7Bloc_59CC:
		call	p7Bsub_5B85
		pop		af
		ld		a, (hl)
		ld		hl, 81A0h
		sub		(hl)
		ld		(penCol), a
		call	j_BufRight
		jr		nz, p7Bloc_59EA
		call	j_BufLeft
		push	de
		call	j_BufRight
		pop		de
		call	BCALL_4CC9
		jr		p7Bloc_5A1A
; ---------------------------------------------------------------------------

p7Bloc_59EA:
		push	de
		call	p7Bsub_5C3D
		pop		de
		push	af
		scf
		call	BCALL_4CF6
		call	j_BufLeft
		pop		bc
		ld		a, (penCol)
		sub		b
		jp		c, p7Bloc_596C
		ld		hl, 817Bh
		cp		(hl)
		jp		c, p7Bloc_596C
		bit		0, (iy+0Eh)
		jr		z, p7Bloc_5A17
		ld		b, a
		sub		(hl)
		cp		3
		ld		a, b
		jp		c, p7Bloc_596C
		jr		p7Bloc_5A17
; ---------------------------------------------------------------------------

p7Bloc_5A16:
		pop		af

p7Bloc_5A17:
		ld		(penCol), a

p7Bloc_5A1A:
		; p7Bsub_5935+4Cj	...
		res		6, (iy+5)
		call	BCALL_4CF3
		jr		p7Bloc_5A29
; ---------------------------------------------------------------------------

p7Bloc_5A23:
		call	j_ProcessBufKeys
		call	BCALL_4CF3

p7Bloc_5A29:
		jp		p7Bloc_580C
; End of function p7Bsub_5935


; =============== S U B	R O U T	I N E =======================================


BCALL_4CE7:
		ld		hl, (penCol)
		ld		(unk_819B), hl
		res		1, (iy+2Ah)
		res		cursorHookActive, (iy+hookflags2)
		ld		hl, appBackUpScreen
		call	j_SaveDisp
		call	j_saveShadow2
		ret
; End of function BCALL_4CE7

ForceSmallEditReturn:
ForceSmallEditReturn2:
		xor		a
p7Bloc_5A45:
		ld		sp, (sedMonSp)
		ld		hl, (unk_818F)
		push	hl
		ld		hl, (unk_818D)
		push	hl
		ld		hl, (unk_818B)
		push	hl
		ret
; ---------------------------------------------------------------------------

ReleaseSedit:
		res		cursorHookActive, (iy+hookflags2)
		res		6, (iy+2Bh)
		call	j_closeeditbufnor
		call	j_releaseBuffer
		res		1, (iy+2Ah)
		ld		hl, 817Ch
		call	p7Bsub_573A
		ld		hl, (unk_8195)
		ld		(appRawKeyHandle), hl
		ld		a, (unk_8197)
		ld		(appPage), a
		ret
; ---------------------------------------------------------------------------

DoNothing:
		ret
; ---------------------------------------------------------------------------

BCALL_4CC6:
		call	p7Bsub_588E
		set		1, (iy+2Ah)
		call	j_numError02
		jp		errchkalphabox
; ---------------------------------------------------------------------------
; START	OF FUNCTION CHUNK FOR BCALL_4D2C

BCALL_4CDE:
		ld		b, 40h ; '@'
		ld		hl, appBackUpScreen
		ld		a, (iy+14h)
		push	af
		call	j_RestoreDisp
		pop		af
		ld		(iy+14h), a
		ld		hl, (unk_819B)
		ld		(penCol), hl
		call	j_ZifRclHandler
		jr		nz, p7Bloc_5AAE
		or		a
		call	BCALL_4D2C
		call	j_rstrCurRow

p7Bloc_5AAB:
		jp		p7Bloc_580C
; ---------------------------------------------------------------------------

p7Bloc_5AAE:
		set		1, (iy+2Ah)
		jr		p7Bloc_5AAB
; END OF FUNCTION CHUNK	FOR BCALL_4D2C

; =============== S U B	R O U T	I N E =======================================


p7Bsub_5AB4:
		; BCALL_4CCCp ...
		ld		a, (penCol)
		ld		(unk_819D), a
		ld		a, 0FFh
		ld		(unk_819D+1), a
		ld		(unk_819F), a
		ret
; End of function p7Bsub_5AB4


; =============== S U B	R O U T	I N E =======================================


BCALL_4CF0:
		call	IsAtTop
		jr		z, BCALL_4CD2
		dec		hl
		call	page0_191D
		ld		d, 0
		jr		z, p7Bloc_5AD9
		push	hl
		dec		hl
		call	isPtrHLA2ByteTok
		pop		hl
		jr		nz, p7Bloc_5AD9
		dec		hl

p7Bloc_5AD9:
		; BCALL_4CF0+13j
		ex		de, hl
		ld		hl, (penCol)
		push	hl
		ex		de, hl
		jr		p7Bloc_5AE8
; End of function BCALL_4CF0


; =============== S U B	R O U T	I N E =======================================


BCALL_4CD2:
		; BCALL_4CF0+3j ...
		ld		hl, (penCol)
		push	hl
		ld		hl, (editCursor)

p7Bloc_5AE8:
		call	p7Bsub_5AB4
		ld		a, (appFlagsAddr)
		push	af
		res		appAutoScroll, (iy+appFlags)

p7Bloc_5AF3:
		ld		de, (editTop)
		call	CpHLDE
		ccf
		jr		z, p7Bloc_5B49
		call	j_GetPrevTok
		or		1
		call	BCALL_4CD5
		jr		c, p7Bloc_5AF3
		ld		hl, 817Bh
		ld		a, (unk_819D)
		sub		(hl)
		cp		3
		jr		nc, p7Bloc_5B2A
		ld		a, (unk_819D+1)
		cp		0FFh
		jr		nz, p7Bloc_5B1D

p7Bloc_5B19:
		ld		a, 3
		jr		p7Bloc_5B2A
; ---------------------------------------------------------------------------

p7Bloc_5B1D:
		sub		(hl)
		cp		3
		jr		nc, p7Bloc_5B2A
		ld		a, (unk_819F)
		cp		0FFh
		jr		z, p7Bloc_5B19
		sub		(hl)

p7Bloc_5B2A:
		; BCALL_4CD2+3Aj ...
		ld		b, a
		add		a, (hl)
		ld		a, (unk_817B)
		ld		(penCol), a
		push	af

p7Bloc_5B33:
		call	j_VPUTBLANK
		djnz	p7Bloc_5B33
		pop		af
		ld		(penCol), a
		add		a, 2
		ld		(unk_819A), a
		call	p7Bsub_5BB5
		set		0, (iy+0Eh)
		or		a

p7Bloc_5B49:
		pop		bc
		ld		a, b
		ld		(appFlagsAddr), a
		pop		hl
		ld		(penCol), hl
		ret
; End of function BCALL_4CD2


; =============== S U B	R O U T	I N E =======================================


VEraseEOL:
		; BCALL_4D14+6p ...
		push	af
		push	bc
		push	de
		push	hl
		ld		a, (SmallEditColumnRight)
		inc		a
		ld		b, a
		ld		a, (penCol)
		push	af
		sub		b
		jr		nc, p7Bloc_5B7C
		neg

p7Bloc_5B65:
		ld		b, a
		cp		4
		jr		c, p7Bloc_5B77
		sub		4
		push	af
		ld		a, 6
		call	j_VPutMap
		pop		af
		jr		nz, p7Bloc_5B65
		jr		z, p7Bloc_5B7C

p7Bloc_5B77:
		; VEraseEOL+27j
		call	j_VPUTBLANK
		djnz	p7Bloc_5B77

p7Bloc_5B7C:
		; VEraseEOL+22j
		pop		af
		ld		(penCol), a
		pop		hl
		pop		de
		pop		bc
		pop		af
		ret
; End of function VEraseEOL


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5B85:
		; p7Bsub_5935:p7Bloc_59CCp ...
		push	hl
		push	de
		ld		a, (penCol)
		push	af
		ld		a, (unk_817B)
		bit		0, (iy+0Eh)
		call	nz, p7Bsub_5BA8
		ld		a, (SmallEditColumnRight)
		sub		2
		bit		1, (iy+0Eh)
		call	nz, p7Bsub_5BA8
		pop		af
		ld		(penCol), a
		pop		de
		pop		hl
		ret
; End of function p7Bsub_5B85


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5BA8:
		ld		(penCol), a
		call	j_VPUTBLANK
		call	j_VPUTBLANK
		call	j_VPUTBLANK
		ret
p7Bsub_5BB5:
		ld		hl, {+}
p7Bsub_5BB8:
		ld		de, ioPrompt
		call	Mov10B
		ld		a, 6
		ld		hl, ioPrompt
		call	j_VPutMapRec
		ret
+:		.db		3
		.db		0
		.db		0
		.db		0
		.db		0
		.db		0
		.db		6
		.db		0
MysteryTable1:
		.db		3
		.db		0
		.db		0
		.db		0
		.db		0
		.db		0
		.db		3
		.db		0

; =============== S U B	R O U T	I N E =======================================


BCALL_4CF3:
		call	j_BUFPEEK
		ld		b, 20h ; ' '
		ld		a, 1
		jr		z, p7Bloc_5BE3
		call	p7Bsub_5C44

p7Bloc_5BE3:
		ld		(unk_81A0), a
		ld		(unk_81A8), a
		ld		hl, curUnder
		ld		(hl), b
		push	af
		call	p7Bloc_5C0D
		pop		af
		ret
; End of function BCALL_4CF3


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5BF3:
		ld		a, 1
		ld		(unk_81A0), a
		ld		(unk_81A8), a
		call	IsEditEmpty
		ld		a, 20h ; ' '
		jr		z, p7Bloc_5C0A
		call	j_BUFPEEK
		call	j_SGetTokString
		inc		hl
		ld		a, (hl)

p7Bloc_5C0A:
		ld		(curUnder), a

p7Bloc_5C0D:
		ld		a, (unk_81A0)
		ld		e, a
		ld		d, 0
		ld		hl, {+}-1
		add		hl, de
		ld		a, (hl)
		ld		hl, 81A1h
		ld		(hl), 0
		ld		b, 6

p7Bloc_5C1F:
		inc		hl
		ld		(hl), a
		djnz	p7Bloc_5C1F
		inc		hl
		ld		b, 5

p7Bloc_5C26:
		inc		hl
		ld		(hl), 0
		djnz	p7Bloc_5C26
		cp		8
		jr		c, p7Bloc_5C31
		res		0, a

p7Bloc_5C31:
		inc		hl
		ld		(hl), a
		inc		hl
		ld		(hl), a
		ret

+:		.db		1
		.db		3
		.db		7
		.db		0Fh
		.db		1Fh
		.db		3Fh	; ?
		.db		7Fh	; 

; =============== S U B	R O U T	I N E =======================================


p7Bsub_5C3D:
		call	j_SGetTokString
		call	SStringLength
		ret
; End of function p7Bsub_5C3D


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5C44:
		; BCALL_4CF6+48p ...
		call	j_SGetTokString
		inc		hl
		ld		a, (hl)
		push	af
		call	j_LoadPattern
		ld		a, (hl)
		pop		bc
		ret
; End of function p7Bsub_5C44

; ---------------------------------------------------------------------------

RestorePenCol:
		push	af
		ld		a, (unk_817B)
		ld		(penCol), a
		pop		af
		ret

; =============== S U B	R O U T	I N E =======================================


BCALL_4CCC:
		call	p7Bsub_5AB4

p7Bloc_5C5C:
		call	Page0Call_3C3F
		ld		a, (penCol)
		push	af
		ld		hl, (editTail)

p7Bloc_5C66:
		call	j_BUFPEEK1
		jr		z, p7Bloc_5CE9
		inc		hl
		push	hl
		call	j_SGetTokString
		ld		b, (hl)
		inc		hl
		ld		a, (SmallEditColumnRight)
		inc		a
		ld		c, a

p7Bloc_5C77:
		push	bc
		push	hl
		ld		a, (hl)
		call	j_LoadPattern
		ld		a, (penCol)
		add		a, (hl)
		ld		d, (hl)
		cp		c
		pop		hl
		pop		bc
		jr		nc, p7Bloc_5C9F
		ld		a, (hl)
		inc		hl
		call	j_VPutMap
		ld		a, (penCol)
		ld		de, (unk_819D)
		ld		(unk_819D+1), de
		ld		(unk_819D), a
		djnz	p7Bloc_5C77
		pop		hl
		jr		p7Bloc_5C66
; ---------------------------------------------------------------------------

p7Bloc_5C9F:
		ld		a, d
		ld		(unk_81B0), a
		pop		hl
		ld		a, (SmallEditColumnRight)
		ld		hl, 819Dh
		sub		(hl)
		cp		2
		jr		nc, p7Bloc_5CC1
		add		a, (hl)
		inc		hl
		bit		7, (hl)
		jr		nz, p7Bloc_5CCC
		sub		(hl)
		cp		2
		jr		nc, p7Bloc_5CC1
		add		a, (hl)
		inc		hl
		bit		7, (hl)
		jr		nz, p7Bloc_5CCC
		sub		(hl)

p7Bloc_5CC1:
		; BCALL_4CCC+5Fj
		inc		a
		ld		b, a
		ld		a, (hl)
		ld		(penCol), a

p7Bloc_5CC7:
		call	j_VPUTBLANK
		djnz	p7Bloc_5CC7

p7Bloc_5CCC:
		; BCALL_4CCC+65j
		ld		a, (SmallEditColumnRight)
		sub		2
		ld		(penCol), a
		ld		(unk_8199), a
		set		1, (iy+0Eh)
		ld		(penCol), a
		ld		hl, MysteryTable1
		call	p7Bsub_5BB8
		pop		af
		ld		(penCol), a
		ret
; ---------------------------------------------------------------------------

p7Bloc_5CE9:
		call	VEraseEOL
		call	Page0Call_3C3F
		pop		af
		ld		(penCol), a
		ret
; End of function BCALL_4CCC


; =============== S U B	R O U T	I N E =======================================


BCALL_4CC9:
		xor		a
; End of function BCALL_4CC9


; =============== S U B	R O U T	I N E =======================================


BCALL_4CF6:
		ld		(unk_81B1), de
		push	af
		call	p7Bsub_5B85
		call	p7Bsub_5C3D
		push	hl
		inc		b
		ld		hl, penCol
		ld		a, (SmallEditColumnRight)
		push	af
		sub		(hl)
		cp		b
		jr		c, p7Bloc_5D14
		pop		af
		pop		hl
		ld		a, (penCol)
		jr		p7Bloc_5D5A
; ---------------------------------------------------------------------------

p7Bloc_5D14:
		inc		b
		inc		b
		bit		textInsMode, (iy+textFlags)
		jr		z, p7Bloc_5D25
		ld		a, (unk_81A0)
		cp		3
		jr		c, p7Bloc_5D25
		add		a, b
		ld		b, a

p7Bloc_5D25:
		; BCALL_4CF6+2Cj
		pop		af
		sub		b
		ld		(hl), a
		pop		hl
		jr		c, p7Bloc_5D35
		push	af
		ld		c, a
		ld		a, (unk_817B)
		inc		c
		cp		c
		jr		c, p7Bloc_5D5B
		pop		hl

p7Bloc_5D35:
		; BCALL_4CF6+A6j ...
		pop		de
		call	j_BUFPEEK
		ld		a, 0
		jr		z, p7Bloc_5D42
		call	p7Bsub_5C44
		add		a, 2

p7Bloc_5D42:
		ld		b, a
		ld		hl, SmallEditColumnRight
		ld		a, (hl)
		sub		b
		push	af
		ld		(penCol), a
		call	BCALL_4CCC
		pop		af
		push	af
		ld		(penCol), a
		call	BCALL_4CD2
		pop		af
		jr		p7Bloc_5DC5
; ---------------------------------------------------------------------------

p7Bloc_5D5A:
		; BCALL_4CF6+C4j
		push	af

p7Bloc_5D5B:
		push	hl
		ld		b, (hl)
		call	p7Bsub_5AB4

p7Bloc_5D60:
		inc		hl
		ld		a, (hl)
		call	j_VPutMap
		ld		a, (penCol)
		ld		de, (unk_819D)
		ld		(unk_819D+1), de
		ld		(unk_819D), a
		djnz	p7Bloc_5D60
		call	p7Bloc_5C5C
		pop		hl
		pop		bc
		ld		a, (penCol)
		bit		1, (iy+0Eh)
		jr		z, p7Bloc_5DBB
		ld		d, a
		ld		hl, 81B0h
		add		a, (hl)
		dec		a
		ld		c, a
		ld		a, (unk_8199)
		dec		a
		cp		c
		ld		a, d
		jr		nc, p7Bloc_5DBB
		pop		af
		ld		a, d
		jr		c, p7Bloc_5DBC
		push	af
		ld		a, (unk_817B)
		cp		b
		jr		z, p7Bloc_5D35
		push	bc
		ld		de, (unk_81B1)
		call	j_SGetTokString
		ld		a, (unk_81B0)
		ld		b, a
		pop		af
		sub		b
		push	hl
		ld		hl, 817Bh
		cp		(hl)
		pop		hl
		jr		c, p7Bloc_5D35
		ld		(penCol), a
		call	p7Bsub_5B85
		jr		p7Bloc_5D5A
; ---------------------------------------------------------------------------

p7Bloc_5DBB:
		; BCALL_4CF6+9Bj
		pop		de

p7Bloc_5DBC:
		push	af
		ld		a, b
		ld		(penCol), a
		call	BCALL_4CF0
		pop		af

p7Bloc_5DC5:
		ld		(penCol), a
		call	BCALL_4CF3
		ret
; End of function BCALL_4CF6


; =============== S U B	R O U T	I N E =======================================


SStringLength:
		; BlinkCellNoLookUp+3Cp ...
		push	hl
		ld		b, (hl)
		xor		a

p7Bloc_5DCF:
		push	bc
		push	af
		inc		hl
		push	hl
		ld		a, (hl)
		call	j_LoadPattern
		ld		d, (hl)
		pop		hl
		pop		af
		add		a, d
		pop		bc
		djnz	p7Bloc_5DCF
		ld		b, a
		pop		hl
		ret
; End of function SStringLength


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5DE1:
		call	j_GetPrevTok

BCALL_4CF9:
		push	bc
		xor		a
		ld		b, 0
		jr		p7Bloc_5DED
; End of function p7Bsub_5DE1


; =============== S U B	R O U T	I N E =======================================


BCALL_4CD5:
		push	bc
		ld		b, 1

p7Bloc_5DED:
		push	de
		push	hl
		push	af
		push	bc
		call	j_SGetTokString
		ld		b, (hl)
		ld		e, b
		ld		d, 0
		add		hl, de

p7Bloc_5DF9:
		ld		a, (unk_817B)
		pop		de
		push	de
		bit		0, d
		jr		nz, p7Bloc_5E3B
		ld		a, (hl)
		cp		0D6h ; '�'
		jr		nz, p7Bloc_5E38
		call	BCALL_4D1A
		ld		a, (penCol+1)
		ld		hl, SmallEditRow
		cp		(hl)
		jp		m, p7Bloc_5E9D
		ld		hl, (editCursor)

p7Bloc_5E17:
		ld		de, (editTop)
		dec		hl
		call	CpHLDE
		jr		c, p7Bloc_5E2A
		inc		hl
		call	j_GetPrevTok
		call	page0_17C7
		jr		nz, p7Bloc_5E17

p7Bloc_5E2A:
		inc		hl
		ld		de, (editCursor)
		call	j_stringwidth
		ld		a, e
		ld		(penCol), a
		jr		p7Bloc_5E74
; ---------------------------------------------------------------------------

p7Bloc_5E38:
		ld		a, (SmallEditColumnLeft)

p7Bloc_5E3B:
		push	bc
		push	hl
		push	af
		ld		a, (hl)
		call	j_LoadPattern
		pop		af
		ld		c, a
		ld		a, (penCol)
		sub		(hl)
		jp		m, p7Bloc_5E7B
		cp		c
		jr		c, p7Bloc_5E7B
		ld		(penCol), a

p7Bloc_5E51:
		ld		hl, (unk_819D)
		ld		(unk_819D+1), hl
		ld		(unk_819D), a
		pop		hl
		push	hl
		push	af
		ld		a, (hl)
		bit		7, (iy+2Ah)
		call	z, j_VPutMap
		ld		a, (penCol)
		ld		(unk_819D+1), a
		pop		af
		ld		(penCol), a
		pop		hl
		dec		hl
		pop		bc
		djnz	p7Bloc_5DF9

p7Bloc_5E74:
		pop		de
		pop		af
		scf

p7Bloc_5E77:
		pop		hl
		pop		de
		pop		bc
		ret
; ---------------------------------------------------------------------------

p7Bloc_5E7B:
		; BCALL_4CD5+62j
		ld		a, (hl)
		ld		(unk_81B0), a
		pop		hl
		pop		bc
		pop		de
		pop		af
		jr		nz, p7Bloc_5E9F
		push	af
		push	de
		push	bc
		push	hl
		call	BCALL_4D1A
		ld		a, (penCol+1)
		push	hl
		ld		hl, SmallEditRow
		cp		(hl)
		pop		hl
		ld		a, (penCol)
		jp		p, p7Bloc_5E51
		pop		hl
		pop		bc

p7Bloc_5E9D:
		pop		de
		pop		af

p7Bloc_5E9F:
		or		a
		jr		p7Bloc_5E77
; End of function BCALL_4CD5


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5EA2:
		push	af
		srl	a
		srl	a
		srl	a
		or		20h ; ' '
		ld		b, a
		pop		af

p7Bloc_5EAD:
		sub		8
		jr		nc, p7Bloc_5EAD
		add		a, 8
		ld		e, a
		ld		d, 0
		add		hl, de
		ld		a, (hl)
		ret
; End of function p7Bsub_5EA2

MysteryTable2:
		.db		0FFh
		.db		7Fh	; 
		.db		3Fh	; ?
		.db		1Fh
		.db		0Fh
		.db		7
		.db		3
		.db		1
MysteryTable3:
		.db		80h	; �
		.db		0C0h	; �
		.db		0E0h	; �
		.db		0F0h	; �
		.db		0F8h	; �
		.db		0FCh	; �
		.db		0FEh	; �
		.db		0FFh

BCALL_4CFC:
		xor		a
		push	af
		res		textScrolled, (iy+textFlags)
		ld		de, (editTop)
		ld		bc, (penCol)
		inc		c

p7Bloc_5ED8:
		call	j_CursorLeft
		ld		hl, (editCursor)
		ld		a, (penCol+1)
		cp		b
		jr		nz, p7Bloc_5EF1
		bit		textScrolled, (iy+textFlags)
		jr		nz, p7Bloc_5EF1
		pop		af
		push	af
		or		a
		jr		nz, p7Bloc_5EF8
		jr		p7Bloc_5F0D
; ---------------------------------------------------------------------------

p7Bloc_5EF1:
		; BCALL_4CFC+1Fj
		ld		b, a
		pop		af
		or		a
		ret		nz
		or		1
		push	af

p7Bloc_5EF8:
		ld		a, (penCol)
		cp		c
		jr		c, p7Bloc_5F12
		push	de
		push	hl
		call	j_GetPrevTok
		pop		hl
		ld		(editCursor), hl
		call	page0_17C7
		pop		de
		jr		z, p7Bloc_5F12

p7Bloc_5F0D:
		call	CpHLDE
		jr		nz, p7Bloc_5ED8

p7Bloc_5F12:
		; BCALL_4CFC+42j
		pop		af
		or		a
		ret
; End of function BCALL_4CFC


; =============== S U B	R O U T	I N E =======================================


BCALL_4CFF:
		xor		a
		push	af
		res		textScrolled, (iy+textFlags)
		ld		de, (editBtm)
		ld		bc, (penCol)

p7Bloc_5F23:
		call	j_cursorRight
		ld		hl, (editTail)
		ld		a, (penCol+1)
		cp		b
		jr		nz, p7Bloc_5F3C
		bit		textScrolled, (iy+textFlags)
		jr		nz, p7Bloc_5F3C
		pop		af
		push	af
		or		a
		jr		nz, p7Bloc_5F43
		jr		p7Bloc_5F4E
; ---------------------------------------------------------------------------

p7Bloc_5F3C:
		; BCALL_4CFF+1Ej
		ld		b, a
		pop		af
		or		a
		ret		nz
		or		1
		push	af

p7Bloc_5F43:
		ld		a, (penCol)
		cp		c
		jr		nc, p7Bloc_5F53
		ld		a, (hl)
		cp		3Fh ; '?'
		jr		z, p7Bloc_5F53

p7Bloc_5F4E:
		call	CpHLDE
		jr		nz, p7Bloc_5F23

p7Bloc_5F53:
		; BCALL_4CFF+37j
		pop		af
		or		a
		ret
; End of function BCALL_4CFF

; ---------------------------------------------------------------------------

BCALL_4D02:
		ld		hl, (penCol)
		push	hl
		set		7, (iy+2Ah)
		call	p7Bsub_5F8D
		ld		a, (SmallEditColumnLeft)
		bit		7, (iy+2Ah)
		res		7, (iy+2Ah)
		jr		nz, p7Bloc_5F71
		ld		a, (unk_817B)

p7Bloc_5F71:
		ld		hl, penCol
		sub		(hl)
		pop		hl
		jr		z, p7Bsub_5F81
		add		a, l
		ld		l, a
		call	p7Bsub_5F81
		call	BCALL_4D05
		ret

; =============== S U B	R O U T	I N E =======================================


p7Bsub_5F81:
		push	hl
		ld		(penCol), hl
		call	p7Bsub_5F8D
		pop		hl
		ld		(penCol), hl
		ret
; End of function p7Bsub_5F81


; =============== S U B	R O U T	I N E =======================================


p7Bsub_5F8D:
		ld		a, (unk_8198)
		push	af
		ld		hl, (editCursor)
		ld		de, (editTop)
		ld		a, (appFlagsAddr)
		push	af
		res		appAutoScroll, (iy+appFlags)

p7Bloc_5FA0:
		call	CpHLDE
		jr		nz, p7Bloc_5FB6
		bit		7, (iy+2Ah)
		jr		z, p7Bloc_5FB1
		res		7, (iy+2Ah)
		jr		p7Bloc_5FBD
; ---------------------------------------------------------------------------

p7Bloc_5FB1:
		call	p7Bsub_588E
		jr		p7Bloc_5FBD
; ---------------------------------------------------------------------------

p7Bloc_5FB6:
		push	de
		call	p7Bsub_5DE1
		pop		de
		jr		c, p7Bloc_5FA0

p7Bloc_5FBD:
		pop		af
		ld		(appFlagsAddr), a
		pop		af
		ld		(unk_8198), a
		ret
; End of function p7Bsub_5F8D


; =============== S U B	R O U T	I N E =======================================


BCALL_4D05:
		ld		a, (unk_8198)
		push	af
		ld		hl, (penCol)
		push	hl
		ld		hl, (editTail)
		ld		a, (appFlagsAddr)
		push	af
		res		appAutoScroll, (iy+appFlags)

p7Bloc_5FD9:
		call	j_BUFPEEK1
		jr		z, p7Bloc_5FF3
		inc		hl
		push	hl
		res		6, (iy+2Ah)
		call	BCALL_4D08
		ld		a, (unk_8198)
		ld		hl, SmallEditRowCount
		cp		(hl)
		pop		hl
		jr		c, p7Bloc_5FD9
		jr		p7Bloc_5FF7
; ---------------------------------------------------------------------------

p7Bloc_5FF3:
		call	BCALL_4D23
		scf

p7Bloc_5FF7:
		pop		de
		ld		(iy+0Dh), d

p7Bloc_5FFB:
		pop		hl
		ld		(penCol), hl
		pop		hl
		ld		a, h
		ld		(unk_8198), a
		ret
; End of function BCALL_4D05


; =============== S U B	R O U T	I N E =======================================


BCALL_4D08:
		; BCALL_4D20+1Cp
		call	j_SGetTokString
		call	BCALL_4D0E
		ret
; End of function BCALL_4D08

; ---------------------------------------------------------------------------

BCALL_4D0B:
		push	af
		push	de
		ld		hl, (editCursor)
		call	j_GetPrevTok
		call	j_GetPrevTok
		call	j_SGetTokString
		ld		b, (hl)
		ld		e, b
		ld		d, 0
		add		hl, de
		ld		a, (hl)
		call	j_LoadPattern
		ld		a, (penCol)
		push	af
		sub		(hl)
		call	p7Bsub_61EB
		pop		af
		ld		(penCol), a
		pop		de
		res		textScrolled, (iy+textFlags)
		call	j_SGetTokString
		pop		af
		res		6, (iy+2Ah)
		call	BCALL_4D0E
		bit		textScrolled, (iy+textFlags)
		ret		z
		call	BCALL_4D05
		ret

; =============== S U B	R O U T	I N E =======================================


BCALL_4D0E:

		ld		b, (hl)
		inc		hl
		ld		a, b
		or		a
		ret		z

p7Bloc_604D:
		; BCALL_4D0E:p7Bloc_6064j
		ld		a, (hl)
		inc		hl
		call	BCALL_4D11
		ld		a, (unk_8198)
		ld		c, a
		ld		a, (SmallEditRowCount)
		cp		c
		ret		z
		bit		5, (iy+2Ah)
		jr		z, p7Bloc_6064
		dec		hl
		jr		p7Bloc_604D
; ---------------------------------------------------------------------------

p7Bloc_6064:
		djnz	p7Bloc_604D
		ret
; End of function BCALL_4D0E


; =============== S U B	R O U T	I N E =======================================


BCALL_4D11:
		res		5, (iy+2Ah)
		push	af
		push	hl
		push	de
		push	bc
		cp		0D6h ; '�'
		jr		nz, p7Bloc_6078
		call	BCALL_4D14
		jr		p7Bloc_609C
; ---------------------------------------------------------------------------

p7Bloc_6078:
		push	af
		call	j_LoadPattern
		ld		a, (hl)
		call	p7Bsub_6424
		pop		hl
		ld		a, h
		jr		c, p7Bloc_608D
		call	BCALL_4D14
		set		5, (iy+2Ah)
		jr		p7Bloc_609C
; ---------------------------------------------------------------------------

p7Bloc_608D:
		push	af
		call	p7Bsub_61EE
		pop		af
		call	j_VPutMap
		xor		a
		call	p7Bsub_6424
		call	nc, BCALL_4D14

p7Bloc_609C:
		; BCALL_4D11+24j
		pop		bc
		pop		de
		pop		hl
		pop		af
		ret
; End of function BCALL_4D11


; =============== S U B	R O U T	I N E =======================================


BCALL_4D14:
		; BCALL_4D11+1Dp ...
		push	af
		push	bc
		push	de
		push	hl
		push	ix
		call	VEraseEOL
		ld		a, (SmallEditColumnLeft)
		ld		(penCol), a
		ld		a, (unk_8198)
		inc		a
		ld		hl, SmallEditRowCount
		cp		(hl)
		jr		c, p7Bloc_60D6
		bit		appAutoScroll, (iy+appFlags)
		jr		z, p7Bloc_60D6
		set		textScrolled, (iy+textFlags)
		call	BCALL_4D17
		ld		a, e
		call	p7Bsub_6199
		ld		hl, 81B9h
		ld		de, 81B8h
		call	mov9B2
		jr		p7Bloc_60E2
; ---------------------------------------------------------------------------

p7Bloc_60D6:
		; BCALL_4D14+1Dj
		ld		hl, 8198h
		ld		(hl), a
		ld		a, (penCol+1)
		add		a, 6
		ld		(penCol+1), a

p7Bloc_60E2:
		; BCALL_4D1D+44j
		pop		ix
		pop		hl
		pop		de
		pop		bc
		pop		af
		ret
; End of function BCALL_4D14


; =============== S U B	R O U T	I N E =======================================


BCALL_4D17:
		ld		hl, (unk_81B5)
		ld		(OP1), hl
		ld		hl, (unk_81B3)
		ld		(OP1M), hl
		ld		c, 6
		ld		a, (SmallEditRowCount)
		dec		a
		ld		b, a
		ld		h, 6
		ld		a, (SmallEditRow)
		jr		nz, p7Bloc_6107
		add		a, 80h ; '�'
		ld		e, a
		ret
; ---------------------------------------------------------------------------

p7Bloc_6107:
		add		a, 80h ; '�'
		call	j_AppScreenUpDown
		ret
; End of function BCALL_4D17


; =============== S U B	R O U T	I N E =======================================


BCALL_4D1A:
		; BCALL_4CD5+9Fp
		push	af
		push	de
		push	hl
		ld		de, 8198h
		ld		a, (de)
		sub		1
		jr		nc, p7Bloc_612E
		bit		appAutoScroll, (iy+appFlags)
		jr		z, p7Bloc_6137
		call	BCALL_4D1D
		ld		a, (SmallEditColumnRight)
		ld		hl, 81B0h
		sub		(hl)
		inc		a
		call	p7Bsub_61EB
		jr		p7Bloc_6140
; ---------------------------------------------------------------------------

p7Bloc_612E:
		ld		(de), a
		call	p7Bsub_6205
		ld		(penCol), a
		jr		p7Bloc_6138
; ---------------------------------------------------------------------------

p7Bloc_6137:
		ld		(de), a

p7Bloc_6138:
		ld		a, (penCol+1)
		sub		6
		ld		(penCol+1), a

p7Bloc_6140:
		pop		hl
		pop		de
		pop		af
		ret
; End of function BCALL_4D1A


; =============== S U B	R O U T	I N E =======================================


BCALL_4D1D:
		push	af
		push	bc
		push	de
		push	hl
		push	ix
		call	j_RunIndicOff
		set		textScrolled, (iy+textFlags)
		ld		a, (SmallEditRowCount)
		dec		a
		jr		nz, p7Bloc_615C
		call	p7Bsub_618B
		jr		p7Bloc_6181
; ---------------------------------------------------------------------------

p7Bloc_615C:
		ld		b, a
		ld		c, 0FAh	; '�'
		ld		hl, (unk_81B5)
		ld		(OP1), hl
		ld		hl, (unk_81B3)
		ld		(OP1M), hl
		ld		h, 6
		call	p7Bsub_618B
		call	j_AppScreenUpDown
		ld		a, e
		push	af
		ld		hl, 81C1h
		ld		de, 81C2h
		ld		bc, 9
		lddr
		pop		af

p7Bloc_6181:
		call	p7Bsub_6199
		ei
		call	j_RunIndicOn
		jp		p7Bloc_60E2
; End of function BCALL_4D1D


; =============== S U B	R O U T	I N E =======================================


p7Bsub_618B:
		; BCALL_4D1D+29p
		push	bc
		add		a, a
		ld		b, a
		add		a, a
		add		a, b
		add		a, 80h ; '�'
		ld		c, a
		ld		a, (SmallEditRow)
		add		a, c
		pop		bc
		ret
; End of function p7Bsub_618B


; =============== S U B	R O U T	I N E =======================================


p7Bsub_6199:
		; BCALL_4D1D:p7Bloc_6181p
		di
		ld		d, a
		ld		a, (unk_81B5)
		ld		e, a
		ld		a, (unk_81B3)

p7Bloc_61A2:
		ld		c, a
		call	SetYUp
		call	lcd_busy
		ld		a, e
		out		(10h), a
		call	lcd_busy
		ld		a, d
		out		(10h), a
		call	SetXUp
		ld		b, 6

p7Bloc_61B7:
		call	SetYUp
		call	lcd_busy
		in		a, (11h)
		call	lcd_busy
		in		a, (11h)
		or		c
		xor		c
		push	af
		call	SetXUp
		ld		a, e
		call	lcd_busy
		out		(10h), a
		pop		af
		call	lcd_busy
		out		(11h), a
		djnz	p7Bloc_61B7
		ld		a, e
		ld		hl, 81B6h
		cp		(hl)
		ret		z
		inc		a
		ld		e, a
		cp		(hl)
		ld		a, 0FFh
		jr		nz, p7Bloc_61A2
		ld		a, (unk_81B3+1)
		jr		p7Bloc_61A2
; End of function p7Bsub_6199

; ---------------------------------------------------------------------------
		ret

; =============== S U B	R O U T	I N E =======================================


p7Bsub_61EB:
		; BCALL_4D1A+1Cp
		ld		(penCol), a
; End of function p7Bsub_61EB


; =============== S U B	R O U T	I N E =======================================


p7Bsub_61EE:

		bit		6, (iy+2Ah)
		ret		nz
		ld		hl, 81B8h
		ld		a, (unk_8198)
		cp		0Ah
		ret		nc
		ld		e, a
		ld		d, 0
		add		hl, de
		ld		a, (penCol)
		ld		(hl), a
		ret
; End of function p7Bsub_61EE


; =============== S U B	R O U T	I N E =======================================


p7Bsub_6205:
		ld		hl, 81B8h
		ld		a, (unk_8198)
		ld		e, a
		ld		d, 0
		add		hl, de
		ld		a, (hl)
		ret
; End of function p7Bsub_6205


; =============== S U B	R O U T	I N E =======================================


BCALL_4D20:
		ld		hl, (editBtm)
		ld		de, (editTail)
		ld		a, (iy+0Dh)
		push	af
		res		appAutoScroll, (iy+appFlags)
		ex		de, hl

p7Bloc_6221:
		push	de
		call	j_BUFPEEK2
		jr		z, p7Bloc_623D
		inc		hl
		push	hl
		res		6, (iy+2Ah)
		call	BCALL_4D08
		ld		a, (unk_8198)
		ld		hl, SmallEditRowCount
		cp		(hl)
		pop		hl
		pop		de
		jr		nc, p7Bloc_6242
		jr		p7Bloc_6221
; ---------------------------------------------------------------------------

p7Bloc_623D:
		pop		de
		call	VEraseEOL
		scf

p7Bloc_6242:
		pop		de
		ld		(iy+0Dh), d
		ret
; End of function BCALL_4D20


; =============== S U B	R O U T	I N E =======================================


BCALL_4D23:

		push	af
		push	hl
		ld		a, (unk_8198)
		push	af
		ld		hl, (penCol)
		push	hl
		ld		hl, SmallEditRowCount
		sub		(hl)
		jr		z, p7Bloc_6262

p7Bloc_6257:
		inc		a
		jr		z, p7Bloc_625F
		call	BCALL_4D14
		jr		p7Bloc_6257
; ---------------------------------------------------------------------------

p7Bloc_625F:
		call	VEraseEOL

p7Bloc_6262:
		pop		hl
		ld		(penCol), hl
		pop		hl
		ld		a, h
		ld		(unk_8198), a
		pop		hl
		pop		af
		ret
; End of function BCALL_4D23

; ---------------------------------------------------------------------------

initsmalleditboxvar:
		ld		(iy+2Ah), 0
		set		3, (iy+2Ah)
		jr		p7Bloc_6286
; ---------------------------------------------------------------------------

initsmalleditboxop1:
		ld		(iy+2Ah), 0
		set		4, (iy+2Ah)
		jr		p7Bloc_6286
; ---------------------------------------------------------------------------

initsmalleditBox:
		ld		(iy+2Ah), 0

p7Bloc_6286:
		call	p7Bsub_6297
		in		a, (6)
		ld		(appPage), a
		ld		hl, EmptyHook
		ld		(appRawKeyHandle), hl
		ret
EmptyHook:
		add		a, e
		ret
p7Bsub_6297:
		ld		hl, smallEditContext
		call	p7Bsub_5816
		xor		a
		ld		(unk_8198), a
		ld		a, (SmallEditColumnLeft)
		ld		hl, MysteryTable2
		call	p7Bsub_5EA2
		ld		(unk_81B3), a
		ld		a, b
		ld		(unk_81B5), a
		ld		a, (SmallEditColumnRight)
		ld		hl, MysteryTable3
		call	p7Bsub_5EA2
		ld		(unk_81B3+1), a
		ld		a, b
		ld		(unk_81B5+1), a
		call	BCALL_4D05
		res		5, (iy+5)
		call	p7Bsub_5BF3
		set		1, (iy+2Ah)
		ret
smallEditContext:
		.dw		smallEditcxMain
		.dw		BCALL_4CE7
		.dw		ForceSmallEditReturn2
		.dw		BCALL_4CDE
		.dw		BCALL_4CEA
		.dw		BCALL_4D2C
		.db		0Ch
smallEditcxMain:
		bit		6, (iy+2Bh)
		jr		z, p7Bloc_62F8
		cp		6
		jr		nc, p7Bloc_62F8
		ld		(kbdKey), a
		call	BCALL_4E25
		call	BCALL_4E22
		cp		28h ; '('
		jp		z, p7Bloc_580C
		ld		a, (kbdKey)

p7Bloc_62F8:
		cp		40h ; '@'

p7Bloc_62FA:
		jp		z, p7Bloc_58FF
		cp		5
		jr		z, p7Bloc_62FA
		cp		2
		jr		nz, p7Bloc_630E
		call	j_CursorLeft

p7Bloc_6308:
		call	BCALL_4CF3

p7Bloc_630B:
		jp		p7Bloc_580C
; ---------------------------------------------------------------------------

p7Bloc_630E:
		cp		3
		jr		nz, p7Bloc_6317
		call	BCALL_4CFC
		jr		p7Bloc_6308
; ---------------------------------------------------------------------------

p7Bloc_6317:
		cp		4
		jr		nz, p7Bloc_6320
		call	BCALL_4CFF
		jr		p7Bloc_6308
; ---------------------------------------------------------------------------

p7Bloc_6320:
		cp		9
		jr		nz, p7Bloc_633E
		call	CanAlphIns
		call	IsEditEmpty
		jr		z, p7Bloc_630B
		call	j_BufToTop
		call	p7Bsub_588E
		xor		a
		ld		(unk_8198), a
		call	j_BufClear
		call	BCALL_4D23
		jr		p7Bloc_6308
; ---------------------------------------------------------------------------

p7Bloc_633E:
		cp		21h ; '!'
		jr		nz, p7Bloc_6349
		call	j_CursorLeft
		jr		z, p7Bloc_6308
		jr		p7Bloc_634D
; ---------------------------------------------------------------------------

p7Bloc_6349:
		cp		0Ah
		jr		nz, p7Bloc_639F

p7Bloc_634D:
		res		textInsMode, (iy+textFlags)
		call	j_BufDelete
		call	j_BUFPEEK
		jr		z, p7Bloc_6386
		call	p7Bsub_5C44
		call	p7Bsub_6424
		jr		c, p7Bloc_6386
		ld		hl, (editCursor)
		call	j_GetPrevTok
		call	j_SGetTokString
		ld		b, (hl)
		ld		e, b
		ld		d, 0
		add		hl, de
		ld		a, (hl)
		call	j_LoadPattern
		ld		a, (hl)
		neg
		ld		hl, penCol
		ld		b, (hl)
		add		a, (hl)
		ld		(hl), a
		call	p7Bsub_61EE
		ld		a, b
		ld		(penCol), a
		call	BCALL_4D14

p7Bloc_6386:
		call	p7Bsub_638B
		jr		p7Bloc_63D0

; =============== S U B	R O U T	I N E =======================================


p7Bsub_638B:

		ld		a, (unk_8198)
		push	af
		ld		hl, (penCol)
		push	hl
		call	BCALL_4D20
		call	BCALL_4D23
		call	BCALL_4CF3
		jp		p7Bloc_5FFB
; End of function p7Bsub_638B

; ---------------------------------------------------------------------------

p7Bloc_639F:
		cp		0Ch
		jp		z, j_RCLREGEQ_CALL
		call	page0_1808
		jp		z, j_initNamePrompt2
		cp		0Dh
		jp		nz, p7Bloc_63CA
		call	CanAlphIns

p7Bloc_63B2:
		call	IsAtTop
		jr		z, p7Bloc_63BC
		call	j_cursorUp
		jr		p7Bloc_63B2
; ---------------------------------------------------------------------------

p7Bloc_63BC:
		call	GETLASTENTRY
		call	j_RCLENTRYTOEDIT
		call	j_BufToTop
		call	p7Bsub_638B
		jr		p7Bloc_63CD
; ---------------------------------------------------------------------------

p7Bloc_63CA:
		call	Page0Call_2FF1

p7Bloc_63CD:
		call	BCALL_4CF3

p7Bloc_63D0:
		jp		p7Bloc_580C
; ---------------------------------------------------------------------------

BCALL_4CEA:
		call	p7Bsub_588E
		set		1, (iy+2Ah)
		xor		a
		ld		(unk_8198), a
		call	page0_166E
		call	j_setupEditEqu
		call	j_cursorToOffset
		bit		6, (iy+2Bh)
		jp		z, BCALL_4CF3

errchkalphabox:
		call	BCALL_4E2E
		jr		p7Bloc_63CD

; =============== S U B	R O U T	I N E =======================================


BCALL_4E2E:
		ld		hl, (unk_8160)
		ld		de, (unk_8172)
		ld		a, (unk_8162)
		push	af
		call	BCALL_4E37
		pop		af
		ld		(unk_8162), a
		ret
; End of function BCALL_4E2E


; =============== S U B	R O U T	I N E =======================================


BCALL_4D2C:



		jp		c, BCALL_4CDE
		call	BCALL_4CE7
		ld		a, (penCol+1)
		cp		33h ; '3'
		ret		c
		ld		a, 80h ; '�'
		ld		d, a
		ld		hl, 800h
		ld		bc, 708h
		call	j_AppScreenUpDown1
		ld		a, e
		call	j_ClearRow
		ret
; End of function BCALL_4D2C

; ---------------------------------------------------------------------------
		ret

; =============== S U B	R O U T	I N E =======================================


p7Bsub_6424:
		; BCALL_4D11+2Fp ...
		dec		a
		ld		hl, penCol
		add		a, (hl)
		ld		hl, SmallEditColumnRight
		cp		(hl)
		ret
; End of function p7Bsub_6424


; =============== S U B	R O U T	I N E =======================================


GetDispRowOffset:

		and		7Fh ; ''
		ld		l, a
		ld		h, 0
		add		hl, hl
		add		hl, hl
		push	hl
		pop		de
		add		hl, de
		add		hl, de
		ret
; End of function GetDispRowOffset

; ---------------------------------------------------------------------------

FillRectPattern:
		ld		a, i
		push	af
		di
		res		5, (iy+2Ah)
		ld		a, l
		ld		(unk_866A), a
		ld		a, d
		ld		(ioPrompt), a
		ld		a, e
		ld		(unk_866B), a
		ld		(penCol), hl
		ld		a, (dImageWidth)
		ld		d, a
		ld		a, h
		jr		p7Bloc_6473
; ---------------------------------------------------------------------------

p7Bloc_6458:
		bit		5, (iy+2Ah)
		jr		z, p7Bloc_6462
		pop		af
		ret		po
		ei
		ret
; ---------------------------------------------------------------------------

p7Bloc_6462:
		ld		a, (unk_866A)
		ld		(penCol), a
		ld		hl, (penCol)
		ld		a, (dImageWidth)
		ld		d, a
		add		a, h
		ld		(penCol+1), a

p7Bloc_6473:
		ld		hl, ioPrompt
		add		a, d
		dec		a
		sub		(hl)
		jr		c, p7Bloc_6487
		set		5, (iy+2Ah)
		jr		z, p7Bloc_6487
		neg
		add		a, d
		ld		(dImageWidth), a

p7Bloc_6487:
		ld		a, (unk_8661)
		push	af
		ld		d, a
		ld		a, (penCol)
		ld		hl, 866Bh
		add		a, d
		dec		a
		sub		(hl)
		jr		c, p7Bloc_64BF
		jr		z, p7Bloc_64BF
		ld		b, a
		neg
		add		a, d
		or		a
		push	af
		push	bc
		ld		hl, 8662h
		push	hl
		ld		de, varCurrent
		call	Mov8B
		pop		hl
		pop		bc
		ld		a, (dImageWidth)
		ld		d, a

p7Bloc_64B0:
		push	bc
		ld		a, (hl)

p7Bloc_64B2:
		srl	a
		djnz	p7Bloc_64B2
		ld		(hl), a
		inc		hl
		pop		bc
		dec		d
		jr		nz, p7Bloc_64B0
		pop		af
		jr		p7Bloc_64C1
; ---------------------------------------------------------------------------

p7Bloc_64BF:
		ld		a, d
		scf

p7Bloc_64C1:
		push	af
		ld		(unk_8661), a
		ld		a, (dImageWidth)
		ld		(customHeight), a
		ld		hl, (penCol)
		push	hl
		call	p7Bsub_6503
		pop		hl
		bit		plotLoc, (iy+plotFlags)
		jr		nz, p7Bloc_64E7
		ld		(penCol), hl
		set		textWrite, (iy+sGrFlags)
		call	p7Bsub_6503
		res		textWrite, (iy+sGrFlags)

p7Bloc_64E7:
		pop		af
		jr		c, p7Bloc_64F3
		ld		de, 8662h
		ld		hl, varCurrent
		call	Mov8B

p7Bloc_64F3:
		pop		af
		ld		(unk_8661), a
		ld		a, (unk_866B)
		ld		hl, penCol
		cp		(hl)
		jp		c, p7Bloc_6458
		jr		p7Bloc_6487

; =============== S U B	R O U T	I N E =======================================


p7Bsub_6503:
		set		customFont, (iy+fontFlags)
		ld		hl, 8661h
		call	j_VPutMapRec
		res		customFont, (iy+fontFlags)
		ret
; End of function p7Bsub_6503


; =============== S U B	R O U T	I N E =======================================


EraseRectBorder:
		ld		b, 0
		jr		p7Bloc_6518
; End of function EraseRectBorder


; =============== S U B	R O U T	I N E =======================================


DrawRectBorder:
		; BlinkCellNoLookUp+4Fp ...
		ld		b, 1

p7Bloc_6518:
		bit		fullScrnDraw, (iy+apiFlg4)
		push	af
		set		fullScrnDraw, (iy+apiFlg4)
		ld		a, 3Fh ; '?'
		sub		h
		ld		h, l
		ld		l, a
		ld		a, 3Fh ; '?'
		sub		d
		ld		d, e
		ld		e, a
		push	hl
		ld		h, b
		pop		bc
		push	bc
		ld		b, d
		call	j_ILine
		pop		bc
		push	bc
		ld		c, e
		call	j_ILine
		pop		bc
		push	de
		ld		d, b
		call	j_ILine
		pop		de
		ld		e, c
		call	j_ILine
		pop		af
		ret		nz
		res		fullScrnDraw, (iy+apiFlg4)
		ret
; End of function DrawRectBorder

; ---------------------------------------------------------------------------

DrawRectBorderClear:
		push	hl
		push	de
		call	DrawRectBorder
		pop		de
		pop		hl
		inc		h
		inc		l
		dec		d
		dec		e

; =============== S U B	R O U T	I N E =======================================


ClearRect:
		; p7Bsub_6C38+50j
		ld		c, 2
		jr		p7Bloc_6560
; ---------------------------------------------------------------------------

FillRect:
		ld		c, 0
		jr		p7Bloc_6560
; ---------------------------------------------------------------------------

InvertRect:
		ld		c, 1

p7Bloc_6560:
		ld		a, i
		push	af
		di
		ld		a, d
		sub		h
		inc		a
		ld		(unk_8127), a
		ld		a, h
		add		a, 80h ; '�'
		ld		(unk_8125), a
		push	de
		ld		a, l
		ld		hl, MysteryTable2
		call	p7Bsub_5EA2
		ld		(unk_8128), a
		ld		a, b
		ld		(unk_8124), a
		pop		de
		ld		a, e
		ld		hl, MysteryTable3
		call	p7Bsub_5EA2
		ld		(unk_8129), a
		ld		a, b
		ld		hl, 8124h
		sub		(hl)
		inc		a
		ld		(unk_8126), a
		call	SetYUp
		ld		a, (unk_8127)
		ld		b, a
		ld		a, (unk_8125)

p7Bloc_659D:
		res		4, (iy+2Ah)
		push	bc
		push	af
		call	lcd_busy
		out		(10h), a
		call	GetDispRowOffset
		ex		de, hl
		ld		a, (unk_8124)
		and		1Fh
		ld		l, a
		ld		h, 0
		add		hl, de
		ex		de, hl
		ld		hl, saveSScreen
		add		hl, de
		ex		de, hl
		push	bc
		ld		bc, plotSScreen
		add		hl, bc
		pop		bc
		push	hl
		push	de
		call	p7Bsub_663A
		call	lcd_busy
		in		a, (11h)

p7Bloc_65CB:
		; ClearRect+A4j
		call	lcd_busy
		in		a, (11h)
		push	hl
		ld		hl, 812Ah
		bit		0, c
		jr		nz, p7Bloc_65DD
		or		(hl)
		bit		1, c
		jr		z, p7Bloc_65DE

p7Bloc_65DD:
		xor		(hl)

p7Bloc_65DE:
		ld		(de), a
		ld		(hl), 0FFh
		pop		hl
		inc		hl
		inc		de
		ld		a, b
		or		a
		jr		z, p7Bloc_65FC
		djnz	p7Bloc_65CB
		ld		a, (unk_8129)
		ld		(unk_812A), a
		ld		b, 1
		bit		4, (iy+2Ah)
		set		4, (iy+2Ah)
		jr		z, p7Bloc_65CB

p7Bloc_65FC:
		pop		de
		pop		hl
		res		4, (iy+2Ah)
		call	p7Bsub_663A

p7Bloc_6605:
		; ClearRect+D4j
		ld		a, (de)
		bit		plotLoc, (iy+plotFlags)
		jr		nz, p7Bloc_660D
		ld		(hl), a

p7Bloc_660D:
		call	lcd_busy
		out		(11h), a
		inc		de
		inc		hl
		ld		a, b
		or		a
		jr		z, p7Bloc_662C
		djnz	p7Bloc_6605
		ld		a, (unk_8129)
		ld		(unk_812A), a
		ld		b, 1
		bit		4, (iy+2Ah)
		set		4, (iy+2Ah)
		jr		z, p7Bloc_6605

p7Bloc_662C:
		pop		af
		inc		a
		pop		bc
		dec		b
		jp		nz, p7Bloc_659D
		call	SetXUp
		pop		af
		ret		po
		ei
		ret
; End of function ClearRect


; =============== S U B	R O U T	I N E =======================================


p7Bsub_663A:
		; ClearRect+ACp
		ld		a, (unk_8126)
		dec		a
		ld		b, a

p7Bloc_663F:
		ld		a, (unk_8128)
		jr		nz, p7Bloc_664A
		push	hl
		ld		hl, 8129h
		and		(hl)
		pop		hl

p7Bloc_664A:
		ld		(unk_812A), a
		ld		a, (unk_8124)
		bit		7, a
		ret		nz
		call	lcd_busy
		out		(10h), a
		ret
; End of function p7Bsub_663A


; =============== S U B	R O U T	I N E =======================================


p7Bsub_6659:
		ld		a, (unk_8126)
		dec		a
		ld		b, a
		ld		a, (unk_8664)
		ld		hl, 8124h
		cp		(hl)
		jr		p7Bloc_663F
; End of function p7Bsub_6659


; =============== S U B	R O U T	I N E =======================================


p7Bsub_6667:

		ld		hl, MysteryTable2
		call	p7Bsub_5EA2
		ld		(unk_8128), a
		ld		c, 0
		cp		0FFh
		jr		z, p7Bloc_667D

p7Bloc_6676:
		srl	a
		jr		nc, p7Bloc_667D
		inc		c
		jr		p7Bloc_6676
; ---------------------------------------------------------------------------

p7Bloc_667D:
		ld		a, c
		ld		(ioPrompt), a
		ret
; End of function p7Bsub_6667


; =============== S U B	R O U T	I N E =======================================


p7Bsub_6682:
		bit		3, (iy+2Ah)
		ret		nz
		bit		5, (iy+2Bh)
		ret		nz
		cp		a
		ret
; End of function p7Bsub_6682

; ---------------------------------------------------------------------------

DisplayImage:
		ld		a, i
		push	af
		di
		ld		a, e
		ld		(unk_8124), a
		ld		a, (hl)
		add		a, d
		cp		40h ; '@'
		jr		c, p7Bloc_66A1
		ld		a, 40h ; '@'
		sub		d
		jr		p7Bloc_66A2
; ---------------------------------------------------------------------------

p7Bloc_66A1:
		sub		d

p7Bloc_66A2:
		ld		(unk_8127), a
		res		5, (iy+2Bh)
		ld		a, d
		add		a, 80h ; '�'
		jr		nc, p7Bloc_66B4
		add		a, 80h ; '�'
		set		5, (iy+2Bh)

p7Bloc_66B4:
		ld		(unk_8125), a
		push	hl
		push	de
		res		3, (iy+2Ah)
		ld		a, e
		bit		7, a
		jr		z, p7Bloc_66DD
		set		3, (iy+2Ah)
		ld		a, 0
		call	p7Bsub_6667
		pop		de
		push	de
		ld		a, e
		neg

p7Bloc_66D0:
		sub		8
		jr		z, p7Bloc_66D6
		jr		nc, p7Bloc_66D0

p7Bloc_66D6:
		add		a, 8
		ld		(ioPrompt), a
		jr		p7Bloc_66E8
; ---------------------------------------------------------------------------

p7Bloc_66DD:
		call	p7Bsub_6667
		ld		hl, 8124h
		bit		7, (hl)
		jr		nz, p7Bloc_66E8
		ld		(hl), b

p7Bloc_66E8:
		pop		de
		pop		hl
		ld		a, e
		inc		hl
		add		a, (hl)
		dec		a
		cp		60h ; '`'
		jr		c, p7Bloc_66F4
		ld		a, 5Fh ; '_'

p7Bloc_66F4:
		push	hl
		ld		hl, MysteryTable3
		call	p7Bsub_5EA2
		ld		(unk_8129), a
		ld		a, b
		ld		(unk_8664), a
		pop		hl
		ld		a, (hl)
		ld		(dImageWidth), a
		dec		a
		srl	a
		srl	a
		srl	a
		inc		a
		ld		(unk_8126), a
		inc		hl
		call	SetYUp
		ld		a, (unk_8127)
		ld		b, a
		ld		a, (unk_8125)

p7Bloc_671D:
		res		4, (iy+2Ah)
		push	af
		push	bc
		push	hl
		bit		5, (iy+2Bh)
		jr		nz, p7Bloc_6732
		call	lcd_busy
		out		(10h), a
		call	GetDispRowOffset

p7Bloc_6732:
		ld		a, (dImageWidth)
		ld		(unk_8665), a
		ld		a, (unk_8124)
		ld		(curY), a
		bit		7, a
		jr		z, p7Bloc_6746
		set		3, (iy+2Ah)

p7Bloc_6746:
		ex		de, hl
		ld		a, (curY)
		bit		3, (iy+2Ah)
		jr		z, p7Bloc_675B
		ld		hl, ioPrompt
		add		a, (hl)
		ld		(curY), a
		ld		a, 0
		jr		p7Bloc_6760
; ---------------------------------------------------------------------------

p7Bloc_675B:
		ld		(curY), a
		and		1Fh

p7Bloc_6760:
		ld		l, a
		ld		h, 0
		add		hl, de
		ld		bc, plotSScreen
		add		hl, bc
		ld		(unk_8661), hl
		call	p7Bsub_6659
		call	p7Bsub_6682
		jr		nz, p7Bloc_6795
		ld		a, (unk_8664)
		ld		hl, 8124h
		cp		(hl)
		pop		hl
		push	bc
		jr		nz, p7Bloc_679E
		ld		a, (unk_812A)
		ld		b, 0

p7Bloc_6783:
		sla	a
		jr		c, p7Bloc_678A
		inc		b
		jr		p7Bloc_6783
; ---------------------------------------------------------------------------

p7Bloc_678A:
		ld		a, b
		or		a
		ld		a, (hl)
		jr		z, p7Bloc_6793

p7Bloc_678F:
		srl	a
		djnz	p7Bloc_678F

p7Bloc_6793:
		jr		p7Bloc_67C0
; ---------------------------------------------------------------------------

p7Bloc_6795:
		pop		hl
		bit		5, (iy+2Bh)
		jp		nz, p7Bloc_6885
		push	bc

p7Bloc_679E:
		ld		a, (ioPrompt)
		or		a
		ld		b, a
		ld		a, (hl)
		jr		z, p7Bloc_67C0
		ld		c, 0

p7Bloc_67A8:
		sla	a
		rl	c
		djnz	p7Bloc_67A8
		ld		(unk_8663), a
		ld		a, (unk_8124)
		bit		7, a
		jr		z, p7Bloc_67BF
		ld		a, 20h ; ' '
		call	lcd_busy
		out		(10h), a

p7Bloc_67BF:
		ld		a, c

p7Bloc_67C0:

		push	hl
		push	af
		ld		a, (unk_8665)
		ld		b, a
		ld		hl, ioPrompt
		ld		a, (hl)
		or		a
		jr		nz, p7Bloc_67CF
		ld		a, 8

p7Bloc_67CF:
		neg
		add		a, b
		ld		(unk_8665), a
		pop		af
		ld		hl, 812Ah
		call	BCALL_4D9E

p7Bloc_67DC:
		bit		plotLoc, (iy+plotFlags)
		jr		nz, p7Bloc_67F3
		ld		hl, curY
		bit		3, (iy+2Ah)
		ld		hl, (unk_8661)
		jr		nz, p7Bloc_67F3
		ld		(hl), a
		inc		hl
		ld		(unk_8661), hl

p7Bloc_67F3:
		ld		a, (curY)
		bit		3, (iy+2Ah)
		jr		z, p7Bloc_6810
		or		a
		jr		z, p7Bloc_6803
		add		a, 8
		jr		p7Bloc_6812
; ---------------------------------------------------------------------------

p7Bloc_6803:
		res		3, (iy+2Ah)
		ld		a, 20h ; ' '
		call	lcd_busy
		out		(10h), a
		jr		p7Bloc_6812
; ---------------------------------------------------------------------------

p7Bloc_6810:
		ld		c, a
		inc		a

p7Bloc_6812:
		ld		(curY), a
		pop		hl
		ld		a, (unk_8665)
		or		a
		ld		b, a
		jr		z, p7Bloc_6887
		ld		a, c
		cp		2Bh ; '+'
		jr		nz, p7Bloc_6824
		jr		p7Bloc_6887
; ---------------------------------------------------------------------------

p7Bloc_6824:
		ld		a, (ioPrompt)
		ld		b, a
		ld		a, (unk_8665)
		cp		9
		jr		nc, p7Bloc_683B
		pop		af
		push	af
		set		4, (iy+2Ah)
		or		a
		jr		nz, p7Bloc_683B
		xor		a
		jr		p7Bloc_6840
; ---------------------------------------------------------------------------

p7Bloc_683B:
		pop		af
		dec		a
		push	af
		inc		hl
		ld		a, (hl)

p7Bloc_6840:
		push	hl
		ld		c, a
		ld		a, b
		or		a
		ld		a, c
		jr		z, p7Bloc_6856
		ld		e, 0

p7Bloc_6849:
		sla	a
		rl	e
		djnz	p7Bloc_6849
		ld		hl, 8663h
		ld		c, (hl)
		ld		(hl), a
		ld		a, c
		or		e

p7Bloc_6856:
		bit		4, (iy+2Ah)
		jr		z, p7Bloc_6864
		ld		hl, 8129h
		call	BCALL_4D9E
		jr		p7Bloc_6874
; ---------------------------------------------------------------------------

p7Bloc_6864:
		bit		bufferOnly, (iy+plotFlag3)
		jr		nz, p7Bloc_6874
		call	p7Bsub_6682
		jr		nz, p7Bloc_6874
		call	lcd_busy
		out		(11h), a

p7Bloc_6874:
		push	af
		ld		a, (unk_8665)
		sub		8
		jr		nc, p7Bloc_687E
		ld		a, 0

p7Bloc_687E:
		ld		(unk_8665), a
		pop		af
		jp		p7Bloc_67DC
; ---------------------------------------------------------------------------

p7Bloc_6885:
		ld		a, b
		push	af

p7Bloc_6887:
		pop		af
		inc		hl
		or		a
		jr		z, p7Bloc_6890
		ld		e, a
		ld		d, 0
		add		hl, de

p7Bloc_6890:
		pop		bc
		pop		af
		inc		a
		jr		nz, p7Bloc_689B
		ld		a, 80h ; '�'
		res		5, (iy+2Bh)

p7Bloc_689B:
		dec		b
		jp		nz, p7Bloc_671D
		call	SetXUp
		pop		af
		ret		po
		ei
		ret

; =============== S U B	R O U T	I N E =======================================


BCALL_4D9E:
		push	hl
		and		(hl)
		ld		c, a
		ld		hl, curY
		bit		3, (iy+2Ah)
		jr		nz, p7Bloc_68C8
		bit		bufferOnly, (iy+plotFlag3)
		jr		z, p7Bloc_68BE
		ld		hl, (unk_8661)
		ld		a, (hl)
		jr		p7Bloc_68C8
; ---------------------------------------------------------------------------

p7Bloc_68BE:
		call	lcd_busy
		in		a, (11h)
		call	lcd_busy
		in		a, (11h)

p7Bloc_68C8:
		; BCALL_4D9E+16j
		pop		hl
		or		(hl)
		xor		(hl)
		or		c
		ld		c, a
		ld		a, (curY)
		call	p7Bsub_6682
		ret		nz
		call	lcd_busy
		out		(10h), a
		call	lcd_busy
		ld		a, c
		bit		bufferOnly, (iy+plotFlag3)
		ret		nz
		out		(11h), a
		ret
; End of function BCALL_4D9E

; ---------------------------------------------------------------------------

initalphabox:
		push	af
		res		cellOverride, (iy+apiFlg4)
		ld		(unk_8156), a
		ld		(unk_8157), de
		push	bc
		pop		de
		ex		de, hl
		add		hl, de
		ex		de, hl
		pop		af
		call	initcellbox
		ld		a, 1
		ld		(unk_8162), a
		set		plotLoc, (iy+plotFlags)
		ret
; ---------------------------------------------------------------------------

BCALL_4E1C:
		ld		a, (unk_8162)
		call	CellBoxManager
		cp		4
		ret		z
		cp		29h ; ')'
		jr		z, p7Bloc_6918
		di
		call	p7Bsub_6A42
		ei
		jr		BCALL_4E1C
; ---------------------------------------------------------------------------
; START	OF FUNCTION CHUNK FOR BCALL_4E22

p7Bloc_6918:
		; BCALL_4E22+2j
		ld		a, d
		or		a
		jr		nz, p7Bloc_692D
		ld		(keyExtend), a
		ld		a, e
		ld		(kbdKey), a
		cp		7
		jr		z, p7Bloc_693B
		cp		8
		jr		z, p7Bloc_693B
		jr		p7Bloc_6934
; ---------------------------------------------------------------------------

p7Bloc_692D:
		ld		(kbdKey), a
		ld		a, e
		ld		(keyExtend), a

p7Bloc_6934:
		ld		a, 29h ; ')'
		ret
; END OF FUNCTION CHUNK	FOR BCALL_4E22

; =============== S U B	R O U T	I N E =======================================


BCALL_4E22:



		cp		29h ; ')'
		jr		z, p7Bloc_6918

p7Bloc_693B:
		; BCALL_4E22-Ej
		di
		call	CellkHandle
		ei
		ld		a, 28h ; '('
		ret
; End of function BCALL_4E22


; =============== S U B	R O U T	I N E =======================================


setmodecellflag:
		call	getmodecellflag
		or		c
		ld		(hl), a
		ret
; End of function setmodecellflag


; =============== S U B	R O U T	I N E =======================================


resetmodecellflag:
		call	setmodecellflag
		xor		c
		ld		(hl), a
		ret
; End of function resetmodecellflag

; ---------------------------------------------------------------------------

iscurmodecellset:
		ld		a, (unk_8162)

; =============== S U B	R O U T	I N E =======================================


ismodecellset:
		call	getmodecellflag
		and		c
		ret
; End of function ismodecellset


; =============== S U B	R O U T	I N E =======================================


getcurmodecellflag:
		ld		a, (unk_8162)
; End of function getcurmodecellflag


; =============== S U B	R O U T	I N E =======================================


getmodecellflag:
		; ismodecellsetp
		push	af
		ld		a, (unk_8171)
		call	BCALL_4E31
		pop		bc
		add		a, b
		dec		a
		ld		b, a
		and		7
		ld		e, a
		ld		d, 0
		ld		hl, {+}
		add		hl, de
		ld		c, (hl)
		ld		a, b
		srl	a
		srl	a
		srl	a
		ld		e, a
		ld		hl, (unk_8163)
		add		hl, de
		ld		a, (hl)
		ret

+:		.db		80h	; �
		.db		40h	; @
		.db		20h
		.db		10h
		.db		8
		.db		4
		.db		2
		.db		1

; =============== S U B	R O U T	I N E =======================================


BCALL_4E31:
		; BCALL_4DDD+19p ...
		dec		a
		jr		nz, p7Bloc_6992
		ld		hl, (unk_8157)
		call	page0_190B
		ld		(unk_812B), a
		ret
; ---------------------------------------------------------------------------

p7Bloc_6992:
		ld		b, a
		push	bc
		ld		hl, (unk_8157)
		call	page0_190B
		inc		a

p7Bloc_699B:
		push	af
		call	BCALL_4E46
		pop		af
		pop		bc
		dec		b
		ret		z
		ld		hl, 812Bh
		add		a, (hl)
		inc		a
		push	bc
		jr		p7Bloc_699B
; End of function BCALL_4E31


; =============== S U B	R O U T	I N E =======================================


BCALL_4DDD:
		; BCALL_4E25+7p ...
		ld		a, (unk_8162)

BCALL_4E49:

		bit		3, (iy+2Bh)
		jr		z, p7Bloc_69BB
		ld		b, a
		ld		a, 2Bh ; '+'
		call	BCALL_4DEF
		ret		nz

p7Bloc_69BB:
		ld		b, a
		ld		a, (unk_8171)
		cp		1
		jr		z, p7Bloc_69CA
		push	bc
		call	BCALL_4E31
		pop		bc
		add		a, b
		ld		b, a

p7Bloc_69CA:
		ld		a, b
		jp		BCALL_4E46
; End of function BCALL_4DDD


; =============== S U B	R O U T	I N E =======================================


BCALL_4DE6:
		; p7Bsub_5935-124p ...
		di
		call	BCALL_4DDD
		ld		a, (unk_812B)
		bit		0, a
		ret		z
		in		a, (6)
		ld		hl, cellCursorHook
		call	setCursorHook
		set		cursorHookActive, (iy+hookflags2Override)
		res		curLock, (iy+curFlags)
		call	j_CursorOn
		ret
; End of function BCALL_4DE6


; =============== S U B	R O U T	I N E =======================================


CellBoxManager:
		ld		(unk_8162), a

startnewcell:
		call	BCALL_4DE6
		ei
		call	j_getkey
		ld		(kbdKey), a
; End of function CellBoxManager


; =============== S U B	R O U T	I N E =======================================


BCALL_4E25:
		push	af
		call	j_CursorOff
		call	ClrCursorHook
		call	BCALL_4DDD
		pop		af
		cp		5
		jr		nc, p7Bloc_6A26
		ld		hl, (unk_812E)
		ld		de, (unk_8130)
		ld		b, h
		cp		2
		jr		z, p7Bloc_6A1F
		ld		b, l
		cp		1
		jr		z, p7Bloc_6A1F
		ld		b, e
		cp		3
		jr		z, p7Bloc_6A1F
		ld		b, d

p7Bloc_6A1F:
		; BCALL_4E25+1Ej ...
		ld		a, b
		ld		(unk_816C), a
		ld		a, 28h ; '('
		ret
; ---------------------------------------------------------------------------

p7Bloc_6A26:
		ld		a, 4
		ret		nz
		ld		de, (unk_8132)
		ld		a, 29h ; ')'
		ret
; End of function BCALL_4E25


; =============== S U B	R O U T	I N E =======================================


eraseallcells:
		; CellkHandle+23p
		ld		a, (unk_8170)
		ld		b, a

p7Bloc_6A34:
		push	bc
		ld		a, b
		call	ClearCell
		pop		bc
		djnz	p7Bloc_6A34
		ld		a, 1
		ld		(unk_8162), a
		ret
; End of function eraseallcells


; =============== S U B	R O U T	I N E =======================================


p7Bsub_6A42:
		ret		z
; End of function p7Bsub_6A42


; =============== S U B	R O U T	I N E =======================================


CellkHandle:



		ld		a, (kbdKey)
		cp		7
		jr		nz, p7Bloc_6A62
		call	eraseallcells
		ld		hl, 8171h
		inc		(hl)

p7Bloc_6A51:
		ld		a, (hl)
		call	BCALL_4E31
		ld		a, (unk_812B)
		ld		b, a
		call	BCALL_4E34
		ld		a, 1
		ld		(unk_8162), a
		ret
; ---------------------------------------------------------------------------

p7Bloc_6A62:
		cp		8
		jr		nz, p7Bloc_6A6F
		call	eraseallcells
		ld		hl, 8171h
		dec		(hl)
		jr		p7Bloc_6A51
; ---------------------------------------------------------------------------

p7Bloc_6A6F:
		cp		5
		jr		z, p7Bloc_6A8D
		ret		nc
		call	BlinkCurCellToOff
		call	ClearCurCell
		ld		hl, 8162h
		ld		a, (hl)
		ld		(hl), 0
		call	drawcell
		ld		a, (unk_816C)
		ld		(unk_8162), a
		call	drawcell
		ret
; ---------------------------------------------------------------------------

p7Bloc_6A8D:
		ld		hl, 812Bh
		bit		3, (hl)
		ret		z
		call	getcurmodecellflag
		push	bc
		push	hl
		call	BCALL_4DDD
		pop		hl
		pop		bc
		ld		a, (unk_8134)
		or		a
		ld		a, (hl)
		jr		z, p7Bloc_6AD2
		and		c
		jr		nz, BlinkCurCellToOn
		ld		a, (hl)
		or		c
		ld		(hl), a
		ld		hl, 812Bh
		ld		a, (unk_8134)

p7Bloc_6AB0:
		push	af
		push	hl
		call	BCALL_4E40
		pop		hl
		push	hl
		ld		a, (unk_8162)
		cp		(hl)
		jr		z, p7Bloc_6AC9
		ld		a, (hl)
		or		a
		jr		z, p7Bloc_6ACE
		push	af
		call	resetmodecellflag
		pop		af
		call	BlinkCellToOff

p7Bloc_6AC9:
		pop		hl
		inc		hl
		pop		af
		jr		p7Bloc_6AB0
; ---------------------------------------------------------------------------

p7Bloc_6ACE:
		pop		hl
		pop		af
		jr		BlinkCurCellToOn
; ---------------------------------------------------------------------------

p7Bloc_6AD2:
		xor		c
		ld		(hl), a
		and		c
		jr		nz, BlinkCurCellToOn
		jr		BlinkCurCellToOff
; End of function CellkHandle


; =============== S U B	R O U T	I N E =======================================


BlinkCurCellToOff:
		ld		a, (unk_8162)
; End of function BlinkCurCellToOff


; =============== S U B	R O U T	I N E =======================================


BlinkCellToOff:
		ld		(unk_8176), a
		call	BCALL_4E49

BlinkCellToOffNoLookUp:
		ld		a, 24h ; '$'
		jr		BlinkCellNoLookUp

cellCursorhook:
		add		a, e
CellCursorHandle:
		push	bc
		ld		hl, (penCol)
		push	hl
		push	af
		ld		a, (unk_8162)
		ld		(unk_8176), a
		call	BCALL_4E49
		pop		af
		call	BlinkCellNoLookUp
		pop		hl
		ld		hl, (penCol)
		ld		a, (unk_816B)
		bit		2, a
		pop		bc
		ld		a, b
		ret

; =============== S U B	R O U T	I N E =======================================


p7Bsub_6B06:
		inc		hl
		bit		0, (hl)
		inc		hl
		ld		e, (hl)
		inc		hl
		ld		a, (hl)
		ret		nz
		ld		d, 0
		inc		e
		add		hl, de
		add		a, (hl)
		ret
; End of function p7Bsub_6B06

; ---------------------------------------------------------------------------
; START	OF FUNCTION CHUNK FOR CellkHandle

BlinkCurCellToOn:
		; CellkHandle+8Dj ...
		ld		a, (unk_8162)

BlinkCellToOn:
		ld		(unk_8176), a
		call	BCALL_4E49

BlinkCellToOnNoLookUp:
		ld		a, 23h ; '#'
		jr		BlinkCellNoLookUp
; END OF FUNCTION CHUNK	FOR CellkHandle
; ---------------------------------------------------------------------------

BlinkCurCell:
		ld		a, (unk_8162)

BlinkCell:
		ld		(unk_8176), a
		call	BCALL_4E49

; =============== S U B	R O U T	I N E =======================================


BlinkCellNoLookUp:

		ld		hl, 812Bh
		bit		5, (hl)
		jr		z, p7Bloc_6B38
		ld		b, a
		ld		a, 2Ah ; '*'
		call	BCALL_4DEF
		ret
; ---------------------------------------------------------------------------

p7Bloc_6B38:
		bit		4, (hl)
		jr		z, p7Bloc_6B47
		cp		24h ; '$'
		push	af
		call	nz, ClearBlnkCell
		pop		af
		call	z, drawblnkcell
		ret
; ---------------------------------------------------------------------------

p7Bloc_6B47:
		bit		1, (hl)
		ld		hl, 8135h
		jr		z, p7Bloc_6B5C
		cp		24h ; '$'
		push	af
		call	ClearBlnkCell
		call	drawblnkcell
		pop		af
		call	nz, invertblnkcell
		ret
; ---------------------------------------------------------------------------

p7Bloc_6B5C:
		cp		24h ; '$'
		push	af
		ld		a, (hl)
		cp		0FEh ; '�'
		jr		z, p7Bloc_6B81
		jr		nc, p7Bloc_6B97
		call	SStringLength
		ld		hl, (unk_812C)
		dec		h
		dec		l
		dec		l
		add		a, l
		add		a, 3
		ld		e, a
		ld		a, h
		add		a, 8

p7Bloc_6B76:
		; BlinkCellNoLookUp+82j
		ld		d, a
		pop		af
		push	af
		call	nz, DrawRectBorder
		pop		af
		call	z, EraseRectBorder
		ret
; ---------------------------------------------------------------------------

p7Bloc_6B81:
		inc		hl
		ld		a, (hl)
		add		a, a
		add		a, a
		add		a, (hl)
		add		a, (hl)
		ld		hl, (unk_812C)
		dec		l
		dec		l
		dec		h
		dec		h
		add		a, l
		add		a, 2
		ld		e, a
		ld		a, h
		add		a, 0Ah
		jr		p7Bloc_6B76
; ---------------------------------------------------------------------------

p7Bloc_6B97:
		call	p7Bsub_6B06
		ld		hl, (unk_812C)
		dec		l
		dec		l
		dec		h
		dec		h
		add		a, l
		add		a, 3
		ld		e, a
		ld		a, (unk_8137)
		add		a, 2
		add		a, h
		ld		d, a
		jr		p7Bloc_6B76
; End of function BlinkCellNoLookUp


; =============== S U B	R O U T	I N E =======================================


initcellbox:
		ld		a, 1
		jr		nc, p7Bloc_6BB3
		dec		a

p7Bloc_6BB3:
		ld		(unk_8174), a
		ld		a, 1
		ld		(unk_8171), a
		ld		a, (iy+0Ch)
		ld		(unk_816B), a
		ld		(unk_8163), bc
; End of function initcellbox


; =============== S U B	R O U T	I N E =======================================


BCALL_4E37:
		ld		(unk_8160), hl
		ld		(unk_8172), de
		push	de
		call	ClearRect
		pop		de
		ld		a, (unk_8174)
		sub		1
		ld		hl, (unk_8160)
		call	c, DrawRectBorder
		ld		a, (unk_8171)
		call	BCALL_4E31
		ld		a, (unk_812B)
		ld		b, a
; End of function BCALL_4E37


; =============== S U B	R O U T	I N E =======================================


BCALL_4E34:
		ld		(unk_8170), a
		xor		a
		ld		(unk_8162), a

p7Bloc_6BED:
		push	bc
		ld		a, b
		call	drawcell
		pop		bc
		djnz	p7Bloc_6BED
		ret
; End of function BCALL_4E34

; ---------------------------------------------------------------------------

covercurcell:
		ld		a, (unk_8162)

covercell:
		ld		c, 3
		jr		BCALL_4DA1

; =============== S U B	R O U T	I N E =======================================


ClearBlnkCell:
		; BlinkCellNoLookUp+27p
		ld		a, (unk_8176)
		jr		ClearCell
; End of function ClearBlnkCell


; =============== S U B	R O U T	I N E =======================================


ClearCurCell:
		ld		a, (unk_8162)
; End of function ClearCurCell


; =============== S U B	R O U T	I N E =======================================


ClearCell:
		; ClearBlnkCell+3j
		ld		c, 2
		ld		d, 26h ; '&'
		jr		BCALL_4DEC
; End of function ClearCell


; =============== S U B	R O U T	I N E =======================================


invertblnkcell:
		ld		a, (unk_8176)
		jr		invertcell
; ---------------------------------------------------------------------------

invertcurcell:
		ld		a, (unk_8162)

invertcell:
		; p7Bsub_6C38+89j
		ld		c, 1
		ld		d, 27h ; '''
		jr		BCALL_4DEC
; End of function invertblnkcell


; =============== S U B	R O U T	I N E =======================================


drawblnkcell:
		; BlinkCellNoLookUp+2Ap
		ld		a, (unk_8176)
		jr		drawcell
; End of function drawblnkcell

; ---------------------------------------------------------------------------

drawcurcell:
		ld		a, (unk_8162)

; =============== S U B	R O U T	I N E =======================================


drawcell:
		; CellkHandle+46p ...
		ld		c, 0
		ld		d, 25h ; '%'

BCALL_4DEC:
		; invertblnkcell+Cj
		ld		b, a
		ld		a, d
		call	BCALL_4DEF
		ret		nz

BCALL_4D74:
		ld		a, b

BCALL_4DA1:
		ld		hl, (penCol)
		push	hl
		call	p7Bsub_6C38
		pop		hl
		ld		(penCol), hl
		ret
; End of function drawcell


; =============== S U B	R O U T	I N E =======================================


p7Bsub_6C38:
		ld		(unk_8175), a
		push	bc
		call	BCALL_4E49
		ld		hl, (unk_812C)
		ld		(penCol), hl
		pop		bc
		res		textEraseBelow, (iy+textFlags)
		ld		a, (unk_8135)
		cp		0FEh ; '�'
		ld		a, c
		jr		z, p7Bloc_6CCA
		jp		nc, p7Bloc_6CE7
		ld		hl, 8135h
		or		a
		jr		z, p7Bloc_6C8E
		push	af
		call	SStringLength
		ld		b, 5

p7Bloc_6C61:
		; p7Bsub_6C38:p7Bloc_6CFBj
		ld		hl, (penCol)
		add		a, l
		dec		a
		ld		e, a
		ld		a, h
		add		a, b
		ld		d, a
		ld		a, (unk_8135)
		cp		0FEh ; '�'
		jr		c, p7Bloc_6C75
		jr		nz, p7Bloc_6C82
		jr		p7Bloc_6C7C
; ---------------------------------------------------------------------------

p7Bloc_6C75:
		ld		a, d
		inc		a
		cp		41h ; 'A'
		jr		z, p7Bloc_6C7C
		ld		d, a

p7Bloc_6C7C:
		ld		a, l
		sub		1
		jr		c, p7Bloc_6C82
		ld		l, a

p7Bloc_6C82:
		pop		af
		sub		2
		jp		c, InvertRect
		jp		z, ClearRect
		jp		FillRect
; ---------------------------------------------------------------------------

p7Bloc_6C8E:
		ld		b, (hl)
		inc		hl
		call	j_VPutSN
		res		fracDrawLFont, (iy+fontFlags)
		res		6, (iy+32h)

p7Bloc_6C9B:
		ld		hl, 812Bh
		bit		3, (hl)
		jr		z, p7Bloc_6CB7
		ld		a, (unk_8175)
		call	ismodecellset
		ret		z
		ld		a, (unk_8175)
		call	BCALL_4E49
		ld		hl, 812Bh
		ld		a, (unk_8175)
		jr		p7Bloc_6CBF
; ---------------------------------------------------------------------------

p7Bloc_6CB7:
		ld		a, (unk_8162)
		or		a
		ret		z
		bit		0, (hl)
		ret		nz

p7Bloc_6CBF:
		bit		1, (hl)
		jp		nz, invertcell
		bit		2, (hl)
		ret		z
		jp		BlinkCellToOn
; ---------------------------------------------------------------------------

p7Bloc_6CCA:
		set		fracDrawLFont, (iy+fontFlags)
		ld		hl, 8136h
		or		a
		jr		z, p7Bloc_6C8E
		push	af
		res		6, (iy+32h)
		res		fracDrawLFont, (iy+fontFlags)
		ld		a, (hl)
		add		a, a
		add		a, a
		add		a, (hl)
		add		a, (hl)
		ld		b, 7
		jp		p7Bloc_6C61
; ---------------------------------------------------------------------------

p7Bloc_6CE7:
		or		a
		jr		z, p7Bloc_6CFE
		push	af
		ld		a, (unk_8137)
		dec		a
		ld		b, a
		ld		a, (unk_8137+1)
		ld		hl, 8136h
		bit		0, (hl)
		jr		nz, p7Bloc_6CFB
		add		a, a

p7Bloc_6CFB:
		jp		p7Bloc_6C61
; ---------------------------------------------------------------------------

p7Bloc_6CFE:
		ld		hl, 8138h
		call	p7Bsub_6D1A
		ld		a, (unk_8136)
		cp		1
		jr		z, p7Bloc_6C9B
		ld		hl, 8139h
		ld		de, (unk_8137)
		ld		d, 0
		add		hl, de
		call	p7Bsub_6D1A
		jr		p7Bloc_6C9B
; End of function p7Bsub_6C38


; =============== S U B	R O U T	I N E =======================================


p7Bsub_6D1A:
		ld		a, (unk_8137)
		ld		(customHeight), a
		set		customFont, (iy+fontFlags)
		call	j_VPutMapRec
		res		customFont, (iy+fontFlags)
		ret
; End of function p7Bsub_6D1A

; ---------------------------------------------------------------------------

setcelloverride:
		ld		(unk_815D), hl
		ld		(unk_815F), a
		set		cellOverride, (iy+apiFlg4)
		ret

; =============== S U B	R O U T	I N E =======================================


BCALL_4DEF:
		; BlinkCellNoLookUp+Ap	...
		bit		cellOverride, (iy+apiFlg4)
		ret		z
		push	bc
		push	hl
		push	de
		ld		hl, j_GetFirstInvalidAppPageToB
		ld		de, 815Ah
		call	page0_118F
		pop		de
		pop		hl
		pop		bc
		call	unk_815A
		ret
MemClear:
		xor		a
MemSet:
		ld		(hl), a
		ld		e, l
		ld		d, h
		inc		de
		dec		bc
		ldir
		ret

ExecuteONSCRPT:
		ld		hl, aONSCRPT
-:		rst		20h
		call	ChkFindSym
		ret		c
		call	IsBZero
		ret		nz
		ex		de, hl
		ld		c, (hl)
		inc		hl
		ld		b, (hl)
		ld		de, ramStart
		ldir
		jp		ramStart
ExecuteOFFSCRPT:
		ld		hl, aOFFSCRPT
		jr		{-}
aONSCRPT:
		.asc AppVarObj,'ONSCRPT',0
aOFFSCRPT:
		.asc AppVarObj,'OFFSCRPT',0

DrawCirc2:
		ld		hl, 0A2h ; '�'
		call	AllocFPS1
		call	p7Bsub_6F45
		rst		20h
		ld		de, 9
		add		hl, de
		call	Mov9ToOP2
		push	hl
		rst		30h
		pop		de
		call	MovFrOP1
		call	p7Bsub_6F4A
		push	hl
		call	mov9B2
		call	MovFrOP1
		pop		hl
		call	mov9B2
		push	de
		call	p7Bsub_6F45
		rst		20h
		ld		de, 9
		add		hl, de
		call	Mov9ToOP2
		call	FPSub
		pop		de
		call	MovFrOP1
		call	p7Bsub_6F4A
		push	hl
		call	mov9B2
		call	MovFrOP1
		pop		hl
		call	mov9B2
		call	p7Bsub_6F45
		call	mov9B2
		push	de
		rst		20h
		call	Mov9ToOP2
		rst		30h
		pop		de
		call	MovFrOP1
		call	p7Bsub_6F45
		push	hl
		call	mov9B2
		call	MovFrOP1
		pop		hl
		call	mov9B2
		push	de
		rst		20h
		call	Mov9ToOP2
		call	FPSub
		pop		de
		call	MovFrOP1
		call	p7Bsub_6F45
		call	mov9B2
		call	MovFrOP1
		ld		hl, MysteryCellTable1
		ld		a, 7

p7Bloc_6E06:
		push	af
		rst		20h
		push	hl
		ld		bc, 0FF55h
		ld		hl, (FPS)
		add		hl, bc
		call	Mov9ToOP2
		call	FPMult
		call	CpyO1ToFPS1
		pop		hl
		rst		20h
		push	hl
		call	FPMult
		call	CpyO1ToFPST
		call	p7Bsub_6F45
		call	Mov9ToOP2
		push	hl
		rst		30h
		call	OP1ToOP4
		pop		hl
		call	Mov9ToOP2
		call	CpyTo1FPS1
		rst		30h
		rst		8
		call	OP4ToOP1
		ld		bc, 0FF5Eh
		ld		hl, (FPS)
		add		hl, bc
		call	p7Bsub_6F14
		push	hl
		call	p7Bsub_6F4A
		rst		20h
		call	CpyTo2FPS1
		call	FPSub
		rst		8
		ld		bc, 0FF5Eh
		ld		hl, (FPS)
		add		hl, bc
		rst		20h
		pop		hl
		call	p7Bsub_6F14
		push	hl
		call	CpyTo2FPST
		call	p7Bsub_6F45
		rst		20h
		call	FPSub
		ld		bc, 0FF67h
		ld		hl, (FPS)
		add		hl, bc
		call	Mov9ToOP2
		pop		hl
		call	p7Bsub_6F14
		push	hl
		ld		bc, 0FF79h
		ld		hl, (FPS)
		add		hl, bc
		call	Mov9ToOP2
		rst		20h
		pop		hl
		call	p7Bsub_6F14
		push	hl
		call	CpyTo1FPS1
		call	p7Bsub_6F45
		call	Mov9ToOP2
		rst		30h
		call	OP1ToOP4
		call	p7Bsub_6F4A
		call	Mov9ToOP2
		call	CpyTo1FPST
		rst		30h
		rst		8
		call	OP4ToOP1
		pop		hl
		call	p7Bsub_6F14
		push	hl
		call	p7Bsub_6F45
		rst		20h
		call	CpyTo2FPS1
		call	FPSub
		ld		bc, 0FFAFh
		ld		hl, (FPS)
		add		hl, bc
		call	Mov9ToOP2
		pop		hl
		call	p7Bsub_6F14
		push	hl
		call	CpyTo2FPST
		call	p7Bsub_6F4A
		rst		20h
		call	FPSub
		rst		8
		ld		bc, 0FFA6h
		ld		hl, (FPS)
		add		hl, bc
		rst		20h
		pop		hl
		call	p7Bsub_6F14
		push	hl
		ld		bc, 0FFB8h
		ld		hl, (FPS)
		add		hl, bc
		rst		20h
		ld		bc, 0FFD3h
		ld		hl, (FPS)
		add		hl, bc
		call	Mov9ToOP2
		pop		hl
		call	p7Bsub_6F14
		pop		hl
		pop		af
		dec		a
		jp		nz, p7Bloc_6E06
		call	FPOPCPLX
		ld		bc, 0FFA6h
		call	p7Bsub_6F2F
		ld		bc, 0FF94h
		call	p7Bsub_6F2F
		ld		bc, 0FFB8h
		call	p7Bsub_6F2F
		ld		bc, 0FFA6h
		call	p7Bsub_6F2F
		ld		de, 63h	; 'c'
		call	DeallocFPS1
		ret

; =============== S U B	R O U T	I N E =======================================
p7Bsub_6F14:
		push	hl
		ld		de, OP3
		call	mov9B2
		inc		de
		inc		de
		call	mov9B2
		pop		de
		call	MovFrOP1
		inc		hl
		inc		hl
		call	mov9B2
		push	de
		call	j_CLine
		pop		hl
		ret
; End of function p7Bsub_6F14


; =============== S U B	R O U T	I N E =======================================


p7Bsub_6F2F:
		ld		hl, (FPS)
		add		hl, bc
		ld		de, OP3
		call	mov9B2
		inc		de
		inc		de
		call	mov9B2
		call	POPMCPLXO1
		call	j_CLine
		ret
; End of function p7Bsub_6F2F


; =============== S U B	R O U T	I N E =======================================


p7Bsub_6F45:
		ld		bc, 0FF43h
		jr		p7Bloc_6F4D
; End of function p7Bsub_6F45


; =============== S U B	R O U T	I N E =======================================


p7Bsub_6F4A:
		ld		bc, 0FF4Ch

p7Bloc_6F4D:
		ld		hl, (FPS)
		add		hl, bc
		ret
; End of function p7Bsub_6F4A

MysteryCellTable1:
		.db		0
		.db		7Fh	; 
		.db		10h
		.db		45h	; E
		.db		28h	; (
		.db		46h	; F
		.db		32h	; 2
		.db		67h	; g
		.db		65h	; e
		.db		0
		.db		7Fh	; 
		.db		99h	; �
		.db		45h	; E
		.db		21h	; !
		.db		89h	; 	
		.db		53h	; S
		.db		68h	; h
		.db		27h	; '
		.db		0
		.db		7Fh	; 
		.db		20h
		.db		79h	; y
		.db		11h
		.db		69h	; i
		.db		08h
		.db		17h
		.db		76h	; v
		.db		0
		.db		7Fh	; 
		.db		97h	; �
		.db		81h	; �
		.db		47h	; G
		.db		60h	; `
		.db		07h
		.db		33h	; 3
		.db		81h	; �
		.db		0
		.db		7Fh	; 
		.db		30h	; 0
		.db		90h	; �
		.db		16h
		.db		99h	; �
		.db		43h	; C
		.db		74h	; t
		.db		95h	; �
		.db		0
		.db		7Fh	; 
		.db		95h	; �
		.db		10h
		.db		56h	; V
		.db		51h	; Q
		.db		62h	; b
		.db		95h	; �
		.db		15h
		.db		0
		.db		7Fh	; 
		.db		40h	; @
		.db		67h	; g
		.db		36h	; 6
		.db		64h	; d
		.db		30h	; 0
		.db		75h	; u
		.db		80h	; �
		.db		0
		.db		7Fh	; 
		.db		91h	; �
		.db		35h	; 5
		.db		45h	; E
		.db		45h	; E
		.db		76h	; v
		.db		42h	; B
		.db		60h	; `
		.db		0
		.db		7Fh	; 
		.db		50h	; P
		.db		00h
		.db		00h
		.db		00h
		.db		00h
		.db		00h
		.db		00h
		.db		0
		.db		7Fh	; 
		.db		86h	; �
		.db		60h	; `
		.db		25h	; %
		.db		40h	; @
		.db		37h	; 7
		.db		84h	; �
		.db		44h	; D
		.db		0
		.db		7Fh	; 
		.db		58h	; X
		.db		77h	; w
		.db		85h	; �
		.db		25h	; %
		.db		22h	; "
		.db		92h	; �
		.db		47h	; G
		.db		0
		.db		7Fh	; 
		.db		80h	; �
		.db		90h	; �
		.db		16h
		.db		99h	; �
		.db		43h	; C
		.db		74h	; t
		.db		95h	; �
		.db		0
		.db		7Fh	; 
		.db		66h	; f
		.db		91h	; �
		.db		30h	; 0
		.db		60h	; `
		.db		63h	; c
		.db		58h	; X
		.db		86h	; �
		.db		0
		.db		7Fh	; 
		.db		74h	; t
		.db		31h	; 1
		.db		44h	; D
		.db		82h	; �
		.db		54h	; T
		.db		77h	; w
		.db		39h	; 9

; =============== S U B	R O U T	I N E =======================================


BCALL_4E40:
		ld		b, a
		ld		hl, (unk_8157)
		inc		hl
		inc		hl

p7Bloc_6FD6:
		djnz	p7Bloc_6FDC
		call	IsOP1Num5
		ret
; ---------------------------------------------------------------------------

p7Bloc_6FDC:
		call	page0_18F4
		jr		p7Bloc_6FD6
; End of function BCALL_4E40


; =============== S U B	R O U T	I N E =======================================


BCALL_4E46:
		; BCALL_4DDD+20j
		ld		b, a
		push	bc
		ld		hl, (unk_8157)
		inc		hl
		call	page0_190B
		ld		b, a
		inc		hl

p7Bloc_6FEC:
		call	page0_18F4
		djnz	p7Bloc_6FEC
		pop		bc

p7Bloc_6FF2:
		; BCALL_4E46+52j
		djnz	p7Bloc_7005
		call	IsOP1Num5
		ld		hl, (unk_8160)
		ld		de, (unk_812C)
		add		hl, de
		ld		(unk_812C), hl
		or		1
		ret
; ---------------------------------------------------------------------------

p7Bloc_7005:
		ld		de, 0Ah
		add		hl, de
		call	page0_190B
		cp		0FCh ; '�'
		jr		nz, p7Bloc_7013
		inc		hl
		jr		p7Bloc_6FF2
; ---------------------------------------------------------------------------

p7Bloc_7013:
		cp		0FEh ; '�'
		jr		c, p7Bloc_702B
		inc		hl
		jr		z, p7Bloc_702B
		call	page0_190B
		cp		1
		inc		hl
		call	page0_190B
		jr		z, p7Bloc_7027
		add		a, a
		inc		a

p7Bloc_7027:
		add		a, 2
		jr		p7Bloc_702F
; ---------------------------------------------------------------------------

p7Bloc_702B:
		; BCALL_4E46+37j
		call	page0_190B
		inc		a

p7Bloc_702F:
		ld		e, a
		ld		d, 0
		add		hl, de
		jr		p7Bloc_6FF2

ReloadAppEntryVecs:
		ld		hl, MonDefaultVectors2
		call	AppInit
p7Bsub_703B:
		ld		hl, noErrorEntry
		ld		(mcxErrorEP), hl
		ret
; End of function p7Bsub_703B

; ---------------------------------------------------------------------------

ClearParseVar:
		push	af
		xor		a
		jr		p7Bloc_7049
; ---------------------------------------------------------------------------

SetParseVarProg:
		push	af
		ld		a, 6

p7Bloc_7049:
		ld		(basic_prog), a
		pop		af
		ret
; ---------------------------------------------------------------------------

Page7B_3E2B:
		ld		a, (OP1)
		cp		24h ; '$'
		jr		z, p7Bloc_705D
		call	page0_17BB
		jr		z, p7Bloc_7088
		jp		ErrDataType
; ---------------------------------------------------------------------------

p7Bloc_705D:
		call	j_FindApp
		jp		c, ErrUndefined
		ld		de, progToEdit
		ld		hl, 849Ah
		ld		bc, 8
		ldir
		ld		sp, (onSP)
		res		indicOnly, (iy+indicFlags)
		ld		a, 40h ; '@'
		ld		(mcxCurApp), a
		res		monAbandon, (iy+monFlags)
		res		nocxPutAway, (iy+contextFlags)
		ld		a, 58h ; 'X'
		jp		Mon_SwitchToStandardContext
; ---------------------------------------------------------------------------

p7Bloc_7088:
		call	Page0Call_240E
		ld		hl, ramStart
		ld		(rclQueue), hl
		jr		c, p7Bloc_70B3
		ex		de, hl
		ld		c, (hl)
		inc		hl
		ld		b, (hl)
		ld		a, c
		or		b
		jr		z, p7Bloc_70B3
		inc		hl
		ld		a, (hl)
		cp		0BBh ; '�'
		jr		nz, p7Bloc_70B3
		inc		hl
		ld		a, (hl)
		cp		6Dh ; 'm'
		jr		z, p7Bloc_70AB
		cp		6Ch ; 'l'
		jr		nz, p7Bloc_70B3

p7Bloc_70AB:
		ld		a, 0BBh	; '�'
		ld		(de), a
		inc		de
		ld		a, 6Ah ; 'j'
		ld		(de), a
		inc		de

p7Bloc_70B3:
		ld		hl, OP4
		ld		a, 5Fh ; '_'
		ld		(hl), a
		call	strcopy
		ld		a, 3Fh ; '?'
		ld		(de), a
		inc		de
		set		enableQueue, (iy+rclFlag)
		set		useRclQueueEnd, (iy+hookflags1)
		ld		(rclQueueEnd), de
		set		appTextSave, (iy+appFlags)
		call	last_entry_to_OP1
		call	FINDPROGSYM
		call	nc, DelVar
		ld		hl, 0
		ld		(cmdCursor), hl
		call	CreateProg
		call	j_ClrScrn
		call	j_HomeUp
		call	j_saveCmdShadow
		ld		a, 40h ; '@'
		set		noTempDelete, (iy+hookflags1)
		jp		JForceCmd
; ---------------------------------------------------------------------------
		res		7, a
		jp		JError
; ---------------------------------------------------------------------------

JForceCmdNoChar2:
		jp		JForceCmdNoChar
; ---------------------------------------------------------------------------

JForceCmdNoChar3:
		jp		JForceCmdNoChar
; ---------------------------------------------------------------------------

p7Bloc_70FF:
		bit		0, (iy+29h)
		res		0, (iy+29h)
		ret		nz
		set		0, (iy+2Ah)
		ld		a, (appPage)
		push	af
		ld		hl, 4000h
		call	Page0Call_2C97
		rst		28h
; ---------------------------------------------------------------------------
		.dw		80A8h
; ---------------------------------------------------------------------------
		jr		nz, p7Bloc_714B
		pop		af
		push	af
		call	Page0Call_2C9D
		jr		c, p7Bloc_7124
		jr		z, p7Bloc_714B

p7Bloc_7124:
		pop		af
		push	af
		call	NZIf83Plus
		jr		nz, p7Bloc_712D
		sub		54h ; 'T'

p7Bloc_712D:
		sub		15h
		neg
		ld		b, 0
		ld		c, a
		push	bc
		pop		ix
		call	Page0Call_2CA3
		jr		c, p7Bloc_714B
		jr		nz, p7Bloc_714B
		call	Chk_Batt_Low
		jr		z, p7Bloc_714B
		pop		af
		push	af
		call	Page0Call_2CA9
		call	Page0Call_2E65

p7Bloc_714B:
		pop		af

MonReset:
		call	p7Bsub_51E6
		ld		hl, MonDefaultVectors
		ld		de, mcxMain
		ld		bc, 12
		ldir

AppSetup:
		res		bufferOnly, (iy+plotFlag3)
		res		appRunning, (iy+APIFlg)
		ld		(iy+5),	0
		ld		a, (iy+37h)
		cpl
		ld		hl, 8A24h
		and		(hl)
		ld		(hl), a
		ld		a, (iy+38h)
		cpl

p7Bloc_7173:
		ld		hl, 8A25h
		and		(hl)
		ld		(hl), a
		ld		a, (iy+39h)
		cpl
		ld		hl, 8A26h
		and		(hl)
		ld		(hl), a
		xor		a
		ld		(iy+28h), a
		ld		(iy+29h), a
		ld		(iy+2Ah), a
		ld		(iy+2Bh), a
		ld		(iy+37h), a
		ld		(iy+38h), a
		ld		(iy+39h), a

MonDummyReset:
		ret
MonDefaultVectors:
		.dw		MonDummyReset
		.dw		MonDummyReset
		.dw		MonDummyReset
		.dw		MonDummyReset
		.dw		MonDummyReset
		.dw		MonDummyReset
MonDummyReset2:
		ret
MonDefaultVectors2:
		.dw		MonDummyReset2
		.dw		MonDummyReset2
		.dw		p7Bloc_70FF
		.dw		MonDummyReset2
		.dw		MonDummyReset2
		.dw		MonDummyReset2
		.db		0Ah

MouseMemData:
		.db		9Fh	; �
		.db		25h	; %
		.db		1
		.db		0
		.db		1
		.db		1
		.db		0
		.db		1
		.db		1
		.db		0
		.db		1
		.db		0
		.db		0
		.db		0
		.db		0F0h	; �
		.db		0E0h	; �
		.db		10h
		.db		0E0h	; �
		.db		0C0h	; �
		.db		20h
		.db		0F0h	; �
		.db		0A0h	; �
		.db		50h	; P
		.db		0B8h	; �
		.db		10h
		.db		0A8h	; �
MouseMemData2:
		.db		1Fh
		.db		0Eh
		.db		11h
		.db		1Eh
		.db		0Ch
		.db		12h
		.db		1Fh
		.db		0Ah
		.db		15h
		.db		0Bh
		.db		1
		.db		0Ah
		.db		0
		.db		0
		.db		0
		.db		0
		.db		0
		.db		0
		.db		0
		.db		0
		.db		0
		.db		80h	; �
		.db		0
		.db		80h	; �

; =============== S U B	R O U T	I N E =======================================
AppSetupMouseMem:
		call	j_CursorOff
		call	j_RunIndicOff
		ld		hl, 301Fh
		ld		(unk_986D), hl
		ld		hl, MouseMemData
		ld		de, ramCode
		ld		bc, 1Ah
		ldir
		ret
; End of function AppSetupMouseMem


; =============== S U B	R O U T	I N E =======================================
ShiftBitsLeft:
		ex		de, hl
		ld		a, (hl)
		add		a, a
		ld		(hl), a
		ex		de, hl
		rl	(hl)
		inc		hl
		inc		de
		djnz	ShiftBitsLeft
		ret

; =============== S U B	R O U T	I N E =======================================
BCALL_4DAA:
		ld		a, (unk_986D)
		cp		3Dh ; '='
		jr		nc, p7Bloc_7221
		ld		c, 0
		ld		d, 3
		ld		hl, 811Ah
		call	BCALL_4DB3
		ld		c, 1
		ld		hl, 811Eh
		call	BCALL_4DB3

p7Bloc_7221:
		ld		hl, 8120h
		ld		de, 8121h
		ld		bc, 7
		lddr
		ld		c, 0
		ld		hl, 811Ah
		bit		3, (iy+2Ch)
		call	z, BCALL_4DB9
		ld		c, 1
		ld		hl, 811Eh
		bit		4, (iy+2Ch)
		call	z, BCALL_4DB9
		ret
; End of function BCALL_4DAA


; =============== S U B	R O U T	I N E =======================================


BCALL_4DAD:
		ld		c, 0
		ld		d, 0
		ld		a, (unk_811A)
		call	BCALL_4DB6
		ld		c, 1
		ld		a, (unk_811E)
		call	BCALL_4DB6
		ld		hl, 811Bh
		ld		de, 811Ah
		call	Mov7B2
		ld		c, 0
		ld		hl, 811Ah
		bit		3, (iy+2Ch)
		call	z, BCALL_4DBC
		ld		c, 1
		ld		hl, 811Eh
		bit		4, (iy+2Ch)
		call	z, BCALL_4DBC
		ret
; End of function BCALL_4DAD


; =============== S U B	R O U T	I N E =======================================


BCALL_4DB0:
		push	de
		push	hl
		ld		hl, 986Dh
		ld		a, 3Fh ; '?'
		sub		(hl)
		cp		4
		jr		c, p7Bloc_7287
		ld		a, 3

p7Bloc_7287:
		ld		e, a
		ld		d, 0
		pop		hl
		add		hl, de
		pop		de
		ret
; End of function BCALL_4DB0


; =============== S U B	R O U T	I N E =======================================


BCALL_4DB3:
		; BCALL_4DAA+16p
		call	BCALL_4DB0
		ld		a, (hl)

BCALL_4DB6:
		; BCALL_4DAD+Fp
		ld		b, a
		ld		a, (unk_8101)
		add		a, c
		cp		2Ch ; ','
		ret		z
		call	p7Bsub_74DA
		ld		a, (ramCode)
		add		a, d
		cp		0C0h ; '�'
		jr		c, p7Bloc_72A7
		ld		a, 0BFh	; '�'

p7Bloc_72A7:
		call	p7Bsub_74DA
		call	lcd_busy
		ld		a, b
		out		(11h), a
		ret
; End of function BCALL_4DB3


; =============== S U B	R O U T	I N E =======================================


BCALL_4DBC:
		; BCALL_4DAD+30p
		call	BCALL_4DB0
; End of function BCALL_4DBC


; =============== S U B	R O U T	I N E =======================================


BCALL_4DB9:
		; BCALL_4DAA+39p
		ld		a, (unk_8101)
		add		a, c
		cp		2Ch ; ','
		ret		z
		call	p7Bsub_74DA
		ld		a, (ramCode)
		dec		a
		bit		5, (iy+2Ch)
		jr		nz, p7Bloc_72D0
		add		a, 5
		cp		0C0h ; '�'
		jr		c, p7Bloc_72D0
		ld		a, 0BFh	; '�'

p7Bloc_72D0:
		; BCALL_4DB9+18j
		call	p7Bsub_74DA
		call	lcd_busy
		in		a, (11h)
		call	lcd_busy
		in		a, (11h)
		ld		(hl), a
		ret
; End of function BCALL_4DB9


; =============== S U B	R O U T	I N E =======================================


AppUpdateMouseRow:
		; AppDispPrevMouse+A8p	...
		ld		hl, ramCode
		bit		5, (iy+2Ch)
		jr		z, p7Bloc_72E9
		dec		(hl)

p7Bloc_72E9:
		bit		6, (iy+2Ch)
		jr		z, locret_72F0
		inc		(hl)

locret_72F0:
		ret
; End of function AppUpdateMouseRow


; =============== S U B	R O U T	I N E =======================================


AppDispPrevMouse:

		bit		7, (iy+2Ch)
		jr		nz, p7Bloc_732E
		ld		hl, 8102h
		ld		a, (unk_8101)
		ld		de, 811Ah
		set		2, (iy+2Ch)
		set		3, (iy+2Dh)
		call	AppDrawMouseDirect
		ld		hl, 810Eh
		ld		a, (unk_8101)
		inc		a
		ld		de, 811Eh
		call	AppDrawMouseDirect
		res		2, (iy+2Ch)
		res		3, (iy+2Dh)
		bit		5, (iy+2Ch)
		call	nz, BCALL_4DAA
		bit		6, (iy+2Ch)
		call	nz, BCALL_4DAD

p7Bloc_732E:
		bit		0, (iy+2Dh)
		jr		z, p7Bloc_73A1
		bit		4, (iy+2Ch)
		jr		nz, p7Bloc_7378
		ld		hl, 8102h
		ld		de, 810Eh
		ld		b, 0Ch
		call	ShiftBitsLeft
		ld		a, (unk_986D+1)
		cp		5Fh ; '_'
		jr		nz, AppUpdateMouseCoords
		ld		hl, 8117h
		set		0, (hl)
		inc		hl
		inc		hl
		set		0, (hl)

AppUpdateMouseCoords:
		; AppDispPrevMouse+B4j	...
		call	AppUpdateMouseRow

AppUpdateMouseXY:
		; AppDispPrevMouse+10Fj
		ld		hl, (unk_8122)
		ld		(unk_986D), hl
		bit		7, (iy+2Ch)
		jr		nz, p7Bloc_7368
		set		2, (iy+2Dh)

p7Bloc_7368:
		bit		4, (iy+2Dh)
		call	z, AppDispMouse
		ld		(iy+2Ch), 0
		ld		(iy+2Dh), 0
		ret
; ---------------------------------------------------------------------------

p7Bloc_7378:
		ld		hl, MouseMemData+2
		ld		de, 8102h
		ld		bc, 18h
		ldir
		ld		hl, 8101h
		dec		(hl)
		ld		hl, 811Ah
		ld		de, 811Eh
		call	page0_118D
		ld		a, (unk_8101)
		call	p7Bsub_74DA
		ld		de, 811Ah
		call	AppUpdateMouseRow
		call	p7Bsub_74C0
		jr		AppUpdateMouseXY
; ---------------------------------------------------------------------------

p7Bloc_73A1:
		bit		1, (iy+2Dh)
		jp		z, AppUpdateMouseCoords
		bit		3, (iy+2Ch)
		jr		nz, p7Bloc_73D8
		ld		hl, 8119h
		ld		de, 810Dh
		ld		b, 0Ch

p7Bloc_73B6:
		ex		de, hl
		ld		a, (hl)
		srl	a
		ld		(hl), a
		ex		de, hl
		rr	(hl)
		dec		hl
		dec		de
		djnz	p7Bloc_73B6
		ld		a, (unk_986D+1)
		or		a
		jp		nz, AppUpdateMouseCoords
		ld		hl, 8102h
		call	p7Bsub_7682
		call	p7Bsub_7682
		call	p7Bsub_7682
		jp		AppUpdateMouseCoords
; ---------------------------------------------------------------------------

p7Bloc_73D8:
		ld		hl, MouseMemData2
		ld		de, 8102h
		ld		bc, 18h
		ldir
		ld		hl, 8101h
		inc		(hl)
		ld		de, 811Ah
		ld		hl, 811Eh
		call	page0_118D
		ld		a, (unk_8101)
		inc		a
		call	p7Bsub_74DA
		ld		de, 811Eh
		call	AppUpdateMouseRow
		call	p7Bsub_74C0
		jp		AppUpdateMouseXY
; End of function AppDispPrevMouse

; ---------------------------------------------------------------------------

AppEraseMouse:
		res		1, (iy+2Ch)
		set		2, (iy+2Ch)
		jr		AppDrawMouse

; =============== S U B	R O U T	I N E =======================================


AppDispMouse:

		set		1, (iy+2Ch)
		res		2, (iy+2Ch)

AppDrawMouse:
		call	SetXUp
		ld		hl, 8102h
		ld		a, (hl)
		or		a
		jr		nz, p7Bloc_742C
		bit		2, (iy+2Dh)
		jr		z, p7Bloc_7435
		ld		a, (unk_810E)
		bit		7, a
		jr		z, p7Bloc_7435

p7Bloc_742C:
		ld		a, (unk_8101)
		ld		de, 811Ah
		call	AppDrawMouseDirect

p7Bloc_7435:
		; AppDispMouse+1Dj
		ld		a, (unk_8117)
		or		a
		jr		nz, p7Bloc_7446
		bit		2, (iy+2Dh)
		ret		z
		ld		a, (unk_810B)
		bit		0, a
		ret		z

p7Bloc_7446:
		ld		hl, 810Eh
		ld		a, (unk_8101)
		inc		a
		ld		de, 811Eh
; End of function AppDispMouse


; =============== S U B	R O U T	I N E =======================================


AppDrawMouseDirect:
		; AppDispPrevMouse+24p	...
		call	p7Bsub_74DA
		bit		2, (iy+2Dh)
		jr		nz, p7Bloc_7470
		bit		2, (iy+2Ch)
		jr		z, p7Bloc_746B
		push	de
		ld		de, prevDData
		call	p7Bsub_74C0
		ld		de, prevDData
		jr		p7Bloc_7470
; ---------------------------------------------------------------------------

p7Bloc_746B:
		push	de
		call	p7Bsub_74C0
		pop		de

p7Bloc_7470:
		; AppDrawMouseDirect+19j
		call	p7Bsub_74AC

p7Bloc_7473:
		ld		a, (de)
		ld		c, (hl)
		bit		2, (iy+2Ch)
		jr		z, p7Bloc_7492
		or		c
		xor		c
		ex		(sp), hl
		or		(hl)
		bit		3, (iy+2Dh)
		jr		z, p7Bloc_748C
		ld		(hl), a
		inc		hl
		ex		(sp), hl
		inc		hl
		inc		hl
		jr		p7Bloc_749F
; ---------------------------------------------------------------------------

p7Bloc_748C:
		inc		hl
		ex		(sp), hl
		inc		hl
		inc		hl
		jr		p7Bloc_749A
; ---------------------------------------------------------------------------

p7Bloc_7492:
		and		(hl)
		ld		c, a
		ld		a, (de)
		inc		hl
		or		(hl)
		inc		hl
		or		(hl)
		xor		(hl)

p7Bloc_749A:
		call	lcd_busy
		out		(11h), a

p7Bloc_749F:
		ld		a, c
		ld		(de), a
		inc		hl
		inc		de
		djnz	p7Bloc_7473
		bit		2, (iy+2Ch)
		ret		z
		pop		hl
		ret
; End of function AppDrawMouseDirect


; =============== S U B	R O U T	I N E =======================================


p7Bsub_74AC:
		; p7Bsub_74C0p
		ld		a, (ramCode)
		call	p7Bsub_74DA
		cp		0BDh ; '�'
		jr		c, p7Bloc_74BD
		neg
		add		a, 0C0h	; '�'
		ld		b, a
		jr		locret_74BF
; ---------------------------------------------------------------------------

p7Bloc_74BD:
		ld		b, 4

locret_74BF:
		ret
; End of function p7Bsub_74AC


; =============== S U B	R O U T	I N E =======================================


p7Bsub_74C0:
		; AppDispPrevMouse+10Cp ...
		call	p7Bsub_74AC
		call	lcd_busy
		in		a, (11h)

p7Bloc_74C8:
		call	lcd_busy
		in		a, (11h)
		ld		(de), a
		inc		de
		djnz	p7Bloc_74C8
		ret
; End of function p7Bsub_74C0

; ---------------------------------------------------------------------------
		ld		a, (ramCode)
		jr		p7Bsub_74DA
; ---------------------------------------------------------------------------
		ld		a, (unk_8101)

; =============== S U B	R O U T	I N E =======================================
p7Bsub_74DA:
		call	lcd_busy
		out		(10h), a
		ret
		push	bc
		ld		bc, 0Ch
		add		hl, bc
		inc		de
		inc		de
		inc		de
		inc		de
		pop		bc
		ret
AppSetupMouseMemCoords:
		push	hl
		call	AppSetupMouseMem
		pop		hl
		ld		a, 1Fh
		sub		h
		jr		z, p7Bloc_7505
		ld		a, 1
		jr		c, p7Bloc_74FB
		ld		a, 4

p7Bloc_74FB:
		call	AppMoveMouse
		ld		a, (unk_986D)
		cp		h
		ld		a, b
		jr		nz, p7Bloc_74FB

p7Bloc_7505:
		ld		a, 30h ; '0'
		sub		l
		ret		z
		ld		a, 3
		jr		c, p7Bloc_74FB
		ld		a, 2

p7Bloc_750F:
		call	AppMoveMouse
		ld		a, (unk_986D+1)
		cp		l
		ld		a, b
		jr		nz, p7Bloc_750F
		ret

; =============== S U B	R O U T	I N E =======================================


AppMoveMouse:

		push	af
		push	hl
		call	AppMouseForceKey
		set		4, (iy+2Dh)
		set		7, (iy+2Ch)
		call	AppDispPrevMouse
		pop		hl
		pop		bc
		ret
; End of function AppMoveMouse

; ---------------------------------------------------------------------------

AppStartMouse:
		call	AppSetupMouseMem

AppStartMouseNoSetup:
		call	AppDispMouse
; START	OF FUNCTION CHUNK FOR AppMouseForceKey

AppMouseGetKey:
;TODO: Uh? What in the world was the intention here?
		ld		a, 1
		ld		($32), a
		ld		($0A), a
		set		useDiscreteArrowKeyValues, (iy+mouseFlag1)
		ei
		halt
		call	GetCSC
		or		a
		jr		z, AppMouseGetKey
; END OF FUNCTION CHUNK	FOR AppMouseForceKey

; =============== S U B	R O U T	I N E =======================================
AppMouseForceKey:
		di
		ld		hl, (unk_986D)
		ld		(unk_8122), hl
		res		useDiscreteArrowKeyValues, (iy+mouseFlag1)
		cp		0Ah
		jr		c, p7Bloc_7568
		cp		0F3h ; '�'
		jr		nc, p7Bloc_7568
		cp		36h ; '6'
		jr		nz, AppMouseGetKey
		ld		a, (iy+12h)
		xor		0
		ld		(iy+12h), a
		jr		AppMouseGetKey
; ---------------------------------------------------------------------------

p7Bloc_7568:
		; AppMouseForceKey+11j
		cp		9
		jr		nz, p7Bloc_7574
		res		shift2nd, (iy+shiftFlags)
		ld		a, 0Ch
		ei
		ret
; ---------------------------------------------------------------------------

p7Bloc_7574:
		cp		4
		jr		nz, p7Bloc_7597

p7Bloc_7578:
		; AppMouseForceKey+ECj
		ld		a, (unk_986D)
		or		a
		jr		z, AppMouseGetKey
		dec		a
		ld		(unk_8122), a
		set		5, (iy+2Ch)

p7Bloc_7586:
		; p7Bsub_75B7:p7Bloc_75D8j ...
		ld		a, 0Ah
		bit		shift2nd, (iy+shiftFlags)
		jr		nz, p7Bloc_7593
		ld		hl, (unk_8122)
		or		a
		ret
; ---------------------------------------------------------------------------

p7Bloc_7593:
		ld		a, 8
		ei
		ret
; ---------------------------------------------------------------------------

p7Bloc_7597:
		cp		1
		jr		nz, p7Bloc_75AC

p7Bloc_759B:
		; AppMouseForceKey+12Bj
		ld		a, (unk_986D)
		cp		3Fh ; '?'
		jr		z, AppMouseGetKey
		inc		a
		ld		(unk_8122), a
		set		6, (iy+2Ch)
		jr		p7Bloc_7586
; ---------------------------------------------------------------------------

p7Bloc_75AC:
		cp		3
		jr		nz, p7Bloc_75DA

p7Bloc_75B0:
		; AppMouseForceKey+105j
		call	p7Bsub_75B7
		ret		nz
		jp		AppMouseGetKey
; End of function AppMouseForceKey


; =============== S U B	R O U T	I N E =======================================


p7Bsub_75B7:
		; AppMouseForceKey+E9p	...
		ld		a, (unk_986D+1)
		cp		5Fh ; '_'
		ret		z
		set		1, (iy+2Dh)
		inc		a
		ld		(unk_8122+1), a
		res		3, (iy+2Ch)
		ld		hl, 8119h
		bit		0, (hl)
		jr		z, p7Bloc_75D8
		cp		5Fh ; '_'
		jr		z, p7Bloc_75D8
		set		3, (iy+2Ch)

p7Bloc_75D8:
		jr		p7Bloc_7586
; End of function p7Bsub_75B7

; ---------------------------------------------------------------------------
; START	OF FUNCTION CHUNK FOR AppMouseForceKey

p7Bloc_75DA:
		cp		2
		jr		nz, p7Bloc_7607

p7Bloc_75DE:
		; AppMouseForceKey+125j
		call	p7Bsub_75E5
		ret		nz
		jp		AppMouseGetKey
; END OF FUNCTION CHUNK	FOR AppMouseForceKey

; =============== S U B	R O U T	I N E =======================================


p7Bsub_75E5:
		; AppMouseForceKey+CAp	...
		ld		a, (unk_986D+1)
		or		a
		ret		z
		set		0, (iy+2Dh)
		dec		a
		ld		(unk_8122+1), a
		res		4, (iy+2Ch)
		ld		hl, 8102h
		bit		7, (hl)
		jr		z, p7Bloc_7604
		or		a
		jr		z, p7Bloc_7604
		set		4, (iy+2Ch)

p7Bloc_7604:
		jp		p7Bloc_7586
; End of function p7Bsub_75E5

; ---------------------------------------------------------------------------
; START	OF FUNCTION CHUNK FOR AppMouseForceKey

p7Bloc_7607:
		cp		0F5h ; '�'
		jr		nz, p7Bloc_7625
		ld		a, (unk_986D)
		or		a
		jr		z, p7Bloc_75DE
		call	p7Bsub_75E5
		jp		z, p7Bloc_7578
		set		5, (iy+2Ch)
		ld		a, (unk_986D)
		dec		a
		ld		(unk_8122), a

p7Bloc_7622:
		; AppMouseForceKey+119j ...
		jp		p7Bloc_7586
; ---------------------------------------------------------------------------

p7Bloc_7625:
		cp		0F3h ; '�'
		jr		nz, p7Bloc_7643
		ld		a, (unk_986D)
		or		a
		jp		z, p7Bloc_75B0
		call	p7Bsub_75B7
		jp		z, p7Bloc_7578
		set		5, (iy+2Ch)
		ld		a, (unk_986D)
		dec		a
		ld		(unk_8122), a
		jr		p7Bloc_7622
; ---------------------------------------------------------------------------

p7Bloc_7643:
		cp		0FAh ; '�'
		jr		nz, p7Bloc_7662
		ld		a, (unk_986D)
		cp		3Fh ; '?'
		jp		z, p7Bloc_75B0
		call	p7Bsub_75B7
		jp		z, p7Bloc_759B
		set		6, (iy+2Ch)
		ld		a, (unk_986D)
		inc		a
		ld		(unk_8122), a
		jr		p7Bloc_7622
; ---------------------------------------------------------------------------

p7Bloc_7662:
		cp		0FCh ; '�'
		jp		nz, AppMouseGetKey
		ld		a, (unk_986D)
		cp		3Fh ; '?'
		jp		z, p7Bloc_75DE
		call	p7Bsub_75E5
		jp		z, p7Bloc_759B
		set		6, (iy+2Ch)
		ld		a, (unk_986D)
		inc		a
		ld		(unk_8122), a
		jr		p7Bloc_7622
; END OF FUNCTION CHUNK	FOR AppMouseForceKey

; =============== S U B	R O U T	I N E =======================================


p7Bsub_7682:
		; AppDispPrevMouse+DEp	...
		set		7, (hl)
		inc		hl
		inc		hl
		set		7, (hl)
		inc		hl
		ret
; End of function p7Bsub_7682

; ---------------------------------------------------------------------------

AppUpdateMouse:
		res		7, (iy+2Ch)

p7Bloc_768E:
		call	AppDispPrevMouse
		jp		AppMouseGetKey
; ---------------------------------------------------------------------------

BCALL_4D8F:
		set		7, (iy+2Ch)
		jr		p7Bloc_768E
; ---------------------------------------------------------------------------

ExecuteApp:
		call	Page0Call_2CAF
		push	hl
		ld		hl, MonDefaultVectors2
		call	AppInitEnoughMem50
		call	p7Bsub_703B
		call	AppSetup
		set		appRunning, (iy+APIFlg)
		set		6, (iy+28h)
		pop		hl
		ld		(appBank_jump), hl
		res		useDiscreteArrowKeyValues, (iy+mouseFlag1)
		ld		(iy+37h), 0
		ld		(iy+38h), 0
		jr		p7Bloc_76C7
; ---------------------------------------------------------------------------
		ld		(appBank_jump), hl

p7Bloc_76C7:
		ld		hl, appBank_jump
		push	hl
		jp		sFAIL
; ---------------------------------------------------------------------------

set2IY34:
		set		2, (iy+34h)
		ret
; ---------------------------------------------------------------------------

DisableApd:
		res		apdAble, (iy+apdFlags)
		ret
; ---------------------------------------------------------------------------

EnableApd:
		set		apdAble, (iy+apdFlags)
		ret
; ---------------------------------------------------------------------------

SetIgnoreKey:
		set		appIgnoreKey, (iy+APIFlg)
		ret
; ---------------------------------------------------------------------------

SetSendThisKeyBack:
		set		sendKeyStraightTocxMain, (iy+APIFlg)
		ld		(kbdKey), a
		ret
GetHookByte:
		push	bc
		push	de
		ld		e, (hl)
		inc		hl
		ld		d, (hl)
		inc		hl
		ld		a, (hl)
		cp		0FFh
		jr		z, p7Bloc_7701
		ld		(unk_9B77), a
		ex		de, hl
		call	GetBytePaged
		inc		hl
		ld		(hookExecTemp), hl
		ld		a, b
p7Bloc_7701:
		pop		de
		pop		bc
		cp		83h ; '�'
		ret
cursorhook:
		push	af
		ld		hl, cursorHookPtr
		call	GetHookByte
		jr		z, p7Bloc_7762
		pop		af
		or		1
		ld		a, b

; =============== S U B	R O U T	I N E =======================================


ClrCursorHook:
		res		cursorHookActive, (iy+hookflags2)
		ret
; End of function ClrCursorHook

; ---------------------------------------------------------------------------

RunCatalog2Hook:
		push	af
		push	hl
		ld		hl, catalog2HookPtr
		call	GetHookByte
		pop		hl
		jr		z, p7Bloc_7762
		pop		af

DisableCatalog2Hook:
		res		catalog2HookActive, (iy+hookflags2)
		ret
; ---------------------------------------------------------------------------

call_linkactivity_hook:
		push	af
		ld		hl, linkActivityHook
		call	GetHookByte
		jr		z, p7Bloc_7762
		pop		af

DisableLinkHook:
		res		bPLinkOn, (iy+hookflags1)
		ret
; ---------------------------------------------------------------------------

getkeyhook:
		push	af
		ld		hl, getKeyHookPtr
		call	GetHookByte
		jr		z, p7Bloc_7762
		pop		af
		or		1
		ld		a, b

ClrGetKeyHook:
		res		getCSCHookActive, (iy+hookflags2)
		ret
; ---------------------------------------------------------------------------

call_library_hook:
		ld		hl, libraryHookPtr
		call	GetHookByte
		jr		z, p7Bloc_7763
		or		1

DisableLibraryHook:
		res		libraryHookActive, (iy+hookflags2)
		ret
; ---------------------------------------------------------------------------

call_rawkey_hook:
		push	af
		ld		hl, rawKeyHookPtr
		call	GetHookByte
		jr		nz, p7Bloc_77B0
; START	OF FUNCTION CHUNK FOR p7Bsub_7871

p7Bloc_7762:
		pop		af

p7Bloc_7763:
		ld		(unk_9C22), a
		in		a, (20h)
		push	af
		bit		5, (iy+24h)
		call	SetSpeed_NZForFast
		pop		af
		push	af
		ld		a, (unk_9C22)
		push	hl
		ld		hl, SEspeed
		inc		(hl)
		ld		hl, page0_BBD
		ex		(sp), hl
		push	hl
		ld		hl, RestoreCPUSpeed
		ex		(sp), hl
		push	hl
		ld		hl, hookExecTemp
		ex		(sp), hl
		jp		sNameEq
RestoreCPUSpeed:
		push	af
		push	hl
		ld		hl, SEspeed
		dec		(hl)
		pop		hl
		call	NZIf83Plus
		jr		nz, p7Bloc_77AA
		pop		af
		ld		(unk_9C22), bc
		pop		bc
		pop		bc
		push	af
		ld		a, b
		and		1
		out		(20h), a
		pop		af
		ld		bc, (unk_9C22)
		ret
; ---------------------------------------------------------------------------

p7Bloc_77AA:
		pop		af
		inc		sp
		inc		sp
		inc		sp
		inc		sp
		ret
; ---------------------------------------------------------------------------

p7Bloc_77B0:
		pop		af

ClrRawKeyHook:
		res		rawKeyHookActive, (iy+hookflags2)
		ret
; ---------------------------------------------------------------------------

Page7B_3C15:
		push	hl
		ld		hl, tokenHookPtr
		call	GetHookByte
		pop		hl
		jr		z, p7Bloc_7763

ClearTokenHook:
		res		tokenHookActive, (iy+hookflags3)
		ret
; ---------------------------------------------------------------------------

call_character_hook:
		push	af
		push	hl
		ld		hl, localizeHookPtr
		call	GetHookByte
		pop		hl
; START	OF FUNCTION CHUNK FOR p7Bsub_7871

p7Bloc_77CE:
		jr		z, p7Bloc_7762
		pop		af
		or		1

DisableLocalizeHook:
		push	hl
		ld		hl, 109h
		ld		(localLanguage), hl
		pop		hl
		res		localizeHookActive, (iy+hookflags3)
		ret
; END OF FUNCTION CHUNK	FOR p7Bsub_7871
; ---------------------------------------------------------------------------

Page7B_2D51:
		push	af
		ld		hl, homescreenHookPtr
		call	GetHookByte
		jr		z, p7Bloc_77CE
		pop		af
		cp		a

ClrHomeScreenHook:
		res		homescreenHookActive, (iy+hookflags2)
		ret
; ---------------------------------------------------------------------------

Page7B_362D:
		push	af
		push	hl
		ld		hl, windowHookPtr
		call	GetHookByte
		pop		hl
		jr		z, p7Bloc_77CE
		pop		af
		cp		a

DisableWindowHook:
		res		windowHookActive, (iy+hookflags3)
		ret
; ---------------------------------------------------------------------------

Page7B_330F:
		push	af
		ld		hl, graphHookPtr
		call	GetHookByte
; START	OF FUNCTION CHUNK FOR p7Bsub_7871

p7Bloc_7809:
		jr		z, p7Bloc_77CE
		pop		af
		cp		a

DisableGraphHook:
		res		graphHookActive, (iy+hookflags3)
		ret
; END OF FUNCTION CHUNK	FOR p7Bsub_7871
; ---------------------------------------------------------------------------

Page7B_2FDF:
		push	af
		push	hl
		ld		hl, yEqualsHookPtr
		call	GetHookByte
		pop		hl
		jr		z, p7Bloc_7809
		pop		af
		cp		a

DisableYEquHook:
		res		yEquHookActive, (iy+hookflags3)
		ret
; ---------------------------------------------------------------------------

FontHook:
		push	af
		push	hl
		ld		hl, fontHookPtr
		call	GetHookByte
		pop		hl
		jr		z, p7Bloc_7809
		pop		af

ClrFontHook:
		res		fontHookActive, (iy+hookflags3)
		ret
; ---------------------------------------------------------------------------

RunTraceHook:
		push	af
		ld		hl, traceHookPtr
		call	GetHookByte
		jr		z, p7Bloc_7809
		pop		af
		cp		a

DisableTraceHook:
		res		0, (iy+36h)
		ret
; ---------------------------------------------------------------------------

RunGraphingHook:
		push	af
		push	hl
		ld		hl, regraphHookPtr
		call	GetHookByte
		pop		hl
		jr		z, p7Bloc_7809
		pop		af
		cp		a

DisableRegraphHook:
		res		regraphHookActive, (iy+hookflags3)
		ret
; ---------------------------------------------------------------------------

Page7B_2D69:
		push	af
		push	hl
		ld		hl, parserHookPtr
		call	GetHookByte
		pop		hl
		jr		z, p7Bloc_7809
		pop		af
		cp		a

ClearParserHook:
		res		1, (iy+36h)
		ret
; ---------------------------------------------------------------------------

call_appchange_hook:
		push	af
		push	hl
		ld		hl, appChangeHookPtr
		call	GetHookByte

; =============== S U B	R O U T	I N E =======================================


p7Bsub_7871:





		pop		hl
		jr		z, p7Bloc_7809
		pop		af
		cp		a

ClearAppChangeHook:
		res		2, (iy+36h)
		ret
; End of function p7Bsub_7871

; ---------------------------------------------------------------------------

Page7B_3483:
		push	af
		push	hl
		ld		hl, graphicsHook
		call	GetHookByte
		pop		hl

p7Bloc_7884:
		jr		z, p7Bloc_7809
		pop		af
		cp		a

DisableGraphicsHook:
		res		drawingHookActive, (iy+hookflags3)
		ret
; ---------------------------------------------------------------------------

RunCatalog1Hook:
		push	af
		push	hl
		ld		hl, catalog1HookPtr
		call	GetHookByte
		pop		hl
		jr		z, p7Bloc_7884
		pop		af
		cp		0Ch
		jr		nz, p7Bloc_78A0
		or		a
		jr		DisableCatalog1Hook
; ---------------------------------------------------------------------------

p7Bloc_78A0:
		cp		a

DisableCatalog1Hook:
		res		3, (iy+36h)
		ret
; ---------------------------------------------------------------------------

Page7B_3123:
		push	af
		push	hl
		ld		hl, helpHookPtr
		call	GetHookByte
		pop		hl
		jr		z, p7Bloc_7884
		pop		af
		cp		a

DisableHelpHook:
		res		4, (iy+36h)
		ret
; ---------------------------------------------------------------------------

Page7B_36F3:
		push	af
		ld		hl, cxRedispHookPtr
		call	GetHookByte
		jr		z, p7Bloc_7884
		pop		af
		cp		a

DisablecxRedispHook:
		res		5, (iy+36h)
		ret
; ---------------------------------------------------------------------------

Page7B_2D15:
		push	af
		push	hl
		ld		hl, menuHookPtr
		call	GetHookByte
		pop		hl
		jr		z, p7Bloc_7884
		pop		af
		cp		a

ClearMenuHook:
		res		6, (iy+36h)
		ret
; ---------------------------------------------------------------------------

Page7B_2CB5:
		push	af
		ld		hl, silentLinkHookPtr
		call	GetHookByte
		jr		z, p7Bloc_7884
		pop		af

DisableSilentLinkHook:
		res		7, (iy+36h)
		ret
; ---------------------------------------------------------------------------

EnableLibraryHook:
		ld		(libraryHookPtr), hl
		ld		(unk_9B82), a
		set		libraryHookActive, (iy+hookflags2)
		ret
; ---------------------------------------------------------------------------

EnableCatalog2Hook:
		ld		(catalog2HookPtr), hl
		ld		(unk_9BC6), a
		set		catalog2HookActive, (iy+hookflags2)
		ret
; ---------------------------------------------------------------------------

SetGetcscHook:
		ld		(getKeyHookPtr), hl
		ld		(unk_9B8A), a
		set		getCSCHookActive, (iy+hookflags2)
		ret
; ---------------------------------------------------------------------------

EnableLinkActivityHook:
		ld		(linkActivityHook), hl
		ld		(unk_9B7A), a
		set		bPLinkOn, (iy+hookflags1)
		ret

; =============== S U B	R O U T	I N E =======================================


setCursorHook:
		ld		(cursorHookPtr), hl
		ld		(unk_9B7E), a
		set		cursorHookActive, (iy+hookflags2)
		ret
; End of function setCursorHook


; =============== S U B	R O U T	I N E =======================================


SetGetKeyHook:
		ld		(rawKeyHookPtr), hl
		ld		(unk_9B86), a
		set		rawKeyHookActive, (iy+hookflags2)
		ret
; End of function SetGetKeyHook

; ---------------------------------------------------------------------------

SetTokenHook:
		ld		(tokenHookPtr), hl
		ld		(unk_9BCA), a
		set		tokenHookActive, (iy+hookflags3)
		ret
; ---------------------------------------------------------------------------

EnableLocalizeHook:
		ld		(localizeHookPtr), hl
		ld		(unk_9BCE), a
		set		localizeHookActive, (iy+hookflags3)
		ret
; ---------------------------------------------------------------------------

SetHomescreenHook:
		ld		(homescreenHookPtr), hl
		ld		(unk_9B8E), a
		set		homescreenHookActive, (iy+hookflags2)
		ret
; ---------------------------------------------------------------------------

SetWindowHook:
		ld		(windowHookPtr), hl
		ld		(unk_9B92), a
		set		windowHookActive, (iy+hookflags3)
		ret
; ---------------------------------------------------------------------------

SetGraphModeHook:
		ld		(graphHookPtr), hl
		ld		(unk_9B96), a
		set		graphHookActive, (iy+hookflags3)
		ret
; ---------------------------------------------------------------------------

SetYeditHook:
		ld		(yEqualsHookPtr), hl
		ld		(unk_9B9A), a
		set		yEquHookActive, (iy+hookflags3)
		ret
; ---------------------------------------------------------------------------

SetFontHook:
		ld		(fontHookPtr), hl
		ld		(unk_9B9E), a
		set		fontHookActive, (iy+hookflags3)
		ret
; ---------------------------------------------------------------------------

SetRegraphHook:
		ld		(regraphHookPtr), hl
		ld		(unk_9BA2), a
		set		regraphHookActive, (iy+hookflags3)
		ret
; ---------------------------------------------------------------------------

SetTraceHook:
		ld		(traceHookPtr), hl
		ld		(unk_9BAA), a
		set		0, (iy+36h)
		ret
; ---------------------------------------------------------------------------

SetParserHook:
		ld		(parserHookPtr), hl
		ld		(unk_9BAE), a
		set		1, (iy+36h)
		ret
; ---------------------------------------------------------------------------

SetAppChangeHook:
		ld		(appChangeHookPtr), hl
		ld		(unk_9BB2), a
		set		2, (iy+36h)
		ret
; ---------------------------------------------------------------------------

EnableGraphicsHook:
		ld		(graphicsHook), hl
		ld		(unk_9BA6), a
		set		drawingHookActive, (iy+hookflags3)
		ret
; ---------------------------------------------------------------------------

EnableCatalog1Hook:
		ld		(catalog1HookPtr), hl
		ld		(unk_9BB6), a
		set		3, (iy+36h)
		ret
; ---------------------------------------------------------------------------

EnableHelpHook:
		ld		(helpHookPtr), hl
		ld		(unk_9BBA), a
		set		4, (iy+36h)
		ret
; ---------------------------------------------------------------------------

EnablecxRedispHook:
		ld		(cxRedispHookPtr), hl
		ld		(unk_9BBE), a
		set		5, (iy+36h)
		ret
; ---------------------------------------------------------------------------

SetMenuHook:
		ld		(menuHookPtr), hl
		ld		(unk_9BC2), a
		set		6, (iy+36h)
		ret
; ---------------------------------------------------------------------------

SetSilentLinkHook:
		ld		(silentLinkHookPtr), hl
		ld		(unk_9BD2), a
		set		7, (iy+36h)
		ret
; ---------------------------------------------------------------------------

ResetHookBytes:
		ld		hl, 9B7Ah
		ld		b, 17h
		ld		de, 3

p7Bloc_79EE:
		ld		a, (hl)
		inc		hl
		ld		(hl), a
		add		hl, de
		djnz	p7Bloc_79EE
		ret
; ---------------------------------------------------------------------------

AdjustAllHooks:
		push	af
		sub		c
		inc		a
		ld		d, a
		pop		af
		ld		hl, 9B7Bh
		ld		b, 17h

p7Bloc_79FF:
		push	af
		cp		(hl)
		jr		z, p7Bloc_7A19
		jr		nc, p7Bloc_7A0D

p7Bloc_7A05:
		pop		af
		inc		hl
		inc		hl
		inc		hl
		inc		hl
		djnz	p7Bloc_79FF
		ret
; ---------------------------------------------------------------------------

p7Bloc_7A0D:
		ld		a, (hl)
		cp		8
		jr		c, p7Bloc_7A05
		cp		0FFh
		jr		z, p7Bloc_7A05
		cp		d
		jr		c, p7Bloc_7A21

p7Bloc_7A19:
		dec		hl
		ld		(hl), 0FFh
		inc		hl
		ld		(hl), 0FFh
		jr		p7Bloc_7A05
; ---------------------------------------------------------------------------

p7Bloc_7A21:
		dec		hl
		ld		a, (hl)
		add		a, c
		ld		(hl), a
		inc		hl
		jr		p7Bloc_7A05