2 // PC-6001/6601 disk I/O
3 // This file is based on a disk I/O program in C++
4 // by Mr. Yumitaro and translated into C for Cocoa iP6
5 // by Koichi NISHIDA 2006
9 NEC PC-6601 Emulator 'yaPC-6601'
10 NEC PC-6601SR Emulator 'yaPC-6801'
15 [ internal floppy drive ]
22 #include "../../emu.h"
23 #include "../device.h"
25 #if defined(USE_SOUND_FILES)
26 #define FLOPPY_SND_TBL_MAX 256
27 #ifndef SIG_SOUNDER_MUTE
28 #define SIG_SOUNDER_MUTE (65536 + 0)
30 #ifndef SIG_SOUNDER_RELOAD
31 #define SIG_SOUNDER_RELOAD (65536 + 32)
33 #ifndef SIG_SOUNDER_ADD
34 #define SIG_SOUNDER_ADD (65536 + 64)
37 #define FLOPPY_SND_TYPE_SEEK 0
38 #define FLOPPY_SND_TYPE_HEAD 1
41 class FLOPPY : public DEVICE
53 int Seek88(int drvno, int trackno, int sectno);
54 unsigned char Getc88(int drvno);
55 int Putc88(int drvno, unsigned char dat);
57 // data buffer (256BytesX4)
58 unsigned char Data[4][256];
62 unsigned char Data[10];
66 CmdBuffer CmdIn; // command buffer
67 CmdBuffer CmdOut; // status buffer
68 unsigned char SeekST0; // ST0 when SEEK
69 unsigned char LastCylinder; // last read cylinder
70 int SeekEnd; // complete seek flag
71 unsigned char SendSectors; // amount(100H unit)
72 int DIO; // data direction TRUE: Buffer->CPU FALSE: CPU->Buffer
73 unsigned char Status; // FDC status register
74 #if defined(USE_SOUND_FILES)
75 int seek_track_num[2];
78 void Push(int part, unsigned char data);
79 unsigned char Pop(int part);
83 void PushStatus(int data);
84 unsigned char PopStatus();
85 void OutFDC(unsigned char data);
86 unsigned char InFDC();
90 void SenseInterruptStatus(void);
93 void OutB1H_66(unsigned char data);
94 void OutB2H_66(unsigned char data);
95 void OutB3H_66(unsigned char data);
96 void OutD0H_66(unsigned char data);
97 void OutD1H_66(unsigned char data);
98 void OutD2H_66(unsigned char data);
99 void OutD3H_66(unsigned char data);
100 void OutD6H_66(unsigned char data);
101 void OutD8H_66(unsigned char data);
102 void OutDAH_66(unsigned char data);
103 void OutDDH_66(unsigned char data);
104 void OutDEH_66(unsigned char data);
106 unsigned char InB2H_66();
107 unsigned char InD0H_66();
108 unsigned char InD1H_66();
109 unsigned char InD2H_66();
110 unsigned char InD3H_66();
111 unsigned char InD4H_66();
112 unsigned char InDCH_66();
113 unsigned char InDDH_66();
115 #if defined(USE_SOUND_FILES)
117 _TCHAR snd_seek_name[512];
118 _TCHAR snd_head_name[512];
119 int snd_seek_mix_tbl[FLOPPY_SND_TBL_MAX];
120 int snd_head_mix_tbl[FLOPPY_SND_TBL_MAX];
121 int16_t *snd_seek_data; // Read only
122 int16_t *snd_head_data; // Read only
123 int snd_seek_samples_size;
124 int snd_head_samples_size;
126 int snd_level_l, snd_level_r;
127 virtual void mix_main(int32_t *dst, int count, int16_t *src, int *table, int samples);
128 void add_sound(int type);
131 FLOPPY(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
133 #if defined(USE_SOUND_FILES)
134 seek_track_num[0] = seek_track_num[1] = 0;
135 cur_trk[0] = cur_trk[1] = 0;
136 seek_event_id[0] = seek_event_id[1] = -1;
137 for(int i = 0; i < FLOPPY_SND_TBL_MAX; i++) {
138 snd_seek_mix_tbl[i] = -1;
139 snd_head_mix_tbl[i] = -1;
141 snd_seek_data = snd_head_data = NULL;
142 snd_seek_samples_size = snd_head_samples_size = 0;
144 snd_level_l = snd_level_r = decibel_to_volume(0);
145 memset(snd_seek_name, 0x00, sizeof(snd_seek_name));
146 memset(snd_head_name, 0x00, sizeof(snd_head_name));
148 set_device_name(_T("Floppy Drive"));
156 void event_callback(int event_id, int err);
157 void write_io8(uint32_t addr, uint32_t data);
158 uint32_t read_io8(uint32_t addr);
159 uint32_t read_signal(int ch);
160 void save_state(FILEIO* state_fio);
161 bool load_state(FILEIO* state_fio);
164 void set_context_ext(DEVICE* device)
168 DISK* get_disk_handler(int drv)
172 #if defined(USE_SOUND_FILES)
173 // Around SOUND. 20161004 K.O
174 bool load_sound_data(int type, const _TCHAR *pathname);
175 void release_sound_data(int type);
176 bool reload_sound_data(int type);
178 void mix(int32_t *buffer, int cnt);
179 void set_volume(int ch, int decibel_l, int decibel_r);
181 void open_disk(int drv, const _TCHAR* file_path, int bank);
182 void close_disk(int drv);
183 bool is_disk_inserted(int drv);
184 void is_disk_protected(int drv, bool value);
185 bool is_disk_protected(int drv);