OSDN Git Service

[VM][PC6001] Add seek sounds.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc6001 / floppy.h
1 //
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
6 //
7
8 /*
9         NEC PC-6601 Emulator 'yaPC-6601'
10         NEC PC-6601SR Emulator 'yaPC-6801'
11
12         Author : tanam
13         Date   : 2013.07.15-
14
15         [ internal floppy drive ]
16 */
17
18 #ifndef _FLOPPY_H_
19 #define _FLOPPY_H_
20
21 #include "../vm.h"
22 #include "../../emu.h"
23 #include "../device.h"
24
25 class DISK;
26 #if defined(USE_SOUND_FILES)
27 class WAV_SOUNDER;
28 #endif
29 class FLOPPY : public DEVICE
30 {
31 private:
32         DEVICE *d_ext;
33         unsigned char io_B1H;
34         
35         DISK* disk[2];
36 #if defined(USE_SOUND_FILES)
37         DEVICE *d_seek_sound;
38 #endif
39         int cur_trk[2];
40         int cur_sct[2];
41         int cur_pos[2];
42         bool access[2];
43         
44         int Seek88(int drvno, int trackno, int sectno);
45         unsigned char Getc88(int drvno);
46         int Putc88(int drvno, unsigned char dat);
47         
48         // data buffer (256BytesX4)
49         unsigned char Data[4][256];
50         int Index[4];
51         
52         typedef struct {
53                 unsigned char Data[10];
54                 int Index;
55         } CmdBuffer;
56         
57         CmdBuffer CmdIn;                                        // command buffer
58         CmdBuffer CmdOut;                               // status buffer
59         unsigned char SeekST0;                  // ST0 when SEEK
60         unsigned char LastCylinder;             // last read cylinder
61         int SeekEnd;                                            // complete seek flag
62         unsigned char SendSectors;              // amount(100H unit)
63         int DIO;                                                        // data direction TRUE: Buffer->CPU FALSE: CPU->Buffer
64         unsigned char Status;                   // FDC status register
65 #if defined(USE_SOUND_FILES)
66         int seek_track_num[2];
67         int seek_event_id[2];
68 #endif
69         void Push(int part, unsigned char data);
70         unsigned char Pop(int part);
71         void Clear(int i);
72         
73         int DiskInit66(void);
74         void PushStatus(int data);
75         unsigned char PopStatus();
76         void OutFDC(unsigned char data);
77         unsigned char InFDC();
78         void Read();
79         void Write(void);
80         void Seek(void);
81         void SenseInterruptStatus(void);
82         void Exec();
83         
84         void OutB1H_66(unsigned char data);
85         void OutB2H_66(unsigned char data);
86         void OutB3H_66(unsigned char data);
87         void OutD0H_66(unsigned char data);
88         void OutD1H_66(unsigned char data);
89         void OutD2H_66(unsigned char data);
90         void OutD3H_66(unsigned char data);
91         void OutD6H_66(unsigned char data);
92         void OutD8H_66(unsigned char data);
93         void OutDAH_66(unsigned char data);
94         void OutDDH_66(unsigned char data);
95         void OutDEH_66(unsigned char data);
96         
97         unsigned char InB2H_66();
98         unsigned char InD0H_66();
99         unsigned char InD1H_66();
100         unsigned char InD2H_66();
101         unsigned char InD3H_66();
102         unsigned char InD4H_66();
103         unsigned char InDCH_66();
104         unsigned char InDDH_66();
105         
106 public:
107         FLOPPY(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
108         {
109 #if defined(USE_SOUND_FILES)
110         seek_track_num[0] = seek_track_num[1] = 0;
111         cur_trk[0] = cur_trk[1] = 0;
112         seek_event_id[0] = seek_event_id[1] = -1;
113         d_seek_sound = NULL;
114 #endif
115         }
116         ~FLOPPY() {}
117         
118         // common functions
119         void initialize();
120         void release();
121         void reset();
122         void event_callback(int event_id, int err);
123         void write_io8(uint32_t addr, uint32_t data);
124         uint32_t read_io8(uint32_t addr);
125         uint32_t read_signal(int ch);
126         void save_state(FILEIO* state_fio);
127         bool load_state(FILEIO* state_fio);
128         
129         // unique functions
130         void set_context_ext(DEVICE* device)
131         {
132                 d_ext = device;
133         }
134 #if defined(USE_SOUND_FILES)
135         void set_context_seek(DEVICE *d)
136         {
137                 d_seek_sound = d;
138         }
139 #endif
140         DISK* get_disk_handler(int drv)
141         {
142                 return disk[drv];
143         }
144         void open_disk(int drv, const _TCHAR* file_path, int bank);
145         void close_disk(int drv);
146         bool is_disk_inserted(int drv);
147         void is_disk_protected(int drv, bool value);
148         bool is_disk_protected(int drv);
149 };
150
151 #endif
152