; Disassembly of the CP/M boot sector for side 1 of the CPC6128 system discs ; (C/PM +) (Track 0, sector &41, side 0) ; ; Loading is done using "sector offset", which is the number of sectors from the start of the usable data ; i.e. after the reserved tracks ; ; Sector 0..3 is the disc directory, starting at track 2, sector &41. With 64 directory entries. ; Each directory entry takes 32 bytes. ; ; There should only be 1 EMS file on the disc. ; The EMS file is loaded to &c00 in RAM and then executed. ; ; This boot sector is hardcoded for CPC vendor/system format. ; A cluster is 2 sectors. ; ; NOTE: This uses the CPM 2.2 BIOS that is setup by AMSDOS. ; ; load directory into RAM 0100 110003 ld de,&0300 ;; load address 0103 210000 ld hl,&0000 ;; sector offset 0106 0604 ld b,&04 ;; read 4 sectors (length of sector) 0108 cd0102 call &0201 010b 3034 jr nc,&0141 ;; NC = disc read fail 010d 10f9 djnz &0108 ;; Load EMS file 010f cdc501 call &01c5 ;; Find first directory entry for ".EMS" file 0112 2064 jr nz,&0178 ;; Cannot find ".EMS" file 0114 11000c ld de,&0c00 ;; location to load them to ;; loop for each directory entry 0117 0610 ld b,&10 ;; number of clusters to load from this directory entry 0119 7e ld a,(hl) ;; get cluster index (0 used to pad list) 011a b7 or a 011b 281a jr z,&0137 011d e5 push hl 011e c5 push bc 011f 6f ld l,a 0120 2600 ld h,&00 0122 cdfc01 call &01fc ;; load cluster 0125 301a jr nc,&0141 0127 c1 pop bc 0128 e1 pop hl 0129 23 inc hl 012a 10ed djnz &0119 012c 212a02 ld hl,&022a 012f 34 inc (hl) ;; Increment "extent" in directory entry 0130 d5 push de 0131 cdc501 call &01c5 ;; find next directory entry for ".EMS" file with this ;; extent 0134 d1 pop de 0135 28e0 jr z,&0117 ;; no more entries have been found. ;; boot this program CP/M 0137 21000c ld hl,&0c00 013a 0eff ld c,&ff 013c cd9bbe call &be9b ;; ENTER_FIRMWARE defw &bd16 ;; MC START PROGRAM ;;---------------------------------------------------------------------------------------------------- 0141 214601 ld hl,&0146 0144 186b jr &01b1 0146 defb 13,10,"Discette read failure",13,10 defb "Press any key to restart",&ff ;;---------------------------------------------------------------------------------------------------- 0178 217d01 ld hl,&017d 017b 1834 jr &01b1 017d: defb 13,10,'Cannot find ".EMS" file',13,10 defb "Press any key to restart",&ff ;;---------------------------------------------------------------------------------------------------- ;; display message terminated with &ff byte, then wait for a key to be pressed ;; then performs reset 01b1 7e ld a,(hl) 01b2 23 inc hl 01b3 feff cp &ff 01b5 c45abb call nz,&bb5a ;; TXT OUTPUT 01b8 20f7 jr nz,&01b1 ;; clear keyboard buffer 01ba cd1bbb call &bb1b ;; KM READ KEY 01bd 38fb jr c,&01ba ;; now wait for char 01bf cd18bb call &bb18 ;; KM WAIT KEY ;; reset 01c2 cf rst &08 ;; RST 1: LOW JUMP defw 0 ;;---------------------------------------------------------------------------------------------------- ;; Find ".EMS" file in directory 01c5 210003 ld hl,&0300 ;; directory 01c8 0640 ld b,&40 ;; number of directory entries 01ca 7e ld a,(hl) ;; user number 01cb e6f0 and &f0 01cd 2022 jr nz,&01f1 01cf c5 push bc 01d0 e5 push hl 01d1 110d00 ld de,&000d 01d4 19 add hl,de 01d5 112b02 ld de,&022b 01d8 01ff0c ld bc,&0cff 01db 1b dec de 01dc 1a ld a,(de) 01dd 2b dec hl 01de ae xor (hl) 01df a1 and c 01e0 2809 jr z,&01eb 01e2 1a ld a,(de) 01e3 fe3f cp &3f ;; '?' 01e5 2008 jr nz,&01ef 01e7 7e ld a,(hl) 01e8 a1 and c 01e9 12 ld (de),a 01ea af xor a 01eb 0e7f ld c,&7f 01ed 10ec djnz &01db 01ef e1 pop hl 01f0 c1 pop bc 01f1 111000 ld de,&0010 01f4 19 add hl,de 01f5 c8 ret z 01f6 19 add hl,de 01f7 10d1 djnz &01ca 01f9 f6ff or &ff 01fb c9 ret ;;---------------------------------------------------------------------------- ;; HL = cluster to load ;; convert to sector offset 01fc 29 add hl,hl ;; call for first sector 01fd cd0102 call &0201 0200 d0 ret nc ;; call for second sector ;; HL = sector offset 0201 c5 push bc 0202 e5 push hl 0203 01f7ff ld bc,&fff7 ;; -9 0206 3e01 ld a,&01 0208 3c inc a 0209 09 add hl,bc 020a 38fc jr c,&0208 020c 67 ld h,a ;; track 020d 7d ld a,l 020e c64a add a,&4a 0210 4f ld c,a ;; sector 0211 2e00 ld l,&00 ;; drive ;; DE = address of buffer 0213 eb ex de,hl ;; HL = address of buffer ;; E = drive number ;; D = track number ;; C = sector number 0214 cd89be call &be89 ;; BIOS READ SECTOR 0217 eb ex de,hl 0218 e1 pop hl 0219 c1 pop bc 021a d0 ret nc 021b 14 inc d 021c 14 inc d 021d 23 inc hl 021e c9 ret 021f defb "????????EMS",0 ;; rest of directory is filled with CF byte rept &300-&22b defb &cf endm