;Logging routines include "settings.inc" include "ti83plus.inc" include "equates.inc" SEGMENT Main GLOBALS ON EXTERN StartApp,PutSApp,IsInstalled,notInstalled,DispHexA,ExitApp currentPage equ 0FFFDh currentAddress equ 0FFFEh Var logPage,1 Var logAddr,2 startLog: ;Are we installed? call IsInstalled jr c,notInstalled ;Clear RAM pages 84h-87h di ld hl,8000h ld (currentAddress),hl ld a,84h ld (currentPage),a res 7,a out (5),a ld a,85h out (7),a ld hl,8000h ld (hl),0 ld de,8001h ld bc,8000h-1 ldir ld a,87h out (7),a ld a,06h out (5),a ld hl,8000h ld (hl),0 ld de,8001h ld bc,8000h-1 ldir ld a,81h out (7),a xor a out (5),a in a,(6) ld hl,ioLinkHook ld (9BD8h),hl ld (9BD8h+2),a set 1,(iy+3Ah) B_CALL ClrLCDFull B_CALL HomeUp ld hl,sLoggingStarted call PutSApp B_CALL GetKey jr StartApp stopLog: res 1,(iy+3Ah) B_CALL ClrLCDFull B_CALL HomeUp ld hl,sLoggingStopped call PutSApp B_CALL GetKey jr StartApp sLoggingStarted: DB "Logging started." DB "Press any key",0CEh,0 sLoggingStopped: DB "Logging stopped." DB "Press any key",0CEh,0 sSent: DB "Sent:",0 sReceived: DB "Received:",0 ioLinkHook: add a,e push bc push de push af push hl ld (83EBh),a ld a,b dec a ;B=1 ld c,1 jr z,continueLinkHook dec a ;B=2 jr z,endLinkHook ;don't care dec a ;B=3 jr z,endLinkHook ;don't care dec a ;B=4 jr z,endLinkHook ;don't care dec a ;B=5 jr z,endLinkHook ;don't care ld c,2 continueLinkHook: ;C=1: sending byte ;C=2: receiving byte ;A = byte ld hl,(currentAddress) ld b,a ld a,(currentPage) cp 88h jr z,endLinkHook ;no more space to log with ld a,i jp pe,$F ld a,i $$: di push af ld a,(83EBh) ld b,a ld a,(currentPage) out (7),a ld (hl),c inc hl ld (hl),b ld a,81h out (7),a inc hl bit 6,h jr z,$F res 6,h ld a,(currentPage) inc a ld (currentPage),a $$: ld (currentAddress),hl pop af jp po,endLinkHook ei endLinkHook: pop hl pop af pop de pop bc cp a ret viewLog: ld hl,8000h ld (logAddr),hl ld a,84h ld (logPage),a DisplayLog: B_CALL ClrLCDFull DisplayLogNoClear: B_CALL HomeUp ld hl,(logAddr) ld a,(logPage) push hl push af xor a DisplayLogLoop: push af ld (curRow),a xor a ld (curCol),a call GetLogWord push bc ld a,c or a jr nz,$F pop bc B_CALL EraseEOL jr skipLogDisplay $$: dec a ld hl,sSent jr z,$F ld hl,sReceived $$: call PutSApp ld a,14 ld (curCol),a pop bc ld a,b call DispHexA skipLogDisplay: pop af inc a cp 8 jr c,DisplayLogLoop pop af pop hl ld (logPage),a ld (logAddr),hl logKeyLoop: B_CALL GetKey cp kUp jr z,moveUp cp kDown jr z,moveDown cp kSub jr z,scrollUp cp kAdd jr z,scrollDown cp kQuit jr z,ExitApp cp kClear jr nz,logKeyLoop jr StartApp scrollUp: ld b,7 $$: push bc call CanDoMoveUp pop bc jr c,$F call DecPtr djnz $B $$: jr DisplayLog moveUp: call CanDoMoveUp jr c,logKeyLoop B_CALL scrollDown B_CALL RunIndicOff call DecPtr jr DisplayLogNoClear DecPtr: ld hl,(logAddr) dec hl dec hl bit 7,h jr nz,$F set 7,h ld a,(logPage) dec a ld (logPage),a $$: ld (logAddr),hl ret CanDoMoveUp: ld a,(logPage) cp 84h jr nz,$F ld de,8000h ld hl,(logAddr) B_CALL CpHLDE scf ret z or a ret scrollDown: ld b,7 $$: push bc call CanDoMoveDown pop bc jr c,$F push bc call GetLogWord pop bc djnz $B $$: jr DisplayLog moveDown: call CanDoMoveDown jr c,logKeyLoop B_CALL scrollUp B_CALL RunIndicOff call GetLogWord jr DisplayLogNoClear CanDoMoveDown: ld hl,(logAddr) ld a,(logPage) cp 87h jr nz,$F ld de,0BFFEh B_CALL CpHLDE scf ret z $$: push af push hl call GetLogWord call GetLogWord pop hl pop af ld (logAddr),hl ld (logPage),a ld a,c or a scf ret z or a ret GetLogWord: di ld hl,(logAddr) ld a,(logPage) out (7),a ld c,(hl) inc hl ld b,(hl) inc hl ld a,81h out (7),a bit 6,h jr z,$F res 6,h ld a,(logPage) inc a ld (logPage),a $$: ld (logAddr),hl ret