2 Skelton for retropc emulator
4 Author : Takeda.Toshiya
16 #include "../common.h"
18 //#include "../common.h"
22 #define MEDIA_TYPE_2D 0x00
23 #define MEDIA_TYPE_2DD 0x10
24 #define MEDIA_TYPE_2HD 0x20
25 #define MEDIA_TYPE_144 0x30
26 #define MEDIA_TYPE_UNK 0xff
28 #define DRIVE_TYPE_2D MEDIA_TYPE_2D
29 #define DRIVE_TYPE_2DD MEDIA_TYPE_2DD
30 #define DRIVE_TYPE_2HD MEDIA_TYPE_2HD
31 #define DRIVE_TYPE_144 MEDIA_TYPE_144
32 #define DRIVE_TYPE_UNK MEDIA_TYPE_UNK
34 // this value will be stored to the state file,
35 // so don't change these definitions
36 #define SPECIAL_DISK_X1TURBO_ALPHA 1
37 #define SPECIAL_DISK_X1_BATTEN 2
38 #define SPECIAL_DISK_FM7_GAMBLER 11
39 #define SPECIAL_DISK_FM7_DEATHFORCE 12
40 #define SPECIAL_DISK_FM77AV_PSYOBLADE 13
41 #define SPECIAL_DISK_FM7_TAIYOU1 14
42 #define SPECIAL_DISK_FM7_TAIYOU2 15
43 #define SPECIAL_DISK_FM7_XANADU2_D 16
44 #define SPECIAL_DISK_FM7_RIGLAS 17
45 #define SPECIAL_DISK_FM7_FLEX 18
48 #define DISK_BUFFER_SIZE 0x380000 // 3.5MB
49 #define TRACK_BUFFER_SIZE 0x080000 // 0.5MB
51 // physical format table for solid image
54 int ncyl, nside, nsec, size;
58 class csp_state_utils;
69 csp_state_utils *state_entry;
71 uint8_t buffer[DISK_BUFFER_SIZE + TRACK_BUFFER_SIZE];
72 _TCHAR orig_path[_MAX_PATH];
73 _TCHAR dest_path[_MAX_PATH];
74 fd_format_t fd_formats[32];
78 uint32_t orig_file_size;
85 uint8_t fdi_header[4096];
86 int solid_ncyl, solid_nside, solid_nsec, solid_size;
103 void set_sector_info(uint8_t *t);
106 // teledisk image decoder (td0)
107 bool teledisk_to_d88(FILEIO *fio);
109 // imagedisk image decoder (imd)
110 bool imagedisk_to_d88(FILEIO *fio);
112 // cpdread image decoder (dsk)
113 bool cpdread_to_d88(FILEIO *fio);
115 // nfd r0/r1 image decoder (nfd)
116 bool nfdr0_to_d88(FILEIO *fio);
117 bool nfdr1_to_d88(FILEIO *fio);
119 // solid image decoder (fdi/hdm/xdf/2d/img/sf7/tfd)
120 bool solid_to_d88(FILEIO *fio, int type, int ncyl, int nside, int nsec, int size, bool mfm);
121 void setup_fd_formats(void);
123 // internal routines for track
124 bool get_track_tmp(int trk, int side);
125 bool make_track_tmp(int trk, int side);
126 bool get_sector_tmp(int trk, int side, int index);
127 bool format_track_tmp(int trk, int side);
131 DISK(EMU* parent_emu) : emu(parent_emu)
136 inserted = ejected = write_protected = changed = false;
138 sector_size.sd = sector_num.sd = 0;
140 drive_type = DRIVE_TYPE_UNK;
147 set_device_name(_T("Floppy Disk Drive #%d"), drive_num + 1);
148 type_sc3000 = type_smc70 = type_x1 = type_x1turbo = false;
149 type_m5 = type_mz80b = false;
150 type_fm7 = type_fm77 = type_fm77av =false;
151 type_fm77av_2dd = type_1dd = type_any2d88 = false;
169 void open(const _TCHAR* file_path, int bank);
174 void save_as_d88(const _TCHAR* file_path);
176 bool get_track(int trk, int side);
177 bool make_track(int trk, int side);
178 bool get_sector(int trk, int side, int index);
179 void set_deleted(bool value);
180 void set_data_crc_error(bool value);
181 void set_data_mark_missing();
183 bool format_track(int trk, int side);
184 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);
187 int get_max_tracks();
189 int get_track_size();
190 double get_usec_per_track();
191 double get_usec_per_bytes(int bytes);
192 int get_bytes_per_usec(double usec);
193 bool check_media_type();
197 bool write_protected;
204 uint8_t track[TRACK_BUFFER_SIZE];
209 int cur_track, cur_side;
211 int sync_position[512];
212 int am1_position[512];
213 int id_position[512];
214 int data_position[512];
225 int _tmp_sector_offset;
231 int track_size; // hack for YIS :-(
233 bool correct_timing()
235 if(type_any2d88) return false;
238 //#if defined(_FM7) || defined(_FM8) || defined(_FM77_VARIANTS) || defined(_FM77AV_VARIANTS)
239 if((is_special_disk == SPECIAL_DISK_FM7_TAIYOU1) || (is_special_disk == SPECIAL_DISK_FM7_TAIYOU2)) {
244 if(drive_num < (int)array_length(config.correct_disk_timing)) {
245 return config.correct_disk_timing[drive_num];
252 if(type_any2d88) return false;
254 if(drive_num < (int)array_length(config.ignore_disk_crc)) {
255 return config.ignore_disk_crc[drive_num];
262 bool process_state(FILEIO* state_fio, bool loading);
265 void set_device_name(const _TCHAR* format, ...)
271 va_start(ap, format);
272 my_vstprintf_s(buffer, 1024, format, ap);
275 my_tcscpy_s(this_device_name, 128, buffer);
277 // emu->get_osd()->set_vm_node(this_device_id, buffer);
281 const _TCHAR *get_device_name()
283 return (const _TCHAR *)this_device_name;
285 _TCHAR this_device_name[128];