;Get TNS/TNO file include "settings.inc" include "ti83plus.inc" include "equates.inc" include "usb8x.inc" SEGMENT Main GLOBALS ON PUBLIC GetFileUI EXTERN temp_file,bChoice,sOK,currentPath,selectedItem,IGetKey,IPutS,DisplayWaitScreen EXTERN DialogBox,FunkyLine,vputstring,fastCopy,IGetKey,DisplayDirectory EXTERN GetNamePointer,NavNetGetFile,USBError,dFileSize GetFileUI: ld l,13 ld h,15 ld e,79 ld d,47 call DialogBox ld bc,13*256+24 ld e,78 call FunkyLine ld hl,16*256+16 ld (pencol),hl ld hl,sCopyText call vputstring ld hl,40*256+41 ld (pencol),hl ld hl,sOK call vputstring ld bc,13*256+40 ld e,78 call FunkyLine xor a ld (bChoice),a DisplayOptions: ld hl,plotSScreen B_CALL SaveDisp ld hl,plotSScreen+12*25+2 ld b,10 ld de,7 $$: ld (hl),0 inc hl ld (hl),0 inc hl ld (hl),0 inc hl ld (hl),0 inc hl ld (hl),0 inc hl ld (hl),0 add hl,de djnz $B call fastCopy ld a,(bChoice) or a jr nz,getInFlash ld hl,28*256+20 jr $F getInFlash: ld hl,28*256+41 $$: ld (pencol),hl ld a,Lconvert B_CALL VPutMap ld a,24 ld (pencol),a ld hl,sRAMFlash call vputstring ld a,45 ld (pencol),a call vputstring getKeyLoop: call IGetKey cp kClear jr z,DisplayDirectory cp kQuit jr z,DisplayDirectory cp kEnter jr z,getEnterPressed cp kLeft jr z,$F cp kRight jr z,$F jr getKeyLoop $$: ld a,(bChoice) xor 1 ld (bChoice),a jr DisplayOptions getEnterPressed: call DisplayWaitScreen ;Full path is already at appBackUpScreen+512 (zero-terminated ASCII string) ;File size is double word at dFileSize (Little Endian) ;Get the 84+/SE compatible name of this file B_CALL CleanAll B_CALL ZeroOP1 ld hl,appBackUpScreen+512 $$: ld a,(hl) inc hl or a jr nz,$B push hl $$: dec hl ld a,(hl) cp '/' jr nz,$B inc hl pop bc dec bc ;now pointing to zero dec bc ;now pointing to 'S'/'O' dec bc ;now pointing to 'N' dec bc ;now pointing to 'T' dec bc ;now pointing to '.' ld de,OP1+1 ld b,8 $$: ld a,(hl) inc hl cp ' ' jr z,$B push hl or a sbc hl,bc pop hl jr z,$F ld (de),a inc de djnz $B $$: call ToUpperOP1 ;Delete it if it already exists B_CALL ChkFindSym jr c,$F B_CALL DelVarArc $$: ;See if we have enough memory, abort if not ld hl,(dFileSize+2) ld a,h or l jr nz,DisplayDirectory ;ERROR: >64KB, definitely not enough space ld de,(dFileSize) ld hl,0FFFFh-2 or a sbc hl,de jr c,DisplayDirectory ;ERROR: >64KB, definitely not enough space ;Get free RAM and Flash ld a,(bChoice) or a jr nz,checkFreeFlash B_CALL MemChk ld de,(dFileSize) inc de inc de or a sbc hl,de jr c,DisplayDirectory ;ERROR: not enough free RAM jr enoughMemoryFound checkFreeFlash: B_CALL ArcChk ld ix,839Fh ld a,(ix+0) ld l,(ix+1) or l jr nz,enoughMemoryFound ;We have more than 64KB free, so we should be good ld h,(ix+2) ld l,(ix+3) ld de,(dFileSize) inc de inc de or a sbc hl,de jr c,DisplayDirectory ;ERROR: not enough free Flash enoughMemoryFound: ;Get the file contents and store it ld a,AppVarObj ld (OP1),a ld hl,appBackUpScreen+512 ld a,(bChoice) ld b,a ld de,(dFileSize) call NavNetGetFile jr c,USBError jr DisplayDirectory ToUpperOP1: ld hl,OP1+1 ld b,8 tuOP1Loop: ld a,(hl) cp 'a' jp m,$F cp 'z'+1 jp p,$F sub 20h ld (hl),a $$: inc hl djnz tuOP1Loop ret sCopyText: DB "COPY FILE TO...",0 sRAMFlash: DB "RAM",0 DB "Archive",0