2019-11-28 04:27:32 +00:00
|
|
|
//
|
2020-02-17 04:38:38 +00:00
|
|
|
// woz.h
|
2019-11-28 04:27:32 +00:00
|
|
|
// A2Mac
|
|
|
|
//
|
2020-02-17 04:38:38 +00:00
|
|
|
// Created by Tamas Rudnai on 2/15/20.
|
|
|
|
// Copyright © 2020 GameAlloy. All rights reserved.
|
2019-11-28 04:27:32 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef woz_h
|
|
|
|
#define woz_h
|
|
|
|
|
2020-02-17 04:38:38 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
|
2020-06-26 02:52:23 +00:00
|
|
|
#define MAXFILENAME 4096
|
|
|
|
|
2020-01-28 06:54:03 +00:00
|
|
|
#define DISKII_MAXTRACKS 80
|
|
|
|
#define DISKII_PHASES 4
|
|
|
|
|
2020-02-17 04:38:38 +00:00
|
|
|
#define WOZ1_MAGIC 0x315A4F57
|
|
|
|
#define WOZ2_MAGIC 0x325A4F57
|
|
|
|
#define WOZ_INFO_CHUNK_ID 0x4F464E49
|
|
|
|
#define WOZ_TMAP_CHUNK_ID 0x50414D54
|
|
|
|
#define WOZ_TRKS_CHUNK_ID 0x534B5254
|
|
|
|
#define WOZ_META_CHUNK_ID 0x4154454D
|
|
|
|
|
2020-06-04 18:37:35 +00:00
|
|
|
#define WOZ_ERR_OK 0
|
|
|
|
#define WOZ_ERR_FILE_NOT_FOUND -1
|
|
|
|
#define WOZ_ERR_NOT_WOZ_FILE -2
|
|
|
|
#define WOZ_ERR_BAD_CHUNK_HDR -3
|
|
|
|
#define WOZ_ERR_BAD_DATA -4
|
|
|
|
|
2020-01-28 06:54:03 +00:00
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
2019-11-28 04:27:32 +00:00
|
|
|
|
|
|
|
typedef struct woz_header_s {
|
|
|
|
uint32_t magic;
|
|
|
|
uint8_t no7;
|
|
|
|
char lineend [3];
|
|
|
|
uint32_t crc;
|
|
|
|
} woz_header_t;
|
|
|
|
|
|
|
|
typedef struct woz_chunk_header_s {
|
|
|
|
uint32_t magic;
|
|
|
|
uint32_t size;
|
|
|
|
} woz_chunk_header_t;
|
|
|
|
|
|
|
|
// chunk data only
|
|
|
|
typedef struct woz_info_s {
|
|
|
|
uint8_t version;
|
|
|
|
uint8_t disk_type; // 1 = 5.25, 2 = 3.5
|
|
|
|
uint8_t is_write_protected;
|
|
|
|
uint8_t sync; // 1 = Cross track sync
|
|
|
|
uint8_t cleaned; // 1 = MC3470 fake bits removed
|
|
|
|
char creator [32]; // Name of software created this file (UTF-8, 0x20 padded, NOT zero terminated)
|
|
|
|
} woz_info_t;
|
|
|
|
|
|
|
|
// chunk data only
|
|
|
|
typedef struct woz_tmap_s {
|
2020-01-28 06:54:03 +00:00
|
|
|
uint8_t phase [DISKII_MAXTRACKS * DISKII_PHASES];
|
2019-11-28 04:27:32 +00:00
|
|
|
} woz_tmap_t;
|
|
|
|
|
|
|
|
#define WOZ_TRACK_BYTE_COUNT 6646
|
|
|
|
// chunk data only
|
2020-01-28 06:54:03 +00:00
|
|
|
|
2019-11-28 04:27:32 +00:00
|
|
|
typedef struct woz_track_s {
|
|
|
|
uint8_t data [WOZ_TRACK_BYTE_COUNT];
|
|
|
|
uint16_t bytes_used;
|
|
|
|
uint16_t bit_count;
|
|
|
|
uint16_t splice_point;
|
|
|
|
uint8_t splice_nibble;
|
|
|
|
uint8_t splice_bit_count;
|
|
|
|
uint16_t reserved;
|
|
|
|
} woz_track_t;
|
|
|
|
|
2020-01-28 06:54:03 +00:00
|
|
|
|
2019-11-28 04:27:32 +00:00
|
|
|
// chunk data only
|
2020-01-28 06:54:03 +00:00
|
|
|
typedef woz_track_t woz_trks_t[DISKII_MAXTRACKS];
|
2019-11-28 04:27:32 +00:00
|
|
|
|
2020-01-28 06:54:03 +00:00
|
|
|
#pragma pack(pop)
|
2019-11-28 04:27:32 +00:00
|
|
|
|
2020-02-17 04:38:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef union {
|
|
|
|
struct {
|
|
|
|
uint8_t data;
|
2020-06-18 22:14:54 +00:00
|
|
|
uint8_t latch;
|
|
|
|
|
|
|
|
// for debug and diag purposes
|
|
|
|
uint8_t out[6];
|
2020-02-17 04:38:38 +00:00
|
|
|
};
|
|
|
|
struct {
|
|
|
|
uint16_t lower15 : 15;
|
|
|
|
uint16_t valid : 1;
|
|
|
|
};
|
2020-06-18 22:14:54 +00:00
|
|
|
uint64_t shift;
|
2020-02-17 04:38:38 +00:00
|
|
|
} WOZread_t;
|
|
|
|
|
2020-06-26 02:52:23 +00:00
|
|
|
|
|
|
|
typedef struct woz_flags_s {
|
|
|
|
uint8_t image_loaded : 1;
|
|
|
|
uint8_t image_file_readonly : 1;
|
|
|
|
uint8_t disk_write_protected : 1;
|
|
|
|
uint8_t disk_modified : 1;
|
|
|
|
} woz_flags_t;
|
2020-02-17 04:38:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern WOZread_t WOZread;
|
|
|
|
extern uint8_t WOZlatch;
|
2020-06-26 02:52:23 +00:00
|
|
|
extern char woz_filename[MAXFILENAME];
|
|
|
|
extern woz_flags_t woz_flags;
|
2020-02-17 04:38:38 +00:00
|
|
|
|
|
|
|
//extern woz_header_t woz_header;
|
|
|
|
//extern woz_chunk_header_t woz_chunk_header;
|
|
|
|
//extern woz_tmap_t woz_tmap;
|
|
|
|
//extern woz_trks_t woz_trks;
|
|
|
|
|
|
|
|
|
2020-02-18 06:22:14 +00:00
|
|
|
extern uint8_t woz_read(void);
|
2020-06-18 22:14:54 +00:00
|
|
|
extern void woz_write( uint8_t data );
|
2020-06-04 18:37:35 +00:00
|
|
|
extern int woz_loadFile( const char * filename );
|
2020-06-25 23:23:20 +00:00
|
|
|
extern int woz_saveFile( const char * filename );
|
2020-06-26 02:52:23 +00:00
|
|
|
extern void woz_eject(void);
|
2020-02-17 04:38:38 +00:00
|
|
|
|
2019-11-28 04:27:32 +00:00
|
|
|
#endif /* woz_h */
|