2 NEC PC-9801 Emulator 'ePC-9801'
3 NEC PC-9801E/F/M Emulator 'ePC-9801E'
5 Author : Takeda.Toshiya
14 void CMT::initialize()
17 play = rec = remote = false;
29 play = rec = remote = false;
32 void CMT::write_io8(uint32_t addr, uint32_t data)
37 remote = ((data & 0x20) != 0);
42 void CMT::write_signal(int id, uint32_t data, uint32_t mask)
44 if(id == SIG_CMT_OUT) {
47 buffer[bufcnt++] = data & mask;
48 if(bufcnt >= BUFFER_SIZE) {
49 fio->Fwrite(buffer, bufcnt, 1);
56 void CMT::play_tape(const _TCHAR* file_path)
60 if(fio->Fopen(file_path, FILEIO_READ_BINARY)) {
61 fio->Fseek(0, FILEIO_SEEK_END);
62 int size = (fio->Ftell() + 9) & (BUFFER_SIZE - 1);
63 fio->Fseek(0, FILEIO_SEEK_SET);
64 memset(buffer, 0, sizeof(buffer));
65 fio->Fread(buffer, sizeof(buffer), 1);
68 // this implement does not care the sio buffer size... :-(
69 for(int i = 0; i < size; i++) {
70 d_sio->write_signal(SIG_I8251_RECV, buffer[i], 0xff);
76 void CMT::rec_tape(const _TCHAR* file_path)
80 if(fio->Fopen(file_path, FILEIO_WRITE_BINARY)) {
86 void CMT::close_tape()
92 d_sio->write_signal(SIG_I8251_CLEAR, 0, 0);
95 void CMT::release_tape()
99 fio->Fwrite(buffer, bufcnt, 1);
107 #define STATE_VERSION 1
109 void CMT::save_state(FILEIO* state_fio)
111 state_fio->FputUint32(STATE_VERSION);
112 state_fio->FputInt32(this_device_id);
114 state_fio->FputInt32(bufcnt);
115 state_fio->Fwrite(buffer, sizeof(buffer), 1);
116 state_fio->FputBool(play);
117 state_fio->FputBool(rec);
118 state_fio->FputBool(remote);
121 bool CMT::load_state(FILEIO* state_fio)
123 if(state_fio->FgetUint32() != STATE_VERSION) {
126 if(state_fio->FgetInt32() != this_device_id) {
129 bufcnt = state_fio->FgetInt32();
130 state_fio->Fread(buffer, sizeof(buffer), 1);
131 play = state_fio->FgetBool();
132 rec = state_fio->FgetBool();
133 remote = state_fio->FgetBool();