#ifndef _DISK_H_
#define _DISK_H_
-#include "vm.h"
-#include "../emu.h"
+//#ifndef _ANY2D88
+//#include "vm.h"
+//#include "../emu.h"
+#include "../common.h"
+//#else
+//#include "../common.h"
+//#endif
// d88 media type
#define MEDIA_TYPE_2D 0x00
// so don't change these definitions
#define SPECIAL_DISK_X1TURBO_ALPHA 1
#define SPECIAL_DISK_X1_BATTEN 2
-#define SPECIAL_DISK_FM7_GAMBLER 11
-#define SPECIAL_DISK_FM7_DEATHFORCE 12
+#define SPECIAL_DISK_FM7_GAMBLER 11
+#define SPECIAL_DISK_FM7_DEATHFORCE 12
+#define SPECIAL_DISK_FM77AV_PSYOBLADE 13
+#define SPECIAL_DISK_FM7_TAIYOU1 14
+#define SPECIAL_DISK_FM7_TAIYOU2 15
+#define SPECIAL_DISK_FM7_XANADU2_D 16
+#define SPECIAL_DISK_FM7_RIGLAS 17
// d88 constant
#define DISK_BUFFER_SIZE 0x380000 // 3.5MB
#define TRACK_BUFFER_SIZE 0x080000 // 0.5MB
-// teledisk decoder constant
-#define STRING_BUFFER_SIZE 4096
-#define LOOKAHEAD_BUFFER_SIZE 60
-#define THRESHOLD 2
-#define N_CHAR (256 - THRESHOLD + LOOKAHEAD_BUFFER_SIZE)
-#define TABLE_SIZE (N_CHAR * 2 - 1)
-#define ROOT_POSITION (TABLE_SIZE - 1)
-#define MAX_FREQ 0x8000
+// physical format table for solid image
+typedef struct {
+ int type;
+ int ncyl, nside, nsec, size;
+ bool mfm;
+} fd_format_t;
class FILEIO;
-
+class OSD;
class DISK
{
+#ifndef _ANY2D88
protected:
EMU* emu;
+ OSD* osd;
+#endif
private:
- FILEIO* fi;
- uint8 buffer[DISK_BUFFER_SIZE + TRACK_BUFFER_SIZE];
+ uint8_t buffer[DISK_BUFFER_SIZE + TRACK_BUFFER_SIZE];
_TCHAR orig_path[_MAX_PATH];
_TCHAR dest_path[_MAX_PATH];
- _TCHAR temp_path[_MAX_PATH];
- pair file_size;
+ fd_format_t fd_formats[32];
+
+ pair_t file_size;
int file_bank;
- uint32 crc32;
+ uint32_t orig_file_size;
+ uint32_t orig_crc32;
bool trim_required;
- bool temporary;
- uint8 fdi_header[4096];
- void set_sector_info(uint8 *t);
+ bool is_1dd_image;
+ bool is_solid_image;
+ bool is_fdi_image;
+ uint8_t fdi_header[4096];
+ int solid_ncyl, solid_nside, solid_nsec, solid_size;
+ bool solid_mfm;
+
+ bool type_sc3000;
+ bool type_smc70;
+ bool type_x1;
+ bool type_x1turbo;
+ bool type_m5;
+ bool type_mz80b;
+ bool type_fm7;
+ bool type_fm77;
+ bool type_fm77av;
+ bool type_fm77av_2dd;
+ bool type_yis;
+ bool type_1dd;
+ bool type_any2d88;
+
+ void set_sector_info(uint8_t *t);
void trim_buffer();
// teledisk image decoder (td0)
- bool teledisk_to_d88();
- int next_word();
- int get_bit();
- int get_byte();
- void start_huff();
- void reconst();
- void update(int c);
- short decode_char();
- short decode_position();
- void init_decode();
- int decode(uint8 *buf, int len);
+ bool teledisk_to_d88(FILEIO *fio);
// imagedisk image decoder (imd)
- bool imagedisk_to_d88();
+ bool imagedisk_to_d88(FILEIO *fio);
// cpdread image decoder (dsk)
- bool cpdread_to_d88(int extended);
-
- // solid image decoder (fdi/tfd/2d/sf7)
- bool solid_to_d88(int type, int ncyl, int nside, int nsec, int size);
-
- uint8 text_buf[STRING_BUFFER_SIZE + LOOKAHEAD_BUFFER_SIZE - 1];
- uint16 ptr;
- uint16 bufcnt, bufndx, bufpos;
- uint16 ibufcnt,ibufndx;
- uint8 inbuf[512];
- uint16 freq[TABLE_SIZE + 1];
- short prnt[TABLE_SIZE + N_CHAR];
- short son[TABLE_SIZE];
- uint16 getbuf;
- uint8 getlen;
+ bool cpdread_to_d88(FILEIO *fio);
+
+ // nfd r0/r1 image decoder (nfd)
+ bool nfdr0_to_d88(FILEIO *fio);
+ bool nfdr1_to_d88(FILEIO *fio);
+
+ // solid image decoder (fdi/hdm/xdf/2d/img/sf7/tfd)
+ bool solid_to_d88(FILEIO *fio, int type, int ncyl, int nside, int nsec, int size, bool mfm);
+ void setup_fd_formats(void);
public:
+#ifndef _ANY2D88
DISK(EMU* parent_emu) : emu(parent_emu)
+#else
+ DISK()
+#endif
{
inserted = ejected = write_protected = changed = false;
file_size.d = 0;
drive_type = DRIVE_TYPE_UNK;
drive_rpm = 0;
drive_mfm = true;
+ track_size = 0;
static int num = 0;
+ is_special_disk = 0;
drive_num = num++;
+ set_device_name(_T("Floppy Disk Drive #%d"), drive_num + 1);
+ type_sc3000 = type_smc70 = type_x1 = type_x1turbo = false;
+ type_m5 = type_mz80b = false;
+ type_fm7 = type_fm77 = type_fm77av =false;
+ type_fm77av_2dd = type_1dd = type_any2d88 = false;
+ type_yis = false;
+ open_as_1dd = false;
+ open_as_256 = false;
+ setup_fd_formats();
}
~DISK()
{
- if(inserted) {
- close();
+//#ifndef _ANY2D88
+ if(!type_any2d88) {
+ if(inserted) {
+ close();
+ }
}
+//#endif
}
- void open(_TCHAR path[], int bank);
+ void open(const _TCHAR* file_path, int bank);
void close();
+//#ifdef _ANY2D88
+ bool open_as_1dd;
+ bool open_as_256;
+ void save_as_d88(const _TCHAR* file_path);
+//#endif
bool get_track(int trk, int side);
bool make_track(int trk, int side);
bool get_sector(int trk, int side, int index);
void set_data_mark_missing();
bool format_track(int trk, int side);
- void insert_sector(uint8 c, uint8 h, uint8 r, uint8 n, bool deleted, bool data_crc_error, uint8 fill_data, int length);
+ void insert_sector(uint8_t c, uint8_t h, uint8_t r, uint8_t n, bool deleted, bool data_crc_error, uint8_t fill_data, int length);
void sync_buffer();
int get_rpm();
bool ejected;
bool write_protected;
bool changed;
- uint8 media_type;
- bool is_solid_image;
- bool is_fdi_image;
- bool is_1dd_image;
+ uint8_t media_type;
int is_special_disk;
// track
- uint8 track[TRACK_BUFFER_SIZE];
- pair sector_num;
+ uint8_t track[TRACK_BUFFER_SIZE];
+ pair_t sector_num;
+ bool track_mfm;
bool invalid_format;
- bool no_skew;
+// bool no_skew;
int cur_track, cur_side;
- int sync_position[256];
- int id_position[256];
- int data_position[256];
+ int sync_position[512];
+ int am1_position[512];
+ int id_position[512];
+ int data_position[512];
+// int gap3_size;
// sector
- uint8* sector;
- pair sector_size;
- uint8 id[6];
- uint8 density;
+ uint8_t* sector;
+ pair_t sector_size;
+ uint8_t id[6];
+ uint8_t density;
bool deleted;
bool addr_crc_error;
bool data_crc_error;
// drive
- uint8 drive_type;
+ uint8_t drive_type;
int drive_rpm;
bool drive_mfm;
+ int track_size; // hack for YIS :-(
int drive_num;
bool correct_timing()
{
- if(drive_num < array_length(config.correct_disk_timing)) {
+ if(type_any2d88) return false;
+//#ifndef _ANY2D88
+ if(type_fm7) {
+//#if defined(_FM7) || defined(_FM8) || defined(_FM77_VARIANTS) || defined(_FM77AV_VARIANTS)
+ if((is_special_disk == SPECIAL_DISK_FM7_TAIYOU1) || (is_special_disk == SPECIAL_DISK_FM7_TAIYOU2)) {
+ return true;
+ }
+ }
+//#endif
+ if(drive_num < (int)array_length(config.correct_disk_timing)) {
return config.correct_disk_timing[drive_num];
}
+//#endif
return false;
}
bool ignore_crc()
{
- if(drive_num < array_length(config.ignore_disk_crc)) {
+ if(type_any2d88) return false;
+//#ifndef _ANY2D88
+ if(drive_num < (int)array_length(config.ignore_disk_crc)) {
return config.ignore_disk_crc[drive_num];
}
+//#endif
return false;
}
// state
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
+
+ // device name
+ void set_device_name(const _TCHAR* format, ...)
+ {
+ if(format != NULL) {
+ va_list ap;
+ _TCHAR buffer[1024];
+
+ va_start(ap, format);
+ my_vstprintf_s(buffer, 1024, format, ap);
+ va_end(ap);
+
+ my_tcscpy_s(this_device_name, 128, buffer);
+#ifdef _USE_QT
+// emu->get_osd()->set_vm_node(this_device_id, buffer);
+#endif
+ }
+ }
+ const _TCHAR *get_device_name()
+ {
+ return (const _TCHAR *)this_device_name;
+ }
+ _TCHAR this_device_name[128];
};
#endif