2 NEC PC-6001 Emulator 'yaPC-6001'
3 NEC PC-6001mkII Emulator 'yaPC-6201'
4 NEC PC-6001mkIISR Emulator 'yaPC-6401'
5 NEC PC-6601 Emulator 'yaPC-6601'
6 NEC PC-6601SR Emulator 'yaPC-6801'
8 Author : Takeda.Toshiya
21 void TIMER::initialize()
23 #if defined(_PC6601SR) || defined(_PC6001MK2SR)
24 memset(sr_vectors, 0, sizeof(sr_vectors));
38 #if defined(_PC6601SR) || defined(_PC6001MK2SR)
49 void TIMER::write_io8(uint32 addr, uint32 data)
52 #if defined(_PC6601SR) || defined(_PC6001MK2SR)
61 sr_vectors[addr & 7] = data;
66 // d_mem->set_portF3(data);
80 #if defined(_PC6601SR) || defined(_PC6001MK2SR)
91 uint32 TIMER::read_io8(uint32 addr)
94 #if defined(_PC6601SR) || defined(_PC6001MK2SR)
103 return sr_vectors[addr & 7];
115 #if defined(_PC6601SR) || defined(_PC6001MK2SR)
126 void TIMER::event_callback(int event_id, int err)
128 if(event_id == EVENT_TIMER) {
129 write_signal(SIG_TIMER_IRQ_TIMER, 1, 1);
131 // register next event
133 register_event(this, EVENT_TIMER, 2000.0, false, &timer_id);
135 #if defined(_PC6601SR) || defined(_PC6001MK2SR)
137 register_event(this, EVENT_TIMER, 2000.0 * (portF6 + 1) / 0x80, false, &timer_id);
140 register_event(this, EVENT_TIMER, 2000.0 * (portF6 + 1) / 4, false, &timer_id);
145 void TIMER::set_portB0(uint32 data)
150 cancel_event(this, timer_id);
157 // first period is 1msec
158 register_event(this, EVENT_TIMER, 1000.0, false, &timer_id);
160 #if defined(_PC6601SR) || defined(_PC6001MK2SR)
162 register_event(this, EVENT_TIMER, 2000.0 * (portF6 + 1) / 0x80, false, &timer_id);
165 register_event(this, EVENT_TIMER, 2000.0 * (portF6 + 1) / 4, false, &timer_id);
171 void TIMER::write_signal(int id, uint32 data, uint32 mask)
181 uint32 TIMER::get_intr_ack()
183 #if defined(_PC6601SR) || defined(_PC6001MK2SR)
185 for(int i = 0, bit = 1; i < 8; i++, bit <<= 1) {
189 return sr_vectors[i];
196 if(NewIRQ & 0x01) { // Sub-CPU
203 return d_sub->get_intr_ack();
206 else if(NewIRQ & 0x02) { // Joystick
214 else if(NewIRQ & 0x04) { // Timer
223 else if(NewIRQ & 0x08) { // Voice
227 else if(NewIRQ & 0x10) { // VRTC
231 else if(NewIRQ & 0x20) { // RS-232C
235 else if(NewIRQ & 0x40) { // Printer
239 else if(NewIRQ & 0x80) { // Ext Int
244 return 0x06; // dummy
247 void TIMER::notify_intr_reti()
252 void TIMER::update_intr()
256 NewIRQ &= 0x05; // Only Sub-CPU and Timer
258 #if defined(_PC6601SR) || defined(_PC6001MK2SR)
276 d_cpu->write_signal(SIG_CPU_IRQ, 1, 1);
278 // d_cpu->write_signal(SIG_CPU_IRQ, 0, 1);
282 #define STATE_VERSION 1
284 void TIMER::save_state(FILEIO* state_fio)
286 state_fio->FputUint32(STATE_VERSION);
287 state_fio->FputInt32(this_device_id);
289 state_fio->FputUint8(IRQ);
290 state_fio->FputUint8(NewIRQ);
291 state_fio->FputInt32(timer_id);
293 #if defined(_PC6601SR) || defined(_PC6001MK2SR)
294 state_fio->Fwrite(sr_vectors, sizeof(sr_vectors), 1);
295 state_fio->FputUint8(portFA);
296 state_fio->FputUint8(portFB);
298 state_fio->FputUint8(portF3);
299 state_fio->FputUint8(portF4);
300 state_fio->FputUint8(portF5);
301 state_fio->FputUint8(portF6);
302 state_fio->FputUint8(portF7);
306 bool TIMER::load_state(FILEIO* state_fio)
308 if(state_fio->FgetUint32() != STATE_VERSION) {
311 if(state_fio->FgetInt32() != this_device_id) {
314 IRQ = state_fio->FgetUint8();
315 NewIRQ = state_fio->FgetUint8();
316 timer_id = state_fio->FgetInt32();
318 #if defined(_PC6601SR) || defined(_PC6001MK2SR)
319 state_fio->Fread(sr_vectors, sizeof(sr_vectors), 1);
320 portFA = state_fio->FgetUint8();
321 portFB = state_fio->FgetUint8();
323 portF3 = state_fio->FgetUint8();
324 portF4 = state_fio->FgetUint8();
325 portF5 = state_fio->FgetUint8();
326 portF6 = state_fio->FgetUint8();
327 portF7 = state_fio->FgetUint8();