[VM][General] Fix state save/load.
#ifdef USE_LASER_DISC
fio->Fwrite(&laser_disc_status, sizeof(laser_disc_status), 1);
#endif
-#ifdef USE_FD1
- fio->Fwrite(floppy_disk_status, sizeof(floppy_disk_status), 1);
- fio->Fwrite(d88_file, sizeof(d88_file), 1);
-#endif
// save vm state
vm->save_state(fio);
// end of state file
{
state_fio->FputUint32_BE(STATE_VERSION);
state_fio->FputInt32_BE(this_device_id);
+ p_emu->out_debug_log("Save State: DISPLAY : id=%d ver=%d\n", this_device_id, STATE_VERSION);
{
int i;
if(this_device_id != state_fio->FgetInt32_BE()) {
return false;
}
+ p_emu->out_debug_log("Load State: DISPLAY : id=%d ver=%d\n", this_device_id, version);
if(version >= 1) {
int addr;
*
*/
+#include "emu.h"
#include "dummydevice.h"
-
DUMMYDEVICE::DUMMYDEVICE(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
status = 0x00000000;
clear_on_reset = true;
clear_with_zero = true;
+ p_emu = parent_emu;
}
DUMMYDEVICE::~DUMMYDEVICE()
{
state_fio->FputUint32_BE(STATE_VERSION);
state_fio->FputInt32_BE(this_device_id);
+ p_emu->out_debug_log("Save State: DUMMYDEVICE: id=%d ver=%d\n", this_device_id, STATE_VERSION);
// Version 1
{
state_fio->FputUint32_BE(status);
{
uint32_t version;
version = state_fio->FgetUint32_BE();
+ p_emu->out_debug_log("Load State: DUMMYDEVICE: id=%d ver=%d\n", this_device_id, version);
if(this_device_id != state_fio->FgetInt32_BE()) return false;
// Version 1
- if((version < 1) || (version > STATE_VERSION)) return false;
{
status = state_fio->FgetUint32_BE();
clear_on_reset = state_fio->FgetBool();
clear_with_zero = state_fio->FgetBool();
}
+ if(version != STATE_VERSION) return false;
return true;
}
SIG_DUMMYDEVICE_CLEAR_ON_RESET,
SIG_DUMMYDEVICE_CLEAR_WITH_ZERO,
};
+class EMU;
class DUMMYDEVICE : public DEVICE {
private:
+ EMU *p_emu;
uint32_t status;
bool clear_on_reset;
bool clear_with_zero;
void VM::save_state(FILEIO* state_fio)
{
state_fio->FputUint32_BE(STATE_VERSION);
-
for(DEVICE* device = first_device; device; device = device->next_device) {
device->save_state(state_fio);
}
{
uint32_t version = state_fio->FgetUint32_BE();
int i = 1;
- if(version > STATE_VERSION) {
+ if(version != STATE_VERSION) {
return false;
}
for(DEVICE* device = first_device; device; device = device->next_device) {
return false;
}
}
- if(version >= 1) {// V1
- if(version == 3) return true;
- }
- return false;
+ return true;
}
#ifdef USE_DIG_RESOLUTION
int addr;
state_fio->FputUint32_BE(STATE_VERSION);
state_fio->FputInt32_BE(this_device_id);
+ p_emu->out_debug_log("Save State: MAINIO: id=%d ver=%d\n", this_device_id, STATE_VERSION);
// Version 1
{
version = state_fio->FgetUint32_BE();
if(this_device_id != state_fio->FgetInt32_BE()) return false;
+ p_emu->out_debug_log("Load State: MAINIO: id=%d ver=%d\n", this_device_id, version);
if(version >= 1) {
for(addr = 0; addr < 0x100; addr++) io_w_latch[addr] = state_fio->FgetUint8();
{
state_fio->FputUint32_BE(STATE_VERSION);
state_fio->FputInt32_BE(this_device_id);
+ p_emu->out_debug_log("Save State: MAINMEM: id=%d ver=%d\n", this_device_id, STATE_VERSION);
// V1
state_fio->FputBool(ioaccess_wait);
uint32_t version;
version = state_fio->FgetUint32_BE();
if(this_device_id != state_fio->FgetInt32_BE()) return false;
+ p_emu->out_debug_log("Load State: MAINMEM: id=%d ver=%d\n", this_device_id, version);
if(version >= 1) {
// V1
ioaccess_wait = state_fio->FgetBool();
#endif
if(version == 1) return true;
}
- if(version >= 2) { // V2;
+ { // V2;
is_basicrom = state_fio->FgetBool();
clockmode = state_fio->FgetBool();
basicrom_fd0f = state_fio->FgetBool();
state_fio->Fread(mmr_map_data, sizeof(mmr_map_data), 1);
#endif
}
+ if(version != STATE_VERSION) return false;
return true;
}
memset(bubble_data, 0x00, 0x20000);
bubble_inserted = false;
read_access = write_access = false;
+ p_emu = parent_emu;
}
BUBBLECASETTE::~BUBBLECASETTE()
int i, j;
state_fio->FputUint32_BE(STATE_VERSION);
state_fio->FputInt32_BE(this_device_id);
+ p_emu->out_debug_log("Save State: BUBBLE: id=%d ver=%d\n", this_device_id, STATE_VERSION);
// Attributes
state_fio->FputUint32_BE(file_length);
int i, j;
if(state_fio->FgetUint32_BE() != STATE_VERSION) return false;
if(state_fio->FgetInt32_BE() != this_device_id) return false;
+ p_emu->out_debug_log("Load State: BUBBLE: id=%d ver=%d\n", this_device_id, STATE_VERSION);
// Attributes
file_length = state_fio->FgetUint32_BE();
int i;
state_fio->FputUint32_BE(STATE_VERSION);
state_fio->FputInt32_BE(this_device_id);
+ p_emu->out_debug_log("Save State: HD6844: id=%d ver=%d\n", this_device_id, STATE_VERSION);
{ // V1
for(i = 0; i < 4; i++) {
state_fio->FputUint32_BE(addr_reg[i]);
int i;
version = state_fio->FgetUint32_BE();
if(this_device_id != state_fio->FgetInt32_BE()) return false;
+ p_emu->out_debug_log("Load State: HD6844: id=%d ver=%d\n", this_device_id, version);
if(version >= 1) {
for(i = 0; i < 4; i++) {
addr_reg[i] = state_fio->FgetUint32_BE();
lx = ly = -1;
mouse_button = 0x00;
mouse_timeout_event = -1;
- port_a_val = 0;
- port_b_val = 0;
lpmask = 0x00;
lpt_type = config.printer_device_type;
+ port_b_val = 0;
}
void JOYSTICK::reset()
uint32_t retval = 0xff;
uint32_t val;
#if !defined(_FM8)
+ mouse_state = p_emu->get_mouse_buffer();
if(mouse_state != NULL) {
dx += (mouse_state[0] / 2);
dy += (mouse_state[1] / 2);
case 0: // OPN
//opn->write_io8(0, 0x0f);
//opnval = opn->read_io8(1);
- opnval = port_b_val;
+ opnval = (uint32_t)port_b_val;
if(emulate_mouse[0]) {
if((opnval & 0xc0) == 0x00) {
return update_mouse((opnval & 0x03) << 4);
emulate_mouse[1] = val_b;
break;
case FM7_JOYSTICK_MOUSE_STROBE:
- port_b_val = data;
+ port_b_val = (uint8_t)data;
if(emulate_mouse[0]) {
update_strobe(((data & 0x10) != 0));
} else if(emulate_mouse[1]) {
}
#endif
}
-#define STATE_VERSION 3
+#define STATE_VERSION 4
void JOYSTICK::save_state(FILEIO *state_fio)
{
int ch;
state_fio->FputUint32_BE(STATE_VERSION);
state_fio->FputInt32_BE(this_device_id);
+ p_emu->out_debug_log("Save State: JOYSTICK: id=%d ver=%d\n", this_device_id, STATE_VERSION);
// Version 1
for(ch = 0; ch < 2; ch++) {
#if !defined(_FM8)
#endif
// Version 3
state_fio->FputUint8(lpmask);
+ // Version 4
+ state_fio->FputUint8(port_b_val);
}
bool JOYSTICK::load_state(FILEIO *state_fio)
uint32_t devid = state_fio->FgetInt32_BE();
bool stat = false;
int ch;
+ p_emu->out_debug_log("Load State: JOYSTICK: id=%d ver=%d\n", devid, version);
if(devid != this_device_id) return stat;
if(version >= 1) {
for(ch = 0; ch < 2; ch++) {
#endif
joydata[ch] = state_fio->FgetUint32_BE();
}
- if(version == 1) stat = true;
+ //if(version == 1) stat = true;
}
#if !defined(_FM8)
// After version 2.
mouse_data = state_fio->FgetUint32_BE();
//mouse_timeout_event = state_fio->FgetInt32();
#endif
+ // V3
lpmask = state_fio->FgetUint8();
- if(version == 3) stat = true;
+ lpt_type = config.printer_device_type;
+ // V4
+ port_b_val = state_fio->FgetUint8();
+ if(version == STATE_VERSION) stat = true;
return stat;
}
uint32_t mouse_data;
int mouse_phase;
int mouse_timeout_event;
- uint32_t port_a_val;
- uint32_t port_b_val;
+ uint8_t port_b_val;
uint8_t lpmask;
int lpt_type;
protected:
*/
#include "../../fileio.h"
+#include "emu.h"
#include "fm7_common.h"
#include "kanjirom.h"
fio = new FILEIO();
memset(data_table, 0xff, 0x20000);
// read_table[0].memory = data_table;
-
+ p_emu = parent_emu;
if(type_2std) {
class2 = true;
if(fio->Fopen(create_local_path(_T("KANJI2.ROM")), FILEIO_READ_BINARY)) {
{
state_fio->FputUint32_BE(STATE_VERSION);
state_fio->FputInt32_BE(this_device_id);
+ p_emu->out_debug_log("Save State: KANJIROM: id=%d ver=%d\n", this_device_id, STATE_VERSION);
state_fio->FputBool(class2);
state_fio->FputBool(read_ok);
uint32_t version;
version = state_fio->FgetUint32_BE();
if(this_device_id != state_fio->FgetInt32_BE()) return false;
+ p_emu->out_debug_log("Load State: KANJIROM: id=%d ver=%d\n", this_device_id, version);
if(version >= 1) {
class2 = state_fio->FgetBool();
#include "../device.h"
#include "../mc6809.h"
+class EMU;
+
class KANJIROM: public DEVICE {
private:
+ EMU *p_emu;
uint8_t data_table[0x20000];
bool read_ok;
bool class2;
{
state_fio->FputUint32_BE(STATE_VERSION);
state_fio->FputInt32_BE(this_device_id);
+ p_emu->out_debug_log("Save State: KEYBOARD: id=%d ver=%d\n", this_device_id, STATE_VERSION);
// Version 1
{
version = state_fio->FgetUint32_BE();
if(this_device_id != state_fio->FgetInt32_BE()) return false;
+ p_emu->out_debug_log("Load State: KEYBOARD: id=%d ver=%d\n", this_device_id, version);
if(version >= 1) {
keycode_7 = state_fio->FgetUint32_BE();
did_hidden_message_av_1 = state_fio->FgetBool();
#endif
}
- if(version == 2) {
+ if(version == STATE_VERSION) {
return true;
}
return false;
do_compare(addr);
break;
}
- //printf("ALU DMYREAD ADDR=%04x, CMD=%02x CMP STATUS=%02x\n", addr, command_reg, cmp_status_reg);
+ //p_emu->out_debug_log("ALU DMYREAD ADDR=%04x, CMD=%02x CMP STATUS=%02x\n", addr, command_reg, cmp_status_reg);
//if(eventid_busy >= 0) cancel_event(this, eventid_busy) ;
//register_event(this, EVENT_MB61VH010_BUSY_OFF, 1.0 / 16.0, false, &eventid_busy) ;
}
xcount = abs(ax);
ycount = abs(ay);
- //printf("LINE: (%d,%d)-(%d,%d)\n", x_begin, y_begin, x_end , y_end);
+ //p_emu->out_debug_log("LINE: (%d,%d)-(%d,%d)\n", x_begin, y_begin, x_end , y_end);
if(ycount == 0) {
if(ax > 0) {
if((cpx_t & 0x07) != 7) total_bytes = 1;
//if(!lastflag) total_bytes++;
if(alu_addr < 0x8000) do_alucmds(alu_addr);
- if(total_bytes > 16) { // Over 1.0us
- usec = (double)total_bytes / 16.0;
- if(eventid_busy >= 0) cancel_event(this, eventid_busy) ;
- register_event(this, EVENT_MB61VH010_BUSY_OFF, usec, false, &eventid_busy) ;
- } else {
- busy_flag = false;
- }
+ //if(total_bytes > 16) { // Over 1.0us
+ usec = (double)total_bytes / 16.0;
+ if(eventid_busy >= 0) cancel_event(this, eventid_busy) ;
+ register_event(this, EVENT_MB61VH010_BUSY_OFF, usec, false, &eventid_busy) ;
+ //} else {
+ // busy_flag = false;
+ //}
}
bool MB61VH010::put_dot(int x, int y)
void MB61VH010::write_data8(uint32_t id, uint32_t data)
{
- //printf("ALU: ADDR=%02x DATA=%02x\n", id, data);
+ //p_emu->out_debug_log("ALU: ADDR=%02x DATA=%02x\n", id, data);
if(id == ALU_CMDREG) {
command_reg = data;
return;
int i;
state_fio->FputUint32(STATE_VERSION);
state_fio->FputInt32(this_device_id);
+ p_emu->out_debug_log("Save State: MB61VH010 : id=%d ver=%d\n", this_device_id, STATE_VERSION);
{ // V1
state_fio->FputUint8(command_reg);
{
uint32_t version = state_fio->FgetUint32();
int i;
-
+ p_emu->out_debug_log("Load State: MB61VH010 : id=%d ver=%d\n", this_device_id, version);
if(this_device_id != state_fio->FgetInt32()) return false;
if(version >= 1) {
command_reg = state_fio->FgetUint8();
line_style.d = 0;
line_style.w.l = state_fio->FgetUint16_BE();
}
+ if(version != STATE_VERSION) return false;
return true;
}