Apple II disk emulation crashes on woz2
From
Jens Gaulke@21:1/5 to
All on Sun Mar 19 14:01:47 2023
Hi there,
I managed to get my disk II emulation working - at least I thought so until I discovered an error.
I decided to start with woz images and started with the file format description on applesauce page to write a routine to setup the track info:
def decode_woz2(self, drivestate, filename):
disk_data = drivestate.disk_data
# Überprüfen, ob die Diskette den richtigen Header hat
woz2 = [0x57, 0x4F, 0x5A, 0x32, 0xFF, 0x0A, 0x0D, 0x0A]
found = True
for i in range (len(woz2)):
if woz2[i] != disk_data[i]:
found = False
if not found:
return
if disk_data[22] == 1:
drivestate.is_write_protected = True
else:
drivestate.is_write_protected = False
# checksum überprüfung fehlt noch
# WOZ 2
for htrack in range(80):
tmap_index = disk_data[88 + htrack*2]
if tmap_index < 255:
tmap_offset = 256 + 8*tmap_index
trk = disk_data[tmap_offset:tmap_offset + 8]
drivestate.track_start[htrack] = 512 * (trk[0] + (trk[1] << 8))
drivestate.track_nbits[htrack] = trk[4] + (trk[5] << 8) + (trk[6] << 16) + (trk[7] << 24)
else:
drivestate.track_start[htrack] = 0
drivestate.track_nbits[htrack] = 51200
return True
def decode_woz1(self, drivestate, filename):
disk_data = drivestate.disk_data
# Überprüfen, ob die Diskette den richtigen Header hat
woz1 = [0x57, 0x4F, 0x5A, 0x31, 0xFF, 0x0A, 0x0D, 0x0A]
found = True
for i in range (len(woz1)):
if woz1[i] != disk_data[i]:
found = False
if not found:
return
if disk_data[22] == 1:
drivestate.is_write_protected = True
else:
drivestate.is_write_protected = False
# checksum überprüfung fehlt noch
# WOZ 1
for htrack in range(80):
tmap_index = disk_data[88 + htrack*2]
if tmap_index < 255:
drivestate.track_start[htrack] = 256 + tmap_index * 6656
trk = disk_data[(drivestate.track_start[htrack]+6646):(drivestate.track_start[htrack]+6656)]
drivestate.track_nbits[htrack] = trk[2] + (trk[3] << 8)
else:
drivestate.track_start[htrack] = 0
drivestate.track_nbits[htrack] = 51200
return True
It works fine for woz1 disks, woz2 disks are read but it seems I get "wrong bytes". The DOS3.3 disk first reads then crashes, a choplifter disk reads the starting picture but with some flashing ascii chars on it before it crashes.
I think my softswitch routines work fine as woz1 images start perfectly, so I think the error must be in decoding the woz2 images.
Do you have any recommendation for me?
Cheers,
Jens
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)