.nolist #include "ti84pce.inc" .list .org userMem-2 .db tExtTok,tAsm84CeCmp .assume ADL=1 ;------------------------------------------------------------------------------- userArchive equ $0C0000 itemBuffer equ cursorImage itemSize equ cursorImage+30 itemType equ cursorImage+33 saveSP equ cursorImage+34 ;------------------------------------------------------------------------------- _PrgmBegin: ld (saveSP),sp ;------------------------------------------------------------------------------- _SearchBegin: ; begins searching for deleted data ; each sector is 64kb in size ; if the sector's first byte is: ; $FE : it is a swap sector ; $F0 : it has data ; $FC : it has something? ; $FF : it has something more? ld hl,userArchive _SearchLoop: call _SetAToHLU cp a,$3B jp z,_SearchDone ld a,(hl) cp a,$F0 ; data sector, let's see if there is cool stuffs jr z,_ValidSector ; cp a,$FC ; maybe -- unused? ; jr z,_ValidSector ; cp a,$FF ; maybe -- unused? ; jr z,_ValidSector ; cp a,$FE ; swap sector, skip it ; jr z,_MoveToNextSector _MoveToNextSector: ld de,65536 add hl,de jr _SearchLoop ;------------------------------------------------------------------------------- _ValidSector: ; this scans the sector for any data. If a program is found, it is displayed ; hl is the starting address inc hl _SectorSearch: ld a,(hl) cp a,$FF ; end of sector; move to the next one jr z,_MoveToNextSector cp a,$F0 ; represents a deleted item in the archive jr z,_FoundDeletedItem cp a,$FC ; Check everythings jp nz,_ErrVarExtendsPastSector _UnknownData: inc hl call _LoadDEInd_s ; load the size of the data into de add hl,de jr _SectorSearch ; move to the next data block _FoundDeletedItem: push hl inc hl call _LoadDEInd_s ld (itemSize), de ld a,(hl) and a,3Fh ld (itemType), a cp a,progObj jr z,_FoundRecoverableItem cp a,protProgObj jr z,_FoundRecoverableItem cp a,appVarObj jr z,_FoundRecoverableItem pop hl jr _UnknownData ; move to the next data block _FoundRecoverableItem: ld de,6 ; name of deleted item is prefixed with size of name add hl,de ld de,itemBuffer push de ld bc,20 ldir pop hl ld a,(hl) ; contains the length of the string inc a call _AddHLAndA ld (hl),0 ld hl,20 call _EnoughMem jp c,_ErrLowMem call _ClrScrn call _HomeUp pop hl ; restore location to start of data push hl call _DispHL_HEX ; this is where the data is located in memory ld a,' ' call _PutC ld a,(itemType) cp a,ProtProgObj jr nz,+_ ld a,'p' jr _ShowItemName _: cp a,progObj jr nz,+_ ld a,'P' jr _ShowItemName _: ld a,'a' _ShowItemName: call _PutC ld a,' ' call _PutC ld hl,itemBuffer+1 call _PutS ld hl,(itemSize) call _DispHL_s call _NewLine ld hl,confirmUndelete call _DispStrings call _WaitForCSC jr z,_UndeleteItem cp a,sk2nd jr z,_UndeleteItem cp a,skMode jp z,_QuitNow pop hl jp _UnknownData _UndeleteItem: ld hl,itemBuffer call _Mov9ToOP1 ld a,(itemType) ld (OP1),a call _ChkFindSym jp c,_NotFound _ErrNameExists: push hl push de call _NewLine ld hl,1 ld.s (currow),hl ld hl,errNameExistsMsg call _DispStrings call _WaitForCSC pop de pop hl cp a,sk2nd jr nz,_NextItem call _DelVarArc ld hl,itemBuffer call _Mov9ToOP1 ld a,(itemType) ld (OP1),a _NotFound: ld hl,0 ld a,(itemType) call _CreateVar push hl ex de,hl ld de,2 call _DelMem pop hl dec hl dec hl dec hl pop de ld (hl),e dec hl ld (hl),d dec hl call _SetAToDEU ld (hl),a push de call _NewLine ld hl,undeletedMsg call _DispStrings call _NewLine call _WaitForCSC cp a,skClear jr z,_QuitNow cp a,skMode jr z,_QuitNow _NextItem: pop hl jp _UnknownData ;------------------------------------------------------------------------------- _SearchDone: ld hl,searchDoneMsg jr _MsgQuit _ErrLowMem: ld hl,errLowMemMsg jr _MsgQuit _ErrVarExtendsPastSector: ld hl,errVarExtendsPastSectorMsg _MsgQuit: push hl call _NewLine pop hl call _PutS call _WaitForCSC _QuitNow: ld sp,(saveSP) call _ClrScrn call _HomeUp res donePrgm,(iy + doneFlags) ret ;------------------------------------------------------------------------------- _WaitForCSC: ; waits for a key press ei halt call _GetCSC or a,a ret nz jr _WaitForCSC ;------------------------------------------------------------------------------- _DispStrings: ; displays an array of strings ld b,(hl) inc hl _: push bc call _PutS push hl call _NewLine pop hl pop bc djnz -_ ret ;------------------------------------------------------------------------------- _DispHL_HEX: ; Input: ; - HL ; Output: ; - Word displayed ; Destroys: ; - AF call _SetAToHLU call +_ ld a,h call +_ ld a,l _: push af rra rra rra rra call +_ pop af _: or a,$F0 daa add a,$0A0 adc a,$40 jp _PutC ;------------------------------------------------------------------------------- searchDoneMsg: .db "Search complete",0 confirmUndelete: .db 3 .db "2nd : Undelete",0 .db "Clear : Skip",0 .db "Mode : Quit",0 undeletedMsg: .db 2 .db "Sucsess!",0 .db "Recovered into archive",0 ;------------------------------------------------------------------------------- errLowMemMsg: .db "Insufficient memory",0 errNameExistsMsg: .db 3 .db "Already Exists ",0 .db "2nd : Overwrite",0 .db "Clear : Skip",0 errVarExtendsPastSectorMsg: .db "Archive error",0