;Send Nspire/CAS AppVar to device include "settings.inc" include "ti83plus.inc" include "equates.inc" include "usb8x.inc" SEGMENT Main GLOBALS ON Public PutFileUI EXTERN DialogBox,vputstring,FunkyLine,VEraseEOL,IGetKey,IPutS,DispHexHL,strcpy EXTERN DisplayDirectory,USBError,NavNetPutFile,DisplayWaitScreen,DispHexA EXTERN currentPath,sOK PutFileUI: ld bc,0 ld (iMathPtr5),bc $$: call Traverse_symTable jr c,$F ld bc,(iMathPtr5) inc bc ld (iMathPtr5),bc jr $B $$: ld bc,(iMathPtr5) ld a,b or c jr z,DisplayDirectory dec bc ld (iMathPtr5),bc ;Draw the main dialog ld l,3 ld h,15 ld e,89 ld d,47 call DialogBox ld bc,3*256+24 ld e,88 call FunkyLine ld hl,16*256+6 ld (penCol),hl ld hl,sAddText call vputstring ld hl,24*256+6 ld (penCol),hl ld hl,sAdd1 call vputstring ld hl,31*256+6 ld (penCol),hl ld a,0CFh B_CALL VPutMap ld hl,31*256+84 ld (penCol),hl ld a,Lconvert B_CALL VPutMap ld hl,40*256+42 ld (penCol),hl ld hl,sOK call vputstring ld bc,3*256+40 ld e,88 call FunkyLine Add_Display: ld bc,(iMathPtr5) call Traverse_symTable ld hl,31*256+10 ld (penCol),hl ld hl,OP1+1 call vputstring ld c,55 call VEraseEOL ld a,60 ld (penCol),a ld hl,sAVAR call vputstring ld c,83 call VEraseEOL Add_KeyLoop: call IGetKey cp kClear jr z,DisplayDirectory cp kQuit jr z,DisplayDirectory cp kLeft jr z,Add_MoveLeft cp kRight jr z,Add_MoveRight cp kEnter jr z,Add_DoTheDew jr Add_KeyLoop Add_MoveLeft: ld bc,(iMathPtr5) inc bc call Traverse_symTable jr c,Add_KeyLoop ld bc,(iMathPtr5) inc bc ld (iMathPtr5),bc jr Add_Display Add_MoveRight: ld bc,(iMathPtr5) dec bc call Traverse_symTable jr c,Add_KeyLoop ld bc,(iMathPtr5) dec bc ld (iMathPtr5),bc jr Add_Display Add_DoTheDew: call DisplayWaitScreen ;Send the AppVar's data to the device ld bc,(iMathPtr5) call Traverse_symTable ld hl,currentPath ld de,appBackUpScreen+512 call strcpy dec de ;Now pointing at the zero dec de ld a,(de) inc de cp '/' ;is the last character a slash? jr z,$F ;No, so add one ld a,'/' ld (de),a inc de $$: ld hl,OP1+1 call strcpy dec de ;Now pointing at the zero ex de,hl ;Write ".tns" extension to file name ld (hl),'.' inc hl ld (hl),'t' inc hl ld (hl),'n' inc hl ld (hl),'s' inc hl ld (hl),0 B_CALL ChkFindSym ex de,hl ld a,b or a jr z,$F ld de,9 call BHL_plus_DE call myLoadCIndPaged ld d,0 ld e,c call BHL_plus_DE $$: ;BHL points to the size bytes call myLoadCIndPaged push bc call myLoadCIndPaged pop de ld d,c call myLoadCIndPaged ;skip past the two AppVar ID bytes call myLoadCIndPaged ;DE is the data size dec de dec de push de pop ix ld de,appBackUpScreen+512 call NavNetPutFile jr c,USBError jr DisplayDirectory sAddText: DB "ADD FILE...",0 sAdd1: DB "Select variable:",0 sAdding: DB "COPYING",0CEh,0 sAVAR: DB "AVAR",0 Traverse_symTable: ;Inputs: BC: the variable number to get ;Outputs: OP1: variable name found ; Returns carry flag set if nothing found ld hl,symTable ld (iMathPtr4),hl inc bc tstBegin2: ld hl,(iMathPtr4) tstBegin: push hl ld de,(pTemp) or a sbc hl,de pop hl ret c jr nz,$F scf ret $$: push bc 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 push hl ld hl,OP1 ld de,OP2 ld bc,11 ldir pop hl pop bc 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 nz,tstContinue ld a,(OP1+1) cp 5Ch jp p,tstBegin jr tstContinue $$: ld a,(OP1+1) cp 30h jp m,tstBegin tstContinue: ld a,(OP1) cp AppVarObj jr nz,tstBegin ld (iMathPtr4),hl ;See if this is a variable we care about push bc B_CALL ChkFindSym ex de,hl ld a,b or a jr z,$F ld de,9 call BHL_plus_DE call myLoadCIndPaged ld d,0 ld e,c call BHL_plus_DE $$: ;BHL points to the size bytes call myLoadCIndPaged push bc call myLoadCIndPaged pop de ld d,c ;DE is the data size ld a,b ld (83EBh),a pop bc ld a,d or e jr z,tstBegin2 dec de ld a,d or e jr z,tstBegin2 ;We know we're at least 2 bytes big now push bc ld a,(83EBh) ld b,a call myLoadDEIndPaged ;Check to see if this is our header ld hl,3532h B_CALL cphlde ex de,hl pop bc jr nz,tstBegin2 ld hl,(iMathPtr4) dec bc ld a,b or c jr nz,tstBegin ld hl,OP2 ld de,OP1 ld bc,11 ldir ret 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