OSDN Git Service

26d617335b15557a10f91871009fd4534dfb548e
[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
27 class FLOPPY : public DEVICE
28 {
29 private:
30         DEVICE *d_ext;
31         unsigned char io_B1H;
32         
33         DISK* disk[2];
34         
35         int cur_trk[2];
36         int cur_sct[2];
37         int cur_pos[2];
38         bool access[2];
39         
40         int Seek88(int drvno, int trackno, int sectno);
41         unsigned char Getc88(int drvno);
42         int Putc88(int drvno, unsigned char dat);
43         
44         // data buffer (256BytesX4)
45         unsigned char Data[4][256];
46         int Index[4];
47         
48         typedef struct {
49                 unsigned char Data[10];
50                 int Index;
51         } CmdBuffer;
52         
53         CmdBuffer CmdIn;                                        // command buffer
54         CmdBuffer CmdOut;                               // status buffer
55         unsigned char SeekST0;                  // ST0 when SEEK
56         unsigned char LastCylinder;             // last read cylinder
57         int SeekEnd;                                            // complete seek flag
58         unsigned char SendSectors;              // amount(100H unit)
59         int DIO;                                                        // data direction TRUE: Buffer->CPU FALSE: CPU->Buffer
60         unsigned char Status;                   // FDC status register
61         
62         void Push(int part, unsigned char data);
63         unsigned char Pop(int part);
64         void Clear(int i);
65         
66         int DiskInit66(void);
67         void PushStatus(int data);
68         unsigned char PopStatus();
69         void OutFDC(unsigned char data);
70         unsigned char InFDC();
71         void Read();
72         void Write(void);
73         void Seek(void);
74         void SenseInterruptStatus(void);
75         void Exec();
76         
77         void OutB1H_66(unsigned char data);
78         void OutB2H_66(unsigned char data);
79         void OutB3H_66(unsigned char data);
80         void OutD0H_66(unsigned char data);
81         void OutD1H_66(unsigned char data);
82         void OutD2H_66(unsigned char data);
83         void OutD3H_66(unsigned char data);
84         void OutD6H_66(unsigned char data);
85         void OutD8H_66(unsigned char data);
86         void OutDAH_66(unsigned char data);
87         void OutDDH_66(unsigned char data);
88         void OutDEH_66(unsigned char data);
89         
90         unsigned char InB2H_66();
91         unsigned char InD0H_66();
92         unsigned char InD1H_66();
93         unsigned char InD2H_66();
94         unsigned char InD3H_66();
95         unsigned char InD4H_66();
96         unsigned char InDCH_66();
97         unsigned char InDDH_66();
98         
99 public:
100         FLOPPY(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) {}
101         ~FLOPPY() {}
102         
103         // common functions
104         void initialize();
105         void release();
106         void reset();
107         void write_io8(uint32 addr, uint32 data);
108         uint32 read_io8(uint32 addr);
109         uint32 read_signal(int ch);
110         void save_state(FILEIO* state_fio);
111         bool load_state(FILEIO* state_fio);
112         
113         // unique functions
114         void set_context_ext(DEVICE* device)
115         {
116                 d_ext = device;
117         }
118         void open_disk(int drv, _TCHAR* file_path, int offset);
119         void close_disk(int drv);
120         bool disk_inserted(int drv);
121 };
122
123 #endif
124