;Utility routines include "settings.inc" include "ti83plus.inc" include "equates.inc" SEGMENT Main GLOBALS ON unlockFlash: B_CALL GetBaseVer cp 2 jr c,oldUnlock cp 3 jp p,newUnlock ld a,b cp 40 jr c,oldUnlock newUnlock: ld a,1 ld (appInfo+2),a rst 28h DW 50CBh ret oldUnlock: ld hl,oldUnlockCode ld de,appBackUpScreen ld bc,oldUnlockCodeEnd-oldUnlockCode ldir jp appBackUpScreen oldUnlockCode: in a,(6) push af ld a,7Bh call translatePage-oldUnlockCode+appBackUpScreen out (6),a ld hl,50CBh ld e,(hl) inc hl ld d,(hl) inc hl ld a,(hl) call translatePage-oldUnlockCode+appBackUpScreen out (6),a ex de,hl ld a,1 ld (appInfo+2),a ld a,0F5h ld bc,0FFFFh cpir dec hl ld de,returnPoint-oldUnlockCode+appBackUpScreen push de jp (hl) returnPoint: pop af out (6),a ret translatePage: ld b,a in a,(2) and 80h jr z,_old in a,(21h) and 3 ld a,b ret nz and 3Fh ret _old: ld a,b and 1Fh ret oldUnlockCodeEnd: ConvOP1: ;Gets a number out of OP1 ;Returns C if the number was too large ld b,5 ld de,0 ConvOP1_Loop: push bc xor a ld hl,OP1+4 rld dec hl rld dec hl rld ex de,hl add hl,hl push hl add hl,hl add hl,hl jr c,ConvOP1_Return2 pop bc add hl,bc jr c,ConvOP1_Return ;HL is times 10 ld b,0 ld c,a add hl,bc ex de,hl dec hl pop bc dec (hl) ret p djnz ConvOP1_Loop scf ret ConvOP1_Return2: pop bc ConvOP1_Return: pop bc ret IPutS8Max: ld b,8 $$: ld a,(hl) or a jr z,$F B_CALL PutC inc hl djnz $B ld a,' ' B_CALL PutC ret $$: ld a,' ' B_CALL PutC djnz $B ld a,' ' B_CALL PutC ret grayScreen: ld hl,savesscreen B_CALL SaveDisp ld hl,savesscreen ld d,01010101b ld c,64 grayScreenLoop: ld b,12 $$: ld a,d and (hl) ld (hl),a inc hl djnz $B ld a,d rrca ld d,a dec c jr nz,grayScreenLoop ld hl,savesscreen ld b,64 B_CALL RestoreDisp ret SoftKey: push hl ld bc,51*256+7 ld de,51*256+57 ; B_CALL DarkLine ld bc,7 ld de,95*256+7 B_CALL DarkLine ld bc,19*256+7 ld de,19*256 B_CALL DarkLine ld bc,38*256+7 ld de,38*256 B_CALL DarkLine ld bc,57*256+7 ld de,57*256 B_CALL DarkLine ld bc,76*256+7 ld de,76*256 B_CALL DarkLine ld hl,57*256+2 ld (pencol),hl pop hl ld b,5 $$: ld a,(pencol) ld c,a push bc call vputstring pop bc ld a,c add a,19 ld (pencol),a djnz $B ret DispHexArray: ld hl,2 ld (curRow),hl ld b,14 ld hl,header $$: ld a,(hl) call DispHexA inc hl djnz $B ret ;myDispHexA: ; push ix ; push af ; push hl ; push bc ; push af ; rrca ; rrca ; rrca ; rrca ; call mydispha ; pop af ; call mydispha ; pop bc ; pop hl ; pop af ; pop ix ; ret ;mydispha: ; and 15 ; cp 10 ; jp nc,mydhlet ; add a,48 ; jp mydispdh ;mydhlet: ; add a,55 ;mydispdh: ; call myPutC ; ret VPutSAppCenter: push hl call SStringLen pop hl ld a,95 sub c srl a ld (penCol),a VPutSApp: ld a,(hl) inc hl or a ret z B_CALL VPutMap jr VPutSApp PutSApp: ld a,(hl) inc hl or a ret z B_CALL PutMap ld a,(curCol) inc a ld (curCol),a cp 16 jr nz,PutSApp xor a ld (curCol),a ld a,(curRow) cp 7 jr z,PutSApp inc a ld (curRow),a jr PutSApp SStringLen: ld c,0 $$: ld a,(hl) inc hl or a ret z push hl ld h,0 ld l,a add hl,hl add hl,hl add hl,hl B_CALL SFont_Len ld a,b pop hl add a,c ld c,a jr $B IPutS11: push hl push bc ld bc,0 ld (curRow),bc ld b,8 $$: ld a,(hl) or a jr z,$F inc hl B_CALL PutC djnz $B $$: pop bc pop hl ret myLoadCIndPaged: B_CALL LoadCIndPaged inc_BHL: inc hl inc_BHL_1: bit 7,h ret z inc b res 7,h set 6,h ret myLoadDEIndPaged: B_CALL LoadDEIndPaged jr inc_BHL BHL_plus_DE: add hl,de jr inc_BHL_1 ;Draws horizontal dotted line ;Input: bc = (x,y) coordinate of first point (lower left corner is (0,0)) ; e = column to stop at ;Output: line drawn FunkyLine: ld d,1 FunkyLine_Loop: B_CALL IPoint inc b inc b ld a,b cp e jp m,FunkyLine_Loop ret vputstring: ld a,(hl) inc hl or a ret z B_CALL VPutMap jr vputstring DispA: push hl ld c,-1 DispA_loop: inc c sub 10 jr nc,DispA_loop add a,10 push af ld a,c add a,'0' B_CALL VPutMap pop af add a,'0' B_CALL VPutMap pop hl ret IGetKey: push ix push bc push de push hl res onInterrupt,(iy+onFlags) B_CALL GetKey pop hl pop de pop bc pop ix ret IPutS: ld a,(hl) inc hl or a ret z call IPutC jr IPutS IPutC: push hl ;don't think these are necessary push bc B_CALL PutC pop bc pop hl ret Var TempNum,2 GetHexA: ;lets user input an 8 bit number in hexadecimal ;prompt is at currow,curcol ;number is returned in a set curAble,(iy+curFlags) ld b,2 ld hl,TempNum getnumhloop: call IGetKey cp 2 jp nz,gnhnotback ld a,b cp 2 jp z,gnhnotback ld a,' ' B_CALL PutMap ld hl,curCol dec (hl) jp GetHexA gnhnotback: sub 142 cp 10 jp c,gnhnumpressed sub 12 cp 6 jp c,gnhletpressed jp getnumhloop gnhnumpressed: ld (hl),a inc hl add a,48 call IPutC djnz getnumhloop jp gnhdone gnhletpressed: add a,10 ld (hl),a inc hl add a,55 call IPutC djnz getnumhloop gnhdone: dec hl ld b,(hl) dec hl ld a,(hl) rlca rlca rlca rlca or b res curAble,(iy+curFlags) ret DispHexHL: push af push bc push de push hl push ix ld a,h call DispHexA ld a,l call DispHexA pop ix pop hl pop de pop bc pop af ret DispHexA: push ix push af push hl push bc push af rrca rrca rrca rrca call dispha pop af call dispha pop bc pop hl pop af pop ix ret dispha: and 15 cp 10 jp nc,dhlet add a,48 jp dispdh dhlet: add a,55 dispdh: call IPutC ret ;DialogBox ; Input ; (H,L) = (y,x) upper left ; (D,E) = (y,x) lower right ;H and l must be >= 1 ;D must be <= 62 ;E must be <= 93 ;Text inside the box must be displayed manually DialogBox: push hl push de dec h dec l inc d inc d inc e inc e B_CALL EraseRectBorder pop de pop hl push hl push de B_CALL DrawRectBorderClear pop de pop hl push hl push de inc d inc e B_CALL DrawRectBorder pop de pop hl ld a,h xor 63 ;Adjust for funny IPoint coordinates ld h,a ld a,d xor 63 ld b,l ld c,h ld d,0 B_CALL IPoint ;(b,c) = (x,y xor 63) - upper left ld b,e B_CALL IPoint inc b B_CALL IPoint dec c B_CALL IPoint ld c,a dec c B_CALL IPoint ld b,l B_CALL IPoint inc b B_CALL IPoint dec b inc c B_CALL IPoint ret VStrLen: ld b,0 VStrLen_Loop: ld a,(hl) or a ret z push hl ld h,0 ld l,a add hl,hl add hl,hl add hl,hl push bc B_CALL SFont_Len ld a,b pop bc pop hl inc hl add a,b ld b,a jr VStrLen_Loop fastCopy: di ld hl,plotsscreen ld b,64 ld a,07h out (10h),a ld a,80h-1 layerloop1: push bc ld b,0Ch inc a ld (OP1),a call lcddelay out (10h),a call lcddelay ld a,20h out (10h),a layerloop2: ld a,(hl) call lcddelay out (11h),a inc hl djnz layerloop2 pop bc ld a,(OP1) djnz layerloop1 ld a,5 call lcddelay out (10h),a ei ret lcddelay: push af lcddelayloop: in a,(2) and 2 jr z,lcddelayloop pop af ret fixVarNames: ;Converts TI-OS style variable name in OP1 to ASCIIZ ld a,(OP1) cp 01h ;list jr z,fixList cp 0Dh jr z,fixList cp 02h ;matrix jr z,fixMatrix cp 03h ;equation jr z,fixEquation cp 04h jr z,fixString cp 07h jr z,fixPicture cp 08h jr z,fixGDB ret fixList: ld a,(OP1+2) cp 10 jp p,fixNamedList add a,31h ld (OP1+2),a ld a,'L' ld (OP1+1),a ret fixNamedList: ld a,LlistL ld (OP1+1),a ret fixMatrix: ld a,(OP1+2) inc a ld hl,sMatrixTable-4 ld de,4 ld b,a f_m_1: add hl,de djnz f_m_1 ld de,OP1+1 ld bc,4 ldir ret sMatrixTable: DB 0C1h,"A",5Dh,0 DB 0C1h,"B",5Dh,0 DB 0C1h,"C",5Dh,0 DB 0C1h,"D",5Dh,0 DB 0C1h,"E",5Dh,0 DB 0C1h,"F",5Dh,0 DB 0C1h,"G",5Dh,0 DB 0C1h,"H",5Dh,0 DB 0C1h,"I",5Dh,0 DB 0C1h,"J",5Dh,0 fixPicture: ld a,(OP1+2) inc a ld hl,sPictureTable-5 ld de,5 ld b,a f_p_1: add hl,de djnz f_p_1 ld de,OP1+1 ld bc,5 ldir ret sPictureTable: DB "Pic1",0 DB "Pic2",0 DB "Pic3",0 DB "Pic4",0 DB "Pic5",0 DB "Pic6",0 DB "Pic7",0 DB "Pic8",0 DB "Pic9",0 DB "Pic0",0 fixGDB: ld a,(OP1+2) inc a ld hl,sGDBTable-5 ld de,5 ld b,a f_gdb_1: add hl,de djnz f_gdb_1 ld de,OP1+1 ld bc,5 ldir ret sGDBTable: DB "GDB1",0 DB "GDB2",0 DB "GDB3",0 DB "GDB4",0 DB "GDB5",0 DB "GDB6",0 DB "GDB7",0 DB "GDB8",0 DB "GDB9",0 DB "GDB0",0 fixEquation: ld a,(OP1+2) cp 7Fh jp p,fixEquation_s cp 3Fh jp p,fixEquation_r cp 1Fh jp p,fixEquation_l sub 10h ld hl,sEquTableY-3 inc a ld b,a ld de,3 fe_y_1: add hl,de djnz fe_y_1 ld de,OP1+1 ld bc,3 ldir ret sEquTableY: DB "Y",81h,0 DB "Y",82h,0 DB "Y",83h,0 DB "Y",84h,0 DB "Y",85h,0 DB "Y",86h,0 DB "Y",87h,0 DB "Y",88h,0 DB "Y",89h,0 DB "Y",80h,0 fixEquation_l: ld hl,sEquTableL-4 sub 20h inc a ld b,a ld de,4 fe_l_1: add hl,de djnz fe_l_1 ld de,OP1+1 ld bc,4 ldir ret sEquTableL: DB "X",81h,0Dh,0 DB "Y",81h,0Dh,0 DB "X",82h,0Dh,0 DB "Y",82h,0Dh,0 DB "X",83h,0Dh,0 DB "Y",83h,0Dh,0 DB "X",84h,0Dh,0 DB "Y",84h,0Dh,0 DB "X",85h,0Dh,0 DB "Y",85h,0Dh,0 DB "X",86h,0Dh,0 DB "Y",86h,0Dh,0 fixEquation_s: sub 80h add a,75h ld (OP1+1),a xor a ld (OP1+2),a ret fixEquation_r: ld hl,sEquTable-3 ld a,(OP1+2) sub 40h inc a ld b,a ld de,3 fe_r_1: add hl,de djnz fe_r_1 ld de,OP1+1 ld bc,3 ldir ret sEquTable: DB "r1",0 DB "r2",0 DB "r3",0 DB "r4",0 DB "r5",0 DB "r6",0 fixString: ld hl,sStrTable-5 ld a,(OP1+2) inc a ld b,a ld de,5 fs_1: add hl,de djnz fs_1 ld de,OP1+1 ld bc,5 ldir ret sStrTable: DB "Str1",0 DB "Str2",0 DB "Str3",0 DB "Str4",0 DB "Str5",0 DB "Str6",0 DB "Str7",0 DB "Str8",0 DB "Str9",0 DB "Str0",0 VEraseEOL: ld a,' ' B_CALL VPutMap ld a,(pencol) cp c jp m,VEraseEOL ret cmpstr: ld a,(de) cp (hl) ret nz or a ret z inc de inc hl jr cmpstr cmpstrb: ld a,(de) cp (hl) ret nz inc de inc hl djnz cmpstrb xor a ret putsb: push bc push hl $$: ld a,(hl) B_CALL PutC inc hl djnz $B pop hl pop bc ret