OSDN Git Service

[VM][STATE][PC9801][X1] Apply new state framework to PC9801 series and X1 series.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc9801 / cmt.h
1 /*
2         NEC PC-9801 Emulator 'ePC-9801'
3         NEC PC-9801E/F/M Emulator 'ePC-9801E'
4
5         Author : Takeda.Toshiya
6         Date   : 2011.04.08-
7
8         [ cmt ]
9 */
10
11 #ifndef _CMT_H_
12 #define _CMT_H_
13
14 #include "../vm.h"
15 #include "../../emu.h"
16 #include "../device.h"
17
18 #define SIG_CMT_OUT     0
19 #define SIG_CMT_TXRDY   1
20 #define SIG_CMT_RXRDY   2
21 #define SIG_CMT_TXEMP   3
22
23 // max 256kbytes
24 #define BUFFER_SIZE     0x40000
25
26 class CMT : public DEVICE
27 {
28 private:
29         DEVICE* d_sio;
30         
31         FILEIO* fio;
32         int bufcnt;
33         uint8_t buffer[BUFFER_SIZE];
34         bool play, rec, remote;
35         
36         void release_tape();
37         
38 public:
39         CMT(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
40         {
41                 set_device_name(_T("CMT I/F"));
42         }
43         ~CMT() {}
44         
45         // common functions
46         void initialize();
47         void release();
48         void reset();
49         void write_io8(uint32_t addr, uint32_t data);
50         void write_signal(int id, uint32_t data, uint32_t mask);
51         void decl_state();
52         void save_state(FILEIO* state_fio);
53         bool load_state(FILEIO* state_fio);
54         
55         // unique functions
56         void set_context_sio(DEVICE* device)
57         {
58                 d_sio = device;
59         }
60         void play_tape(const _TCHAR* file_path);
61         void rec_tape(const _TCHAR* file_path);
62         void close_tape();
63         bool is_tape_inserted()
64         {
65                 return (play || rec);
66         }
67 };
68
69 #endif
70