2 FUJITSU FMR-50 Emulator 'eFMR-50'
3 FUJITSU FMR-60 Emulator 'eFMR-60'
5 Author : Takeda.Toshiya
13 #include "../msm58321.h"
14 #include "../pcm1bit.h"
16 void TIMER::initialize()
19 intr_reg = rtc_data = 0;
20 tmout0 = tmout1 = false;
23 void TIMER::write_io8(uint32 addr, uint32 data)
32 d_pcm->write_signal(SIG_PCM1BIT_ON, data, 4);
35 d_rtc->write_signal(SIG_MSM58321_DATA, data, 0x0f);
38 d_rtc->write_signal(SIG_MSM58321_CS, data, 0x80);
39 d_rtc->write_signal(SIG_MSM58321_READ, data, 0x04);
40 d_rtc->write_signal(SIG_MSM58321_WRITE, data, 0x02);
41 d_rtc->write_signal(SIG_MSM58321_ADDR_WRITE, data, 0x01);
46 uint32 TIMER::read_io8(uint32 addr)
50 free_run_counter = (uint16)passed_usec(0);
51 return free_run_counter & 0xff;
53 return free_run_counter >> 8;
55 return (tmout0 ? 1 : 0) | (tmout1 ? 2 : 0) | ((intr_reg & 7) << 2) | 0xe0;
62 void TIMER::write_signal(int id, uint32 data, uint32 mask)
64 if(id == SIG_TIMER_CH0) {
69 } else if(id == SIG_TIMER_CH1) {
70 tmout1 = ((data & mask) != 0);
72 } else if(id == SIG_TIMER_RTC) {
73 rtc_data = (data & mask) | (rtc_data & ~mask);
77 void TIMER::update_intr()
79 if((tmout0 && (intr_reg & 1)) || (tmout1 && (intr_reg & 2))) {
80 d_pic->write_signal(SIG_I8259_CHIP0 | SIG_I8259_IR0, 1, 1);
82 d_pic->write_signal(SIG_I8259_CHIP0 | SIG_I8259_IR0, 0, 1);
86 #define STATE_VERSION 1
88 void TIMER::save_state(FILEIO* state_fio)
90 state_fio->FputUint32(STATE_VERSION);
91 state_fio->FputInt32(this_device_id);
93 state_fio->FputUint16(free_run_counter);
94 state_fio->FputUint8(intr_reg);
95 state_fio->FputUint8(rtc_data);
96 state_fio->FputBool(tmout0);
97 state_fio->FputBool(tmout1);
100 bool TIMER::load_state(FILEIO* state_fio)
102 if(state_fio->FgetUint32() != STATE_VERSION) {
105 if(state_fio->FgetInt32() != this_device_id) {
108 free_run_counter = state_fio->FgetUint16();
109 intr_reg = state_fio->FgetUint8();
110 rtc_data = state_fio->FgetUint8();
111 tmout0 = state_fio->FgetBool();
112 tmout1 = state_fio->FgetBool();