#define STATE_VERSION 3
-#include "../../statesub.h"
-
-void KEYBOARD::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_FIFO(key_buf);
- DECL_STATE_ENTRY_INT32(phase);
- DECL_STATE_ENTRY_UINT16(send_data);
- DECL_STATE_ENTRY_UINT32(stc_clock);
- DECL_STATE_ENTRY_UINT8(recv_data);
- DECL_STATE_ENTRY_BOOL(recv_ok);
- DECL_STATE_ENTRY_BOOL(stc);
- DECL_STATE_ENTRY_BOOL(dc);
- DECL_STATE_ENTRY_BOOL(caps);
- DECL_STATE_ENTRY_BOOL(kana);
- DECL_STATE_ENTRY_BOOL(pro_mode);
-
- 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);
-
-// key_buf->save_state((void *)state_fio);
-// state_fio->FputInt32(phase);
-// state_fio->FputUint16(send_data);
-// state_fio->FputUint32(stc_clock);
-// state_fio->FputUint8(recv_data);
-// state_fio->FputBool(recv_ok);
-// state_fio->FputBool(stc);
-// state_fio->FputBool(dc);
-// state_fio->FputBool(caps);
-// state_fio->FputBool(kana);
-// state_fio->FputBool(pro_mode);
-}
-
-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;
-// }
-// if(!key_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// phase = state_fio->FgetInt32();
-// send_data = state_fio->FgetUint16();
-// stc_clock = state_fio->FgetUint32();
-// recv_data = state_fio->FgetUint8();
-// recv_ok = state_fio->FgetBool();
-// stc = state_fio->FgetBool();
-// dc = state_fio->FgetBool();
-// caps = state_fio->FgetBool();
-// kana = state_fio->FgetBool();
-// pro_mode = state_fio->FgetBool();
- return true;
-}
-
bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void write_signal(int id, uint32_t data, uint32_t mask);
void event_callback(int event_id, int err);
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_subcpu(DEVICE* device)
#define STATE_VERSION 2
-#include "../../statesub.h"
-
-void MAIN::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_1D_ARRAY(common, sizeof(common));
- DECL_STATE_ENTRY_UINT8(ma);
- DECL_STATE_ENTRY_UINT8(ms);
- DECL_STATE_ENTRY_UINT8(mo);
- DECL_STATE_ENTRY_BOOL(me1);
- DECL_STATE_ENTRY_BOOL(me2);
- DECL_STATE_ENTRY_UINT8(srqb);
- DECL_STATE_ENTRY_UINT8(sres);
- DECL_STATE_ENTRY_BOOL(sack);
- DECL_STATE_ENTRY_BOOL(srdy);
- DECL_STATE_ENTRY_BOOL(intfd);
- DECL_STATE_ENTRY_BOOL(int0);
- DECL_STATE_ENTRY_BOOL(int1);
- DECL_STATE_ENTRY_BOOL(int2);
- DECL_STATE_ENTRY_BOOL(int3);
- DECL_STATE_ENTRY_BOOL(int4);
- DECL_STATE_ENTRY_BOOL(me);
- DECL_STATE_ENTRY_BOOL(e1);
- DECL_STATE_ENTRY_UINT8(inp);
- DECL_STATE_ENTRY_BOOL(motor);
- DECL_STATE_ENTRY_BOOL(drq);
- DECL_STATE_ENTRY_BOOL(index);
- DECL_STATE_ENTRY_BOOL(crt_400line);
-
- 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->Fwrite(common, sizeof(common), 1);
-// state_fio->FputUint8(ma);
-// state_fio->FputUint8(ms);
-// state_fio->FputUint8(mo);
-// state_fio->FputBool(me1);
-// state_fio->FputBool(me2);
-// state_fio->FputUint8(srqb);
-// state_fio->FputUint8(sres);
-// state_fio->FputBool(sack);
-// state_fio->FputBool(srdy);
-// state_fio->FputBool(intfd);
-// state_fio->FputBool(int0);
-// state_fio->FputBool(int1);
-// state_fio->FputBool(int2);
-// state_fio->FputBool(int3);
-// state_fio->FputBool(int4);
-// state_fio->FputBool(me);
-// state_fio->FputBool(e1);
-// state_fio->FputUint8(inp);
-// state_fio->FputBool(motor);
-// state_fio->FputBool(drq);
-// state_fio->FputBool(index);
-// state_fio->FputBool(crt_400line);
-}
-
-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);
-// state_fio->Fread(common, sizeof(common), 1);
-// ma = state_fio->FgetUint8();
-// ms = state_fio->FgetUint8();
-// mo = state_fio->FgetUint8();
-// me1 = state_fio->FgetBool();
-// me2 = state_fio->FgetBool();
-// srqb = state_fio->FgetUint8();
-// sres = state_fio->FgetUint8();
-// sack = state_fio->FgetBool();
-// srdy = state_fio->FgetBool();
-// intfd = state_fio->FgetBool();
-// int0 = state_fio->FgetBool();
-// int1 = state_fio->FgetBool();
-// int2 = state_fio->FgetBool();
-// int3 = state_fio->FgetBool();
-// int4 = state_fio->FgetBool();
-// me = state_fio->FgetBool();
-// e1 = state_fio->FgetBool();
-// inp = state_fio->FgetUint8();
-// motor = state_fio->FgetBool();
-// drq = state_fio->FgetBool();
-// index = state_fio->FgetBool();
-// crt_400line = state_fio->FgetBool();
-
- // post process
- update_bank();
- return true;
-}
-
bool MAIN::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 functions
void set_context_maincpu(DEVICE* device)
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 5
-#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::MZ_3500_HEAD")), csp_logger);
- DECL_STATE_ENTRY_UINT8(halt);
-
- 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->FputUint8(halt);
-}
-
-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;
- }
- }
- //halt = state_fio->FgetUint8();
- 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->StateUint8(halt);
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 SUB::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_1D_ARRAY(vram_chr, sizeof(vram_chr));
- DECL_STATE_ENTRY_1D_ARRAY(vram_gfx, sizeof(vram_gfx));
- DECL_STATE_ENTRY_1D_ARRAY(disp, sizeof(disp));
- DECL_STATE_ENTRY_INT32(cblink);
- DECL_STATE_ENTRY_BOOL(crt_400line);
-
- leave_decl_state();
-}
-
-void SUB::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_chr, sizeof(vram_chr), 1);
-// state_fio->Fwrite(vram_gfx, sizeof(vram_gfx), 1);
-// state_fio->Fwrite(disp, sizeof(disp), 1);
-// state_fio->FputInt32(cblink);
-// state_fio->FputBool(crt_400line);
-}
-
-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;
- }
-// 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_chr, sizeof(vram_chr), 1);
-// state_fio->Fread(vram_gfx, sizeof(vram_gfx), 1);
-// state_fio->Fread(disp, sizeof(disp), 1);
-// cblink = state_fio->FgetInt32();
-// crt_400line = state_fio->FgetBool();
- return true;
-}
-
bool SUB::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
void set_context_main(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void DISPLAY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette_pc, sizeof(palette_pc) / sizeof(scrntype_t));
- DECL_STATE_ENTRY_1D_ARRAY(palette, sizeof(palette));
- DECL_STATE_ENTRY_1D_ARRAY(back, sizeof(back));
- DECL_STATE_ENTRY_1D_ARRAY(reverse, sizeof(reverse));
- DECL_STATE_ENTRY_UINT8(rno);
- DECL_STATE_ENTRY_1D_ARRAY(wregs, sizeof(wregs));
- DECL_STATE_ENTRY_1D_ARRAY(pri, sizeof(pri) / sizeof(int));
- DECL_STATE_ENTRY_1D_ARRAY(vma, sizeof(vma) / sizeof(int));
- DECL_STATE_ENTRY_1D_ARRAY(vds, sizeof(vds));
- DECL_STATE_ENTRY_UINT8(mode_r);
- DECL_STATE_ENTRY_UINT8(mode_c);
- DECL_STATE_ENTRY_UINT8(mode_p);
-
- 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(palette_pc, sizeof(palette_pc), 1);
-// state_fio->Fwrite(palette, sizeof(palette), 1);
-// state_fio->Fwrite(back, sizeof(back), 1);
-// state_fio->Fwrite(reverse, sizeof(reverse), 1);
-// state_fio->FputUint8(rno);
-// state_fio->Fwrite(wregs, sizeof(wregs), 1);
-// state_fio->Fwrite(pri, sizeof(pri), 1);
-// state_fio->Fwrite(vma, sizeof(vma), 1);
-// state_fio->Fwrite(vds, sizeof(vds), 1);
-// state_fio->FputUint8(mode_r);
-// state_fio->FputUint8(mode_c);
-// state_fio->FputUint8(mode_p);
-}
-
-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(palette_pc, sizeof(palette_pc), 1);
-// state_fio->Fread(palette, sizeof(palette), 1);
-// state_fio->Fread(back, sizeof(back), 1);
-// state_fio->Fread(reverse, sizeof(reverse), 1);
-// rno = state_fio->FgetUint8();
-// state_fio->Fread(wregs, sizeof(wregs), 1);
-// state_fio->Fread(pri, sizeof(pri), 1);
-// state_fio->Fread(vma, sizeof(vma), 1);
-// state_fio->Fread(vds, sizeof(vds), 1);
-// mode_r = state_fio->FgetUint8();
-// mode_c = state_fio->FgetUint8();
-// mode_p = state_fio->FgetUint8();
- return true;
-}
-
bool DISPLAY::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(palette_pc, sizeof(palette_pc), 1);
+ //state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
+ for(int i = 0; i < (sizeof(palette) / sizeof(scrntype_t)); i++) {
+ if(loading) {
+ uint8_t r, g, b;
+ r = state_fio->FgetUint8();
+ g = state_fio->FgetUint8();
+ b = state_fio->FgetUint8();
+ palette[i] = RGB_COLOR(r, g, b);
+ } else {
+ uint8_t r, g, b;
+ r = R_OF_COLOR(palette[i]);
+ g = G_OF_COLOR(palette[i]);
+ b = B_OF_COLOR(palette[i]);
+ state_fio->FputUint8(r);
+ state_fio->FputUint8(g);
+ state_fio->FputUint8(b);
+ }
+ }
state_fio->StateBuffer(palette, sizeof(palette), 1);
state_fio->StateBuffer(back, sizeof(back), 1);
state_fio->StateBuffer(reverse, sizeof(reverse), 1);
state_fio->StateUint8(rno);
state_fio->StateBuffer(wregs, sizeof(wregs), 1);
- state_fio->StateBuffer(pri, sizeof(pri), 1);
- state_fio->StateBuffer(vma, sizeof(vma), 1);
+ //state_fio->StateBuffer(pri, sizeof(pri), 1);
+ for(int i = 0; i < (sizeof(pri) / sizeof(int)); i++) {
+ state_fio->StateInt32(pri[i]);
+ }
+ //state_fio->StateBuffer(vma, sizeof(vma), 1);
+ for(int i = 0; i < (sizeof(vma) / sizeof(int)); i++) {
+ state_fio->StateInt32(vma[i]);
+ }
state_fio->StateBuffer(vds, sizeof(vds), 1);
state_fio->StateUint8(mode_r);
state_fio->StateUint8(mode_c);
void initialize();
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_vram_ptr(uint8_t* ptr)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void KEYBOARD::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_FIFO(key_buf);
- DECL_STATE_ENTRY_FIFO(rsp_buf);
- DECL_STATE_ENTRY_BOOL(caps);
- DECL_STATE_ENTRY_BOOL(kana);
- DECL_STATE_ENTRY_BOOL(graph);
- DECL_STATE_ENTRY_INT32(dk);
- DECL_STATE_ENTRY_INT32(srk);
- DECL_STATE_ENTRY_INT32(dc);
- DECL_STATE_ENTRY_INT32(stc);
- DECL_STATE_ENTRY_INT32(send);
- DECL_STATE_ENTRY_INT32(recv);
- DECL_STATE_ENTRY_INT32(phase);
- DECL_STATE_ENTRY_INT32(timeout);
-
- 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);
-
-// key_buf->save_state((void *)state_fio);
-// rsp_buf->save_state((void *)state_fio);
-// state_fio->FputBool(caps);
-// state_fio->FputBool(kana);
-// state_fio->FputBool(graph);
-// state_fio->FputInt32(dk);
-// state_fio->FputInt32(srk);
-// state_fio->FputInt32(dc);
-// state_fio->FputInt32(stc);
-// state_fio->FputInt32(send);
-// state_fio->FputInt32(recv);
-// state_fio->FputInt32(phase);
-// state_fio->FputInt32(timeout);
-}
-
-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;
-// }
-// if(!key_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// if(!rsp_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// caps = state_fio->FgetBool();
-// kana = state_fio->FgetBool();
-// graph = state_fio->FgetBool();
-// dk = state_fio->FgetInt32();
-// srk = state_fio->FgetInt32();
-// dc = state_fio->FgetInt32();
-// stc = state_fio->FgetInt32();
-// send = state_fio->FgetInt32();
-// recv = state_fio->FgetInt32();
-// phase = state_fio->FgetInt32();
-// timeout = state_fio->FgetInt32();
- return true;
-}
-
bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void reset();
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"
#define SET_BANK(s, e, w, r) { \
int sb = (s) >> 14, eb = (e) >> 14; \
} \
}
-void MEMORY::initialize()
+void MZ5500_MEMORY::initialize()
{
// init memory
memset(ram, 0, sizeof(ram));
haddr = 0;
}
-void MEMORY::reset()
+void MZ5500_MEMORY::reset()
{
bank1 = 0xe0;
bank2 = 0;
update_bank();
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void MZ5500_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
addr &= 0xfffff;
// if((0x80000 <= addr && addr < 0xa0000) || (0xf0000 <= addr && addr < 0xfc000)) {
wbank[addr >> 14][addr & 0x3fff] = data;
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t MZ5500_MEMORY::read_data8(uint32_t addr)
{
addr &= 0xfffff;
// if((0x80000 <= addr && addr < 0xa0000) || (0xf0000 <= addr && addr < 0xfc000)) {
return rbank[addr >> 14][addr & 0x3fff];
}
-void MEMORY::write_dma_data8(uint32_t addr, uint32_t data)
+void MZ5500_MEMORY::write_dma_data8(uint32_t addr, uint32_t data)
{
addr = (addr & 0xffff) | haddr;
// if((0x80000 <= addr && addr < 0xa0000) || (0xf0000 <= addr && addr < 0xfc000)) {
wbank[addr >> 14][addr & 0x3fff] = data;
}
-uint32_t MEMORY::read_dma_data8(uint32_t addr)
+uint32_t MZ5500_MEMORY::read_dma_data8(uint32_t addr)
{
addr = (addr & 0xffff) | haddr;
// if((0x80000 <= addr && addr < 0xa0000) || (0xf0000 <= addr && addr < 0xfc000)) {
return rbank[addr >> 14][addr & 0x3fff];
}
-void MEMORY::write_io8(uint32_t addr, uint32_t data)
+void MZ5500_MEMORY::write_io8(uint32_t addr, uint32_t data)
{
switch(addr & 0xff) {
case 0x50:
}
}
-uint32_t MEMORY::read_io8(uint32_t addr)
+uint32_t MZ5500_MEMORY::read_io8(uint32_t addr)
{
return 0xf0 | bank2; // ???
}
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void MZ5500_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
{
if(bank1 != data) {
bank1 = data;
}
}
-void MEMORY::update_bank()
+void MZ5500_MEMORY::update_bank()
{
switch(bank1 & 0xe0) {
case 0xe0:
#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));
-#if defined(_MZ6500) || defined(_MZ6550)
- DECL_STATE_ENTRY_1D_ARRAY(mz1r32, sizeof(mz1r32));
-#endif
- DECL_STATE_ENTRY_UINT8(bank1);
- DECL_STATE_ENTRY_UINT8(bank2);
- DECL_STATE_ENTRY_UINT32(haddr);
-
- 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);
-//#if defined(_MZ6500) || defined(_MZ6550)
-// state_fio->Fwrite(mz1r32, sizeof(mz1r32), 1);
-//#endif
-// state_fio->FputUint8(bank1);
-// state_fio->FputUint8(bank2);
-// state_fio->FputUint32(haddr);
-}
-
-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);
-//#if defined(_MZ6500) || defined(_MZ6550)
-// state_fio->Fread(mz1r32, sizeof(mz1r32), 1);
-//#endif
-// bank1 = state_fio->FgetUint8();
-// bank2 = state_fio->FgetUint8();
-// haddr = state_fio->FgetUint32();
-
- // post process
- update_bank();
- return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool MZ5500_MEMORY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ memory ]
*/
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _MZ5500_MEMORY_H_
+#define _MZ5500_MEMORY_H_
#include "../vm.h"
#include "../../emu.h"
#define SIG_MEMORY_BANK 0
-class MEMORY : public DEVICE
+class MZ5500_MEMORY : public DEVICE
{
private:
DEVICE* d_cpu;
void update_bank();
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ MZ5500_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~MZ5500_MEMORY() {}
// common functions
void initialize();
void write_signal(int id, uint32_t data, uint32_t mask);
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_cpu(DEVICE* device)
#include "display.h"
#include "keyboard.h"
-#include "memory.h"
+#include "./memory.h"
#include "sysport.h"
// ----------------------------------------------------------------------------
display = new DISPLAY(this, emu);
keyboard = new KEYBOARD(this, emu);
- memory = new MEMORY(this, emu);
+ memory = new MZ5500_MEMORY(this, emu);
sysport = new SYSPORT(this, emu);
// set contexts
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
- decl_state();
for(int i = 0; i < 4; i++) {
#if defined(_MZ6500) || defined(_MZ6550)
fdc->set_drive_type(i, DRIVE_TYPE_2HD);
#define STATE_VERSION 5
-#include "../../statesub.h"
-#include "../../qt/gui/csp_logger.h"
-extern CSP_Logger DLL_PREFIX_I *csp_logger;
-
-void VM::decl_state(void)
-{
-#if defined(_MZ5500)
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::MZ_5500_HEAD")), csp_logger);
-#elif defined(_MZ6500)
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::MZ_6500_HEAD")), csp_logger);
-#elif defined(_MZ6550)
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::MZ_6550_HEAD")), csp_logger);
-#else
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::MZ_5500_SERIES_HEAD")), csp_logger);
-#endif
-
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->decl_state();
- }
-}
-
-void VM::save_state(FILEIO* state_fio)
-{
- //state_fio->FputUint32(STATE_VERSION);
-
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->save_state(state_fio);
- }
-}
-
-bool VM::load_state(FILEIO* state_fio)
-{
- //if(state_fio->FgetUint32() != STATE_VERSION) {
- // return false;
- //}
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- emu->out_debug_log("INFO: HEADER DATA ERROR");
- return false;
- }
- for(DEVICE* device = first_device; device; device = device->next_device) {
- if(!device->load_state(state_fio)) {
- return false;
- }
- }
- return true;
-}
-
bool VM::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- for(DEVICE* device = first_device; device; device = device->next_device) {
- const char *name = typeid(*device).name() + 6; // skip "class "
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ // Note: typeid(foo).name is fixed by recent ABI.Not dec 6.
+ // const char *name = typeid(*device).name();
+ // But, using get_device_name() instead of typeid(foo).name() 20181008 K.O
+ const char *name = device->get_device_name();
int len = strlen(name);
if(!state_fio->StateCheckInt32(len)) {
+ if(loading) {
+ printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
return false;
}
if(!state_fio->StateCheckBuffer(name, len, 1)) {
- return false;
- }
+ if(loading) {
+ printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
+ return false;
+ }
if(!device->process_state(state_fio, loading)) {
- return false;
- }
- }
+ if(loading) {
+ printf("Data loading Error: DEVID=%d\n", device->this_device_id);
+ }
+ return false;
+ }
+ }
return true;
}
class DISPLAY;
class KEYBOARD;
-class MEMORY;
+class MZ5500_MEMORY;
class SYSPORT;
class VM : public VM_TEMPLATE
DISPLAY* display;
KEYBOARD* keyboard;
- MEMORY* memory;
+ MZ5500_MEMORY* memory;
SYSPORT* sysport;
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 SYSPORT::decl_state()
-{
-
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_INT32(rst);
- DECL_STATE_ENTRY_INT32(highden);
-
- leave_decl_state();
-}
-
-void SYSPORT::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(rst);
-// state_fio->FputInt32(highden);
-}
-
-bool SYSPORT::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;
-// }
-// rst = state_fio->FgetInt32();
-// highden = state_fio->FgetInt32();
- return true;
-}
-
bool SYSPORT::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
void set_context_fdc(DEVICE* device)
[ memory ]
*/
-#include "memory.h"
+#include "./memory.h"
#define SET_BANK(s, e, w, r) { \
int sb = (s) >> 11, eb = (e) >> 11; \
} \
}
-void MEMORY::initialize()
+void N5200_MEMORY::initialize()
{
// init memory
memset(ram, 0, sizeof(ram));
delete fio;
}
-void MEMORY::release()
+void N5200_MEMORY::release()
{
// save ram image
FILEIO* fio = new FILEIO();
delete fio;
}
-void MEMORY::reset()
+void N5200_MEMORY::reset()
{
SET_BANK(0x000000, 0xffffff, wdmy, rdmy);
SET_BANK(0x000000, 0x0bffff, ram, ram);
protect = true;
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void N5200_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
addr &= 0xffffff;
if(0xe7800 <= addr && addr < 0xf0000 && protect) {
wbank[addr >> 11][addr & 0x7ff] = data;
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t N5200_MEMORY::read_data8(uint32_t addr)
{
addr &= 0xffffff;
return rbank[addr >> 11][addr & 0x7ff];
}
-void MEMORY::write_io8(uint32_t addr, uint32_t data)
+void N5200_MEMORY::write_io8(uint32_t addr, uint32_t data)
{
switch(addr) {
case 0x74:
}
}
-uint32_t MEMORY::read_io8(uint32_t addr)
+uint32_t N5200_MEMORY::read_io8(uint32_t addr)
{
return 0xff;
}
[ memory ]
*/
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _N5200_MEMORY_H_
+#define _N5200_MEMORY_H_
#include "../vm.h"
#include "../../emu.h"
#include "../device.h"
-class MEMORY : public DEVICE
+class N5200_MEMORY : public DEVICE
{
private:
uint8_t* rbank[8192]; // 16MB / 2KB
bool protect;
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ N5200_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~N5200_MEMORY() {}
// common functions
void initialize();
#include "display.h"
#include "floppy.h"
#include "keyboard.h"
-#include "memory.h"
+#include "./memory.h"
#include "system.h"
// ----------------------------------------------------------------------------
display = new DISPLAY(this, emu);
floppy = new FLOPPY(this, emu);
keyboard = new KEYBOARD(this, emu);
- memory = new MEMORY(this, emu);
+ memory = new N5200_MEMORY(this, emu);
system = new SYSTEM(this, emu);
// set contexts
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;
}
-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;
-}
class DISPLAY;
class FLOPPY;
class KEYBOARD;
-class MEMORY;
+class N5200_MEMORY;
class SYSTEM;
class VM : public VM_TEMPLATE
DISPLAY* display;
FLOPPY* floppy;
KEYBOARD* keyboard;
- MEMORY* memory;
+ N5200_MEMORY* memory;
SYSTEM* system;
public:
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void DISPLAY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT8(mode);
- DECL_STATE_ENTRY_UINT16(cursor);
- DECL_STATE_ENTRY_UINT16(cblink);
-
- 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->FputUint8(mode);
-// state_fio->FputUint16(cursor);
-// state_fio->FputUint16(cblink);
-}
-
-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;
-// }
-// mode = state_fio->FgetUint8();
-// cursor = state_fio->FgetUint16();
-// cblink = state_fio->FgetUint16();
- return true;
-}
-
bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void write_io8(uint32_t addr, uint32_t data);
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_crtc(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void FLOPPY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_BOOL(intr);
- DECL_STATE_ENTRY_BOOL(supported);
-
- 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(intr);
-// state_fio->FputBool(supported);
-}
-
-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;
-// }
-// intr = state_fio->FgetBool();
-// supported = 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 functions
void set_context_fdc(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void KANJIPAC2::decl_state()
-{
- state_entry = new csp_state_utils(STATE_VERSION, 0, (const _TCHAR *)_T("PAC2SLOT::KANJIPAC2"), NULL);
-
- DECL_STATE_ENTRY_UINT32(ptr);
-
- //leave_decl_state();
-}
-
-void KANJIPAC2::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 KANJIPAC2::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 KANJIPAC2::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void initialize(int id);
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(sel);
-
- 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(sel);
-}
-
-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;
-// }
-// sel = 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 "../i8255.h"
#define SET_BANK(s, e, w, r) { \
} \
}
-void MEMORY::initialize()
+void PASOPIA_MEMORY::initialize()
{
// load ipl
memset(rdmy, 0xff, sizeof(rdmy));
vram_data = mem_map = 0;
}
-void MEMORY::load_ipl()
+void PASOPIA_MEMORY::load_ipl()
{
// load ipl
memset(rom, 0xff, sizeof(rom));
}
-void MEMORY::reset()
+void PASOPIA_MEMORY::reset()
{
memset(vram, 0, sizeof(vram));
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void PASOPIA_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
addr &= 0xffff;
wbank[addr >> 12][addr & 0xfff] = data;
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t PASOPIA_MEMORY::read_data8(uint32_t addr)
{
addr &= 0xffff;
return rbank[addr >> 12][addr & 0xfff];
}
-void MEMORY::write_io8(uint32_t addr, uint32_t data)
+void PASOPIA_MEMORY::write_io8(uint32_t addr, uint32_t data)
{
mem_map = data;
d_pio2->write_signal(SIG_I8255_PORT_C, (mem_map & 2) ? 4 : 0, 4);
}
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void PASOPIA_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
{
// vram control
if(id == SIG_MEMORY_I8255_0_A) {
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void MEMORY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
- DECL_STATE_ENTRY_1D_ARRAY(attr, sizeof(attr));
- DECL_STATE_ENTRY_UINT16(vram_ptr);
- DECL_STATE_ENTRY_UINT8(vram_data);
- DECL_STATE_ENTRY_UINT8(mem_map);
-
- leave_decl_state();
-}
-
-void MEMORY::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->Fwrite(ram, sizeof(ram), 1);
-// state_fio->Fwrite(vram, sizeof(vram), 1);
-// state_fio->Fwrite(attr, sizeof(attr), 1);
-// state_fio->FputUint16(vram_ptr);
-// state_fio->FputUint8(vram_data);
-// state_fio->FputUint8(mem_map);
-}
-
-bool MEMORY::load_state(FILEIO* state_fio)
-{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) return false;
-// if(state_fio->FgetUint32() != STATE_VERSION) {
-// return false;
-// }
-// if(state_fio->FgetInt32() != this_device_id) {
-// return false;
-// }
-// state_fio->Fread(ram, sizeof(ram), 1);
-// state_fio->Fread(vram, sizeof(vram), 1);
-// state_fio->Fread(attr, sizeof(attr), 1);
-// vram_ptr = state_fio->FgetUint16();
-// vram_data = state_fio->FgetUint8();
-// mem_map = state_fio->FgetUint8();
-
- // post process
- if(mem_map & 2) {
- SET_BANK(0x0000, 0x7fff, ram, ram);
- } else {
- SET_BANK(0x0000, 0x7fff, ram, rom);
- }
- return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool PASOPIA_MEMORY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ memory ]
*/
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _PASOPIA_MEMORY_H_
+#define _PASOPIA_MEMORY_H_
#include "../vm.h"
#include "../../emu.h"
#define SIG_MEMORY_I8255_0_B 1
#define SIG_MEMORY_I8255_1_C 2
-class MEMORY : public DEVICE
+class PASOPIA_MEMORY : public DEVICE
{
private:
DEVICE *d_pio0, *d_pio1, *d_pio2;
uint8_t vram_data, mem_map;
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ PASOPIA_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~PASOPIA_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_pio0(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void PAC2::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_INT32(device_type);
-
- if(rampac2 != NULL) {
- rampac2->decl_state();
- }
- if(kanji != NULL) {
- kanji->decl_state();
- }
- if(joy != NULL) {
- joy->decl_state();
- }
- if(dummy != NULL) {
- dummy->decl_state();
- }
-
-
- leave_decl_state();
-}
-
-void PAC2::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(device_type);
- get_device()->save_state(state_fio);
-}
-
-bool PAC2::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;
-// }
-// device_type = state_fio->FgetInt32();
- if(!get_device()->load_state(state_fio)) {
- return false;
- }
- return true;
-}
-
bool PAC2::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 open_rampac2(const _TCHAR* file_path);
virtual void reset() {}
virtual void write_io8(uint32_t addr, uint32_t data) {}
virtual uint32_t read_io8(uint32_t addr) { return 0xff; }
- virtual void decl_state() { state_entry = NULL; }
- virtual void save_state(FILEIO* state_fio) { }
- virtual bool load_state(FILEIO* state_fio) { return true; }
+ virtual bool process_state(FILEIO* state_fio, bool loading) { return true; }
virtual void set_device_name(const _TCHAR* format, ...)
{
#include "floppy.h"
#include "display.h"
#include "keyboard.h"
-#include "memory.h"
+#include "./memory.h"
#include "pac2.h"
// ----------------------------------------------------------------------------
floppy = new FLOPPY(this, emu);
display = new DISPLAY(this, emu);
key = new KEYBOARD(this, emu);
- memory = new MEMORY(this, emu);
+ memory = new PASOPIA_MEMORY(this, emu);
pac2 = new PAC2(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 3
-#include "../../statesub.h"
-#include "../../qt/gui/csp_logger.h"
-extern CSP_Logger DLL_PREFIX_I *csp_logger;
-
-void VM::decl_state(void)
-{
-#if defined(_LCD)
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PASOPIA_WITH_LCD_HEAD")), csp_logger);
-#else
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PASOPIA_HEAD")), csp_logger);
-#endif
- DECL_STATE_ENTRY_INT32(boot_mode);
- 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->FputInt32(boot_mode);
-}
-
-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)) {
- //printf("LOAD ERROR at DEVID#%d\n", device->this_device_id);
- return false;
- }
- }
- //boot_mode = state_fio->FgetInt32();
- //printf("LOAD STATE OK\n");
- 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->StateInt32(boot_mode);
return true;
}
class FLOPPY;
class DISPLAY;
class KEYBOARD;
-class MEMORY;
+class PASOPIA_MEMORY;
class PAC2;
class VM : public VM_TEMPLATE
FLOPPY* floppy;
DISPLAY* display;
KEYBOARD* key;
- MEMORY* memory;
+ PASOPIA_MEMORY* memory;
PAC2* pac2;
int boot_mode;
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 RAMPAC2::decl_state()
-{
- state_entry = new csp_state_utils(STATE_VERSION, 1, (const _TCHAR *)_T("PAC2SLOT::RAMPAC2"), NULL);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_UINT32(ptr);
-
- DECL_STATE_ENTRY_BOOL(opened);
- DECL_STATE_ENTRY_BOOL(modified);
- //leave_decl_state();
-}
-
-
-void RAMPAC2::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-
-// state_fio->Fwrite(ram, sizeof(ram), 1);
-// state_fio->FputUint32(ptr);
-// state_fio->FputBool(opened);
-// state_fio->FputBool(modified);
-}
-
-bool RAMPAC2::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;
-// }
-// state_fio->Fread(ram, sizeof(ram), 1);
-// ptr = state_fio->FgetUint32();
-// opened = state_fio->FgetBool();
-// modified = state_fio->FgetBool();
- return true;
-}
-
bool RAMPAC2::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 open_file(const _TCHAR* file_path);
- 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 DISPLAY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT8(mode);
- DECL_STATE_ENTRY_UINT8(text_page);
- DECL_STATE_ENTRY_UINT16(cursor);
- DECL_STATE_ENTRY_UINT16(cblink);
- DECL_STATE_ENTRY_UINT16(flash_cnt);
- DECL_STATE_ENTRY_BOOL(blink);
- DECL_STATE_ENTRY_BOOL(pal_dis);
-
- 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->FputUint8(mode);
-// state_fio->FputUint8(text_page);
-// state_fio->FputUint16(cursor);
-// state_fio->FputUint16(cblink);
-// state_fio->FputUint16(flash_cnt);
-// state_fio->FputBool(blink);
-// state_fio->FputBool(pal_dis);
-}
-
-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;
-// }
-// mode = state_fio->FgetUint8();
-// text_page = state_fio->FgetUint8();
-// cursor = state_fio->FgetUint16();
-// cblink = state_fio->FgetUint16();
-// flash_cnt = state_fio->FgetUint16();
-// blink = state_fio->FgetBool();
-// pal_dis = state_fio->FgetBool();
- return true;
-}
-
bool DISPLAY::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_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(intr);
-
- 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(intr);
-}
-
-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;
-// }
-// intr = 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 IOBUS::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_BOOL(mio);
-
- leave_decl_state();
-}
-
-void IOBUS::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(mio);
-}
-
-bool IOBUS::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;
-// }
-// mio = state_fio->FgetBool();
- return true;
-}
-
bool IOBUS::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 functions
void set_context_io(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void IOTRAP::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_BOOL(nmi_mask);
- DECL_STATE_ENTRY_BOOL(pasopia);
-
- leave_decl_state();
-}
-
-void IOTRAP::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(nmi_mask);
-// state_fio->FputBool(pasopia);
-}
-
-bool IOTRAP::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;
-// }
-// nmi_mask = state_fio->FgetBool();
-// pasopia = state_fio->FgetBool();
- return true;
-}
-
bool IOTRAP::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 functions
void set_context_cpu(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void KANJIPAC2::decl_state()
-{
- state_entry = new csp_state_utils(STATE_VERSION, 0, (const _TCHAR *)_T("PAC2SLOT::KANJIPAC2"), NULL);
-
- DECL_STATE_ENTRY_UINT32(ptr);
-
- //leave_decl_state();
-}
-
-void KANJIPAC2::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 KANJIPAC2::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 KANJIPAC2::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(sel);
-
- 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(sel);
-}
-
-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;
- //}
- //sel = 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 "iobus.h"
#include "../i8255.h"
} \
}
-void MEMORY::initialize()
+void PASOPIA7_MEMORY::initialize()
{
memset(bios, 0xff, sizeof(bios));
memset(basic, 0xff, sizeof(basic));
vram_sel = pal_sel = attr_wrap = false;
}
-void MEMORY::reset()
+void PASOPIA7_MEMORY::reset()
{
memset(vram, 0, sizeof(vram));
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void PASOPIA7_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
addr &= 0xffff;
if(vram_sel && (addr & 0xc000) == 0x8000) {
wbank[addr >> 12][addr & 0xfff] = data;
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t PASOPIA7_MEMORY::read_data8(uint32_t addr)
{
addr &= 0xffff;
if(vram_sel && (addr & 0xc000) == 0x8000) {
return rbank[addr >> 12][addr & 0xfff];
}
-void MEMORY::write_io8(uint32_t addr, uint32_t data)
+void PASOPIA7_MEMORY::write_io8(uint32_t addr, uint32_t data)
{
if(mem_map != (data & 7)) {
mem_map = data & 7;
d_pio2->write_signal(SIG_I8255_PORT_C, data, 3);
}
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void PASOPIA7_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
{
if(id == SIG_MEMORY_I8255_1_A) {
plane = data;
}
}
-void MEMORY::update_memory_map()
+void PASOPIA7_MEMORY::update_memory_map()
{
if(mem_map == 0xff) {
SET_BANK(0x0000, 0x3fff, wdmy, bios);
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void MEMORY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
- DECL_STATE_ENTRY_1D_ARRAY(pal, sizeof(pal));
- DECL_STATE_ENTRY_UINT8(mem_map);
- DECL_STATE_ENTRY_UINT8(plane);
- DECL_STATE_ENTRY_UINT8(attr_data);
- DECL_STATE_ENTRY_UINT8(attr_latch);
- DECL_STATE_ENTRY_BOOL(vram_sel);
- DECL_STATE_ENTRY_BOOL(pal_sel);
- DECL_STATE_ENTRY_BOOL(attr_wrap);
-
- leave_decl_state();
-}
-
-void MEMORY::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->Fwrite(ram, sizeof(ram), 1);
-// state_fio->Fwrite(vram, sizeof(vram), 1);
-// state_fio->Fwrite(pal, sizeof(pal), 1);
-// state_fio->FputUint8(mem_map);
-// state_fio->FputUint8(plane);
-// state_fio->FputUint8(attr_data);
-// state_fio->FputUint8(attr_latch);
-// state_fio->FputBool(vram_sel);
-// state_fio->FputBool(pal_sel);
-// state_fio->FputBool(attr_wrap);
-}
-
-bool MEMORY::load_state(FILEIO* state_fio)
-{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) return false;
-// if(state_fio->FgetUint32() != STATE_VERSION) {
-// return false;
-// }
-// if(state_fio->FgetInt32() != this_device_id) {
-// return false;
-// }
-// state_fio->Fread(ram, sizeof(ram), 1);
-// state_fio->Fread(vram, sizeof(vram), 1);
-// state_fio->Fread(pal, sizeof(pal), 1);
-// mem_map = state_fio->FgetUint8();
-// plane = state_fio->FgetUint8();
-// attr_data = state_fio->FgetUint8();
-// attr_latch = state_fio->FgetUint8();
-// vram_sel = state_fio->FgetBool();
-// pal_sel = state_fio->FgetBool();
-// attr_wrap = state_fio->FgetBool();
-
- // post process
- update_memory_map();
- return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool PASOPIA7_MEMORY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ memory ]
*/
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _PASOPIA7_MEMORY_H_
+#define _PASOPIA7_MEMORY_H_
#include "../vm.h"
#include "../../emu.h"
#define SIG_MEMORY_I8255_1_B 1
#define SIG_MEMORY_I8255_1_C 2
-class MEMORY : public DEVICE
+class PASOPIA7_MEMORY : public DEVICE
{
private:
DEVICE *d_iobus, *d_pio0, *d_pio2;
void update_memory_map();
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ PASOPIA7_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~PASOPIA7_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_iobus(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void PAC2::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_INT32(sel);
-
- if(dummy != NULL) {
- dummy->decl_state();
- }
- if(kanji != NULL) {
- kanji->decl_state();
- }
- if(joy != NULL) {
- joy->decl_state();
- }
- for(int i = 0; i < 2; i++) {
- if(rampac2[i] != NULL) {
- rampac2[i]->decl_state();
- }
- }
- leave_decl_state();
-}
-
-void PAC2::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(sel);
- rampac2[0]->save_state(state_fio);
- rampac2[1]->save_state(state_fio);
- kanji->save_state(state_fio);
-}
-
-bool PAC2::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;
-// }
-// sel = state_fio->FgetInt32();
- if(!rampac2[0]->load_state(state_fio)) {
- return false;
- }
- if(!rampac2[1]->load_state(state_fio)) {
- return false;
- }
- if(!kanji->load_state(state_fio)) {
- return false;
- }
- return true;
-}
-
bool PAC2::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 open_rampac2(int drv, const _TCHAR* file_path);
virtual void reset() {}
virtual void write_io8(uint32_t addr, uint32_t data) {}
virtual uint32_t read_io8(uint32_t addr) { return 0xff; }
- virtual void decl_state() { state_entry = NULL; }
- virtual void save_state(FILEIO* state_fio) {}
- virtual bool load_state(FILEIO* state_fio) { return true; }
+ virtual bool process_state(FILEIO* state_fio, bool loading) { return true; }
virtual void set_device_name(const _TCHAR* format, ...)
{
#include "iobus.h"
#include "iotrap.h"
#include "keyboard.h"
-#include "memory.h"
+#include "./memory.h"
#include "pac2.h"
// ----------------------------------------------------------------------------
iobus = new IOBUS(this, emu);
iotrap = new IOTRAP(this, emu);
key = new KEYBOARD(this, emu);
- memory = new MEMORY(this, emu);
+ memory = new PASOPIA7_MEMORY(this, emu);
pac2 = new PAC2(this, emu);
// set contexts
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
- decl_state();
for(DEVICE* device = first_device; device; device = device->next_device) {
// if(device->this_device_id != event->this_device_id) {
device->reset();
#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)
-{
-#if defined(_LCD)
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PASOPIA7_WITH_LCD_HEAD")), csp_logger);
-#else
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PASOPIA7_HEAD")), csp_logger);
-#endif
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->decl_state();
- }
-}
-void VM::save_state(FILEIO* state_fio)
-{
- //state_fio->FputUint32(STATE_VERSION);
-
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->save_state(state_fio);
- }
-}
-
-bool VM::load_state(FILEIO* state_fio)
-{
- //if(state_fio->FgetUint32() != STATE_VERSION) {
- // return false;
- //}
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- emu->out_debug_log("INFO: HEADER DATA ERROR");
- return false;
- }
- for(DEVICE* device = first_device; device; device = device->next_device) {
- if(!device->load_state(state_fio)) {
- return false;
- }
- }
- return true;
-}
-
bool VM::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- for(DEVICE* device = first_device; device; device = device->next_device) {
- const char *name = typeid(*device).name() + 6; // skip "class "
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ // Note: typeid(foo).name is fixed by recent ABI.Not dec 6.
+ // const char *name = typeid(*device).name();
+ // But, using get_device_name() instead of typeid(foo).name() 20181008 K.O
+ const char *name = device->get_device_name();
int len = strlen(name);
if(!state_fio->StateCheckInt32(len)) {
+ if(loading) {
+ printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
return false;
}
if(!state_fio->StateCheckBuffer(name, len, 1)) {
- return false;
- }
+ if(loading) {
+ printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
+ return false;
+ }
if(!device->process_state(state_fio, loading)) {
- return false;
- }
- }
+ if(loading) {
+ printf("Data loading Error: DEVID=%d\n", device->this_device_id);
+ }
+ return false;
+ }
+ }
return true;
}
class IOBUS;
class IOTRAP;
class KEYBOARD;
-class MEMORY;
+class PASOPIA7_MEMORY;
class PAC2;
class VM : public VM_TEMPLATE
IOBUS* iobus;
IOTRAP* iotrap;
KEYBOARD* key;
- MEMORY* memory;
+ PASOPIA7_MEMORY* memory;
PAC2* pac2;
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 RAMPAC2::decl_state()
-{
- state_entry = new csp_state_utils(STATE_VERSION, this_device_id, (const _TCHAR *)_T("PAC2SLOT::RAMPAC2"), NULL);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_UINT32(ptr);
-
- DECL_STATE_ENTRY_BOOL(opened);
- DECL_STATE_ENTRY_BOOL(modified);
- //leave_decl_state();
-}
-
-void RAMPAC2::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-//
-// state_fio->Fwrite(ram, sizeof(ram), 1);
-// state_fio->FputUint32(ptr);
-// state_fio->FputBool(opened);
-// state_fio->FputBool(modified);
-}
-
-bool RAMPAC2::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;
-// }
-// state_fio->Fread(ram, sizeof(ram), 1);
-// ptr = state_fio->FgetUint32();
-// opened = state_fio->FgetBool();
-// modified = state_fio->FgetBool();
- return true;
-}
-
bool RAMPAC2::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 open_file(const _TCHAR* file_path);
- 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 CRTC::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette_pc, 16);
- DECL_STATE_ENTRY_1D_ARRAY(palette, 16);
- DECL_STATE_ENTRY_UINT8(sel);
- DECL_STATE_ENTRY_1D_ARRAY(regs, sizeof(regs));
- DECL_STATE_ENTRY_UINT16(vs);
- DECL_STATE_ENTRY_UINT16(cmd);
- DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
- DECL_STATE_ENTRY_UINT32(shift);
- DECL_STATE_ENTRY_UINT32(maskl);
- DECL_STATE_ENTRY_UINT32(maskh);
- DECL_STATE_ENTRY_UINT32(busl);
- DECL_STATE_ENTRY_UINT32(bush);
- DECL_STATE_ENTRY_UINT32(write_plane);
- DECL_STATE_ENTRY_UINT32(read_plane);
-
- leave_decl_state();
-}
-
-void CRTC::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(palette_pc, sizeof(palette_pc), 1);
-// state_fio->Fwrite(palette, sizeof(palette), 1);
-// state_fio->FputUint8(sel);
-// state_fio->Fwrite(regs, sizeof(regs), 1);
-// state_fio->FputUint16(vs);
-// state_fio->FputUint16(cmd);
-// state_fio->Fwrite(vram, sizeof(vram), 1);
-// state_fio->FputUint32(shift);
-// state_fio->FputUint32(maskl);
-// state_fio->FputUint32(maskh);
-// state_fio->FputUint32(busl);
-// state_fio->FputUint32(bush);
-// state_fio->FputUint32(write_plane);
-// state_fio->FputUint32(read_plane);
-}
-
-bool CRTC::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(palette_pc, sizeof(palette_pc), 1);
-// state_fio->Fread(palette, sizeof(palette), 1);
-// sel = state_fio->FgetUint8();
-// state_fio->Fread(regs, sizeof(regs), 1);
-// vs = state_fio->FgetUint16();
-// cmd = state_fio->FgetUint16();
-// state_fio->Fread(vram, sizeof(vram), 1);
-// shift = state_fio->FgetUint32();
-// maskl = state_fio->FgetUint32();
-// maskh = state_fio->FgetUint32();
-// busl = state_fio->FgetUint32();
-// bush = state_fio->FgetUint32();
-// write_plane = state_fio->FgetUint32();
-// read_plane = state_fio->FgetUint32();
- return true;
-}
-
bool CRTC::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(palette_pc, sizeof(palette_pc), 1);
- state_fio->StateBuffer(palette, sizeof(palette), 1);
+ //state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
+ for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
+ if(loading) {
+ 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 {
+ 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);
+ }
+ }
+ //state_fio->StateBuffer(palette, sizeof(palette), 1);
+ for(int i = 0; i < (sizeof(palette) / sizeof(uint16_t)); i++) {
+ state_fio->StateUint16(palette[i]);
+ }
state_fio->StateUint8(sel);
state_fio->StateBuffer(regs, sizeof(regs), 1);
state_fio->StateUint16(vs);
void write_memory_mapped_io16(uint32_t addr, uint32_t data);
uint32_t read_memory_mapped_io16(uint32_t addr);
void write_signal(int id, uint32_t data, uint32_t mask);
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_pic(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void IOCTRL::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_BOOL(caps);
- DECL_STATE_ENTRY_BOOL(kana);
- DECL_STATE_ENTRY_FIFO(key_buf);
- DECL_STATE_ENTRY_UINT32(key_val);
- DECL_STATE_ENTRY_UINT32(key_mouse);
- DECL_STATE_ENTRY_INT32(key_prev);
- DECL_STATE_ENTRY_BOOL(key_res);
- DECL_STATE_ENTRY_BOOL(key_done);
- DECL_STATE_ENTRY_INT32(register_id);
- DECL_STATE_ENTRY_UINT8(ts);
-
- leave_decl_state();
-}
-
-
-void IOCTRL::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(caps);
-// state_fio->FputBool(kana);
-// key_buf->save_state((void *)state_fio);
-// state_fio->FputUint32(key_val);
-// state_fio->FputUint32(key_mouse);
-// state_fio->FputInt32(key_prev);
-// state_fio->FputBool(key_res);
-// state_fio->FputBool(key_done);
-// state_fio->FputInt32(register_id);
-// state_fio->FputUint8(ts);
-}
-
-bool IOCTRL::load_state(FILEIO* state_fio)
-{
- 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;
-// }
-// caps = state_fio->FgetBool();
-// kana = state_fio->FgetBool();
-// if(!key_buf->load_state((void *)state_fio)) {
-// return false;
-// }
-// key_val = state_fio->FgetUint32();
-// key_mouse = state_fio->FgetUint32();
-// key_prev = state_fio->FgetInt32();
-// key_res = state_fio->FgetBool();
-// key_done = state_fio->FgetBool();
-// register_id = state_fio->FgetInt32();
-// ts = state_fio->FgetUint8();
- return true;
-}
-
bool IOCTRL::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
uint32_t read_io8(uint32_t addr);
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_pic(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void KANJI::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT16(ptr);
- DECL_STATE_ENTRY_BOOL(strobe);
-
- 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->FputUint16(ptr);
-// state_fio->FputBool(strobe);
-}
-
-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;
-// }
-// ptr = state_fio->FgetUint16();
-// strobe = state_fio->FgetBool();
- return true;
-}
-
bool KANJI::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void initialize();
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
};
#endif
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
- decl_state();
}
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::PC_100_HEAD")), csp_logger);
- DECL_STATE_ENTRY_1D_ARRAY(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;
+ }
+ }
+ // Machine specified.
state_fio->StateBuffer(ram, sizeof(ram), 1);
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
[ i/o ]
*/
-#include "io.h"
+#include "./io.h"
#include "../datarec.h"
#include "../upd16434.h"
#include "../upd1990a.h"
#define EVENT_TIMER 0
-void IO::initialize()
+void PC2001_IO::initialize()
{
register_event(this, EVENT_TIMER, 20000, true, NULL);
key_stat = emu->get_key_buffer();
}
-void IO::reset()
+void PC2001_IO::reset()
{
port_a = port_b = port_s = 0xff;
drec_in = rtc_in = false;
key_strobe = 0xffff;
}
-void IO::write_io8(uint32_t addr, uint32_t data)
+void PC2001_IO::write_io8(uint32_t addr, uint32_t data)
{
switch(addr) {
case UPD7807_PORTA:
}
}
-uint32_t IO::read_io8(uint32_t addr)
+uint32_t PC2001_IO::read_io8(uint32_t addr)
{
uint32_t value = 0xff;
return value;
}
-void IO::write_io16(uint32_t addr, uint32_t data)
+void PC2001_IO::write_io16(uint32_t addr, uint32_t data)
{
switch(addr) {
case UPD7807_PORTE:
}
}
-void IO::write_signal(int id, uint32_t data, uint32_t mask)
+void PC2001_IO::write_signal(int id, uint32_t data, uint32_t mask)
{
switch(id) {
case SIG_IO_DREC_IN:
}
}
-void IO::event_callback(int event_id, int err)
+void PC2001_IO::event_callback(int event_id, int err)
{
if(event_id == EVENT_TIMER) {
d_cpu->write_signal(SIG_UPD7810_INTF1, 1, 1);
}
}
-uint8_t IO::get_key()
+uint8_t PC2001_IO::get_key()
{
uint8_t data = 0x3f;
return data;
}
-bool IO::key_hit(int code)
+bool PC2001_IO::key_hit(int code)
{
bool value = (key_stat[code] != 0);
return value;
#define STATE_VERSION 2
-#include "../../statesub.h"
-
-void IO::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT8(port_a);
- DECL_STATE_ENTRY_UINT8(port_b);
- DECL_STATE_ENTRY_UINT8(port_s);
- DECL_STATE_ENTRY_BOOL(drec_in);
- DECL_STATE_ENTRY_BOOL(rtc_in);
- DECL_STATE_ENTRY_UINT16(key_strobe);
-
- 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->FputUint8(port_a);
-// state_fio->FputUint8(port_b);
-// state_fio->FputUint8(port_s);
-// state_fio->FputBool(drec_in);
-// state_fio->FputBool(rtc_in);
-// state_fio->FputUint16(key_strobe);
-}
-
-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;
-// }
-// port_a = state_fio->FgetUint8();
-// port_b = state_fio->FgetUint8();
-// port_s = state_fio->FgetUint8();
-// drec_in = state_fio->FgetBool();
-// rtc_in = state_fio->FgetBool();
-// key_strobe = state_fio->FgetUint16();
- return true;
-}
-
-bool IO::process_state(FILEIO* state_fio, bool loading)
+bool PC2001_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 _PC2001_IO_H_
+#define _PC2001_IO_H_
#include "../vm.h"
#include "../../emu.h"
class UPD16434;
-class IO : public DEVICE
+class PC2001_IO : public DEVICE
{
private:
UPD16434 *d_lcd[4];
bool key_hit(int code);
public:
- IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ PC2001_IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("I/O Bus"));
}
- ~IO() {}
+ ~PC2001_IO() {}
// common functions
void initialize();
void write_io16(uint32_t addr, uint32_t data);
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_lcd(int index, UPD16434* device)
#include "../debugger.h"
#endif
-#include "io.h"
+#include "./io.h"
// ----------------------------------------------------------------------------
// initialize
rtc = new UPD1990A(this, emu);
cpu = new UPD7810(this, emu);
- io = new IO(this, emu);
+ io = new PC2001_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::PC_2001_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)) {
class UPD1990A;
class UPD7810;
-class IO;
+class PC2001_IO;
class VM : public VM_TEMPLATE
{
protected:
UPD1990A* rtc;
UPD7810* cpu;
- IO* io;
+ PC2001_IO* io;
// memory
uint8_t ram[0x5000];
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 DISPLAY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_INT32(tmp_vram_size);
-
- leave_decl_state();
-}
-
-void DISPLAY::save_state(FILEIO* state_fio)
-{
- tmp_vram_size = (int)(vram_ptr - ram_ptr);
-
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->FputInt32((int)(vram_ptr - ram_ptr));
-}
-
-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;
-// }
-// vram_ptr = ram_ptr + state_fio->FgetInt32();
- vram_ptr = ram_ptr + tmp_vram_size;
- return true;
-}
-
bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
// common functions
void reset();
void write_io8(uint32_t addr, uint32_t data);
- 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_vdp(MC6847* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void FLOPPY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT8(io_B1H);
- DECL_STATE_ENTRY_1D_ARRAY(cur_trk, 2);
- DECL_STATE_ENTRY_1D_ARRAY(cur_sct, 2);
- DECL_STATE_ENTRY_1D_ARRAY(cur_pos, 2);
- DECL_STATE_ENTRY_1D_ARRAY(access, 2);
- DECL_STATE_ENTRY_2D_ARRAY(Data, 4, 256);
- DECL_STATE_ENTRY_1D_ARRAY(Index, 4);
- {
- DECL_STATE_ENTRY_1D_ARRAY((CmdIn.Data), 10 * sizeof(unsigned char));
- DECL_STATE_ENTRY_INT32((CmdIn.Index));
- }
- {
- DECL_STATE_ENTRY_1D_ARRAY((CmdOut.Data), 10 * sizeof(unsigned char));
- DECL_STATE_ENTRY_INT32((CmdOut.Index));
- }
-
- DECL_STATE_ENTRY_UINT8(SeekST0);
- DECL_STATE_ENTRY_UINT8(LastCylinder);
- DECL_STATE_ENTRY_INT32(SeekEnd);
- DECL_STATE_ENTRY_UINT8(SendSectors);
- DECL_STATE_ENTRY_INT32(DIO);
- DECL_STATE_ENTRY_UINT8(Status);
- leave_decl_state();
-
- for(int i = 0; i < 2; i++) {
- disk[i]->decl_state(p_logger);
- }
-
-}
-
-
-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->FputUint8(io_B1H);
- for(int i = 0; i < 2; i++) {
- disk[i]->save_state(state_fio);
- }
-// state_fio->Fwrite(cur_trk, sizeof(cur_trk), 1);
-// state_fio->Fwrite(cur_sct, sizeof(cur_sct), 1);
-// state_fio->Fwrite(cur_pos, sizeof(cur_pos), 1);
-// state_fio->Fwrite(access, sizeof(access), 1);
-// state_fio->Fwrite(Data, sizeof(Data), 1);
-// state_fio->Fwrite(Index, sizeof(Index), 1);
-// state_fio->Fwrite(&CmdIn, sizeof(CmdBuffer), 1);
-// state_fio->Fwrite(&CmdOut, sizeof(CmdBuffer), 1);
-
-// state_fio->FputUint8(SeekST0);
-// state_fio->FputUint8(LastCylinder);
-// state_fio->FputInt32(SeekEnd);
-// state_fio->FputUint8(SendSectors);
-// state_fio->FputInt32(DIO);
-// state_fio->FputUint8(Status);
-}
-
-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;
-// }
-// io_B1H = state_fio->FgetUint8();
- for(int i = 0; i < 2; i++) {
- if(!disk[i]->load_state(state_fio)) {
- return false;
- }
- }
-// state_fio->Fread(cur_trk, sizeof(cur_trk), 1);
-// state_fio->Fread(cur_sct, sizeof(cur_sct), 1);
-// state_fio->Fread(cur_pos, sizeof(cur_pos), 1);
-// state_fio->Fread(access, sizeof(access), 1);
-// state_fio->Fread(Data, sizeof(Data), 1);
-// state_fio->Fread(Index, sizeof(Index), 1);
-// state_fio->Fread(&CmdIn, sizeof(CmdBuffer), 1);
-// state_fio->Fread(&CmdOut, sizeof(CmdBuffer), 1);
-// SeekST0 = state_fio->FgetUint8();
-// LastCylinder = state_fio->FgetUint8();
-// SeekEnd = state_fio->FgetInt32();
-// SendSectors = state_fio->FgetUint8();
-// DIO = state_fio->FgetInt32();
-// Status = state_fio->FgetUint8();
- return true;
-}
-
bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
}
- state_fio->StateBuffer(cur_trk, sizeof(cur_trk), 1);
- state_fio->StateBuffer(cur_sct, sizeof(cur_sct), 1);
- state_fio->StateBuffer(cur_pos, sizeof(cur_pos), 1);
- state_fio->StateBuffer(access, sizeof(access), 1);
+ //state_fio->StateBuffer(cur_trk, sizeof(cur_trk), 1);
+ for(int i = 0; i < (sizeof(cur_trk) / sizeof(int)); i++) {
+ state_fio->StateInt32(cur_trk[i]);
+ }
+ //state_fio->StateBuffer(cur_sct, sizeof(cur_sct), 1);
+ for(int i = 0; i < (sizeof(cur_sct) / sizeof(int)); i++) {
+ state_fio->StateInt32(cur_sct[i]);
+ }
+ //state_fio->StateBuffer(cur_pos, sizeof(cur_pos), 1);
+ for(int i = 0; i < (sizeof(cur_pos) / sizeof(int)); i++) {
+ state_fio->StateInt32(cur_pos[i]);
+ }
+ //state_fio->StateBuffer(access, sizeof(access), 1);
+ for(int i = 0; i < (sizeof(access) / sizeof(bool)); i++) {
+ state_fio->StateBool(access[i]);
+ }
state_fio->StateBuffer(Data, sizeof(Data), 1);
- state_fio->StateBuffer(Index, sizeof(Index), 1);
- state_fio->StateBuffer(&CmdIn, sizeof(CmdBuffer), 1);
- state_fio->StateBuffer(&CmdOut, sizeof(CmdBuffer), 1);
+ //state_fio->StateBuffer(Index, sizeof(Index), 1);
+ for(int i = 0; i < (sizeof(Index) / sizeof(int)); i++) {
+ state_fio->StateInt32(Index[i]);
+ }
+ //state_fio->StateBuffer(&CmdIn, sizeof(CmdBuffer), 1);
+ {
+ state_fio->StateBuffer(CmdIn.Data, sizeof(CmdIn.Data), 1);
+ state_fio->StateInt32(CmdIn.Index);
+ }
+ //state_fio->StateBuffer(&CmdOut, sizeof(CmdBuffer), 1);
+ {
+ state_fio->StateBuffer(CmdOut.Data, sizeof(CmdOut.Data), 1);
+ state_fio->StateInt32(CmdOut.Index);
+ }
state_fio->StateUint8(SeekST0);
state_fio->StateUint8(LastCylinder);
state_fio->StateInt32(SeekEnd);
uint32_t read_io8(uint32_t addr);
uint32_t read_signal(int ch);
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);
// unique functions
void set_context_ext(DEVICE* device)
[ memory ]
*/
-#include "memory.h"
+#include "./memory.h"
#include "timer.h"
#define RAM (MEMORY_BASE + RAM_BASE)
#define SYSTEMROM2 (MEMORY_BASE + SYSTEMROM2_BASE)
#define CGROM6 (MEMORY_BASE + CGROM6_BASE)
-void MEMORY::initialize()
+void PC6001_MEMORY::initialize()
{
FILEIO* fio = new FILEIO();
#if defined(_PC6001)
#endif
}
-void MEMORY::reset()
+void PC6001_MEMORY::reset()
{
#ifdef _PC6001
int J;
#endif
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void PC6001_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
#if defined(_PC6601SR) || defined(_PC6001MK2SR)
/* Graphics Vram Write (SR basic) */
WrMem[addr >> 13][addr & 0x1FFF] = data;
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t PC6001_MEMORY::read_data8(uint32_t addr)
{
#if defined(_PC6601SR) || defined(_PC6001MK2SR)
/* Graphics Vram Read (SR basic) */
return(RdMem[addr >> 13][addr & 0x1FFF]);
}
-void MEMORY::write_io8(uint32_t addr, uint32_t data)
+void PC6001_MEMORY::write_io8(uint32_t addr, uint32_t data)
{
unsigned int VRAMHead[2][4] = {
{ 0xc000, 0xe000, 0x8000, 0xa000 },
}
#ifndef _PC6001
-uint32_t MEMORY::read_io8(uint32_t addr)
+uint32_t PC6001_MEMORY::read_io8(uint32_t addr)
{
uint16_t port=(addr & 0x00ff);
uint8_t Value=0xff;
#define EVENT_HBLANK 1
-void MEMORY::event_vline(int v, int clock)
+void PC6001_MEMORY::event_vline(int v, int clock)
{
#if defined(_PC6601SR) || defined(_PC6001MK2SR)
if(static_cast<VM *>(vm)->sr_mode) {
}
}
-void MEMORY::event_callback(int event_id, int err)
+void PC6001_MEMORY::event_callback(int event_id, int err)
{
if(event_id == EVENT_HBLANK) {
d_cpu->write_signal(SIG_CPU_BUSREQ, 0, 0);
}
#endif
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void PC6001_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
{
if(id == SIG_MEMORY_PIO_PORT_C) {
#ifdef _PC6001
}
}
-void MEMORY::open_cart(const _TCHAR* file_path)
+void PC6001_MEMORY::open_cart(const _TCHAR* file_path)
{
FILEIO* fio = new FILEIO();
if(fio->Fopen(file_path, FILEIO_READ_BINARY)) {
delete fio;
}
-void MEMORY::close_cart()
+void PC6001_MEMORY::close_cart()
{
/// EXTROM1 = EXTROM2 = EmptyRAM;
EXTROM1 = RAM + 0x4000;
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void MEMORY::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(&(MEMORY_BASE[RAM_BASE]), RAM_SIZE);
-// state_fio->FputInt32((int)(CGROM - MEMORY_BASE));
-// state_fio->FputInt32((int)(EXTROM1 - MEMORY_BASE));
-// state_fio->FputInt32((int)(EXTROM2 - MEMORY_BASE));
-// for(int i = 0; i < 8; i++) {
-// state_fio->FputInt32((int)(RdMem[i] - MEMORY_BASE));
-// state_fio->FputInt32((int)(WrMem[i] - MEMORY_BASE));
-// }
-// state_fio->FputInt32((int)(VRAM - MEMORY_BASE));
- DECL_STATE_ENTRY_1D_ARRAY(EnWrite, sizeof(EnWrite));
- DECL_STATE_ENTRY_UINT8(CGSW93);
- DECL_STATE_ENTRY_BOOL(inserted);
-#ifndef _PC6001
- DECL_STATE_ENTRY_UINT8(CRTKILL);
-// DECL_STATE_ENTRY_INT32((int)(CurKANJIROM - MEMORY_BASE));
- DECL_STATE_ENTRY_UINT8(CRTMode1);
- DECL_STATE_ENTRY_UINT8(CRTMode2);
- DECL_STATE_ENTRY_UINT8(CRTMode3);
- DECL_STATE_ENTRY_UINT8(CSS1);
- DECL_STATE_ENTRY_UINT8(CSS2);
- DECL_STATE_ENTRY_UINT8(CSS3);
- DECL_STATE_ENTRY_UINT8(portF0);
- DECL_STATE_ENTRY_UINT8(portF1);
-#if defined(_PC6601SR) || defined(_PC6001MK2SR)
- DECL_STATE_ENTRY_INT32(bitmap);
- DECL_STATE_ENTRY_INT32(cols);
- DECL_STATE_ENTRY_INT32(rows);
- DECL_STATE_ENTRY_INT32(lines);
-// state_fio->FputInt32((int)(TEXTVRAM - MEMORY_BASE));
-// state_fio->FputInt32((int)(SYSROM2 - MEMORY_BASE));
- DECL_STATE_ENTRY_1D_ARRAY(&(MEMORY_BASE[EXTRAM_BASE]), EXTRAM_SIZE);
- DECL_STATE_ENTRY_1D_ARRAY(port60, sizeof(port60));
- DECL_STATE_ENTRY_UINT8(portC1);
- DECL_STATE_ENTRY_UINT8(portC8);
- DECL_STATE_ENTRY_UINT8(portCA);
- DECL_STATE_ENTRY_UINT8(portCB);
- DECL_STATE_ENTRY_UINT8(portCC);
- DECL_STATE_ENTRY_UINT8(portCE);
- DECL_STATE_ENTRY_UINT8(portCF);
- DECL_STATE_ENTRY_1D_ARRAY(palet, sizeof(palet) / sizeof(int));
-#endif
-#endif
- // Pointer Values
- DECL_STATE_ENTRY_INT32(tmp_cgrom_ptr);
- DECL_STATE_ENTRY_INT32(tmp_extrom1_ptr);
- DECL_STATE_ENTRY_INT32(tmp_extrom2_ptr);
- {
- DECL_STATE_ENTRY_1D_ARRAY(tmp_rdmem_ptr, 8);
- DECL_STATE_ENTRY_1D_ARRAY(tmp_wrmem_ptr, 8);
- }
- DECL_STATE_ENTRY_INT32(tmp_vram_ptr);
-#ifndef _PC6001
- DECL_STATE_ENTRY_INT32(tmp_kanjirom_ptr);
-#if defined(_PC6601SR) || defined(_PC6001MK2SR)
- DECL_STATE_ENTRY_INT32(tmp_textvram_ptr);
- DECL_STATE_ENTRY_INT32(tmp_sysrom2_ptr);
-#endif
-#endif
-
- leave_decl_state();
-}
-
-void MEMORY::save_state(FILEIO* state_fio)
-{
- tmp_cgrom_ptr = (int)(CGROM - MEMORY_BASE);
- tmp_extrom1_ptr = (int)(EXTROM1 - MEMORY_BASE);
- tmp_extrom2_ptr = (int)(EXTROM2 - MEMORY_BASE);
- for(int i = 0; i < 8; i++) {
- tmp_rdmem_ptr[i] = (int)(RdMem[i] - MEMORY_BASE);
- tmp_wrmem_ptr[i] = (int)(WrMem[i] - MEMORY_BASE);
- }
- tmp_vram_ptr =(int)(VRAM - MEMORY_BASE);
-#ifndef _PC6001
- tmp_kanjirom_ptr = (int)(CurKANJIROM - MEMORY_BASE);
-#if defined(_PC6601SR) || defined(_PC6001MK2SR)
- tmp_textvram_ptr = (int)(TEXTVRAM - MEMORY_BASE);
- tmp_sysrom2_ptr = (int)(SYSROM2 - MEMORY_BASE);
-#endif
-#endif
-
- 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, RAM_SIZE, 1);
-// state_fio->FputInt32((int)(CGROM - MEMORY_BASE));
-// state_fio->FputInt32((int)(EXTROM1 - MEMORY_BASE));
-// state_fio->FputInt32((int)(EXTROM2 - MEMORY_BASE));
-// for(int i = 0; i < 8; i++) {
-// state_fio->FputInt32((int)(RdMem[i] - MEMORY_BASE));
-// state_fio->FputInt32((int)(WrMem[i] - MEMORY_BASE));
-// }
-// state_fio->FputInt32((int)(VRAM - MEMORY_BASE));
-// state_fio->Fwrite(EnWrite, sizeof(EnWrite), 1);
-// state_fio->FputUint8(CGSW93);
-// state_fio->FputBool(inserted);
-#ifndef _PC6001
-// state_fio->FputUint8(CRTKILL);
-// state_fio->FputInt32((int)(CurKANJIROM - MEMORY_BASE));
-// state_fio->FputUint8(CRTMode1);
-// state_fio->FputUint8(CRTMode2);
-// state_fio->FputUint8(CRTMode3);
-// state_fio->FputUint8(CSS1);
-// state_fio->FputUint8(CSS2);
-// state_fio->FputUint8(CSS3);
-// state_fio->FputUint8(portF0);
-// state_fio->FputUint8(portF1);
-#if defined(_PC6601SR) || defined(_PC6001MK2SR)
-// state_fio->FputInt32(bitmap);
-// state_fio->FputInt32(cols);
-// state_fio->FputInt32(rows);
-// state_fio->FputInt32(lines);
-// state_fio->FputInt32((int)(TEXTVRAM - MEMORY_BASE));
-// state_fio->FputInt32((int)(SYSROM2 - MEMORY_BASE));
-// state_fio->Fwrite(EXTRAM, EXTRAM_SIZE, 1);
-// state_fio->Fwrite(port60, sizeof(port60), 1);
-// state_fio->FputUint8(portC1);
-// state_fio->FputUint8(portC8);
-// state_fio->FputUint8(portCA);
-// state_fio->FputUint8(portCB);
-// state_fio->FputUint8(portCC);
-// state_fio->FputUint8(portCE);
-// state_fio->FputUint8(portCF);
-// state_fio->Fwrite(palet, sizeof(palet), 1);
-#endif
-#endif
-}
-
-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, RAM_SIZE, 1);
-// CGROM = MEMORY_BASE + state_fio->FgetInt32();
-// EXTROM1 = MEMORY_BASE + state_fio->FgetInt32();
-// EXTROM2 = MEMORY_BASE + state_fio->FgetInt32();
-// for(int i = 0; i < 8; i++) {
-// RdMem[i] = MEMORY_BASE + state_fio->FgetInt32();
-// WrMem[i] = MEMORY_BASE + state_fio->FgetInt32();
-// }
-// VRAM = MEMORY_BASE + state_fio->FgetInt32();
-// state_fio->Fread(EnWrite, sizeof(EnWrite), 1);
-// CGSW93 = state_fio->FgetUint8();
-// inserted = state_fio->FgetBool();
-//#ifndef _PC6001
-// CRTKILL = state_fio->FgetUint8();
-// CurKANJIROM = MEMORY_BASE + state_fio->FgetInt32();
-// CRTMode1 = state_fio->FgetUint8();
-// CRTMode2 = state_fio->FgetUint8();
-// CRTMode3 = state_fio->FgetUint8();
-// CSS1 = state_fio->FgetUint8();
-// CSS2 = state_fio->FgetUint8();
-// CSS3 = state_fio->FgetUint8();
-// portF0 = state_fio->FgetUint8();
-// portF1 = state_fio->FgetUint8();
-//#if defined(_PC6601SR) || defined(_PC6001MK2SR)
-// bitmap = state_fio->FgetInt32();
-// cols = state_fio->FgetInt32();
-// rows = state_fio->FgetInt32();
-// lines = state_fio->FgetInt32();
-// TEXTVRAM = MEMORY_BASE + state_fio->FgetInt32();
-// SYSROM2 = MEMORY_BASE + state_fio->FgetInt32();
-// state_fio->Fread(EXTRAM, EXTRAM_SIZE, 1);
-// state_fio->Fread(port60, sizeof(port60), 1);
-// portC1 = state_fio->FgetUint8();
-// portC8 = state_fio->FgetUint8();
-// portCA = state_fio->FgetUint8();
-// portCB = state_fio->FgetUint8();
-// portCC = state_fio->FgetUint8();
-// portCE = state_fio->FgetUint8();
-// portCF = state_fio->FgetUint8();
-// state_fio->Fread(palet, sizeof(palet), 1);
-//#endif
-//#endif
-
- // Post Process
- CGROM = MEMORY_BASE + tmp_cgrom_ptr;
- EXTROM1 = MEMORY_BASE + tmp_extrom1_ptr;
- EXTROM2 = MEMORY_BASE + tmp_extrom2_ptr;
- for(int i = 0; i < 8; i++) {
- RdMem[i] = MEMORY_BASE + tmp_rdmem_ptr[i];
- WrMem[i] = MEMORY_BASE + tmp_wrmem_ptr[i];
- }
- VRAM = MEMORY_BASE + tmp_vram_ptr;
-#ifndef _PC6001
- CurKANJIROM = MEMORY_BASE + tmp_kanjirom_ptr;
-#if defined(_PC6601SR) || defined(_PC6001MK2SR)
- TEXTVRAM = MEMORY_BASE + tmp_textvram_ptr;
- SYSROM2 = MEMORY_BASE + tmp_sysrom2_ptr;
-#endif
-#endif
- return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool PC6001_MEMORY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ memory ]
*/
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _PC6001_MEMORY_H_
+#define _PC6001_MEMORY_H_
#include "../vm.h"
#include "../../emu.h"
#define MEMORY_SIZE (CGROM6_BASE + CGROM6_SIZE)
#endif
-class MEMORY : public DEVICE
+class PC6001_MEMORY : public DEVICE
{
private:
DEVICE *d_cpu;
#endif
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ PC6001_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
inserted = false;
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~PC6001_MEMORY() {}
// common functions
void initialize();
void event_callback(int event_id, int err);
#endif
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
#ifndef _PC6001
#define SeqPix21(c) dest[X*8+W]=c;W++;
#define SeqPix41(c) dest[X*8+W]=c;W++;dest[X*8+W]=c;W++;
-void MEMORY::draw_screen()
+void PC6001_MEMORY::draw_screen()
{
if (CRTKILL) {
for(int y = 0; y < 400; y++) {
}
// RefreshScr10: N60-BASIC select function
-void MEMORY::RefreshScr10()
+void PC6001_MEMORY::RefreshScr10()
{
if ((*VRAM&0x80) == 0x00)
RefreshScr11();
}
// RefreshScr11: N60-BASIC screen 1,2
-void MEMORY::RefreshScr11()
+void PC6001_MEMORY::RefreshScr11()
{
uint8_t X,Y,K;
int FC,BC;
}
// RefreshScr13: N60-BASIC screen 3,4
-void MEMORY::RefreshScr13()
+void PC6001_MEMORY::RefreshScr13()
{
uint8_t X,Y;
uint8_t *T1,*T2;
}
// RefreshScr13a: N60-BASIC screen 3,4
-void MEMORY::RefreshScr13a() /* 64x 64 color / 128x 64 */
+void PC6001_MEMORY::RefreshScr13a() /* 64x 64 color / 128x 64 */
{
uint8_t X,Y;
uint8_t *T1,*T2;
}
// RefreshScr13b: N60-BASIC screen 3,4
-void MEMORY::RefreshScr13b() /* 128x 64 color */
+void PC6001_MEMORY::RefreshScr13b() /* 128x 64 color */
{
uint8_t X,Y;
uint8_t *T1,*T2;
}
// RefreshScr13c: N60-BASIC screen 3,4
-void MEMORY::RefreshScr13c() /* 128x 96 */
+void PC6001_MEMORY::RefreshScr13c() /* 128x 96 */
{
uint8_t X,Y;
uint8_t *T1,*T2;
}
// RefreshScr13d: N60-BASIC screen 3,4
-void MEMORY::RefreshScr13d() /* 128x 96 color */
+void PC6001_MEMORY::RefreshScr13d() /* 128x 96 color */
{
uint8_t X,Y;
uint8_t *T1,*T2;
}
// RefreshScr13e: N60-BASIC screen 3,4
-void MEMORY::RefreshScr13e() /* 128x192 */
+void PC6001_MEMORY::RefreshScr13e() /* 128x192 */
{
uint8_t X,Y;
uint8_t *T1,*T2;
}
// RefreshScr51: N60m/66-BASIC screen 1,2
-void MEMORY::RefreshScr51()
+void PC6001_MEMORY::RefreshScr51()
{
uint8_t X,Y,K;
int FC,BC;
}
// RefreshScr53: N60m/66-BASIC screen 3
-void MEMORY::RefreshScr53()
+void PC6001_MEMORY::RefreshScr53()
{
uint8_t X,Y;
uint8_t *T1,*T2;
}
// RefreshScr54: N60m/66-BASIC screen 4
-void MEMORY::RefreshScr54()
+void PC6001_MEMORY::RefreshScr54()
{
uint8_t X,Y;
uint8_t *T1,*T2;
#if defined(_PC6601SR) || defined(_PC6001MK2SR)
// RefreshScr61: N66-SR BASIC screen 1
-void MEMORY::RefreshScr61()
+void PC6001_MEMORY::RefreshScr61()
{
uint8_t X,Y,K;
register int FC,BC;
}
// RefreshScr62 N66-SR BASIC screen 2
-void MEMORY::RefreshScr62()
+void PC6001_MEMORY::RefreshScr62()
{
uint8_t X,Y;
uint8_t *T1,*T2;
}
// RefreshScr63 N66-SR BASIC screen 3
-void MEMORY::RefreshScr63()
+void PC6001_MEMORY::RefreshScr63()
{
uint8_t X,Y;
uint8_t *T1,*T2;
}
}
-void MEMORY::do_palet(int dest,int src)
+void PC6001_MEMORY::do_palet(int dest,int src)
{
int textpalet2[16]={0,4,1,5,2,6,3,7,8,12,9,13,10,14,11,15}; /* color code-> VRAM code*/
// *************** for RefreshScr 53/54/62/63 ***************************
BPal[textpalet2[dest]]= BPal61[ textpalet2[src]];
}
-void MEMORY::make_semigraph(void)
+void PC6001_MEMORY::make_semigraph(void)
{
uint8_t *P;
unsigned int i, j, m1, m2;
}
}
-int MEMORY::chk_gvram(uint32_t A,int flag)
+int PC6001_MEMORY::chk_gvram(uint32_t A,int flag)
{
if (port60[ (A>>13)+flag ]==0x00 && bitmap) // VRAM \82Ì\90æ\93ª\82©\82Â\81ACRT\82ª BITMAP mode
return 1;
return 0;
}
-uint8_t MEMORY::gvram_read(uint32_t A)
+uint8_t PC6001_MEMORY::gvram_read(uint32_t A)
{
uint8_t* adr;
uint8_t ret;
return (ret);
}
-void MEMORY::gvram_write(uint32_t A, uint32_t V)
+void PC6001_MEMORY::gvram_write(uint32_t A, uint32_t V)
{
uint8_t* adr;
int x,y,z,w,off;
// floppy->set_context_noise_head_up(noise_head_up);
#endif
joystick = new JOYSTICK(this, emu);
- memory = new MEMORY(this, emu);
+ memory = new PC6001_MEMORY(this, emu);
timer = new TIMER(this, emu);
// set contexts
pc6031->get_disk_handler(0)->drive_num = drive_num++;
pc6031->get_disk_handler(1)->drive_num = drive_num++;
}
- decl_state();
}
VM::~VM()
#define STATE_VERSION 6
-#include "../../statesub.h"
-#include "../../qt/gui/csp_logger.h"
-extern CSP_Logger DLL_PREFIX_I *csp_logger;
-
-void VM::decl_state(void)
-{
-#if defined(_PC6001)
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_6001_HEAD")), csp_logger);
-#elif defined(_PC6001MK2)
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_6001_MK2_HEAD")), csp_logger);
-#elif defined(_PC6001MK2SR)
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_6001_MK2_SR_HEAD")), csp_logger);
-#elif defined(_PC6601)
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_6601_HEAD")), csp_logger);
-#elif defined(_PC601SR)
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_6601_SR_HEAD")), csp_logger);
-#else
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_6001_SERIES_HEAD")), csp_logger);
-#endif
- DECL_STATE_ENTRY_INT32(sr_mode);
- 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->FputInt32(sr_mode);
-}
-
-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;
- }
- }
- //sr_mode = state_fio->FgetInt32();
- 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->StateInt32(sr_mode);
return true;
}
class FLOPPY;
#endif
class JOYSTICK;
-class MEMORY;
+class PC6001_MEMORY;
class PSUB;
class SUB;
class TIMER;
FLOPPY* floppy;
#endif
JOYSTICK* joystick;
- MEMORY* memory;
+ PC6001_MEMORY* memory;
PSUB* psub;
TIMER* timer;
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 PSUB::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_BOOL(play);
- DECL_STATE_ENTRY_BOOL(rec);
- DECL_STATE_ENTRY_BOOL(is_wav);
- DECL_STATE_ENTRY_BOOL(is_p6t);
- 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(CasIntFlag);
- DECL_STATE_ENTRY_INT32(CasIndex);
- DECL_STATE_ENTRY_INT32(CasRecv);
- DECL_STATE_ENTRY_INT32(CasMode);
- DECL_STATE_ENTRY_INT32(CasBaud);
- DECL_STATE_ENTRY_INT32(FileBaud);
- DECL_STATE_ENTRY_1D_ARRAY(CasData, sizeof(CasData));
- DECL_STATE_ENTRY_INT32(CasLength);
- DECL_STATE_ENTRY_INT32(CasSkipFlag);
- DECL_STATE_ENTRY_INT32(kbFlagFunc);
- DECL_STATE_ENTRY_INT32(kbFlagGraph);
- DECL_STATE_ENTRY_INT32(kbFlagCtrl);
- DECL_STATE_ENTRY_INT32(kanaMode);
- DECL_STATE_ENTRY_INT32(katakana);
- DECL_STATE_ENTRY_INT32(p6key);
- DECL_STATE_ENTRY_INT32(stick0);
- DECL_STATE_ENTRY_INT32(StrigIntFlag);
- DECL_STATE_ENTRY_INT32(StrigEventID);
-
- leave_decl_state();
-}
-
-void PSUB::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(is_wav);
-// state_fio->FputBool(is_p6t);
-// 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(CasIntFlag);
-// state_fio->FputInt32(CasIndex);
-// state_fio->FputInt32(CasRecv);
-// state_fio->FputInt32(CasMode);
-// state_fio->FputInt32(CasBaud);
-// state_fio->FputInt32(FileBaud);
-// state_fio->Fwrite(CasData, sizeof(CasData), 1);
-// state_fio->FputInt32(CasLength);
-// state_fio->FputInt32(CasSkipFlag);
-// state_fio->FputInt32(kbFlagFunc);
-// state_fio->FputInt32(kbFlagGraph);
-// state_fio->FputInt32(kbFlagCtrl);
-// state_fio->FputInt32(kanaMode);
-// state_fio->FputInt32(katakana);
-// state_fio->FputInt32(p6key);
-// state_fio->FputInt32(stick0);
-// state_fio->FputInt32(StrigIntFlag);
-// state_fio->FputInt32(StrigEventID);
-}
-
-bool PSUB::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;
-// }
-// play = state_fio->FgetBool();
-// rec = state_fio->FgetBool();
-// is_wav = state_fio->FgetBool();
-// is_p6t = 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;
-// }
-// }
-// CasIntFlag = state_fio->FgetInt32();
-// CasIndex = state_fio->FgetInt32();
-// CasRecv = state_fio->FgetInt32();
-// CasMode = state_fio->FgetInt32();
-// CasBaud = state_fio->FgetInt32();
-// FileBaud = state_fio->FgetInt32();
-// state_fio->Fread(CasData, sizeof(CasData), 1);
-// CasLength = state_fio->FgetInt32();
-// CasSkipFlag = state_fio->FgetInt32();
-// kbFlagFunc = state_fio->FgetInt32();
-// kbFlagGraph = state_fio->FgetInt32();
-// kbFlagCtrl = state_fio->FgetInt32();
-// kanaMode = state_fio->FgetInt32();
-// katakana = state_fio->FgetInt32();
-// p6key = state_fio->FgetInt32();
-// stick0 = state_fio->FgetInt32();
-// StrigIntFlag = state_fio->FgetInt32();
-// StrigEventID = state_fio->FgetInt32();
- return true;
-}
-
bool PSUB::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void event_frame();
void event_callback(int event_id, int err);
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_pio(DEVICE* device)
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void SUB::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_INT32(p1_out);
- DECL_STATE_ENTRY_INT32(p2_in);
- DECL_STATE_ENTRY_BOOL(drec_in);
- DECL_STATE_ENTRY_BOOL(rxrdy_in);
- DECL_STATE_ENTRY_BOOL(update_key);
- DECL_STATE_ENTRY_BOOL(rec);
- DECL_STATE_ENTRY_BOOL(is_wav);
- DECL_STATE_ENTRY_BOOL(is_p6t);
- 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(prev_command);
- DECL_STATE_ENTRY_INT32(baud);
- DECL_STATE_ENTRY_INT32(index);
- DECL_STATE_ENTRY_BOOL(skip);
- DECL_STATE_ENTRY_1D_ARRAY(buffer, sizeof(buffer));
-
- leave_decl_state();
-}
-
-void SUB::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(p1_out);
-// state_fio->FputInt32(p2_in);
-// state_fio->FputBool(drec_in);
-// state_fio->FputBool(rxrdy_in);
-// state_fio->FputBool(update_key);
-// state_fio->FputBool(rec);
-// state_fio->FputBool(is_wav);
-// state_fio->FputBool(is_p6t);
-// 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(prev_command);
-// state_fio->FputInt32(baud);
-// state_fio->FputInt32(index);
-// state_fio->FputBool(skip);
-// state_fio->Fwrite(buffer, sizeof(buffer), 1);
-}
-
-bool SUB::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;
-// }
-// p1_out = state_fio->FgetInt32();
-// p2_in = state_fio->FgetInt32();
-// drec_in = state_fio->FgetBool();
-// rxrdy_in = state_fio->FgetBool();
-// update_key = state_fio->FgetBool();
-// rec = state_fio->FgetBool();
-// is_wav = state_fio->FgetBool();
-// is_p6t = 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;
-// }
-// }
-// prev_command = state_fio->FgetInt32();
-// baud = state_fio->FgetInt32();
-// index = state_fio->FgetInt32();
-// skip = state_fio->FgetBool();
-// state_fio->Fread(buffer, sizeof(buffer), 1);
- return true;
-}
-
bool SUB::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void event_frame();
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_pio(DEVICE* device)
#include "timer.h"
#ifndef _PC6001
-#include "memory.h"
+#include "./memory.h"
#endif
#define EVENT_TIMER 0
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void TIMER::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT8(IRQ);
- DECL_STATE_ENTRY_UINT8(NewIRQ);
- DECL_STATE_ENTRY_INT32(timer_id);
-#ifndef _PC6001
-#if defined(_PC6601SR) || defined(_PC6001MK2SR)
- DECL_STATE_ENTRY_1D_ARRAY(sr_vectors, sizeof(sr_vectors));
- DECL_STATE_ENTRY_UINT8(portFA);
- DECL_STATE_ENTRY_UINT8(portFB);
-#endif
- DECL_STATE_ENTRY_UINT8(portF3);
- DECL_STATE_ENTRY_UINT8(portF4);
- DECL_STATE_ENTRY_UINT8(portF5);
- DECL_STATE_ENTRY_UINT8(portF6);
- DECL_STATE_ENTRY_UINT8(portF7);
-#endif
-
- leave_decl_state();
-}
-void TIMER::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(IRQ);
-// state_fio->FputUint8(NewIRQ);
-// state_fio->FputInt32(timer_id);
-//#ifndef _PC6001
-//#if defined(_PC6601SR) || defined(_PC6001MK2SR)
-// state_fio->Fwrite(sr_vectors, sizeof(sr_vectors), 1);
-// state_fio->FputUint8(portFA);
-// state_fio->FputUint8(portFB);
-//#endif
-// state_fio->FputUint8(portF3);
-// state_fio->FputUint8(portF4);
-// state_fio->FputUint8(portF5);
-// state_fio->FputUint8(portF6);
-// state_fio->FputUint8(portF7);
-//#endif
-}
-
-bool TIMER::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;
-// }
-// IRQ = state_fio->FgetUint8();
-// NewIRQ = state_fio->FgetUint8();
-// timer_id = state_fio->FgetInt32();
-//#ifndef _PC6001
-//#if defined(_PC6601SR) || defined(_PC6001MK2SR)
-// state_fio->Fread(sr_vectors, sizeof(sr_vectors), 1);
-// portFA = state_fio->FgetUint8();
-// portFB = state_fio->FgetUint8();
-//#endif
-// portF3 = state_fio->FgetUint8();
-// portF4 = state_fio->FgetUint8();
-// portF5 = state_fio->FgetUint8();
-// portF6 = state_fio->FgetUint8();
-// portF7 = state_fio->FgetUint8();
-//#endif
- return true;
-}
-
bool TIMER::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
#define SIG_TIMER_IRQ_EXT_INT 7
#ifndef _PC6001
-class MEMORY;
+class PC6001_MEMORY;
#endif
class TIMER : public DEVICE
private:
DEVICE *d_cpu, *d_sub;
#ifndef _PC6001
- MEMORY *d_mem;
+ PC6001_MEMORY *d_mem;
#endif
uint8_t IRQ, NewIRQ;
void write_signal(int id, uint32_t data, uint32_t mask);
uint32_t get_intr_ack();
void notify_intr_reti();
- 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)
d_sub = device;
}
#ifndef _PC6001
- void set_context_memory(MEMORY* device)
+ void set_context_memory(PC6001_MEMORY* device)
{
d_mem = device;
}
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void CMT::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_BOOL(is_wav);
- 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));
- DECL_STATE_ENTRY_INT32(prev_signal);
- DECL_STATE_ENTRY_UINT32(prev_clock);
-
- 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(is_wav);
-// 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);
-// state_fio->FputInt32(prev_signal);
-// state_fio->FputUint32(prev_clock);
-}
-
-bool CMT::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;
-// }
-// is_wav = 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);
-// prev_signal = state_fio->FgetInt32();
-// prev_clock = state_fio->FgetUint32();
- 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 rec_tape(const _TCHAR* file_path);
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void KEYBOARD::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT16(column);
- DECL_STATE_ENTRY_BOOL(caps);
- 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->FputUint16(column);
-// state_fio->FputBool(caps);
-// 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->FgetUint16();
-// caps = state_fio->FgetBool();
-// kana = state_fio->FgetBool();
- return true;
-}
-
bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
void initialize();
uint32_t read_io8(uint32_t addr);
void write_signal(int id, uint32_t data, uint32_t mask);
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void key_down(int code);
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void LCD::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- for(int i = 0; i < 10; i++) {
- DECL_STATE_ENTRY_2D_ARRAY_MEMBER((seg[i].vram), 4, 50, i);
- DECL_STATE_ENTRY_INT32_MEMBER((seg[i].updown), i);
- DECL_STATE_ENTRY_INT32_MEMBER((seg[i].disp), i);
- DECL_STATE_ENTRY_INT32_MEMBER((seg[i].spg), i);
- DECL_STATE_ENTRY_INT32_MEMBER((seg[i].page), i);
- DECL_STATE_ENTRY_INT32_MEMBER((seg[i].ofs), i);
- DECL_STATE_ENTRY_INT32_MEMBER((seg[i].ofs2), i);
- }
- DECL_STATE_ENTRY_UINT16(sel);
-
- leave_decl_state();
-}
-
-void LCD::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(seg, sizeof(seg), 1);
-// state_fio->FputUint16(sel);
-}
-
-bool LCD::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(seg, sizeof(seg), 1);
-// sel = state_fio->FgetUint16();
- return true;
-}
-
bool LCD::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(seg, sizeof(seg), 1);
+ //state_fio->StateBuffer(seg, sizeof(seg), 1);
+ for(int i = 0; i < 10; i++) {
+ state_fio->StateBuffer(&(seg[i].vram[0][0]), sizeof(seg[i].vram), 1);
+ state_fio->StateInt32(seg[i].updown);
+ state_fio->StateInt32(seg[i].disp);
+ state_fio->StateInt32(seg[i].spg);
+ state_fio->StateInt32(seg[i].page);
+ state_fio->StateInt32(seg[i].ofs);
+ state_fio->StateInt32(seg[i].ofs2);
+ }
state_fio->StateUint16(sel);
return true;
}
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 draw_screen();
} \
}
-void MEMORY::initialize()
+void PC8201_MEMORY::initialize()
{
// init memory
memset(ram, 0, sizeof(ram));
delete fio;
}
-void MEMORY::release()
+void PC8201_MEMORY::release()
{
// save ram image
FILEIO* fio = new FILEIO();
delete fio;
}
-void MEMORY::reset()
+void PC8201_MEMORY::reset()
{
sio = bank = 0;
update_bank();
}
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void PC8201_MEMORY::write_data8(uint32_t addr, uint32_t data)
{
addr &= 0xffff;
wbank[addr >> 12][addr & 0xfff] = data;
}
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t PC8201_MEMORY::read_data8(uint32_t addr)
{
addr &= 0xffff;
return rbank[addr >> 12][addr & 0xfff];
}
-void MEMORY::write_io8(uint32_t addr, uint32_t data)
+void PC8201_MEMORY::write_io8(uint32_t addr, uint32_t data)
{
switch(addr & 0xf0) {
case 0x90:
}
}
-uint32_t MEMORY::read_io8(uint32_t addr)
+uint32_t PC8201_MEMORY::read_io8(uint32_t addr)
{
// $A0: bank status
return (sio & 0xc0) | (bank & 0xf);
}
-void MEMORY::update_bank()
+void PC8201_MEMORY::update_bank()
{
switch(bank & 3) {
case 0:
#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(sio);
- 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(sio);
-// 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);
-// sio = state_fio->FgetUint8();
-// bank = state_fio->FgetUint8();
-
- // post process
- update_bank();
- return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool PC8201_MEMORY::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
[ memory ]
*/
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _PC8201_MEMORY_H_
+#define _PC8201_MEMORY_H_
#include "../vm.h"
#include "../../emu.h"
#include "../device.h"
-class MEMORY : public DEVICE
+class PC8201_MEMORY : public DEVICE
{
private:
DEVICE *d_cmt, *d_drec, *d_rtc;
void update_bank();
public:
- MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+ PC8201_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
{
set_device_name(_T("Memory Bus"));
}
- ~MEMORY() {}
+ ~PC8201_MEMORY() {}
// common functions
void initialize();
uint32_t read_data8(uint32_t addr);
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_cmt(DEVICE* device)
#include "cmt.h"
#include "keyboard.h"
#include "lcd.h"
-#include "memory.h"
+#include "./memory.h"
// ----------------------------------------------------------------------------
// initialize
cmt = new CMT(this, emu);
keyboard = new KEYBOARD(this, emu);
lcd = new LCD(this, emu);
- memory = new MEMORY(this, emu);
+ memory = new PC8201_MEMORY(this, emu);
// set contexts
event->set_context_cpu(cpu);
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
- decl_state();
rtc->write_signal(SIG_UPD1990A_STB, 0, 0);
}
#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)
-{
-#if defined(_PC8201)
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_8201_HEAD")), csp_logger);
-#elif defined(_PC8201A)
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_8201A_HEAD")), csp_logger);
-#else
- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_8201_SERIES_HEAD")), csp_logger);
-#endif
-
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->decl_state();
- }
-}
-
-void VM::save_state(FILEIO* state_fio)
-{
- //state_fio->FputUint32(STATE_VERSION);
-
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
- }
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->save_state(state_fio);
- }
-}
-
-bool VM::load_state(FILEIO* state_fio)
-{
- //if(state_fio->FgetUint32() != STATE_VERSION) {
- // return false;
- //}
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) {
- emu->out_debug_log("INFO: HEADER DATA ERROR");
- return false;
- }
- for(DEVICE* device = first_device; device; device = device->next_device) {
- if(!device->load_state(state_fio)) {
- return false;
- }
- }
- return true;
-}
-
bool VM::process_state(FILEIO* state_fio, bool loading)
{
if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- for(DEVICE* device = first_device; device; device = device->next_device) {
- const char *name = typeid(*device).name() + 6; // skip "class "
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ // Note: typeid(foo).name is fixed by recent ABI.Not dec 6.
+ // const char *name = typeid(*device).name();
+ // But, using get_device_name() instead of typeid(foo).name() 20181008 K.O
+ const char *name = device->get_device_name();
int len = strlen(name);
if(!state_fio->StateCheckInt32(len)) {
+ if(loading) {
+ printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
return false;
}
if(!state_fio->StateCheckBuffer(name, len, 1)) {
- return false;
- }
+ if(loading) {
+ printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
+ return false;
+ }
if(!device->process_state(state_fio, loading)) {
- return false;
- }
- }
+ if(loading) {
+ printf("Data loading Error: DEVID=%d\n", device->this_device_id);
+ }
+ return false;
+ }
+ }
+ // Machine specified.
return true;
}
class CMT;
class KEYBOARD;
class LCD;
-class MEMORY;
+class PC8201_MEMORY;
class VM :public VM_TEMPLATE
{
CMT* cmt;
KEYBOARD* keyboard;
LCD* lcd;
- MEMORY* memory;
+ PC8201_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