OSDN Git Service

[VM][STATE] Use namespace {VMNAME} to separate per VMs.
[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 class NOISE;
27
28 namespace PC6001 {
29
30 class FLOPPY : public DEVICE
31 {
32 private:
33         DEVICE *d_ext;
34         NOISE *d_noise_seek;
35 //      NOISE* d_noise_head_down;
36 //      NOISE* d_noise_head_up;
37         unsigned char io_B1H;
38         
39         DISK* disk[2];
40         
41         int cur_trk[2];
42         int cur_sct[2];
43         int cur_pos[2];
44         bool access[2];
45         
46         int Seek88(int drvno, int trackno, int sectno);
47         unsigned char Getc88(int drvno);
48         int Putc88(int drvno, unsigned char dat);
49         
50         // data buffer (256BytesX4)
51         unsigned char Data[4][256];
52         int Index[4];
53         
54         typedef struct {
55                 unsigned char Data[10];
56                 int Index;
57         } CmdBuffer;
58         
59         CmdBuffer CmdIn;                                        // command buffer
60         CmdBuffer CmdOut;                               // status buffer
61         unsigned char SeekST0;                  // ST0 when SEEK
62         unsigned char LastCylinder;             // last read cylinder
63         int SeekEnd;                                            // complete seek flag
64         unsigned char SendSectors;              // amount(100H unit)
65         int DIO;                                                        // data direction TRUE: Buffer->CPU FALSE: CPU->Buffer
66         unsigned char Status;                   // FDC status register
67         
68         void Push(int part, unsigned char data);
69         unsigned char Pop(int part);
70         void Clear(int i);
71         
72         int DiskInit66(void);
73         void PushStatus(int data);
74         unsigned char PopStatus();
75         void OutFDC(unsigned char data);
76         unsigned char InFDC();
77         void Read();
78         void Write(void);
79         void Seek(void);
80         void SenseInterruptStatus(void);
81         void Exec();
82         
83         void OutB1H_66(unsigned char data);
84         void OutB2H_66(unsigned char data);
85         void OutB3H_66(unsigned char data);
86         void OutD0H_66(unsigned char data);
87         void OutD1H_66(unsigned char data);
88         void OutD2H_66(unsigned char data);
89         void OutD3H_66(unsigned char data);
90         void OutD6H_66(unsigned char data);
91         void OutD8H_66(unsigned char data);
92         void OutDAH_66(unsigned char data);
93         void OutDDH_66(unsigned char data);
94         void OutDEH_66(unsigned char data);
95         
96         unsigned char InB2H_66();
97         unsigned char InD0H_66();
98         unsigned char InD1H_66();
99         unsigned char InD2H_66();
100         unsigned char InD3H_66();
101         unsigned char InD4H_66();
102         unsigned char InDCH_66();
103         unsigned char InDDH_66();
104         
105 public:
106         FLOPPY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
107         {
108                 d_noise_seek = NULL;
109 //              d_noise_head_down = NULL;
110 //              d_noise_head_up = NULL;
111                 set_device_name(_T("Floppy Drive"));
112         }
113         ~FLOPPY() {}
114         
115         // common functions
116         void initialize();
117         void release();
118         void reset();
119         void write_io8(uint32_t addr, uint32_t data);
120         uint32_t read_io8(uint32_t addr);
121         uint32_t read_signal(int ch);
122         void update_config();
123         bool process_state(FILEIO* state_fio, bool loading);
124         
125         // unique functions
126         void set_context_ext(DEVICE* device)
127         {
128                 d_ext = device;
129         }
130         void set_context_noise_seek(NOISE* device)
131         {
132                 d_noise_seek = device;
133         }
134         NOISE* get_context_noise_seek()
135         {
136                 return d_noise_seek;
137         }
138 //      void set_context_noise_head_down(NOISE* device)
139 //      {
140 //              d_noise_head_down = device;
141 //      }
142 //      NOISE* get_context_noise_head_down()
143 //      {
144 //              return d_noise_head_down;
145 //      }
146 //      void set_context_noise_head_up(NOISE* device)
147 //      {
148 //              d_noise_head_up = device;
149 //      }
150 //      NOISE* get_context_noise_head_up()
151 //      {
152 //              return d_noise_head_up;
153 //      }
154         DISK* get_disk_handler(int drv)
155         {
156                 return disk[drv];
157         }
158         void open_disk(int drv, const _TCHAR* file_path, int bank);
159         void close_disk(int drv);
160         bool is_disk_inserted(int drv);
161         void is_disk_protected(int drv, bool value);
162         bool is_disk_protected(int drv);
163 };
164
165 }
166 #endif
167