Thursday, January 2, 2020

PC-8801 d88 disk format for Cosmic Soldier

I worked through the disk for Cosmic Soldier (1985, Kogado) for PC-88 and managed to decipher a lot of it. I wrote a tool to extract the files but it doesn't work on other disks right now.

COSMIC SOLDIER

Cylinders: 40
Sectors per track: 17 (16 in cylinders 1-8, 1 dummy sector in 9-40)
Total no. sectors: 1280 (1344 including dummy sectors)


First 688 bytes: Disk header
 first 16: all zeroes
 [remainder is unknown atm, likely CP/M code?]


Every sector has a 16-byte header for every 256 bytes of data.
Header looks like this:
[C] [T] [S] 01h [B] 10x00h 01h

C: cylinder, 0-27h (0-39)
T: track, 0-1
S: sector, 00-10h (0-16)
(01h byte)
B: side: 10h if cylinder 0-7, 11h if cylinder is 8-27h
   (8 cylinders = 65kb; likely legacy 16bit address limit)
(ten 00h bytes)
(01h byte)

The 4th, 6th and 16th byte will change values on other disks. I am assuming the 01s somehow indicates BASIC programs with a file directory listing.

The extra 17th sector in cylinders 8+ (header no. 10h) is always 256*FF bytes.


Directory listing for the disk is at address 27-01-01 (cylinder 39, track 2, sector 1):
16 bytes per file, extends until 27-01-0d - This means there is room for 192 file indexes.

9 bytes: File name
1 byte: File type
  00: Data A (writeable?)
  01: Data B ?
  80: BASIC program
1 byte: Sector address / 8
5 bytes: FFh

 E.g.:
"init     ",80h,4Ch
Means a BASIC program named "init     " starts in sector 608 (4C*8 in decimal)
Sector 608 / 32 = 19, in decimal = 13h; therefore "init     " starts at sector address 13-00-00. Tracking through the disk shows this to be true. This does not include dummy sectors - 608 is the sector count not including dummies.


The listing at sector address 27-01-0D is the disk's auto-exec code.
 E.g.:
00h,02h,RUN"start"

Final 3 sectors are a mystery for now.

It took quite a bit of searching, but luckily the Z88dk has a listing of BASIC tokens for N88-BASIC, here:
https://github.com/z88dk/techdocs/blob/master/targets/pc8801/pc88.map

Shouldn't take much work to convert the code back to its original source.

No comments:

Post a Comment