;Utility routines include "settings.inc" include "ti83plus.inc" include "equates.inc" SEGMENT Main GLOBALS ON DispHexHLB: ld a,(hl) call DispHexA inc hl djnz DispHexHLB 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 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 SoftKey: push hl ld bc,7 ld de,95*256+7 ld h,1 B_CALL ILine ld b,19 ld d,b ld e,0 B_CALL ILine ld b,38 ld d,b B_CALL ILine ld b,57 ld d,b B_CALL ILine ld b,76 ld d,b B_CALL ILine ld b,0 ld d,b B_CALL ILine ld b,95 ld d,b B_CALL ILine pop hl ld a,57 ld (penRow),a ld a,3 SoftKeyLoop: ld (penCol),a push af call vputstring pop af add a,19 cp 98 jr nz,SoftKeyLoop ret IPutS11: push hl ld b,11 $$: ld a,(hl) B_CALL PutC inc hl djnz $B pop hl ret ;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 GetKeyRetOff pop hl pop de pop bc pop ix ret IPutSUnicode: ;Display a unicode string descriptor ld b,(hl) inc hl inc hl dec b dec b $$: ld a,(hl) or a call nz,IPutC inc hl djnz $b ret PutSApp: 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 INewLine: push af ld a,(curRow) inc a ld (curRow),a xor a ld (curCol),a pop af ret PutHexA: push de push ix push af push bc push af rrca rrca rrca rrca call putha pop af call putha pop bc pop af pop ix pop de ret putha: and 15 cp 10 jr nc,putdhlet add a,48 jr putdh putdhlet: add a,55 putdh: ld (hl),a inc hl ret DispHexA: push de 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 pop de ret dispha: and 15 cp 10 jr nc,dhlet add a,48 jr dispdh dhlet: add a,55 dispdh: call IPutC ret VDispHexA: push de push ix push af push hl push bc push af rrca rrca rrca rrca call vdispha pop af call vdispha pop bc pop hl pop af pop ix pop de ret vdispha: and 15 cp 10 jr nc,vdhlet add a,48 jp vdispdh vdhlet: add a,55 vdispdh: call IVPutMap ret IVPutMap: push ix push de push hl push af push bc B_CALL VPutMap pop bc pop af pop hl pop de pop ix 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 Traverse_symTable: ld hl,symTable inc a ld c,a tstBegin: push bc push hl ld bc,(pTemp) or a sbc hl,bc pop hl pop bc ret c jr nz,$F scf ret $$:ld a,(hl) and 1Fh ld b,a ld de,6 sbc hl,de ld e,3 cp AppVarObj jr z,tstMove1 cp ProgObj jr z,tstMove1 cp ProtProgObj jr z,tstMove1 cp TempProgObj jr z,tstMove1 cp 17h jr z,tstMove1 dec hl ld a,(hl) inc hl cp tVarLst jr nz,tstMove2 tstMove1: ld e,(hl) dec hl tstMove2: ld a,b ld b,e ld de,OP1 ld (de),a inc de tstCopy: ld a,(hl) ld (de),a inc de dec hl djnz tstCopy xor a ld (de),a ld a,(OP1) cp 17h jr z,$F cp ProgObj jr z,$F cp ProtProgObj jr z,$F cp AppVarObj jr z,$F or a jr z,tstReal jr tstContinue tstReal: ld a,(OP1+1) cp 5Ch jp p,tstBegin jr tstContinue $$:ld a,(OP1+1) cp 30h jp m,tstBegin tstContinue: ld a,(OP1) push hl call filterTypes pop hl jr c,tstBegin dec c jr nz,tstBegin ld hl,OP1 ld de,OP2 ld bc,11 ldir ret filterTypes: ld a,(OP1) ld b,a ld hl,bTypeTable filterTypesLoop: ld a,(hl) cp b ret z cp 0FFh jr z,$F inc hl jr filterTypesLoop $$:scf ret bTypeTable: DB 0,1,2,3,4,5,6,7,8,0Ch,0Dh,15h,0FFh 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