; Gets everything up and running Initialize: call _RunIndicOff xor a \ sbc hl,hl ld (currLine),hl ld (selFile),a ld (prevSel),a ld (scrollOffset),a ; Reset Stuff cpl ld bc,256*2 ld hl,mpLcdPalette call _MemSet jp setup8bppMode Redraw: call clearVBuf2 drawRectFilled(0,0,320,20) drawSpr255(icon_sprite,3,3) changeFGColor(1) changeBGColor(0) print(PgrmName, 20, 5) call getTable DrawFilesLoop: call ResetForNew changeFGColor(0) changeBGColor(1) xor a ld (numFiles),a ld (fullNumFiles),a ld a,20-5 ld (posY),a ld hl,fileLocations ld (saveLocations),hl ld hl,(progPtr) ld a,(scrollOffset) or a jr z,NoScrollOffset ld b,a ScrollToFindStartFile: push bc ld ix,progSearchHeader call fdetect pop bc jp nz,NoScrollOffset ld a,(fullNumFiles) inc a ld (fullNumFiles),a djnz ScrollToFindStartFile NoScrollOffset: ScanFindNextFile: ld de,(saveLocations) ex de,hl ld (hl),de ex de,hl inc de inc de inc de ld (saveLocations),de ld ix,progSearchHeader call fdetect ld (curSearchFile),hl jr nz,FoundAllFiles ; No more files push hl ld hl,numFiles inc (hl) ld hl,fullNumFiles inc (hl) ld a,(numFiles) pop hl cp maxLines jr nz,notHitMax jr FoundAllFiles notHitMax: ld a,(posY) add a,13 ld (posY),a ld bc,14 ld (posX),bc ex de,hl call DrawLine20 ld hl,(curSearchFile) jr ScanFindNextFile FoundAllFiles: ld hl,(curSearchFile) CountAllFiles: ld ix,progSearchHeader call fdetect jr nz,countedAllFiles ld a,(fullNumFiles) inc a ld (fullNumFiles),a jr CountAllFiles NoFiles: changeFGColor(0) changeBGColor(1) print(NoFilesStr, 6, 33-5) call FullBufCpy _: call _GetCSC cp skyequ jp z,GetNextFileName cp skClear jp z,FullExit cp skGraph jp z,FullExit jr -_ countedAllFiles: drawRectFilled(0,225,320,240) changeFGColor(1) changeBGColor(0) ld ($D40000+(320*240)-1),a print(NewStr, 3, 230) print(ExitStr, 284, 230) ld a,(numFiles) or a jp z,NoFiles changeFGColor(1) changeBGColor(0) print(RenameStr, 58, 230) print(DeleteStr, 133, 230) changeFGColor(0) changeBGColor(1) ld a,(selFile) ld b,a ld a,(scrollOffset) add a,b inc a ld (absScrollPos),a ld a,(prevSel) ld hl,ExtraSpace ld b,2 DrawBulletLoop: push bc or a jr z,First ld b,a xor a Add: add a,13 djnz Add First: add a,33-5 ; Offset ld bc,3 ld (posX),bc ld (posY),a ld a,(hl) call drawChar ld a,(selFile) ld hl,Arrow pop bc djnz DrawBulletLoop call fullbufcpy ;------------------------------------------------------------------ ; MainLoop ;------------------------------------------------------------------ noKeyPressedGUI: call _getCSC or a jr z,noKeyPressedGUI cp skyequ jp z,GetNextFileName cp skWindow jp z,getFileName cp skZoom jp z,deleteFile cp skDel jp z,deleteFile cp skClear jp z,FullExit cp skGraph jp z,FullExit cp skEnter jp z,loadAndDrawFile cp sk2nd jp z,loadAndDrawFile cp skUp jr nz,notGUIUp ld a,(selFile) or a jr nz,notOffTop ld a,(scrollOffset) or a jr z,noKeyPressedGUI ld (prevSel),a dec a ld (scrollOffset),a call ClearScreenPartial jp DrawFilesLoop notOffTop: ld (prevSel),a dec a ld (selFile),a jp DrawFilesLoop notGUIUp: dec a ; Down jr nz,noKeyPressedGUI ld a,(numFiles) ld b,a ld a,(selFile) ld (prevSel),a inc a cp maxLines-1 jr nz,notOffBottomScreen ld a,(absScrollPos) ld b,a ld a,(fullNumFiles) cp b jp z,noKeyPressedGUI ld a,(scrollOffset) inc a ld (scrollOffset),a call ClearScreenPartial jp DrawFilesLoop notOffBottomScreen: cp b jp z,noKeyPressedGUI ld (selFile),a jp DrawFilesLoop loadAndDrawFile: ld hl,safeMem ld bc,plotsscreen-safeMem-1 call _MemClear set saved,(iy+txtFlgs) drawRectFilled(0,225,320,240) changeFGColor(1) changeBGColor(0) print(SavedStr, 3, 230) print(ExitStr, 284, 230) res smallInput,(iy+txtFlgs) call ClearScreenPartial call LoadFile ld (textPtr),hl ld a,27 ld bc,1 ld (cursorYReal),a ld (cursorXReal),bc call Redrawtext xor a ld (alphaStatus),a call getTable jp ReturnHere