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;
18 buffer_size = BUFFER_SIZE;
30 play = rec = remote = false;
33 void CMT::write_io8(uint32 addr, uint32 data)
35 remote = ((data & 0x20) != 0);
38 void CMT::write_signal(int id, uint32 data, uint32 mask)
40 if(id == SIG_CMT_OUT) {
43 buffer[bufcnt++] = data & mask;
44 if(bufcnt >= BUFFER_SIZE) {
45 fio->Fwrite(buffer, bufcnt, 1);
52 void CMT::play_tape(_TCHAR* file_path)
56 if(fio->Fopen(file_path, FILEIO_READ_BINARY)) {
57 fio->Fseek(0, FILEIO_SEEK_END);
58 int size = (fio->Ftell() + 9) & (BUFFER_SIZE - 1);
59 fio->Fseek(0, FILEIO_SEEK_SET);
60 memset(buffer, 0, sizeof(buffer));
62 fio->Fread(buffer, sizeof(buffer), 1);
65 // this implement does not care the sio buffer size... :-(
66 for(int i = 0; i < size; i++) {
67 d_sio->write_signal(SIG_I8251_RECV, buffer[i], 0xff);
73 void CMT::rec_tape(_TCHAR* file_path)
77 if(fio->Fopen(file_path, FILEIO_WRITE_BINARY)) {
83 void CMT::close_tape()
87 buffer_size = BUFFER_SIZE;
89 d_sio->write_signal(SIG_I8251_CLEAR, 0, 0);
92 void CMT::release_tape()
96 fio->Fwrite(buffer, bufcnt, 1);
105 void CMT::mix(int32 *buffer, int cnt)
108 // Not implemented yet :)
112 #define STATE_VERSION 1
114 void CMT::save_state(FILEIO* state_fio)
116 state_fio->FputUint32(STATE_VERSION);
117 state_fio->FputInt32(this_device_id);
119 state_fio->FputInt32(bufcnt);
120 state_fio->Fwrite(buffer, sizeof(buffer), 1);
121 state_fio->FputBool(play);
122 state_fio->FputBool(rec);
123 state_fio->FputBool(remote);
126 bool CMT::load_state(FILEIO* state_fio)
128 if(state_fio->FgetUint32() != STATE_VERSION) {
131 if(state_fio->FgetInt32() != this_device_id) {
134 bufcnt = state_fio->FgetInt32();
135 state_fio->Fread(buffer, sizeof(buffer), 1);
136 play = state_fio->FgetBool();
137 rec = state_fio->FgetBool();
138 remote = state_fio->FgetBool();