include "ti83plus.inc" _EnableGetCSCHook equ 4F7Bh _DisableGetCSCHook equ 4F7Eh getCSCHookActive equ 0 getCSCHookPtr equ 9B88h EXT_APP equ 1 cseg db 080h, 00Fh db 000h, 000h, 000h, 000h db 080h, 012h db 001h, 004h db 080h, 021h db 001h db 080h, 031h db 001h db 080h, 048h db "XtraTokn" db 080h, 081h db 001h db 080h, 090h db 003h, 026h, 009h, 004h db 018h, 0D8h, 0D2h, 099h db 002h, 00Dh, 040h, 0A1h, 06Bh, 099h, 0F6h, 059h, 0BCh, 067h db 0F5h, 085h, 09Ch, 009h, 06Ch, 00Fh, 0B4h, 003h, 09Bh, 0C9h db 003h, 032h, 02Ch, 0E0h, 003h, 020h, 0E3h, 02Ch, 0F4h, 02Dh db 073h, 0B4h, 027h, 0C4h, 0A0h, 072h, 054h, 0B9h, 0EAh, 07Ch db 03Bh, 0AAh, 016h, 0F6h, 077h, 083h, 07Ah, 0EEh, 01Ah, 0D4h db 042h, 04Ch, 06Bh, 08Bh, 013h, 01Fh, 0BBh, 093h, 08Bh, 0FCh db 019h, 01Ch, 03Ch, 0ECh, 04Dh, 0E5h, 075h db 080h, 07Fh db 000h, 000h, 000h, 000h db 000h, 000h, 000h, 000h db 000h, 000h, 000h, 000h db 000h, 000h, 000h, 000h db 000h, 000h, 000h, 000h ; /////////////////////////////////////////////////////////////// ; // App StartApp: res IndicRun, (iy + IndicFlags) B_CALL ClrLCDFull B_CALL HomeUp set textInverse, (iy + textFlags) ld hl, AppMenu call PutSApp res textInverse, (iy + textFlags) ld hl, AppMenu1 call PutSApp B_CALL NewLine ld hl, AppMenu2 call PutSApp B_CALL NewLine ld hl, AppMenu3 call PutSApp B_CALL NewLine GetCSC_Loop: ei halt B_CALL GetCSC or a jr z, GetCSC_Loop cp sk1 jr z, Install cp sk2 jr z, Uninstall cp sk3 jr z, Quit cp skClear jr z, Quit cp skMode jr z, Quit jr GetCSC_Loop Install: bit getCSCHookActive, (iy + 34h) call nz, PrepareChainHook ld hl, RawKeyHook in a, (6) B_CALL EnableGetCSCHook B_CALL ClrLCDFull B_CALL HomeUp ld hl, InstallOk call PutSApp B_CALL NewLine B_CALL NewLine ld hl, PressAnyKey call PutSApp call WaitKey jr StartApp PrepareChainHook: ld a, (getCSCHookPtr + 2) ld b, a in a, (6) cp b ret z ld hl, AppVar B_CALL Mov9ToOP1 B_CALL ChkFindSym ret nc ld hl, 4 B_CALL CreateAppVar inc de inc de ld bc, 4 ld hl, getCSCHookPtr ld a, (hl) inc a ld (hl), a ; Skip db 083h ldir ret Uninstall: ld hl, AppVar B_CALL Mov9ToOP1 B_CALL ChkFindSym jr c, NoRestore push hl push de inc de inc de push de ex de, hl B_CALL LdHLInd dec l ; db 083h ex de, hl pop hl inc hl inc hl ld a, (hl) ex de, hl B_CALL EnableGetCSCHook pop de pop hl B_CALL DelVarArc jr Restored NoRestore: B_CALL DisableGetCSCHook Restored: B_CALL ClrLCDFull B_CALL HomeUp ld hl, UninstallOk call PutSApp B_CALL NewLine B_CALL NewLine ld hl, PressAnyKey call PutSApp call WaitKey jr StartApp Options: jr StartApp Quit: set IndicRun, (iy + IndicFlags) B_JUMP JForceCmdNoChar AppMenu: db "XtraTokn 1.1 ", 0 AppMenu1: db "1) Install", 0 AppMenu2: db "2) Uninstall", 0 AppMenu3: db "3) Quit", 0 InstallOk: db "Install OK!", 0 UninstallOk: db "Uninstall OK!", 0 PressAnyKey: db "Press any key...", 0 AppVar: db AppVarObj, "XtraTokn" ; // App ; ///////////////////////////////////////////////////////////////// PutSApp: ld a,(hl) inc hl or a ret z B_CALL PutC jr PutSApp WaitKey: push hl WaitKeyLoop: ei halt B_CALL GetCSC or a jr z, WaitKeyLoop pop hl ret ; ///////////////////////////////////////////////////////////////// ; // Hook HeaderSelect equ AppBackUpScreen VarsSelect equ AppBackUpScreen + 1 ; //////////////////////////////////////////// ; // Hook entry RawKeyHook: add a, e ld e, a ld d, b cp 1Bh jr nz, RetNoPop ld a, b cp skVars jr nz, RetNoPop bit ShiftAlpha, (iy + ShiftFlags) jr z, RetNoPop ld b, a ld a, (MenuCurrent) or a jr nz, RetNoPop ld a, (cxCurApp) cp kExtApps jr z, RetNoPop bit EditOpen, (iy + EditFlags) jr z, RetNoPop res IndicRun, (iy + IndicFlags) res CurOn, (iy + CurFlags) res CurAble, (iy + CurFlags) res ShiftAlpha, (iy + ShiftFlags) res appTextSave, (iy + appFlags) res 0, (iy + asmFlag3) ld a, 0FFh ld (VarsSelect), a ld hl, (CurRow) push hl ld hl, plotSScreen B_CALL SaveDisp call DisplayMenu set appTextSave, (iy + appFlags) set CurAble, (iy + CurFlags) set CurOn, (iy + CurFlags) ld hl, plotSScreen ld b, 64 B_CALL RestoreDisp pop hl ld (CurRow), hl ld a, d add a, e or a jr z, Exit ; B_CALL BufInsert ; B_CALL BufLeft ; B_CALL DispEOW ; B_CALL CursorRight ld hl, (editTail) dec hl ld (hl), e dec hl ld (hl), d ld a, l ld (editTail), a ld a, h ld (editTail + 1), a B_CALL DispEOW res cmdVirgin, (iy + cmdFlags) Exit: ld a, skRight cp 1 ret RetNoPop: push bc push de ld hl, AppVar ld de, OP1 ld bc, 9 ldir B_CALL ChkFindSym jr c, RetPopNoChain ld a, b or a jr z, VarInRam B_CALL Arc_Unarc pop de pop bc jr RetNoPop VarInRam: ex de, hl inc hl inc hl ld de, getCSCHookPtr ld bc, 3 ldir pop de ld a, e ld b, d rst 28h dw getCSCHookPtr + 4000h push af in a, (6) ld hl, RawKeyHook B_CALL EnableGetCSCHook pop af pop bc ret RetPopNoChain: pop de pop bc ld a, e ld b, d cp 1Bh ret nz cp 1Ah ld a, b ret ; // Hook leave ; ////////////////////////////////////////// ; ////////////////////////////////////////// ; // Display menu header DisplayMenu: B_CALL ClrLCDFull ld a, 1 ld (HeaderSelect), a jr Refresh HookWaitKey: call WaitKey cp skLeft jr z, GoLeft cp skRight jr z, GoRight cp skDown jr z, GoDown cp skUp jr z, GoUp cp skClear jr z, ExitMenu jr HookWaitKey GoLeft: ld a, (HeaderSelect) dec a or a jr nz, GoLeftOk ld a, 3 GoLeftOk: ld (HeaderSelect), a jr Refresh GoRight ld a, (HeaderSelect) inc a cp 4 jr nz, GoLeftOk xor a inc a GoRightOk: ld (HeaderSelect), a Refresh: call DrawHeader call DrawMenu jr HookWaitKey ExitMenu: ld de, 0 ret ; /////////////////////////// ; // Subclass key press GoUp: ld c, 1 jr GoUpDown GoDown: ld c, 0 GoUpDown: ld a, (HeaderSelect) push af xor a ld (HeaderSelect), a call DrawHeader pop af ld (HeaderSelect), a push af cp 1 jr z, CallCallBackCharAccent cp 2 jr z, CallCallBackCharAccent cp 3 call z, CallBackVars jr GoDownUp CallCallBackCharAccent: call CallBackCharAccent GoDownUp: jr nc, Follow pop af ret Follow: pop af ld (HeaderSelect), a call DrawHeader jr HookWaitKey ; // Subclass key press ; /////////////////////////// ; /////////////////////////// ; // Draw header DrawHeader: ld hl, 0000h ld (CurRow), hl ld b, 16 ld a, ' ' EraseLoop: B_CALL PutC djnz EraseLoop ld hl, 0000h ld (CurRow), hl ld hl, HeaderChar ld b, 1 call ChkInv call PutSApp ld a, (CurCol) inc a ld (CurCol), a ld hl, HeaderAccent inc b call ChkInv call PutSApp ld a, (CurCol) inc a ld (CurCol), a ld hl, HeaderVars inc b call ChkInv call PutSApp res textInverse, (iy + textFlags) ret ChkInv: ld a, (HeaderSelect) cp b jr z, ChkInvTrue res textInverse, (iy + textFlags) ret ChkInvTrue: set textInverse, (iy + textFlags) ret ; // Draw header ; /////////////////////////// HeaderChar: db "Char", 0 HeaderAccent: db "Accent", 0 HeaderVars: db "Vars", 0 ; // Display menu header ; ////////////////////////////////////////// ; ////////////////////////////////////////// ; // Draw sub menus DrawMenu: ld a, (HeaderSelect) cp 1 jr z, DrawMenuChar cp 2 jr z, DrawMenuAccent cp 3 xor a jr z, DrawMenuVars ret ; /////////////////////////// ; // Draw char and accent menus ; /////////////////////////// ; // Draw char map DrawMenuChar: ld hl, CharMap jr DrawMenuCharAccent DrawMenuAccent: ld hl, AccentMap DrawMenuCharAccent: call DrawMap ret DrawMap: ld a, 2 ld (CurRow), a ld bc, 0 ld a, (hl) or a ret z DrawNewLine: xor a ld (CurCol), a push hl ld hl, RowColMap or a push bc ld b, 0 adc hl, bc pop bc ld a, (hl) B_CALL PutC pop hl DrawLineLoop: ld a, (hl) or a jr z, EndLine inc b B_CALL PutMap ld a, (CurCol) cp 15 jr z, NoSpace inc a ld (CurCol), a ld a, ' ' B_CALL PutC NoSpace: inc hl jr DrawLineLoop EndLine: inc hl ld a, (hl) or a jr z, EndDraw ld a, (CurRow) inc a ld (CurRow), a inc c jr DrawNewLine EndDraw: ld a, b cp 8 jr c, ColOk ld b, 8 ColOk: ld hl, 0001h ld (CurRow), hl ld hl, RowColMap DispFirstLineLoop: ld a, ' ' B_CALL PutC ld a, (hl) B_CALL PutC inc hl djnz DispFirstLineLoop ret ; // Draw char map ; /////////////////////////// ; /////////////////////////// ; // Move inside char and accent menu CallBackCharAccent: cp 1 jr nz, caAccent ld hl, CharMap jr caNext caAccent: ld hl, AccentMap caNext: ld de, 0102h ld (CurRow), de ld a, c or a jr z, caStartUp inc c push hl caFindBottomLoop: ld a, (hl) or a jr z, caIfBottom inc hl jr caFindBottomLoop caIfBottom: inc hl ld a, (hl) or a jr z, caBottomFound pop de push hl inc c jr caFindBottomLoop caBottomFound: pop hl ld a, c ld (CurRow), a caStartUp: call caDrawInv caWaitKey: call WaitKey cp skRight jr z, caGoRight cp skLeft jr z, caGoLeft cp skDown jr z, caGoDown cp skUp jr z, caGoUp cp skEnter jr z, caInsertChar cp skClear jr nz, caWaitKey scf ld de, 0 ret caGoRight: call caDrawNormal inc hl ld a, (hl) or a jr nz, caGoRightOk ld a, (CurCol) inc a srl a ld b, a caDecHLLoop: dec hl djnz caDecHLLoop ld a, 1 ld (CurCol), a jr caEndGoRight caGoRightOk: ld a, (CurCol) cp 16 jr nz, caGoRightOk2 ld a, -1 caGoRightOk2: inc a inc a ld (CurCol), a caEndGoRight: ld a, (hl) call caDrawInv jr caWaitKey caGoLeft: call caDrawNormal ld a, (CurCol) cp 1 jr nz, caGoLeftOk ld b, 1 caIncHLLoop: inc hl ld a, (hl) or a jr z, caIncEnd inc b inc b jr caIncHLLoop caIncEnd: dec hl ld a, b ld (CurCol), a jr caEndGoLeft caGoLeftOk: dec hl ld a, (CurCol) dec a dec a ld (CurCol), a caEndGoLeft: ld a, (hl) call caDrawInv jr caWaitKey caGoDown: call caDrawNormal ld c, 0 ld b, 9 caIsEndLoop: inc hl ld a, (hl) or a jr nz, caNotEnd ld a, c or a jr nz, caRet inc c caNotEnd: djnz caIsEndLoop ld a, (CurRow) inc a ld (CurRow), a ld a, (hl) call caDrawInv jr caWaitKey caGoUp: call caDrawNormal ld a, (CurRow) cp 2 jr z, caRet dec a ld (CurRow), a ld b, 9 caDecHLLoop2: dec hl djnz caDecHLLoop2 ld a, (hl) call caDrawInv jr caWaitKey caRet: scf ccf ret caDrawInv: set textInverse, (iy + textFlags) caDrawNormal: set preClrForMode, (IY + newDispF) ld a, (hl) B_CALL PutMap res textInverse, (iy + textFlags) res preClrForMode, (IY + newDispF) ret RowColMap: db Lsub0, Lsub1, Lsub2, Lsub3, Lsub4, Lsub5, Lsub6, Lsub7, Lsub8, Lsub9 CharMap: db Lalpha, Lbeta, Lgamma, LcapDelta, Ldelta, Lepsilon, Llambda, Lmu, 0 db Lrho, LcapSigma, Lsigma, Ltau, Lphi, Lchi, LcapOmega, Langle, 0 db LsqUp, LsqDown, Lintegral, Lcross, LupArrow, LdownArrow, Lroot, LsupX, 0 db Lpound, Lpercent, Lleft, Lconvert, Lsemicolon, LatSign, Lbackslash, Lampersand, 0 db Lunderscore, Lellipsis, LcapS, LquesDown, LexclamDown, Lsub0, Lsub1, Lsub2, 0 db Lsub3, Lsub4, Lsub5, Lsub6, Lsub7, Lsub8, Lsub9, Lten, 0 db 0 AccentMap: db LeAcute, LeGrave, LeCaret, LeDier, LcapEAcute, LcapEGrave, LcapECaret, LcapEDier, 0 db LaAcute, LaGrave, LaCaret, LaDier, LcapAAcute, LcapAGrave, LcapACaret, LcapADier, 0 db LiAcute, LiGrave, LiCaret, LiDier, LcapIAcute, LcapIGrave, LcapICaret, LcapIDier, 0 db LoAcute, LoGrave, LoCaret, LoDier, LcapOAcute, LcapOGrave, LcapOCaret, LcapODier, 0 db LuAcute, LuGrave, LuCaret, LuDier, LcapUAcute, LcapUGrave, LcapUCaret, LcapUDier, 0 db LcapCCed, LcCed, LcapNTilde, LnTilde, Laccent, Lgrave, Ltilde, Ldieresis, 0 db 0 TokenCharMap: db tLalpha, tLbeta, tLgamma, tLcapDelta, tLdelta, tLepsilon, tLlambda, tLmu, 0 db tLrho, tLcapSigma, tLsigma, tLtau, tLphi, tLchi, tLcapOmega, 0DCh, 0 db 0F2h, 0F3h, 0F1h, 0F0h, 0EDh, 0EEh, 0F4h, 0DEh, 0 db 0D2h, 0DAh, 0EBh, 0ECh, 0D6h, 0D1h, 0D7h, 0D4h, 0 db 0D9h, 0DBh, 0D3h, 09Dh, 09Eh, 0E0h, 0E1h, 0E2h, 0 db 0E3h, 0E4h, 0E5h, 0E6h, 0E7h, 0E8h, 0E9h, 0EAh, 0 db 0 TokenAccentMap: db tLeAcute, tLeGrave, tLeCaret, tLeDier, tLcapEAcute, tLcapEGrave, tLcapECaret, tLcapEDier, 0 db tLaAcute, tLaGrave, tLaCaret, tLaDier, tLcapAAcute, tLcapAGrave, tLcapACaret, tLcapADier, 0 db tLiAcute, tLiGrave, tLiCaret, tLiDier, tLcapIAcute, tLcapIGrave, tLcapICaret, tLcapIDier, 0 db tLoAcute, tLoGrave, tLoCaret, tLoDier, tLcapOAcute, tLcapOGrave, tLcapOCaret, tLcapODier, 0 db tLuAcute, tLuGrave, tLuCaret, tLuDier, tLcapUAcute, tLcapUGrave, tLcapUCaret, tLcapUDier, 0 db tLcapCCed, tLcCed, tLcapNTilde, tLnTilde, tLaccent, tLgrave, 0CFh, 09Ch, 0 db 0 ; // Move inside char and accent menu ; /////////////////////////// ; // Draw char and accent menu ; /////////////////////////// caInsertChar: ld a, (HeaderSelect) cp 1 jr z, caciCharMap cp 2 jr z, caciAccentMap scf ret caciCharMap: ld de, TokenCharMap push de ld de, CharMap jr caciNext caciAccentMap: ld de, TokenAccentMap push de ld de, AccentMap caciNext: scf ccf sbc hl, de ex de, hl pop hl adc hl, de ld e, (hl) ld d, t2ByteTok scf ret VarsType: db " Strings", Lellipsis, " ", 0 db " Pictures", Lellipsis, " ", 0 db " Matrices", Lellipsis, " ", 0 db " GDBs", Lellipsis, " ", 0 db " Y-Vars", Lellipsis, " ", 0 db " Lists", Lellipsis, " ", 0 db " ", 0 VarsTypeToken: db tVarStrng, tVarPict, tVarMat, tVarGDB, tVarEqu, tVarLst DrawMenuVars: push af ld hl, 0001h ld (CurRow), hl ld a, (VarsSelect) cp 0FFh jr nz, VarsTypeSelected ld hl, VarsType ld b, 7 DispMenuVarsLoop: call PutSApp djnz DispMenuVarsLoop ld a, ' ' B_CALL PutMap ret VarsTypeSelected: push af ld hl, 0001h ld (CurRow), hl ld hl, VarsType ld de, 17 ld a, (VarsSelect) or a jr z, FirstTitle ld b, a SearchTitleLoop: add hl, de djnz SearchTitleLoop FirstTitle: call PutSApp ld b, 6*16-1 ld a, ' ' EraseLoopP: B_CALL PutC djnz EraseLoopP B_CALL PutMap pop af cp 0cch jr z, NoPop pop af NoPop: or a jr z, NoInverse set textInverse, (iy + textFlags) set preClrForMode, (IY + newDispF) NoInverse: ld hl, 0702h ld (CurRow), hl ld a, LsqUp B_CALL PutMap ld hl, 0503h ld (CurRow), hl ld a, Lleft B_CALL PutMap ld a, 9 ld (CurCol), a ld a, Lconvert B_CALL PutMap ld hl, 0704h ld (CurRow), hl ld a, LsqDown B_CALL PutMap res textInverse, (iy + textFlags) res preClrForMode, (IY + newDispF) ret CallBackVars: ld a, (VarsSelect) cp 0FFh jr nz, cvVarsTypeSelected ld a, c or a jr nz, cvFromDown ld hl, 0001h jr cvFromUp cvFromDown: ld hl, 0006h cvFromUp: ld (CurRow), hl call cvDraw cvWaitKey: call WaitKey cp skDown jr z, cvGoDown cp skUp jr z, cvGoUp cp skEnter jr z, cvGoEnter cp skClear jr nz, cvWaitKey ld de, 0 scf ret cvGoDown: call cvErase ld a, (CurRow) inc a cp 7 jr z, cvQuit ld (CurRow), a call cvDraw jr cvWaitKey cvGoUp: call cvErase ld a, (CurRow) dec a or a jr z, cvQuit ld (CurRow), a call cvDraw jr cvWaitKey cvQuit: scf ccf ret cvGoEnter: ld a, (CurRow) dec a ld (VarsSelect), a cvVarsTypeSelected: ld a, 0cch call VarsTypeSelected ld a, (VarsSelect) ld e, a ld d, 0 ld hl, VarsTypeToken add hl, de ld d, (hl) ld e, 0 call cvDispNum cvWaitKey2: call WaitKey cp skClear jr z, cvLevelUp cp skLeft jr z, cvSub1 cp skRight jr z, cvAdd1 cp skDown jr z, cvSub10 cp skUp jr z, cvAdd10 cp skEnter jr z, cvEnter ld b, 0 cp sk1 jr z, cvMul1 cp sk2 jr z, cvMul2 cp sk3 jr z, cvMul3 cp sk4 jr z, cvMul4 cp sk5 jr z, cvMul5 cp sk6 jr z, cvMul6 cp sk7 jr z, cvMul7 cp sk8 jr z, cvMul8 cp sk9 jr z, cvMul9 cp sk0 jr z, cvMul0 cp skDel jr z, cvDel jr cvWaitKey2 cvLevelUp: ld a, 0FFh ld (VarsSelect), a xor a call DrawMenuVars ld c, 0 jr CallBackVars cvSub1: dec e call cvDispNum jr cvWaitKey2 cvAdd1: inc e call cvDispNum jr cvWaitKey2 cvSub10: ld a, e sub a, 10 ld e, a call cvDispNum jr cvWaitKey2 cvAdd10: ld a, e add a, 10 ld e, a call cvDispNum jr cvWaitKey2 cvEnter: scf ret cvMul9: inc b cvMul8: inc b cvMul7: inc b cvMul6: inc b cvMul5: inc b cvMul4: inc b cvMul3: inc b cvMul2: inc b cvMul1: inc b cvMul0: push de push bc ld h, 10 call H_Times_E pop bc ld d, 0 ld e, b add hl, de pop de ld e, l call cvDispNum jr cvWaitKey2 cvDel: push de push de pop hl ld h, 0 B_CALL DivHLBy10 pop de ld e, l call cvDispNum jr cvWaitKey2 H_Times_E: ld d, 0 ld l, d ld b, 8 __loop: add hl, hl jr nc, __skip add hl, de __skip: djnz __loop ret cvErase: ld a, ' ' B_CALL PutMap ret cvDraw: ld a, Lconvert B_CALL PutMap ret cvDispNum: push de ld hl, 0903h ld (CurRow), hl ld h, 0 ld l, e ld a, e or a jr nz, cvDispNumLoop ld hl, 0803h ld (CurRow), hl ld a, '0' B_CALL PutMap jr cvRet cvDispNumLoop: ld a, l or a jr z, cvRet B_CALL DivHLBy10 push hl ld hl, cvNumMap ld d, 0 ld e, a add hl, de ld a, (CurCol) dec a ld (CurCol), a ld a, (hl) pop hl B_CALL PutMap jr cvDispNumLoop cvRet: ld a, (CurCol) sub a, 6 or a jr z, cvRet2 ld b, a cvEraseLoop: ld a, (CurCol) dec a ld (CurCol), a ld a, ' ' B_CALL PutMap djnz cvEraseLoop cvRet2: pop de ld hl, 0406h ld (CurRow), hl ld hl, cvEraseStrng call PutSApp ld hl, 0406h ld (CurRow), hl push de B_CALL PutTokString pop de ret cvNumMap: db "0123456789" cvEraseStrng: db " ", 0