OSDN Git Service

[VM][WIP] Set default name to devices, these are WIP.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc6031.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         Skelton for retropc emulator
10
11         Author : Takeda.Toshiya
12         Origin : tanam
13         Date   : 2014.05.21-
14
15         [ PC-6031 ]
16 */
17
18 #ifndef _PC6031_H_
19 #define _PC6031_H_
20
21 #include "vm.h"
22 #include "../emu.h"
23 #include "device.h"
24
25 class DISK;
26
27 class PC6031 : public DEVICE
28 {
29 private:
30         DISK* disk[2];
31         
32         int cur_trk[2];
33         int cur_sct[2];
34         int cur_pos[2];
35         bool access[2];
36         
37         int Seek88(int drvno, int trackno, int sectno);
38         unsigned char Getc88(int drvno);
39         int Putc88(int drvno, unsigned char dat);
40         
41         typedef struct {
42                 int ATN;                                // attention
43                 int DAC;                                // data accepted
44                 int RFD;                                // ready for data
45                 int DAV;                                // data valid
46                 int command;                    // received command
47                 int step;                               // status for waiting parameter
48                 int blk;                                // block number
49                 int drv;                                // drive number - 1
50                 int trk;                                // track number
51                 int sct;                                // sector number
52                 int size;                               // byte number to process
53                 unsigned char retdat;   // return from port D0H
54         } DISK60;
55         
56         DISK60 mdisk;
57         unsigned char io_D1H;
58         unsigned char io_D2H, old_D2H;
59         unsigned char io_D3H;
60         int DrvNum;
61         
62         unsigned char FddIn60();
63         void FddOut60(unsigned char dat);
64         unsigned char FddCntIn60(void);
65         void FddCntOut60(unsigned char dat);
66         
67         void OutD1H_60(unsigned char data);
68         void OutD2H_60(unsigned char data);
69         void OutD3H_60(unsigned char data);
70         
71         unsigned char InD0H_60();
72         unsigned char InD1H_60();
73         unsigned char InD2H_60();
74         unsigned char InD3H_60();
75         
76 public:
77         PC6031(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) {
78                 set_device_name(_T("PSEUDO PC-6031"));
79         }
80         ~PC6031() {}
81         
82         // common functions
83         void initialize();
84         void release();
85         void write_io8(uint32_t addr, uint32_t data);
86         uint32_t read_io8(uint32_t addr);
87         uint32_t read_signal(int ch);
88         void save_state(FILEIO* state_fio);
89         bool load_state(FILEIO* state_fio);
90         
91         // unique functions
92         DISK* get_disk_handler(int drv)
93         {
94                 return disk[drv];
95         }
96         void open_disk(int drv, const _TCHAR* file_path, int bank);
97         void close_disk(int drv);
98         bool is_disk_inserted(int drv);
99         bool disk_ejected(int drv);
100         void is_disk_protected(int drv, bool value);
101         bool is_disk_protected(int drv);
102 };
103
104 #endif
105