;X-Link v1.1 by Brandon Wilson ;11/19/05 ; ;X-Link is an application for transmitting and receiving variables of nearly any type to/from any ;calculator to/from your TI-83 Plus/TI-83 Plus Silver Edition/TI-84 Plus/TI-84 Plus Silver Edition in the ;form of AppVars. ; ;It currently supports nearly all variable types from the TI-85, TI-86, TI-89, TI-89 ;Titanium, TI-92, TI-92 Plus, and Voyage 200. The 73, 82, 83 and 84 series of calculators are not supported ;because they already contain the built-in ability to send to each other. ; ;Please do not modify the contents of this file or publish it without both my prior knowledge and permission. include "ti83plus.inc" EXT_APP equ 1 ;This definition is required of all apps cseg ;This linker directive is required of all apps. db 080h,0Fh ;Field: Program length db 00h,00h,00h,00h ;Length=0 (N/A for unsigned apps) db 080h,012h ;Field: Program type db 01h,04h ;Type= Shareware, TI-83Plus db 080h,021h ;Field: App ID db 01h ;Id = 1 db 080h,031h ;Field: App Build db 01h ;Build = 1 db 080h,048h ;Field: App Name db 058h,02Dh,04Ch,069h,06Eh,06Bh,020h,020h ;Name = "X-Link " must be 8 characters db 080h,081h ;Field: App Pages db 01h ;App Pages = 1 db 080h,090h ;No default splash screen db 03h,026h ,09h,04h, 04h,06fh,01bh,80h ;Field: Date stamp- 5/12/1999 db 02h,0dh,040h ;Dummy encrypted TI date stamp signature db 0a1h ,06bh ,099h ,0f6h ,059h ,0bch ,067h db 0f5h ,085h ,09ch ,09h ,06ch ,0fh ,0b4h ,03h ,09bh ,0c9h db 03h ,032h ,02ch ,0e0h ,03h ,020h ,0e3h ,02ch ,0f4h ,02dh db 073h ,0b4h ,027h ,0c4h ,0a0h ,072h ,054h ,0b9h ,0eah ,07ch db 03bh ,0aah ,016h ,0f6h ,077h ,083h ,07ah ,0eeh ,01ah ,0d4h db 042h ,04ch ,06bh ,08bh ,013h ,01fh ,0bbh ,093h ,08bh ,0fch db 019h ,01ch ,03ch ,0ech ,04dh ,0e5h ,075h db 80h,7Fh ;Field: Program Image length db 0,0,0,0 ;Length=0, N/A db 0,0,0,0 ;Reserved db 0,0,0,0 ;Reserved db 0,0,0,0 ;Reserved db 0,0,0,0 ;Reserved ;X-Link Flags xlinkFlags equ asm_Flag1 twoMenus equ 0 curMenu equ 1 arcRecvd equ 2 overwriteAll equ 3 varArchived equ 4 ;Memory Equates wMenu1Addr equ appBackUpScreen wMenu2Addr equ appBackUpScreen+2 bCurChoice equ appBackUpScreen+4 wTemp equ appBackUpScreen+6 bNumChoices equ appBackUpScreen+8 wDataAddr equ appBackUpScreen+9 bMachineID equ appBackUpScreen+11 bVariableType equ appBackUpScreen+12 wPacketChecksum equ appBackUpScreen+13 wVarSize equ appBackUpScreen+15 wPacketLength equ appBackUpScreen+17 strVarName equ appBackUpScreen+19 bType1 equ appBackUpScreen+29 bType2 equ appBackUpScreen+30 bCurScreenChoice equ appBackUpScreen+31 bTopScreenChoice equ appBackUpScreen+32 bVarNameLength equ appBackUpScreen+33 wRamOffset equ appBackUpScreen+34 wRomOffset equ appBackUpScreen+36 bRomPage equ appBackUpScreen+38 bNumItems equ appBackUpScreen+39 bSelectItem equ appBackUpScreen+40 bCurScreenItem equ appBackUpScreen+41 bTemp equ appBackUpScreen+42 bCounter equ appBackUpScreen+43 bTopScreenItem equ appBackUpScreen+44 bLastKey equ appBackUpScreen+45 bSelectTable equ appBackUpScreen+46 startApp: xor a ld (bLastKey),a set appAutoScroll,(iy+appFlags) set twoMenus,(iy+xlinkFlags) res curMenu,(iy+xlinkFlags) ld hl,bSendMenu ld (wMenu1Addr),hl ld hl,bRecvMenu ld (wMenu2Addr),hl jr DrawMenu DrawMenu: xor a ld (bCurChoice),a B_CALL ClrLCDFull B_CALL HomeUp B_CALL RunIndicOff bit curMenu,(iy+xlinkFlags) call z,setTextInverse ld hl,(wMenu1Addr) call PutSApp bit curMenu,(iy+xlinkFlags) jr nz,dmSecond inc hl ld a,(hl) ld (bNumChoices),a inc hl ld (wDataAddr),hl call resTextInverse dmSecond: ld hl,curCol inc (hl) bit twoMenus,(iy+xlinkFlags) jr z,dmFirst bit curMenu,(iy+xlinkFlags) call nz,setTextInverse ld hl,(wMenu2Addr) call PutSApp bit curMenu,(iy+xlinkFlags) jr z,dmFirst inc hl ld a,(hl) ld (bNumChoices),a inc hl ld (wDataAddr),hl call resTextInverse dmFirst: B_CALL NewLine ld b,0 ld hl,(wDataAddr) ld (wTemp),hl dmDrawLoop: ld a,(bCurChoice) ld c,a ld a,b cp c call z,setTextInverse ld a,b add a,31h B_CALL PutC ld a,':' B_CALL PutC call resTextInverse ld hl,(wTemp) push hl call PutSApp pop hl ld de,18 add hl,de ld (wTemp),hl ld a,b cp 6 jr z,dmKeyLoop B_CALL NewLine ld a,(bNumChoices) ld c,a inc b ld a,b cp c jr z,dmKeyLoop cp 7 jr nz,dmDrawLoop dmKeyLoop: B_CALL GetKey ld b,a ld a,(bLastKey) cp kMode jr nz,_dmKeyLoopContinue ld a,b cp kCapS jr nz,_dmKeyLoopContinue ;easter egg B_CALL ClrLCDFull B_CALL HomeUp ld hl,strSendingEgg call PutSApp ld hl,linkFailed call APP_PUSH_ERRORH ld hl,strEggData ld (wMenu1Addr),hl easterEggLoop: ld a,08h B_CALL SendAByte ld a,87h B_CALL SendAByte ld hl,(wMenu1Addr) ld a,(hl) B_CALL SendAByte xor a B_CALL SendAByte B_CALL Rec1stByteNC B_CALL RecAByteIO B_CALL RecAByteIO B_CALL RecAByteIO ld hl,(wMenu1Addr) inc hl ld (wMenu1Addr),hl ld a,(hl) or a jr nz,easterEggLoop call APP_POP_ERRORH res indicOnly,(iy+indicFlags) B_CALL NewLine B_CALL DispDone B_CALL GetKey jp startApp strEggData: db "Thanks for using X-Link!",0 strSendingEgg: db "Sending data",0CEh,0 _dmKeyLoopContinue: ld a,b ld (bLastKey),a cp kClear jr z,exitApp cp kQuit jr z,exitApp cp kLeft jr z,dmSwitchMenu cp kRight jr z,dmSwitchMenu cp kUp jr z,dmUp cp kDown jr z,dmDown cp kEnter jr z,dmExecute cp k1 jp m,dmKeyLoop cp k8 jp p,dmKeyLoop sub k0 ld b,a ld a,(bNumChoices) cp b jp m,dmKeyLoop ld hl,(wDataAddr) ld de,18 sbc hl,de dmklLoop: add hl,de djnz dmklLoop ld de,16 add hl,de ld a,(hl) ld e,a inc hl ld a,(hl) ld d,a ex de,hl jp (hl) dmSwitchMenu: bit twoMenus,(iy+xlinkFlags) jr z,DrawMenu bit curMenu,(iy+xlinkFlags) jr z,dmToSecond res curMenu,(iy+xlinkFlags) jr DrawMenu dmToSecond: set curMenu,(iy+xlinkFlags) jr DrawMenu dmUp: ld a,(bCurChoice) or a jr nz,_dmuNoWrap ld a,(bNumChoices) ld (bCurChoice),a xor a _dmuNoWrap: ld hl,curCol ld (hl),0 inc a ld (curRow),a add a,30h B_CALL PutC ld a,':' B_CALL PutC ld a,(bCurChoice) dec a ld (bCurChoice),a call setTextInverse ld hl,curCol ld (hl),0 inc a ld (curRow),a add a,30h B_CALL PutC ld a,':' B_CALL PutC call resTextInverse jr dmKeyLoop dmDown: ld a,(bCurChoice) inc a ld b,a ld a,(bNumChoices) cp b jr nz,_dmdNoWrap ld a,0FFh ld (bCurChoice),a _dmdNoWrap: ld a,b ld (curRow),a ld hl,curCol ld (hl),0 add a,30h B_CALL PutC ld a,':' B_CALL PutC ld a,(bCurChoice) inc a ld (bCurChoice),a call setTextInverse ld hl,curCol ld (hl),0 inc a ld (curRow),a add a,30h B_CALL PutC ld a,':' B_CALL PutC call resTextInverse jr dmKeyLoop dmExecute: ld a,(bCurChoice) inc a ld b,a ld de,18 ld hl,(wDataAddr) sbc hl,de dmeLoop: add hl,de djnz dmeLoop ld de,16 add hl,de ld a,(hl) ld e,a inc hl ld a,(hl) ld d,a ex de,hl jp (hl) Send73Menu: ld a,74h ld (bMachineID),a jr SendToMenu Send85Menu: ld a,85h ld (bMachineID),a jr SendToMenu Send86Menu: ld a,86h ld (bMachineID),a jr SendToMenu Send89Menu: ld a,98h ld (bMachineID),a jr SendToMenu Send92Menu: ld a,89h ld (bMachineID),a jr SendToMenu Send92PlusMenu: ld a,88h ld (bMachineID),a jr SendToMenu SendVoy200Menu: ld a,88h ld (bMachineID),a SendToMenu: ld hl,bSelectTable ld b,255 _smEraseLoop: ld (hl),0 inc hl djnz _smEraseLoop SendMenu: B_CALL ClrLCDFull B_CALL HomeUp bit curMenu,(iy+xlinkFlags) call z,setTextInverse ld hl,strSelect call PutSApp call resTextInverse ld hl,curCol inc (hl) bit curMenu,(iy+xlinkFlags) call nz,setTextInverse ld hl,strTransmit call PutSApp call resTextInverse B_CALL NewLine bit curMenu,(iy+xlinkFlags) jr z,smContinue call setTextInverse ld a,'1' B_CALL PutC ld a,':' B_CALL PutC call resTextInverse ld hl,strTransmitText call PutSApp smtKeyLoop: B_CALL GetKey cp kQuit jr z,exitApp cp kClear jr z,exitApp cp kLeft jr z,smSwitchMenu cp kRight jr z,smSwitchMenu cp kEnter jr z,transmitVars cp k1 jr z,transmitVars jr smtKeyLoop smSwitchMenu: bit curMenu,(iy+xlinkFlags) jr nz,_smToFirst set curMenu,(iy+xlinkFlags) jr SendMenu _smToFirst: res curMenu,(iy+xlinkFlags) jr SendMenu smContinue: ld hl,bDummyVar rst 20h xor a ld (bNumItems),a _smcLoop: call findCompatibleAppVar jr c,_smcLoopDone ld a,(bNumItems) inc a ld (bNumItems),a jr _smcLoop _smcLoopDone: ld a,(bNumItems) or a jr z,smtKeyLoop ld hl,bDummyVar rst 20h call selectDisplayNames displayedItemsGK: ld hl,0001h ld (curRow),hl ld a,1 ld (bSelectItem),a ld (bCurScreenItem),a xor a ld (bTopScreenItem),a ld a,(bSelectItem) call dispCurSelectStatus selectGK: B_CALL GetKey cp kQuit jr z,exitApp cp kClear jr z,exitApp cp kEnter call z,selectEnterPressed cp kLeft jr z,smSwitchMenu cp kRight jr z,smSwitchMenu cp kDown call z,selectDownPressed cp kUp call z,selectUpPressed jr selectGK selectEnterPressed: ld a,(bSelectItem) ld d,0 ld e,a ld hl,bSelectTable-1 add hl,de ld a,(hl) or a jr z,_sepCheck ld (hl),0 jr _sepContinue _sepCheck: ld (hl),1 _sepContinue: ld a,(bCurScreenItem) ld (curRow),a xor a ld (curCol),a ld a,(bSelectItem) jr dispCurSelectStatus selectUpPressed: ld a,(bSelectItem) cp 1 ret z ld a,(bCurScreenItem) cp 1 jr nz,_supNoScroll ld a,(bTopScreenItem) dec a ld (bTopScreenItem),a ld a,(bSelectItem) dec a ld (bSelectItem),a push af ld hl,bDummyVar rst 20h pop af dec a ld b,a or a jr z,_skipFindVarName _supFindVarName: push bc call findCompatibleAppVar pop bc djnz _supFindVarName _skipFindVarName: call selectDisplayNames ld hl,0001h ld (curRow),hl ld a,(bSelectItem) jr dispCurSelectStatus _supNoScroll: ld a,(bCurScreenItem) ld (curRow),a xor a ld (curCol),a ld a,(bSelectItem) call dispSelectStatus ld a,(bSelectItem) dec a ld (bSelectItem),a ld a,(bCurScreenItem) dec a ld (bCurScreenItem),a ld (curRow),a xor a ld (curCol),a ld a,(bSelectItem) jr dispCurSelectStatus selectDownPressed: ld a,(bSelectItem) ld b,a ld a,(bNumItems) cp b ld a,0 ret z ld a,(bCurScreenItem) cp 7 jr nz,_sdpNoScroll ld a,(bTopScreenItem) inc a ld (bTopScreenItem),a ld a,b inc a ld (bSelectItem),a sub 6 ld b,a ld hl,bDummyVar rst 20h _sdpFindVarName: push bc call findCompatibleAppVar pop bc djnz _sdpFindVarName call selectDisplayNames ld hl,0007h ld (curRow),hl ld a,(bSelectItem) jr dispCurSelectStatus _sdpNoScroll: ld a,(bCurScreenItem) ld (curRow),a xor a ld (curCol),a ld a,(bSelectItem) call dispSelectStatus ld a,(bCurScreenItem) inc a ld (bCurScreenItem),a ld a,(bSelectItem) inc a ld (bSelectItem),a ld a,(bCurScreenItem) ld (curRow),a xor a ld (curCol),a ld a,(bSelectItem) jr dispCurSelectStatus selectDisplayNames: ld a,1 ld (bCounter),a _sdn1: call findCompatibleAppVar jr c,displayedItemsGK xor a ld (curCol),a ld a,(bCounter) ld (curRow),a ld b,a ld a,(bTopScreenItem) add a,b call dispSelectStatus call dispArcStatus ld hl,op1+1 call PutSApp B_CALL EraseEOL call dispVarType ld a,(bCounter) inc a ld (bCounter),a cp 8 ret z B_CALL NewLine jr _sdn1 dispSelectStatus: ld d,0 ld e,a ld hl,bSelectTable-1 add hl,de ld a,(hl) or a jr nz,_dss1 ld a,Lspace jr _dss2 _dss1: ld a,Lblock _dss2: B_CALL PutC ret dispCurSelectStatus: ld d,0 ld e,a ld hl,bSelectTable-1 add hl,de ld a,(hl) or a jr nz,_dcss1 ld a,Lconvert jr _dcss2 _dcss1: ld a,LblockArrow _dcss2: B_CALL PutC ret dispArcStatus: B_CALL ChkFindSym ld a,b or a jr nz,_das1 ld a,Lspace jr _das2 _das1: ld a,Lasterisk _das2: B_CALL PutC ret transmitVars: xor a ld (bNumChoices),a ld b,255 ld hl,bSelectTable _tvLoop: ld a,(hl) or a jr z,_tvLoopEnd ld a,(bNumChoices) inc a ld (bNumChoices),a _tvLoopEnd: inc hl djnz _tvLoop B_CALL RunIndicOn B_CALL ClrLCDFull ld hl,0100h ld (curRow),hl ld hl,strSending call PutSApp ld a,(bNumChoices) or a jr z,transferDoneN xor a ld (bCurChoice),a ld a,255 ld (wTemp+1),a ld hl,bSelectTable ld (wDataAddr),hl _favLoop: ld hl,(wDataAddr) ld a,(hl) or a jr nz,sendAppVar appVarSent: ld hl,(wDataAddr) inc hl ld (wDataAddr),hl ld a,(bCurChoice) inc a ld (bCurChoice),a ld a,(wTemp+1) dec a ld (wTemp+1),a or a jr nz,_favLoop ld hl,linkFailed call APP_PUSH_ERRORH ld a,(bMachineID) B_CALL SendAByte ld a,92h B_CALL SendAByte xor a B_CALL SendAByte xor a B_CALL SendAByte B_CALL Rec1stByteNC B_CALL RecAByteIO cp 56h jr nz,forceLinkErr B_CALL RecAByteIO B_CALL RecAByteIO call APP_POP_ERRORH res indicOnly,(iy+indicFlags) B_CALL RunIndicOff xor a ld (curCol),a ld a,Lspace B_CALL PutC jr transferDone sendAppVar: ld hl,bDummyVar rst 20h ld a,(bCurChoice) inc a ld b,a _savLoop: push bc call findCompatibleAppVar pop bc jr c,_doneSending djnz _savLoop xor a ld (curCol),a ld a,Lspace B_CALL PutC B_CALL NewLine ld a,Lconvert B_CALL PutC bit varArchived,(iy+xlinkFlags) jr nz,_savArchived ld a,Lspace B_CALL PutC jr _savContinue _savArchived: ld a,Lasterisk B_CALL PutC _savContinue: ld hl,op1+1 call PutSApp call dispVarType ld hl,linkFailed call APP_PUSH_ERRORH ld a,(bMachineID) B_CALL SendAByte ld a,06h B_CALL SendAByte B_CALL ChkFindSym ld a,b or a jr nz,_savGetArcInfo push hl ld a,(de) ld l,a inc de ld a,(de) ld h,a push de ld de,6 sbc hl,de ld (wVarSize),hl pop de pop hl inc de ;after this, gets you to 26h inc de inc de inc de inc de ld a,(de) ld (bType1),a inc de ld a,(de) ld (bType2),a inc de ld (wRamOffset),de ld de,6 sbc hl,de ld a,(hl) ld (bVarNameLength),a jr _savContinueHeader _savGetArcInfo: ex de,hl call myLoadCIndPaged ;skip data valid flag call myLoadDEIndPaged ;skip data length ld de,6 call BHL_plus_DE call myLoadCIndPaged ;c is name length ld d,0 ld e,c ld a,c ld (bVarNameLength),a call BHL_plus_DE call myLoadDEIndPaged ;size bytes push hl ld hl,-6 add hl,de ex de,hl pop hl ld (wVarSize),de call myLoadCIndPaged ;after this, gets you to 26h call myLoadCIndPaged call myLoadCIndPaged call myLoadCIndPaged call myLoadCIndPaged ld a,c ld (bType1),a call myLoadCIndPaged ld a,c ld (bType2),a ld (wRomOffset),hl ld a,b ld (bRomPage),a _savContinueHeader: call checkIf89Series jr c,_savSend86Series cp 89h jr z,_savSend92 ld a,(bVarNameLength) add a,7 ld (wPacketLength),a jr _savSendPacketLength _savSend92: ld a,(bVarNameLength) add a,6 ld (wPacketLength),a jr _savSendPacketLength _savSend86Series: ld a,(bVarNameLength) add a,4 ld (wPacketLength),a _savSendPacketLength: ld a,(wPacketLength) B_CALL SendAByte xor a B_CALL SendAByte ld a,(wVarSize) call updatePacketChecksumReset B_CALL SendAByte ld a,(wVarSize+1) call updatePacketChecksum B_CALL SendAByte call checkIf89Series jr c,_savNoExtraSizeBytes xor a B_CALL SendAByte xor a B_CALL SendAByte _savNoExtraSizeBytes: ld a,(bVariableType) call updatePacketChecksum B_CALL SendAByte ld a,(bVarNameLength) call updatePacketChecksum B_CALL SendAByte ld a,(bVarNameLength) ld b,a ld hl,op1 _savNameLoop: push bc inc hl ld a,(hl) push hl call updatePacketChecksum B_CALL SendAByte pop hl pop bc djnz _savNameLoop call checkIf89Series jr c,_savNoExtraByte cp 89h jr z,_savNoExtraByte xor a B_CALL SendAByte _savNoExtraByte: ld a,(wPacketChecksum) B_CALL SendAByte ld a,(wPacketChecksum+1) B_CALL SendAByte B_CALL Rec1stByteNC B_CALL RecAByteIO cp 56h jr nz,forceLinkErr B_CALL RecAByteIO B_CALL RecAByteIO B_CALL Rec1stByteNC B_CALL RecAByteIO cp 09h jr nz,forceLinkErr B_CALL RecAByteIO B_CALL RecAByteIO ld a,(bMachineID) B_CALL SendAByte ld a,56h B_CALL SendAByte xor a B_CALL SendAByte xor a B_CALL SendAByte ld a,(bMachineID) B_CALL SendAByte ld a,15h B_CALL SendAByte ld a,(wVarSize) B_CALL SendAByte ld a,(wVarSize+1) B_CALL SendAByte B_CALL ChkFindSym ld hl,0 ld (wPacketChecksum),hl ld bc,(wVarSize) _savdLoop: push bc call getDataByte call updatePacketChecksum B_CALL SendAByte pop bc dec bc ld a,b or c jr nz,_savdLoop ld a,(wPacketChecksum) B_CALL SendAByte ld a,(wPacketChecksum+1) B_CALL SendAByte B_CALL RecAByteIO B_CALL RecAByteIO cp 56h jr nz,forceLinkErr B_CALL RecAByteIO B_CALL RecAByteIO _doneSending: call APP_POP_ERRORH res indicOnly,(iy+indicFlags) jr appVarSent getDataByte: bit varArchived,(iy+xlinkFlags) jr nz,_gdbArchive ld hl,(wRamOffset) ld a,(hl) inc hl ld (wRamOffset),hl ret _gdbArchive: ld hl,(wRomOffset) ld a,(bRomPage) ld b,a call myLoadCIndPaged ld a,b ld (bRomPage),a ld (wRomOffset),hl ld a,c ret RecvToRAM: res arcRecvd,(iy+xlinkFlags) jr receiveVar RecvToFlash: set arcRecvd,(iy+xlinkFlags) receiveVar: res overwriteAll,(iy+xlinkFlags) B_CALL RunIndicOn B_CALL ClrLCDFull ld hl,0100h ld (curRow),hl ld hl,strWaiting call PutSApp ld hl,linkFailed call APP_PUSH_ERRORH B_CALL Rec1stByteNC ld (bMachineID),a call checkIf89Series jr nc,_validMachineID cp 85h jr z,_validMachineID cp 86h jr z,_validMachineID jr forceLinkErr _validMachineID: ld hl,0100h ld (curRow),hl ld hl,strReceiving call PutSApp _rIsReady: B_CALL RecAByteIO cp 68h jr nz,_rNotReady B_CALL RecAByteIO ;this is ready packet, get checksum 1 B_CALL RecAByteIO ;get checksum 2 ;send acknowledge ld a,(bMachineID) B_CALL SendAByte ld a,56h B_CALL SendAByte xor a B_CALL SendAByte xor a B_CALL SendAByte B_CALL RecAByteIO ;get machine ID jr _rIsReady ;try getting something other than 68h again _rNotReady: cp 06h jr nz,forceLinkErr receiveVarHeader: xor a ld (curCol),a ld a,' ' B_CALL PutC B_CALL NewLine ;packet length 1 B_CALL RecAByteIO ld (wPacketLength),a ;packet length 2, must be zero B_CALL RecAByteIO or a jr nz,forceLinkErr ld (wPacketLength+1),a B_CALL RecAByteIO call updatePacketChecksumReset ld (wVarSize),a B_CALL RecAByteIO call updatePacketChecksum ld (wVarSize+1),a call checkIf89Series jr c,_rhGetType B_CALL RecAByteIO ;size byte 3, must be zero call updatePacketChecksum or a jr nz,forceLinkErr B_CALL RecAByteIO ;size byte 4, must be zero call updatePacketChecksum or a jr nz,forceLinkErr ;variable type _rhGetType: B_CALL RecAByteIO call updatePacketChecksum ld (bVariableType),a call checkValidTypes jr c,forceLinkErr ;assume padded 8-byte name ld b,8 ld a,(bMachineID) cp 74h jr z,_rhPadded ;name length byte B_CALL RecAByteIO call updatePacketChecksum ld b,a _rhPadded: ld hl,strVarName ld (hl),AppVarObj _rhLoop: push hl push bc ;name byte B_CALL RecAByteIO call updatePacketChecksum pop bc pop hl or a jr z,_rhSkip inc hl ld (hl),a _rhSkip: djnz _rhLoop inc hl ld (hl),0 ;89 series unknown byte call checkIf89Series jr c,_rhNoExtraByte ld a,(bMachineID) cp 89h jr z,_rhNoExtraByte B_CALL RecAByteIO _rhNoExtraByte: ;packet checksum 1 B_CALL RecAByteIO ld (wTemp),a ;packet checksum 2 B_CALL RecAByteIO ld h,a ld a,(wTemp) ld l,a ld de,(wPacketChecksum) B_CALL cphlde jr nz,forceLinkErr call checkIf89Series jr nc,_rSendAck ld a,(bVariableType) cp 17h jp m,_rSendAck cp 2Ah jr z,_rSendAck ld hl,bFixNamesTable-6 ld de,6 sub 16h ld b,a _fixLoop: add hl,de djnz _fixLoop ld de,strVarName+1 ld bc,6 ldir ;send acknowledge _rSendAck: xor a ld (curCol),a ld a,Lconvert B_CALL PutC ld hl,curCol inc (hl) ld hl,strVarName+1 call PutSApp call dispVarType ld a,(bMachineID) B_CALL SendAByte ld a,56h B_CALL SendAByte xor a B_CALL SendAByte xor a B_CALL SendAByte ;save extra type bytes ld hl,(strVarName+1) ld (bType1),hl bit overwriteAll,(iy+xlinkFlags) jr nz,receiveContinue ld hl,strVarName rst 20h B_CALL ChkFindSym jr nc,duplicateVarFound receiveContinue: ld hl,(wVarSize) ld de,6 ;26h, 58h, machine ID, type byte, type bytes 1 and 2 add hl,de B_CALL EnoughMem jr c,forceMemErr ;send continue ld a,(bMachineID) B_CALL SendAByte ld a,09h B_CALL SendAByte ld a,(wPacketLength) B_CALL SendAByte ld a,(wPacketLength+1) B_CALL SendAByte ;receive acknowledge B_CALL RecAByteIO B_CALL RecAByteIO cp 56h jr nz,forceLinkErr B_CALL RecAByteIO B_CALL RecAByteIO ;receive data packet B_CALL RecAByteIO B_CALL RecAByteIO cp 15h jr nz,forceLinkErr B_CALL RecAByteIO ld (wPacketLength),a B_CALL RecAByteIO ld (wPacketLength+1),a ld hl,strVarName rst 20h B_CALL ChkFindSym jr c,_rdCreateVar B_CALL DelVarArc _rdCreateVar: ld hl,(wPacketLength) ld de,6 add hl,de B_CALL CreateAppVar jr c,forceMemErr inc de inc de ld a,26h ld (de),a inc de ld a,58h ld (de),a inc de ld a,(bMachineID) ld (de),a inc de ld a,(bVariableType) ld (de),a inc de ld a,(bType1) ld (de),a inc de ld a,(bType2) ld (de),a inc de ld bc,(wPacketLength) ld hl,0 ld (wPacketChecksum),hl _rdLoop: push de push bc B_CALL RecAByteIO call updatePacketChecksum pop bc pop de ld (de),a inc de dec bc ld a,b or c jr nz,_rdLoop B_CALL RecAByteIO ld (wTemp),a B_CALL RecAByteIO ld h,a ld a,(wTemp) ld l,a ld de,(wPacketChecksum) B_CALL cphlde jr nz,forceLinkErr bit arcRecvd,(iy+xlinkFlags) jr z,_receiveNoArchive ld hl,strVarName rst 20h B_CALL ChkFindSym B_CALL Arc_Unarc jr c,forceMemErr ld a,1 ld (curCol),a ld a,Lasterisk B_CALL PutC _receiveNoArchive: ld a,(bMachineID) B_CALL SendAByte ld a,56h B_CALL SendAByte ld a,(wPacketLength) B_CALL SendAByte ld a,(wPacketLength+1) B_CALL SendAByte ;receive another header or EOT B_CALL RecAByteIO B_CALL RecAByteIO cp 06h jr z,receiveVarHeader cp 92h jr nz,forceLinkErr receiveEOT: B_CALL RecAByteIO B_CALL RecAByteIO ;send acknowledge ld a,(bMachineID) B_CALL SendAByte ld a,56h B_CALL SendAByte xor a B_CALL SendAByte xor a B_CALL SendAByte transferDone: call APP_POP_ERRORH transferDoneN: res indicOnly,(iy+indicFlags) B_CALL RunIndicOff B_CALL NewLine B_CALL DispDone B_CALL GetKey jr startApp exitApp: B_CALL ClrLCDFull B_CALL HomeUp B_JUMP JForceCmdNoChar forceMemErr: call APP_POP_ERRORH res indicOnly,(iy+indicFlags) res twoMenus,(iy+xlinkFlags) res curMenu,(iy+xlinkFlags) ld hl,bMemErrMenu ld (wMenu1Addr),hl ld (wMenu2Addr),hl jr DrawMenu forceLinkErr: call APP_POP_ERRORH linkFailed: res indicOnly,(iy+indicFlags) res twoMenus,(iy+xlinkFlags) res curMenu,(iy+xlinkFlags) res onInterrupt,(iy+onFlags) ld hl,bLinkErrMenu ld (wMenu1Addr),hl ld (wMenu2Addr),hl jr DrawMenu checkValidTypes: call checkIf89Series jr nc,_cvt89Series ld a,(bVariableType) or a ret z cp 01h ret z cp 02h ret z cp 03h ret z cp 04h ret z cp 05h ret z cp 06h ret z cp 07h ret z cp 08h ret z cp 09h ret z cp 0Ah ret z cp 0Ch ret z cp 0Dh ret z cp 0Eh ret z cp 0Fh ret z cp 10h ret z cp 11h ret z cp 12h ret z cp 17h ret z cp 18h ret z cp 19h ret z cp 1Ah ret z cp 1Bh ret z cp 2Ah ret z scf ret _cvt89Series: ld a,(bVariableType) or a ret z cp 04h ret z cp 06h ret z cp 0Ah ret z cp 0Bh ret z cp 0Ch ret z cp 0Dh ret z cp 0Eh ret z cp 10h ret z cp 12h ret z cp 13h ret z cp 14h ret z cp 21h ret z scf ret PutSApp: ld a,(hl) or a ret z B_CALL PutMap ld a,(curCol) inc a ld (curCol),a inc hl jr PutSApp resTextInverse: res textInverse,(iy+textFlags) ret setTextInverse: set textInverse,(iy+textFlags) ret updatePacketChecksumReset: ld hl,0 ld (wPacketChecksum),hl updatePacketChecksum: ld d,0 ld e,a ld hl,(wPacketChecksum) add hl,de ld (wPacketChecksum),hl ret duplicateVarFound: call APP_POP_ERRORH res indicOnly,(iy+indicFlags) res twoMenus,(iy+xlinkFlags) res curMenu,(iy+xlinkFlags) ld hl,bDuplicateVarMenu ld (wMenu1Addr),hl ld (wMenu2Addr),hl jr DrawMenu checkIf89Series: ld a,(bMachineID) cp 08h ret z cp 88h ret z cp 98h ret z cp 89h ret z scf ret findPreviousAppVar: B_CALL FindAlphaUp ret c B_CALL ChkFindSym ld a,b or a jr nz,_fpavArchived inc de inc de ld a,(de) cp 26h jr nz,findPreviousAppVar inc de ld a,(de) cp 58h jr nz,findPreviousAppVar inc de ld a,(de) ld b,a ld a,(bMachineID) cp b jr nz,findPreviousAppVar inc de ld a,(de) ld (bVariableType),a res varArchived,(iy+xlinkFlags) ret _fpavArchived: ex de,hl call myLoadCIndPaged ;skip data valid flag call myLoadDEIndPaged ;skip data length so now at symbol table entry ld de,6 call BHL_plus_DE call myLoadCIndPaged ;get name length byte ld d,0 ld e,c call BHL_plus_DE ;get to data call myLoadDEIndPaged ;go past size bytes call myLoadCIndPaged ld a,c cp 26h jr nz,findPreviousAppVar call myLoadCIndPaged ld a,c cp 58h jr nz,findPreviousAppVar call myLoadCIndPaged ld a,(bMachineID) cp c jr nz,findPreviousAppVar call myLoadCIndPaged ld a,c ld (bVariableType),a set varArchived,(iy+xlinkFlags) ret findCompatibleAppVar: B_CALL FindAlphaUp ret c B_CALL ChkFindSym ld a,b or a jr nz,_fcavArchived inc de inc de ld a,(de) cp 26h jr nz,findCompatibleAppVar inc de ld a,(de) cp 58h jr nz,findCompatibleAppVar inc de ld a,(de) ld b,a ld a,(bMachineID) cp b jr nz,findCompatibleAppVar inc de ld a,(de) ld (bVariableType),a res varArchived,(iy+xlinkFlags) ret _fcavArchived: ex de,hl call myLoadCIndPaged ;skip data valid flag call myLoadDEIndPaged ;skip data length so now at symbol table entry ld de,6 call BHL_plus_DE call myLoadCIndPaged ;get name length byte ld d,0 ld e,c call BHL_plus_DE ;get to data call myLoadDEIndPaged ;go past size bytes call myLoadCIndPaged ld a,c cp 26h jr nz,findCompatibleAppVar call myLoadCIndPaged ld a,c cp 58h jr nz,findCompatibleAppVar call myLoadCIndPaged ld a,(bMachineID) cp c jr nz,findCompatibleAppVar call myLoadCIndPaged ld a,c ld (bVariableType),a set varArchived,(iy+xlinkFlags) ret myLoadCIndPaged: B_CALL LoadCIndPaged inc_BHL: inc hl 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 bit 7,h ret z inc b res 7,h set 6,h ret dispVarType: call checkIf89Series jr nc,dvt89Series ld hl,b86SeriesTable-6 jr dvtContinue dvt89Series: ld hl,b89SeriesTable-6 dvtContinue: ld de,6 ld a,(bVariableType) inc a ld b,a dvtLoop: add hl,de djnz dvtLoop ld a,10 ld (curCol),a ld a,' ' B_CALL PutC jr PutSApp dispSelectedStatus: ld a,(bCurScreenChoice) inc a ld (curRow),a xor a ld (curCol),a ld a,(bCurChoice) ld d,0 ld e,a ld hl,bSelectTable add hl,de ld a,(hl) or a jr nz,_dssSelected ld a,Lconvert B_CALL PutC ret _dssSelected: ld a,LblockArrow B_CALL PutC ret dispUnselectedStatus: ld a,(wTemp) inc a ld (curRow),a dispUnselectedStatusNoR: xor a ld (curCol),a ld a,(wTemp) ld b,a ld a,(bTopScreenChoice) add a,b ld d,0 ld e,a ld hl,bSelectTable add hl,de ld a,(hl) or a jr nz,_dusSelected ld a,Lspace B_CALL PutC ret _dusSelected: ld a,Lblock B_CALL PutC ret renameDuplicateVar: B_CALL ClrLCDFull B_CALL ClrTxtShd ld hl,strVarName rst 20h ld hl,0 ld (curRow),hl ld a,Lconvert B_CALL PutC ld hl,curCol inc (hl) ld hl,strVarName+1 call PutSApp call dispVarType ld hl,0007h ld (curRow),hl ld hl,strNamePrompt call PutSApp _rdvStartOver: B_CALL CursorOff ld a,' ' ld (curUnder),a ld a,5 ld (curCol),a B_CALL EraseEOL B_CALL CursorOn ld hl,strVarName+1 ld b,20 _rdv2: ld (hl),0 inc hl djnz _rdv2 ld hl,strVarName+1 ld (wDataAddr),hl set lwrCaseActive,(iy+appLwrCaseFlag) _rdvGK: B_CALL GetKey cp kQuit jr z,quitTransmission cp kClear jr z,_rdvStartOver cp kLeft jr z,_rdvLeft cp kRight jr z,_rdvRight cp kEnter jr z,_rdvStoreName cp kUp jr z,_rdvMoveStart cp kDown jr z,_rdvMoveEnd cp 0CCh jr z,_rdvThetaPressed cp kDel jr z,_rdvDeleteChar cp 08Eh jp m,_rdvChkULetters cp 98h jp p,_rdvChkULetters sub 5Eh push af ld a,(curCol) cp 5 pop bc ld a,b jr z,_rdvChkULetters call _rdvUpdDispChar _rdvChkULetters: cp 9Ah jp m,_rdvChkLLetters cp 0B4h jp p,_rdvChkLLetters sub 59h call _rdvUpdDispChar _rdvChkLLetters: cp 0FCh jr nz,_rdvGK ld a,(keyExtend) cp k83_00End+73 jp m,_rdvGK cp k83_00End+99 jp p,_rdvGK sub 81h call _rdvUpdDispChar jr _rdvGK _rdvThetaPressed: ld a,05Bh call _rdvUpdDispChar jr _rdvGK _rdvUpdDispChar: push af B_CALL CursorOff pop af ld hl,(wDataAddr) ld (hl),a inc hl ld (wDataAddr),hl B_CALL PutC ld a,(curCol) cp 13 jr nz,_rdvUpdDispChar2 dec a ld (curCol),a ld hl,(wDataAddr) dec hl ld (wDataAddr),hl ld a,(curCol) _rdvUpdDispChar2: sub 5 ld d,0 ld e,a ld hl,strVarName+1 add hl,de ld a,(hl) ld (curUnder),a B_CALL CursorOn ret _rdvLeft: ld a,(curCol) cp 5 jr z,_rdvGK push af B_CALL CursorOff pop af ld hl,(wDataAddr) dec hl ld (wDataAddr),hl dec a jr _rdvStorePos _rdvRight: ld a,(curCol) cp 12 jr z,_rdvGK ld hl,(wDataAddr) ld a,(hl) or a jr z,_rdvGK B_CALL CursorOff inc hl ld (wDataAddr),hl ld a,(curCol) inc a _rdvStorePos: ld (curCol),a sub 5 ld d,0 ld e,a ld hl,strVarName+1 add hl,de ld a,(hl) ld (curUnder),a B_CALL CursorOn jr _rdvGK _rdvDeleteChar: ld hl,(wDataAddr) ld a,(hl) or a jr z,_rdvGK B_CALL CursorOff ld a,(curCol) push af ld hl,(wDataAddr) ld b,10 _rdv3: inc hl ld a,(hl) or a jr z,_rdv3Done dec hl ld (hl),a B_CALL PutC inc hl djnz _rdv3 _rdv3Done: ld b,10 dec hl _rdv4: ld (hl),0 inc hl djnz _rdv4 B_CALL EraseEOL ld hl,(wDataAddr) ld a,(hl) ld (curUnder),a pop af ld (curCol),a B_CALL CursorOn jr _rdvGK _rdvMoveStart: B_CALL CursorOff ld a,5 ld (curCol),a ld hl,strVarName+1 ld (wDataAddr),hl ld a,(hl) ld (curUnder),a B_CALL CursorOn jr _rdvGK _rdvMoveEnd: B_CALL CursorOff ld hl,strVarName+1 ld a,5 ld (curCol),a _rdv5: ld a,(curCol) inc a ld (curCol),a ld a,(hl) or a inc hl jr nz,_rdv5 ld a,(curCol) cp 14 jr nz,_rdv6 dec a ld (curCol),a ld hl,strVarName+8 _rdv6: dec hl ld a,(curCol) dec a ld (curCol),a ld a,(hl) ld (wDataAddr),hl or a jr nz,_rdv7 ld a,' ' ld (curUnder),a _rdv7: B_CALL CursorOn jr _rdvGK _rdvStoreName: B_CALL CursorOff ld hl,linkFailed call APP_PUSH_ERRORH ld hl,strVarName rst 20h B_CALL ChkFindSym jr c,_rdvsn1 B_CALL DelVarArc _rdvsn1: call APP_POP_ERRORH B_CALL ClrLCDFull B_CALL RunIndicOn ld hl,0 ld (curRow),hl ld a,Lconvert B_CALL PutC ld hl,curCol inc (hl) ld hl,strVarName+1 call PutSApp call dispVarType _cancelRename: res shiftKeepAlph,(iy+shiftFlags) B_CALL CanAlphIns res lwrCaseActive,(iy+appLwrCaseFlag) B_CALL RunIndicOn ld hl,linkFailed call APP_PUSH_ERRORH jr receiveContinue overwriteAllVars: set overwriteAll,(iy+xlinkFlags) overwriteDuplicateVar: B_CALL ClrLCDFull ld hl,0 ld (curRow),hl ld a,Lconvert B_CALL PutC ld hl,curCol inc (hl) ld hl,strVarName+1 call PutSApp call dispVarType jr _cancelRename skipDuplicateVar: ld hl,linkFailed call APP_PUSH_ERRORH B_CALL ClrLCDFull B_CALL RunIndicOn ld hl,0 ld (curRow),hl ld a,(bMachineID) B_CALL SendAByte ld a,36h B_CALL SendAByte ld a,01h B_CALL SendAByte xor a B_CALL SendAByte ld a,02h B_CALL SendAByte ld a,02h B_CALL SendAByte xor a B_CALL SendAByte B_CALL RecAByteIO B_CALL RecAByteIO cp 56h jr nz,forceLinkErr B_CALL RecAByteIO B_CALL RecAByteIO B_CALL RecAByteIO B_CALL RecAByteIO cp 06h jr z,receiveVarHeader cp 92h jr z,receiveEOT jr forceLinkErr quitTransmission: B_CALL CursorOff ld hl,linkFailed call APP_PUSH_ERRORH B_CALL ClrLCDFull B_CALL RunIndicOn ld hl,0 ld (curRow),hl ld a,(bMachineID) B_CALL SendAByte ld a,36h B_CALL SendAByte ld a,01h B_CALL SendAByte xor a B_CALL SendAByte ld a,01h B_CALL SendAByte ld a,01h B_CALL SendAByte xor a B_CALL SendAByte B_CALL RecAByteIO B_CALL RecAByteIO cp 56h jr nz,forceLinkErr B_CALL RecAByteIO B_CALL RecAByteIO jr transferDone bDummyVar: db AppVarObj,01h,0 bFixNamesTable: db "Func",0,0 db "Pol",0,0,0 db "Param",0 db "DifEq",0 db "ZRCL",0 b86SeriesTable: db "REAL",0,0 db "CPLX",0,0 db "VECT",0,0 db "VECT",0,0 db "LIST",0,0 db "LIST",0,0 db "MATRX",0 db "MATRX",0 db "CONS",0,0 db "CONS",0,0 db "EQU",0,0,0 db 0,0,0,0,0,0 db "STRNG",0 db "GDB",0,0,0 db "GDB",0,0,0 db "GDB",0,0,0 db "GDB",0,0,0 db "PIC",0,0,0 db "PRGM",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 "WIND",0,0 db "WIND",0,0 db "WIND",0,0 db "WIND",0,0 db "WIND",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 0,0,0,0,0,0 db "EQU",0,0,0 b89SeriesTable: db "EXPR",0,0 db 0,0,0,0,0,0 db 0,0,0,0,0,0 db 0,0,0,0,0,0 db "LIST",0,0 db 0,0,0,0,0,0 db "MATRX",0 db 0,0,0,0,0,0 db 0,0,0,0,0,0 db 0,0,0,0,0,0 db "DATA",0,0 db "TEXT",0,0 db "STRNG",0 db "GDB",0,0,0 db "FIG",0,0,0 db 0,0,0,0,0,0 db "PIC",0,0,0 db 0,0,0,0,0,0 db "PRGM",0,0 db "FUNC",0,0 db "MACRO",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 "ASM",0,0,0 strNamePrompt: db "Name=",0 strSelect: db "SELECT",0 strTransmit: db "TRANSMIT",0 strTransmitText: db "Transmit",0 strSending: db "Sending",0CEh,0 strWaiting: db "Waiting...",0 strReceiving: db "Receiving",0CEh,0 bMemErrMenu: db "ERR:MEMORY",0,1 db "Quit",0,0,0,0,0,0,0,0,0,0,0,0 dw startApp bLinkErrMenu: db "ERR:LINK",0,1 db "Quit",0,0,0,0,0,0,0,0,0,0,0,0 dw startApp bDuplicateVarMenu: db "Duplicate Var",0,5 db "Rename",0CEh,0,0,0,0,0,0,0,0,0 dw renameDuplicateVar db "Overwrite",0,0,0,0,0,0,0 dw overwriteDuplicateVar db "Overwrite All",0,0,0 dw overwriteAllVars db "Skip",0,0,0,0,0,0,0,0,0,0,0,0 dw skipDuplicateVar db "Quit",0,0,0,0,0,0,0,0,0,0,0,0 dw quitTransmission bSendMenu: db "SEND",0,6 db "To TI-85",0CEh,0,0,0,0,0,0,0 dw Send85Menu db "To TI-86",0CEh,0,0,0,0,0,0,0 dw Send86Menu db "To TI-89",0CEh,0,0,0,0,0,0,0 dw Send89Menu db "To TI-92",0CEh,0,0,0,0,0,0,0 dw Send92Menu db "To TI-92 Plus",0CEh,0,0 dw Send92PlusMenu db "To Voyage 200",0CEh,0,0 dw SendVoy200Menu bRecvMenu: db "RECEIVE",0,2 db "Recv to RAM",0CEh,0,0,0,0 dw RecvToRAM db "Recv to Flash",0CEh,0,0 dw RecvToFlash