}
for(DEVICE* device = first_device; device; device = device->next_device) {
if(!device->load_state(state_fio)) {
- //printf("Load Error: DEVID=%d\n", device->this_device_id);
+ printf("Load Error: DEVID=%d\n", device->this_device_id);
return false;
}
}
#if defined(_FM77L4)
class HD46505;
#endif
-class csp_state_utils;
+
class DISPLAY: public DEVICE
{
private:
protected:
EMU *p_emu;
VM *p_vm;
- csp_state_utils *state_entry;
uint32_t (DISPLAY::*read_cpu_func_table[512])(uint32_t);
uint32_t (DISPLAY::*read_dma_func_table[512])(uint32_t);
void write_data8(uint32_t addr, uint32_t data);
void reset(void);
void release(void);
+ void decl_state();
void save_state(FILEIO *f);
bool load_state(FILEIO *f);
void set_context_rxrdy(DEVICE *p, int id, uint32_t mask) {
DECL_STATE_ENTRY_UINT8_ARRAY(opn_ch3mode, 4);
DECL_STATE_ENTRY_2D_ARRAY(opn_regs, 4, 0x100);
- //DECL_STATE_ENTRY_MULTI(void, opn_regs[0], 0x100 * sizeof(uint8_t));
- //DECL_STATE_ENTRY_MULTI(void, opn_regs[1], 0x100 * sizeof(uint8_t));
- //DECL_STATE_ENTRY_MULTI(void, opn_regs[2], 0x100 * sizeof(uint8_t));
- //DECL_STATE_ENTRY_MULTI(void, opn_regs[3], 0x100 * sizeof(uint8_t));
- //for(int ch = 0; ch < 4; ch++) {
- // DECL_STATE_ENTRY_MULTI(void, opn_regs[ch], 0x100 * sizeof(uint8_t));
- //}
}
void FM7_MAINIO::save_state(FILEIO *state_fio)
#if defined(CAPABLE_JCOMMCARD)
class FM7_JCOMMCARD;
#endif
-class csp_state_utils;
class FM7_MAINIO : public DEVICE {
protected:
protected:
VM* p_vm;
EMU* p_emu;
- csp_state_utils *state_entry;
uint8_t io_w_latch[0x100];
}
#define STATE_VERSION 7
-void FM7_MAINMEM::save_state(FILEIO *state_fio)
+
+#include "../../statesub.h"
+
+void FM7_MAINMEM::decl_state(void)
{
- state_fio->FputUint32_BE(STATE_VERSION);
- state_fio->FputInt32_BE(this_device_id);
- out_debug_log(_T("Save State: MAINMEM: id=%d ver=%d\n"), this_device_id, STATE_VERSION);
-
- // V1
- state_fio->FputBool(ioaccess_wait);
- state_fio->FputInt32_BE(waitfactor);
- state_fio->FputInt32_BE(waitcount);
- state_fio->FputBool(sub_halted);
+ state_entry = new csp_state_utils(STATE_VERSION, this_device_id, _T("MAINMEM"));
+
+ DECL_STATE_ENTRY_BOOL(ioaccess_wait);
+ DECL_STATE_ENTRY_INT32(waitfactor);
+ DECL_STATE_ENTRY_INT32(waitcount);
+ DECL_STATE_ENTRY_BOOL(sub_halted);
- state_fio->FputBool(diag_load_basicrom);
- state_fio->FputBool(diag_load_bootrom_bas);
- state_fio->FputBool(diag_load_bootrom_dos);
- state_fio->FputBool(diag_load_bootrom_mmr);
- state_fio->FputBool(diag_load_bootrom_bubble);
- state_fio->FputBool(diag_load_bootrom_bubble_128k);
- state_fio->FputBool(diag_load_bootrom_sfd8);
- state_fio->FputBool(diag_load_bootrom_2hd);
-
- state_fio->Fwrite(fm7_mainmem_omote, sizeof(fm7_mainmem_omote), 1);
- state_fio->Fwrite(fm7_mainmem_ura, sizeof(fm7_mainmem_ura), 1);
- state_fio->Fwrite(fm7_mainmem_basicrom, sizeof(fm7_mainmem_basicrom), 1);
- state_fio->Fwrite(fm7_mainmem_bioswork, sizeof(fm7_mainmem_bioswork), 1);
- state_fio->Fwrite(fm7_mainmem_bootrom_vector, sizeof(fm7_mainmem_bootrom_vector), 1);
- state_fio->Fwrite(fm7_mainmem_reset_vector, sizeof(fm7_mainmem_reset_vector), 1);
+ DECL_STATE_ENTRY_BOOL(diag_load_basicrom);
+ DECL_STATE_ENTRY_BOOL(diag_load_bootrom_bas);
+ DECL_STATE_ENTRY_BOOL(diag_load_bootrom_dos);
+ DECL_STATE_ENTRY_BOOL(diag_load_bootrom_mmr);
+ DECL_STATE_ENTRY_BOOL(diag_load_bootrom_bubble);
+ DECL_STATE_ENTRY_BOOL(diag_load_bootrom_bubble_128k);
+ DECL_STATE_ENTRY_BOOL(diag_load_bootrom_sfd8);
+ DECL_STATE_ENTRY_BOOL(diag_load_bootrom_2hd);
+
+ DECL_STATE_ENTRY_1D_ARRAY(fm7_mainmem_omote, sizeof(fm7_mainmem_omote));
+ DECL_STATE_ENTRY_1D_ARRAY(fm7_mainmem_ura, sizeof(fm7_mainmem_ura));
+ DECL_STATE_ENTRY_1D_ARRAY(fm7_mainmem_basicrom, sizeof(fm7_mainmem_basicrom));
+ DECL_STATE_ENTRY_1D_ARRAY(fm7_mainmem_bioswork, sizeof(fm7_mainmem_bioswork));
+ DECL_STATE_ENTRY_1D_ARRAY(fm7_mainmem_bootrom_vector, sizeof(fm7_mainmem_bootrom_vector));
+ DECL_STATE_ENTRY_1D_ARRAY(fm7_mainmem_reset_vector, sizeof(fm7_mainmem_reset_vector));
- state_fio->Fwrite(fm7_mainmem_null, sizeof(fm7_mainmem_null), 1);
+ DECL_STATE_ENTRY_1D_ARRAY(fm7_mainmem_null, sizeof(fm7_mainmem_null));
+
#if defined(_FM77AV_VARIANTS) || defined(_FM77_VARIANTS)
- state_fio->Fwrite(fm7_bootram, sizeof(fm7_bootram), 1);
+ DECL_STATE_ENTRY_1D_ARRAY(fm7_bootram, sizeof(fm7_bootram));
#endif
#if defined(_FM77_VARIANTS) || defined(_FM8)
- for(int i = 0; i < 8; i++) state_fio->Fwrite(fm7_bootroms[i], sizeof(0x200), 1);
+ for(int i = 0; i < 8; i++) DECL_STATE_ENTRY_1D_ARRAY(fm7_bootroms[i], 0x200);
#elif defined(_FM7) || defined(_FMNEW7)
- for(int i = 0; i < 4; i++) state_fio->Fwrite(fm7_bootroms[i], sizeof(0x200), 1);
+ for(int i = 0; i < 4; i++) DECL_STATE_ENTRY_1D_ARRAY(fm7_bootroms[i], 0x200);
#endif
+
#if defined(_FM8)
- state_fio->FputBool(diag_load_sm11_14);
- state_fio->FputBool(diag_load_sm11_15);
+ DECL_STATE_ENTRY_BOOL(diag_load_sm11_14);
+ DECL_STATE_ENTRY_BOOL(diag_load_sm11_15);
#elif defined(_FM77_VARIANTS)
- state_fio->FputBool(diag_load_wb11_12);
+ DECL_STATE_ENTRY_BOOL(diag_load_wb11_12);
#elif defined(_FM7) || defined(_FMNEW7)
- state_fio->FputBool(diag_load_tl11_11);
+ DECL_STATE_ENTRY_BOOL(diag_load_tl11_11);
# if defined(_FMNEW7)
- state_fio->FputBool(diag_load_tl11_12);
+ DECL_STATE_ENTRY_BOOL(diag_load_tl11_12);
# endif
#elif defined(_FM77AV_VARIANTS)
- state_fio->FputBool(dictrom_connected);
- state_fio->FputBool(use_page2_extram);
+ DECL_STATE_ENTRY_BOOL(dictrom_connected);
+ DECL_STATE_ENTRY_BOOL(use_page2_extram);
- state_fio->FputBool(diag_load_initrom);
- state_fio->FputBool(diag_load_dictrom);
- state_fio->FputBool(diag_load_learndata);
- state_fio->Fwrite(fm7_mainmem_initrom, sizeof(fm7_mainmem_initrom), 1);
- state_fio->Fwrite(fm77av_hidden_bootmmr, sizeof(fm77av_hidden_bootmmr), 1);
+ DECL_STATE_ENTRY_BOOL(diag_load_initrom);
+ DECL_STATE_ENTRY_BOOL(diag_load_dictrom);
+ DECL_STATE_ENTRY_BOOL(diag_load_learndata);
+ DECL_STATE_ENTRY_1D_ARRAY(fm7_mainmem_initrom, sizeof(fm7_mainmem_initrom));
+ DECL_STATE_ENTRY_1D_ARRAY(fm77av_hidden_bootmmr, sizeof(fm77av_hidden_bootmmr));
- state_fio->Fwrite(fm7_mainmem_mmrbank_0, sizeof(fm7_mainmem_mmrbank_0), 1);
- state_fio->Fwrite(fm7_mainmem_mmrbank_2, sizeof(fm7_mainmem_mmrbank_2), 1);
+ DECL_STATE_ENTRY_1D_ARRAY(fm7_mainmem_mmrbank_0, sizeof(fm7_mainmem_mmrbank_0));
+ DECL_STATE_ENTRY_1D_ARRAY(fm7_mainmem_mmrbank_2, sizeof(fm7_mainmem_mmrbank_2));
# if defined(_FM77AV40EX) || defined(_FM77AV40SX)
- state_fio->FputBool(diag_load_extrarom);
- state_fio->Fwrite(fm7_mainmem_extrarom, sizeof(fm7_mainmem_extrarom), 1);
+ DECL_STATE_ENTRY_BOOL(diag_load_extrarom);
+ DECL_STATE_ENTRY_1D_ARRAY(fm7_mainmem_extrarom, sizeof(fm7_mainmem_extrarom));
# endif
# if defined(CAPABLE_DICTROM)
- state_fio->Fwrite(fm7_mainmem_dictrom, sizeof(fm7_mainmem_dictrom), 1);
- state_fio->Fwrite(fm7_mainmem_learndata, sizeof(fm7_mainmem_learndata), 1);
+ DECL_STATE_ENTRY_1D_ARRAY(fm7_mainmem_dictrom, sizeof(fm7_mainmem_dictrom));
+ DECL_STATE_ENTRY_1D_ARRAY(fm7_mainmem_learndata, sizeof(fm7_mainmem_learndata));
# endif
#endif
-
+
#ifdef HAS_MMR
- state_fio->FputBool(extram_connected);
+ DECL_STATE_ENTRY_BOOL(extram_connected);
# if defined(_FM77AV40) || defined(_FM77AV40EX) || defined(_FM77AV40SX) || \
defined(_FM77_VARIANTS)
- int pages;
- state_fio->FputInt32_BE(extram_pages);
- pages = extram_pages;
+ DECL_STATE_ENTRY_INT32(extram_pages);
+ DECL_STATE_ENTRY_VARARRAY_VAR(fm7_mainmem_extram, extram_size);
# if defined(_FM77_VARIANTS)
- if(pages > 3) pages = 3;
-# else
- if(pages > 12) pages = 12;
-# endif
- if(pages > 0) state_fio->Fwrite(fm7_mainmem_extram, pages * 0x10000, 1);
-# if defined(_FM77_VARIANTS)
- state_fio->Fwrite(fm77_shadowram, sizeof(fm77_shadowram), 1);
+ DECL_STATE_ENTRY_1D_ARRAY(fm77_shadowram, sizeof(fm77_shadowram));
# endif
# endif
#endif
-
+
{ // V2;
- state_fio->FputBool(is_basicrom);
- state_fio->FputBool(clockmode);
- state_fio->FputBool(basicrom_fd0f);
- state_fio->FputUint32_BE(bootmode);
+ DECL_STATE_ENTRY_BOOL(is_basicrom);
+ DECL_STATE_ENTRY_BOOL(clockmode);
+ DECL_STATE_ENTRY_BOOL(basicrom_fd0f);
+ DECL_STATE_ENTRY_UINT32(bootmode);
#if defined(_FM77AV_VARIANTS)
- state_fio->FputUint32_BE(extcard_bank);
- state_fio->FputBool(extrom_bank);
- state_fio->FputBool(initiator_enabled);
- state_fio->FputBool(dictrom_enabled);
- state_fio->FputBool(dictram_enabled);
+ DECL_STATE_ENTRY_UINT32(extcard_bank);
+ DECL_STATE_ENTRY_BOOL(extrom_bank);
+ DECL_STATE_ENTRY_BOOL(initiator_enabled);
+ DECL_STATE_ENTRY_BOOL(dictrom_enabled);
+ DECL_STATE_ENTRY_BOOL(dictram_enabled);
#endif
#if defined(_FM77AV_VARIANTS) || defined(_FM77_VARIANTS)
- state_fio->FputBool(boot_ram_write);
+ DECL_STATE_ENTRY_BOOL(boot_ram_write);
#endif
#if defined(HAS_MMR)
- state_fio->FputBool(window_enabled);
- state_fio->FputBool(mmr_enabled);
- state_fio->FputBool(mmr_fast);
- state_fio->FputBool(mmr_extend);
+ DECL_STATE_ENTRY_BOOL(window_enabled);
+ DECL_STATE_ENTRY_BOOL(mmr_enabled);
+ DECL_STATE_ENTRY_BOOL(mmr_fast);
+ DECL_STATE_ENTRY_BOOL(mmr_extend);
- state_fio->FputUint16_BE(window_offset);
- state_fio->FputBool(window_fast);
- state_fio->FputBool(refresh_fast);
- state_fio->FputUint8(mmr_segment);
- state_fio->Fwrite(mmr_map_data, sizeof(mmr_map_data), 1);
+ DECL_STATE_ENTRY_UINT16(window_offset);
+ DECL_STATE_ENTRY_BOOL(window_fast);
+ DECL_STATE_ENTRY_BOOL(refresh_fast);
+ DECL_STATE_ENTRY_UINT8(mmr_segment);
+ DECL_STATE_ENTRY_1D_ARRAY(mmr_map_data, sizeof(mmr_map_data));
#endif
}
- state_fio->FputUint32_BE(mem_waitfactor); // OK?
- state_fio->FputUint32_BE(mem_waitcount); // OK?
+ DECL_STATE_ENTRY_UINT32(mem_waitfactor); // OK?
+ DECL_STATE_ENTRY_UINT32(mem_waitcount); // OK?
- state_fio->FputUint32_BE(cpu_clocks); // OK?
+ DECL_STATE_ENTRY_UINT32(cpu_clocks); // OK?
}
-bool FM7_MAINMEM::load_state(FILEIO *state_fio)
+void FM7_MAINMEM::save_state(FILEIO *state_fio)
{
- uint32_t version;
- version = state_fio->FgetUint32_BE();
- if(this_device_id != state_fio->FgetInt32_BE()) return false;
- out_debug_log(_T("Load State: MAINMEM: id=%d ver=%d\n"), this_device_id, version);
- if(version >= 1) {
- // V1
- ioaccess_wait = state_fio->FgetBool();
- waitfactor = state_fio->FgetInt32_BE();
- waitcount = state_fio->FgetInt32_BE();
-
- sub_halted = state_fio->FgetBool();
-
- diag_load_basicrom = state_fio->FgetBool();
- diag_load_bootrom_bas = state_fio->FgetBool();
- diag_load_bootrom_dos = state_fio->FgetBool();
- diag_load_bootrom_mmr = state_fio->FgetBool();
- diag_load_bootrom_bubble = state_fio->FgetBool();
- diag_load_bootrom_bubble_128k = state_fio->FgetBool();
- diag_load_bootrom_sfd8 = state_fio->FgetBool();
- diag_load_bootrom_2hd = state_fio->FgetBool();
-
- state_fio->Fread(fm7_mainmem_omote, sizeof(fm7_mainmem_omote), 1);
- state_fio->Fread(fm7_mainmem_ura, sizeof(fm7_mainmem_ura), 1);
- state_fio->Fread(fm7_mainmem_basicrom, sizeof(fm7_mainmem_basicrom), 1);
- state_fio->Fread(fm7_mainmem_bioswork, sizeof(fm7_mainmem_bioswork), 1);
- state_fio->Fread(fm7_mainmem_bootrom_vector, sizeof(fm7_mainmem_bootrom_vector), 1);
- state_fio->Fread(fm7_mainmem_reset_vector, sizeof(fm7_mainmem_reset_vector), 1);
-
- state_fio->Fread(fm7_mainmem_null, sizeof(fm7_mainmem_null), 1);
-#if defined(_FM77AV_VARIANTS) || defined(_FM77_VARIANTS)
- state_fio->Fread(fm7_bootram, sizeof(fm7_bootram), 1);
-#endif
-#if defined(_FM77_VARIANTS) || defined(_FM8)
- for(int i = 0; i < 8; i++) state_fio->Fread(fm7_bootroms[i], sizeof(0x200), 1);
-#elif defined(_FM7) || defined(_FMNEW7)
- for(int i = 0; i < 4; i++) state_fio->Fread(fm7_bootroms[i], sizeof(0x200), 1);
-#endif
-#if defined(_FM8)
- diag_load_sm11_14 = state_fio->FgetBool();
- diag_load_sm11_15 = state_fio->FgetBool();
-#elif defined(_FM77_VARIANTS)
- diag_load_wb11_12 = state_fio->FgetBool();
-#elif defined(_FM7) || defined(_FMNEW7)
- diag_load_tl11_11 = state_fio->FgetBool();
-# if defined(_FMNEW7)
- diag_load_tl11_12 = state_fio->FgetBool();
-# endif
-#elif defined(_FM77AV_VARIANTS)
- dictrom_connected = state_fio->FgetBool();
- use_page2_extram = state_fio->FgetBool();
-
- diag_load_initrom = state_fio->FgetBool();
- diag_load_dictrom = state_fio->FgetBool();
- diag_load_learndata = state_fio->FgetBool();
- state_fio->Fread(fm7_mainmem_initrom, sizeof(fm7_mainmem_initrom), 1);
- state_fio->Fread(fm77av_hidden_bootmmr, sizeof(fm77av_hidden_bootmmr), 1);
-
- state_fio->Fread(fm7_mainmem_mmrbank_0, sizeof(fm7_mainmem_mmrbank_0), 1);
- state_fio->Fread(fm7_mainmem_mmrbank_2, sizeof(fm7_mainmem_mmrbank_2), 1);
-
-# if defined(_FM77AV40EX) || defined(_FM77AV40SX)
- diag_load_extrarom = state_fio->FgetBool();
- state_fio->Fread(fm7_mainmem_extrarom, sizeof(fm7_mainmem_extrarom), 1);
-# endif
-# if defined(CAPABLE_DICTROM)
- state_fio->Fread(fm7_mainmem_dictrom, sizeof(fm7_mainmem_dictrom), 1);
- state_fio->Fread(fm7_mainmem_learndata, sizeof(fm7_mainmem_learndata), 1);
-# endif
-#endif
-
-#ifdef HAS_MMR
- extram_connected = state_fio->FgetBool();
-# if defined(_FM77AV40) || defined(_FM77AV40EX) || defined(_FM77AV40SX) || \
- defined(_FM77_VARIANTS)
- int pages;
- extram_pages = state_fio->FgetInt32_BE();
- pages = extram_pages;
-# if defined(_FM77_VARIANTS)
- if(pages > 3) pages = 3;
-# else
- if(pages > 12) pages = 12;
-# endif
- if(fm7_mainmem_extram != NULL) {
- free(fm7_mainmem_extram);
- fm7_mainmem_extram = NULL;
- }
- if(pages > 0) {
- fm7_mainmem_extram = (uint8_t *)malloc(pages * 0x10000);
- state_fio->Fread(fm7_mainmem_extram, pages * 0x10000, 1);
- }
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+#if defined(HAS_MMR)
# if defined(_FM77_VARIANTS)
- state_fio->Fread(fm77_shadowram, sizeof(fm77_shadowram), 1);
+ if(extram_pages > 3) extram_pages = 3;
+# elif defined(_FM77AV40) || defined(_FM77AV40EX) || defined(_FM77AV40SX)
+ if(extram_pages > 12) extram_pages = 12;
# endif
-# endif
#endif
- if(version == 1) return true;
+ //extram_size = extram_pages * 0x10000;
+}
+
+bool FM7_MAINMEM::load_state(FILEIO *state_fio)
+{
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
+ this->out_debug_log(_T("Load State: MAINIO: id=%d stat=%s\n"), this_device_id, (mb) ? _T("OK") : _T("NG"));
+ if(!mb) return false;
}
- { // V2;
- is_basicrom = state_fio->FgetBool();
- clockmode = state_fio->FgetBool();
- basicrom_fd0f = state_fio->FgetBool();
- bootmode = state_fio->FgetUint32_BE();
-#if defined(_FM77AV_VARIANTS)
- extcard_bank = state_fio->FgetUint32_BE();
- extrom_bank = state_fio->FgetBool();
- initiator_enabled = state_fio->FgetBool();
- dictrom_enabled = state_fio->FgetBool();
- dictram_enabled = state_fio->FgetBool();
-#endif
-#if defined(_FM77AV_VARIANTS) || defined(_FM77_VARIANTS)
- boot_ram_write = state_fio->FgetBool();
-#endif
#if defined(HAS_MMR)
- window_enabled = state_fio->FgetBool();
- mmr_enabled = state_fio->FgetBool();
- mmr_fast = state_fio->FgetBool();
- mmr_extend = state_fio->FgetBool();
-
- window_offset = state_fio->FgetUint16_BE();
- window_fast = state_fio->FgetBool();
- refresh_fast = state_fio->FgetBool();
- mmr_segment = state_fio->FgetUint8();
- state_fio->Fread(mmr_map_data, sizeof(mmr_map_data), 1);
+# if defined(_FM77_VARIANTS)
+ if(extram_pages > 3) extram_pages = 3;
+# elif defined(_FM77AV40) || defined(_FM77AV40EX) || defined(_FM77AV40SX)
+ if(extram_pages > 12) extram_pages = 12;
+# endif
#endif
- }
- mem_waitfactor = state_fio->FgetUint32_BE();
- mem_waitcount = state_fio->FgetUint32_BE();
-
- cpu_clocks = state_fio->FgetUint32_BE();
-
+ //extram_size = extram_pages * 0x10000;
init_data_table();
update_all_mmr_jumptable();
- if(version != STATE_VERSION) return false;
return true;
}
bool diag_load_extrarom;
uint8_t fm7_mainmem_extrarom[0x10000]; // $20000-$2bfff, banked
int extram_pages;
+ uint32_t extram_size;
uint8_t *fm7_mainmem_extram; // $40000- : MAX 768KB ($c0000)
# endif
# endif
# if defined(_FM77_VARIANTS)
int extram_pages;
+ uint32_t extram_size;
uint8_t *fm7_mainmem_extram; // $00000-$2ffff
uint8_t fm77_shadowram[0x200];
# endif
bool get_loadstat_basicrom(void);
bool get_loadstat_bootrom_bas(void);
bool get_loadstat_bootrom_dos(void);
+ void decl_state();
void save_state(FILEIO *state_fio);
void update_config();
bool load_state(FILEIO *state_fio);
#define STATE_VERSION 3
#include "../../statesub.h"
+
void BUBBLECASETTE::decl_state(void)
{
state_entry = new csp_state_utils(STATE_VERSION, this_device_id, _T("BUBBLE_CASETTE"));
};
class VM;
class EMU;
-class csp_state_utils;
class HD6844: public DEVICE {
protected:
// HACKs
outputs_t interrupt_line; // 20180117 K.O
outputs_t busreq_line[2];
- csp_state_utils *state_entry;
// Registers
uint32_t addr_reg[4];
state_entry = new csp_state_utils(STATE_VERSION, this_device_id, _T("FM7_JCOMM_CARD"));
DECL_STATE_ENTRY_SINGLE(n_bank);
- DECL_STATE_ENTRY_SINGLE(rcb_address);
+ DECL_STATE_ENTRY_SINGLE(rcb_address);
DECL_STATE_ENTRY_SINGLE(kanji_address);
DECL_STATE_ENTRY_SINGLE(halted);
- DECL_STATE_ENTRY_1DARRAY(prog_rom, 0x4000);
- DECL_STATE_ENTRY_1DARRAY(dict_rom, 0x60000);
- DECL_STATE_ENTRY_1DARRAY(p_ram, 0x2000);
+ DECL_STATE_ENTRY_1D_ARRAY(prog_rom, 0x4000);
+ DECL_STATE_ENTRY_1D_ARRAY(dict_rom, 0x60000);
+ DECL_STATE_ENTRY_1D_ARRAY(p_ram, 0x2000);
DECL_STATE_ENTRY_BOOL(firmware_ok);
}
#include "../device.h"
#include "../../common.h"
-class csp_state_utils;
class MC6809;
class FM7_JCOMMCARD : public DEVICE {
private:
MC6809 *cpu;
- csp_state_utils* state_entry;
uint8_t n_bank;
uint8_t rcb_address;
pair_t kanji_address;
#endif
}
#define STATE_VERSION 4
-void JOYSTICK::save_state(FILEIO *state_fio)
+
+#include "../../statesub.h"
+
+void JOYSTICK::decl_state()
{
- int ch;
- state_fio->FputUint32_BE(STATE_VERSION);
- state_fio->FputInt32_BE(this_device_id);
- this->out_debug_log(_T("Save State: JOYSTICK: id=%d ver=%d\n"), this_device_id, STATE_VERSION);
- // Version 1
- for(ch = 0; ch < 2; ch++) {
+ state_entry = new csp_state_utils(STATE_VERSION, this_device_id, _T("JOYSTICK"));
+
#if !defined(_FM8)
- state_fio->FputBool(emulate_mouse[ch]);
+ DECL_STATE_ENTRY_1D_ARRAY(emulate_mouse, 2);
#endif
- state_fio->FputUint32_BE(joydata[ch]);
- }
- // After Version2.
+ DECL_STATE_ENTRY_1D_ARRAY(joydata, 2);
+
#if !defined(_FM8)
- state_fio->FputInt32_BE(dx);
- state_fio->FputInt32_BE(dy);
- state_fio->FputInt32_BE(lx);
- state_fio->FputInt32_BE(ly);
- state_fio->FputUint32_BE(mouse_button);
- state_fio->FputBool(mouse_strobe);
- state_fio->FputUint32_BE(mouse_phase);
- state_fio->FputUint32_BE(mouse_data);
- //state_fio->FputInt32(mouse_timeout_event);
+ DECL_STATE_ENTRY_INT32(dx);
+ DECL_STATE_ENTRY_INT32(dy);
+ DECL_STATE_ENTRY_INT32(lx);
+ DECL_STATE_ENTRY_INT32(ly);
+ DECL_STATE_ENTRY_UINT32(mouse_button);
+ DECL_STATE_ENTRY_BOOL(mouse_strobe);
+ DECL_STATE_ENTRY_UINT32(mouse_phase);
+ DECL_STATE_ENTRY_INT32(mouse_data);
+ //DECL_STATE_ENTRY_INT32(mouse_timeout_event);
#endif
// Version 3
- state_fio->FputUint8(lpmask);
+ DECL_STATE_ENTRY_UINT8(lpmask);
// Version 4
- state_fio->FputUint8(port_b_val);
+ DECL_STATE_ENTRY_UINT8(port_b_val);
+}
+void JOYSTICK::save_state(FILEIO *state_fio)
+{
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
}
bool JOYSTICK::load_state(FILEIO *state_fio)
{
- uint32_t version = state_fio->FgetUint32_BE();
- int32_t devid = state_fio->FgetInt32_BE();
- bool stat = false;
- int ch;
- this->out_debug_log(_T("Load State: JOYSTICK: id=%d ver=%d\n"), devid, version);
- if(devid != this_device_id) return stat;
- if(version >= 1) {
- for(ch = 0; ch < 2; ch++) {
-#if !defined(_FM8)
- emulate_mouse[ch] = state_fio->FgetBool();
-#endif
- joydata[ch] = state_fio->FgetUint32_BE();
- }
- //if(version == 1) stat = true;
+ bool mb;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
+ if(!mb) return false;
}
-#if !defined(_FM8)
- // After version 2.
- dx = state_fio->FgetInt32_BE();
- dy = state_fio->FgetInt32_BE();
- lx = state_fio->FgetInt32_BE();
- ly = state_fio->FgetInt32_BE();
- mouse_button = state_fio->FgetUint32_BE();
- mouse_strobe = state_fio->FgetBool();
- mouse_phase = state_fio->FgetUint32_BE();
- mouse_data = state_fio->FgetUint32_BE();
- //mouse_timeout_event = state_fio->FgetInt32();
-#endif
- // V3
- lpmask = state_fio->FgetUint8();
- lpt_type = config.printer_type;
- // V4
- port_b_val = state_fio->FgetUint8();
- if(version == STATE_VERSION) stat = true;
- return stat;
+ return true;
}
VM* p_vm;
EMU* p_emu;
DEVICE *opn;
+
private:
uint32_t update_mouse(uint32_t mask);
void update_strobe(bool flag);
void reset(void);
void update_config();
+ void decl_state();
void save_state(FILEIO *state_fio);
bool load_state(FILEIO *state_fio);
}
#define STATE_VERSION 4
-void KANJIROM::save_state(FILEIO *state_fio)
-{
- state_fio->FputUint32_BE(STATE_VERSION);
- state_fio->FputInt32_BE(this_device_id);
- this->out_debug_log(_T("Save State: KANJIROM: id=%d ver=%d\n"), this_device_id, STATE_VERSION);
- state_fio->FputBool(class2);
- state_fio->FputBool(read_ok);
- state_fio->Fwrite(data_table, sizeof(data_table), 1);
- state_fio->FputUint16_BE(kanjiaddr.w.l);
+#include "../../statesub.h"
+void KANJIROM::decl_state()
+{
+ state_entry = new csp_state_utils(STATE_VERSION, this_device_id, _T("KANJI_ROM"));
+ DECL_STATE_ENTRY_BOOL(class2);
+ DECL_STATE_ENTRY_BOOL(read_ok);
+ DECL_STATE_ENTRY_1D_ARRAY(data_table, sizeof(data_table));
+ DECL_STATE_ENTRY_PAIR(kanjiaddr);
+}
+void KANJIROM::save_state(FILEIO *state_fio)
+{
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
}
bool KANJIROM::load_state(FILEIO *state_fio)
{
- uint32_t version;
- version = state_fio->FgetUint32_BE();
- if(this_device_id != state_fio->FgetInt32_BE()) return false;
- this->out_debug_log(_T("Load State: KANJIROM: id=%d ver=%d\n"), this_device_id, version);
-
- if(version >= 1) {
- class2 = state_fio->FgetBool();
- read_ok = state_fio->FgetBool();
- state_fio->Fread(data_table, sizeof(data_table), 1);
- if(version == 1) return true;
- }
- if(version >= 2) {
- kanjiaddr.d = 0;
- kanjiaddr.w.l = state_fio->FgetUint16_BE();
- if(version >= 2) return true;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- return false;
+ if(!mb) return false;
+ kanjiaddr.w.h = 0;
+ return true;
}
#include "./fm7.h"
#include "fm7_common.h"
#include "../device.h"
+
class EMU;
class VM;
class KANJIROM: public DEVICE {
private:
EMU *p_emu;
+
uint8_t data_table[0x20000];
bool read_ok;
bool class2;
void release();
void reset(void);
bool get_readstat(void);
-
+
+ void decl_state();
void save_state(FILEIO *state_fio);
bool load_state(FILEIO *state_fio);
};
{
}
-#define STATE_VERSION 6
+#define STATE_VERSION 7
#if defined(Q_OS_WIN)
DLL_PREFIX_I struct cur_time_s cur_time;
#endif
-void KEYBOARD::save_state(FILEIO *state_fio)
-{
- state_fio->FputUint32_BE(STATE_VERSION);
- state_fio->FputInt32_BE(this_device_id);
- this->out_debug_log(_T("Save State: KEYBOARD: id=%d ver=%d\n"), this_device_id, STATE_VERSION);
- // Version 1
- {
- state_fio->FputUint32_BE(keycode_7);
- state_fio->FputInt32_BE(keymode);
+#include "../../statesub.h"
+
+void KEYBOARD::decl_state()
+{
+#if defined(_FM77AV_VARIANTS)
+ state_entry = new csp_state_utils(STATE_VERSION, this_device_id, _T("KEYBOARD_AND_RTC"));
+#else
+ state_entry = new csp_state_utils(STATE_VERSION, this_device_id, _T("KEYBOARD"));
+#endif
+
+ DECL_STATE_ENTRY_UINT32(keycode_7);
+ DECL_STATE_ENTRY_INT32(keymode);
- state_fio->FputBool(ctrl_pressed);
- state_fio->FputBool(lshift_pressed);
- state_fio->FputBool(rshift_pressed);
- state_fio->FputBool(shift_pressed);
- state_fio->FputBool(graph_pressed);
- state_fio->FputBool(caps_pressed);
- state_fio->FputBool(kana_pressed);
- state_fio->FputBool(break_pressed);
-
- state_fio->FputInt32_BE(event_keyrepeat);
+ DECL_STATE_ENTRY_BOOL(ctrl_pressed);
+ DECL_STATE_ENTRY_BOOL(lshift_pressed);
+ DECL_STATE_ENTRY_BOOL(rshift_pressed);
+ DECL_STATE_ENTRY_BOOL(shift_pressed);
+ DECL_STATE_ENTRY_BOOL(graph_pressed);
+ DECL_STATE_ENTRY_BOOL(caps_pressed);
+ DECL_STATE_ENTRY_BOOL(kana_pressed);
+ DECL_STATE_ENTRY_BOOL(break_pressed);
+
+ DECL_STATE_ENTRY_INT32(event_keyrepeat);
- state_fio->FputUint8(scancode); // After V.4, uint8_t
- state_fio->FputUint8(datareg);
- state_fio->FputUint32(older_vk);
+ DECL_STATE_ENTRY_UINT8(scancode); // After V.4, uint8_t
+ DECL_STATE_ENTRY_UINT8(datareg);
+ DECL_STATE_ENTRY_UINT32(older_vk);
- state_fio->FputBool(repeat_mode);
- state_fio->FputInt32_BE(repeat_time_short);
- state_fio->FputInt32_BE(repeat_time_long);
- state_fio->FputUint8(repeat_keycode);
+ DECL_STATE_ENTRY_BOOL(repeat_mode);
+ DECL_STATE_ENTRY_INT32(repeat_time_short);
+ DECL_STATE_ENTRY_INT32(repeat_time_long);
+ DECL_STATE_ENTRY_UINT8(repeat_keycode);
#if defined(_FM77AV_VARIANTS)
- state_fio->FputInt32_BE(event_key_rtc);
+ DECL_STATE_ENTRY_INT32(event_key_rtc);
- state_fio->FputUint8(rtc_yy);
- state_fio->FputUint8(rtc_mm);
- state_fio->FputUint8(rtc_dd);
- state_fio->FputUint8(rtc_dayofweek);
- state_fio->FputUint8(rtc_hour);
- state_fio->FputUint8(rtc_minute);
- state_fio->FputUint8(rtc_sec);
-
- state_fio->FputBool(rtc_count24h);
- state_fio->FputBool(rtc_ispm);
-
- state_fio->FputBool(rtc_set);
- state_fio->FputBool(rtc_set_flag);
- state_fio->FputBool(rxrdy_status);
- state_fio->FputBool(key_ack_status);
- state_fio->FputInt32_BE(cmd_phase);
-
- state_fio->FputInt32_BE(event_hidden1_av);
- state_fio->FputUint16_BE(hidden1_ptr);
-
- cmd_fifo->save_state((void *)state_fio);
- data_fifo->save_state((void *)state_fio);
- cur_time.save_state((void *)state_fio);
-#endif
- state_fio->FputInt32_BE(event_int);
- key_fifo->save_state((void *)state_fio);
- }
- // Version 2
- {
-#if defined(_FM77AV_VARIANTS)
- state_fio->FputBool(did_hidden_message_av_1);
+ DECL_STATE_ENTRY_UINT8(rtc_yy);
+ DECL_STATE_ENTRY_UINT8(rtc_mm);
+ DECL_STATE_ENTRY_UINT8(rtc_dd);
+ DECL_STATE_ENTRY_UINT8(rtc_dayofweek);
+ DECL_STATE_ENTRY_UINT8(rtc_hour);
+ DECL_STATE_ENTRY_UINT8(rtc_minute);
+ DECL_STATE_ENTRY_UINT8(rtc_sec);
+
+ DECL_STATE_ENTRY_BOOL(rtc_count24h);
+ DECL_STATE_ENTRY_BOOL(rtc_ispm);
+
+ DECL_STATE_ENTRY_BOOL(rtc_set);
+ DECL_STATE_ENTRY_BOOL(rtc_set_flag);
+ DECL_STATE_ENTRY_BOOL(rxrdy_status);
+ DECL_STATE_ENTRY_BOOL(key_ack_status);
+
+ DECL_STATE_ENTRY_BOOL(did_hidden_message_av_1);
+ DECL_STATE_ENTRY_INT32(event_hidden1_av);
+
+ DECL_STATE_ENTRY_INT32(cmd_phase);
+ DECL_STATE_ENTRY_UINT16(hidden1_ptr);
+ DECL_STATE_ENTRY_INT32(beep_phase);
+ //cmd_fifo->save_state((void *)state_fio);
+ //data_fifo->save_state((void *)state_fio);
+ //cur_time.save_state((void *)state_fio);
#endif
+ DECL_STATE_ENTRY_INT32(event_int);
+ //key_fifo->save_state((void *)state_fio);
+ DECL_STATE_ENTRY_UINT8(autokey_backup);
+ // Version 5
+ DECL_STATE_ENTRY_BOOL(ins_led_status);
+ DECL_STATE_ENTRY_BOOL(kana_led_status);
+ DECL_STATE_ENTRY_BOOL(caps_led_status);
+ // Version 6
+ DECL_STATE_ENTRY_BOOL(override_break_key);
+}
+
+void KEYBOARD::save_state(FILEIO *state_fio)
+{
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
}
- // Version 3
- {
+ //state_fio->FputUint32_BE(STATE_VERSION);
+ //state_fio->FputInt32_BE(this_device_id);
+ this->out_debug_log(_T("Save State: KEYBOARD: id=%d ver=%d\n"), this_device_id, STATE_VERSION);
+
+// ToDo: DECL_STATE_foo() for FIFO:: and cur_time_t:: .
#if defined(_FM77AV_VARIANTS)
- state_fio->FputInt32_BE(beep_phase);
+ cmd_fifo->save_state((void *)state_fio);
+ data_fifo->save_state((void *)state_fio);
+ cur_time.save_state((void *)state_fio);
#endif
- }
- // Version 4
- state_fio->FputUint8(autokey_backup);
- // Version 5
- state_fio->FputBool(ins_led_status);
- state_fio->FputBool(kana_led_status);
- state_fio->FputBool(caps_led_status);
- // Version 6
- state_fio->FputBool(override_break_key);
+ key_fifo->save_state((void *)state_fio);
}
bool KEYBOARD::load_state(FILEIO *state_fio)
{
uint32_t version;
- version = state_fio->FgetUint32_BE();
- if(this_device_id != state_fio->FgetInt32_BE()) return false;
- this->out_debug_log(_T("Load State: KEYBOARD: id=%d ver=%d\n"), this_device_id, version);
-
- if(version >= 1) {
- keycode_7 = state_fio->FgetUint32_BE();
- keymode = state_fio->FgetInt32_BE();
-
- ctrl_pressed = state_fio->FgetBool();
- lshift_pressed = state_fio->FgetBool();
- rshift_pressed = state_fio->FgetBool();
- shift_pressed = state_fio->FgetBool();
- graph_pressed = state_fio->FgetBool();
- caps_pressed = state_fio->FgetBool();
- kana_pressed = state_fio->FgetBool();
- break_pressed = state_fio->FgetBool();
-
- event_keyrepeat = state_fio->FgetInt32_BE();
-
- scancode = state_fio->FgetUint8();
- datareg = state_fio->FgetUint8();
- older_vk = state_fio->FgetUint32();
-
- repeat_mode = state_fio->FgetBool();
- repeat_time_short = state_fio->FgetInt32_BE();
- repeat_time_long = state_fio->FgetInt32_BE();
- repeat_keycode = state_fio->FgetUint8();
-
-#if defined(_FM77AV_VARIANTS)
- event_key_rtc = state_fio->FgetInt32_BE();
- rtc_yy = state_fio->FgetUint8();
- rtc_mm = state_fio->FgetUint8();
- rtc_dd = state_fio->FgetUint8();
- rtc_dayofweek = state_fio->FgetUint8();
- rtc_hour = state_fio->FgetUint8();
- rtc_minute = state_fio->FgetUint8();
- rtc_sec = state_fio->FgetUint8();
-
- rtc_count24h = state_fio->FgetBool();
- rtc_ispm = state_fio->FgetBool();
-
- rtc_set = state_fio->FgetBool();
- rtc_set_flag = state_fio->FgetBool();
- rxrdy_status = state_fio->FgetBool();
- key_ack_status = state_fio->FgetBool();
- cmd_phase = state_fio->FgetInt32_BE();
-
- event_hidden1_av = state_fio->FgetInt32_BE();
- hidden1_ptr = state_fio->FgetUint16_BE();
-
- cmd_fifo->load_state((void *)state_fio);
- data_fifo->load_state((void *)state_fio);
- cur_time.load_state((void *)state_fio);
-#endif
- event_int = state_fio->FgetInt32_BE();
- key_fifo->load_state((void *)state_fio);
- if(version == 1) return true;
+ //version = state_fio->FgetUint32_BE();
+ //if(this_device_id != state_fio->FgetInt32_BE()) return false;
+ //this->out_debug_log(_T("Load State: KEYBOARD: id=%d ver=%d\n"), this_device_id, version);
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- // Version 2
- {
+ if(!mb) return false;
#if defined(_FM77AV_VARIANTS)
- did_hidden_message_av_1 = state_fio->FgetBool();
+ if(!(cmd_fifo->load_state((void *)state_fio))) return false;
+ if(!(data_fifo->load_state((void *)state_fio))) return false;
+ if(!(cur_time.load_state((void *)state_fio))) return false;
#endif
- }
- // Version 3
- {
-#if defined(_FM77AV_VARIANTS)
- beep_phase = state_fio->FgetInt32_BE();
-#endif
- }
- // Version 4
- autokey_backup = state_fio->FgetUint8();
- // Version 5
- ins_led_status = state_fio->FgetBool();
- kana_led_status = state_fio->FgetBool();
- caps_led_status = state_fio->FgetBool();
- // Version 6
- override_break_key = state_fio->FgetBool();
-
- if(version == STATE_VERSION) {
- return true;
- }
- return false;
+ if(!(key_fifo->load_state((void *)state_fio))) return false;
+ return true;
}
if(extram_pages > 3) extram_pages = 3;
#else
if(extram_pages > 12) extram_pages = 12;
-#endif
+#endif
+ extram_size = extram_pages * 0x10000;
if(extram_pages > 0) {
i = FM7_MAINMEM_EXTRAM;
- fm7_mainmem_extram = (uint8_t *)malloc(extram_pages * 0x10000);
+ fm7_mainmem_extram = (uint8_t *)malloc(extram_size);
if(fm7_mainmem_extram != NULL) {
- memset(fm7_mainmem_extram, 0x00, extram_pages * 0x10000);
+ memset(fm7_mainmem_extram, 0x00, extram_size);
}
}
#endif
class VM;
class EMU;
-class csp_state_utils;
+
class MB61VH010: public DEVICE {
protected:
DEVICE *target;
- csp_state_utils *state_entry;
+
// Registers
uint8_t command_reg; // D410 (RW)
uint8_t color_reg; // D411 (RW)