
A disc starts whatever its header points at. DISKMON can write sectors. So DISKMON can make a disc start DISKMON.
DISKMON is assembled to run at 0100h. If the MOS loads it there at power-on, nothing in it needs to change. The header has to be loaded too - it is the first seven bytes at the start address - so put the start address seven bytes early, at 00F9h: the header fills 00F9h-00FFh, and DISKMON's first byte lands at 0100h.
| Header field | Value |
|---|---|
| Start | 00F9h |
| End | LAST, a label on DISKMON's very last byte |
| Jump | 0100h, where START is |
| Side | 0 |
B writes those seven bytes into memory at 00F9h, then writes memory
from 00F9h onwards to drive 1, track 0, sectors 0, 1, 2... - as many as it
takes to reach LAST, which the assembler works out: (LAST-00F9H)/512+1.
Write that sum straight into the instructions that need it. If you give
it a name with EQU above LAST, z80asm makes it 0 without a word of
warning, because it has not seen LAST yet.
When the disc boots, the MOS loads DISKMON and jumps to 0100h. There is
no DOS: no 0:, nothing at 0005h. START still keeps the stack pointer
it was given and switches to its own, the MOS calls DISKMON makes for
keys, printing and sectors are all still there - and S, D and L
work. Its BDOS commands do not, and S21 deals with that.
After the line JP Z,CMDU, add:
CP 'B'
JP Z,CMDB
After the last line of CMDU (JP CRMAIN), add:
; B: make the disc in drive 1 start DISKMON. A header goes in the 7
; bytes before 0100h - start 00F9h, end LAST, jump 0100h, side 0 - and
; from 00F9h on, as many sectors as that takes are written to track 0.
CMDB: LD HL,00F9H
LD (HL),0F9H ; start: 00F9h
INC HL
LD (HL),00H
INC HL
LD DE,LAST
LD (HL),E ; end: LAST
INC HL
LD (HL),D
INC HL
LD (HL),00H ; jump: 0100h
INC HL
LD (HL),01H
INC HL
LD (HL),0 ; side: 0
LD A,1
LD (0FB50H),A
XOR A
LD (0FB51H),A
LD HL,00F9H
LD B,(LAST-00F9H)/512+1 ; sectors from 00F9h to LAST
LD C,0
CMDB1: LD A,C
LD (0FB52H),A
LD (0FB53H),HL
PUSH BC
PUSH HL
RST 8
DEFB 163
POP HL
POP BC
JP NZ,DISCERR
INC H
INC H
INC C
DJNZ CMDB1
LD L,(LAST-00F9H)/512+1
LD H,0
CALL PDEC
LD HL,BOOTM
JP DONE
After the line SIDEM: DEFB ' SIDE ',0, add:
BOOTM: DEFB ' SECTORS WRITTEN TO TRACK 0',13,10,0
After the line BOOTM: DEFB ' SECTORS WRITTEN TO TRACK 0',13,10,0, add:
LAST: DEFB 0 ; the last byte the boot loads
Run it: make work.mfi from PRIMER.DSK with DISKMON on it (S10),
run DISKMON from it under XtalDOS, and type:
B
Q
> B
5 SECTORS WRITTEN TO TRACK 0
>
Quit MAME. Now start it with work.mfi in drive 0 and nothing else:
mame -rompath ~/roms einstein -window -nomaximize -ui_active -skip_gameinfo -flop1 work.mfi
What you should see - no XtalDOS sign-on, DISKMON's own prompt. Then
D 0:
> D 0
POEM .TXT EXTENT 0 RECORDS 3
ROOMS .DAT EXTENT 0 RECORDS 128
ROOMS .DAT EXTENT 1 RECORDS 72
DISKMON .COM EXTENT 0 RECORDS 17
>
DISKMON, started by the Einstein itself, reading its own disc's directory. The disc's files are untouched: tracks 0 and 1 are not part of the filesystem.
U 1 after B. What start, end and jump will it show?T 0:POEM.TXT. What will happen, and why? (Save anything
you care about first.)A seven-byte header at 00F9h and five sectors of track 0: DISKMON starts straight from the disc, with the MOS and nothing else.
S21: life with no BDOS - what DISKMON must stop doing, and what memory it now has.
This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.