void IOCTRL::initialize()
{
// init keyboard
- key_stat = emu->key_buffer();
- mouse_stat = emu->mouse_buffer();
+ key_stat = emu->get_key_buffer();
+ mouse_stat = emu->get_mouse_buffer();
key_buf = new FIFO(64);
caps = kana = false;
update_key();
}
-void IOCTRL::write_io8(uint32 addr, uint32 data)
+void IOCTRL::write_io8(uint32_t addr, uint32_t data)
{
switch(addr & 0x3f0) {
case 0x22:
}
}
-uint32 IOCTRL::read_io8(uint32 addr)
+uint32_t IOCTRL::read_io8(uint32_t addr)
{
switch(addr & 0x3ff) {
case 0x20:
update_key();
return key_val;
case 0x22:
- if(config.monitor_type) {
- return key_mouse | 0x0d; // virt monitor
- } else {
- return key_mouse | 0x2d; // horiz monitor
+ // bit1: 0 = Color Mode, 1 = Monochrome Mode
+ // bit2: 1 = Double FDD, 0 = Single FDD
+ // bit3: 1 = 2D, 0 = 2DD
+ // bit4: 1 = KD, 0 = MD
+ // bit5: 1 = Horizontal Monitor, 0 = Virtical Monitor
+ {
+ uint32_t value = key_mouse | 0x05;
+ if(!config.drive_type) {
+ value |= 0x08; // 2D
+ }
+ if(!config.monitor_type) {
+ value |= 0x20; // Horizontal Monitor
+ }
+ return value;
}
}
return 0xff;
}
// mouse
if(key_buf->empty()) {
- uint8 val = 0;
+ uint8_t val = 0;
if(!(mouse_stat[2] & 1)) val |= 1;
if(!(mouse_stat[2] & 2)) val |= 2;
if(caps) val |= 0x10;
}
}
-void IOCTRL::write_signal(int id, uint32 data, uint32 mask)
+void IOCTRL::write_signal(int id, uint32_t data, uint32_t mask)
{
bool next = ((data & mask) != 0);
if(!key_res && next) {
#define STATE_VERSION 1
-void IOCTRL::save_state(FILEIO* state_fio)
+bool IOCTRL::process_state(FILEIO* state_fio, bool loading)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
- state_fio->FputBool(caps);
- state_fio->FputBool(kana);
- key_buf->save_state((void *)state_fio);
- state_fio->FputUint32(key_val);
- state_fio->FputUint32(key_mouse);
- state_fio->FputInt32(key_prev);
- state_fio->FputBool(key_res);
- state_fio->FputBool(key_done);
- state_fio->FputInt32(register_id);
- state_fio->FputUint8(ts);
-}
-
-bool IOCTRL::load_state(FILEIO* state_fio)
-{
- if(state_fio->FgetUint32() != STATE_VERSION) {
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
- caps = state_fio->FgetBool();
- kana = state_fio->FgetBool();
- if(!key_buf->load_state((void *)state_fio)) {
+ state_fio->StateBool(caps);
+ state_fio->StateBool(kana);
+ if(!key_buf->process_state((void *)state_fio, loading)) {
return false;
}
- key_val = state_fio->FgetUint32();
- key_mouse = state_fio->FgetUint32();
- key_prev = state_fio->FgetInt32();
- key_res = state_fio->FgetBool();
- key_done = state_fio->FgetBool();
- register_id = state_fio->FgetInt32();
- ts = state_fio->FgetUint8();
+ state_fio->StateUint32(key_val);
+ state_fio->StateUint32(key_mouse);
+ state_fio->StateInt32(key_prev);
+ state_fio->StateBool(key_res);
+ state_fio->StateBool(key_done);
+ state_fio->StateInt32(register_id);
+ state_fio->StateUint8(ts);
return true;
}
-