;Remote Viewer code include "settings.inc" include "ti83plus.inc" include "equates.inc" SEGMENT Main GLOBALS ON EXTERN StartApp,PutSApp,DispHexA,DispHexHL,IGetKey,SoftKey,varNameOffset,ExitApp,grayScreen,machineID,curVarOffset,curAppOffset,IPutS8Max EXTERN clearAllScreens EXTERN curChoice,IPutS,curScreenChoice,maxChoice,fixVarNames,curVarAdder,curVarEnd,tempByte RemoteView: ld hl,0 ld (varNameOffset),hl ld (maxChoice),hl ld (curChoice),hl ld de,9 ld (curVarAdder),de xor a ld (curScreenChoice),a ld hl,varNameTable ld bc,1080 ;120*9 B_CALL MemClear ld hl,appNameTable ld bc,752 ;94*8 B_CALL MemClear call grayScreen ld hl,0403h ld (curRow),hl ld hl,sCaching call PutSApp ;cache names to varNameTable and appNameTable ld hl,sRemoteLinkError call APP_PUSH_ERRORH xor a ld (machineID),a ld a,68h ld (header+1),a call Send4BytesR call Get4Bytes ld a,(header) ld (machineID),a ld hl,baseAppBrTab2 ld (hl),0 inc hl ld (hl),0 inc hl ld (hl),19h ld de,9 add hl,de ld (hl),0 inc hl ld (hl),0 ld a,0A2h ld hl,baseAppBrTab2 ld bc,13 call SendPacket ld hl,OP2 call GetDataPacket ld hl,varNameTable ld (varNameOffset),hl ld hl,appNameTable ld (curAppOffset),hl $$: call Get4Bytes ld a,(header+1) cp 92h jr z,$F ld hl,baseAppBrTab2 call GetDataPacketRest ld a,(baseAppBrTab2+2) cp 24h jr z,receivingFlashAppHeader ld hl,baseAppBrTab2+2 rst 20h xor a ld (OP1+9),a call fixVarNames ld hl,OP1 ld de,baseAppBrTab+2 ld bc,9 ldir ld de,(varNameOffset) ld a,(baseAppBrTab2+2) ld (de),a inc de ld hl,baseAppBrTab2+3 ld bc,8 ldir ld (varNameOffset),de ld (curVarEnd),de ld hl,(maxChoice) inc hl ld (maxChoice),hl jr $B receivingFlashAppHeader: ld de,(curAppOffset) ld hl,baseAppBrTab2+3 ld bc,8 ldir ld (curAppOffset),de ld hl,(maxChoice) inc hl ld (maxChoice),hl jr $B $$: call SendAck call APP_POP_ERRORH ld hl,(maxChoice) ld a,h or l jr nz,$F ld hl,0103h ld (curRow),hl ld hl,sNoVarsFound call IPutS call IGetKey jr StartApp sNoVarsFound: DB "No Vars Found!",0 $$: B_CALL ClrLCDFull B_CALL HomeUp ld hl,sRAMFree call PutSApp ld hl,(OP2) B_CALL disphl ld hl,remoteMenuTable call SoftKey ld hl,varNameTable+1 ld (curVarOffset),hl displayNames: ld hl,0001h ld (curRow),hl ld hl,(curVarOffset) push hl ld de,(curVarAdder) push de ld hl,(curVarOffset) ld c,0 displayNamesLoop: push bc push hl ld a,(curScreenChoice) cp c jr nz,$F set textInverse,(iy+textFlags) $$: ld a,' ' B_CALL PutC ld a,(hl) or a jr nz,$F pop hl ld hl,appNameTable ld (curVarOffset),hl ld de,8 ld (curVarAdder),de push hl $$: call IPutS8Max pop hl push hl ld a,(curRow) push af bit 4,h jr z,$F ld hl,sAPP jr displayType $$: dec hl ld b,(hl) inc b ld hl,typeTable-6 ld de,6 $$: add hl,de djnz $B displayType: call IPutS ld a,' ' B_CALL PutC res textInverse,(iy+textFlags) pop af inc a ld (curRow),a xor a ld (curCol),a pop hl pop bc ld de,(curVarAdder) add hl,de inc c ld a,c cp 6 jr nz,displayNamesLoop pop de ld (curVarAdder),de pop hl ld (curVarOffset),hl RemoteViewKeyLoop: call IGetKey cp kGraph jr z,StartApp cp kClear jr z,StartApp cp kQuit jr z,ExitApp cp kDown jr z,remoteDown cp kUp jr z,remoteUp jr RemoteViewKeyLoop remoteDown: ld a,(curScreenChoice) inc a cp 6 jr z,remoteDownScroll ld (curScreenChoice),a ld hl,(curChoice) inc hl ld (curChoice),hl jr displayNames remoteDownScroll: ld hl,(curChoice) inc hl ld de,(maxChoice) B_CALL cphlde jr z,RemoteViewKeyLoop ld (curChoice),hl ld hl,(curVarOffset) ld de,(curVarAdder) add hl,de inc hl ld a,(hl) dec hl or a jr nz,$F ld hl,appNameTable ld (curVarOffset),hl ld de,8 ld (curVarAdder),de $$: ld (curVarOffset),hl jr displayNames remoteUp: ld a,(curScreenChoice) or a jr z,remoteUpScroll dec a ld (curScreenChoice),a ld hl,(curChoice) dec hl ld (curChoice),hl jr displayNames remoteUpScroll: ld hl,(curChoice) ld a,h or l jr z,RemoteViewKeyLoop dec hl ld (curChoice),hl ld hl,(curVarOffset) ld de,appNameTable B_CALL cphlde jr nz,$F ld de,9 ld (curVarAdder),de ld hl,(curVarEnd) inc hl ld (curVarOffset),hl $$: ld de,(curVarAdder) ld hl,0FFFFh or a sbc hl,de inc hl ex de,hl ld hl,(curVarOffset) add hl,de ld (curVarOffset),hl jr displayNames remoteMenuTable: DB " Add",0 DB 0 DB " Del",0 DB 0 DB " Back",0 sCaching: DB "Caching",0CEh,0 sRAMFree: DB "RAM FREE ",0 typeTable: DB "REAL ",0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB "PRGM ",0 DB "PRGM ",0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB "AVAR ",0 DB 0,0,0,0,0,0 DB "GROUP",0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 DB 0,0,0,0,0,0 sAPP: DB "APP ",0 GetDataPacket: push hl call Get4Bytes pop hl GetDataPacketRest: ld bc,(header+2) $$: push bc push hl call GetByte pop hl pop bc ld (hl),a inc hl dec bc ld a,b or c jr nz,$B call GetByte call GetByte SendAck: ld a,56h ld (header+1),a jr Send4BytesR SendPacket: ld de,0 ld (header+4),de ld (header+1),a ld a,c ld (header+2),a ld a,b ld (header+3),a push bc push hl call Send4BytesR pop hl pop bc $$: ld a,(hl) inc hl push hl push bc call updateChecksum call SendAByte pop bc pop hl dec bc ld a,b or c jr nz,$B ld a,(header+4) call SendAByte ld a,(header+5) call SendAByte jr Get4Bytes updateChecksum: ld hl,(header+4) ld d,0 ld e,a add hl,de ld (header+4),hl ret Send4BytesR: ld a,(machineID) call SendAByte ld a,(header+1) call SendAByte ld a,(header+2) call SendAByte ld a,(header+3) ;fall through to SendAByte SendAByte: B_CALL SendAByte ret Get4Bytes: call GetByte ld (header),a call GetByte ld (header+1),a call GetByte ld (header+2),a call GetByte ld (header+3),a ret GetByte: ld b,15 GetByteLoop: push hl push bc call getByte_sub pop bc pop hl ret z djnz GetByteLoop B_JUMP ErrLinkXmit getByte_sub: ld hl,$F call APP_PUSH_ERRORH B_CALL RecAByteIO ld (tempByte),a call APP_POP_ERRORH ld a,(tempByte) cp a ret $$: or a ret sRemoteLinkError: call clearAllScreens B_CALL HomeUp res indicOnly,(iy+indicFlags) set textInverse,(iy+textFlags) ld hl,sErrLink call PutSApp B_CALL NewLine ld a,'1' B_CALL PutC ld a,':' B_CALL PutC res textInverse,(iy+textFlags) ld hl,sQuit call PutSApp $$: B_CALL GetKey cp k1 jr z,StartApp cp kEnter jr z,StartApp cp kClear jr z,StartApp cp kQuit jr z,StartApp jr $B sErrLink: DB "ERR:LINK",0 sQuit: DB "Quit",0 RemoteControl: B_CALL ClrLCDFull ld (iy+linkFlags),0 ld a,03h ld (machineID),a ld hl,sRemoteLinkError call APP_PUSH_ERRORH call getScreenshot remoteControlKeyLoop: res indicOnly,(iy+indicFlags) B_CALL GetKeyRetOff cp kOff jr z,RemoteControlDone B_CALL IsA2ByteTok jr nz,$F ld (header+3),a ld a,(keyExtend) ld (header+2),a jr sendKeypress $$: ld (header+2),a xor a ld (header+3),a sendKeypress: ld a,87h ld (header+1),a call Send4BytesR call Get4Bytes call Get4Bytes call getScreenshot jr remoteControlKeyLoop RemoteControlDone: call APP_POP_ERRORH jr StartApp getScreenshot: ld a,6Dh ld (header+1),a call Send4BytesR call Get4Bytes call Get4Bytes ld bc,(header+2) ld hl,savesscreen $$: push bc push hl call GetByte pop hl pop bc ld (hl),a inc hl dec bc ld a,b or c jr nz,$B call GetByte call GetByte ld a,56h ld (header+1),a call Send4BytesR ld b,63 ld hl,savesscreen B_CALL RestoreDisp ret