[VM] Apply new state framework to some VMs.
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
- decl_state();
for(int i = 0; i < 4; i++) {
fdc->set_drive_type(i, DRIVE_TYPE_2D);
}
#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)
-{
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::FP_1100_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;
+ }
+ }
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 3
-#include "../../statesub.h"
-
-void MAIN::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_UINT8(comm_data);
- DECL_STATE_ENTRY_BOOL(rom_sel);
- DECL_STATE_ENTRY_UINT8(slot_sel);
- DECL_STATE_ENTRY_1D_ARRAY(slot_exp, sizeof(slot_exp));
- DECL_STATE_ENTRY_UINT8(intr_mask);
- DECL_STATE_ENTRY_UINT8(intr_request);
- DECL_STATE_ENTRY_UINT8(intr_in_service);
-
- leave_decl_state();
-}
-
-void MAIN::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->FputUint8(comm_data);
-// state_fio->FputBool(rom_sel);
-// state_fio->FputUint8(slot_sel);
-// state_fio->Fwrite(slot_exp, sizeof(slot_exp), 1);
-// state_fio->FputUint8(intr_mask);
-// state_fio->FputUint8(intr_request);
-// state_fio->FputUint8(intr_in_service);
-}
-
-bool MAIN::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);
-// comm_data = state_fio->FgetUint8();
-// rom_sel = state_fio->FgetBool();
-// slot_sel = state_fio->FgetUint8();
-// state_fio->Fread(slot_exp, sizeof(slot_exp), 1);
-// intr_mask = state_fio->FgetUint8();
-// intr_request = state_fio->FgetUint8();
-// intr_in_service = state_fio->FgetUint8();
-
- // post process
- update_memory_map();
- return true;
-}
-
bool MAIN::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
uint32_t get_intr_ack();
void notify_intr_reti();
void notify_intr_ei();
- 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 RAMPACK::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_BOOL(modified);
-
- leave_decl_state();
-}
-
-void RAMPACK::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->FputBool(modified);
-}
-
-bool RAMPACK::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);
-// modified = state_fio->FgetBool();
- return true;
-}
-
bool RAMPACK::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void release();
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 variable
int index;
}
}
-#define STATE_VERSION 2
-
-#include "../../statesub.h"
-
-#define DECL_STATE_ENTRY_74LS74(foo) { \
- DECL_STATE_ENTRY_BOOL((foo.in_d)); \
- DECL_STATE_ENTRY_BOOL((foo.in_ck)); \
- DECL_STATE_ENTRY_BOOL((foo.in_s)); \
- DECL_STATE_ENTRY_BOOL((foo.in_r)); \
- DECL_STATE_ENTRY_BOOL((foo.out_q)); \
- DECL_STATE_ENTRY_BOOL((foo.out_nq)); \
- DECL_STATE_ENTRY_BOOL((foo.tmp_ck)); \
- }
-#define DECL_STATE_ENTRY_74LS151(foo) { \
- DECL_STATE_ENTRY_BOOL((foo.in_d0)); \
- DECL_STATE_ENTRY_BOOL((foo.in_d1)); \
- DECL_STATE_ENTRY_BOOL((foo.in_d2)); \
- DECL_STATE_ENTRY_BOOL((foo.in_d3)); \
- DECL_STATE_ENTRY_BOOL((foo.in_d4)); \
- DECL_STATE_ENTRY_BOOL((foo.in_d5)); \
- DECL_STATE_ENTRY_BOOL((foo.in_d6)); \
- DECL_STATE_ENTRY_BOOL((foo.in_d7)); \
- DECL_STATE_ENTRY_BOOL((foo.in_a)); \
- DECL_STATE_ENTRY_BOOL((foo.in_b)); \
- DECL_STATE_ENTRY_BOOL((foo.in_c)); \
- DECL_STATE_ENTRY_BOOL((foo.in_s)); \
- DECL_STATE_ENTRY_BOOL((foo.out_y)); \
- DECL_STATE_ENTRY_BOOL((foo.out_ny)); \
+#define PROCESS_STATE_74LS74(foo) \
+ { \
+ state_fio->StateBool(foo.in_d); \
+ state_fio->StateBool(foo.in_ck); \
+ state_fio->StateBool(foo.in_s); \
+ state_fio->StateBool(foo.in_r); \
+ state_fio->StateBool(foo.out_q); \
+ state_fio->StateBool(foo.out_nq); \
+ state_fio->StateBool(foo.tmp_ck); \
}
-#define DECL_STATE_ENTRY_74LS93(foo) { \
- DECL_STATE_ENTRY_BOOL((foo.in_a)); \
- DECL_STATE_ENTRY_BOOL((foo.in_b)); \
- DECL_STATE_ENTRY_BOOL((foo.in_rc1)); \
- DECL_STATE_ENTRY_BOOL((foo.in_rc2)); \
- DECL_STATE_ENTRY_BOOL((foo.out_qa)); \
- DECL_STATE_ENTRY_BOOL((foo.out_qb)); \
- DECL_STATE_ENTRY_BOOL((foo.out_qc)); \
- DECL_STATE_ENTRY_BOOL((foo.tmp_a)); \
- DECL_STATE_ENTRY_BOOL((foo.tmp_b)); \
- DECL_STATE_ENTRY_UINT8((foo.counter_a)); \
- DECL_STATE_ENTRY_UINT8((foo.counter_b)); \
+#define PROCESS_STATE_74LS151(foo) \
+ { \
+ state_fio->StateBool(foo.in_d0); \
+ state_fio->StateBool(foo.in_d1); \
+ state_fio->StateBool(foo.in_d2); \
+ state_fio->StateBool(foo.in_d3); \
+ state_fio->StateBool(foo.in_d4); \
+ state_fio->StateBool(foo.in_d5); \
+ state_fio->StateBool(foo.in_d6); \
+ state_fio->StateBool(foo.in_d7); \
+ state_fio->StateBool(foo.in_a); \
+ state_fio->StateBool(foo.in_b); \
+ state_fio->StateBool(foo.in_c); \
+ state_fio->StateBool(foo.in_s); \
+ state_fio->StateBool(foo.out_y); \
+ state_fio->StateBool(foo.out_ny); \
}
-#define DECL_STATE_ENTRY_TC4024BP(foo) { \
- DECL_STATE_ENTRY_BOOL((foo.in_ck)); \
- DECL_STATE_ENTRY_BOOL((foo.in_clr)); \
- DECL_STATE_ENTRY_BOOL((foo.out_q5)); \
- DECL_STATE_ENTRY_BOOL((foo.out_q6)); \
- DECL_STATE_ENTRY_BOOL((foo.tmp_ck)); \
- DECL_STATE_ENTRY_UINT8((foo.counter)); \
- }
-
-void SUB::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_1D_ARRAY(vram_b, sizeof(vram_b));
- DECL_STATE_ENTRY_1D_ARRAY(vram_r, sizeof(vram_r));
- DECL_STATE_ENTRY_1D_ARRAY(vram_g, sizeof(vram_g));
- DECL_STATE_ENTRY_UINT8(pa);
- DECL_STATE_ENTRY_UINT8(pb);
- DECL_STATE_ENTRY_UINT8(pc);
- DECL_STATE_ENTRY_UINT8(comm_data);
- DECL_STATE_ENTRY_BOOL(so);
- DECL_STATE_ENTRY_UINT8(clock);
- DECL_STATE_ENTRY_74LS74(b16_1);
- DECL_STATE_ENTRY_74LS74(b16_2);
- DECL_STATE_ENTRY_74LS74(g21_1);
- DECL_STATE_ENTRY_74LS74(g21_2);
-
- DECL_STATE_ENTRY_74LS151(c15);
- DECL_STATE_ENTRY_74LS93(c16);
-
- DECL_STATE_ENTRY_TC4024BP(f21);
-
- DECL_STATE_ENTRY_UINT8(key_sel);
- DECL_STATE_ENTRY_UINT8(key_data);
- DECL_STATE_ENTRY_UINT8(color_reg);
- DECL_STATE_ENTRY_BOOL(hsync);
- DECL_STATE_ENTRY_BOOL(wait);
- DECL_STATE_ENTRY_UINT8(cblink);
-
- leave_decl_state();
-}
-
-void SUB::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
+#define PROCESS_STATE_74LS93(foo) \
+ { \
+ state_fio->StateBool(foo.in_a); \
+ state_fio->StateBool(foo.in_b); \
+ state_fio->StateBool(foo.in_rc1); \
+ state_fio->StateBool(foo.in_rc2); \
+ state_fio->StateBool(foo.out_qa); \
+ state_fio->StateBool(foo.out_qb); \
+ state_fio->StateBool(foo.out_qc); \
+ state_fio->StateBool(foo.tmp_a); \
+ state_fio->StateBool(foo.tmp_b); \
+ state_fio->StateUint8(foo.counter_a); \
+ state_fio->StateUint8(foo.counter_b); \
}
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->Fwrite(ram, sizeof(ram), 1);
-// state_fio->Fwrite(vram_b, sizeof(vram_b), 1);
-// state_fio->Fwrite(vram_r, sizeof(vram_r), 1);
-// state_fio->Fwrite(vram_g, sizeof(vram_g), 1);
-// state_fio->FputUint8(pa);
-// state_fio->FputUint8(pb);
-// state_fio->FputUint8(pc);
-// state_fio->FputUint8(comm_data);
-// state_fio->FputBool(so);
-// state_fio->FputUint8(clock);
-// state_fio->Fwrite(&b16_1, sizeof(b16_1), 1);
-// state_fio->Fwrite(&b16_2, sizeof(b16_2), 1);
-// state_fio->Fwrite(&g21_1, sizeof(g21_1), 1);
-// state_fio->Fwrite(&g21_2, sizeof(g21_2), 1);
-// state_fio->Fwrite(&c15, sizeof(c15), 1);
-// state_fio->Fwrite(&c16, sizeof(c16), 1);
-// state_fio->Fwrite(&f21, sizeof(f21), 1);
-// state_fio->FputUint8(key_sel);
-// state_fio->FputUint8(key_data);
-// state_fio->FputUint8(color_reg);
-// state_fio->FputBool(hsync);
-// state_fio->FputBool(wait);
-// state_fio->FputUint8(cblink);
-}
-
-bool SUB::load_state(FILEIO* state_fio)
-{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- return false;
+#define PROCESS_STATE_4024(foo) \
+ { \
+ state_fio->StateBool(foo.in_ck); \
+ state_fio->StateBool(foo.in_clr); \
+ state_fio->StateBool(foo.out_q5); \
+ state_fio->StateBool(foo.out_q6); \
+ state_fio->StateBool(foo.tmp_ck); \
+ state_fio->StateUint8(foo.counter); \
}
-// 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_b, sizeof(vram_b), 1);
-// state_fio->Fread(vram_r, sizeof(vram_r), 1);
-// state_fio->Fread(vram_g, sizeof(vram_g), 1);
-// pa = state_fio->FgetUint8();
-// pb = state_fio->FgetUint8();
-// pc = state_fio->FgetUint8();
-// comm_data = state_fio->FgetUint8();
-// so = state_fio->FgetBool();
-// clock = state_fio->FgetUint8();
-// state_fio->Fread(&b16_1, sizeof(b16_1), 1);
-// state_fio->Fread(&b16_2, sizeof(b16_2), 1);
-// state_fio->Fread(&g21_1, sizeof(g21_1), 1);
-// state_fio->Fread(&g21_2, sizeof(g21_2), 1);
-// state_fio->Fread(&c15, sizeof(c15), 1);
-// state_fio->Fread(&c16, sizeof(c16), 1);
-// state_fio->Fread(&f21, sizeof(f21), 1);
-// key_sel = state_fio->FgetUint8();
-// key_data = state_fio->FgetUint8();
-// color_reg = state_fio->FgetUint8();
-// hsync = state_fio->FgetBool();
-// wait = state_fio->FgetBool();
-// cblink = state_fio->FgetUint8();
- return true;
-}
+#define STATE_VERSION 2
bool SUB::process_state(FILEIO* state_fio, bool loading)
{
state_fio->StateUint8(comm_data);
state_fio->StateBool(so);
state_fio->StateUint8(clock);
- state_fio->StateBuffer(&b16_1, sizeof(b16_1), 1);
- state_fio->StateBuffer(&b16_2, sizeof(b16_2), 1);
- state_fio->StateBuffer(&g21_1, sizeof(g21_1), 1);
- state_fio->StateBuffer(&g21_2, sizeof(g21_2), 1);
- state_fio->StateBuffer(&c15, sizeof(c15), 1);
- state_fio->StateBuffer(&c16, sizeof(c16), 1);
- state_fio->StateBuffer(&f21, sizeof(f21), 1);
+ //state_fio->StateBuffer(&b16_1, sizeof(b16_1), 1);
+ //state_fio->StateBuffer(&b16_2, sizeof(b16_2), 1);
+ //state_fio->StateBuffer(&g21_1, sizeof(g21_1), 1);
+ //state_fio->StateBuffer(&g21_2, sizeof(g21_2), 1);
+ PROCESS_STATE_74LS74(b16_1);
+ PROCESS_STATE_74LS74(b16_2);
+ PROCESS_STATE_74LS74(g21_1);
+ PROCESS_STATE_74LS74(g21_2);
+
+ //state_fio->StateBuffer(&c15, sizeof(c15), 1);
+ PROCESS_STATE_74LS151(c15);
+
+ //state_fio->StateBuffer(&c16, sizeof(c16), 1);
+ PROCESS_STATE_74LS93(c16);
+
+ //state_fio->StateBuffer(&f21, sizeof(f21), 1);
+ PROCESS_STATE_4024(f21);
+
state_fio->StateUint8(key_sel);
state_fio->StateUint8(key_data);
state_fio->StateUint8(color_reg);
void write_signal(int id, uint32_t data, uint32_t mask);
void event_frame();
void event_callback(int event_id, int err);
- 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)
#include "../debugger.h"
#endif
-#include "io.h"
+#include "./io.h"
// ----------------------------------------------------------------------------
// initialize
memory = new MEMORY(this, emu);
rtc = new RP5C01(this, emu);
- io = new IO(this, emu);
+ io = new FP200_IO(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::FP_200_HEAD")), csp_logger);
- DECL_STATE_ENTRY_MULTI(void, ram, sizeof(ram));
- 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);
-}
-
-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);
- 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;
+ }
+ }
state_fio->StateBuffer(ram, sizeof(ram), 1);
return true;
}
class MEMORY;
class RP5C01;
-class IO;
+class FP200_IO;
class VM : public VM_TEMPLATE
{
MEMORY* memory;
RP5C01* rtc;
- IO* io;
+ FP200_IO* io;
// memory
uint8_t rom[0x8000];
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
{0x0d, 0xdd, 0x14, 0xe2, 0x36, 0x59, 0x48, 0x4e}
};
-void IO::initialize()
+void FP200_IO::initialize()
{
FILEIO* fio = new FILEIO();
if(fio->Fopen(create_local_path(_T("FONT.ROM")), FILEIO_READ_BINARY)) {
key_stat = emu->get_key_buffer();
}
-void IO::release()
+void FP200_IO::release()
{
close_tape();
delete cmt_fio;
}
-void IO::reset()
+void FP200_IO::reset()
{
mode_basic = (config.boot_mode == 0);
#define REVERSE(v) (((v) & 0x80) >> 7) | (((v) & 0x40) >> 5) | (((v) & 0x20) >> 3) | (((v) & 0x10) >> 1) | (((v) & 0x08) << 1) | (((v) & 0x04) << 3) | (((v) & 0x02) << 5) | (((v) & 0x01) << 7)
-void IO::write_io8(uint32_t addr, uint32_t data)
+void FP200_IO::write_io8(uint32_t addr, uint32_t data)
{
#ifdef _IO_DEBUG_LOG
this->out_debug_log(_T("%06x\tSOD=%d\tOUT8\t%04x, %02x\n"), get_cpu_pc(0), sod ? 1 : 0, addr & 0xff, data & 0xff);
}
}
-uint32_t IO::read_io8(uint32_t addr)
+uint32_t FP200_IO::read_io8(uint32_t addr)
{
uint32_t value = 0xff;
return value;
}
-void IO::write_io8w(uint32_t addr, uint32_t data, int* wait)
+void FP200_IO::write_io8w(uint32_t addr, uint32_t data, int* wait)
{
*wait = 2;
write_io8(addr, data);
}
-uint32_t IO::read_io8w(uint32_t addr, int* wait)
+uint32_t FP200_IO::read_io8w(uint32_t addr, int* wait)
{
*wait = 2;
return read_io8(addr);
}
-void IO::write_signal(int id, uint32_t data, uint32_t mask)
+void FP200_IO::write_signal(int id, uint32_t data, uint32_t mask)
{
if(id == SIG_IO_SOD) {
sod = ((data & mask) != 0);
#define BIT_1200HZ 0x20
#define BIT_300HZ 0x80
-void IO::event_callback(int event_id, int err)
+void FP200_IO::event_callback(int event_id, int err)
{
if(event_id == EVENT_CMT_READY) {
if(CMT_RECORDING) {
}
}
-void IO::key_down(int code)
+void FP200_IO::key_down(int code)
{
if(code >= 0x10 && code <= 0x13) {
update_sid();
}
}
-void IO::key_up()
+void FP200_IO::key_up()
{
update_sid();
}
-void IO::update_sid()
+void FP200_IO::update_sid()
{
switch(key_column) {
case 5:
}
}
-void IO::cmt_write_buffer(uint8_t value, int samples)
+void FP200_IO::cmt_write_buffer(uint8_t value, int samples)
{
if(cmt_is_wav) {
for(int i = 0; i < samples; i++) {
}
}
-void IO::rec_tape(const _TCHAR* file_path)
+void FP200_IO::rec_tape(const _TCHAR* file_path)
{
close_tape();
}
}
-void IO::close_tape()
+void FP200_IO::close_tape()
{
// close file
if(cmt_fio->IsOpened()) {
cmt_bufcnt = 0;
}
-void IO::update_cmt()
+void FP200_IO::update_cmt()
{
bool prev_load_clock = c15.out_y;
}
}
-void IO::draw_screen()
+void FP200_IO::draw_screen()
{
// render screen
for(int y = 0; y < 8; y++) {
}
}
-#define STATE_VERSION 3
-
-#include "../../statesub.h"
-
-#define DECL_STATE_ENTRY_74LS74(foo) { \
- DECL_STATE_ENTRY_BOOL((foo.in_d)); \
- DECL_STATE_ENTRY_BOOL((foo.in_ck)); \
- DECL_STATE_ENTRY_BOOL((foo.in_s)); \
- DECL_STATE_ENTRY_BOOL((foo.in_r)); \
- DECL_STATE_ENTRY_BOOL((foo.out_q)); \
- DECL_STATE_ENTRY_BOOL((foo.out_nq)); \
- DECL_STATE_ENTRY_BOOL((foo.tmp_ck)); \
+#define PROCESS_STATE_74LS74(foo) \
+ { \
+ state_fio->StateBool(foo.in_d); \
+ state_fio->StateBool(foo.in_ck); \
+ state_fio->StateBool(foo.in_s); \
+ state_fio->StateBool(foo.in_r); \
+ state_fio->StateBool(foo.out_q); \
+ state_fio->StateBool(foo.out_nq); \
+ state_fio->StateBool(foo.tmp_ck); \
}
-#define DECL_STATE_ENTRY_74LS151(foo) { \
- DECL_STATE_ENTRY_BOOL((foo.in_d0)); \
- DECL_STATE_ENTRY_BOOL((foo.in_d1)); \
- DECL_STATE_ENTRY_BOOL((foo.in_d2)); \
- DECL_STATE_ENTRY_BOOL((foo.in_d3)); \
- DECL_STATE_ENTRY_BOOL((foo.in_d4)); \
- DECL_STATE_ENTRY_BOOL((foo.in_d5)); \
- DECL_STATE_ENTRY_BOOL((foo.in_d6)); \
- DECL_STATE_ENTRY_BOOL((foo.in_d7)); \
- DECL_STATE_ENTRY_BOOL((foo.in_a)); \
- DECL_STATE_ENTRY_BOOL((foo.in_b)); \
- DECL_STATE_ENTRY_BOOL((foo.in_c)); \
- DECL_STATE_ENTRY_BOOL((foo.in_s)); \
- DECL_STATE_ENTRY_BOOL((foo.out_y)); \
- DECL_STATE_ENTRY_BOOL((foo.out_ny)); \
+#define PROCESS_STATE_74LS151(foo) \
+ { \
+ state_fio->StateBool(foo.in_d0); \
+ state_fio->StateBool(foo.in_d1); \
+ state_fio->StateBool(foo.in_d2); \
+ state_fio->StateBool(foo.in_d3); \
+ state_fio->StateBool(foo.in_d4); \
+ state_fio->StateBool(foo.in_d5); \
+ state_fio->StateBool(foo.in_d6); \
+ state_fio->StateBool(foo.in_d7); \
+ state_fio->StateBool(foo.in_a); \
+ state_fio->StateBool(foo.in_b); \
+ state_fio->StateBool(foo.in_c); \
+ state_fio->StateBool(foo.in_s); \
+ state_fio->StateBool(foo.out_y); \
+ state_fio->StateBool(foo.out_ny); \
}
-#define DECL_STATE_ENTRY_74LS93(foo) { \
- DECL_STATE_ENTRY_BOOL((foo.in_a)); \
- DECL_STATE_ENTRY_BOOL((foo.in_b)); \
- DECL_STATE_ENTRY_BOOL((foo.in_rc1)); \
- DECL_STATE_ENTRY_BOOL((foo.in_rc2)); \
- DECL_STATE_ENTRY_BOOL((foo.out_qa)); \
- DECL_STATE_ENTRY_BOOL((foo.out_qb)); \
- DECL_STATE_ENTRY_BOOL((foo.out_qc)); \
- DECL_STATE_ENTRY_BOOL((foo.tmp_a)); \
- DECL_STATE_ENTRY_BOOL((foo.tmp_b)); \
- DECL_STATE_ENTRY_UINT8((foo.counter_a)); \
- DECL_STATE_ENTRY_UINT8((foo.counter_b)); \
- }
-
-#define DECL_STATE_ENTRY_TC4024BP(foo) { \
- DECL_STATE_ENTRY_BOOL((foo.in_ck)); \
- DECL_STATE_ENTRY_BOOL((foo.in_clr)); \
- DECL_STATE_ENTRY_BOOL((foo.out_q5)); \
- DECL_STATE_ENTRY_BOOL((foo.out_q6)); \
- DECL_STATE_ENTRY_BOOL((foo.tmp_ck)); \
- DECL_STATE_ENTRY_UINT8((foo.counter)); \
- }
-
-void IO::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- for(int i = 0; i < 2; i++) {
- DECL_STATE_ENTRY_1D_ARRAY_MEMBER(lcd[i].ram, sizeof(lcd[0].ram), i);
- DECL_STATE_ENTRY_INT32_MEMBER((lcd[i].offset), i);
- DECL_STATE_ENTRY_INT32_MEMBER((lcd[i].cursor), i);
- }
- DECL_STATE_ENTRY_INT32(lcd_status);
- DECL_STATE_ENTRY_INT32(lcd_addr);
- DECL_STATE_ENTRY_BOOL(lcd_text);
- DECL_STATE_ENTRY_BOOL(cmt_selected);
- DECL_STATE_ENTRY_UINT8(cmt_mode);
- DECL_STATE_ENTRY_BOOL(cmt_play_ready);
- DECL_STATE_ENTRY_BOOL(cmt_play_signal);
- DECL_STATE_ENTRY_BOOL(cmt_rec_ready);
- DECL_STATE_ENTRY_BOOL(cmt_rec);
- DECL_STATE_ENTRY_BOOL(cmt_is_wav);
- DECL_STATE_ENTRY_STRING(cmt_rec_file_path, sizeof(cmt_rec_file_path));
- DECL_STATE_ENTRY_CMT_RECORDING(cmt_fio, cmt_rec, cmt_rec_file_path);
-
- DECL_STATE_ENTRY_INT32(cmt_bufcnt);
- // ToDo: Write cmt_buffer only used (indicated by cmt_bufcnt).
- DECL_STATE_ENTRY_1D_ARRAY(cmt_buffer, sizeof(cmt_buffer));
-
- DECL_STATE_ENTRY_UINT8(cmt_clock);
- DECL_STATE_ENTRY_74LS74(b16_1);
- DECL_STATE_ENTRY_74LS74(b16_2);
- DECL_STATE_ENTRY_74LS74(g21_1);
- DECL_STATE_ENTRY_74LS74(g21_2);
-
- DECL_STATE_ENTRY_74LS151(c15);
-
- DECL_STATE_ENTRY_74LS93(c16);
-
- DECL_STATE_ENTRY_TC4024BP(f21);
- DECL_STATE_ENTRY_UINT8(key_column);
-
- leave_decl_state();
-}
-
-void IO::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
+#define PROCESS_STATE_74LS93(foo) \
+ { \
+ state_fio->StateBool(foo.in_a); \
+ state_fio->StateBool(foo.in_b); \
+ state_fio->StateBool(foo.in_rc1); \
+ state_fio->StateBool(foo.in_rc2); \
+ state_fio->StateBool(foo.out_qa); \
+ state_fio->StateBool(foo.out_qb); \
+ state_fio->StateBool(foo.out_qc); \
+ state_fio->StateBool(foo.tmp_a); \
+ state_fio->StateBool(foo.tmp_b); \
+ state_fio->StateUint8(foo.counter_a); \
+ state_fio->StateUint8(foo.counter_b); \
}
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->Fwrite(lcd, sizeof(lcd), 1);
-// state_fio->FputInt32(lcd_status);
-// state_fio->FputInt32(lcd_addr);
-// state_fio->FputBool(lcd_text);
-// state_fio->FputBool(cmt_selected);
-// state_fio->FputUint8(cmt_mode);
-// state_fio->FputBool(cmt_play_ready);
-// state_fio->FputBool(cmt_play_signal);
-// state_fio->FputBool(cmt_rec_ready);
-// state_fio->FputBool(cmt_rec);
-// state_fio->FputBool(cmt_is_wav);
-// state_fio->Fwrite(cmt_rec_file_path, sizeof(cmt_rec_file_path), 1);
-// if(cmt_rec && cmt_fio->IsOpened()) {
-// int length_tmp = (int)cmt_fio->Ftell();
-// cmt_fio->Fseek(0, FILEIO_SEEK_SET);
-/// state_fio->FputInt32(length_tmp);
-// while(length_tmp != 0) {
-/// uint8_t buffer_tmp[1024];
-/// int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
-// cmt_fio->Fread(buffer_tmp, length_rw, 1);
-// state_fio->Fwrite(buffer_tmp, length_rw, 1);
-// length_tmp -= length_rw;
-// }
-// } else {
-// state_fio->FputInt32(0);
-// }
-// state_fio->FputInt32(cmt_bufcnt);
-// state_fio->Fwrite(cmt_buffer, cmt_bufcnt, 1);
-// state_fio->FputUint8(cmt_clock);
-// state_fio->Fwrite(&b16_1, sizeof(b16_1), 1);
-// state_fio->Fwrite(&b16_2, sizeof(b16_2), 1);
-// state_fio->Fwrite(&g21_1, sizeof(g21_1), 1);
-// state_fio->Fwrite(&g21_2, sizeof(g21_2), 1);
-// state_fio->Fwrite(&c15, sizeof(c15), 1);
-// state_fio->Fwrite(&c16, sizeof(c16), 1);
-// state_fio->Fwrite(&f21, sizeof(f21), 1);
-// state_fio->FputUint8(key_column);
-}
-
-bool IO::load_state(FILEIO* state_fio)
-{
- close_tape();
-
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- return false;
+#define PROCESS_STATE_4024(foo) \
+ { \
+ state_fio->StateBool(foo.in_ck); \
+ state_fio->StateBool(foo.in_clr); \
+ state_fio->StateBool(foo.out_q5); \
+ state_fio->StateBool(foo.out_q6); \
+ state_fio->StateBool(foo.tmp_ck); \
+ state_fio->StateUint8(foo.counter); \
}
-// if(state_fio->FgetUint32() != STATE_VERSION) {
-// return false;
-// }
-// if(state_fio->FgetInt32() != this_device_id) {
-// return false;
-// }
-// state_fio->Fread(lcd, sizeof(lcd), 1);
-// lcd_status = state_fio->FgetInt32();
-// lcd_addr = state_fio->FgetInt32();
-// lcd_text = state_fio->FgetBool();
-// cmt_selected = state_fio->FgetBool();
-// cmt_mode = state_fio->FgetUint8();
-// cmt_play_ready = state_fio->FgetBool();
-// cmt_play_signal = state_fio->FgetBool();
-// cmt_rec_ready = state_fio->FgetBool();
-// cmt_rec = state_fio->FgetBool();
-// cmt_is_wav = state_fio->FgetBool();
-// state_fio->Fread(cmt_rec_file_path, sizeof(cmt_rec_file_path), 1);
-// int length_tmp = state_fio->FgetInt32();
-// if(cmt_rec) {
-// cmt_fio->Fopen(cmt_rec_file_path, FILEIO_READ_WRITE_NEW_BINARY);
-// while(length_tmp != 0) {
-// uint8_t buffer_tmp[1024];
-// int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
-// state_fio->Fread(buffer_tmp, length_rw, 1);
-// if(cmt_fio->IsOpened()) {
-// cmt_fio->Fwrite(buffer_tmp, length_rw, 1);
-// }
-// length_tmp -= length_rw;
-// }
-// }
-// cmt_bufcnt = state_fio->FgetInt32();
-// if(cmt_bufcnt) {
-// state_fio->Fread(cmt_buffer, cmt_bufcnt, 1);
-// }
-// cmt_clock = state_fio->FgetUint8();
-// state_fio->Fread(&b16_1, sizeof(b16_1), 1);
-// state_fio->Fread(&b16_2, sizeof(b16_2), 1);
-// state_fio->Fread(&g21_1, sizeof(g21_1), 1);
-// state_fio->Fread(&g21_2, sizeof(g21_2), 1);
-// state_fio->Fread(&c15, sizeof(c15), 1);
-/// state_fio->Fread(&c16, sizeof(c16), 1);
-// state_fio->Fread(&f21, sizeof(f21), 1);
-// key_column = state_fio->FgetUint8();
- return true;
-}
+#define STATE_VERSION 4
-bool IO::process_state(FILEIO* state_fio, bool loading)
+bool FP200_IO::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
if(loading) {
close_tape();
}
- state_fio->StateBuffer(lcd, sizeof(lcd), 1);
+ //state_fio->StateBuffer(lcd, sizeof(lcd), 1);
+ for(int i = 0; i < 2; i++) {
+ state_fio->StateBuffer(&(lcd[i].ram), 0x400, 1);
+ state_fio->StateInt32(lcd[i].offset);
+ state_fio->StateInt32(lcd[i].cursor);
+ }
state_fio->StateInt32(lcd_status);
state_fio->StateInt32(lcd_addr);
state_fio->StateBool(lcd_text);
state_fio->StateInt32(cmt_bufcnt);
state_fio->StateBuffer(cmt_buffer, cmt_bufcnt, 1);
state_fio->StateUint8(cmt_clock);
- state_fio->StateBuffer(&b16_1, sizeof(b16_1), 1);
- state_fio->StateBuffer(&b16_2, sizeof(b16_2), 1);
- state_fio->StateBuffer(&g21_1, sizeof(g21_1), 1);
- state_fio->StateBuffer(&g21_2, sizeof(g21_2), 1);
- state_fio->StateBuffer(&c15, sizeof(c15), 1);
- state_fio->StateBuffer(&c16, sizeof(c16), 1);
- state_fio->StateBuffer(&f21, sizeof(f21), 1);
+
+ //state_fio->StateBuffer(&b16_1, sizeof(b16_1), 1);
+ //state_fio->StateBuffer(&b16_2, sizeof(b16_2), 1);
+ //state_fio->StateBuffer(&g21_1, sizeof(g21_1), 1);
+ //state_fio->StateBuffer(&g21_2, sizeof(g21_2), 1);
+ PROCESS_STATE_74LS74(b16_1);
+ PROCESS_STATE_74LS74(b16_2);
+ PROCESS_STATE_74LS74(g21_1);
+ PROCESS_STATE_74LS74(g21_2);
+
+ //state_fio->StateBuffer(&c15, sizeof(c15), 1);
+ PROCESS_STATE_74LS151(c15);
+
+ //state_fio->StateBuffer(&c16, sizeof(c16), 1);
+ PROCESS_STATE_74LS93(c16);
+ //state_fio->StateBuffer(&f21, sizeof(f21), 1);
+ PROCESS_STATE_4024(f21);
state_fio->StateUint8(key_column);
return true;
}
[ io ]
*/
-#ifndef _IO_H_
-#define _IO_H_
+#ifndef _FP200_IO_H_
+#define _FP200_IO_H_
#include "../vm.h"
#include "../../emu.h"
class FILEIO;
-class IO : public DEVICE
+class FP200_IO : public DEVICE
{
private:
DEVICE *d_cpu, *d_drec, *d_rtc;
void update_sid();
public:
- IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ FP200_IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("I/O Bus"));
}
- ~IO() {}
+ ~FP200_IO() {}
// common functions
void initialize();
uint32_t read_io8w(uint32_t addr, int* wait);
void write_signal(int id, uint32_t data, uint32_t mask);
void event_callback(int event_id, int err);
- 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)
cpu_tf20->set_device_name(_T("TF20 CPU(Z80)"));
sio_tf20->set_device_name(_T("TF20 SIO(Z80 SIO)"));
fdc_tf20->set_device_name(_T("TF20 FDC(uPD765A)"));
- memory = new MEMORY(this, emu);
+ memory = new HC20_MEMORY(this, emu);
// set contexts
event->set_context_cpu(cpu);
event->set_context_cpu(cpu_tf20, 4000000);
#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::HC_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;
+ }
+ }
return true;
}
class Z80;
class Z80SIO;
-class MEMORY;
+class HC20_MEMORY;
class VM : public VM_TEMPLATE
{
Z80* cpu_tf20;
Z80SIO* sio_tf20;
- MEMORY* memory;
+ HC20_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
[ memory ]
*/
-#include "memory.h"
+#include "./memory.h"
#include "../beep.h"
#include "../hd6301.h"
#include "../z80sio.h"
0x79, 0x7a, 0x77, 0x75, 0x2e, 0x76, 0x00, 0x00, 0x00, 0x21
};
-void MEMORY::initialize()
+void HC20_MEMORY::initialize()
{
// initialize memory
memset(ram, 0, sizeof(ram));
register_event_by_clock(this, EVENT_SOUND, 256, true, NULL);
}
-void MEMORY::release()
+void HC20_MEMORY::release()
{
// save battery backuped ram
FILEIO* fio = new FILEIO();
delete cmd_buf;
}
-void MEMORY::reset()
+void HC20_MEMORY::reset()
{
// select internal rom
// SET_BANK(0x4000, 0x7fff, wdmy, rdmy);
int_mask = 0;
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void HC20_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
addr &= 0xffff;
if(addr < 0x40) {
}
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t HC20_MEMORY::read_data8(uint32_t addr)
{
addr &= 0xffff;
if(addr < 0x40) {
return rbank[(addr >> 13) & 7][addr & 0x1fff];
}
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void HC20_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
{
if(id == SIG_MEMORY_PORT_2) {
sio_select = ((data & 0x04) != 0);
}
}
-void MEMORY::event_callback(int event_id, int err)
+void HC20_MEMORY::event_callback(int event_id, int err)
{
if(event_id == EVENT_SOUND) {
update_sound();
}
}
-void MEMORY::update_sound()
+void HC20_MEMORY::update_sound()
{
if(sound_ptr < sound_count) {
if(sound[sound_ptr].remain-- == 0) {
}
}
-void MEMORY::update_keyboard()
+void HC20_MEMORY::update_keyboard()
{
key_data = 0x3ff;
}
}
-void MEMORY::notify_power_off()
+void HC20_MEMORY::notify_power_off()
{
int_status |= INT_POWER;
update_intr();
}
-void MEMORY::key_down(int code)
+void HC20_MEMORY::key_down(int code)
{
key_stat[code] = 1;
}
}
-void MEMORY::key_up(int code)
+void HC20_MEMORY::key_up(int code)
{
key_stat[code] = 0;
}
-void MEMORY::update_intr()
+void HC20_MEMORY::update_intr()
{
// d_cpu->write_signal(SIG_CPU_IRQ, (int_status && !int_mask) ? 1 : 0, 1);
d_cpu->write_signal(SIG_CPU_IRQ, int_status ? 1 : 0, 1);
}
-void MEMORY::send_to_slave(uint8_t val)
+void HC20_MEMORY::send_to_slave(uint8_t val)
{
cmd_buf->write(val);
uint8_t cmd = cmd_buf->read_not_remove(0);
}
}
-void MEMORY::send_to_main(uint8_t val)
+void HC20_MEMORY::send_to_main(uint8_t val)
{
// send to main cpu
d_cpu->write_signal(SIG_MC6801_SIO_RECV, val, 0xff);
}
-void MEMORY::play_tape(const _TCHAR* file_path)
+void HC20_MEMORY::play_tape(const _TCHAR* file_path)
{
close_tape();
}
}
-void MEMORY::rec_tape(const _TCHAR* file_path)
+void HC20_MEMORY::rec_tape(const _TCHAR* file_path)
{
close_tape();
}
}
-void MEMORY::close_tape()
+void HC20_MEMORY::close_tape()
{
if(cmt_fio->IsOpened()) {
if(cmt_rec && cmt_count) {
cmt_play = cmt_rec = false;
}
-void MEMORY::draw_screen()
+void HC20_MEMORY::draw_screen()
{
static const int xtop[12] = {0, 0, 40, 40, 80, 80, 0, 0, 40, 40, 80, 80};
static const int ytop[12] = {0, 8, 0, 8, 0, 8, 16, 24, 16, 24, 16, 24};
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void MEMORY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_BOOL(tmp_wbank_is_ext); // (wbank[0x8000 >> 13] == ext);
- DECL_STATE_ENTRY_BOOL(tmp_rbank_is_ext); // (rbank[0x8000 >> 13] == ext);
-
- DECL_STATE_ENTRY_1D_ARRAY(rom, sizeof(rom));
- DECL_STATE_ENTRY_1D_ARRAY(ext, sizeof(ext));
- DECL_STATE_ENTRY_FIFO(cmd_buf);
-
- DECL_STATE_ENTRY_BOOL(sio_select);
- DECL_STATE_ENTRY_BOOL(special_cmd_masked);
- DECL_STATE_ENTRY_1D_ARRAY(slave_mem, sizeof(slave_mem));
- {
- DECL_STATE_ENTRY_DOUBLE_STRIDE((sound[0].freq), sizeof(sound) / sizeof(sound[0]), sizeof(sound[0]));
- DECL_STATE_ENTRY_INT32_STRIDE((sound[0].period), sizeof(sound) / sizeof(sound[0]), sizeof(sound[0]));
- DECL_STATE_ENTRY_INT32_STRIDE((sound[0].remain), sizeof(sound) / sizeof(sound[0]), sizeof(sound[0]));
- }
-
- DECL_STATE_ENTRY_INT32(sound_ptr);
- DECL_STATE_ENTRY_INT32(sound_count);
- DECL_STATE_ENTRY_UINT8(sound_reply);
- DECL_STATE_ENTRY_DOUBLE(sound_freq);
- DECL_STATE_ENTRY_1D_ARRAY(key_stat, sizeof(key_stat));
- DECL_STATE_ENTRY_1D_ARRAY(key_flag, sizeof(key_flag));
- DECL_STATE_ENTRY_INT32(key_data);
- DECL_STATE_ENTRY_INT32(key_strobe);
- DECL_STATE_ENTRY_INT32(key_intmask);
- DECL_STATE_ENTRY_BOOL(cmt_play);
- DECL_STATE_ENTRY_BOOL(cmt_rec);
- DECL_STATE_ENTRY_STRING(cmt_file_path, sizeof(cmt_file_path));
- DECL_STATE_ENTRY_CMT_RECORDING(cmt_fio, cmt_rec, cmt_file_path);
-
- DECL_STATE_ENTRY_INT32(cmt_count);
- DECL_STATE_ENTRY_1D_ARRAY(cmt_buffer, sizeof(cmt_buffer));
- for(int i = 0; i < 6; i++) {
- DECL_STATE_ENTRY_1D_ARRAY_MEMBER((lcd[i].buffer), 80, i);
- DECL_STATE_ENTRY_INT32_MEMBER((lcd[i].bank), i);
- DECL_STATE_ENTRY_INT32_MEMBER((lcd[i].addr), i);
- }
-
- DECL_STATE_ENTRY_UINT8(lcd_select);
- DECL_STATE_ENTRY_UINT8(lcd_data);
- DECL_STATE_ENTRY_INT32(lcd_clock);
- DECL_STATE_ENTRY_INT32(int_status);
- DECL_STATE_ENTRY_INT32(int_mask);
-
- leave_decl_state();
-}
-
-void MEMORY::save_state(FILEIO* state_fio)
-{
- tmp_wbank_is_ext = (wbank[0x8000 >> 13] == ext);
- tmp_rbank_is_ext = (rbank[0x8000 >> 13] == ext);
-
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->FputBool(wbank[0x8000 >> 13] == ext);
-// state_fio->FputBool(rbank[0x8000 >> 13] == ext);
-// state_fio->Fwrite(rom, sizeof(rom), 1);
-// state_fio->Fwrite(ext, sizeof(ext), 1);
-// cmd_buf->save_state((void *)state_fio);
-// state_fio->FputBool(sio_select);
-// state_fio->FputBool(special_cmd_masked);
-// state_fio->Fwrite(slave_mem, sizeof(slave_mem), 1);
-// state_fio->Fwrite(sound, sizeof(sound), 1);
-// state_fio->FputInt32(sound_ptr);
-// state_fio->FputInt32(sound_count);
-// state_fio->FputUint8(sound_reply);
-// state_fio->FputDouble(sound_freq);
-// state_fio->Fwrite(key_stat, sizeof(key_stat), 1);
-// state_fio->Fwrite(key_flag, sizeof(key_flag), 1);
-// state_fio->FputInt32(key_data);
-// state_fio->FputInt32(key_strobe);
-// state_fio->FputInt32(key_intmask);
-// state_fio->FputBool(cmt_play);
-// state_fio->FputBool(cmt_rec);
-// state_fio->Fwrite(cmt_file_path, sizeof(cmt_file_path), 1);
-// if(cmt_rec && cmt_fio->IsOpened()) {
-// int length_tmp = (int)cmt_fio->Ftell();
-// cmt_fio->Fseek(0, FILEIO_SEEK_SET);
-// state_fio->FputInt32(length_tmp);
-// while(length_tmp != 0) {
-// uint8_t buffer_tmp[1024];
-// int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
-// cmt_fio->Fread(buffer_tmp, length_rw, 1);
-// state_fio->Fwrite(buffer_tmp, length_rw, 1);
-// length_tmp -= length_rw;
-// }
-// } else {
-// state_fio->FputInt32(0);
-// }
-// state_fio->FputInt32(cmt_count);
-// state_fio->Fwrite(cmt_buffer, sizeof(cmt_buffer), 1);
-// state_fio->Fwrite(lcd, sizeof(lcd), 1);
-// state_fio->FputUint8(lcd_select);
-// state_fio->FputUint8(lcd_data);
-// state_fio->FputInt32(lcd_clock);
-// state_fio->FputInt32(int_status);
-// state_fio->FputInt32(int_mask);
-}
-
-bool MEMORY::load_state(FILEIO* state_fio)
-{
- close_tape();
-
- 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;
-// }
-// bool wr = state_fio->FgetBool();
-// bool rd = state_fio->FgetBool();
-// state_fio->Fread(rom, sizeof(rom), 1);
-// state_fio->Fread(ext, sizeof(ext), 1);
-// if(!cmd_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// sio_select = state_fio->FgetBool();
-// special_cmd_masked = state_fio->FgetBool();
-// state_fio->Fread(slave_mem, sizeof(slave_mem), 1);
-// state_fio->Fread(sound, sizeof(sound), 1);
-// sound_ptr = state_fio->FgetInt32();
-// sound_count = state_fio->FgetInt32();
-// sound_reply = state_fio->FgetUint8();
-// sound_freq = state_fio->FgetDouble();
-// state_fio->Fread(key_stat, sizeof(key_stat), 1);
-// state_fio->Fread(key_flag, sizeof(key_flag), 1);
-// key_data = state_fio->FgetInt32();
-// key_strobe = state_fio->FgetInt32();
-// key_intmask = state_fio->FgetInt32();
-// cmt_play = state_fio->FgetBool();
-// cmt_rec = state_fio->FgetBool();
-// state_fio->Fread(cmt_file_path, sizeof(cmt_file_path), 1);
-// int length_tmp = state_fio->FgetInt32();
-// if(cmt_rec) {
-// cmt_fio->Fopen(cmt_file_path, FILEIO_READ_WRITE_NEW_BINARY);
-// while(length_tmp != 0) {
-// uint8_t buffer_tmp[1024];
-// int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
-// state_fio->Fread(buffer_tmp, length_rw, 1);
-// if(cmt_fio->IsOpened()) {
-// cmt_fio->Fread(buffer_tmp, length_rw, 1);
-// }
-// length_tmp -= length_rw;
-// }
-// }
-// cmt_count = state_fio->FgetInt32();
-// state_fio->Fread(cmt_buffer, sizeof(cmt_buffer), 1);
-// state_fio->Fread(lcd, sizeof(lcd), 1);
-// lcd_select = state_fio->FgetUint8();
-// lcd_data = state_fio->FgetUint8();
-// lcd_clock = state_fio->FgetInt32();
-// int_status = state_fio->FgetInt32();
-// int_mask = state_fio->FgetInt32();
-
- // post process
- SET_BANK(0x8000, 0xbfff, tmp_wbank_is_ext ? ext : wdmy, tmp_rbank_is_ext ? ext : rom);
- return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool HC20_MEMORY::process_state(FILEIO* state_fio, bool loading)
{
bool wr = false;
bool rd = false;
state_fio->FputBool(rbank[0x8000 >> 13] == ext);
}
state_fio->StateBuffer(rom, sizeof(rom), 1);
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
state_fio->StateBuffer(ext, sizeof(ext), 1);
if(!cmd_buf->process_state((void *)state_fio, loading)) {
return false;
state_fio->StateBool(sio_select);
state_fio->StateBool(special_cmd_masked);
state_fio->StateBuffer(slave_mem, sizeof(slave_mem), 1);
- state_fio->StateBuffer(sound, sizeof(sound), 1);
+ //state_fio->StateBuffer(sound, sizeof(sound), 1);
+ for(int i = 0; i < 256; i++) {
+ state_fio->StateDouble(sound[i].freq);
+ state_fio->StateInt32(sound[i].period);
+ state_fio->StateInt32(sound[i].remain);
+ }
state_fio->StateInt32(sound_ptr);
state_fio->StateInt32(sound_count);
state_fio->StateUint8(sound_reply);
}
state_fio->StateInt32(cmt_count);
state_fio->StateBuffer(cmt_buffer, sizeof(cmt_buffer), 1);
- state_fio->StateBuffer(lcd, sizeof(lcd), 1);
+ //state_fio->StateBuffer(lcd, sizeof(lcd), 1);
+ for(int i = 0; i < (sizeof(lcd) / sizeof(lcd_t)); i++) {
+ state_fio->StateBuffer(lcd[i].buffer, 0x80, 1);
+ state_fio->StateInt32(lcd[i].bank);
+ state_fio->StateInt32(lcd[i].addr);
+ }
state_fio->StateUint8(lcd_select);
state_fio->StateUint8(lcd_data);
state_fio->StateInt32(lcd_clock);
[ memory ]
*/
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _HC20_MEMORY_H_
+#define _HC20_MEMORY_H_
#include "../vm.h"
#include "../../emu.h"
class BEEP;
class FIFO;
-class MEMORY : public DEVICE
+class HC20_MEMORY : public DEVICE
{
private:
BEEP *d_beep;
void send_to_main(uint8_t val);
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ HC20_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~HC20_MEMORY() {}
// common functions
void initialize();
uint32_t read_data8(uint32_t addr);
void write_signal(int id, uint32_t data, uint32_t mask);
void event_callback(int event_id, int err);
- 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_beep(BEEP* device)
tf20 = new PTF20(this, emu);
cpu = new Z80(this, emu);
- io = new IO(this, emu);
- memory = new MEMORY(this, emu);
+ io = new HC40_IO(this, emu);
+ memory = new HC40_MEMORY(this, emu);
// set contexts
event->set_context_cpu(cpu);
event->set_context_sound(beep);
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::HC_40_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;
+ }
+ }
return true;
}
class PTF20;
class Z80;
-class IO;
-class MEMORY;
+class HC40_IO;
+class HC40_MEMORY;
class VM : public VM_TEMPLATE
{
PTF20* tf20;
Z80* cpu;
- IO* io;
- MEMORY* memory;
+ HC40_IO* io;
+ HC40_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
[ i/o ]
*/
-#include "io.h"
+#include "./io.h"
#include "../beep.h"
#include "../datarec.h"
#include "../ptf20.h"
DLL_PREFIX_I struct cur_time_s cur_time;
#endif
-void IO::initialize()
+void HC40_IO::initialize()
{
// init external ram disk
memset(ext, 0, 0x20000);
register_event_by_clock(this, EVENT_1SEC, CPU_CLOCKS, true, ®ister_id_1sec);
}
-void IO::release()
+void HC40_IO::release()
{
// save external ram disk
FILEIO* fio = new FILEIO();
delete art_buf;
}
-void IO::reset()
+void HC40_IO::reset()
{
// reset gapnit
bcr = slbcr = isr = ier = bankr = ioctlr = 0;
register_id_art = -1;
}
-void IO::sysreset()
+void HC40_IO::sysreset()
{
// reset 7508
onesec_intr = alarm_intr = false;
res_7508 = true;
}
-void IO::write_signal(int id, uint32_t data, uint32_t mask)
+void HC40_IO::write_signal(int id, uint32_t data, uint32_t mask)
{
if(id == SIG_IO_DREC) {
// signal from data recorder
}
}
-void IO::event_frame()
+void HC40_IO::event_frame()
{
d_beep->write_signal(SIG_BEEP_ON, beep ? 1 : 0, 1);
beep = false;
}
-void IO::event_callback(int event_id, int err)
+void HC40_IO::event_callback(int event_id, int err)
{
if(event_id == EVENT_FRC) {
// FRC overflow event
}
}
-void IO::write_io8(uint32_t addr, uint32_t data)
+void HC40_IO::write_io8(uint32_t addr, uint32_t data)
{
switch(addr & 0xff) {
case 0x00:
}
}
-uint32_t IO::read_io8(uint32_t addr)
+uint32_t HC40_IO::read_io8(uint32_t addr)
{
uint32_t val = 0xff;
return 0xff;
}
-uint32_t IO::get_intr_ack()
+uint32_t HC40_IO::get_intr_ack()
{
if(isr & BIT_7508) {
isr &= ~BIT_7508;
return 0xff;
}
-void IO::update_intr()
+void HC40_IO::update_intr()
{
// set int signal
bool next = ((isr & ier & 0x1f) != 0);
// 7508
// ----------------------------------------------------------------------------
-void IO::send_to_7508(uint8_t val)
+void HC40_IO::send_to_7508(uint8_t val)
{
int res;
}
}
-uint8_t IO::rec_from_7508()
+uint8_t HC40_IO::rec_from_7508()
{
return rsp_buf->read();
}
-void IO::key_down(int code)
+void HC40_IO::key_down(int code)
{
if(code == 0x14) {
// toggle caps lock
}
}
-void IO::key_up(int code)
+void HC40_IO::key_up(int code)
{
if(code == 0x10) {
update_key(0xa3); // break shift
}
}
-void IO::update_key(int code)
+void HC40_IO::update_key(int code)
{
if(code != 0xff) {
// add to buffer
// video
// ----------------------------------------------------------------------------
-void IO::draw_screen()
+void HC40_IO::draw_screen()
{
if(yoff & 0x80) {
uint8_t* vram = ram + ((vadr & 0xf8) << 8);
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void IO::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT32(cur_clock);
- DECL_STATE_ENTRY_UINT8(bcr);
- DECL_STATE_ENTRY_UINT8(slbcr);
- DECL_STATE_ENTRY_UINT8(isr);
- DECL_STATE_ENTRY_UINT8(ier);
- DECL_STATE_ENTRY_UINT8(bankr);
- DECL_STATE_ENTRY_UINT8(ioctlr);
- DECL_STATE_ENTRY_UINT32(icrc);
- DECL_STATE_ENTRY_UINT32(icrb);
- DECL_STATE_ENTRY_BOOL(ear);
- DECL_STATE_ENTRY_UINT8(vadr);
- DECL_STATE_ENTRY_UINT8(yoff);
- DECL_STATE_ENTRY_FIFO(cmd_buf);
- DECL_STATE_ENTRY_FIFO(rsp_buf);
- DECL_STATE_ENTRY_CUR_TIME_T(cur_time);
-
- DECL_STATE_ENTRY_INT32(register_id_1sec);
- DECL_STATE_ENTRY_BOOL(onesec_intr);
- DECL_STATE_ENTRY_BOOL(onesec_intr_enb);
- DECL_STATE_ENTRY_BOOL(alarm_intr);
- DECL_STATE_ENTRY_BOOL(alarm_intr_enb);
- DECL_STATE_ENTRY_1D_ARRAY(alarm, sizeof(alarm));
- DECL_STATE_ENTRY_FIFO(key_buf);
- DECL_STATE_ENTRY_BOOL(kb_intr_enb);
- DECL_STATE_ENTRY_BOOL(kb_rep_enb);
- DECL_STATE_ENTRY_BOOL(kb_caps);
- DECL_STATE_ENTRY_UINT8(kb_rep_spd1);
- DECL_STATE_ENTRY_UINT8(kb_rep_spd2);
- DECL_STATE_ENTRY_FIFO(art_buf);
- DECL_STATE_ENTRY_UINT8(artsr);
- DECL_STATE_ENTRY_UINT8(artdir);
- DECL_STATE_ENTRY_BOOL(txen);
- DECL_STATE_ENTRY_BOOL(rxen);
- DECL_STATE_ENTRY_BOOL(dsr);
- DECL_STATE_ENTRY_INT32(register_id_art);
- DECL_STATE_ENTRY_BOOL(beep);
- DECL_STATE_ENTRY_BOOL(res_z80);
- DECL_STATE_ENTRY_BOOL(res_7508);
- DECL_STATE_ENTRY_1D_ARRAY(ext, sizeof(ext));
- DECL_STATE_ENTRY_UINT32(extar);
- DECL_STATE_ENTRY_UINT8(extcr);
-
- leave_decl_state();
-}
-
-
-void IO::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->FputUint32(cur_clock);
-// state_fio->FputUint8(bcr);
-// state_fio->FputUint8(slbcr);
-// state_fio->FputUint8(isr);
-// state_fio->FputUint8(ier);
-// state_fio->FputUint8(bankr);
-// state_fio->FputUint8(ioctlr);
-// state_fio->FputUint32(icrc);
-// state_fio->FputUint32(icrb);
-// state_fio->FputBool(ear);
-// state_fio->FputUint8(vadr);
-// state_fio->FputUint8(yoff);
-// cmd_buf->save_state((void *)state_fio);
-// rsp_buf->save_state((void *)state_fio);
-// cur_time.save_state((void *)state_fio);
-// state_fio->FputInt32(register_id_1sec);
-// state_fio->FputBool(onesec_intr);
-// state_fio->FputBool(onesec_intr_enb);
-// state_fio->FputBool(alarm_intr);
-// state_fio->FputBool(alarm_intr_enb);
-// state_fio->Fwrite(alarm, sizeof(alarm), 1);
-// key_buf->save_state((void *)state_fio);
-// state_fio->FputBool(kb_intr_enb);
-// state_fio->FputBool(kb_rep_enb);
-// state_fio->FputBool(kb_caps);
-// state_fio->FputUint8(kb_rep_spd1);
-// state_fio->FputUint8(kb_rep_spd2);
-// art_buf->save_state((void *)state_fio);
-// state_fio->FputUint8(artsr);
-// state_fio->FputUint8(artdir);
-// state_fio->FputBool(txen);
-// state_fio->FputBool(rxen);
-// state_fio->FputBool(dsr);
-// state_fio->FputInt32(register_id_art);
-// state_fio->FputBool(beep);
-// state_fio->FputBool(res_z80);
-// state_fio->FputBool(res_7508);
-// state_fio->Fwrite(ext, sizeof(ext), 1);
-// state_fio->FputUint32(extar);
-// state_fio->FputUint8(extcr);
-}
-
-bool IO::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;
-// }
-// cur_clock = state_fio->FgetUint32();
-// bcr = state_fio->FgetUint8();
-// slbcr = state_fio->FgetUint8();
-// isr = state_fio->FgetUint8();
-// ier = state_fio->FgetUint8();
-// bankr = state_fio->FgetUint8();
-// ioctlr = state_fio->FgetUint8();
-// icrc = state_fio->FgetUint32();
-// icrb = state_fio->FgetUint32();
-// ear = state_fio->FgetBool();
-// vadr = state_fio->FgetUint8();
-// yoff = state_fio->FgetUint8();
-// if(!cmd_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// if(!rsp_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// if(!cur_time.load_state((void *)state_fio)) {
-// return false;
-// }
-
-// register_id_1sec = state_fio->FgetInt32();
-// onesec_intr = state_fio->FgetBool();
-// onesec_intr_enb = state_fio->FgetBool();
-// alarm_intr = state_fio->FgetBool();
-// alarm_intr_enb = state_fio->FgetBool();
-// state_fio->Fread(alarm, sizeof(alarm), 1);
-// if(!key_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// kb_intr_enb = state_fio->FgetBool();
-// kb_rep_enb = state_fio->FgetBool();
-// kb_caps = state_fio->FgetBool();
-// kb_rep_spd1 = state_fio->FgetUint8();
-// kb_rep_spd2 = state_fio->FgetUint8();
-// if(!art_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// artsr = state_fio->FgetUint8();
-// artdir = state_fio->FgetUint8();
-// txen = state_fio->FgetBool();
-// rxen = state_fio->FgetBool();
-// dsr = state_fio->FgetBool();
-// register_id_art = state_fio->FgetInt32();
-// beep = state_fio->FgetBool();
-// res_z80 = state_fio->FgetBool();
-// res_7508 = state_fio->FgetBool();
-// state_fio->Fread(ext, sizeof(ext), 1);
-// extar = state_fio->FgetUint32();
-// extcr = state_fio->FgetUint8();
- return true;
-}
-
-bool IO::process_state(FILEIO* state_fio, bool loading)
+bool HC40_IO::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ i/o ]
*/
-#ifndef _IO_H_
-#define _IO_H_
+#ifndef _HC40_IO_H_
+#define _HC40_IO_H_
#include "../vm.h"
#include "../../emu.h"
class FIFO;
-class IO : public DEVICE
+class HC40_IO : public DEVICE
{
private:
DEVICE *d_cpu, *d_mem, *d_tf20, *d_beep, *d_drec;
scrntype_t pd, pb;
public:
- IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ HC40_IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("I/O Bus"));
}
- ~IO() {}
+ ~HC40_IO() {}
// common functions
void initialize();
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
uint32_t get_intr_ack();
- 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)
} \
}
-void MEMORY::initialize()
+void HC40_MEMORY::initialize()
{
// initialize memory
memset(ram, 0, sizeof(ram));
delete fio;
}
-void MEMORY::release()
+void HC40_MEMORY::release()
{
// save battery backuped ram
FILEIO* fio = new FILEIO();
delete fio;
}
-void MEMORY::reset()
+void HC40_MEMORY::reset()
{
set_bank(0);
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void HC40_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
addr &= 0xffff;
wbank[(addr >> 13) & 7][addr & 0x1fff] = data;
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t HC40_MEMORY::read_data8(uint32_t addr)
{
addr &= 0xffff;
return rbank[(addr >> 13) & 7][addr & 0x1fff];
}
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void HC40_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
{
set_bank(data);
}
-void MEMORY::set_bank(uint32_t val)
+void HC40_MEMORY::set_bank(uint32_t val)
{
SET_BANK(0x0000, 0xffff, ram, ram);
#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_UINT8(bank);
-
- 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->FputUint8(bank);
-}
-
-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);
-// bank = state_fio->FgetUint8();
-
- // post process
- set_bank(bank);
- return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool HC40_MEMORY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ memory ]
*/
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _HC40_MEMORY_H_
+#define _HC40_MEMORY_H_
#include "../vm.h"
#include "../../emu.h"
#include "../device.h"
-class MEMORY : public DEVICE
+class HC40_MEMORY : public DEVICE
{
private:
// memory
void set_bank(uint32_t val);
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ HC40_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~HC40_MEMORY() {}
// common functions
void initialize();
void write_data8(uint32_t addr, uint32_t data);
uint32_t read_data8(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 function
uint8_t* get_ram()
#include "../debugger.h"
#endif
-#include "io.h"
-#include "memory.h"
+#include "./io.h"
+#include "./memory.h"
// ----------------------------------------------------------------------------
// initialize
tf20 = new PTF20(this, emu);
cpu = new Z80(this, emu);
- io = new IO(this, emu);
- memory = new MEMORY(this, emu);
+ io = new HC80_IO(this, emu);
+ memory = new HC80_MEMORY(this, emu);
// set contexts
event->set_context_cpu(cpu);
event->set_context_sound(beep);
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
- decl_state();
}
VM::~VM()
#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::HC_80_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;
+ }
+ }
return true;
}
class PTF20;
class Z80;
-class IO;
-class MEMORY;
+class HC80_IO;
+class HC80_MEMORY;
class VM : public VM_TEMPLATE
{
PTF20* tf20;
Z80* cpu;
- IO* io;
- MEMORY* memory;
+ HC80_IO* io;
+ HC80_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
DLL_PREFIX_I struct cur_time_s cur_time;
#endif
-void IO::initialize()
+void HC80_IO::initialize()
{
// config
device_type = config.device_type;
register_event_by_clock(this, EVENT_6303, 100, true, NULL);
}
-void IO::release()
+void HC80_IO::release()
{
// save external ram disk
FILEIO* fio = new FILEIO();
delete key_buf;
}
-void IO::reset()
+void HC80_IO::reset()
{
// reset gapnit
bcr = slbcr = isr = ier = ioctlr = 0;
iramdisk_ptr = iramdisk_buf;
}
-void IO::sysreset()
+void HC80_IO::sysreset()
{
// reset 7508
onesec_intr = alarm_intr = false;
res_7508 = true;
}
-void IO::write_signal(int id, uint32_t data, uint32_t mask)
+void HC80_IO::write_signal(int id, uint32_t data, uint32_t mask)
{
if(id == SIG_IO_RXRDY) {
// notify rxrdy is changed from i8251
}
}
-void IO::event_frame()
+void HC80_IO::event_frame()
{
d_beep->write_signal(SIG_BEEP_ON, beep ? 1 : 0, 1);
beep = false;
blink++;
}
-void IO::event_callback(int event_id, int err)
+void HC80_IO::event_callback(int event_id, int err)
{
if(event_id == EVENT_FRC) {
// FRC overflow event
}
}
-void IO::write_io8(uint32_t addr, uint32_t data)
+void HC80_IO::write_io8(uint32_t addr, uint32_t data)
{
//this->out_debug_log(_T("OUT %2x,%2x\n"), addr & 0xff, data);
switch(addr & 0xff) {
}
}
-uint32_t IO::read_io8(uint32_t addr)
+uint32_t HC80_IO::read_io8(uint32_t addr)
{
uint32_t val = 0xff;
// this->out_debug_log(_T("IN %2x\n"), addr & 0xff);
return 0xff;
}
-uint32_t IO::get_intr_ack()
+uint32_t HC80_IO::get_intr_ack()
{
if(isr & BIT_7508) {
isr &= ~BIT_7508;
return 0xff;
}
-void IO::update_intr()
+void HC80_IO::update_intr()
{
// set int signal
bool next = ((isr & ier & 0x3f) != 0);
// 7508
// ----------------------------------------------------------------------------
-void IO::send_to_7508(uint8_t val)
+void HC80_IO::send_to_7508(uint8_t val)
{
int res;
}
}
-uint8_t IO::rec_from_7508()
+uint8_t HC80_IO::rec_from_7508()
{
return rsp7508_buf->read();
}
-void IO::key_down(int code)
+void HC80_IO::key_down(int code)
{
if(code == 0x14) {
// toggle caps lock
}
}
-void IO::key_up(int code)
+void HC80_IO::key_up(int code)
{
if(code == 0x10) {
update_key(0xa3); // break shift
}
}
-void IO::update_key(int code)
+void HC80_IO::update_key(int code)
{
if(code != 0xff) {
// add to buffer
// 6303
// ----------------------------------------------------------------------------
-void IO::process_6303()
+void HC80_IO::process_6303()
{
switch(cmd6303) {
case 0x00:
}
}
-uint8_t IO::get_point(int x, int y)
+uint8_t HC80_IO::get_point(int x, int y)
{
if(0 <= x && x < 480 && 0 <= y && y < 64) {
uint8_t bit = dot_tbl[x & 7];
return 0;
}
-void IO::draw_point(int x, int y, uint16_t dot)
+void HC80_IO::draw_point(int x, int y, uint16_t dot)
{
if(0 <= x && x < 480 && 0 <= y && y < 64) {
uint8_t bit = dot_tbl[x & 7];
}
}
-void IO::draw_line(int sx, int sy, int ex, int ey, uint16_t ope)
+void HC80_IO::draw_line(int sx, int sy, int ex, int ey, uint16_t ope)
{
int next_x = sx, next_y = sy;
int delta_x = abs(ex - sx) * 2;
BANK: 1 or 2
*/
-void IO::iramdisk_write_data(uint8_t val)
+void HC80_IO::iramdisk_write_data(uint8_t val)
{
if(iramdisk_dest == IRAMDISK_IN && iramdisk_count) {
*(iramdisk_ptr++) = val;
}
}
-void IO::iramdisk_write_cmd(uint8_t val)
+void HC80_IO::iramdisk_write_cmd(uint8_t val)
{
iramdisk_cmd = val;
iramdisk_count = 0;
}
}
-uint8_t IO::iramdisk_read_data()
+uint8_t HC80_IO::iramdisk_read_data()
{
if(iramdisk_dest == IRAMDISK_OUT) {
if(iramdisk_count) {
return 0;
}
-uint8_t IO::iramdisk_read_stat()
+uint8_t HC80_IO::iramdisk_read_stat()
{
if(iramdisk_dest == IRAMDISK_OUT) {
return IRAMDISK_WAIT;
// ----------------------------------------------------------------------------
-void IO::draw_screen()
+void HC80_IO::draw_screen()
{
if(lcd_on) {
memset(lcd, 0, sizeof(lcd));
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void IO::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT32(cur_clock);
- DECL_STATE_ENTRY_UINT8(bcr);
- DECL_STATE_ENTRY_UINT8(slbcr);
- DECL_STATE_ENTRY_UINT8(isr);
- DECL_STATE_ENTRY_UINT8(ier);
- DECL_STATE_ENTRY_UINT8(ioctlr);
- DECL_STATE_ENTRY_UINT32(icrc);
- DECL_STATE_ENTRY_UINT32(icrb);
- DECL_STATE_ENTRY_BOOL(ear);
- DECL_STATE_ENTRY_UINT8(vadr);
- DECL_STATE_ENTRY_UINT8(yoff);
- DECL_STATE_ENTRY_FIFO(cmd7508_buf);
- DECL_STATE_ENTRY_FIFO(rsp7508_buf);
- DECL_STATE_ENTRY_CUR_TIME_T(cur_time);
- DECL_STATE_ENTRY_INT32(register_id);
- DECL_STATE_ENTRY_BOOL(onesec_intr);
- DECL_STATE_ENTRY_BOOL(onesec_intr_enb);
- DECL_STATE_ENTRY_BOOL(alarm_intr);
- DECL_STATE_ENTRY_BOOL(alarm_intr_enb);
- DECL_STATE_ENTRY_1D_ARRAY(alarm, sizeof(alarm));
- DECL_STATE_ENTRY_FIFO(key_buf);
- DECL_STATE_ENTRY_BOOL(kb_intr_enb);
- DECL_STATE_ENTRY_BOOL(kb_rep_enb);
- DECL_STATE_ENTRY_BOOL(kb_caps);
- DECL_STATE_ENTRY_UINT8(kb_rep_spd1);
- DECL_STATE_ENTRY_UINT8(kb_rep_spd2);
- DECL_STATE_ENTRY_BOOL(beep);
- DECL_STATE_ENTRY_BOOL(res_z80);
- DECL_STATE_ENTRY_BOOL(res_7508);
- DECL_STATE_ENTRY_UINT8(cmd6303);
- DECL_STATE_ENTRY_UINT8(psr);
- DECL_STATE_ENTRY_FIFO(cmd6303_buf);
- DECL_STATE_ENTRY_FIFO(rsp6303_buf);
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_UINT16(cs_addr);
- DECL_STATE_ENTRY_UINT16(gs_addr);
- DECL_STATE_ENTRY_UINT8(lcd_on);
- DECL_STATE_ENTRY_UINT8(scr_mode);
- DECL_STATE_ENTRY_UINT16(scr_ptr);
- DECL_STATE_ENTRY_UINT8(num_lines);
- DECL_STATE_ENTRY_UINT8(curs_mode);
- DECL_STATE_ENTRY_UINT8(curs_x);
- DECL_STATE_ENTRY_UINT8(curs_y);
- DECL_STATE_ENTRY_UINT8(wnd_ptr_x);
- DECL_STATE_ENTRY_UINT8(wnd_ptr_y);
- DECL_STATE_ENTRY_UINT8(flash_block);
- DECL_STATE_ENTRY_UINT8(cs_blocks);
- DECL_STATE_ENTRY_2D_ARRAY(cs_block, 40, 3);
- DECL_STATE_ENTRY_UINT8(gs_blocks);
- DECL_STATE_ENTRY_2D_ARRAY(gs_block, 144, 3);
- DECL_STATE_ENTRY_1D_ARRAY(font, sizeof(font));
- DECL_STATE_ENTRY_2D_ARRAY(udgc, 256, 255+2);
- DECL_STATE_ENTRY_2D_ARRAY(mov, 64, 80);
- DECL_STATE_ENTRY_2D_ARRAY(lcd, SCREEN_HEIGHT, SCREEN_WIDTH);
- DECL_STATE_ENTRY_INT32(blink);
- DECL_STATE_ENTRY_FIFO(tf20_buf);
- DECL_STATE_ENTRY_INT32(device_type);
- DECL_STATE_ENTRY_1D_ARRAY(ext, sizeof(ext));
- DECL_STATE_ENTRY_UINT32(extar);
- DECL_STATE_ENTRY_UINT8(extcr);
- DECL_STATE_ENTRY_3D_ARRAY(iramdisk_sectors, 15, 64, 128);
- DECL_STATE_ENTRY_UINT8(iramdisk_cmd);
- DECL_STATE_ENTRY_INT32(iramdisk_count);
- DECL_STATE_ENTRY_INT32(iramdisk_dest);
- DECL_STATE_ENTRY_1D_ARRAY(iramdisk_buf, sizeof(iramdisk_buf));
- DECL_STATE_ENTRY_INT32(tmp_iramdisk_size); // (int)(iramdisk_ptr - iramdisk_buf));
-
- leave_decl_state();
-}
-
-void IO::save_state(FILEIO* state_fio)
-{
- tmp_iramdisk_size = (int)(iramdisk_ptr - iramdisk_buf);
-
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->FputUint32(cur_clock);
-// state_fio->FputUint8(bcr);
-// state_fio->FputUint8(slbcr);
-// state_fio->FputUint8(isr);
-// state_fio->FputUint8(ier);
-// state_fio->FputUint8(ioctlr);
-// state_fio->FputUint32(icrc);
-/// state_fio->FputUint32(icrb);
-// state_fio->FputBool(ear);
-// state_fio->FputUint8(vadr);
-// state_fio->FputUint8(yoff);
-// cmd7508_buf->save_state((void *)state_fio);
-// rsp7508_buf->save_state((void *)state_fio);
-// cur_time.save_state((void *)state_fio);
-// state_fio->FputInt32(register_id);
-// state_fio->FputBool(onesec_intr);
-// state_fio->FputBool(onesec_intr_enb);
-// state_fio->FputBool(alarm_intr);
-// state_fio->FputBool(alarm_intr_enb);
-// state_fio->Fwrite(alarm, sizeof(alarm), 1);
-// key_buf->save_state((void *)state_fio);
-// state_fio->FputBool(kb_intr_enb);
-// state_fio->FputBool(kb_rep_enb);
-// state_fio->FputBool(kb_caps);
-// state_fio->FputUint8(kb_rep_spd1);
-// state_fio->FputUint8(kb_rep_spd2);
-// state_fio->FputBool(beep);
-// state_fio->FputBool(res_z80);
-// state_fio->FputBool(res_7508);
-// state_fio->FputUint8(cmd6303);
-// state_fio->FputUint8(psr);
-// cmd6303_buf->save_state((void *)state_fio);
-// rsp6303_buf->save_state((void *)state_fio);
-// state_fio->Fwrite(ram, sizeof(ram), 1);
-// state_fio->FputUint16(cs_addr);
-// state_fio->FputUint16(gs_addr);
-// state_fio->FputUint8(lcd_on);
-// state_fio->FputUint8(scr_mode);
-// state_fio->FputUint16(scr_ptr);
-// state_fio->FputUint8(num_lines);
-// state_fio->FputUint8(curs_mode);
-// state_fio->FputUint8(curs_x);
-// state_fio->FputUint8(curs_y);
-// state_fio->FputUint8(wnd_ptr_x);
-// state_fio->FputUint8(wnd_ptr_y);
-// state_fio->FputUint8(flash_block);
-// state_fio->FputUint8(cs_blocks);
-// state_fio->Fwrite(cs_block, sizeof(cs_block), 1);
-// state_fio->FputUint8(gs_blocks);
-// state_fio->Fwrite(gs_block, sizeof(gs_block), 1);
-// state_fio->Fwrite(font, sizeof(font), 1);
-// state_fio->Fwrite(udgc, sizeof(udgc), 1);
-// state_fio->Fwrite(mov, sizeof(mov), 1);
-// state_fio->Fwrite(lcd, sizeof(lcd), 1);
-// state_fio->FputInt32(blink);
-// tf20_buf->save_state((void *)state_fio);
-// state_fio->FputInt32(device_type);
-// state_fio->Fwrite(ext, sizeof(ext), 1);
-// state_fio->FputUint32(extar);
-// state_fio->FputUint8(extcr);
-// state_fio->Fwrite(iramdisk_sectors, sizeof(iramdisk_sectors), 1);
-// state_fio->FputUint8(iramdisk_cmd);
-// state_fio->FputInt32(iramdisk_count);
-// state_fio->FputInt32(iramdisk_dest);
-// state_fio->Fwrite(iramdisk_buf, sizeof(iramdisk_buf), 1);
-// state_fio->FputInt32((int)(iramdisk_ptr - iramdisk_buf));
-}
-
-bool IO::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;
-// }
-// cur_clock = state_fio->FgetUint32();
-// bcr = state_fio->FgetUint8();
-// slbcr = state_fio->FgetUint8();
-// isr = state_fio->FgetUint8();
-// ier = state_fio->FgetUint8();
-// ioctlr = state_fio->FgetUint8();
-// icrc = state_fio->FgetUint32();
-// icrb = state_fio->FgetUint32();
-// ear = state_fio->FgetBool();
-// vadr = state_fio->FgetUint8();
-// yoff = state_fio->FgetUint8();
-// if(!cmd7508_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// if(!rsp7508_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// if(!cur_time.load_state((void *)state_fio)) {
-// return false;
-// }
-// register_id = state_fio->FgetInt32();
-// onesec_intr = state_fio->FgetBool();
-// onesec_intr_enb = state_fio->FgetBool();
-// alarm_intr = state_fio->FgetBool();
-// alarm_intr_enb = state_fio->FgetBool();
-// state_fio->Fread(alarm, sizeof(alarm), 1);
-// if(!key_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// kb_intr_enb = state_fio->FgetBool();
-// kb_rep_enb = state_fio->FgetBool();
-// kb_caps = state_fio->FgetBool();
-// kb_rep_spd1 = state_fio->FgetUint8();
-// kb_rep_spd2 = state_fio->FgetUint8();
-// beep = state_fio->FgetBool();
-// res_z80 = state_fio->FgetBool();
-// res_7508 = state_fio->FgetBool();
-// cmd6303 = state_fio->FgetUint8();
-// psr = state_fio->FgetUint8();
-// if(!cmd6303_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// if(!rsp6303_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// state_fio->Fread(ram, sizeof(ram), 1);
-// cs_addr = state_fio->FgetUint16();
-// gs_addr = state_fio->FgetUint16();
-// lcd_on = state_fio->FgetUint8();
-// scr_mode = state_fio->FgetUint8();
-// scr_ptr = state_fio->FgetUint16();
-// num_lines = state_fio->FgetUint8();
-// curs_mode = state_fio->FgetUint8();
-// curs_x = state_fio->FgetUint8();
-// curs_y = state_fio->FgetUint8();
-// wnd_ptr_x = state_fio->FgetUint8();
-// wnd_ptr_y = state_fio->FgetUint8();
-// flash_block = state_fio->FgetUint8();
-// cs_blocks = state_fio->FgetUint8();
-// state_fio->Fread(cs_block, sizeof(cs_block), 1);
-// gs_blocks = state_fio->FgetUint8();
-// state_fio->Fread(gs_block, sizeof(gs_block), 1);
-// state_fio->Fread(font, sizeof(font), 1);
-// state_fio->Fread(udgc, sizeof(udgc), 1);
-// state_fio->Fread(mov, sizeof(mov), 1);
-// state_fio->Fread(lcd, sizeof(lcd), 1);
-// blink = state_fio->FgetInt32();
-// if(!tf20_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// device_type = state_fio->FgetInt32();
-// state_fio->Fread(ext, sizeof(ext), 1);
-// extar = state_fio->FgetUint32();
-// extcr = state_fio->FgetUint8();
-// state_fio->Fread(iramdisk_sectors, sizeof(iramdisk_sectors), 1);
-// iramdisk_cmd = state_fio->FgetUint8();
-// iramdisk_count = state_fio->FgetInt32();
-// iramdisk_dest = state_fio->FgetInt32();
-// state_fio->Fread(iramdisk_buf, sizeof(iramdisk_buf), 1);
-
- iramdisk_ptr = iramdisk_buf + tmp_iramdisk_size;
- return true;
-}
-
-bool IO::process_state(FILEIO* state_fio, bool loading)
+bool HC80_IO::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ i/o ]
*/
-#ifndef _IO_H_
-#define _IO_H_
+#ifndef _HC80_IO_H_
+#define _HC80_IO_H_
#include "../vm.h"
#include "../../emu.h"
class FIFO;
-class IO : public DEVICE
+class HC80_IO : public DEVICE
{
private:
DEVICE *d_cpu, *d_mem, *d_sio, *d_beep, *d_tf20;
uint8_t iramdisk_buf[130];
uint8_t *iramdisk_ptr;
- int tmp_iramdisk_size;
public:
- IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ HC80_IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("I/O Bus"));
}
- ~IO() {}
+ ~HC80_IO() {}
// common functions
void initialize();
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
uint32_t get_intr_ack();
- 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)
} \
}
-void MEMORY::initialize()
+void HC80_MEMORY::initialize()
{
// initialize memory
memset(ram, 0, sizeof(ram));
delete fio;
}
-void MEMORY::release()
+void HC80_MEMORY::release()
{
// save battery backuped ram
FILEIO* fio = new FILEIO();
delete fio;
}
-void MEMORY::reset()
+void HC80_MEMORY::reset()
{
set_bank(0);
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void HC80_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
addr &= 0xffff;
wbank[(addr >> 13) & 7][addr & 0x1fff] = data;
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t HC80_MEMORY::read_data8(uint32_t addr)
{
addr &= 0xffff;
return rbank[(addr >> 13) & 7][addr & 0x1fff];
}
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void HC80_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
{
set_bank(data);
}
-void MEMORY::set_bank(uint32_t val)
+void HC80_MEMORY::set_bank(uint32_t val)
{
if(val & 1) {
SET_BANK(0x0000, 0xffff, ram, ram);
#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_UINT8(bank);
-
- 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->FputUint8(bank);
-}
-
-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);
-// bank = state_fio->FgetUint8();
-
- // post process
- set_bank(bank);
- return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool HC80_MEMORY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ memory ]
*/
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _HC80_MEMORY_H_
+#define _HC80_MEMORY_H_
#include "../vm.h"
#include "../../emu.h"
#include "../device.h"
-class MEMORY : public DEVICE
+class HC80_MEMORY : public DEVICE
{
private:
// memory
void set_bank(uint32_t val);
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ HC80_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~HC80_MEMORY() {}
// common functions
void initialize();
void write_data8(uint32_t addr, uint32_t data);
uint32_t read_data8(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);
};
#endif
}
#endif
-typedef struct i286_dtr_1_t{
- UINT32 base;
- UINT16 limit;
-};
-typedef struct i286_dtr_2_t{
- UINT16 sel;
- UINT32 base;
- UINT16 limit;
- UINT8 rights;
-};
-
-#if 0
-#include "../statesub.h"
+#define STATE_VERSION 5
-
-void I286::decl_state_cpustate()
+void I286::process_state_cpustate(FILEIO* state_fio, bool loading)
{
-#if defined(HAS_I286)
- struct i80286_state *state = (i80286_state *)opaque;
- //state_fio->Fwrite(&(state->regs), sizeof(i80286basicregs), 1);
- for(int i = 0; i < 8; i++) {
- DECL_STATE_ENTRY_UINT16_MEMBER((state->regs.w[i]), i);
- }
- DECL_STATE_ENTRY_UINT32((state->amask));
- DECL_STATE_ENTRY_UINT32((state->pc));
- DECL_STATE_ENTRY_UINT32((state->prevpc));
- DECL_STATE_ENTRY_UINT16((state->flags));
- DECL_STATE_ENTRY_UINT16((state->msw));
- DECL_STATE_ENTRY_1D_ARRAY((state->base), 4);
- DECL_STATE_ENTRY_1D_ARRAY((state->sregs), 4);
- DECL_STATE_ENTRY_1D_ARRAY((state->limit), 4);
- DECL_STATE_ENTRY_1D_ARRAY((state->rights), 4);
- DECL_STATE_ENTRY_1D_ARRAY((state->valid), 4);
-
- DECL_STATE_ENTRY_UINT32((state->gdtr.base));
- DECL_STATE_ENTRY_UINT16((state->gdtr.limit));
+#if defined(HAS_I86) || defined(HAS_I88) || defined(HAS_I186) || defined(HAS_V30)
+ struct i8086_state *cpustate = (struct i8086_state *)opaque;
- DECL_STATE_ENTRY_UINT32((state->idtr.base));
- DECL_STATE_ENTRY_UINT16((state->idtr.limit));
-
- DECL_STATE_ENTRY_UINT16((state->ldtr.sel));
- DECL_STATE_ENTRY_UINT32((state->ldtr.base));
- DECL_STATE_ENTRY_UINT32((state->ldtr.limit));
- DECL_STATE_ENTRY_UINT32((state->ldtr.rights));
-
- DECL_STATE_ENTRY_UINT16((state->tr.sel));
- DECL_STATE_ENTRY_UINT32((state->tr.base));
- DECL_STATE_ENTRY_UINT32((state->tr.limit));
- DECL_STATE_ENTRY_UINT32((state->tr.rights));
-
- DECL_STATE_ENTRY_INT32((state->AuxVal));
- DECL_STATE_ENTRY_INT32((state->OverVal));
- DECL_STATE_ENTRY_INT32((state->SignVal));
- DECL_STATE_ENTRY_INT32((state->ZeroVal));
- DECL_STATE_ENTRY_INT32((state->CarryVal));
- DECL_STATE_ENTRY_INT32((state->DirVal));
-
- DECL_STATE_ENTRY_UINT8((state->ParityVal));
- DECL_STATE_ENTRY_UINT8((state->TF));
- DECL_STATE_ENTRY_UINT8((state->IF));
- DECL_STATE_ENTRY_UINT8((state->MF));
- DECL_STATE_ENTRY_INT8((state->nmi_state));
- DECL_STATE_ENTRY_INT8((state->irq_state));
- DECL_STATE_ENTRY_INT8((state->test_state));
-
- DECL_STATE_ENTRY_UINT8((state->rep_in_progress));
- DECL_STATE_ENTRY_INT32((state->extra_cycles));
-
- DECL_STATE_ENTRY_INT32((state->halted));
- DECL_STATE_ENTRY_INT32((state->busreq));
- DECL_STATE_ENTRY_INT32((state->trap_level));
- DECL_STATE_ENTRY_INT32((state->shutdown));
- DECL_STATE_ENTRY_INT32((state->icount));
-
- DECL_STATE_ENTRY_UINT8((state->seg_prefix));
- DECL_STATE_ENTRY_UINT8((state->prefix_seg));
-
- DECL_STATE_ENTRY_UINT32((state->ea));
- DECL_STATE_ENTRY_UINT16((state->eo));
- DECL_STATE_ENTRY_UINT8((state->ea_seg));
-
-# ifdef USE_DEBUGGER
- DECL_STATE_ENTRY_UINT64((state->total_icount));
-# endif
-#else // not I286
-
- struct i8086_state *state = (i8086_state *)opaque;
- for(int i = 0; i < 8; i++) {
- DECL_STATE_ENTRY_UINT16_MEMBER((state->regs.w[i]), i);
+ state_fio->StateBuffer(&(cpustate->regs.b[0]), 16, 1);
+ state_fio->StateUint32(cpustate->pc);
+ state_fio->StateUint32(cpustate->prevpc);
+ for(int i = 0; i < 4; i++) {
+ state_fio->StateUint32(cpustate->base[i]);
}
+ for(int i = 0; i < 4; i++) {
+ state_fio->StateUint16(cpustate->sregs[i]);
+ }
+ state_fio->StateUint16(cpustate->flags);
+ state_fio->StateInt32(cpustate->AuxVal);
+ state_fio->StateInt32(cpustate->OverVal);
+ state_fio->StateInt32(cpustate->SignVal);
+ state_fio->StateInt32(cpustate->ZeroVal);
+ state_fio->StateInt32(cpustate->CarryVal);
+ state_fio->StateInt32(cpustate->DirVal);
+ state_fio->StateUint8(cpustate->ParityVal);
+ state_fio->StateUint8(cpustate->TF);
+ state_fio->StateUint8(cpustate->IF);
+ state_fio->StateUint8(cpustate->MF);
+
+ state_fio->StateUint8(cpustate->int_vector);
+ state_fio->StateInt8(cpustate->nmi_state);
+ state_fio->StateInt8(cpustate->irq_state);
+ state_fio->StateInt8(cpustate->test_state);
+ state_fio->StateUint8(cpustate->rep_in_progress);
+ state_fio->StateInt32(cpustate->extra_cycles);
+
+ state_fio->StateInt32(cpustate->halted);
+ state_fio->StateInt32(cpustate->busreq);
+
+ state_fio->StateUint16(cpustate->ip);
+ state_fio->StateUint32(cpustate->sp);
+
+ #ifdef USE_DEBUGGER
+ state_fio->StateUint64(cpustate->total_icount);
+ #endif
+ state_fio->StateInt32(cpustate->icount);
+
+ state_fio->StateUint8(cpustate->seg_prefix);
+ state_fio->StateUint8(cpustate->prefix_seg);
+ state_fio->StateUint32(cpustate->ea);
+ state_fio->StateUint16(cpustate->eo);
+ state_fio->StateUint8(cpustate->ea_seg);
- DECL_STATE_ENTRY_UINT32((state->pc));
- DECL_STATE_ENTRY_UINT32((state->prevpc));
- DECL_STATE_ENTRY_1D_ARRAY((state->base), 4);
- DECL_STATE_ENTRY_1D_ARRAY((state->sregs), 4);
-
- DECL_STATE_ENTRY_UINT16((state->flags));
-
- DECL_STATE_ENTRY_INT32((state->AuxVal));
- DECL_STATE_ENTRY_INT32((state->OverVal));
- DECL_STATE_ENTRY_INT32((state->SignVal));
- DECL_STATE_ENTRY_INT32((state->ZeroVal));
- DECL_STATE_ENTRY_INT32((state->CarryVal));
- DECL_STATE_ENTRY_INT32((state->DirVal));
-
- DECL_STATE_ENTRY_UINT8((state->ParityVal));
- DECL_STATE_ENTRY_UINT8((state->TF));
- DECL_STATE_ENTRY_UINT8((state->IF));
- DECL_STATE_ENTRY_UINT8((state->MF));
-
- DECL_STATE_ENTRY_UINT8((state->int_vector));
-
- DECL_STATE_ENTRY_INT8((state->nmi_state));
- DECL_STATE_ENTRY_INT8((state->irq_state));
- DECL_STATE_ENTRY_INT8((state->test_state));
-
- DECL_STATE_ENTRY_UINT8((state->rep_in_progress));
- DECL_STATE_ENTRY_INT32((state->extra_cycles));
-
- DECL_STATE_ENTRY_INT32((state->halted));
- DECL_STATE_ENTRY_INT32((state->busreq));
-
- DECL_STATE_ENTRY_UINT16((state->ip));
- DECL_STATE_ENTRY_UINT32((state->sp));
-
- DECL_STATE_ENTRY_INT32((state->icount));
-
- DECL_STATE_ENTRY_UINT8((state->seg_prefix));
- DECL_STATE_ENTRY_UINT8((state->prefix_seg));
-
- DECL_STATE_ENTRY_UINT32((state->ea));
- DECL_STATE_ENTRY_UINT16((state->eo));
- DECL_STATE_ENTRY_UINT8((state->ea_seg));
-
-# ifdef USE_DEBUGGER
- DECL_STATE_ENTRY_UINT64((state->total_icount));
-# endif
-#endif
-}
-#endif
+#elif defined(HAS_I286)
-void I286::save_state_cpustate(FILEIO* state_fio)
-{
-#if defined(HAS_I286)
- struct i80286_state *state = (i80286_state *)opaque;
- state_fio->Fwrite(&(state->regs), sizeof(i80286basicregs), 1);
- state_fio->Fwrite(&(state->amask), sizeof(UINT32), 1);
- state_fio->Fwrite(&(state->pc), sizeof(UINT32), 1);
- state_fio->Fwrite(&(state->prevpc), sizeof(UINT32), 1);
- state_fio->Fwrite(&(state->flags), sizeof(UINT16), 1);
- state_fio->Fwrite(&(state->msw), sizeof(UINT16), 1);
-
- state_fio->Fwrite(&(state->base[0]), sizeof(UINT32) * 4, 1);
- state_fio->Fwrite(&(state->sregs[0]), sizeof(UINT16) * 4, 1);
-
- state_fio->Fwrite(&(state->limit[0]), sizeof(UINT16) * 4, 1);
- state_fio->Fwrite(&(state->rights[0]), sizeof(UINT8) * 4, 1);
-
- state_fio->Fwrite(&(state->valid), sizeof(bool) * 4, 1);
-
- state_fio->Fwrite(&(state->gdtr), sizeof(i286_dtr_1_t), 1);
- state_fio->Fwrite(&(state->idtr), sizeof(i286_dtr_1_t), 1);
- state_fio->Fwrite(&(state->ldtr), sizeof(i286_dtr_2_t), 1);
- state_fio->Fwrite(&(state->tr), sizeof(i286_dtr_2_t), 1);
-
- state_fio->Fwrite(&(state->pic), sizeof(DEVICE *), 1);
- state_fio->Fwrite(&(state->program), sizeof(DEVICE *), 1);
- state_fio->Fwrite(&(state->io), sizeof(DEVICE *), 1);
-#ifdef I86_PSEUDO_BIOS
- state_fio->Fwrite(&(state->bios), sizeof(DEVICE *), 1);
-#endif
-#ifdef SINGLE_MODE_DMA
- state_fio->Fwrite(&(state->dma), sizeof(DEVICE *), 1);
-#endif
-#ifdef USE_DEBUGGER
- state_fio->Fwrite(&(state->emu), sizeof(EMU *), 1);
- state_fio->Fwrite(&(state->debugger), sizeof(DEBUGGER *), 1);
- state_fio->Fwrite(&(state->program_stored), sizeof(DEVICE *), 1);
- state_fio->Fwrite(&(state->io_stored), sizeof(DEVICE *), 1);
-#endif
- //INT32 AuxVal, OverVal, SignVal, ZeroVal, CarryVal, DirVal; /* 0 or non-0 valued flags */
- state_fio->Fwrite(&(state->AuxVal), sizeof(INT32) * 6, 1);
- //UINT8 ParityVal;
- //UINT8 TF, IF; /* 0 or 1 valued flags */
- //UINT8 MF; /* V30 mode flag */
- state_fio->Fwrite(&(state->ParityVal), sizeof(UINT8) * 4, 1);
- //INT8 nmi_state;
- //INT8 irq_state;
- //INT8 test_state;
- state_fio->Fwrite(&(state->nmi_state), sizeof(INT8) * 3, 1);
- //UINT8 rep_in_progress;
- state_fio->Fwrite(&(state->rep_in_progress), sizeof(UINT8) * 1, 1);
- //INT32 extra_cycles; /* extra cycles for interrupts */
- state_fio->Fwrite(&(state->extra_cycles), sizeof(INT32) * 1, 1);
- //int halted; /* Is the CPU halted ? */
- //int busreq;
- //int trap_level;
- //int shutdown;
- //int icount;
- state_fio->Fwrite(&(state->halted), sizeof(int) * 5, 1);
- state_fio->Fwrite(&(state->seg_prefix), sizeof(char) * 1, 1);
- state_fio->Fwrite(&(state->prefix_seg), sizeof(UINT8) * 1, 1);
- state_fio->Fwrite(&(state->ea), sizeof(unsigned), 1);
- state_fio->Fwrite(&(state->eo), sizeof(UINT16), 1);
- state_fio->Fwrite(&(state->ea_seg), sizeof(UINT8), 1);
-
-#else // not I286
-
- struct i8086_state *state = (i8086_state *)opaque;
- state_fio->Fwrite(&(state->regs), sizeof(i8086basicregs), 1);
- state_fio->Fwrite(&(state->pc), sizeof(UINT32), 1);
- state_fio->Fwrite(&(state->prevpc), sizeof(UINT32), 1);
- state_fio->Fwrite(&(state->base[0]), sizeof(UINT32) * 4, 1);
- state_fio->Fwrite(&(state->sregs[0]), sizeof(UINT16) * 4, 1);
-
- state_fio->Fwrite(&(state->flags), sizeof(UINT16), 1);
-
- //INT32 AuxVal, OverVal, SignVal, ZeroVal, CarryVal, DirVal; /* 0 or non-0 valued flags */
- state_fio->Fwrite(&(state->AuxVal), sizeof(INT32) * 6, 1);
- //UINT8 ParityVal;
- //UINT8 TF, IF; /* 0 or 1 valued flags */
- //UINT8 MF; /* V30 mode flag */
- state_fio->Fwrite(&(state->ParityVal), sizeof(UINT8) * 4, 1);
- state_fio->Fwrite(&(state->int_vector), sizeof(UINT8), 1);
- //INT8 nmi_state;
- //INT8 irq_state;
- //INT8 test_state;
- state_fio->Fwrite(&(state->nmi_state), sizeof(INT8) * 3, 1);
- //UINT8 rep_in_progress;
- state_fio->Fwrite(&(state->rep_in_progress), sizeof(UINT8) * 1, 1);
- //INT32 extra_cycles; /* extra cycles for interrupts */
- state_fio->Fwrite(&(state->extra_cycles), sizeof(INT32) * 1, 1);
- //int halted; /* Is the CPU halted ? */
- //int busreq;
- state_fio->Fwrite(&(state->halted), sizeof(int) * 2, 1);
-
- state_fio->Fwrite(&(state->ip), sizeof(UINT16) * 1, 1);
- state_fio->Fwrite(&(state->sp), sizeof(UINT32) * 1, 1);
-
- state_fio->Fwrite(&(state->pic), sizeof(DEVICE *), 1);
- state_fio->Fwrite(&(state->program), sizeof(DEVICE *), 1);
- state_fio->Fwrite(&(state->io), sizeof(DEVICE *), 1);
-#ifdef I86_PSEUDO_BIOS
- state_fio->Fwrite(&(state->bios), sizeof(DEVICE *), 1);
-#endif
-#ifdef SINGLE_MODE_DMA
- state_fio->Fwrite(&(state->dma), sizeof(DEVICE *), 1);
-#endif
-#ifdef USE_DEBUGGER
- state_fio->Fwrite(&(state->emu), sizeof(EMU *), 1);
- state_fio->Fwrite(&(state->debugger), sizeof(DEBUGGER *), 1);
- state_fio->Fwrite(&(state->program_stored), sizeof(DEVICE *), 1);
- state_fio->Fwrite(&(state->io_stored), sizeof(DEVICE *), 1);
-#endif
- state_fio->Fwrite(&(state->icount), sizeof(int) * 1, 1);
- state_fio->Fwrite(&(state->seg_prefix), sizeof(char) * 1, 1);
- state_fio->Fwrite(&(state->prefix_seg), sizeof(UINT8) * 1, 1);
- state_fio->Fwrite(&(state->ea), sizeof(unsigned), 1);
- state_fio->Fwrite(&(state->eo), sizeof(UINT16), 1);
- state_fio->Fwrite(&(state->ea_seg), sizeof(UINT8), 1);
-#endif
-}
+ struct i80286_state *cpustate = (struct i80286_state *)opaque;
-void I286::load_state_cpustate(FILEIO* state_fio)
-{
-#if defined(HAS_I286)
- struct i80286_state *state = (i80286_state *)opaque;
- state_fio->Fread(&(state->regs), sizeof(i80286basicregs), 1);
- state_fio->Fread(&(state->amask), sizeof(UINT32), 1);
- state_fio->Fread(&(state->pc), sizeof(UINT32), 1);
- state_fio->Fread(&(state->prevpc), sizeof(UINT32), 1);
- state_fio->Fread(&(state->flags), sizeof(UINT16), 1);
- state_fio->Fread(&(state->msw), sizeof(UINT16), 1);
-
- state_fio->Fread(&(state->base[0]), sizeof(UINT32) * 4, 1);
- state_fio->Fread(&(state->sregs[0]), sizeof(UINT16) * 4, 1);
-
- state_fio->Fread(&(state->limit[0]), sizeof(UINT16) * 4, 1);
- state_fio->Fread(&(state->rights[0]), sizeof(UINT8) * 4, 1);
-
- state_fio->Fread(&(state->valid), sizeof(bool) * 4, 1);
-
- state_fio->Fread(&(state->gdtr), sizeof(i286_dtr_1_t), 1);
- state_fio->Fread(&(state->idtr), sizeof(i286_dtr_1_t), 1);
- state_fio->Fread(&(state->ldtr), sizeof(i286_dtr_2_t), 1);
- state_fio->Fread(&(state->tr), sizeof(i286_dtr_2_t), 1);
-
- state_fio->Fread(&(state->pic), sizeof(DEVICE *), 1);
- state_fio->Fread(&(state->program), sizeof(DEVICE *), 1);
- state_fio->Fread(&(state->io), sizeof(DEVICE *), 1);
-#ifdef I86_PSEUDO_BIOS
- state_fio->Fread(&(state->bios), sizeof(DEVICE *), 1);
-#endif
-#ifdef SINGLE_MODE_DMA
- state_fio->Fread(&(state->dma), sizeof(DEVICE *), 1);
-#endif
-#ifdef USE_DEBUGGER
- state_fio->Fread(&(state->emu), sizeof(EMU *), 1);
- state_fio->Fread(&(state->debugger), sizeof(DEBUGGER *), 1);
- state_fio->Fread(&(state->program_stored), sizeof(DEVICE *), 1);
- state_fio->Fread(&(state->io_stored), sizeof(DEVICE *), 1);
-#endif
- //INT32 AuxVal, OverVal, SignVal, ZeroVal, CarryVal, DirVal; /* 0 or non-0 valued flags */
- state_fio->Fread(&(state->AuxVal), sizeof(INT32) * 6, 1);
- //UINT8 ParityVal;
- //UINT8 TF, IF; /* 0 or 1 valued flags */
- //UINT8 MF; /* V30 mode flag */
- state_fio->Fread(&(state->ParityVal), sizeof(UINT8) * 4, 1);
- //INT8 nmi_state;
- //INT8 irq_state;
- //INT8 test_state;
- state_fio->Fread(&(state->nmi_state), sizeof(INT8) * 3, 1);
- //UINT8 rep_in_progress;
- state_fio->Fread(&(state->rep_in_progress), sizeof(UINT8) * 1, 1);
- //INT32 extra_cycles; /* extra cycles for interrupts */
- state_fio->Fread(&(state->extra_cycles), sizeof(INT32) * 1, 1);
- //int halted; /* Is the CPU halted ? */
- //int busreq;
- //int trap_level;
- //int shutdown;
- //int icount;
- state_fio->Fread(&(state->halted), sizeof(int) * 5, 1);
- state_fio->Fread(&(state->seg_prefix), sizeof(char) * 1, 1);
- state_fio->Fread(&(state->prefix_seg), sizeof(UINT8) * 1, 1);
- state_fio->Fread(&(state->ea), sizeof(unsigned), 1);
- state_fio->Fread(&(state->eo), sizeof(UINT16), 1);
- state_fio->Fread(&(state->ea_seg), sizeof(UINT8), 1);
-
-#else // not I286
-
- struct i8086_state *state = (i8086_state *)opaque;
- state_fio->Fread(&(state->regs), sizeof(i8086basicregs), 1);
- state_fio->Fread(&(state->pc), sizeof(UINT32), 1);
- state_fio->Fread(&(state->prevpc), sizeof(UINT32), 1);
- state_fio->Fread(&(state->base[0]), sizeof(UINT32) * 4, 1);
- state_fio->Fread(&(state->sregs[0]), sizeof(UINT16) * 4, 1);
-
- state_fio->Fread(&(state->flags), sizeof(UINT16), 1);
-
- //INT32 AuxVal, OverVal, SignVal, ZeroVal, CarryVal, DirVal; /* 0 or non-0 valued flags */
- state_fio->Fread(&(state->AuxVal), sizeof(INT32) * 6, 1);
- //UINT8 ParityVal;
- //UINT8 TF, IF; /* 0 or 1 valued flags */
- //UINT8 MF; /* V30 mode flag */
- state_fio->Fread(&(state->ParityVal), sizeof(UINT8) * 4, 1);
- state_fio->Fread(&(state->int_vector), sizeof(UINT8), 1);
- //INT8 nmi_state;
- //INT8 irq_state;
- //INT8 test_state;
- state_fio->Fread(&(state->nmi_state), sizeof(INT8) * 3, 1);
- //UINT8 rep_in_progress;
- state_fio->Fread(&(state->rep_in_progress), sizeof(UINT8) * 1, 1);
- //INT32 extra_cycles; /* extra cycles for interrupts */
- state_fio->Fread(&(state->extra_cycles), sizeof(INT32) * 1, 1);
- //int halted; /* Is the CPU halted ? */
- //int busreq;
- state_fio->Fread(&(state->halted), sizeof(int) * 2, 1);
-
- state_fio->Fread(&(state->ip), sizeof(UINT16) * 1, 1);
- state_fio->Fread(&(state->sp), sizeof(UINT32) * 1, 1);
-
- state_fio->Fread(&(state->pic), sizeof(DEVICE *), 1);
- state_fio->Fread(&(state->program), sizeof(DEVICE *), 1);
- state_fio->Fread(&(state->io), sizeof(DEVICE *), 1);
-#ifdef I86_PSEUDO_BIOS
- state_fio->Fread(&(state->bios), sizeof(DEVICE *), 1);
-#endif
-#ifdef SINGLE_MODE_DMA
- state_fio->Fread(&(state->dma), sizeof(DEVICE *), 1);
-#endif
-#ifdef USE_DEBUGGER
- state_fio->Fread(&(state->emu), sizeof(EMU *), 1);
- state_fio->Fread(&(state->debugger), sizeof(DEBUGGER *), 1);
- state_fio->Fread(&(state->program_stored), sizeof(DEVICE *), 1);
- state_fio->Fread(&(state->io_stored), sizeof(DEVICE *), 1);
-#endif
- state_fio->Fread(&(state->icount), sizeof(int) * 1, 1);
- state_fio->Fread(&(state->seg_prefix), sizeof(char) * 1, 1);
- state_fio->Fread(&(state->prefix_seg), sizeof(UINT8) * 1, 1);
- state_fio->Fread(&(state->ea), sizeof(unsigned), 1);
- state_fio->Fread(&(state->eo), sizeof(UINT16), 1);
- state_fio->Fread(&(state->ea_seg), sizeof(UINT8), 1);
+ state_fio->StateBuffer(&(cpustate->regs.b[0]), 16, 1);
+ state_fio->StateUint32(cpustate->amask);
+ state_fio->StateUint32(cpustate->pc);
+ state_fio->StateUint32(cpustate->prevpc);
+ state_fio->StateUint16(cpustate->flags);
+ state_fio->StateUint16(cpustate->msw);
+ for(int i = 0; i < 4; i++) {
+ state_fio->StateUint32(cpustate->base[i]);
+ }
+ for(int i = 0; i < 4; i++) {
+ state_fio->StateUint16(cpustate->sregs[i]);
+ }
+ for(int i = 0; i < 4; i++) {
+ state_fio->StateUint16(cpustate->limit[i]);
+ }
+ state_fio->StateBuffer(cpustate->rights, 4, 1);
+ for(int i = 0; i < 4; i++) {
+ state_fio->StateBool(cpustate->valid[i]);
+ }
+ state_fio->StateUint32(cpustate->gdtr.base);
+ state_fio->StateUint16(cpustate->gdtr.limit);
+
+ state_fio->StateUint32(cpustate->idtr.base);
+ state_fio->StateUint16(cpustate->idtr.limit);
+
+ state_fio->StateUint16(cpustate->ldtr.sel);
+ state_fio->StateUint32(cpustate->ldtr.base);
+ state_fio->StateUint16(cpustate->ldtr.limit);
+ state_fio->StateUint8(cpustate->ldtr.rights);
+
+ state_fio->StateUint16(cpustate->tr.sel);
+ state_fio->StateUint32(cpustate->tr.base);
+ state_fio->StateUint16(cpustate->tr.limit);
+ state_fio->StateUint8(cpustate->tr.rights);
+
+ state_fio->StateInt32(cpustate->AuxVal);
+ state_fio->StateInt32(cpustate->OverVal);
+ state_fio->StateInt32(cpustate->SignVal);
+ state_fio->StateInt32(cpustate->ZeroVal);
+ state_fio->StateInt32(cpustate->CarryVal);
+ state_fio->StateInt32(cpustate->DirVal);
+ state_fio->StateUint8(cpustate->ParityVal);
+ state_fio->StateUint8(cpustate->TF);
+ state_fio->StateUint8(cpustate->IF);
+ state_fio->StateUint8(cpustate->MF);
+
+ state_fio->StateInt8(cpustate->nmi_state);
+ state_fio->StateInt8(cpustate->irq_state);
+ state_fio->StateInt8(cpustate->test_state);
+ state_fio->StateUint8(cpustate->rep_in_progress);
+ state_fio->StateInt32(cpustate->extra_cycles);
+
+ state_fio->StateInt32(cpustate->halted);
+ state_fio->StateInt32(cpustate->busreq);
+ state_fio->StateInt32(cpustate->trap_level);
+ state_fio->StateInt32(cpustate->shutdown);
+
+
+ #ifdef USE_DEBUGGER
+ state_fio->StateUint64(cpustate->total_icount);
+ #endif
+ state_fio->StateInt32(cpustate->icount);
+
+ state_fio->StateUint8(cpustate->seg_prefix);
+ state_fio->StateUint8(cpustate->prefix_seg);
+ state_fio->StateUint32(cpustate->ea);
+ state_fio->StateUint16(cpustate->eo);
+ state_fio->StateUint8(cpustate->ea_seg);
#endif
}
-
-#define STATE_VERSION 4
-
bool I286::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
- state_fio->StateBuffer(opaque, sizeof(cpu_state), 1);
+ //state_fio->StateBuffer(opaque, sizeof(cpu_state), 1);
+ process_state_cpustate(state_fio, loading);
// post process
if(loading) {
void save_state_cpustate(FILEIO* state_fio);
void load_state_cpustate(FILEIO* state_fio);
+ void process_state_cpustate(FILEIO* state_fio, bool loading);
bool process_state(FILEIO* state_fio, bool loading);
// unique function
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;
+ }
+ }
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 "
- int len = strlen(name);
-
- if(!state_fio->StateCheckInt32(len)) {
- return false;
- }
- if(!state_fio->StateCheckBuffer(name, len, 1)) {
- return false;
- }
- if(!device->process_state(state_fio, loading)) {
- return false;
- }
- }
- return true;
-}
#include "../debugger.h"
#endif
-#include "memory.h"
+#include "./memory.h"
// ----------------------------------------------------------------------------
// initialize
pcm = new PCM1BIT(this, emu);
via = new SY6522(this, emu);
- memory = new MEMORY(this, emu);
+ memory = new JR100_MEMORY(this, emu);
// set contexts
event->set_context_cpu(cpu);
event->set_context_sound(pcm);
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::JR_100_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;
+ }
+ }
return true;
}
};
#endif
-class csp_state_utils;
class EMU;
class DEVICE;
class EVENT;
class PCM1BIT;
class SY6522;
-class MEMORY;
+class JR100_MEMORY;
class VM : public VM_TEMPLATE
{
protected:
//EMU* emu;
- //csp_state_utils *state_entry;
// devices
//EVENT* event;
PCM1BIT* pcm;
SY6522* via;
- MEMORY* memory;
+ JR100_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
} \
}
-void MEMORY::initialize()
+void JR100_MEMORY::initialize()
{
// initialize memory
memset(ram, 0, sizeof(ram));
register_frame_event(this);
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void JR100_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
if((addr & 0xf000) == 0xc000) {
switch(addr & 0xfc00) {
wbank[(addr >> 13) & 7][addr & 0x1fff] = data;
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t JR100_MEMORY::read_data8(uint32_t addr)
{
if((addr & 0xf000) == 0xc000) {
switch(addr & 0xfc00) {
return rbank[(addr >> 13) & 7][addr & 0x1fff];
}
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void JR100_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
{
if(id == SIG_MEMORY_VIA_PORT_A) {
key_column = data & 0x0f;
{0xbe, 0x20, 0xba, 0x0d, 0xbd}, // . SPACE : RET -
};
-void MEMORY::event_frame()
+void JR100_MEMORY::event_frame()
{
uint32_t data = 0;
if(key_column < 9) {
d_via->write_signal(SIG_SY6522_PORT_B, ~data, 0x1f);
}
-void MEMORY::draw_screen()
+void JR100_MEMORY::draw_screen()
{
int src = 0x100;
for(int y = 0, yy = 0; y < 24; y++, yy += 8) {
#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_INT32(key_column);
- DECL_STATE_ENTRY_BOOL(cmode);
-
- 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->FputInt32(key_column);
-// state_fio->FputBool(cmode);
-}
-
-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);
-// key_column = state_fio->FgetInt32();
-// cmode = state_fio->FgetBool();
- return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool JR100_MEMORY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ memory bus ]
*/
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _JR100_MEMORY_H_
+#define _JR100_MEMORY_H_
#include "../vm.h"
#include "../../emu.h"
#define SIG_MEMORY_VIA_PORT_A 0
#define SIG_MEMORY_VIA_PORT_B 1
-class MEMORY : public DEVICE
+class JR100_MEMORY : public DEVICE
{
private:
// contexts
scrntype_t palette_pc[2];
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ JR100_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~JR100_MEMORY() {}
// common functions
void initialize();
uint32_t read_data8(uint32_t addr);
void write_signal(int id, uint32_t data, uint32_t mask);
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);
// unique functions
void set_context_via(DEVICE* device)
[ memory mapped i/o ]
*/
-#include "io.h"
+#include "./io.h"
#include "../hd44102.h"
-void IO::write_memory_mapped_io8(uint32_t addr, uint32_t data)
+void JR800_IO::write_memory_mapped_io8(uint32_t addr, uint32_t data)
{
int chip = 0;
}
}
-uint32_t IO::read_memory_mapped_io8(uint32_t addr)
+uint32_t JR800_IO::read_memory_mapped_io8(uint32_t addr)
{
const uint8_t* key_stat = emu->get_key_buffer();
uint8_t data = 0;
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void IO::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- leave_decl_state();
-}
-
-void IO::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);
-}
-
-bool IO::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;
-// }
- return true;
-}
-
-bool IO::process_state(FILEIO* state_fio, bool loading)
+bool JR800_IO::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ memory mapped i/o ]
*/
-#ifndef _IO_H_
-#define _IO_H_
+#ifndef _JR800_IO_H_
+#define _JR800_IO_H_
#include "../vm.h"
#include "../../emu.h"
class HD44102;
-class IO : public DEVICE
+class JR800_IO : public DEVICE
{
private:
HD44102 *d_lcd[8];
public:
- IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ JR800_IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Mapped I/O"));
}
- ~IO() {}
+ ~JR800_IO() {}
// common functions
void write_memory_mapped_io8(uint32_t addr, uint32_t data);
uint32_t read_memory_mapped_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 function
void set_context_lcd(int i, HD44102 *device)
#include "../debugger.h"
#endif
-#include "io.h"
+#include "./io.h"
// ----------------------------------------------------------------------------
// initialize
memory = new MEMORY(this, emu);
pcm = new PCM1BIT(this, emu);
- io = new IO(this, emu);
+ io = new JR800_IO(this, emu);
// set contexts
event->set_context_cpu(cpu);
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::JR_800_HEAD")), csp_logger);
- DECL_STATE_ENTRY_MULTI(void, ram, sizeof(ram));
- 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);
-}
-
-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);
- 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;
+ }
+ }
state_fio->StateBuffer(ram, sizeof(ram), 1);
return true;
}
class MEMORY;
class PCM1BIT;
-class IO;
+class JR800_IO;
class VM : public VM_TEMPLATE
{
MEMORY* memory;
PCM1BIT* pcm;
- IO* io;
+ JR800_IO* io;
uint8_t ram[0x6000];
uint8_t rom[0x8000];
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
state_fio->StateInt32(cblink);
return true;
}
-
-bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
-{
- if(!state_fio->StateCheckUint32(STATE_VERSION)) {
- return false;
- }
- if(!state_fio->StateCheckInt32(this_device_id)) {
- return false;
- }
- state_fio->StateBuffer(vram, sizeof(vram), 1);
- state_fio->StateBuffer(extvram, sizeof(extvram), 1);
- state_fio->StateBuffer(vgarray, sizeof(vgarray), 1);
- state_fio->StateBuffer(palette, sizeof(palette), 1);
- state_fio->StateInt32(vgarray_num);
- state_fio->StateBuffer(bankreg, sizeof(bankreg), 1);
- state_fio->StateInt32(bankreg_num);
- state_fio->StateUint8(hires_mode);
- state_fio->StateUint8(page);
- state_fio->StateUint8(status);
- state_fio->StateInt32(cblink);
- return true;
-}
return true;
}
-bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
-{
- if(!state_fio->StateCheckUint32(STATE_VERSION)) {
- return false;
- }
- if(!state_fio->StateCheckInt32(this_device_id)) {
- return false;
- }
- state_fio->StateUint8(prev);
- state_fio->StateInt32(register_id);
- return true;
-}
}
#endif
-#define STATE_VERSION 4
+#define STATE_VERSION 5
-bool I286::process_state(FILEIO* state_fio, bool loading)
+void I286::process_state_cpustate(FILEIO* state_fio, bool loading)
{
- if(!state_fio->StateCheckUint32(STATE_VERSION)) {
- return false;
+#if defined(HAS_I86) || defined(HAS_I88) || defined(HAS_I186) || defined(HAS_V30)
+ struct i8086_state *cpustate = (struct i8086_state *)opaque;
+
+ state_fio->StateBuffer(&(cpustate->regs.b[0]), 16, 1);
+ state_fio->StateUint32(cpustate->pc);
+ state_fio->StateUint32(cpustate->prevpc);
+ for(int i = 0; i < 4; i++) {
+ state_fio->StateUint32(cpustate->base[i]);
}
- if(!state_fio->StateCheckInt32(this_device_id)) {
- return false;
+ for(int i = 0; i < 4; i++) {
+ state_fio->StateUint16(cpustate->sregs[i]);
}
- state_fio->StateBuffer(opaque, sizeof(cpu_state), 1);
+ state_fio->StateUint16(cpustate->flags);
+ state_fio->StateInt32(cpustate->AuxVal);
+ state_fio->StateInt32(cpustate->OverVal);
+ state_fio->StateInt32(cpustate->SignVal);
+ state_fio->StateInt32(cpustate->ZeroVal);
+ state_fio->StateInt32(cpustate->CarryVal);
+ state_fio->StateInt32(cpustate->DirVal);
+ state_fio->StateUint8(cpustate->ParityVal);
+ state_fio->StateUint8(cpustate->TF);
+ state_fio->StateUint8(cpustate->IF);
+ state_fio->StateUint8(cpustate->MF);
- // post process
- if(loading) {
- cpu_state *cpustate = (cpu_state *)opaque;
- cpustate->pic = d_pic;
- cpustate->program = d_mem;
- cpustate->io = d_io;
-#ifdef I86_PSEUDO_BIOS
- cpustate->bios = d_bios;
-#endif
-#ifdef SINGLE_MODE_DMA
- cpustate->dma = d_dma;
-#endif
-#ifdef USE_DEBUGGER
- cpustate->emu = emu;
- cpustate->debugger = d_debugger;
- cpustate->program_stored = d_mem;
- cpustate->io_stored = d_io;
- cpustate->prev_total_icount = cpustate->total_icount;
-#endif
+ state_fio->StateUint8(cpustate->int_vector);
+ state_fio->StateInt8(cpustate->nmi_state);
+ state_fio->StateInt8(cpustate->irq_state);
+ state_fio->StateInt8(cpustate->test_state);
+ state_fio->StateUint8(cpustate->rep_in_progress);
+ state_fio->StateInt32(cpustate->extra_cycles);
+
+ state_fio->StateInt32(cpustate->halted);
+ state_fio->StateInt32(cpustate->busreq);
+
+ state_fio->StateUint16(cpustate->ip);
+ state_fio->StateUint32(cpustate->sp);
+
+ #ifdef USE_DEBUGGER
+ state_fio->StateUint64(cpustate->total_icount);
+ #endif
+ state_fio->StateInt32(cpustate->icount);
+
+ state_fio->StateUint8(cpustate->seg_prefix);
+ state_fio->StateUint8(cpustate->prefix_seg);
+ state_fio->StateUint32(cpustate->ea);
+ state_fio->StateUint16(cpustate->eo);
+ state_fio->StateUint8(cpustate->ea_seg);
+
+#elif defined(HAS_I286)
+
+ struct i80286_state *cpustate = (struct i80286_state *)opaque;
+
+ state_fio->StateBuffer(&(cpustate->regs.b[0]), 16, 1);
+ state_fio->StateUint32(cpustate->amask);
+ state_fio->StateUint32(cpustate->pc);
+ state_fio->StateUint32(cpustate->prevpc);
+ state_fio->StateUint16(cpustate->flags);
+ state_fio->StateUint16(cpustate->msw);
+ for(int i = 0; i < 4; i++) {
+ state_fio->StateUint32(cpustate->base[i]);
}
- return true;
+ for(int i = 0; i < 4; i++) {
+ state_fio->StateUint16(cpustate->sregs[i]);
+ }
+ for(int i = 0; i < 4; i++) {
+ state_fio->StateUint16(cpustate->limit[i]);
+ }
+ state_fio->StateBuffer(cpustate->rights, 4, 1);
+ for(int i = 0; i < 4; i++) {
+ state_fio->StateBool(cpustate->valid[i]);
+ }
+ state_fio->StateUint32(cpustate->gdtr.base);
+ state_fio->StateUint16(cpustate->gdtr.limit);
+
+ state_fio->StateUint32(cpustate->idtr.base);
+ state_fio->StateUint16(cpustate->idtr.limit);
+
+ state_fio->StateUint16(cpustate->ldtr.sel);
+ state_fio->StateUint32(cpustate->ldtr.base);
+ state_fio->StateUint16(cpustate->ldtr.limit);
+ state_fio->StateUint8(cpustate->ldtr.rights);
+
+ state_fio->StateUint16(cpustate->tr.sel);
+ state_fio->StateUint32(cpustate->tr.base);
+ state_fio->StateUint16(cpustate->tr.limit);
+ state_fio->StateUint8(cpustate->tr.rights);
+
+
+ state_fio->StateInt32(cpustate->AuxVal);
+ state_fio->StateInt32(cpustate->OverVal);
+ state_fio->StateInt32(cpustate->SignVal);
+ state_fio->StateInt32(cpustate->ZeroVal);
+ state_fio->StateInt32(cpustate->CarryVal);
+ state_fio->StateInt32(cpustate->DirVal);
+ state_fio->StateUint8(cpustate->ParityVal);
+ state_fio->StateUint8(cpustate->TF);
+ state_fio->StateUint8(cpustate->IF);
+ state_fio->StateUint8(cpustate->MF);
+
+ state_fio->StateInt8(cpustate->nmi_state);
+ state_fio->StateInt8(cpustate->irq_state);
+ state_fio->StateInt8(cpustate->test_state);
+ state_fio->StateUint8(cpustate->rep_in_progress);
+ state_fio->StateInt32(cpustate->extra_cycles);
+
+ state_fio->StateInt32(cpustate->halted);
+ state_fio->StateInt32(cpustate->busreq);
+ state_fio->StateInt32(cpustate->trap_level);
+ state_fio->StateInt32(cpustate->shutdown);
+
+ #ifdef USE_DEBUGGER
+ state_fio->StateUint64(cpustate->total_icount);
+ #endif
+ state_fio->StateInt32(cpustate->icount);
+
+ state_fio->StateUint8(cpustate->seg_prefix);
+ state_fio->StateUint8(cpustate->prefix_seg);
+ state_fio->StateUint32(cpustate->ea);
+ state_fio->StateUint16(cpustate->eo);
+ state_fio->StateUint8(cpustate->ea_seg);
+#endif
}
bool I286::process_state(FILEIO* state_fio, bool loading)
if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
- state_fio->StateBuffer(opaque, sizeof(cpu_state), 1);
+ //state_fio->StateBuffer(opaque, sizeof(cpu_state), 1);
+ process_state_cpustate(state_fio, loading);
// post process
if(loading) {
}
return true;
}
+
void get_debug_regs_info(_TCHAR *buffer, size_t buffer_len);
int debug_dasm(uint32_t pc, _TCHAR *buffer, size_t buffer_len);
#endif
+ void process_state_cpustate(FILEIO* state_fio, bool loading);
bool process_state(FILEIO* state_fio, bool loading);
// unique function
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;
+ }
+ }
state_fio->StateBuffer(ram, sizeof(ram), 1);
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 "
- int len = strlen(name);
-
- if(!state_fio->StateCheckInt32(len)) {
- return false;
- }
- if(!state_fio->StateCheckBuffer(name, len, 1)) {
- return false;
- }
- if(!device->process_state(state_fio, loading)) {
- return false;
- }
- }
- state_fio->StateBuffer(ram, sizeof(ram), 1);
- return true;
-}
#define USE_SCANLINE
#define USE_SOUND_VOLUME 2
#define USE_DEBUGGER
+#define USE_STATE
#define USE_CPU_I286
#define KEYBOARD_HACK
return true;
}
-bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
-{
- if(!state_fio->StateCheckUint32(STATE_VERSION)) {
- return false;
- }
- if(!state_fio->StateCheckInt32(this_device_id)) {
- return false;
- }
- if(!key_buf->process_state(state_fio, loading)) {
- return false;
- }
-#ifndef KEYBOARD_HACK
- state_fio->StateUint64(send_data);
- state_fio->StateInt32(send_count);
-#endif
- state_fio->StateBool(key_latched);
- state_fio->StateUint8(nmi_reg);
- return true;
-}
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void CMT::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_BOOL(in);
- DECL_STATE_ENTRY_BOOL(out);
- DECL_STATE_ENTRY_BOOL(remote);
- DECL_STATE_ENTRY_BOOL(eot);
- DECL_STATE_ENTRY_UINT8(pout);
- DECL_STATE_ENTRY_BOOL(strobe);
- DECL_STATE_ENTRY_BOOL(busy);
-
- 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->FputBool(in);
-// state_fio->FputBool(out);
-// state_fio->FputBool(remote);
-// state_fio->FputBool(eot);
-// state_fio->FputUint8(pout);
-// state_fio->FputBool(strobe);
-// state_fio->FputBool(busy);
-}
-
-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;
-// }
-// in = state_fio->FgetBool();
-// out = state_fio->FgetBool();
-// remote = state_fio->FgetBool();
-// eot = state_fio->FgetBool();
-// pout = state_fio->FgetUint8();
-// strobe = state_fio->FgetBool();
-// busy = state_fio->FgetBool();
- return true;
-}
-
bool CMT::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 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 function
void set_context_drec(DEVICE* device)
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
- decl_state();
inserted = false;
}
#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::M5_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
{
ssl[0] = ssl[1] = ssl[2] = ssl[3] = 0;
expanded[0] = expanded[1] = expanded[2] = expanded[3] = false;
- set_device_name(_T("Memory Bus"));
+ set_device_name(_T("Memory Bus (ex)"));
}
~MEMORY_EX() {}
#define STATE_VERSION 2
-#include "../../statesub.h"
-
-void CMT::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_BOOL(play);
- DECL_STATE_ENTRY_BOOL(rec);
- DECL_STATE_ENTRY_BOOL(remote);
- DECL_STATE_ENTRY_STRING(rec_file_path, sizeof(rec_file_path));
- DECL_STATE_ENTRY_CMT_RECORDING(fio, rec, rec_file_path);
-
- DECL_STATE_ENTRY_INT32(bufcnt);
- DECL_STATE_ENTRY_1D_ARRAY(buffer, sizeof(buffer));
-
- 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->FputBool(play);
-// state_fio->FputBool(rec);
-// state_fio->FputBool(remote);
-// state_fio->Fwrite(rec_file_path, sizeof(rec_file_path), 1);
-// if(rec && fio->IsOpened()) {
-// int length_tmp = (int)fio->Ftell();
-// fio->Fseek(0, FILEIO_SEEK_SET);
-// state_fio->FputInt32(length_tmp);
-// while(length_tmp != 0) {
-// uint8_t buffer_tmp[1024];
-// int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
-// fio->Fread(buffer_tmp, length_rw, 1);
-// state_fio->Fwrite(buffer_tmp, length_rw, 1);
-// length_tmp -= length_rw;
-// }
-// } else {
-// state_fio->FputInt32(0);
-// }
-// state_fio->FputInt32(bufcnt);
-// state_fio->Fwrite(buffer, sizeof(buffer), 1);
-}
-
-bool CMT::load_state(FILEIO* state_fio)
-{
- release_tape();
-
- 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;
-// }
-// play = state_fio->FgetBool();
-// rec = state_fio->FgetBool();
-// remote = state_fio->FgetBool();
-// state_fio->Fread(rec_file_path, sizeof(rec_file_path), 1);
-// int length_tmp = state_fio->FgetInt32();
-// if(rec) {
-// fio->Fopen(rec_file_path, FILEIO_READ_WRITE_NEW_BINARY);
-// while(length_tmp != 0) {
-// uint8_t buffer_tmp[1024];
-// int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
-// state_fio->Fread(buffer_tmp, length_rw, 1);
-// if(fio->IsOpened()) {
-// fio->Fwrite(buffer_tmp, length_rw, 1);
-// }
-// length_tmp -= length_rw;
-// }
-// }
-// bufcnt = state_fio->FgetInt32();
-// state_fio->Fread(buffer, sizeof(buffer), 1);
- return true;
-}
-
bool CMT::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void release();
void reset();
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 play_tape(const _TCHAR* file_path);
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void DISPLAY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(pal, sizeof(pal));
- DECL_STATE_ENTRY_BOOL(text_wide);
- DECL_STATE_ENTRY_BOOL(text_color);
- DECL_STATE_ENTRY_UINT8(graph_color);
- DECL_STATE_ENTRY_UINT8(graph_page);
- DECL_STATE_ENTRY_UINT16(cursor);
- DECL_STATE_ENTRY_UINT16(cblink);
- DECL_STATE_ENTRY_BOOL(hsync);
- DECL_STATE_ENTRY_BOOL(vsync);
- DECL_STATE_ENTRY_BOOL(display);
- DECL_STATE_ENTRY_BOOL(blink);
-
- leave_decl_state();
-}
-
-void DISPLAY::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(pal, sizeof(pal), 1);
-// state_fio->FputBool(text_wide);
-// state_fio->FputBool(text_color);
-// state_fio->FputUint8(graph_color);
-// state_fio->FputUint8(graph_page);
-// state_fio->FputUint16(cursor);
-// state_fio->FputUint16(cblink);
-// state_fio->FputBool(hsync);
-// state_fio->FputBool(vsync);
-// state_fio->FputBool(display);
-// state_fio->FputBool(blink);
-}
-
-bool DISPLAY::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(pal, sizeof(pal), 1);
-// text_wide = state_fio->FgetBool();
-// text_color = state_fio->FgetBool();
-// graph_color = state_fio->FgetUint8();
-// graph_page = state_fio->FgetUint8();
-// cursor = state_fio->FgetUint16();
-// cblink = state_fio->FgetUint16();
-// hsync = state_fio->FgetBool();
-// vsync = state_fio->FgetBool();
-// display = state_fio->FgetBool();
-// blink = state_fio->FgetBool();
- return true;
-}
-
bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
uint32_t read_io8(uint32_t addr);
void write_signal(int id, uint32_t data, uint32_t mask);
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);
// unique functions
void set_vram_ptr(uint8_t* ptr)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void FLOPPY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_BOOL(drq);
-
- leave_decl_state();
-}
-void FLOPPY::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->FputBool(drq);
-}
-
-bool FLOPPY::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;
-// }
-// drq = state_fio->FgetBool();
- return true;
-}
-
bool FLOPPY::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 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 function
void set_context_fdc(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void KANJI::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT32(ptr);
-
- leave_decl_state();
-}
-
-void KANJI::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-
-// state_fio->FputUint32(ptr);
-}
-
-bool KANJI::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;
-// }
-// ptr = state_fio->FgetUint32();
- return true;
-}
-
bool KANJI::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 function
void set_context_pio(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void KEYBOARD::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_INT32(init);
- DECL_STATE_ENTRY_UINT8(code);
- DECL_STATE_ENTRY_UINT8(code_prev);
- DECL_STATE_ENTRY_UINT8(stat);
- DECL_STATE_ENTRY_BOOL(caps);
- DECL_STATE_ENTRY_BOOL(caps_prev);
- DECL_STATE_ENTRY_BOOL(graph);
- DECL_STATE_ENTRY_BOOL(graph_prev);
- DECL_STATE_ENTRY_BOOL(kana);
- DECL_STATE_ENTRY_BOOL(kana_prev);
-
- 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);
-
-// state_fio->FputInt32(init);
-// state_fio->FputUint8(code);
-// state_fio->FputUint8(code_prev);
-// state_fio->FputUint8(stat);
-// state_fio->FputBool(caps);
-// state_fio->FputBool(caps_prev);
-// state_fio->FputBool(graph);
-// state_fio->FputBool(graph_prev);
-// state_fio->FputBool(kana);
-// state_fio->FputBool(kana_prev);
-}
-
-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;
-// }
-// init = state_fio->FgetInt32();
-// code = state_fio->FgetUint8();
-// code_prev = state_fio->FgetUint8();
-// stat = state_fio->FgetUint8();
-// caps = state_fio->FgetBool();
-// caps_prev = state_fio->FgetBool();
-// graph = state_fio->FgetBool();
-// graph_prev = state_fio->FgetBool();
-// kana = state_fio->FgetBool();
-// kana_prev = state_fio->FgetBool();
- return true;
-}
-
bool KEYBOARD::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);
// unique functions
bool get_caps_locked()
} \
}
-void MEMORY::initialize()
+void MULTI8_MEMORY::initialize()
{
// init memory
memset(rom, 0xff, sizeof(rom));
delete fio;
}
-void MEMORY::reset()
+void MULTI8_MEMORY::reset()
{
map1 = 0xf;
map2 = 0;
update_map();
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void MULTI8_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
addr &= 0xffff;
if((addr & 0xc000) == 0x8000 && (map1 & 0x10)) {
wbank[addr >> 12][addr & 0xfff] = data;
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t MULTI8_MEMORY::read_data8(uint32_t addr)
{
addr &= 0xffff;
if((addr & 0xc000) == 0x8000 && (map1 & 0x10)) {
return rbank[addr >> 12][addr & 0xfff];
}
-void MEMORY::write_io8(uint32_t addr, uint32_t data)
+void MULTI8_MEMORY::write_io8(uint32_t addr, uint32_t data)
{
map2 = data;
update_map();
}
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void MULTI8_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
{
if(id == SIG_MEMORY_I8255_C) {
map1 = data & mask;
}
}
-void MEMORY::update_map()
+void MULTI8_MEMORY::update_map()
{
if(map1 & 0x20) {
SET_BANK(0x0000, 0x7fff, ram0, ram0);
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void MEMORY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram0, sizeof(ram0));
- DECL_STATE_ENTRY_1D_ARRAY(ram1, sizeof(ram1));
- DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
- DECL_STATE_ENTRY_UINT8(map1);
- DECL_STATE_ENTRY_UINT8(map2);
-
- 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(ram0, sizeof(ram0), 1);
-// state_fio->Fwrite(ram1, sizeof(ram1), 1);
-// state_fio->Fwrite(vram, sizeof(vram), 1);
-// state_fio->FputUint8(map1);
-// state_fio->FputUint8(map2);
-}
-
-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(ram0, sizeof(ram0), 1);
-// state_fio->Fread(ram1, sizeof(ram1), 1);
-// state_fio->Fread(vram, sizeof(vram), 1);
-// map1 = state_fio->FgetUint8();
-// map2 = state_fio->FgetUint8();
-
- // post process
- update_map();
- return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool MULTI8_MEMORY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
#define SIG_MEMORY_I8255_C 0
-class MEMORY : public DEVICE
+class MULTI8_MEMORY : public DEVICE
{
private:
DEVICE* d_pio;
uint8_t map1, map2;
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ MULTI8_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~MULTI8_MEMORY() {}
// common functions
void initialize();
uint32_t read_data8(uint32_t addr);
void write_io8(uint32_t addr, uint32_t data);
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_pio(DEVICE* device)
#include "floppy.h"
#include "kanji.h"
#include "keyboard.h"
-#include "memory.h"
+#include "./memory.h"
// ----------------------------------------------------------------------------
// initialize
floppy = new FLOPPY(this, emu);
kanji = new KANJI(this, emu);
key = new KEYBOARD(this, emu);
- memory = new MEMORY(this, emu);
+ memory = new MULTI8_MEMORY(this, emu);
// set contexts
event->set_context_cpu(cpu);
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
- decl_state();
for(int i = 0; i < 4; i++) {
fdc->set_drive_type(i, DRIVE_TYPE_2D);
#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)
-{
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::MULTI8_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 FLOPPY;
class KANJI;
class KEYBOARD;
-class MEMORY;
+class MULTI8_MEMORY;
class VM : public VM_TEMPLATE
{
FLOPPY* floppy;
KANJI* kanji;
KEYBOARD* key;
- MEMORY* memory;
+ MULTI8_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 CMOS::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(data_buffer, DATA_SIZE);
- DECL_STATE_ENTRY_UINT32(data_addr);
- DECL_STATE_ENTRY_BOOL(modified);
-
- leave_decl_state();
-}
-
-void CMOS::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(data_buffer, DATA_SIZE, 1);
-// state_fio->FputUint32(data_addr);
-// state_fio->FputBool(modified);
-}
-
-bool CMOS::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(data_buffer, DATA_SIZE, 1);
-// data_addr = state_fio->FgetUint32();
-// modified = state_fio->FgetBool();
- return true;
-}
-
bool CMOS::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);
};
#endif
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void EMM::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(data_buffer, DATA_SIZE);
- DECL_STATE_ENTRY_UINT32(data_addr);
-
- leave_decl_state();
-}
-
-void EMM::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(data_buffer, DATA_SIZE, 1);
-// state_fio->FputUint32(data_addr);
-}
-
-bool EMM::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(data_buffer, DATA_SIZE, 1);
-// data_addr = state_fio->FgetUint32();
- return true;
-}
-
bool EMM::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);
};
#endif
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void FLOPPY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT32(prev_dc);
- DECL_STATE_ENTRY_INT32(register_id);
- DECL_STATE_ENTRY_BOOL(motor_on);
- DECL_STATE_ENTRY_BOOL(irq_enabled);
-
- leave_decl_state();
-}
-
-void FLOPPY::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->FputUint32(prev_dc);
-// state_fio->FputInt32(register_id);
-// state_fio->FputBool(motor_on);
-// state_fio->FputBool(irq_enabled);
-}
-
-bool FLOPPY::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;
-// }
-// prev_dc = state_fio->FgetUint32();
-// register_id = state_fio->FgetInt32();
-// motor_on = state_fio->FgetBool();
-// irq_enabled = state_fio->FgetBool();
- return true;
-}
-
bool FLOPPY::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 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_cpu(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void KANJI::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT32(control_reg);
- DECL_STATE_ENTRY_UINT32(kanji_addr);
- DECL_STATE_ENTRY_UINT32(dic_addr);
-
- leave_decl_state();
-}
-
-void KANJI::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->FputUint32(control_reg);
-// state_fio->FputUint32(kanji_addr);
-// state_fio->FputUint32(dic_addr);
-}
-
-bool KANJI::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;
-// }
-// control_reg = state_fio->FgetUint32();
-// kanji_addr = state_fio->FgetUint32();
-// dic_addr = state_fio->FgetUint32();
- return true;
-}
-
bool KANJI::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);
};
#endif
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void KEYBOARD::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT8(column);
-
- 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);
-
-// state_fio->FputUint8(column);
-}
-
-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;
-// }
-// column = state_fio->FgetUint8();
- return true;
-}
-
bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void initialize();
void write_signal(int id, uint32_t data, uint32_t mask);
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);
// unique function
void set_context_pio(DEVICE* device)
[ memory ]
*/
-#include "memory.h"
+#include "./memory.h"
#include "../i8253.h"
#include "../i8255.h"
#if defined(_MZ800)
#define EXT_FILE_NAME "EXT.ROM"
#endif
-void MEMORY::initialize()
+void MZ700_MEMORY::initialize()
{
// init memory
memset(ipl, 0xff, sizeof(ipl));
}
-void MEMORY::reset()
+void MZ700_MEMORY::reset()
{
#if defined(_MZ800)
// check dip-switch
}
#if defined(_MZ800)
-void MEMORY::update_config()
+void MZ700_MEMORY::update_config()
{
if(config.monitor_type == 0) {
// color
}
#endif
-void MEMORY::event_vline(int v, int clock)
+void MZ700_MEMORY::event_vline(int v, int clock)
{
// vblank / vsync
set_vblank(v >= 200);
}
}
-void MEMORY::event_callback(int event_id, int err)
+void MZ700_MEMORY::event_callback(int event_id, int err)
{
if(event_id == EVENT_TEMPO) {
// 32KHz
}
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void MZ700_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
addr &= 0xffff;
#if defined(_MZ800)
wbank[addr >> 11][addr & 0x7ff] = data;
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t MZ700_MEMORY::read_data8(uint32_t addr)
{
addr &= 0xffff;
#if defined(_MZ800)
return rbank[addr >> 11][addr & 0x7ff];
}
-void MEMORY::write_data8w(uint32_t addr, uint32_t data, int* wait)
+void MZ700_MEMORY::write_data8w(uint32_t addr, uint32_t data, int* wait)
{
*wait = ((mem_bank & MEM_BANK_MON_L) && addr < 0x1000) ? 1 : 0;
write_data8(addr, data);
}
-uint32_t MEMORY::read_data8w(uint32_t addr, int* wait)
+uint32_t MZ700_MEMORY::read_data8w(uint32_t addr, int* wait)
{
*wait = ((mem_bank & MEM_BANK_MON_L) && addr < 0x1000) ? 1 : 0;
return read_data8(addr);
}
-void MEMORY::write_io8(uint32_t addr, uint32_t data)
+void MZ700_MEMORY::write_io8(uint32_t addr, uint32_t data)
{
switch(addr & 0xff) {
#if defined(_MZ800)
}
#if defined(_MZ800)
-uint32_t MEMORY::read_io8(uint32_t addr)
+uint32_t MZ700_MEMORY::read_io8(uint32_t addr)
{
switch(addr & 0xff) {
case 0xce:
}
#endif
-void MEMORY::set_vblank(bool val)
+void MZ700_MEMORY::set_vblank(bool val)
{
if(vblank != val) {
// VBLANK -> 8255:PC7
}
}
-void MEMORY::set_hblank(bool val)
+void MZ700_MEMORY::set_hblank(bool val)
{
if(hblank != val) {
hblank = val;
}
}
-void MEMORY::update_map_low()
+void MZ700_MEMORY::update_map_low()
{
if(mem_bank & MEM_BANK_MON_L) {
SET_BANK(0x0000, 0x0fff, wdmy, ipl);
}
}
-void MEMORY::update_map_middle()
+void MZ700_MEMORY::update_map_middle()
{
#if defined(_MZ800)
if(MZ700_MODE) {
#endif
}
-void MEMORY::update_map_high()
+void MZ700_MEMORY::update_map_high()
{
#if defined(_MZ800)
// MZ-800
}
#if defined(_MZ800)
-int MEMORY::vram_page_mask(uint8_t f)
+int MZ700_MEMORY::vram_page_mask(uint8_t f)
{
switch(dmd & 7) {
case 0: // 320x200,4col
return 0;
}
-int MEMORY::vram_addr(int addr)
+int MZ700_MEMORY::vram_addr(int addr)
{
if(dmd & 4) {
// 640x200
#endif
#if defined(_MZ700) || defined(_MZ1500)
-void MEMORY::draw_line(int v)
+void MZ700_MEMORY::draw_line(int v)
{
int ptr = 40 * (v >> 3);
#if defined(_MZ700)
}
}
-void MEMORY::draw_screen()
+void MZ700_MEMORY::draw_screen()
{
// copy to real screen
emu->set_vm_screen_lines(200);
emu->screen_skip_line(true);
}
#else
-void MEMORY::draw_line_320x200_2bpp(int v)
+void MZ700_MEMORY::draw_line_320x200_2bpp(int v)
{
int ofs1 = (dmd & 1) ? 0x4000 : 0;
int ofs2 = ofs1 | 0x2000;
}
}
-void MEMORY::draw_line_320x200_4bpp(int v)
+void MZ700_MEMORY::draw_line_320x200_4bpp(int v)
{
int ptr = 40 * v;
}
}
-void MEMORY::draw_line_640x200_1bpp(int v)
+void MZ700_MEMORY::draw_line_640x200_1bpp(int v)
{
int ofs = (dmd & 1) ? 0x4000 : 0;
int ptr = 80 * v;
}
}
-void MEMORY::draw_line_640x200_2bpp(int v)
+void MZ700_MEMORY::draw_line_640x200_2bpp(int v)
{
int ptr = 80 * v;
}
}
-void MEMORY::draw_line_mz700(int v)
+void MZ700_MEMORY::draw_line_mz700(int v)
{
int ptr = (40 * (v >> 3)) | 0x3000;
}
}
-void MEMORY::draw_screen()
+void MZ700_MEMORY::draw_screen()
{
// copy to real screen
emu->set_vm_screen_lines(200);
#define STATE_VERSION 2
-#include "../../statesub.h"
-
-void MEMORY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
-#if defined(_MZ700)
- DECL_STATE_ENTRY_1D_ARRAY(&(pcg[0x400]), 0x400);
- DECL_STATE_ENTRY_1D_ARRAY(&(pcg[0xc00]), 0x400);
-#elif defined(_MZ1500)
- DECL_STATE_ENTRY_1D_ARRAY(pcg, sizeof(pcg));
-#endif
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
- DECL_STATE_ENTRY_UINT8(mem_bank);
-#if defined(_MZ700)
- DECL_STATE_ENTRY_UINT8(pcg_data);
- DECL_STATE_ENTRY_UINT8(pcg_addr);
- DECL_STATE_ENTRY_UINT8(pcg_ctrl);
-#elif defined(_MZ800)
- DECL_STATE_ENTRY_UINT8(wf);
- DECL_STATE_ENTRY_UINT8(rf);
- DECL_STATE_ENTRY_UINT8(dmd);
- DECL_STATE_ENTRY_UINT32(vram_addr_top);
- DECL_STATE_ENTRY_BOOL(is_mz800);
-#elif defined(_MZ1500)
- DECL_STATE_ENTRY_UINT8(pcg_bank);
-#endif
-#if defined(_MZ800)
- DECL_STATE_ENTRY_UINT16(sof);
- DECL_STATE_ENTRY_UINT8(sw);
- DECL_STATE_ENTRY_UINT8(ssa);
- DECL_STATE_ENTRY_UINT8(sea);
- DECL_STATE_ENTRY_UINT8(palette_sw);
- DECL_STATE_ENTRY_1D_ARRAY(palette, sizeof(palette));
- DECL_STATE_ENTRY_1D_ARRAY(palette16, sizeof(palette16));
-#elif defined(_MZ1500)
- DECL_STATE_ENTRY_UINT8(priority);
- DECL_STATE_ENTRY_1D_ARRAY(palette, sizeof(palette));
-#endif
- DECL_STATE_ENTRY_BOOL(blink);
- DECL_STATE_ENTRY_BOOL(tempo);
- DECL_STATE_ENTRY_BOOL(hblank);
- DECL_STATE_ENTRY_BOOL(hsync);
- DECL_STATE_ENTRY_BOOL(vblank);
- DECL_STATE_ENTRY_BOOL(vsync);
-#if defined(_MZ700) || defined(_MZ1500)
- DECL_STATE_ENTRY_BOOL(hblank_vram);
-#endif
-#if defined(_MZ1500)
- DECL_STATE_ENTRY_BOOL(hblank_pcg);
-#endif
-#if defined(_MZ800)
- DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette_mz800_pc, sizeof(palette_mz800_pc) / sizeof(scrntype_t));
-#endif
- DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette_pc, sizeof(palette_pc) / sizeof(scrntype_t));
-
- 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);
-
-//#if defined(_MZ700)
-// state_fio->Fwrite(pcg + 0x400, 0x400, 1);
-// state_fio->Fwrite(pcg + 0xc00, 0x400, 1);
-//#elif defined(_MZ1500)
-// state_fio->Fwrite(pcg, sizeof(pcg), 1);
-//#endif
-// state_fio->Fwrite(ram, sizeof(ram), 1);
-// state_fio->Fwrite(vram, sizeof(vram), 1);
-// state_fio->FputUint8(mem_bank);
-//#if defined(_MZ700)
-// state_fio->FputUint8(pcg_data);
-// state_fio->FputUint8(pcg_addr);
-// state_fio->FputUint8(pcg_ctrl);
-//#elif defined(_MZ800)
-// state_fio->FputUint8(wf);
-// state_fio->FputUint8(rf);
-// state_fio->FputUint8(dmd);
-// state_fio->FputUint32(vram_addr_top);
-// state_fio->FputBool(is_mz800);
-//#elif defined(_MZ1500)
-// state_fio->FputUint8(pcg_bank);
-//#endif
-//#if defined(_MZ800)
-// state_fio->FputUint16(sof);
-// state_fio->FputUint8(sw);
-// state_fio->FputUint8(ssa);
-// state_fio->FputUint8(sea);
-// state_fio->FputUint8(palette_sw);
-// state_fio->Fwrite(palette, sizeof(palette), 1);
-// state_fio->Fwrite(palette16, sizeof(palette16), 1);
-//#elif defined(_MZ1500)
-// state_fio->FputUint8(priority);
-// state_fio->Fwrite(palette, sizeof(palette), 1);
-//#endif
-// state_fio->FputBool(blink);
-// state_fio->FputBool(tempo);
-// state_fio->FputBool(hblank);
-// state_fio->FputBool(hsync);
-// state_fio->FputBool(vblank);
-// state_fio->FputBool(vsync);
-//#if defined(_MZ700) || defined(_MZ1500)
-// state_fio->FputBool(hblank_vram);
-//#endif
-//#if defined(_MZ1500)
-// state_fio->FputBool(hblank_pcg);
-//#endif
-//#if defined(_MZ800)
-// state_fio->Fwrite(palette_mz800_pc, sizeof(palette_mz800_pc), 1);
-//#endif
-// state_fio->Fwrite(palette_pc, sizeof(palette_pc), 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;
-// }
-//#if defined(_MZ700)
-// state_fio->Fread(pcg + 0x400, 0x400, 1);
-// state_fio->Fread(pcg + 0xc00, 0x400, 1);
-//#elif defined(_MZ1500)
-// state_fio->Fread(pcg, sizeof(pcg), 1);
-//#endif
-// state_fio->Fread(ram, sizeof(ram), 1);
-// state_fio->Fread(vram, sizeof(vram), 1);
-// mem_bank = state_fio->FgetUint8();
-//#if defined(_MZ700)
-// pcg_data = state_fio->FgetUint8();
-// pcg_addr = state_fio->FgetUint8();
-// pcg_ctrl = state_fio->FgetUint8();
-//#elif defined(_MZ800)
-// wf = state_fio->FgetUint8();
-// rf = state_fio->FgetUint8();
-// dmd = state_fio->FgetUint8();
-// vram_addr_top = state_fio->FgetUint32();
-// is_mz800 = state_fio->FgetBool();
-//#elif defined(_MZ1500)
-// pcg_bank = state_fio->FgetUint8();
-//#endif
-//#if defined(_MZ800)
-// sof = state_fio->FgetUint16();
-// sw = state_fio->FgetUint8();
-// ssa = state_fio->FgetUint8();
-// sea = state_fio->FgetUint8();
-// palette_sw = state_fio->FgetUint8();
-// state_fio->Fread(palette, sizeof(palette), 1);
-// state_fio->Fread(palette16, sizeof(palette16), 1);
-//#elif defined(_MZ1500)
-// priority = state_fio->FgetUint8();
-// state_fio->Fread(palette, sizeof(palette), 1);
-//#endif
-// blink = state_fio->FgetBool();
-// tempo = state_fio->FgetBool();
-// hblank = state_fio->FgetBool();
-// hsync = state_fio->FgetBool();
-// vblank = state_fio->FgetBool();
-// vsync = state_fio->FgetBool();
-//#if defined(_MZ700) || defined(_MZ1500)
-// hblank_vram = state_fio->FgetBool();
-//#endif
-//#if defined(_MZ1500)
-// hblank_pcg = state_fio->FgetBool();
-//#endif
-//#if defined(_MZ800)
-// state_fio->Fread(palette_mz800_pc, sizeof(palette_mz800_pc), 1);
-//#endif
-// state_fio->Fread(palette_pc, sizeof(palette_pc), 1);
-
- // post process
- update_map_low();
- update_map_middle();
- update_map_high();
- return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool MZ700_MEMORY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
state_fio->StateBool(hblank_pcg);
#endif
#if defined(_MZ800)
- state_fio->StateBuffer(palette_mz800_pc, sizeof(palette_mz800_pc), 1);
+ //state_fio->StateBuffer(palette_mz800_pc, sizeof(palette_mz800_pc), 1);
+ if(loading) {
+ for(int i = 0; i < (sizeof(palette_mz800_pc) / sizeof(scrntype_t)); i++) {
+ uint8_t r, g, b;
+ r = state_fio->FgetUint8();
+ g = state_fio->FgetUint8();
+ b = state_fio->FgetUint8();
+ palette_mz800_pc[i] = RGB_COLOR(r, g, b);
+ }
+ } else {
+ for(int i = 0; i < (sizeof(palette_mz800_pc) / sizeof(scrntype_t)); i++) {
+ uint8_t r, g, b;
+ r = R_OF_COLOR(palette_mz800_pc[i]);
+ g = G_OF_COLOR(palette_mz800_pc[i]);
+ b = B_OF_COLOR(palette_mz800_pc[i]);
+ state_fio->FputUint8(r);
+ state_fio->FputUint8(g);
+ state_fio->FputUint8(b);
+ }
+ }
#endif
- state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
+ //state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
+ if(loading) {
+ for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
+ uint8_t r, g, b;
+ r = state_fio->FgetUint8();
+ g = state_fio->FgetUint8();
+ b = state_fio->FgetUint8();
+ palette_pc[i] = RGB_COLOR(r, g, b);
+ }
+ } else {
+ for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
+ uint8_t r, g, b;
+ r = R_OF_COLOR(palette_pc[i]);
+ g = G_OF_COLOR(palette_pc[i]);
+ b = B_OF_COLOR(palette_pc[i]);
+ state_fio->FputUint8(r);
+ state_fio->FputUint8(g);
+ state_fio->FputUint8(b);
+ }
+ }
// post process
if(loading) {
[ memory ]
*/
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _MZ700_MEMORY_H_
+#define _MZ700_MEMORY_H_
#include "../vm.h"
#include "../../emu.h"
class DISPLAY;
#endif
-class MEMORY : public DEVICE
+class MZ700_MEMORY : public DEVICE
{
private:
DEVICE *d_cpu, *d_pit, *d_pio;
#endif
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ MZ700_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~MZ700_MEMORY() {}
// common functions
void initialize();
#if defined(_MZ800)
uint32_t read_io8(uint32_t addr);
#endif
- 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)
#include "emm.h"
#include "kanji.h"
#include "keyboard.h"
-#include "memory.h"
+#include "./memory.h"
#include "ramfile.h"
#if defined(_MZ800) || defined(_MZ1500)
emm = new EMM(this, emu);
kanji = new KANJI(this, emu);
keyboard = new KEYBOARD(this, emu);
- memory = new MEMORY(this, emu);
+ memory = new MZ700_MEMORY(this, emu);
ramfile = new RAMFILE(this, emu);
#if defined(_MZ800) || defined(_MZ1500)
// }
}
#endif
- 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::MZ700_SERIES_HEAD")), csp_logger);
-#if defined(_MZ800)
- DECL_STATE_ENTRY_INT32(boot_mode);
-#endif
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->decl_state();
- }
-}
-
-void VM::save_state(FILEIO* state_fio)
-{
- 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)
-{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- printf("INFO: HEADER DATA ERROR\n");
- return false;
- }
- for(DEVICE* device = first_device; device; device = device->next_device) {
- if(!device->load_state(state_fio)) {
- printf("INFO: DATA ERROR at DEVID=%d\n", device->this_device_id);
- 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;
+ }
+ }
#if defined(_MZ800)
state_fio->StateInt32(boot_mode);
#endif
class EMM;
class KANJI;
class KEYBOARD;
-class MEMORY;
+class MZ700_MEMORY;
class RAMFILE;
#if defined(_MZ800) || defined(_MZ1500)
EMM* emm;
KANJI* kanji;
KEYBOARD* keyboard;
- MEMORY* memory;
+ MZ700_MEMORY* memory;
RAMFILE* ramfile;
#if defined(_MZ800) || defined(_MZ1500)
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 QUICKDISK::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_STRING(file_path, sizeof(file_path) / sizeof(_TCHAR));
- DECL_STATE_ENTRY_BOOL(insert);
- DECL_STATE_ENTRY_BOOL(protect);
- DECL_STATE_ENTRY_BOOL(home);
- DECL_STATE_ENTRY_BOOL(modified);
- DECL_STATE_ENTRY_BOOL(accessed);
- DECL_STATE_ENTRY_1D_ARRAY(buffer, sizeof(buffer) / sizeof(uint16_t));
- DECL_STATE_ENTRY_INT32(buffer_ptr);
- DECL_STATE_ENTRY_INT32(write_ptr);
- DECL_STATE_ENTRY_BOOL(first_data);
- DECL_STATE_ENTRY_BOOL(send_break);
- DECL_STATE_ENTRY_BOOL(wrga);
- DECL_STATE_ENTRY_BOOL(mton);
- DECL_STATE_ENTRY_BOOL(sync);
- DECL_STATE_ENTRY_BOOL(motor_on);
- DECL_STATE_ENTRY_INT32(restore_id);
- DECL_STATE_ENTRY_INT32(end_id);
-
- leave_decl_state();
-}
-
-void QUICKDISK::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(file_path, sizeof(file_path), 1);
-// state_fio->FputBool(insert);
-// state_fio->FputBool(protect);
-// state_fio->FputBool(home);
-// state_fio->FputBool(modified);
-// state_fio->FputBool(accessed);
-// state_fio->Fwrite(buffer, sizeof(buffer), 1);
-// state_fio->FputInt32(buffer_ptr);
-// state_fio->FputInt32(write_ptr);
-// state_fio->FputBool(first_data);
-// state_fio->FputBool(send_break);
-// state_fio->FputBool(wrga);
-// state_fio->FputBool(mton);
-// state_fio->FputBool(sync);
-// state_fio->FputBool(motor_on);
-// state_fio->FputInt32(restore_id);
-// state_fio->FputInt32(end_id);
-}
-
-bool QUICKDISK::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(file_path, sizeof(file_path), 1);
-// insert = state_fio->FgetBool();
-// protect = state_fio->FgetBool();
-// home = state_fio->FgetBool();
-// modified = state_fio->FgetBool();
-// accessed = state_fio->FgetBool();
-// state_fio->Fread(buffer, sizeof(buffer), 1);
-// buffer_ptr = state_fio->FgetInt32();
-// write_ptr = state_fio->FgetInt32();
-// first_data = state_fio->FgetBool();
-// send_break = state_fio->FgetBool();
-// wrga = state_fio->FgetBool();
-// mton = state_fio->FgetBool();
-// sync = state_fio->FgetBool();
-// motor_on = state_fio->FgetBool();
-// restore_id = state_fio->FgetInt32();
-// end_id = state_fio->FgetInt32();
- return true;
-}
-
bool QUICKDISK::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
state_fio->StateBool(home);
state_fio->StateBool(modified);
state_fio->StateBool(accessed);
- state_fio->StateBuffer(buffer, sizeof(buffer), 1);
+ //state_fio->StateBuffer(buffer, sizeof(buffer), 1);
+ for(int i = 0; i < QUICKDISK_BUFFER_SIZE; i++) {
+ state_fio->StateUint16(buffer[i]);
+ }
state_fio->StateInt32(buffer_ptr);
state_fio->StateInt32(write_ptr);
state_fio->StateBool(first_data);
void write_signal(int id, uint32_t data, uint32_t mask);
uint32_t read_signal(int ch);
void event_callback(int event_id, int err);
- 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_sio(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void RAMFILE::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(data_buffer, DATA_SIZE);
- DECL_STATE_ENTRY_UINT32(data_addr);
-
- leave_decl_state();
-}
-
-void RAMFILE::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(data_buffer, DATA_SIZE, 1);
-// state_fio->FputUint32(data_addr);
-}
-
-bool RAMFILE::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(data_buffer, DATA_SIZE, 1);
-// data_addr = state_fio->FgetUint32();
- return true;
-}
-
bool RAMFILE::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);
};
#endif
#define STATE_VERSION 2
-#include "../../statesub.h"
-
-void KEYBOARD::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT8(column);
- DECL_STATE_ENTRY_BOOL(kana);
-
- 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);
-
-// state_fio->FputUint8(column);
-// state_fio->FputBool(kana);
-}
-
-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;
-// }
-// column = state_fio->FgetUint8();
-// kana = state_fio->FgetBool();
- return true;
-}
-
bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void initialize();
void write_signal(int id, uint32_t data, uint32_t mask);
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);
// unique functions
void set_context_pio(DEVICE* device)
[ memory ]
*/
-#include "memory.h"
+#include "./memory.h"
#include "../i8253.h"
#include "../i8255.h"
} \
}
-void MEMORY::initialize()
+void MZ80A_MEMORY::initialize()
{
// init memory
memset(ram, 0, sizeof(ram));
register_event_by_clock(this, EVENT_BLINK, CPU_CLOCKS / 3, true, NULL); // 1.5hz * 2
}
-void MEMORY::reset()
+void MZ80A_MEMORY::reset()
{
#if defined(_MZ1200) || defined(_MZ80A)
// reset memory swap
d_pio->write_signal(SIG_I8255_PORT_C, 0xff, 0x10);
}
-void MEMORY::event_vline(int v, int clock)
+void MZ80A_MEMORY::event_vline(int v, int clock)
{
// draw one line
if(0 <= v && v < 200) {
#endif
}
-void MEMORY::event_callback(int event_id, int err)
+void MZ80A_MEMORY::event_callback(int event_id, int err)
{
if(event_id == EVENT_TEMPO) {
// 32khz
}
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void MZ80A_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
addr &= 0xffff;
if(0xe000 <= addr && addr <= 0xe7ff) {
wbank[addr >> 10][addr & 0x3ff] = data;
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t MZ80A_MEMORY::read_data8(uint32_t addr)
{
addr &= 0xffff;
if(0xe000 <= addr && addr <= 0xe7ff) {
}
#if defined(_MZ1200) || defined(_MZ80A)
-void MEMORY::update_memory_swap()
+void MZ80A_MEMORY::update_memory_swap()
{
if(memory_swap) {
SET_BANK(0x0000, 0x0fff, ram + 0xc000, ram + 0xc000);
#endif
#if defined(SUPPORT_MZ80AIF)
-void MEMORY::update_fdif_rom_bank()
+void MZ80A_MEMORY::update_fdif_rom_bank()
{
// FD IF ROM BANK switching
if(fdc_drq) {
}
#endif
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void MZ80A_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
{
bool signal = ((data & mask) != 0);
}
#if defined(_MZ80K)
-void MEMORY::update_config()
+void MZ80A_MEMORY::update_config()
{
if(config.monitor_type) {
palette_pc[1] = RGB_COLOR(0, 255, 0);
}
#endif
-void MEMORY::draw_screen()
+void MZ80A_MEMORY::draw_screen()
{
// copy to real screen
emu->set_vm_screen_lines(200);
#define STATE_VERSION 3
-#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_BOOL(tempo);
- DECL_STATE_ENTRY_BOOL(blink);
-#if defined(_MZ1200) || defined(_MZ80A)
- DECL_STATE_ENTRY_BOOL(hblank);
- DECL_STATE_ENTRY_BOOL(memory_swap);
-#endif
-#if defined(SUPPORT_MZ80AIF)
- DECL_STATE_ENTRY_BOOL(fdc_irq);
- DECL_STATE_ENTRY_BOOL(fdc_drq);
-#endif
- DECL_STATE_ENTRY_BOOL(vgate);
-#if defined(_MZ1200) || defined(_MZ80A)
- DECL_STATE_ENTRY_BOOL(reverse);
-#endif
-#if defined(_MZ80A)
- DECL_STATE_ENTRY_UINT32(e200);
-#endif
- DECL_STATE_ENTRY_1D_ARRAY(&(pcg[0x400]), 0x400);
-#if defined(_MZ1200)
- DECL_STATE_ENTRY_1D_ARRAY(&(pcg[0xc00]), 0x400);
-#endif
- DECL_STATE_ENTRY_UINT8(pcg_data);
- DECL_STATE_ENTRY_UINT8(pcg_addr);
- DECL_STATE_ENTRY_UINT8(pcg_ctrl);
-
- 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->FputBool(tempo);
-// state_fio->FputBool(blink);
-//#if defined(_MZ1200) || defined(_MZ80A)
-// state_fio->FputBool(hblank);
-// state_fio->FputBool(memory_swap);
-//#endif
-//#if defined(SUPPORT_MZ80AIF)
-// state_fio->FputBool(fdc_irq);
-// state_fio->FputBool(fdc_drq);
-//#endif
-// vgate = state_fio->FgetBool();
-//#if defined(_MZ1200) || defined(_MZ80A)
-// reverse = state_fio->FgetBool();
-//#endif
-//#if defined(_MZ80A)
-// state_fio->FputUint32(e200);
-//#endif
-// state_fio->Fwrite(pcg + 0x400, 0x400, 1);
-//#if defined(_MZ1200)
-// state_fio->Fwrite(pcg + 0xc00, 0x400, 1);
-//#endif
-// state_fio->FputUint8(pcg_data);
-// state_fio->FputUint8(pcg_addr);
-// state_fio->FputUint8(pcg_ctrl);
-}
-
-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);
-// tempo = state_fio->FgetBool();
-// blink = state_fio->FgetBool();
-//#if defined(_MZ1200) || defined(_MZ80A)
-// hblank = state_fio->FgetBool();
-// memory_swap = state_fio->FgetBool();
-//#endif
-//#if defined(SUPPORT_MZ80AIF)
-// fdc_irq = state_fio->FgetBool();
-// fdc_drq = state_fio->FgetBool();
-//#endif
-// state_fio->FputBool(vgate);
-//#if defined(_MZ1200) || defined(_MZ80A)
-// state_fio->FputBool(reverse);
-//#endif
-//#if defined(_MZ80A)
-// e200 = state_fio->FgetUint32();
-//#endif
-// state_fio->Fread(pcg + 0x400, 0x400, 1);
-//#if defined(_MZ1200)
-// state_fio->Fread(pcg + 0xc00, 0x400, 1);
-//#endif
-// pcg_data = state_fio->FgetUint8();
-// pcg_addr = state_fio->FgetUint8();
-// pcg_ctrl = state_fio->FgetUint8();
-
- // post process
-#if defined(_MZ1200) || defined(_MZ80A)
- update_memory_swap();
-#endif
-#if defined(SUPPORT_MZ80AIF)
- update_fdif_rom_bank();
-#endif
- return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool MZ80A_MEMORY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ memory ]
*/
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _MZ80A_MEMORY_H_
+#define _MZ80A_MEMORY_H_
#include "../vm.h"
#include "../../emu.h"
#define SIG_MEMORY_FDC_DRQ 2
#endif
-class MEMORY : public DEVICE
+class MZ80A_MEMORY : public DEVICE
{
private:
DEVICE *d_ctc, *d_pio;
uint8_t pcg_ctrl;
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ MZ80A_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~MZ80A_MEMORY() {}
// common functions
void initialize();
#if defined(_MZ80K)
void update_config();
#endif
- 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_ctc(DEVICE* device)
counter->set_device_name(_T("74LS393 Counter (CTC/Sound)"));
keyboard = new KEYBOARD(this, emu);
- memory = new MEMORY(this, emu);
+ memory = new MZ80A_MEMORY(this, emu);
printer = new PRINTER(this, emu);
#if defined(SUPPORT_MZ80AIF)
io = new IO(this, emu);
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
- decl_state();
}
VM::~VM()
#define STATE_VERSION 7
-#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::MZ80_SERIES_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)
-{
- 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;
- //}
- 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;
+ }
+ }
return true;
}
class Z80;
class KEYBOARD;
-class MEMORY;
+class MZ80A_MEMORY;
class PRINTER;
#if defined(SUPPORT_MZ80AIF)
Z80* cpu;
KEYBOARD* keyboard;
- MEMORY* memory;
+ MZ80A_MEMORY* memory;
PRINTER* printer;
#if defined(SUPPORT_MZ80AIF)
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
#if defined(_MZ1200) || defined(_MZ80K)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void PRINTER::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT8(out_ch);
-
- 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_ch);
-}
-
-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_ch = state_fio->FgetUint8();
- return true;
-}
-#endif
-
bool PRINTER::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
state_fio->StateUint8(out_ch);
return true;
}
+#endif
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
#if defined(_MZ1200) || defined(_MZ80K)
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
#endif
// unique function