Here’s what the Cromix boot sector (for Cromix 11.27) looks like and why …
Display of File BOOT1.BIN 000000: 3E 01 D3 40 38 04 97 08 16 31 21 00 01 01 0F 02 >..@8....1!..... 000010: 3E 7F D3 04 7A D3 34 79 D3 30 97 3D 20 FD DB 34 >...z.4y.0.= ..4 000020: 1F 30 FB DB 30 E6 98 20 D7 78 D3 32 7A F6 80 D3 .0..0.. .x.2z... 000030: 34 0E 33 3E 9C D3 30 DB 34 1F 38 05 ED A2 C3 B7 4.3>..0.4.8..... 000040: 00 DB 30 CB 67 28 B9 C3 00 01 00 00 00 00 00 00 ..0.g(.......... 000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 000070: 00 00 00 00 00 00 00 00 43 4C 44 53 44 44 E5 E5 ........CLDSDD..
You can see the disk type label at bytes 120-127 (0x78..0x7F). It is a Cromix (“C”), Large (“L” aka 8 inch), double-sided (“DS”), double-density (“DD”) disk. If this isn’t present and correct then the boot sequence won’t work and parts of the OS and/or utilities will get things wrong. That doesn’t apply to early versions of CDOS or to CP/M but it does apply to CDOS 2.58 and Cromix.
It would be elegant if just changing those few bytes changed the behaviour of the boot sector so you could use the same program on all boot sectors; but it isn’t quite that good. Just looking above, you can see much of the sector is zeros – so there isn’t a lot of bytes for “smarts”. Despite that, it does have some tied to the “DS” and “DD” bits. Where it fails to adapt is if you copy (or WRTSYS) between disk sizes (5->8 or 8->5).
Here’s what the program does:
ORG 0080H 0080 3e 01 ld a,0x01 ; disable RDOS 0082 d3 40 out (0x40),a 0084 38 04 jr c,0x008a ; if CY use supplied 0086 97 sub a ; default disk=0 0087 08 ex af,af' ; save for later 0088 16 31 ld d,0x31 ; default cmd=motor+8"+A 008a 21 00 01 ld hl,0x0100 ; we're going to load to 100H 008d 01 0f 02 ld bc,0x020f ; B=sector 2, C=restore 0090 3e 7f ld a,0x7f ; select side 0 0092 d3 04 out (0x04),a 0094 7a ld a,d ; 31=motor+8"+A (or supplied) 0095 d3 34 out (0x34),a 0097 79 ld a,c ; cmd. 0F=restore+verify+slow 0098 d3 30 out (0x30),a 009a 97 sub a ; wait 256 009b 3d dec a 009c 20 fd jr nz,0x009b 009e db 34 in a,(0x34) ; wait for end of job, EOJ 00a0 1f rra 00a1 30 fb jr nc,0x009e 00a3 db 30 in a,(0x30) ; check result 00a5 e6 98 and 0x98 ; notRdy+notFound+busy 00a7 20 d7 jr nz,0x0080 ; problem. try again. CY=0 btw 00a9 78 ld a,b ; set sector (2 at start) 00aa d3 32 out (0x32),a 00ac 7a ld a,d ; motor+8"+A (or supplied) 00ad f6 80 or 0x80 ; turn on autowait 00af d3 34 out (0x34),a 00b1 0e 33 ld c,0x33 ; 33H is the disk data port 00b3 3e 9c ld a,0x9c ; read records, head load 00b5 d3 30 out (0x30),a ; send the cmd 00b7 db 34 in a,(0x34) ; check for EOJ 00b9 1f rra 00ba 38 05 jr c,0x00c1 ; read all sectors to end of track 00bc ed a2 ini ; read bytes to HL... 00be c3 b7 00 jp 0x00b7 ; loop until EOJ 00c1 db 30 in a,(0x30) ; check result 00c3 cb 67 bit 4,a ; the "not found" bit 00c5 28 b9 jr z,0x0080 ; error. try again 00c7 c3 00 01 jp 0x0100 ; all ok. run what we loaded. 00ca 00 nop 00cb 00 nop ... 00f6 00 nop 00f7 00 nop 00f8 43 4C 44 DB 'CLDSDD',0xe5,0xe5 00fb 53 44 44 00fe e5 e5
There’s a number of interesting things here:
– it only loads the rest of track 0 (CP/M and CDOS use tracks 0 and 1 for 8″ and 0-2 for 5″)
– it loads to 100H; instead of somewhere high
– despite my statement earlier, it doesn’t care about “CLDSDD”. (Other things do)
– it depends of the CY flag at startup (and A and D)
Cromix is loading into bank 0 of memory. It has all of bank 0 to itself, so it can load anywhere it likes. In CP/M and CDOS, 100H is reserved for user programs.
I don’t have (and haven’t created) a disassembly of RDOS0312; but there is one for RDOS0252. It contains:
C0FA: CALL ckesc ; look for escape CALL setsel LD D,A LD A,(77H) EX AF,AF' CALL ptfol DB CR,'Standby',CR+msbon SCF JP 80H
You can see the value in D getting created (setsel), a value being saved in A’, and SCF just before running the boot sector. “ptfol” prints the following bytes (until one with the most significant bit set, msbon=0x80). CRs get printed as CR, LF. “setsel” builds a bit combination based on whether you’re booting from an 8″ or 5″ drive, which drive it is, and whether it is single density or double density. All those smarts are in RDOS (probably just based on what you typed in as the RDOS command/s or defaults).
For my purposes, to boot without RDOS, I patch the boot.hex program I use with z80sim to “NOP-out” the “JR C, 008AH” line. This means it boots from a single density, 8″ track 0 in drivea.dsk. The image on the disk is unchanged so if you boot a disk within cromix – the SCF override still works.