Difference between revisions of "ACU March 1985 - Type-ins"
From CPCWiki - THE Amstrad CPC encyclopedia!
Line 32: | Line 32: | ||
image:pascal3_2.png | image:pascal3_2.png | ||
</gallery> | </gallery> | ||
+ | |||
+ | =Unerase= | ||
+ | The Z80 assembler code for David Link's Unerase program. | ||
+ | <pre> | ||
+ | ; Unerase a file in CP/M - 04/11/84 | ||
+ | ; Copyright David Link 1984 | ||
+ | |||
+ | ; A program to unerase a file that has been accidentally | ||
+ | ; erased. Should be used immediately after erasing the | ||
+ | ; file since if user later, some blocks may have been re-used. | ||
+ | |||
+ | ; Format is - UNERA filename | ||
+ | |||
+ | DEFCB EQU &5C | ||
+ | |||
+ | fnamelen EQU 8 | ||
+ | extlen EQU 3 | ||
+ | extent EQU 12 | ||
+ | dirlen EQU 32 | ||
+ | |||
+ | ; CP/M BDOS call numbers | ||
+ | |||
+ | OPEN EQU 15 | ||
+ | CLOSE EQU 16 | ||
+ | SEARCH EQU 17 | ||
+ | SRCH_AGAIN EQU 18 | ||
+ | MAKE EQU 22 | ||
+ | SETDMA EQU 26 | ||
+ | |||
+ | ; Default workspace for file reads | ||
+ | |||
+ | tbuff EQU 128 | ||
+ | |||
+ | ; Macro to call CP/M setting DE and C | ||
+ | |||
+ | DOS MAC | ||
+ | LD DE,=0 | ||
+ | LD C,=1 | ||
+ | CALL Dos | ||
+ | ENDM | ||
+ | |||
+ | ; Macro to call CP/M setting C. | ||
+ | |||
+ | SDOS MAC | ||
+ | LD C,=0 | ||
+ | CALL Dos | ||
+ | ENDM | ||
+ | |||
+ | ; COM files begin at &100 | ||
+ | |||
+ | ORG &100 | ||
+ | |||
+ | LD SP,(6) ; set stack to top of TPA | ||
+ | DOS DEFCB,SEARCH ; Does file exist? | ||
+ | INC A | ||
+ | JP NZ,0 ; File exists, return to CCP | ||
+ | LD HL,FCBSPACE ; Initialise pointer to current FCB | ||
+ | LD (FCBPTR),HL | ||
+ | DOS tbuff,SETDMA ; set disc I/O to tbuff | ||
+ | DOS DUMFCB,SEARCH ; and search for the first entry in directory | ||
+ | |||
+ | More_Search INC A | ||
+ | JR Z,End_of_Directory ; No more entries | ||
+ | |||
+ | ; Compare found filename with the required filename | ||
+ | |||
+ | Continue DEC A ; adjust because we INCed it | ||
+ | ADD A,A ; multiply by dirlen to get postion | ||
+ | ADD A,A ; of entry in catalogue | ||
+ | ADD A,A | ||
+ | ADD A,A | ||
+ | ADD A,A | ||
+ | LD D,0 | ||
+ | LD E,A | ||
+ | LD HL,tbuff ; point to found file | ||
+ | ADD HL,DE | ||
+ | |||
+ | Again PUSH HL ; and compare it with required filename | ||
+ | INC HL | ||
+ | LD B,fnamelen+extlen ; both name and type (8, name : 3, type) | ||
+ | LD DE,DEFCB+1 ; filename starts at FCB + 1 | ||
+ | |||
+ | Match LD A,(DE) | ||
+ | LD C,(HL) | ||
+ | RES 7,C ; some CP/Ms set bits on filename | ||
+ | CP C ; so make sure top bit is reset for comparison | ||
+ | INC HL | ||
+ | INC DE | ||
+ | JR NZ,NoMatch ; not this one | ||
+ | DJNZ Match ; good so far... keep going | ||
+ | |||
+ | ; Match found | ||
+ | |||
+ | POP HL ; filename match, but... | ||
+ | PUSH HL | ||
+ | LD A,(HL) ; ... is it erased? | ||
+ | CP &E5 ; e% in first byte of directory = erased | ||
+ | JR NZ,NoMatch ; not erased... so search some more | ||
+ | LD (HL),0 ; it was erased, so unerase it | ||
+ | LD DE,(FCBPTR) ; and store the FCB information in | ||
+ | LD BC,dirlen ; our temporary table | ||
+ | LDIR | ||
+ | LD (FCBPTR),DE ; updating our table pointer afterwards | ||
+ | |||
+ | ; Search for another entry | ||
+ | |||
+ | NoMatch POP HL | ||
+ | DOS DUMFCB,SRCH_AGAIN ; search for next entry in directory | ||
+ | JR More_Search | ||
+ | |||
+ | ; we have now exhausted the directory search and built | ||
+ | ; up our table of directory entries for the required file | ||
+ | |||
+ | End_of_Dir LD DE,FCBSPACE ; start processing table of matched | ||
+ | ; directory entries | ||
+ | MAIN_LOOP LD HL,(FCBPTR) ; have we reached end of table? | ||
+ | OR A | ||
+ | SBC HL,DE | ||
+ | JP Z,0 ; finished, so return | ||
+ | PUSH DE ; save table pointer | ||
+ | LD HL,extent ; address extent byte | ||
+ | ADD HL,DE | ||
+ | LD A,(HL) ; make an extent of new, | ||
+ | LD (DEFCB+extent),a ; unerased file... | ||
+ | DOS DEFCB,MAKE | ||
+ | POP DE ; recover pointer to FCB... | ||
+ | SDOS CLOSE ; and close it | ||
+ | LD HL,dirlen | ||
+ | ADD HL,DE ; have we reached end of table? | ||
+ | EX DE,HL | ||
+ | JR MAIN_LOOP | ||
+ | |||
+ | Dos PUSH HL | ||
+ | PUSH DE | ||
+ | PUSH BC | ||
+ | CALL 5 | ||
+ | POP BC | ||
+ | POP DE | ||
+ | POP HL | ||
+ | RET | ||
+ | |||
+ | FCBPTR DEFS 2 | ||
+ | |||
+ | DUMFCB DEFM "????????????" | ||
+ | DEFW 0,0 | ||
+ | DEFS 16 | ||
+ | DEFW 0,0 | ||
+ | |||
+ | FCBSPACE EQU $ | ||
+ | </pre> | ||
IN PROGRESS<br/> | IN PROGRESS<br/> |
Revision as of 23:53, 26 April 2009
Return to ACU Type-Ins
Contents
Downloads
Cover Image
Jeremy Vine's music routine
To run Jeremy Vine's music routine, type:
RUN"MUSIC"
Number Sort routine
To run Number Sort routine, type:
RUN"SORT"
Prime Numbers
To run Prime Numbers, type:
RUN"PASCAL3"
Unerase
The Z80 assembler code for David Link's Unerase program.
; Unerase a file in CP/M - 04/11/84 ; Copyright David Link 1984 ; A program to unerase a file that has been accidentally ; erased. Should be used immediately after erasing the ; file since if user later, some blocks may have been re-used. ; Format is - UNERA filename DEFCB EQU &5C fnamelen EQU 8 extlen EQU 3 extent EQU 12 dirlen EQU 32 ; CP/M BDOS call numbers OPEN EQU 15 CLOSE EQU 16 SEARCH EQU 17 SRCH_AGAIN EQU 18 MAKE EQU 22 SETDMA EQU 26 ; Default workspace for file reads tbuff EQU 128 ; Macro to call CP/M setting DE and C DOS MAC LD DE,=0 LD C,=1 CALL Dos ENDM ; Macro to call CP/M setting C. SDOS MAC LD C,=0 CALL Dos ENDM ; COM files begin at &100 ORG &100 LD SP,(6) ; set stack to top of TPA DOS DEFCB,SEARCH ; Does file exist? INC A JP NZ,0 ; File exists, return to CCP LD HL,FCBSPACE ; Initialise pointer to current FCB LD (FCBPTR),HL DOS tbuff,SETDMA ; set disc I/O to tbuff DOS DUMFCB,SEARCH ; and search for the first entry in directory More_Search INC A JR Z,End_of_Directory ; No more entries ; Compare found filename with the required filename Continue DEC A ; adjust because we INCed it ADD A,A ; multiply by dirlen to get postion ADD A,A ; of entry in catalogue ADD A,A ADD A,A ADD A,A LD D,0 LD E,A LD HL,tbuff ; point to found file ADD HL,DE Again PUSH HL ; and compare it with required filename INC HL LD B,fnamelen+extlen ; both name and type (8, name : 3, type) LD DE,DEFCB+1 ; filename starts at FCB + 1 Match LD A,(DE) LD C,(HL) RES 7,C ; some CP/Ms set bits on filename CP C ; so make sure top bit is reset for comparison INC HL INC DE JR NZ,NoMatch ; not this one DJNZ Match ; good so far... keep going ; Match found POP HL ; filename match, but... PUSH HL LD A,(HL) ; ... is it erased? CP &E5 ; e% in first byte of directory = erased JR NZ,NoMatch ; not erased... so search some more LD (HL),0 ; it was erased, so unerase it LD DE,(FCBPTR) ; and store the FCB information in LD BC,dirlen ; our temporary table LDIR LD (FCBPTR),DE ; updating our table pointer afterwards ; Search for another entry NoMatch POP HL DOS DUMFCB,SRCH_AGAIN ; search for next entry in directory JR More_Search ; we have now exhausted the directory search and built ; up our table of directory entries for the required file End_of_Dir LD DE,FCBSPACE ; start processing table of matched ; directory entries MAIN_LOOP LD HL,(FCBPTR) ; have we reached end of table? OR A SBC HL,DE JP Z,0 ; finished, so return PUSH DE ; save table pointer LD HL,extent ; address extent byte ADD HL,DE LD A,(HL) ; make an extent of new, LD (DEFCB+extent),a ; unerased file... DOS DEFCB,MAKE POP DE ; recover pointer to FCB... SDOS CLOSE ; and close it LD HL,dirlen ADD HL,DE ; have we reached end of table? EX DE,HL JR MAIN_LOOP Dos PUSH HL PUSH DE PUSH BC CALL 5 POP BC POP DE POP HL RET FCBPTR DEFS 2 DUMFCB DEFM "????????????" DEFW 0,0 DEFS 16 DEFW 0,0 FCBSPACE EQU $
IN PROGRESS
IN PROGRESS
IN PROGRESS
IN PROGRESS
IN PROGRESS
IN PROGRESS
IN PROGRESS
IN PROGRESS
IN PROGRESS
IN PROGRESS
Electric Eddy
To run Electric Eddy, type:
RUN"EDDY"
Electric Fencing
To run Electric Fencing, type:
RUN"FENCING"
Flashman
To run Flashman, type:
RUN"FLASHMAN"
Machine code fill routine and demonstration
To run Machine code fill routine and demonstration, type:
RUN"MCFILL"
Trench
To run Trench, type:
RUN"TRENCH"