From 41cfb1efde3e7b1a43b752b3a44d10e8e985b871 Mon Sep 17 00:00:00 2001 From: Tamas Rudnai Date: Tue, 7 May 2024 20:05:39 -0700 Subject: [PATCH] WOZ 2.0 Disk Image Format --- src/dev/disk/dsk2woz.c | 2 +- src/dev/disk/dsk2woz.h | 1 + src/dev/disk/woz.h | 35 +++++++++++++++++------------------ woz_debug.rtf | 5 +++++ 4 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 woz_debug.rtf diff --git a/src/dev/disk/dsk2woz.c b/src/dev/disk/dsk2woz.c index 2738609..53b575e 100755 --- a/src/dev/disk/dsk2woz.c +++ b/src/dev/disk/dsk2woz.c @@ -343,7 +343,7 @@ static size_t write_sync(uint8_t *buffer, size_t position) { @param dest The at-least-343 byte buffer to which the encoded sector is written. @param src The 256-byte source data. */ -static void encode_6_and_2(uint8_t *dest, const uint8_t *src) { +void encode_6_and_2(uint8_t *dest, const uint8_t *src) { const uint8_t six_and_two_mapping[] = { 0x96, 0x97, 0x9a, 0x9b, 0x9d, 0x9e, 0x9f, 0xa6, 0xa7, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb2, 0xb3, diff --git a/src/dev/disk/dsk2woz.h b/src/dev/disk/dsk2woz.h index c8af0a6..33cc9ac 100644 --- a/src/dev/disk/dsk2woz.h +++ b/src/dev/disk/dsk2woz.h @@ -25,5 +25,6 @@ #define dsk2woz_h int dsk2woz( const char * filename ); +extern void encode_6_and_2(uint8_t *dest, const uint8_t *src); #endif /* dsk2woz_h */ diff --git a/src/dev/disk/woz.h b/src/dev/disk/woz.h index 40f4f33..f0d33d2 100644 --- a/src/dev/disk/woz.h +++ b/src/dev/disk/woz.h @@ -32,7 +32,8 @@ #define WOZ1_FILE_SIZE 233216 -#define DISKII_MAXTRACKS 80 +#define WOZ1_MAXTRACKS 80 +#define WOZ2_MAXTRACKS 160 #define DISKII_PHASES 4 #define WOZ1_MAGIC 0x315A4F57 @@ -54,7 +55,13 @@ #pragma pack(1) typedef struct woz_header_s { - uint32_t magic; + union { + struct { + char woz_name [3]; // should be "WOZ" + char woz_version; // currently "1" (0x31) or "2" (0x32) + }; + uint32_t magic; + }; union { struct { uint8_t no7; @@ -73,8 +80,9 @@ typedef struct woz_chunk_header_s { // chunk data only typedef struct woz_info_s { uint8_t version; // Version number of the INFO chunk. - // WOZ1 version is 1 - // WOZ2 version is 2 + // WOZ1 => 1 + // WOZ2 => 2 + // WOZ 2.1 => 3 uint8_t disk_type; // 1 = 5.25, 2 = 3.5 uint8_t is_write_protected; // 1 = Floppy is write protected uint8_t sync; // 1 = Cross track sync @@ -109,7 +117,7 @@ typedef struct woz_info_s { // chunk data only typedef struct woz_tmap_s { - uint8_t phase [DISKII_MAXTRACKS * DISKII_PHASES]; + uint8_t phase [WOZ1_MAXTRACKS * DISKII_PHASES]; } woz_tmap_t; #define WOZ1_TRACK_BYTE_COUNT 6646 @@ -117,7 +125,7 @@ typedef struct woz_tmap_s { // chunk data only -typedef struct woz1_track_s { +typedef struct woz1_trk_s { uint8_t data [WOZ1_TRACK_BYTE_COUNT]; uint16_t bytes_used; uint16_t bit_count; @@ -125,7 +133,7 @@ typedef struct woz1_track_s { uint8_t splice_nibble; uint8_t splice_bit_count; uint16_t reserved; -} woz1_track_t; +} woz1_trk_t; typedef struct woz2_trk_s { @@ -138,18 +146,9 @@ typedef struct woz2_trk_s { #define WOZ_MAX_TRK 160 -typedef struct woz2_track_s { - uint8_t trks [WOZ_MAX_TRK]; - uint16_t bytes_used; - uint16_t bit_count; - uint16_t splice_point; - uint8_t splice_nibble; - uint8_t splice_bit_count; - uint16_t reserved; -} woz2_track_t; - // chunk data only -typedef woz1_track_t woz1_trks_t[DISKII_MAXTRACKS]; +typedef woz1_trk_t woz1_trks_t[WOZ1_MAXTRACKS]; +typedef woz2_trk_t woz2_trks_t[WOZ2_MAXTRACKS]; #pragma pack(pop) diff --git a/woz_debug.rtf b/woz_debug.rtf new file mode 100644 index 0000000..75cbd5b --- /dev/null +++ b/woz_debug.rtf @@ -0,0 +1,5 @@ +{\rtf1\ansi\ansicpg1252\cocoartf949 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +\margl1440\margr1440\vieww9000\viewh8400\viewkind0 +} \ No newline at end of file