OSDN Git Service

[VM][FMTOWNS][MEMORY] Fix setup around memory banks by I/O 0404h and 0480h.
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz700 / quickdisk.h
1 /*
2         SHARP MZ-800 Emulator 'EmuZ-800'
3         SHARP MZ-1500 Emulator 'EmuZ-1500'
4         SHARP MZ-2200 Emulator 'EmuZ-2200'
5
6         Author : Takeda.Toshiya
7         Date   : 2011.02.17-
8
9         [ quick disk ]
10 */
11
12 #ifndef _QUICKDISK_H_
13 #define _QUICKDISK_H_
14
15 #include "../vm.h"
16 #include "../../emu.h"
17 #include "../device.h"
18
19 #define QUICKDISK_SIO_RTSA      0
20 #define QUICKDISK_SIO_DTRB      1
21 #define QUICKDISK_SIO_SYNC      2
22 #define QUICKDISK_SIO_RXDONE    3
23 #define QUICKDISK_SIO_DATA      4
24 #define QUICKDISK_SIO_BREAK     5
25
26 #define QUICKDISK_BUFFER_SIZE   65536
27
28 namespace MZ700 {
29
30 class QUICKDISK : public DEVICE
31 {
32 private:
33         DEVICE *d_sio;
34         
35         _TCHAR file_path[_MAX_PATH];
36         bool insert, protect, home;
37         bool modified;
38         bool accessed;
39         
40         uint16_t buffer[QUICKDISK_BUFFER_SIZE];
41         int buffer_ptr, write_ptr;
42         bool first_data;
43         bool send_break;
44         
45         bool wrga, mton, sync;
46         bool motor_on;
47         int restore_id, end_id;
48         
49         void restore();
50         void send_data();
51         void write_crc();
52         void end_of_disk();
53         void set_insert(bool val);
54         void set_protect(bool val);
55         void set_home(bool val);
56         void release_disk();
57         unsigned short calc_crc(int* buff, int size);
58         
59 public:
60         QUICKDISK(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu)
61         {
62                 set_device_name(_T("Quick Disk"));
63         }
64         ~QUICKDISK() {}
65         
66         // common functions
67         void initialize();
68         void release();
69         void reset();
70         void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask);
71         uint32_t __FASTCALL read_signal(int ch);
72         void __FASTCALL event_callback(int event_id, int err);
73         bool process_state(FILEIO* state_fio, bool loading);
74         
75         // unique functions
76         void set_context_sio(DEVICE* device)
77         {
78                 d_sio = device;
79         }
80         void open_disk(const _TCHAR* path);
81         void close_disk();
82         bool is_disk_inserted()
83         {
84                 return insert;
85         }
86 };
87
88 }
89 #endif
90