[ memory ]
*/
-#include "memory.h"
+#include "./memory.h"
#include "../datarec.h"
static const uint8_t key_map[9][8] = {
} \
}
-void MEMORY::initialize()
+void PHC20_MEMORY::initialize()
{
memset(rom, 0xff, sizeof(rom));
memset(rdmy, 0xff, sizeof(rdmy));
register_frame_event(this);
}
-void MEMORY::reset()
+void PHC20_MEMORY::reset()
{
memset(ram, 0, sizeof(ram));
memset(vram, 0, sizeof(vram));
sysport = 0;
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void PHC20_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
addr &= 0xffff;
if((0x3000 <= addr && addr < 0x4000) || 0x4400 <= addr) {
wbank[addr >> 10][addr & 0x3ff] = data;
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t PHC20_MEMORY::read_data8(uint32_t addr)
{
addr &= 0xffff;
if((0x3000 <= addr && addr < 0x4000) || 0x4400 <= addr) {
return rbank[addr >> 10][addr & 0x3ff];
}
-void MEMORY::event_frame()
+void PHC20_MEMORY::event_frame()
{
memset(status, 0, sizeof(status));
}
}
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void PHC20_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
{
if(data & mask) {
sysport |= mask;
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void MEMORY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
- DECL_STATE_ENTRY_1D_ARRAY(status, sizeof(status));
- DECL_STATE_ENTRY_UINT8(sysport);
-
- leave_decl_state();
-}
-
-void MEMORY::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->Fwrite(ram, sizeof(ram), 1);
-// state_fio->Fwrite(vram, sizeof(vram), 1);
-// state_fio->Fwrite(status, sizeof(status), 1);
-// state_fio->FputUint8(sysport);
-}
-
-bool MEMORY::load_state(FILEIO* state_fio)
-{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- return false;
- }
-// if(state_fio->FgetUint32() != STATE_VERSION) {
-// return false;
-// }
-// if(state_fio->FgetInt32() != this_device_id) {
-// return false;
-// }
-// state_fio->Fread(ram, sizeof(ram), 1);
-// state_fio->Fread(vram, sizeof(vram), 1);
-// state_fio->Fread(status, sizeof(status), 1);
-// sysport = state_fio->FgetUint8();
- return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool PHC20_MEMORY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ memory ]
*/
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _PHC20_MEMORY_H_
+#define _PHC20_MEMORY_H_
#include "../vm.h"
#include "../../emu.h"
#define SIG_MEMORY_SYSPORT 0
-class MEMORY : public DEVICE
+class PHC20_MEMORY : public DEVICE
{
private:
DEVICE *d_drec;
uint8_t sysport;
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ PHC20_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~PHC20_MEMORY() {}
// common functions
void initialize();
uint32_t read_data8(uint32_t addr);
void event_frame();
void write_signal(int id, uint32_t data, uint32_t mask);
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_drec(DEVICE* device)
#include "../debugger.h"
#endif
-#include "memory.h"
+#include "./memory.h"
// ----------------------------------------------------------------------------
// initialize
drec->set_context_noise_fast(new NOISE(this, emu));
vdp = new MC6847(this, emu);
cpu = new Z80(this, emu);
- memory = new MEMORY(this, emu);
+ memory = new PHC20_MEMORY(this, emu);
// set contexts
event->set_context_cpu(cpu);
event->set_context_sound(drec);
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
- decl_state();
}
VM::~VM()
#define STATE_VERSION 3
-#include "../../statesub.h"
-#include "../../qt/gui/csp_logger.h"
-extern CSP_Logger DLL_PREFIX_I *csp_logger;
-
-void VM::decl_state(void)
-{
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PHC_20_HEAD")), csp_logger);
-
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->decl_state();
- }
-}
-
-void VM::save_state(FILEIO* state_fio)
-{
- //state_fio->FputUint32(STATE_VERSION);
-
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->save_state(state_fio);
- }
-}
-
-bool VM::load_state(FILEIO* state_fio)
-{
- //if(state_fio->FgetUint32() != STATE_VERSION) {
- // return false;
- //}
-
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- emu->out_debug_log("INFO: HEADER DATA ERROR");
- return false;
- }
- for(DEVICE* device = first_device; device; device = device->next_device) {
- if(!device->load_state(state_fio)) {
- return false;
- }
- }
- return true;
-}
-
bool VM::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- for(DEVICE* device = first_device; device; device = device->next_device) {
- const char *name = typeid(*device).name() + 6; // skip "class "
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ // Note: typeid(foo).name is fixed by recent ABI.Not dec 6.
+ // const char *name = typeid(*device).name();
+ // But, using get_device_name() instead of typeid(foo).name() 20181008 K.O
+ const char *name = device->get_device_name();
int len = strlen(name);
if(!state_fio->StateCheckInt32(len)) {
+ if(loading) {
+ printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
return false;
}
if(!state_fio->StateCheckBuffer(name, len, 1)) {
- return false;
- }
+ if(loading) {
+ printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
+ return false;
+ }
if(!device->process_state(state_fio, loading)) {
- return false;
- }
- }
+ if(loading) {
+ printf("Data loading Error: DEVID=%d\n", device->this_device_id);
+ }
+ return false;
+ }
+ }
+ // Machine specified.
return true;
}
class MC6847;
class Z80;
-class MEMORY;
+class PHC20_MEMORY;
class VM : public VM_TEMPLATE
{
MC6847* vdp;
Z80* cpu;
- MEMORY* memory;
+ PHC20_MEMORY* memory;
public:
// ----------------------------------------
bool is_frame_skippable();
void update_config();
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// ----------------------------------------
// for each device
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void KEYBOARD::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-#ifdef _MAP1010
- DECL_STATE_ENTRY_INT32(kana_pressed);
-#else
- DECL_STATE_ENTRY_1D_ARRAY(status, sizeof(status));
-#endif
- leave_decl_state();
-}
-
-void KEYBOARD::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-//
-//#ifdef _MAP1010
-// state_fio->FputInt32(kana_pressed);
-//#else
-// state_fio->Fwrite(status, sizeof(status), 1);
-//#endif
-}
-
-bool KEYBOARD::load_state(FILEIO* state_fio)
-{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- return false;
- }
-// if(state_fio->FgetUint32() != STATE_VERSION) {
-// return false;
-// }
-// if(state_fio->FgetInt32() != this_device_id) {
-// return false;
-// }
-//#ifdef _MAP1010
-// kana_pressed = state_fio->FgetInt32();
-//#else
-// state_fio->Fread(status, sizeof(status), 1);
-//#endif
- return true;
-}
-
bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void reset();
uint32_t read_io8(uint32_t addr);
void event_frame();
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
};
#endif
[ memory ]
*/
-#include "memory.h"
+#include "./memory.h"
#define SET_BANK(s, e, w, r) { \
int sb = (s) >> 11, eb = (e) >> 11; \
} \
}
-void MEMORY::initialize()
+void PHC25_MEMORY::initialize()
{
memset(rom, 0xff, sizeof(rom));
memset(rdmy, 0xff, sizeof(rdmy));
#endif
}
-void MEMORY::reset()
+void PHC25_MEMORY::reset()
{
memset(ram, 0, sizeof(ram));
memset(vram, 0, sizeof(vram));
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void PHC25_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
addr &= 0xffff;
#ifdef _MAP1010
wbank[addr >> 11][addr & 0x7ff] = data;
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t PHC25_MEMORY::read_data8(uint32_t addr)
{
addr &= 0xffff;
#ifdef _MAP1010
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void MEMORY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
-
- leave_decl_state();
-}
-
-void MEMORY::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->Fwrite(ram, sizeof(ram), 1);
-// state_fio->Fwrite(vram, sizeof(vram), 1);
-}
-
-bool MEMORY::load_state(FILEIO* state_fio)
-{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- return false;
- }
-// if(state_fio->FgetUint32() != STATE_VERSION) {
-// return false;
-// }
-// if(state_fio->FgetInt32() != this_device_id) {
-// return false;
-// }
-// state_fio->Fread(ram, sizeof(ram), 1);
-// state_fio->Fread(vram, sizeof(vram), 1);
- return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool PHC25_MEMORY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ memory ]
*/
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _PHC25_MEMORY_H_
+#define _PHC25_MEMORY_H_
#include "../vm.h"
#include "../../emu.h"
#include "../device.h"
-class MEMORY : public DEVICE
+class PHC25_MEMORY : public DEVICE
{
private:
DEVICE *d_kbd;
uint8_t* rbank[32];
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ PHC25_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~PHC25_MEMORY() {}
// common functions
void initialize();
void reset();
void write_data8(uint32_t addr, uint32_t data);
uint32_t read_data8(uint32_t addr);
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_keyboard(DEVICE* device)
#include "joystick.h"
#include "keyboard.h"
-#include "memory.h"
-#include "system.h"
+#include "./memory.h"
+#include "./system.h"
// ----------------------------------------------------------------------------
// initialize
joystick = new JOYSTICK(this, emu);
keyboard = new KEYBOARD(this, emu);
- memory = new MEMORY(this, emu);
- system = new SYSTEM(this, emu);
+ memory = new PHC25_MEMORY(this, emu);
+ system = new PHC25_SYSTEM(this, emu);
// set contexts
event->set_context_cpu(cpu);
event->set_context_sound(psg);
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
- decl_state();
}
VM::~VM()
#define STATE_VERSION 4
-#include "../../statesub.h"
-#include "../../qt/gui/csp_logger.h"
-extern CSP_Logger DLL_PREFIX_I *csp_logger;
-
-void VM::decl_state(void)
-{
-#if defined(_PHC25)
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PHC_25_HEAD")), csp_logger);
-#elif defined(_MAP1010)
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::MAP_1010_HEAD")), csp_logger);
-#else
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PHC_25_SERIES_HEAD")), csp_logger);
-#endif
-
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->decl_state();
- }
-}
-
-void VM::save_state(FILEIO* state_fio)
-{
- //state_fio->FputUint32(STATE_VERSION);
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->save_state(state_fio);
- }
-}
-
-bool VM::load_state(FILEIO* state_fio)
-{
- //if(state_fio->FgetUint32() != STATE_VERSION) {
- // return false;
- //}
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- emu->out_debug_log("INFO: HEADER DATA ERROR");
- return false;
- }
-
- for(DEVICE* device = first_device; device; device = device->next_device) {
- if(!device->load_state(state_fio)) {
- return false;
- }
- }
- return true;
-}
-
bool VM::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- for(DEVICE* device = first_device; device; device = device->next_device) {
- const char *name = typeid(*device).name() + 6; // skip "class "
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ // Note: typeid(foo).name is fixed by recent ABI.Not dec 6.
+ // const char *name = typeid(*device).name();
+ // But, using get_device_name() instead of typeid(foo).name() 20181008 K.O
+ const char *name = device->get_device_name();
int len = strlen(name);
if(!state_fio->StateCheckInt32(len)) {
+ if(loading) {
+ printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
return false;
}
if(!state_fio->StateCheckBuffer(name, len, 1)) {
- return false;
- }
+ if(loading) {
+ printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
+ return false;
+ }
if(!device->process_state(state_fio, loading)) {
- return false;
- }
- }
+ if(loading) {
+ printf("Data loading Error: DEVID=%d\n", device->this_device_id);
+ }
+ return false;
+ }
+ }
+ // Machine specified.
return true;
}
class JOYSTICK;
class KEYBOARD;
-class MEMORY;
-class SYSTEM;
+class PHC25_MEMORY;
+class PHC25_SYSTEM;
class VM : public VM_TEMPLATE
{
JOYSTICK* joystick;
KEYBOARD* keyboard;
- MEMORY* memory;
- SYSTEM* system;
+ PHC25_MEMORY* memory;
+ PHC25_SYSTEM* system;
public:
// ----------------------------------------
bool is_frame_skippable();
void update_config();
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// ----------------------------------------
// for each device
[ system port ]
*/
-#include "system.h"
+#include "./system.h"
#include "../datarec.h"
#include "../mc6847.h"
-void SYSTEM::initialize()
+void PHC25_SYSTEM::initialize()
{
sysport = 0;
}
-void SYSTEM::reset()
+void PHC25_SYSTEM::reset()
{
d_vdp->write_signal(SIG_MC6847_INTEXT, 1, 1);
}
-void SYSTEM::write_io8(uint32_t addr, uint32_t data)
+void PHC25_SYSTEM::write_io8(uint32_t addr, uint32_t data)
{
d_drec->write_signal(SIG_DATAREC_MIC, data, 0x01);
d_drec->write_signal(SIG_DATAREC_REMOTE, ~data, 0x02);
d_vdp->write_signal(SIG_MC6847_AG, data, 0x80);
}
-uint32_t SYSTEM::read_io8(uint32_t addr)
+uint32_t PHC25_SYSTEM::read_io8(uint32_t addr)
{
return sysport;
}
-void SYSTEM::write_signal(int id, uint32_t data, uint32_t mask)
+void PHC25_SYSTEM::write_signal(int id, uint32_t data, uint32_t mask)
{
sysport = (sysport & ~mask) | (data & mask);
}
#include "../../statesub.h"
-void SYSTEM::decl_state()
+void PHC25_SYSTEM::decl_state()
{
enter_decl_state(STATE_VERSION);
leave_decl_state();
}
-void SYSTEM::save_state(FILEIO* state_fio)
+void PHC25_SYSTEM::save_state(FILEIO* state_fio)
{
if(state_entry != NULL) {
state_entry->save_state(state_fio);
// state_fio->FputUint8(sysport);
}
-bool SYSTEM::load_state(FILEIO* state_fio)
+bool PHC25_SYSTEM::load_state(FILEIO* state_fio)
{
bool mb = false;
if(state_entry != NULL) {
return true;
}
-bool SYSTEM::process_state(FILEIO* state_fio, bool loading)
+bool PHC25_SYSTEM::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ system port ]
*/
-#ifndef _SYSTEM_H_
-#define _SYSTEM_H_
+#ifndef _PHC25_SYSTEM_H_
+#define _PHC25_SYSTEM_H_
#include "../vm.h"
#include "../../emu.h"
#define SIG_SYSTEM_PORT 0
-class SYSTEM : public DEVICE
+class PHC25_SYSTEM : public DEVICE
{
private:
DEVICE *d_drec, *d_vdp;
uint8_t sysport;
public:
- SYSTEM(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ PHC25_SYSTEM(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("System I/O"));
}
- ~SYSTEM() {}
+ ~PHC25_SYSTEM() {}
// common functions
void initialize();
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
void write_signal(int id, uint32_t data, uint32_t mask);
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_drec(DEVICE* device)
[ joystick ]
*/
-#include "joystick.h"
+#include "./joystick.h"
void JOYSTICK::initialize()
{
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void JOYSTICK::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT8(column);
- DECL_STATE_ENTRY_UINT8(status);
-
- leave_decl_state();
-}
-
-void JOYSTICK::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->FputUint8(column);
-// state_fio->FputUint8(status);
-}
-
-bool JOYSTICK::load_state(FILEIO* state_fio)
-{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- return false;
- }
-// if(state_fio->FgetUint32() != STATE_VERSION) {
-// return false;
-// }
-// if(state_fio->FgetInt32() != this_device_id) {
-// return false;
-// }
-// column = state_fio->FgetUint8();
-// status = state_fio->FgetUint8();
- return true;
-}
-
bool JOYSTICK::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
void event_frame();
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
};
#endif
*/
#include <math.h>
-#include "psg.h"
+#include "./psg.h"
#define PSG_CLOCK
#define PSG_VOLUME 8192
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void PSG::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_INT32_STRIDE((ch[0].period), 3, sizeof(ch[0]));
-
- leave_decl_state();
-}
-
-void PSG::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// for(int i = 0; i < 3; i++) {
-// state_fio->FputInt32(ch[i].period);
-// }
-}
-
-bool PSG::load_state(FILEIO* state_fio)
-{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- return false;
- }
-// if(state_fio->FgetUint32() != STATE_VERSION) {
-// return false;
-// }
-// if(state_fio->FgetInt32() != this_device_id) {
-// return false;
-// }
-// for(int i = 0; i < 3; i++) {
-// ch[i].period = state_fio->FgetInt32();
-// }
- return true;
-}
-
bool PSG::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void write_io8(uint32_t addr, uint32_t data);
void mix(int32_t* buffer, int cnt);
void set_volume(int ch, int decibel_l, int decibel_r);
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique function
void initialize_sound(int rate);
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
- decl_state();
inserted = false;
}
#define STATE_VERSION 2
-#include "../../statesub.h"
-#include "../../qt/gui/csp_logger.h"
-extern CSP_Logger DLL_PREFIX_I *csp_logger;
-
-void VM::decl_state(void)
-{
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PV_1000_HEAD")), csp_logger);
-
- DECL_STATE_ENTRY_1D_ARRAY(mem, sizeof(mem));
- DECL_STATE_ENTRY_BOOL(inserted);
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->decl_state();
- }
-}
-
-void VM::save_state(FILEIO* state_fio)
-{
- //state_fio->FputUint32(STATE_VERSION);
-
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->save_state(state_fio);
- }
- //state_fio->Fwrite(mem, sizeof(mem), 1);
- //state_fio->FputBool(inserted);
-}
-
-bool VM::load_state(FILEIO* state_fio)
-{
- //if(state_fio->FgetUint32() != STATE_VERSION) {
- // return false;
- //}
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- emu->out_debug_log("INFO: HEADER DATA ERROR");
- return false;
- }
- for(DEVICE* device = first_device; device; device = device->next_device) {
- if(!device->load_state(state_fio)) {
- return false;
- }
- }
- //state_fio->Fread(mem, sizeof(mem), 1);
- //inserted = state_fio->FgetBool();
- return true;
-}
bool VM::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- for(DEVICE* device = first_device; device; device = device->next_device) {
- const char *name = typeid(*device).name() + 6; // skip "class "
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ // Note: typeid(foo).name is fixed by recent ABI.Not dec 6.
+ // const char *name = typeid(*device).name();
+ // But, using get_device_name() instead of typeid(foo).name() 20181008 K.O
+ const char *name = device->get_device_name();
int len = strlen(name);
if(!state_fio->StateCheckInt32(len)) {
+ if(loading) {
+ printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
return false;
}
if(!state_fio->StateCheckBuffer(name, len, 1)) {
- return false;
- }
+ if(loading) {
+ printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
+ return false;
+ }
if(!device->process_state(state_fio, loading)) {
- return false;
- }
- }
+ if(loading) {
+ printf("Data loading Error: DEVID=%d\n", device->this_device_id);
+ }
+ return false;
+ }
+ }
+ // Machine specified.
state_fio->StateBuffer(mem, sizeof(mem), 1);
state_fio->StateBool(inserted);
return true;
bool is_frame_skippable();
void update_config();
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// ----------------------------------------
// for each device
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void VDP::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_INT32(tmp_vram_size); // (int)(vram - base);
- DECL_STATE_ENTRY_INT32(tmp_pcg_size); // (int)(pcg - base);
- DECL_STATE_ENTRY_INT32(tmp_pattern_size); // (int)(pattern - base);
- DECL_STATE_ENTRY_BOOL(force_pattern);
-
- leave_decl_state();
-}
-
-void VDP::save_state(FILEIO* state_fio)
-{
- tmp_vram_size = (int)(vram - base);
- tmp_pcg_size = (int)(pcg - base);
- tmp_pattern_size = (int)(pattern - base);
-
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->FputInt32((int)(vram - base));
-// state_fio->FputInt32((int)(pcg - base));
-// state_fio->FputInt32((int)(pattern - base));
-// state_fio->FputBool(force_pattern);
-}
-
-bool VDP::load_state(FILEIO* state_fio)
-{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- return false;
- }
-// if(state_fio->FgetUint32() != STATE_VERSION) {
-// return false;
-// }
-// if(state_fio->FgetInt32() != this_device_id) {
-// return false;
-// }
-// vram = base + state_fio->FgetInt32();
-// pcg = base + state_fio->FgetInt32();
-// pattern = base + state_fio->FgetInt32();
-// force_pattern = state_fio->FgetBool();
- vram = base + tmp_vram_size;
- pcg = base + tmp_pcg_size;
- pattern = base + tmp_pattern_size;
- return true;
-}
-
bool VDP::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void write_io8(uint32_t addr, uint32_t data);
void event_callback(int event_id, int err);
void event_vline(int v, int clock);
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_cpu(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void CMT::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_INT32(bufcnt);
- DECL_STATE_ENTRY_1D_ARRAY(buffer, sizeof(buffer));
- DECL_STATE_ENTRY_BOOL(play);
- DECL_STATE_ENTRY_BOOL(rec);
- DECL_STATE_ENTRY_UINT8(start);
- DECL_STATE_ENTRY_UINT8(bit);
-
- leave_decl_state();
-}
-
-void CMT::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->FputInt32(bufcnt);
-// state_fio->Fwrite(buffer, sizeof(buffer), 1);
-// state_fio->FputBool(play);
-// state_fio->FputBool(rec);
-// state_fio->FputUint8(start);
-// state_fio->FputUint8(bit);
-}
-
-bool CMT::load_state(FILEIO* state_fio)
-{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- return false;
- }
-// if(state_fio->FgetUint32() != STATE_VERSION) {
-// return false;
-// }
-// if(state_fio->FgetInt32() != this_device_id) {
-// return false;
-// }
-// bufcnt = state_fio->FgetInt32();
-// state_fio->Fread(buffer, sizeof(buffer), 1);
-// play = state_fio->FgetBool();
-// rec = state_fio->FgetBool();
-// start = state_fio->FgetUint8();
-// bit = state_fio->FgetUint8();
- return true;
-}
-
bool CMT::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void reset();
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void play_tape(const _TCHAR* file_path);
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void KEYBOARD::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(key_stat, sizeof(key_stat));
- DECL_STATE_ENTRY_INT32(key_no);
- DECL_STATE_ENTRY_BOOL(intr_enb);
-
- leave_decl_state();
-}
-
-void KEYBOARD::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// if(state_entry != NULL) {
-// state_entry->save_state(state_fio);
-// }
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->Fwrite(key_stat, sizeof(key_stat), 1);
-// state_fio->FputInt32(key_no);
-// state_fio->FputBool(intr_enb);
-}
-
-bool KEYBOARD::load_state(FILEIO* state_fio)
-{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- return false;
- }
-// if(state_fio->FgetUint32() != STATE_VERSION) {
-// return false;
-// }
-// if(state_fio->FgetInt32() != this_device_id) {
-// return false;
-// }
-// state_fio->Fread(key_stat, sizeof(key_stat), 1);
-// key_no = state_fio->FgetInt32();
-// intr_enb = state_fio->FgetBool();
- return true;
-}
bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
{
void reset();
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_cpu(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void PRINTER::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT8(out);
- DECL_STATE_ENTRY_UINT8(ctrl0);
- DECL_STATE_ENTRY_UINT8(ctrl1);
- DECL_STATE_ENTRY_BOOL(busy);
-
- leave_decl_state();
-}
-
-void PRINTER::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->FputUint8(out);
-// state_fio->FputUint8(ctrl0);
-// state_fio->FputUint8(ctrl1);
-// state_fio->FputBool(busy);
-}
-
-bool PRINTER::load_state(FILEIO* state_fio)
-{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- return false;
- }
-// if(state_fio->FgetUint32() != STATE_VERSION) {
-// return false;
-// }
-// if(state_fio->FgetInt32() != this_device_id) {
-// return false;
-// }
-// out = state_fio->FgetUint8();
-// ctrl0 = state_fio->FgetUint8();
-// ctrl1 = state_fio->FgetUint8();
-// busy = state_fio->FgetBool();
- return true;
-}
-
bool PRINTER::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void initialize();
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
};
#endif
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
- decl_state();
inserted = false;
}
#define STATE_VERSION 2
-#include "../../statesub.h"
-#include "../../qt/gui/csp_logger.h"
-extern CSP_Logger DLL_PREFIX_I *csp_logger;
-
-void VM::decl_state(void)
-{
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PV_2000_HEAD")), csp_logger);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_1D_ARRAY(ext, sizeof(ext));
- DECL_STATE_ENTRY_BOOL(inserted);
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->decl_state();
- }
-}
-
-void VM::save_state(FILEIO* state_fio)
-{
- //state_fio->FputUint32(STATE_VERSION);
-
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->save_state(state_fio);
- }
- //state_fio->Fwrite(ram, sizeof(ram), 1);
- //state_fio->Fwrite(ext, sizeof(ext), 1);
- //state_fio->FputBool(inserted);
-}
-
-bool VM::load_state(FILEIO* state_fio)
-{
- //if(state_fio->FgetUint32() != STATE_VERSION) {
- // return false;
- //}
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- emu->out_debug_log("INFO: HEADER DATA ERROR");
- return false;
- }
- for(DEVICE* device = first_device; device; device = device->next_device) {
- if(!device->load_state(state_fio)) {
- return false;
- }
- }
- //state_fio->Fread(ram, sizeof(ram), 1);
- //state_fio->Fread(ext, sizeof(ext), 1);
- //inserted = state_fio->FgetBool();
- return true;
-}
-
bool VM::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- for(DEVICE* device = first_device; device; device = device->next_device) {
- const char *name = typeid(*device).name() + 6; // skip "class "
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ // Note: typeid(foo).name is fixed by recent ABI.Not dec 6.
+ // const char *name = typeid(*device).name();
+ // But, using get_device_name() instead of typeid(foo).name() 20181008 K.O
+ const char *name = device->get_device_name();
int len = strlen(name);
if(!state_fio->StateCheckInt32(len)) {
+ if(loading) {
+ printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
return false;
}
if(!state_fio->StateCheckBuffer(name, len, 1)) {
- return false;
- }
+ if(loading) {
+ printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
+ return false;
+ }
if(!device->process_state(state_fio, loading)) {
- return false;
- }
- }
+ if(loading) {
+ printf("Data loading Error: DEVID=%d\n", device->this_device_id);
+ }
+ return false;
+ }
+ }
+ // Machine specified.
state_fio->StateBuffer(ram, sizeof(ram), 1);
state_fio->StateBuffer(ext, sizeof(ext), 1);
state_fio->StateBool(inserted);
bool is_frame_skippable();
void update_config();
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// ----------------------------------------
// for each device