diff -r 486c42a314bc -r f4f75ec42b53 source/page01/routines.asm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/source/page01/routines.asm Thu May 22 01:52:19 2014 -0400 @@ -0,0 +1,2672 @@ +p01sub_55B5: + call lcd_busy + out (11h), a + jr p01loc_55C6 +sOK: call lcd_busy + in a, (11h) + call lcd_busy + in a, (11h) +p01loc_55C6: + push af + ld a, (curXRow) + jr p01loc_55DD +p01sub_55CC: + call lcd_busy + in a, (11h) + call lcd_busy + in a, (11h) +p01sub_55D6: + push af + ld a, (curXRow) + add a, 8 + sub b +p01loc_55DD: + call p01sub_55E5 + call SetXUp + pop af + ret +p01sub_55E5: + call SetYUp + cp 80h + ret c + cp 0C0h + ret nc + call lcd_busy + out (10h), a + ret + +PutMap: di + push af + push bc + push de + push hl + push ix + res plotDisp, (iy+plotFlags) + bit appTextSave, (iy+appFlags) + jr z, p01loc_5609 + call getcurloc + ld (hl), a +p01loc_5609: + or a + jr z, p01loc_5610 + cp 0F5h + jr c, p01loc_5612 +p01loc_5610: + ld a, 0D0h +p01loc_5612: + ld l, a + ld h, 0 + add hl, hl + add hl, hl + add hl, hl + call Page0Call_3BC7 + push hl + pop ix + ld a, (curRow) + call MAKEROWCMD + ld (curXRow), a + ld a, (curRow+1) + and 1Fh + add a, 20h + ld b, a + xor a + call lcd_busy + out (10h), a + ld a, (curXRow) + call p01sub_55E5 + call SetXUp + ld a, b + call lcd_busy + out (10h), a + ld b, 8 +p01loc_5646: + xor a + dec b + jr z, p01loc_564F + ld a, (ix+0) + inc ix +p01loc_564F: + inc b + sla a + bit textInverse, (iy+textFlags) + jr z, p01loc_568D + xor 3Eh +p01loc_565A: + push af + ld a, (curRow+1) + and 1Fh + jr z, p01loc_568A + add a, 1Fh + call lcd_busy + out (10h), a + call p01sub_55CC + or 1 + bit preClrForMode, (iy+newDispF) + jr z, p01loc_5676 + and 3Eh +p01loc_5676: + call lcd_busy + out (11h), a + ld a, (curRow+1) + and 1Fh + add a, 20h + call lcd_busy + out (10h), a + call p01sub_55D6 +p01loc_568A: + pop af + jr p01loc_5693 +p01loc_568D: + bit preClrForMode, (iy+newDispF) + jr nz, p01loc_565A +p01loc_5693: + call lcd_busy + out (11h), a + djnz p01loc_5646 + ld a, 1 + call lcd_busy + out (10h), a +p01loc_56A1: + pop ix +p01loc_56A3: + pop hl + pop de + pop bc + pop af + ret + +PutC: push af + push hl + cp 0D6h + jr nz, p01loc_56C0 + call EraseEOL + call newline + ld a, (winTop+1) + ld l, a + ld a, (curRow) + cp l + jr nc, p01loc_56D1 + ld a, 3Ah +p01loc_56C0: + call PutMap + res preClrForMode, (iy+newDispF) + ld hl, curCol + inc (hl) + ld a, (hl) + cp 10h + call nc, newline +p01loc_56D1: + pop hl + pop af + ret + +Page01_3C75: + push bc +p01loc_56D5: + ld bc, (unk_839F) + ld (OP1), bc + ld bc, (unk_83A1) + ld (OP1M), bc + ld hl, 848Dh + ld e, a + ld d, 0 + add hl, de + push de + push hl + ld b, a +p01loc_56EF: + ld de, 0Ah + push hl + push bc + rst 28h + .dw 80B1h + pop bc + pop hl + ld a, (OP2+3) + add a, 30h + ld (hl), a + dec hl + djnz p01loc_56EF + sub a + pop hl + inc hl + ld (hl), a + ld hl, 848Dh + ld a, 30h + pop bc + ld b, c + dec b +p01loc_570E: + inc hl + cp (hl) + jr nz, p01loc_5716 + ld (hl), 20h + djnz p01loc_570E +p01loc_5716: + ld hl, OP3 + ld a, c + cp 7 + jr nz, p01loc_5724 + ld a, 20h + cp (hl) + jr nz, p01loc_5727 + inc hl +p01loc_5724: + pop bc + jr Page01_3C81 +p01loc_5727: + ld a, (OP3+4) + cp 35h + jr nc, p01loc_573E + ld a, 4Bh + ld (OP3+4), a + xor a + ld (OP3+5), a + ld a, 20h + call PutC + jr p01loc_5724 +p01loc_573E: + ld hl, 83A2h + ld a, 0F4h + add a, (hl) + ld (hl), a + dec hl + ld a, 1 + adc a, (hl) + ld (hl), a + dec hl + ld a, 0 + adc a, (hl) + ld (hl), a + ld a, c + jr p01loc_56D5 +DispHL: push bc + ld de, 847Ch + ld b, 5 +p01loc_5758: + call DivHLBy10 + add a, 30h + ld (de), a + dec de + djnz p01loc_5758 + sub a + ld (OP1+5), a + ex de, hl + ld a, 30h + ld b, 4 +p01loc_576A: + inc hl + cp (hl) + jr nz, p01loc_5772 + ld (hl), 20h + djnz p01loc_576A +p01loc_5772: + ld hl, OP1 + pop bc +Page01_3C81: + push bc + push af +p01loc_5778: + ld a, (hl) + or a + scf + jr z, p01loc_5791 + ld a, (curRow+1) + cp 0Fh + ld a, (hl) + jr c, p01loc_578B + call PutMap + xor a + jr p01loc_5791 +p01loc_578B: + call PutC + inc hl + jr p01loc_5778 +p01loc_5791: + pop bc + ld a, b + pop bc + ret + +PutS: push bc + push af + ld a, (winTop+1) + ld b, a +p01loc_579B: + ld a, (hl) + inc hl + or a + scf + jr z, p01loc_57AA + call PutC + ld a, (curRow) + cp b + jr c, p01loc_579B +p01loc_57AA: + pop bc + ld a, b + pop bc + ret + +putpsb: ld b, (hl) + inc hl + ld a, b + or a + ret z + ld a, (hl) + cp 20h + jr z, p01loc_57CB + jr p01loc_57C8 +p01loc_57BA: + ld a, (curRow+1) + cp 0Fh + jr c, p01loc_57C7 + ld a, (hl) + call PutMap + jr p01loc_57CB +p01loc_57C7: + ld a, (hl) +p01loc_57C8: + call PutC +p01loc_57CB: + inc hl + djnz p01loc_57BA + ret + +PutPS: ld b, (hl) + inc hl + ld a, b + or a + ret z +p01loc_57D4: + ld a, (hl) + inc hl + call PutC + ld a, (curRow) + ld c, a + ld a, (winTop+1) + cp c + ret z + djnz p01loc_57D4 + ret + +wputps: ld b, (hl) + inc hl + ld a, b + or a + ret z +p01loc_57EA: + ld a, (hl) + inc hl + call wputc + ret c + djnz p01loc_57EA + ret + +putbuf: xor a +putbuf1:bit 1, (iy+2Ah) + jr z, p01loc_57FE + call j_BCALL_4CC9 + ret +p01loc_57FE: + push af + push de + ld hl, (editCursor) + ld de, (editBtm) + call CpHLDE + jr nz, p01loc_5824 + ld a, (mcxCurApp) + cp 42h + jr nz, p01loc_5824 + ld a, (curRow) + or a + jr nz, p01loc_5824 + pop de + ld a, e + call PutMap + call j_BufLeft + ld a, e + pop bc + ret +p01loc_5824: + pop de + call GETTOKSTRING + push hl + ld b, (hl) + inc b + ld hl, curCol + ld a, 10h + push af + sub (hl) + cp b + jr c, p01loc_583C + pop af + pop hl + ld a, (curRow+1) + jr p01loc_585F +p01loc_583C: + pop af + sub b + ld (hl), a + pop hl + push af + ld c, a + ld a, (winLeftEdge) + inc c + cp c + jr c, p01loc_5860 + pop hl +p01loc_584A: + pop de + ld a, 0Eh + ld (curRow+1), a + call fdispEOL + ld a, 0Eh + ld (curRow+1), a + call j_FDISPBOL + ld a, 0Eh + jr p01loc_5893 +p01loc_585F: + push af +p01loc_5860: + push hl + call PutPS + call fdispEOL + pop hl + pop bc + ld a, (curRow+1) + bit 1, (iy+0Eh) + jr z, p01loc_5889 + cp 0Fh + jr nz, p01loc_5889 + ld c, a + pop af + ld a, c + jr c, p01loc_588A + push af + ld a, (winLeftEdge) + cp b + jr z, p01loc_584A + ld a, b + dec a + ld (curRow+1), a + jr p01loc_585F +p01loc_5889: + pop de +p01loc_588A: + push af + ld a, b + ld (curRow+1), a + call j_FDISPBOL1 + pop af +p01loc_5893: + ld (curRow+1), a + ret + +wputc: push bc + push de + push hl + ld c, a + ld hl, (winRow) + ld de, (winAbove) + or a + sbc hl, de + jp p, p01loc_58AE +p01loc_58A8: + set 2, (iy+0Eh) + jr p01loc_5910 +p01loc_58AE: + ld a, (winTop+1) + ld e, a + ld d, 0 + call CpHLDE + jr c, p01loc_58C0 + scf + set 3, (iy+0Eh) + jr p01loc_5910 +p01loc_58C0: + ld a, l + ld hl, winTop + cp (hl) + jr c, p01loc_58A8 + ld (curRow), a + ld hl, (winLeft) + ld a, (winLeftEdge) + ld e, a + add hl, de + ex de, hl + ld hl, (winCol) + call CpHLDE + jp m, p01loc_5914 + ld hl, (winLeft) + ld de, 10h + add hl, de + ex de, hl + ld hl, (winCol) + call CpHLDE + jp p, p01loc_5928 + ld de, (winLeft) + or a + sbc hl, de + ld a, l + ld hl, winLeftEdge + cp (hl) + jr nz, p01loc_5901 + bit 0, (iy+0Eh) + jr nz, p01loc_5909 +p01loc_5901: + ld (curRow+1), a + ld a, c + call PutC + or a +p01loc_5909: + ld hl, (winCol) + inc hl + ld (winCol), hl +p01loc_5910: + pop hl + pop de + pop bc + ret +p01loc_5914: + or a + bit 0, (iy+0Eh) + jr nz, p01loc_5909 + set 0, (iy+0Eh) + set 4, (iy+0Eh) + ld a, (winLeftEdge) + jr p01loc_5939 +p01loc_5928: + scf + bit 1, (iy+0Eh) + jr nz, p01loc_5909 + set 1, (iy+0Eh) + set 5, (iy+0Eh) + ld a, 0Fh +p01loc_5939: + ld (curRow+1), a + ld a, 0CEh + call PutMap + jr p01loc_5909 + +wputs: ld de, (curRow) + push de +p01loc_5948: + ld a, (hl) + or a + jr z, p01loc_5952 + call wputc + inc hl + jr nc, p01loc_5948 +p01loc_5952: + pop hl + ld (curRow), hl + ret + +wputsEOL: + ld de, (curRow) + push de +p01loc_595C: + ld a, (hl) + or a + jr z, p01loc_5968 + call wputc + inc hl + jr nc, p01loc_595C + jr p01loc_596F +p01loc_5968: + ld a, (curRow+1) + or a + call nz, EraseEOL +p01loc_596F: + pop hl + ld (curRow), hl + ret + +wdispEOL: + ld hl, (curRow) + push hl + ld hl, (editTail) + ld de, (editBtm) +p01loc_597F: + call CpHLDE + jr z, p01loc_598D + ld a, (hl) + call wputc + inc hl + jr nc, p01loc_597F + jr p01loc_5994 +p01loc_598D: + ld a, (curRow+1) + or a + call nz, EraseEOL +p01loc_5994: + pop hl + ld (curRow), hl + ret + +whomeup:ld hl, 0 + call CheckSplitFlag + jr z, p01loc_59A3 + ld l, 4 +p01loc_59A3: + ld (winRow), hl + ld l, 0 + ld (winCol), hl + ret + +setNumWindow: + call whomeup + ld a, (curRow) + call j_setwinabove + ld a, (curRow+1) + ld (winLeftEdge), a + ld e, a + ld hl, 0 + or a + sbc hl, de + ld (winLeft), hl + res 1, (iy+0Eh) + res 0, (iy+0Eh) + ret + push de + push hl + ld l, a + ld h, 0 + add hl, hl + add hl, hl + add hl, hl + call j_Load_SFont + ld a, (hl) + pop hl + pop de + ret + +Page01_3CCF: + push hl + ld a, (curRow) + ld hl, winBtm + cp (hl) + pop hl + ret + +newline:push af + push bc + push de + push hl + push ix + sub a + ld (curRow+1), a + ld hl, curRow + ld ix, winTop + ld a, (hl) + inc a + cp (ix+1) + jr c, p01loc_5A3B + bit appAutoScroll, (iy+appFlags) + jr z, p01loc_5A3B + set textScrolled, (iy+textFlags) + call j_SCREENUP + ld a, e + call ClearRow + ei + bit appTextSave, (iy+appFlags) + jr z, p01loc_5A3C + ld a, (ix+0) + call ATimes16 + ld l, a + ld h, 0 + ld de, textShadow + add hl, de + ld e, l + ld d, h + ld bc, 10h + add hl, bc + call p01sub_5B68 + jr z, p01loc_5A31 + ldir +p01loc_5A31: + ld b, 10h + ld a, 20h +p01loc_5A35: + ld (de), a + inc de + djnz p01loc_5A35 + jr p01loc_5A3C +p01loc_5A3B: + ld (hl), a +p01loc_5A3C: + jp p01loc_56A1 + +p01sub_5A3F: + push af + push de + push hl + ld a, 0Fh + ld (curRow+1), a + ld de, curRow + ld a, (de) + dec a + ld hl, winTop + cp (hl) + jp p, p01loc_5A5E + bit appAutoScroll, (iy+appFlags) + jr z, p01loc_5A5E + call scrollDown + jr p01loc_5A5F +p01loc_5A5E: + ld (de), a +p01loc_5A5F: + pop hl + pop de + pop af + ret + +moveDown: + ld a, (curRow) + inc a + ld hl, winBtm + cp (hl) + jr nc, scrollUp + ld (curRow), a + ret + +scrollUp: + push af + push bc + push de + push hl + push ix + ld ix, winTop + call j_SCREENUP + ld a, e + call ClearRow + ei + bit appTextSave, (iy+appFlags) + jp z, p01loc_56A1 + ld a, (ix+0) + call ATimes16 + ld l, a + ld h, 0 + ld de, textShadow + add hl, de + ld e, l + ld d, h + ld bc, 10h + add hl, bc + call p01sub_5B68 + jr z, p01loc_5AA4 + ldir +p01loc_5AA4: + ld b, 10h + ld a, 20h +p01loc_5AA8: + ld (de), a + inc de + djnz p01loc_5AA8 + jp p01loc_56A1 + +shrinkWindow: + ld a, (curRow) + add a, b + sub 7 + cp 1 + ret m + ld b, a + ld hl, curRow +p01loc_5ABC: + call scrollUp + dec (hl) + djnz p01loc_5ABC + ret + +moveUp: ld a, (curRow) + dec a + ld hl, winTop + cp (hl) + jp m, scrollDown + ld (curRow), a + ret + +p01sub_5AD2: + push af + push bc + push de + push hl + push ix + ld hl, winBtm + cp (hl) + jr nz, p01loc_5AE8 + call scrollUp + ld hl, curRow + dec (hl) + jp p01loc_56A1 +p01loc_5AE8: + ld hl, winTop + ld b, (hl) + push bc + ld (hl), a + call scrollDown + pop af + ld (hl), a + jp p01loc_56A1 + +scrollDown: + push af + push bc + push de + push hl + push ix + call RunIndicOff + set textScrolled, (iy+textFlags) + ld ix, winTop + ld a, (ix+1) + sub (ix+0) + dec a + jr nz, p01loc_5B19 + ld a, (ix+1) + dec a + call MAKEROWCMD + jr p01loc_5B24 +p01loc_5B19: + ld b, a + ld c, 0F8h + ld a, (ix+1) + dec a + call j_ScreenUpDown + ld a, e +p01loc_5B24: + call ClearRow + ei + call RunIndicOn + bit appTextSave, (iy+appFlags) + jr z, p01loc_5B53 + ld a, (ix+1) + call ATimes16 + ld l, a + ld h, 0 + ld de, asm_ind_call + add hl, de + ld e, l + ld d, h + ld bc, 0FFF0h + add hl, bc + call p01sub_5B68 + jr z, p01loc_5B4B + lddr +p01loc_5B4B: + ld b, 10h + ld a, 20h +p01loc_5B4F: + ld (de), a + dec de + djnz p01loc_5B4F +p01loc_5B53: + jp p01loc_56A1 + +#ifndef DEVIATE_FROM_ORIGINAL_FILE +;Apparently not referenced anywhere. + ld a, (ix+1) + sub (ix+0) + dec a + push hl + push de + ld b, a + call p01sub_6100 + ld b, h + ld c, l + pop de + pop hl + ret +#endif + +p01sub_5B68: + ld a, (ix+1) + sub (ix+0) + dec a + call ATimes16 + ld c, a + ld b, 0 + ret + +ClrLCDFull: + push af + ld hl, 8A02h + push hl + ld a, (hl) + and 1 + push af + res 0, (hl) + ld b, 80h + ld a, 0B8h + jr p01loc_5BAB + +ClrLCD: push af + ld hl, 8A02h + push hl + ld a, (hl) + and 1 + push af + res 0, (hl) + ld a, 0B8h + push af + ld b, 80h + call CheckSplitFlag + jr z, p01loc_5BAA + ld b, 0A0h + bit plotDisp, (iy+plotFlags) + jr z, p01loc_5BAA + pop af + ld a, 98h + ld b, 80h + push af +p01loc_5BAA: + pop af +p01loc_5BAB: + di +p01loc_5BAC: + push bc + push af + call ClearRow + pop af + sub 8 + pop bc + cp b + jr nc, p01loc_5BAC + ei + pop af + pop hl + or (hl) + ld (hl), a + pop af + ret + +p01sub_5BBF: + push af + ld a, i + push af + ld hl, 8A02h + push hl + ld a, (hl) + and 1 + push af + res 0, (hl) + ld a, 0B8h + ld b, 80h + di +p01loc_5BD2: + push bc + push af + call ClearRow + pop af + sub 8 + pop bc + cp b + jr nc, p01loc_5BD2 + pop af + pop hl + or (hl) + ld (hl), a + pop af + jp po, p01loc_5BE7 + ei +p01loc_5BE7: + pop af + ret + +Page01_3D05: + call p01sub_5BBF + jr p01loc_5BF6 + +ClrScrnFull: + call ClrLCDFull + jr p01loc_5BF6 + +ClrScrn: + call ClrLCD +p01loc_5BF6: + bit appTextSave, (iy+appFlags) + ret z +ClrTxtShd: + ld bc, 7Fh + ld de, 8509h + ld hl, textShadow + ld (hl), 20h + ldir + ret + +ClrWindow: + call HomeUp + ld a, (winTop+1) + dec a + call MAKEROWCMD + push af + ld a, (winTop) + call MAKEROWCMD + di + +p01loc_5C1B: + call ClearRow + pop af + cp d + jr z, p01loc_5C28 + push af + ld a, d + add a, 8 + jr p01loc_5C1B + +p01loc_5C28: + ei + bit appTextSave, (iy+appFlags) + ret z + ld a, (winTop) + ld b, a + ld a, (winTop+1) + sub b + call ATimes16 + dec a + ld c, a + ld a, (winTop) + call ATimes16 + ld l, a + ld h, 0 + ld b, h + ld de, textShadow + add hl, de + ld e, l + ld d, h + inc de + ld (hl), 20h + ldir + ret + +EraseEOL: + push af + bit 1, (iy+2Ah) + jr z, p01loc_5C5D + pop af + call j_VEraseEOL + ret +p01loc_5C5D: + push bc + push de + push hl + ld a, (curRow+1) + push af + sub 10h + jr nc, p01loc_5C79 + neg + ld b, a + ld a, 20h + dec b + jr z, p01loc_5C75 +p01loc_5C70: + call PutC + djnz p01loc_5C70 +p01loc_5C75: + call PutMap + ei +p01loc_5C79: + pop af + ld (curRow+1), a + jp p01loc_56A3 + +EraseEOW: + push af + push hl + ld hl, (curRow) + push hl + ld a, l + ld hl, winBtm + sub (hl) + jr z, p01loc_5C98 +p01loc_5C8D: + call EraseEOL + inc a + jr z, p01loc_5C98 + call newline + jr p01loc_5C8D +p01loc_5C98: + pop hl + ld (curRow), hl + pop hl + pop af + ret + +HomeUp: push hl + ld hl, (winTop) + ld h, 0 + ld (curRow), hl + pop hl + ret + +getcurloc: + push af + push bc + push de + ld hl, (curRow) + ld a, l + call ATimes16 + add a, h + ld l, a + ld h, 0 + ld de, textShadow + add hl, de + pop de + pop bc + pop af + ret + +VPutMapRec: + call p01sub_5CCC + res 6, (iy+32h) + res fracDrawLFont, (iy+fontFlags) + ret + +p01sub_5CCC: + push bc + ld b, a + ld a, i + push af + ld a, b + di + push hl + res fracDrawLFont, (iy+fontFlags) + cp 8 + jr z, p01loc_5D19 + res fracDrawLFont, (iy+fontFlags) + jr p01loc_5D19 + +LoadPattern: + ld l, a + ld h, 0 + add hl, hl + add hl, hl + add hl, hl + bit fracDrawLFont, (iy+fontFlags) + jr z, p01loc_5CF2 + call Page0Call_3C03 + ret + +p01loc_5CF2: + bit 6, (iy+32h) + jr z, p01loc_5D0A + call Page0Call_3BC7 + ld de, 8461h + ld hl, 8460h + ld bc, 7 + lddr + ex de, hl + ld (hl), 5 + ret + +p01loc_5D0A: + call j_Load_SFont + ret + +VPutMap:push bc + ld b, a + ld a, i + push af + ld a, b + di + push hl + call LoadPattern +p01loc_5D19: + push hl + pop ix + ld e, (ix+0) + ld d, 0 + ld hl, LCDTable-1 + add hl, de + ld d, (hl) + push de + ld a, (penCol+1) + ld b, a + or 80h + ld (curXRow), a + call p01sub_55E5 + call SetXUp + call p01sub_6100 + ld a, (penCol) + ld e, a + srl a + srl a + srl a + or 20h + ld (curY), a + call lcd_busy + out (10h), a + ld d, 0 + add hl, de + ld a, e + pop de + add a, e + bit write_on_graph, (iy+sGrFlags) + jr z, p01loc_5D6C + call Bit_VertSplit + jr z, p01loc_5D6C + bit 3, (iy+11h) + jr nz, p01loc_5D68 + cp 30h + jr p01loc_5D82 +p01loc_5D68: + cp 17h + jr p01loc_5D82 +p01loc_5D6C: + bit 3, (iy+11h) + jr z, p01loc_5D76 + cp 30h + jr p01loc_5D82 +p01loc_5D76: + bit 4, (iy+24h) + jr z, p01loc_5D80 + cp 61h + jr p01loc_5D82 +p01loc_5D80: + cp 60h +p01loc_5D82: + ccf + jp c, p01loc_5E78 + push de + ld (penCol), a + ld a, l + and 7 + ld c, a + srl h + rr l + srl h + rr l + srl h + rr l + ld de, plotSScreen + add hl, de + pop de + ld a, (customHeight) + ld b, a + bit customFont, (iy+fontFlags) + jr nz, p01loc_5DC0 + ld b, 7 + bit 6, (iy+32h) + jr nz, p01loc_5DC0 + bit fracDrawLFont, (iy+fontFlags) + jr nz, p01loc_5DBF + ld b, 6 + bit textEraseBelow, (iy+textFlags) + jr z, p01loc_5DC0 +p01loc_5DBF: + inc b +p01loc_5DC0: + ld a, 8 + sub c + sub (ix+0) + inc ix + jp m, p01loc_5E0E + ld c, a + inc c +p01loc_5DCD: + push bc + ld b, c + ld a, (hl) + bit textWrite, (iy+sGrFlags) + call z, sOK + jr p01loc_5DDA +p01loc_5DD9: + rrca +p01loc_5DDA: + djnz p01loc_5DD9 + call p01sub_5E81 + jr p01loc_5DE2 +p01loc_5DE1: + rlca +p01loc_5DE2: + djnz p01loc_5DE1 + bit textWrite, (iy+sGrFlags) + jr z, p01loc_5DF4 + ld (hl), a + push de + ld de, 0Ch + add hl, de + pop de + pop bc + jr p01loc_5E03 +p01loc_5DF4: + call lcd_busy + out (11h), a + ld hl, curXRow + inc (hl) + pop bc + ld a, (hl) + cp 0C0h + jr nc, p01loc_5E05 +p01loc_5E03: + djnz p01loc_5DCD +p01loc_5E05: + pop hl + pop af + jp po, p01loc_5E0B + ei +p01loc_5E0B: + pop bc + xor a + ret +p01loc_5E0E: + neg + ld c, a +p01loc_5E11: + push bc + ld b, c + bit textWrite, (iy+sGrFlags) + jr z, p01loc_5E1E + ld a, (hl) + inc hl + ld e, (hl) + jr p01loc_5E30 +p01loc_5E1E: + call sOK + push af + ld a, (curY) + inc a + call lcd_busy + out (10h), a + call sOK + ld e, a + pop af +p01loc_5E30: + sla e + rla + jr nc, p01loc_5E36 + inc e +p01loc_5E36: + djnz p01loc_5E30 + call p01sub_5E81 +p01loc_5E3B: + srl a + rr e + jr nc, p01loc_5E43 + add a, 80h +p01loc_5E43: + djnz p01loc_5E3B + bit textWrite, (iy+sGrFlags) + jr z, p01loc_5E57 + ld (hl), e + dec hl + ld (hl), a + push de + ld de, 0Ch + add hl, de + pop de + pop bc + jr p01loc_5E74 +p01loc_5E57: + push af + ld a, e + call p01sub_55B5 + ld a, (curY) + call lcd_busy + out (10h), a + pop af + call lcd_busy + out (11h), a + ld hl, curXRow + inc (hl) + pop bc + ld a, (hl) + cp 0C0h + jr nc, p01loc_5E05 +p01loc_5E74: + djnz p01loc_5E11 + jr p01loc_5E05 +p01loc_5E78: + pop hl + pop af + jp po, p01loc_5E7E + ei +p01loc_5E7E: + pop bc + scf + ret + +p01sub_5E81: + bit textInverse, (iy+textFlags) + jr z, p01loc_5E8E + ld b, a + ld a, 0FFh + xor d + or b + jr p01loc_5E8F +p01loc_5E8E: + and d +p01loc_5E8F: + xor (ix+0) + inc ix + ld b, c + ret + +LCDTable: + .db 0FEh + .db 0FCh + .db 0F8h + .db 0F0h + .db 0E0h + .db 0C0h + +VPutS: push af + push de + push ix +p01loc_5EA0: + ld a, (hl) + inc hl + or a + jr z, p01loc_5EAA + call VPutMap + jr nc, p01loc_5EA0 +p01loc_5EAA: + pop ix + pop de + pop af + ret + +VPutSN: push af + push de + push ix +p01loc_5EB3: + ld a, (hl) + inc hl + call VPutMap + jr c, p01loc_5EBC + djnz p01loc_5EB3 +p01loc_5EBC: + pop ix + pop de + pop af + ret + +vputsnG:scf + push af + push de + push ix +p01loc_5EC6: + bit 4, (iy+11h) + jr z, p01loc_5F15 + ld a, (hl) + push hl + push bc + ld l, a + ld h, 0 + add hl, hl + add hl, hl + add hl, hl + call j_SFont_Len + ld a, (penCol) + add a, b + call Bit_VertSplit + jr z, p01loc_5EEF + bit 3, (iy+11h) + jr nz, p01loc_5EEB + cp 2Ch + jr p01loc_5EFB +p01loc_5EEB: + cp 14h + jr p01loc_5EFB +p01loc_5EEF: + bit 3, (iy+11h) + jr z, p01loc_5EF9 + cp 2Ch + jr p01loc_5EFB +p01loc_5EF9: + cp 5Ch +p01loc_5EFB: + ccf + jr nc, p01loc_5F13 + ld a, 0CEh + call VPutMap + pop bc + pop hl +p01loc_5F05: + pop ix + pop de + pop af + res 6, (iy+32h) + res fracDrawLFont, (iy+fontFlags) + or a + ret +p01loc_5F13: + pop bc + pop hl +p01loc_5F15: + bit 4, (iy+24h) + jr z, p01loc_5F1F + set fracDrawLFont, (iy+fontFlags) +p01loc_5F1F: + ld a, (hl) + inc hl + call VPutMap + jr c, p01loc_5F05 + djnz p01loc_5EC6 + res fracDrawLFont, (iy+fontFlags) + jr p01loc_5EBC + +vputsnT: + ld a, (hl) + push hl + push bc + ld l, a + ld h, 0 + add hl, hl + add hl, hl + add hl, hl + call j_SFont_Len + ld a, (penCol) + add a, b + cp 5Ch + ccf + jr nc, p01loc_5F4C + ld a, 0CEh + call VPutMap + pop bc + pop hl +p01loc_5F4A: + or a + ret +p01loc_5F4C: + pop bc + pop hl + ld a, (hl) + inc hl + call VPutMap + jr c, p01loc_5F4A + djnz vputsnT + scf + ret + +RunIndicOn: + push af + push bc + push de + push hl + ld a, 0F0h + ld (indicBusy), a + ld a, 1 + ld (indicCounter), a + call HandleRunIndicator + ei + set indicRun, (iy+indicFlags) + jp p01loc_56A3 + +RunIndicOff: + push bc + push de + push hl + res indicRun, (iy+indicFlags) + ld b, 8 + call p01sub_60C2 + ld d, a +p01loc_5F7F: + ld a, d + call p01sub_55E5 + call SetXUp + call lcd_busy + in a, (11h) + call lcd_busy + in a, (11h) + and 0FEh + ld e, a + ld a, d + call p01sub_55E5 + call SetXUp + ld a, e + call lcd_busy + out (11h), a + inc d + djnz p01loc_5F7F + pop hl + pop de + pop bc + ei + ret + +saveCmdShadow: + call saveShadow + ld de, cmdShadow + ld hl, textShadow + ld bc, 80h + ldir + ld hl, (curRow) + ld (cmdShadCur), hl + ret + +saveShadow: + ld hl, (curRow) + ld (textShadCur), hl + ld a, (winTop) + ld (textShadTop), a + ld a, (unk_8A02) + ld (textShadAlph), a + ld a, (unk_89F5) + and 10h + ld (textShadIns), a + ret + +#ifndef DEVIATE_FROM_ORIGINAL_FILE + ld a, (textShadTop) + ld (winTop), a + ld a, 8 + ld hl, menuAppDepth + sub (hl) + cp 6 + jr nc, p01loc_5FEA + ld a, 6 +p01loc_5FEA: + ld (winTop+1), a + ld hl, 0 + jr p01loc_601B +#endif + +rstrShadow: + ld a, (textShadTop) + ld (winTop), a + ld a, 8 + ld hl, menuAppDepth + sub (hl) + cp 6 + jr nc, p01loc_6004 + ld a, 6 +p01loc_6004: + ld (winTop+1), a + ld hl, 0 + call CheckSplitFlag + jr z, p01loc_601B + sub 4 + ld l, 4 + ld (curRow), hl + ld hl, 8548h + jr p01loc_6021 +p01loc_601B: + ld (curRow), hl + ld hl, textShadow +p01loc_6021: + call ATimes16 + ld b, a + dec b +p01loc_6026: + ld a, (hl) + inc hl + call PutC + djnz p01loc_6026 + ld a, (hl) + call PutMap +BCALL_4D6B: + ld hl, (textShadCur) + ld (curRow), hl + ld a, (textShadAlph) + ld (unk_8A02), a + ld a, (textShadIns) + and 0EFh + ld hl, 89F5h + or (hl) + ld (hl), a + ret + +rstrpartial: + ld a, (textShadTop) + ld (winTop), a + ld a, 8 + ld (winTop+1), a + jr BCALL_4D6B +rstrCurRow: + ld hl, (textShadCur) + ld h, 0 + ld (curRow), hl + call getcurloc + ld b, 0Fh + jr p01loc_6026 + +rstrUnderMenu: + ld a, (curRow) + cp 6 + ret c + ld hl, (curRow) + push hl + sub a + ld (curRow+1), a + ld b, 0Fh + call getcurloc +p01loc_6077: + ld a, (hl) + inc hl + call PutC + djnz p01loc_6077 + ld a, (hl) + call PutMap + pop hl + ld (curRow), hl + ret + +rstrbotrow: + ld hl, (curRow) + push hl + sub a + ld (curRow+1), a + ld b, 0Fh + ld hl, 978Fh + jr p01loc_6077 + +saveTR: bit indicInUse, (iy+indicFlags) + ret nz + push af + push bc + push de + push hl + push ix + set indicInUse, (iy+indicFlags) + ld b, 8 + ld ix, indicMem + call p01sub_60C2 + call lcd_busy + in a, (11h) +p01loc_60B3: + call lcd_busy + in a, (11h) + ld (ix+0), a + inc ix + djnz p01loc_60B3 + jp p01loc_56A1 + +p01sub_60C2: + di + ld a, 2Bh + call lcd_busy + out (10h), a + ld a, 80h + call p01sub_55E5 + call SetXUp + ret + +restoreTR: + bit indicInUse, (iy+indicFlags) + ret z + push af + push bc + push de + push hl + push ix + ld b, 8 + ld ix, indicMem + call p01sub_60C2 +p01loc_60E7: + ld a, (ix+0) + inc ix + call lcd_busy + out (11h), a + djnz p01loc_60E7 + res indicInUse, (iy+indicFlags) + ei + jp p01loc_56A1 + +ATimes16: + add a, a + add a, a + add a, a + add a, a + ret + +p01sub_6100: + inc b + ld hl, 0 + ld de, 60h + jr p01loc_610A +p01loc_6109: + add hl, de +p01loc_610A: + djnz p01loc_6109 + ret + +GetKeyPress: + call GETTOKSTRING + dec hl + ld a, (hl) + ret + +GetTokLen: + call GETTOKSTRING + ld a, (hl) + ret + +GET_TOK_STRNG: + push hl + call j_BUFPEEK3 + call GETTOKSTRING + ld a, (hl) + ld c, a + ld b, 0 + inc hl + push bc + ld de, OP3 + ldir + ex de, hl + ld (hl), 0 + pop bc + pop hl + ret + +GETTOKSTRING: + ld l, e + ld h, 0 + ld a, d + or a + jr z, p01loc_61A6 + ld de, StringTable4200 + cp 5Dh + jr c, p01loc_61A9 + ld de, StringTable4214 + jr z, p01loc_61A9 + ld de, StringTable4220 + cp 60h + jr nc, p01loc_616A + ld a, l + res 4, l + bit 4, a + jr nz, p01loc_61A9 + ld de, StringTable4234 + res 5, l + bit 5, a + jr nz, p01loc_61A9 + ld de, StringTable424C + res 6, l + bit 6, a + jr nz, p01loc_61A9 + res 7, l + ld de, StringTable4258 + jr p01loc_61A9 +p01loc_616A: + ld de, StringTable425E + cp 61h + jr c, p01loc_61A9 + ld de, StringTable4272 + jr z, p01loc_61A9 + ld de, StringTable429A + cp 63h + jr c, p01loc_61A9 + ld de, StringTable4314 + jr z, p01loc_61A9 + cp 7Eh + jr z, p01loc_61A1 + ld de, StringTable4286 + cp 0BBh + jr c, p01loc_61A9 + ld de, StringTable43AA + ld a, l + jr nz, p01loc_619B + cp 0F6h + jr c, p01loc_61A9 + ld l, 0F6h + jr p01loc_61A9 +p01loc_619B: + cp 13h + jr c, p01loc_61A1 + ld l, 13h +p01loc_61A1: + ld de, StringTable4384 + jr p01loc_61A9 +p01loc_61A6: + ld de, StringTable4000 +p01loc_61A9: + add hl, hl + add hl, de + ld e, (hl) + inc hl + ld d, (hl) + ex de, hl + bit tokenHookActive, (iy+hookflags3) + jr z, p01loc_61D8 + ld a, (hl) + ld (localTokStr), a + push bc + push hl + ld hl, StringTable4000+1 + ex de, hl + or a + sbc hl, de + ex de, hl + ld bc, 0 + or a + ld hl, 546h + sbc hl, de + jr nc, p01loc_61D3 + ld b, d + ld c, e + ld de, 0Ch +p01loc_61D3: + pop hl + call Page0Call_3C15 + pop bc +p01loc_61D8: + inc hl + ret + +SGetTokString: + call GETTOKSTRING + ld de, ioPrompt + ld bc, 11h + ldir + ld hl, ioPrompt + ret + +PUTBPATBUF2: + push bc + push de + push hl + push af + ld b, 1 + jr p01loc_61FB + +PUTBPATBUF: + call j_GetPrevTok + +putbPAT: + xor a + push bc + push de + push hl + push af + ld b, 0 +p01loc_61FB: + push bc + call GETTOKSTRING + ld b, (hl) + ld e, b + ld d, 0 + add hl, de +p01loc_6204: + ld a, (winLeftEdge) + pop de + push de + bit 0, d + jr nz, p01loc_6250 + ld a, (hl) + cp 0D6h + jr nz, p01loc_624F + ld hl, curCol + dec (hl) + ld a, 3Ah + call PutMap + call p01sub_5A3F + ld a, (curRow) + ld hl, winTop + cp (hl) + jp m, p01loc_6281 + ld hl, (editCursor) +p01loc_622B: + ld de, (editTop) + dec hl + call CpHLDE + jr c, p01loc_623E + inc hl + call j_GetPrevTok + call page0_17C7 + jr nz, p01loc_622B +p01loc_623E: + inc hl + ld de, (editCursor) + call j_stringwidth + ld a, e + inc a + and 0Fh + ld (curRow+1), a + jr p01loc_6265 +p01loc_624F: + xor a +p01loc_6250: + ld c, a + ld a, (curRow+1) + dec a + jp m, p01loc_626C + cp c + jr c, p01loc_626C + ld (curRow+1), a +p01loc_625E: + ld a, (hl) + dec hl + call PutMap + djnz p01loc_6204 +p01loc_6265: + pop de + pop af + scf +p01loc_6268: + pop hl + pop de + pop bc + ret +p01loc_626C: + pop de + pop af + jr nz, p01loc_6283 + push af + push de + call p01sub_5A3F + ld a, (curRow) + push hl + ld hl, winTop + cp (hl) + pop hl + jp p, p01loc_625E +p01loc_6281: + pop de + pop af +p01loc_6283: + or a + jr p01loc_6268 + +putcCheckScrolL: + push af + res textScrolled, (iy+textFlags) + call GETTOKSTRING + ld a, (mcxCurApp) + cp 49h + jr nz, p01loc_62B2 + pop af + jr nz, p01loc_62AB + push hl + ld a, (hl) + ld de, (curRow) + add a, d + cp 10h + ld a, e + inc a + call nc, p01sub_5AD2 + pop hl + call PutPS + ret + +p01loc_62AB: + call PutPS + call j_DISPYEOS + ret + +p01loc_62B2: + pop af + call PutPS + bit textScrolled, (iy+textFlags) + ret z + call j_DispEOW + ret + +DispEOL: + ld a, (curRow+1) + push af + ld hl, (editTail) +p01loc_62C6: + call j_BUFPEEK1 + jr z, p01loc_62E8 + inc hl + push hl + call GETTOKSTRING + ld b, (hl) +p01loc_62D1: + inc hl + ld a, (curRow+1) + cp 0Fh + ld a, (hl) + jr z, p01loc_62E2 + call PutC + djnz p01loc_62D1 + pop hl + jr p01loc_62C6 +p01loc_62E2: + call PutMap + pop hl + jr p01loc_62EB +p01loc_62E8: + call EraseEOL +p01loc_62EB: + pop af + ld (curRow+1), a + ret + +fdispEOL: + bit 1, (iy+2Ah) + jr z, p01loc_62FA + call j_BCALL_4CCC + ret + +p01loc_62FA: + ld a, (curRow+1) + or a + ret z + call Page0Call_3C3F + push af + ld hl, (editTail) +p01loc_6306: + call j_BUFPEEK1 + jr z, p01loc_6349 + inc hl + push hl + call GETTOKSTRING + ld b, (hl) + inc hl +p01loc_6312: + ld a, (curRow+1) + cp 0Fh + jr z, p01loc_6323 + ld a, (hl) + inc hl + call PutC + djnz p01loc_6312 + pop hl + jr p01loc_6306 +p01loc_6323: + ld c, (hl) + pop hl + ld a, b + cp 2 + jr nc, p01loc_6335 + ld de, (editBtm) + or a + sbc hl, de + ld a, h + or l + jr z, p01loc_633D +p01loc_6335: + set 1, (iy+0Eh) + ld a, 0CEh + jr p01loc_6341 +p01loc_633D: + ld a, c + call Page0Call_3C3F +p01loc_6341: + call PutMap + pop af + ld (curRow+1), a + ret + +p01loc_6349: + call EraseEOL + call Page0Call_3C3F + pop af + ld (curRow+1), a + ret + +ClearRow: + di + ld d, a + ld e, 20h +p01loc_6358: + ld a, d + call p01sub_55E5 + call SetXUp + ld b, 8 + ld a, e + call lcd_busy + out (10h), a +p01loc_6367: + xor a + call lcd_busy + out (11h), a + djnz p01loc_6367 + inc e + ld a, e + cp 2Ch + jr nz, p01loc_6358 + ret + +MAKEROWCMD: + add a, a + add a, a + add a, a + add a, 80h + ret + +TOTOSTRP: + ld b, a +p01loc_637D: + ld a, (hl) + ld (de), a + inc de + ld a, (unk_865E) + inc a + ld (unk_865E), a + cp 10h + ret z + inc hl + djnz p01loc_637D + or 1 + ret + +SETVARNAME: + ld a, (OP1+1) + ld d, 0 + cp 5Ch + jr c, p01loc_63BA + cp 5Dh + ld d, a + ld a, (OP1M) + jr nz, p01loc_63BA + cp 6 + jr c, p01loc_63BA + ld hl, OP1M + ld de, ioPrompt +p01loc_63AB: + ld a, (hl) + or a + jr z, p01loc_63C7 + cp 5Bh + jr nz, p01loc_63B5 + ld a, 5Bh +p01loc_63B5: + ld (de), a + inc de + inc hl + jr p01loc_63AB +p01loc_63BA: + ld e, a + call GETTOKSTRING + ld c, (hl) + ld b, 0 + inc hl + ld de, ioPrompt + ldir +p01loc_63C7: + ld hl, {+} + jp strcopy ++: .asc '=?',0 +DispDone: + bit localizeHookActive, (iy+hookflags3) + jr z, p01loc_63DC + ld a, 0Dh + call j_call_character_hook + ret z +p01loc_63DC: + ld hl, curCol + ld (hl), 0Ch + ld hl, aDone + call PutS + ret + +finishoutput: + call CpHLDE + ret z + push de + call j_BUFPEEK3 + inc hl + push hl + call GETTOKSTRING + ld b, (hl) +p01loc_63F6: + inc hl + ld a, (hl) + call PutC + call Page01_3CCF + jr nc, p01loc_6407 + djnz p01loc_63F6 + pop hl + pop de + jr finishoutput + ret +p01loc_6407: + pop de + pop hl + ret + +DisplayCalcModelAndOSVersion: + call DisplayCalculatorModel + call PutS_penColPrefixed + ld hl, aOSVersionString +PutS_penColPrefixed: + push hl + call ldHLind + inc hl + inc hl + ld (penCol), hl + pop hl + inc hl + inc hl + jp VPutS +aHelpEducation_: + .db 0 + .db 3Ah + .asc 'Help: education.ti.com',0 +aTi83Plus: + .db 1Ah + .db 8 + .asc 'TI-83 Plus',0 +aTi83PlusSilver: + .db 6 + .db 8 + .asc 'TI-83 Plus Silver Edition',0 +aCopyright19982:.asc 'Copyright 1998-2001, Texas Instruments Inc.',0 + +Page01_3E07: + call j_CursorOff + call ClrLCD + call RunIndicOff + call DisplayCalculatorModel + call p01sub_65B0 + ld hl, 62h + call p01sub_65B0 + ld hl, aProd + ld a, 7Dh + bit localizeHookActive, (iy+hookflags3) + call nz, j_call_character_hook + call p01sub_65B0 + rst 28h + .dw 80C3h + ld a, e + ld (OP4), a + ld ix, OP4 + ld hl, OP1 + ld b, 1 + call Page0Call_3C4B + ld a, 2Dh + ld (OP1M), a + xor a + ld (OP1M+1), a + call VPutS + ld de, 80A0h + call p01sub_657F + ld hl, OP1+1 + call VPutS + ld a, 2Dh + ld (OP1), a + xor a + ld (OP1+1), a + ld hl, OP1 + call VPutS + ld de, 8020h + call p01sub_657F + call VPutS + ld a, 2Dh + ld (OP1), a + xor a + ld (OP1+1), a + ld hl, OP1 + call VPutS + ld de, 8030h + call p01sub_657F + call VPutS + rst 28h + .dw 807Eh + jr nz, p01loc_654E + ld hl, aId_01 + call p01sub_65B0 + ld ix, OP4 + ld hl, OP1 + ld d, 1 + call Page0Call_3C4B + push hl + ld hl, 8482h + ld de, OP2 + ld bc, 6 + lddr + ld a, 2Dh + ld (OP1+5), a + pop hl + call VPutS + ld a, 2Dh + call VPutMap + call Page0Call_3C51 + inc hl + call Page0Call_3C57 + dec hl + call Page0Call_3C57 +p01loc_654E: + ld hl, 2504h + ld (penCol), hl + call Page0Call_3C5D + ld hl, 2D00h + ld (penCol), hl + call Page0Call_3C63 + jr nz, p01loc_656F + ld a, b + cp 31h + jr c, p01loc_6569 + ld b, 30h +p01loc_6569: + ld hl, tempSwapArea + call p01sub_65D6 +p01loc_656F: + ld hl, aHelpEducation_ + ld a, 70h + bit localizeHookActive, (iy+hookflags3) + call nz, j_call_character_hook + call p01sub_65B0 + ret + +p01sub_657F: + ld a, 7Ah + ld hl, 4000h + rst 28h + .dw 8075h + jr nz, p01loc_6593 + ld a, 7Ah + inc hl + rst 28h + .dw 805Ah + ld a, b + or c + jr nz, p01loc_659A +p01loc_6593: + ld (OP4), a + ld c, 1 + jr p01loc_65A4 +p01loc_659A: + ld a, 7Ah + ld de, OP4 + push bc + rst 28h + .dw 8054h + pop bc +p01loc_65A4: + ld ix, OP4 + ld hl, OP1 + ld b, c + call Page0Call_3C4B + ret + +p01sub_65B0: + push hl + call ldHLind + ld (penCol), hl + pop hl + inc hl + inc hl + jp VPutS + +p01loc_65BD: + inc hl + ld a, b + or b + ret z + dec b +p01loc_65C2: + ld de, (penCol) + ld e, 0 + ld a, 6 + add a, d + ld d, a + cp 37h + ret nc + ld (penCol), de + ld a, (hl) + jr p01loc_65DF + +p01sub_65D6: + ld a, b + or b + ret z + dec b + ld a, (hl) + cp 0D6h + jr z, p01loc_65BD +p01loc_65DF: + call VPutMap + jr c, p01loc_65C2 + inc hl + jr p01sub_65D6 + +aProd: .db 4 + .db 16h + .asc 'PROD #: ',0 +aId_01: .db 4 + .db 1Eh + .asc 'ID: ',0 + +Page01_3FA5: + di + ld a, 2Bh + call lcd_busy + out (10h), a + ld (hl), 14h + ld hl, indicBusy + rrc (hl) + ld c, (hl) + ld b, 8 + ld d, 80h +p01loc_660F: + ld a, d + call p01sub_55E5 + call SetXUp + call lcd_busy + in a, (11h) + call lcd_busy + in a, (11h) + ld e, a + ld a, d + call p01sub_55E5 + call SetXUp + ld a, e + rr c + jr c, p01loc_6631 + res 0, a + jr p01loc_6633 +p01loc_6631: + set 0, a +p01loc_6633: + call lcd_busy + out (11h), a + inc d + djnz p01loc_660F + ret + +JForceGraphNoKey: + ld a, kGraph +JForceGraphKey: + ld b, a + ld sp, (onSP) + res cmdExec, (iy+cmdFlags) + ld a, kGraph + call newContext0 + jp sendKPress + +DisplayCalculatorModel: + ld hl, aTi83Plus + ld a, 65h + call NZIf83Plus + jr nz, p01loc_665E + ld hl, aTi83PlusSilver + ld a, 7Ch +p01loc_665E: + bit localizeHookActive, (iy+hookflags3) + call nz, j_call_character_hook + ret + +KeyToString: + ld a, d + cp 0FFh + jr z, p01loc_667C + cp 0FBh + jr z, p01loc_6673 + cp 0FCh + jr nz, p01loc_667A +p01loc_6673: + ld h, 2 + call Page0Call_3BB5 + jr p01loc_6691 +p01loc_667A: + cp 0FEh +p01loc_667C: + ld a, e + jr z, p01loc_668C + cp 5Ah + jr c, p01loc_6697 + call p01sub_6720 + ret z + call j_ConvKeyToTok + jr p01loc_6691 +p01loc_668C: + ld h, 1 + call Page0Call_3BB5 +p01loc_6691: + call GETTOKSTRING + jp p01loc_670D +p01loc_6697: + cp 1Fh + jr z, p01loc_66D6 + cp 40h + jr c, p01loc_66EA + cp 59h + jp z, p01loc_66BC + cp 40h + jr nz, p01loc_66CA + ld a, d + cp 10h + ld a, e + jr nz, p01loc_66CA + ld hl, Condition8Table + bit localizeHookActive, (iy+hookflags3) + ld a, 8 + call nz, j_call_character_hook + jr p01loc_670D +p01loc_66BC: + ld a, d + cp 0 + jr c, p01loc_66C5 + ld a, 61h + jr p01loc_66D8 +p01loc_66C5: + ld a, 40h + ld (kbdKey), a +p01loc_66CA: + cp 55h + jr z, p01loc_66E7 + cp 4Ch + jr nz, p01loc_66DB + ld a, 5Fh + jr p01loc_66D8 +p01loc_66D6: + ld a, 50h +p01loc_66D8: + add a, d + jr p01loc_66EC +p01loc_66DB: + cp 56h + jr z, p01loc_66E3 + cp 42h + jr nz, p01loc_66E8 +p01loc_66E3: + add a, 9 + add a, 0Dh +p01loc_66E7: + add a, d +p01loc_66E8: + sub 1Bh +p01loc_66EA: + sub 10h +p01loc_66EC: + cp 63h + jr c, p01loc_66F2 + ld a, 13h +p01loc_66F2: + ld l, a + ld h, 0 + add hl, hl + ld de, MenuItems2Table + add hl, de + bit localizeHookActive, (iy+hookflags3) + jr z, p01loc_6708 + ld e, a + ld a, 9 + call j_call_character_hook + jr z, p01loc_670D +p01loc_6708: + ld e, (hl) + inc hl + ld d, (hl) + ex de, hl + cp a +p01loc_670D: + push af + push bc + push de + dec hl + ld de, keyForStr + ld bc, 12h + ldir + pop de + pop bc + pop af + ld hl, keyToStrRam + ret + +p01sub_6720: + ld hl, MenuFunctionStringTable + ld b, 13 + jr p01loc_6727 +p01loc_6727: + cp (hl) + jr z, p01loc_6730 + inc hl + inc hl + inc hl + djnz p01loc_6727 + ret +p01loc_6730: + inc hl + bit localizeHookActive, (iy+hookflags3) + jr z, p01loc_6708 + ld e, a + ld a, 0Ah + call j_call_character_hook + jr p01loc_670D + jr p01loc_6708