;Utility routines ;This is full of all kinds of unnecessary crap include "settings.inc" include "ti83plus.inc" include "equates.inc" SEGMENT Main GLOBALS ON myLoadDEIndPaged: call myLoadCIndPaged ld e,c call myLoadCIndPaged ld d,c ret myLoadCIndPaged: B_CALL LoadCIndPaged inc_BHL: inc hl jr $F BHL_plus_DE: add hl,de $$: ld a,b or a ret z bit 7,h ret z res 7,h set 6,h inc b ret 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 vputstring: ld a,(hl) inc hl or a ret z B_CALL VPutMap jr vputstring WaitTimer100ms: ;Waits 100ms call WaitTimer20ms call WaitTimer20ms call WaitTimer20ms WaitTimer40ms: ;Waits 40ms call WaitTimer20ms WaitTimer20ms: ;Waits 20ms ld b,2 WaitTimerBms: ;Waits B*10 milliseconds ld a,42h out (36h),a xor a out (37h),a ld a,b out (38h),a $$: in a,(4) bit 7,a jr z,$B ret INewLine: push hl ld hl,(curRow) inc l ld h,0 ld (curRow),hl pop hl 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 PutSApp: ld a,(hl) inc hl or a ret z B_CALL PutC jr PutSApp 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 ;TODO: replace this with something that doesn't use interrupts, if it does B_CALL PutC pop bc pop hl ret Var TempNum,2 GetHexA_StartKeyCodeA: set curAble,(iy+curFlags) ld b,2 ld hl,TempNum jr $F 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: set 7,(iy+28h) 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 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