;Create new folder include "settings.inc" include "ti83plus.inc" include "equates.inc" include "usb8x.inc" SEGMENT Main GLOBALS ON PUBLIC CreateDirectory EXTERN DialogBox,FunkyLine,vputstring EXTERN DisplayDirectory,USBError,NavNetCreateDirectory EXTERN sOK,currentPath hook_temp EQU asm_ram temp_file EQU tempSwapArea+128 CreateDirectory: ;TODO: Consider adding a GetKey hook to add an ALPHA indicator to the top-right corner of the LCD ;Back up any existing key hook ld hl,9B84h ld de,hook_temp+1 ld bc,4 ldir xor a ld (hook_temp),a bit 5,(iy+34h) jr z,$F inc a ld (hook_temp),a $$: ;Install our temporary key hook ld hl,myKeyHook in a,(6) B_CALL EnRawKeyHook ;Draw the dialog box 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,sNewText call vputstring ld hl,40*256+41 ld (pencol),hl ld hl,sOK call vputstring ld hl,25*256+16 ld (pencol),hl ld hl,sNewText1 call vputstring ld bc,13*256+40 ld e,78 call FunkyLine ;Set up small edit buffer ld a,3 ld (SmallEditCancelParse),a ld a,20 ld (SmallEditColumnLeft),a ld a,75 ld (SmallEditColumnRight),a ld a,32 ld (SmallEditRow),a xor a ld (SmallEditPromptString),a inc a ld (SmallEditRowCount),a B_CALL InitSmallEditLine set shiftAlpha,(iy+shiftFlags) set shiftALock,(iy+shiftFlags) ;Get the input B_CALL StartSmallEdit ;Restore any previous key hook push af res 5,(iy+34h) ld hl,hook_temp+1 ld de,9B84h ld bc,4 ldir ld a,(hook_temp) or a jr z,$F set 5,(iy+34h) $$: pop af cp kQuit jr z,Add_Ret ;Get the filename to temp_file ld hl,temp_file ld bc,10 B_CALL MemClear B_CALL ChkFindSym ld a,(de) or a jr z,Add_Ret and 00001111b ld b,a inc de inc de ex de,hl ld de,temp_file New_CopyLoop: ld a,(hl) ld (de),a inc hl inc de djnz New_CopyLoop xor a ld (de),a B_CALL ReleaseSEdit ;Create directory with path temp_file ld hl,currentPath ld de,tempSwapArea $$: ld a,(hl) ld (de),a inc hl inc de or a jr nz,$B dec de ;now pointing at the zero ;Is the last character a /? dec de ld a,(de) inc de cp '/' jr z,$F ;No, so put one and then continue ld a,'/' ld (de),a inc de $$: ;Put our new directory name ld hl,temp_file $$: ld a,(hl) ld (de),a inc hl inc de or a jr nz,$B ld hl,tempSwapArea call NavNetCreateDirectory jr c,USBError jr Add_Quit Add_Ret: B_CALL ReleaseSEdit Add_Quit: jr DisplayDirectory myKeyHook: add a,e cp kDecPnt jr z,mkh_OK $$: cp kUp jr z,mkh_cancel cp kDown jr z,mkh_cancel cp kDel jr z,mkh_OK cp kEnter jr z,mkh_OK cp kLeft jr z,mkh_OK cp kRight jr z,mkh_OK cp kClear jr z,mkh_OK cp kQuit jr z,mkh_OK cp kSpace jr z,mkh_cancel cp kEE jr z,mkh_cancel cp k0 jp m,mkh_cancel cp kCapZ+1 jp m,mkh_OK mkh_cancel: xor a ret mkh_OK:or a ret sNewText: DB "NEW FOLDER...",0 sNewText1: DB "Enter folder name:",0