• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

Common Source Code Project for Qt (a.k.a for FM-7).


Commit MetaInfo

Revision7fc095b6611c43312d90eb6741f78f1fbb0100ca (tree)
Zeit2018-10-14 18:16:24
AutorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[VM][PC9801] Enable to build PC-9801 with upstream 2018-10-05.

Ändern Zusammenfassung

Diff

--- a/source/src/vm/pc9801/cmt.cpp
+++ b/source/src/vm/pc9801/cmt.cpp
@@ -106,31 +106,19 @@ void CMT::release_tape()
106106
107107 #define STATE_VERSION 1
108108
109-void CMT::save_state(FILEIO* state_fio)
109+bool CMT::process_state(FILEIO* state_fio, bool loading)
110110 {
111- state_fio->FputUint32(STATE_VERSION);
112- state_fio->FputInt32(this_device_id);
113-
114- state_fio->FputInt32(bufcnt);
115- state_fio->Fwrite(buffer, sizeof(buffer), 1);
116- state_fio->FputBool(play);
117- state_fio->FputBool(rec);
118- state_fio->FputBool(remote);
119-}
120-
121-bool CMT::load_state(FILEIO* state_fio)
122-{
123- if(state_fio->FgetUint32() != STATE_VERSION) {
111+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
124112 return false;
125113 }
126- if(state_fio->FgetInt32() != this_device_id) {
114+ if(!state_fio->StateCheckInt32(this_device_id)) {
127115 return false;
128116 }
129- bufcnt = state_fio->FgetInt32();
130- state_fio->Fread(buffer, sizeof(buffer), 1);
131- play = state_fio->FgetBool();
132- rec = state_fio->FgetBool();
133- remote = state_fio->FgetBool();
117+ state_fio->StateInt32(bufcnt);
118+ state_fio->StateBuffer(buffer, sizeof(buffer), 1);
119+ state_fio->StateBool(play);
120+ state_fio->StateBool(rec);
121+ state_fio->StateBool(remote);
134122 return true;
135123 }
136124
--- a/source/src/vm/pc9801/cmt.h
+++ b/source/src/vm/pc9801/cmt.h
@@ -48,8 +48,7 @@ public:
4848 void reset();
4949 void write_io8(uint32_t addr, uint32_t data);
5050 void write_signal(int id, uint32_t data, uint32_t mask);
51- void save_state(FILEIO* state_fio);
52- bool load_state(FILEIO* state_fio);
51+ bool process_state(FILEIO* state_fio, bool loading);
5352
5453 // unique functions
5554 void set_context_sio(DEVICE* device)
--- a/source/src/vm/pc9801/cpureg.cpp
+++ b/source/src/vm/pc9801/cpureg.cpp
@@ -106,42 +106,14 @@ uint32_t CPUREG::read_io8(uint32_t addr)
106106
107107 #define STATE_VERSION 1
108108
109-#include "../statesub.h"
110-
111-void CPUREG::decl_state()
109+bool CPUREG::process_state(FILEIO* state_fio, bool loading)
112110 {
113- enter_decl_state(STATE_VERSION);
114-
115- DECL_STATE_ENTRY_BOOL(nmi_enabled);
116-
117- leave_decl_state();
111+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
112+ return false;
113+ }
114+ if(!state_fio->StateCheckInt32(this_device_id)) {
115+ return false;
116+ }
117+ state_fio->StateBool(nmi_enabled);
118+ return true;
118119 }
119-
120-void CPUREG::save_state(FILEIO* state_fio)
121-{
122- if(state_entry != NULL) {
123- state_entry->save_state(state_fio);
124- }
125-// state_fio->FputUint32(STATE_VERSION);
126-// state_fio->FputInt32(this_device_id);
127-
128-// state_fio->FputBool(nmi_enabled);
129-}
130-
131-bool CPUREG::load_state(FILEIO* state_fio)
132-{
133- bool mb = false;
134- if(state_entry != NULL) {
135- mb = state_entry->load_state(state_fio);
136- }
137- if(!mb) return false;
138-// if(state_fio->FgetUint32() != STATE_VERSION) {
139-// return false;
140-// }
141-// if(state_fio->FgetInt32() != this_device_id) {
142-// return false;
143-// }
144-// nmi_enabled = state_fio->FgetBool();
145- return true;
146-}
147-
--- a/source/src/vm/pc9801/cpureg.h
+++ b/source/src/vm/pc9801/cpureg.h
@@ -45,9 +45,7 @@ public:
4545 void reset();
4646 void write_io8(uint32_t addr, uint32_t data);
4747 uint32_t read_io8(uint32_t addr);
48- void decl_state();
49- void save_state(FILEIO* state_fio);
50- bool load_state(FILEIO* state_fio);
48+ bool process_state(FILEIO* state_fio, bool loading);
5149
5250 // unique function
5351 #if defined(SUPPORT_32BIT_ADDRESS)
--- a/source/src/vm/pc9801/display.cpp
+++ b/source/src/vm/pc9801/display.cpp
@@ -2576,252 +2576,142 @@ void DISPLAY::draw_gfx_screen()
25762576
25772577 #define STATE_VERSION 3
25782578
2579-#include "../statesub.h"
2580-
2581-#define DECL_STATE_ENTRY_EGCWORD_T(foo) { \
2582- DECL_STATE_ENTRY_UINT16((foo.w)); \
2583- }
2584-
2585-#define DECL_STATE_ENTRY_EGCQUAD_T(foo) { \
2586- DECL_STATE_ENTRY_UINT64((foo.q)); \
2587- }
2588-
2589-
2590-void DISPLAY::decl_state()
2591-{
2592- enter_decl_state(STATE_VERSION);
2593-
2594- DECL_STATE_ENTRY_1D_ARRAY(tvram, sizeof(tvram));
2595- DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
2579+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
2580+{
2581+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
2582+ return false;
2583+ }
2584+ if(!state_fio->StateCheckInt32(this_device_id)) {
2585+ return false;
2586+ }
2587+ state_fio->StateBuffer(tvram, sizeof(tvram), 1);
2588+ state_fio->StateBuffer(vram, sizeof(vram), 1);
25962589 #if defined(SUPPORT_2ND_VRAM) && !defined(SUPPORT_HIRESO)
2597- DECL_STATE_ENTRY_UINT8(vram_disp_sel);
2598- DECL_STATE_ENTRY_UINT8(vram_draw_sel);
2599-#endif
2600- DECL_STATE_ENTRY_1D_ARRAY(palette_gfx8, sizeof(palette_gfx8) / sizeof(scrntype_t)); // ToDo
2601- DECL_STATE_ENTRY_1D_ARRAY(digipal, sizeof(digipal));
2590+ state_fio->StateUint8(vram_disp_sel);
2591+ state_fio->StateUint8(vram_draw_sel);
2592+#endif
2593+ //state_fio->StateBuffer(palette_gfx8, sizeof(palette_gfx8), 1);
2594+ if(loading) {
2595+ for(int i = 0; i < (sizeof(palette_gfx8) / sizeof(scrntype_t)); i++) {
2596+ uint8_t r, g, b;
2597+ r = state_fio->FgetUint8();
2598+ g = state_fio->FgetUint8();
2599+ b = state_fio->FgetUint8();
2600+ palette_gfx8[i] = RGB_COLOR(r, g, b);
2601+ }
2602+ } else {
2603+ for(int i = 0; i < (sizeof(palette_gfx8) / sizeof(scrntype_t)); i++) {
2604+ uint8_t r, g, b;
2605+ r = R_OF_COLOR(palette_gfx8[i]);
2606+ g = G_OF_COLOR(palette_gfx8[i]);
2607+ b = B_OF_COLOR(palette_gfx8[i]);
2608+ state_fio->FputUint8(r);
2609+ state_fio->FputUint8(g);
2610+ state_fio->FputUint8(b);
2611+ }
2612+ }
2613+ state_fio->StateBuffer(digipal, sizeof(digipal), 1);
26022614 #if defined(SUPPORT_16_COLORS)
2603- DECL_STATE_ENTRY_1D_ARRAY(palette_gfx16, sizeof(palette_gfx16) / sizeof(scrntype_t));
2604- DECL_STATE_ENTRY_2D_ARRAY(anapal, 16, 3);
2605- DECL_STATE_ENTRY_UINT8(anapal_sel);
2606-#endif
2607- DECL_STATE_ENTRY_UINT8(crtv);
2608- DECL_STATE_ENTRY_1D_ARRAY(scroll, sizeof(scroll));
2609- DECL_STATE_ENTRY_1D_ARRAY(modereg1, sizeof(modereg1));
2615+ //state_fio->StateBuffer(palette_gfx16, sizeof(palette_gfx16), 1);
2616+ if(loading) {
2617+ for(int i = 0; i < (sizeof(palette_gfx16) / sizeof(scrntype_t)); i++) {
2618+ uint8_t r, g, b;
2619+ r = state_fio->FgetUint8();
2620+ g = state_fio->FgetUint8();
2621+ b = state_fio->FgetUint8();
2622+ palette_gfx16[i] = RGB_COLOR(r, g, b);
2623+ }
2624+ } else {
2625+ for(int i = 0; i < (sizeof(palette_gfx16) / sizeof(scrntype_t)); i++) {
2626+ uint8_t r, g, b;
2627+ r = R_OF_COLOR(palette_gfx16[i]);
2628+ g = G_OF_COLOR(palette_gfx16[i]);
2629+ b = B_OF_COLOR(palette_gfx16[i]);
2630+ state_fio->FputUint8(r);
2631+ state_fio->FputUint8(g);
2632+ state_fio->FputUint8(b);
2633+ }
2634+ }
2635+ state_fio->StateBuffer(anapal, sizeof(anapal), 1);
2636+ state_fio->StateUint8(anapal_sel);
2637+#endif
2638+ state_fio->StateUint8(crtv);
2639+ state_fio->StateBuffer(scroll, sizeof(scroll), 1);
2640+ state_fio->StateBuffer(modereg1, sizeof(modereg1), 1);
26102641 #if defined(SUPPORT_16_COLORS)
2611- DECL_STATE_ENTRY_1D_ARRAY(modereg2, sizeof(modereg2));
2642+ state_fio->StateBuffer(modereg2, sizeof(modereg2), 1);
26122643 #endif
26132644 #if defined(SUPPORT_GRCG)
2614- DECL_STATE_ENTRY_UINT8(grcg_mode);
2615- DECL_STATE_ENTRY_UINT8(grcg_tile_ptr);
2616- DECL_STATE_ENTRY_1D_ARRAY(grcg_tile, sizeof(grcg_tile));
2617-#endif
2618-#if defined(SUPPORT_EGC)
2619- DECL_STATE_ENTRY_UINT16(egc_access);
2620- DECL_STATE_ENTRY_UINT16(egc_fgbg);
2621- DECL_STATE_ENTRY_UINT16(egc_ope);
2622- DECL_STATE_ENTRY_UINT16(egc_fg);
2623- DECL_STATE_ENTRY_UINT16(egc_mask.w);
2624- DECL_STATE_ENTRY_UINT16(egc_bg);
2625- DECL_STATE_ENTRY_UINT16(egc_sft);
2626- DECL_STATE_ENTRY_UINT16(egc_leng);
2627- DECL_STATE_ENTRY_EGCQUAD_T(egc_lastvram);
2628- DECL_STATE_ENTRY_EGCQUAD_T(egc_patreg);
2629- DECL_STATE_ENTRY_EGCQUAD_T(egc_fgc);
2630- DECL_STATE_ENTRY_EGCQUAD_T(egc_bgc);
2631- DECL_STATE_ENTRY_INT32(egc_func);
2632- DECL_STATE_ENTRY_UINT32(egc_remain);
2633- DECL_STATE_ENTRY_UINT32(egc_stack);
2634-// int inptr_ofs = egc_inptr - egc_buf;
2635-// int outptr_ofs = egc_outptr - egc_buf;
2636- DECL_STATE_ENTRY_INT32(tmp_inptr_ofs);
2637- DECL_STATE_ENTRY_INT32(tmp_outptr_ofs);
2638-
2639- DECL_STATE_ENTRY_EGCWORD_T(egc_mask2);
2640- DECL_STATE_ENTRY_EGCWORD_T(egc_srcmask);
2641-
2642- DECL_STATE_ENTRY_UINT8(egc_srcbit);
2643- DECL_STATE_ENTRY_UINT8(egc_dstbit);
2644- DECL_STATE_ENTRY_UINT8(egc_sft8bitl);
2645- DECL_STATE_ENTRY_UINT8(egc_sft8bitr);
2646- DECL_STATE_ENTRY_1D_ARRAY(egc_buf, sizeof(egc_buf));
2647- DECL_STATE_ENTRY_EGCQUAD_T(egc_vram_src);
2648- DECL_STATE_ENTRY_EGCQUAD_T(egc_vram_data);
2649-#endif
2650- DECL_STATE_ENTRY_UINT16(font_code);
2651- DECL_STATE_ENTRY_UINT8(font_line);
2652-//// DECL_STATE_ENTRY_UINT16(font_lr);
2653- leave_decl_state();
2654-}
2655-
2656-void DISPLAY::save_state(FILEIO* state_fio)
2657-{
2658-#if defined(SUPPORT_EGC)
2659- tmp_inptr_ofs = (int)(egc_inptr - egc_buf);
2660- tmp_outptr_ofs = (int)(egc_outptr - egc_buf);
2645+ state_fio->StateUint8(grcg_mode);
2646+ state_fio->StateUint8(grcg_tile_ptr);
2647+ state_fio->StateBuffer(grcg_tile, sizeof(grcg_tile), 1);
26612648 #endif
2662- if(state_entry != NULL) {
2663- state_entry->save_state(state_fio);
2664- }
2665-// state_fio->FputUint32(STATE_VERSION);
2666-// state_fio->FputInt32(this_device_id);
2667-
2668-// state_fio->Fwrite(tvram, sizeof(tvram), 1);
2669-// state_fio->Fwrite(vram, sizeof(vram), 1);
2670-//#if defined(SUPPORT_2ND_VRAM) && !defined(SUPPORT_HIRESO)
2671-// state_fio->FputUint8(vram_disp_sel);
2672-// state_fio->FputUint8(vram_draw_sel);
2673-//#endif
2674-// state_fio->Fwrite(palette_gfx8, sizeof(palette_gfx8), 1);
2675-// state_fio->Fwrite(digipal, sizeof(digipal), 1);
2676-//#if defined(SUPPORT_16_COLORS)
2677-// state_fio->Fwrite(palette_gfx16, sizeof(palette_gfx16), 1);
2678-// state_fio->Fwrite(anapal, sizeof(anapal), 1);
2679-// state_fio->FputUint8(anapal_sel);
2680-//#endif
2681-// state_fio->FputUint8(crtv);
2682-// state_fio->Fwrite(scroll, sizeof(scroll), 1);
2683-// state_fio->Fwrite(modereg1, sizeof(modereg1), 1);
2684-//#if defined(SUPPORT_16_COLORS)
2685-// state_fio->Fwrite(modereg2, sizeof(modereg2), 1);
2686-//#endif
2687-//#if defined(SUPPORT_GRCG)
2688-// state_fio->FputUint8(grcg_mode);
2689-// state_fio->FputUint8(grcg_tile_ptr);
2690-// state_fio->Fwrite(grcg_tile, sizeof(grcg_tile), 1);
2691-//#endif
2692-//#if defined(SUPPORT_EGC)
2693-// state_fio->FputUint16(egc_access);
2694-// state_fio->FputUint16(egc_fgbg);
2695-// state_fio->FputUint16(egc_ope);
2696-// state_fio->FputUint16(egc_fg);
2697-// state_fio->FputUint16(egc_mask.w);
2698-// state_fio->FputUint16(egc_bg);
2699-// state_fio->FputUint16(egc_sft);
2700-// state_fio->FputUint16(egc_leng);
2701-// state_fio->FputUint64(egc_lastvram.q);
2702-// state_fio->FputUint64(egc_patreg.q);
2703-// state_fio->FputUint64(egc_fgc.q);
2704-// state_fio->FputUint64(egc_bgc.q);
2705-// state_fio->FputInt32(egc_func);
2706-// state_fio->FputUint32(egc_remain);
2707-// state_fio->FputUint32(egc_stack);
2708-// int inptr_ofs = egc_inptr - egc_buf;
2709-// int outptr_ofs = egc_outptr - egc_buf;
2710-// state_fio->FputInt32(inptr_ofs);
2711-// state_fio->FputInt32(outptr_ofs);
2712-// state_fio->FputUint16(egc_mask2.w);
2713-// state_fio->FputUint16(egc_srcmask.w);
2714-// state_fio->FputUint8(egc_srcbit);
2715-// state_fio->FputUint8(egc_dstbit);
2716-// state_fio->FputUint8(egc_sft8bitl);
2717-// state_fio->FputUint8(egc_sft8bitr);
2718-// state_fio->Fwrite(egc_buf, sizeof(egc_buf), 1);
2719-// state_fio->FputUint64(egc_vram_src.q);
2720-// state_fio->FputUint64(egc_vram_data.q);
2721-//#endif
2722-// state_fio->FputUint16(font_code);
2723-// state_fio->FputUint8(font_line);
2724-// state_fio->FputUint16(font_lr);
2725-}
2726-
2727-bool DISPLAY::load_state(FILEIO* state_fio)
2728-{
2729- bool mb = false;
2730- if(state_entry != NULL) {
2731- mb = state_entry->load_state(state_fio);
2732- }
2733- if(!mb) return false;
2734-// if(state_fio->FgetUint32() != STATE_VERSION) {
2735-// return false;
2736-// }
2737-// if(state_fio->FgetInt32() != this_device_id) {
2738-// return false;
2739-// }
2740-// state_fio->Fread(tvram, sizeof(tvram), 1);
2741-// state_fio->Fread(vram, sizeof(vram), 1);
2742-//#if defined(SUPPORT_2ND_VRAM) && !defined(SUPPORT_HIRESO)
2743-// vram_disp_sel = state_fio->FgetUint8();
2744-// vram_draw_sel = state_fio->FgetUint8();
2745-//#endif
2746-// state_fio->Fread(palette_gfx8, sizeof(palette_gfx8), 1);
2747-// state_fio->Fread(digipal, sizeof(digipal), 1);
2748-//#if defined(SUPPORT_16_COLORS)
2749-// state_fio->Fread(palette_gfx16, sizeof(palette_gfx16), 1);
2750-// state_fio->Fread(anapal, sizeof(anapal), 1);
2751-// anapal_sel = state_fio->FgetUint8();
2752-//#endif
2753-// crtv = state_fio->FgetUint8();
2754-// state_fio->Fread(scroll, sizeof(scroll), 1);
2755-// state_fio->Fread(modereg1, sizeof(modereg1), 1);
2756-//#if defined(SUPPORT_16_COLORS)
2757-// state_fio->Fread(modereg2, sizeof(modereg2), 1);
2758-//#endif
2759-//#if defined(SUPPORT_GRCG)
2760-// grcg_mode = state_fio->FgetUint8();
2761-// grcg_tile_ptr = state_fio->FgetUint8();
2762-// state_fio->Fread(grcg_tile, sizeof(grcg_tile), 1);
2763-//#endif
2764-//#if defined(SUPPORT_EGC)
2765-// egc_access = state_fio->FgetUint16();
2766-// egc_fgbg = state_fio->FgetUint16();
2767-// egc_ope = state_fio->FgetUint16();
2768-// egc_fg = state_fio->FgetUint16();
2769-// egc_mask.w = state_fio->FgetUint16();
2770-// egc_bg = state_fio->FgetUint16();
2771-// egc_sft = state_fio->FgetUint16();
2772-// egc_leng = state_fio->FgetUint16();
2773-// egc_lastvram.q = state_fio->FgetUint64();
2774-// egc_patreg.q = state_fio->FgetUint64();
2775-// egc_fgc.q = state_fio->FgetUint64();
2776-// egc_bgc.q = state_fio->FgetUint64();
2777-// egc_func = state_fio->FgetInt32();
2778-// egc_remain = state_fio->FgetUint32();
2779-// egc_stack = state_fio->FgetUint32();
2780-// int inptr_ofs = state_fio->FgetInt32();
2781-// int outptr_ofs = state_fio->FgetInt32();
2782-// egc_inptr = egc_buf + inptr_ofs;
2783-// egc_outptr = egc_buf + outptr_ofs;
2784-// egc_mask2.w = state_fio->FgetUint16();
2785-// egc_srcmask.w = state_fio->FgetUint16();
2786-// egc_srcbit = state_fio->FgetUint8();
2787-// egc_dstbit = state_fio->FgetUint8();
2788-// egc_sft8bitl = state_fio->FgetUint8();
2789-// egc_sft8bitr = state_fio->FgetUint8();
2790-// state_fio->Fread(egc_buf, sizeof(egc_buf), 1);
2791-// egc_vram_src.q = state_fio->FgetUint64();
2792-// egc_vram_data.q = state_fio->FgetUint64();
2793-//#endif
2794-// font_code = state_fio->FgetUint16();
2795-// font_line = state_fio->FgetUint8();
2796-// font_lr = state_fio->FgetUint16();
2797-
2798- // post process
27992649 #if defined(SUPPORT_EGC)
2800- egc_inptr = egc_buf + tmp_inptr_ofs;
2801- egc_outptr = egc_buf + tmp_outptr_ofs;
2802-#endif
2650+ state_fio->StateUint16(egc_access);
2651+ state_fio->StateUint16(egc_fgbg);
2652+ state_fio->StateUint16(egc_ope);
2653+ state_fio->StateUint16(egc_fg);
2654+ state_fio->StateUint16(egc_mask.w);
2655+ state_fio->StateUint16(egc_bg);
2656+ state_fio->StateUint16(egc_sft);
2657+ state_fio->StateUint16(egc_leng);
2658+ state_fio->StateUint64(egc_lastvram.q);
2659+ state_fio->StateUint64(egc_patreg.q);
2660+ state_fio->StateUint64(egc_fgc.q);
2661+ state_fio->StateUint64(egc_bgc.q);
2662+ state_fio->StateInt32(egc_func);
2663+ state_fio->StateUint32(egc_remain);
2664+ state_fio->StateUint32(egc_stack);
2665+ if(loading) {
2666+ int inptr_ofs = state_fio->FgetInt32_LE();
2667+ int outptr_ofs = state_fio->FgetInt32_LE();
2668+ egc_inptr = egc_buf + inptr_ofs;
2669+ egc_outptr = egc_buf + outptr_ofs;
2670+ } else {
2671+ int inptr_ofs = egc_inptr - egc_buf;
2672+ int outptr_ofs = egc_outptr - egc_buf;
2673+ state_fio->FputInt32_LE(inptr_ofs);
2674+ state_fio->FputInt32_LE(outptr_ofs);
2675+ }
2676+ state_fio->StateUint16(egc_mask2.w);
2677+ state_fio->StateUint16(egc_srcmask.w);
2678+ state_fio->StateUint8(egc_srcbit);
2679+ state_fio->StateUint8(egc_dstbit);
2680+ state_fio->StateUint8(egc_sft8bitl);
2681+ state_fio->StateUint8(egc_sft8bitr);
2682+ state_fio->StateBuffer(egc_buf, sizeof(egc_buf), 1);
2683+ state_fio->StateUint64(egc_vram_src.q);
2684+ state_fio->StateUint64(egc_vram_data.q);
2685+#endif
2686+ state_fio->StateUint16(font_code);
2687+ state_fio->StateUint8(font_line);
2688+// state_fio->StateUint16(font_lr);
2689+
2690+ // post process
28032691 #if defined(SUPPORT_2ND_VRAM) && !defined(SUPPORT_HIRESO)
2804- if(vram_disp_sel & 1) {
2805- vram_disp_b = vram + 0x28000;
2806- vram_disp_r = vram + 0x30000;
2807- vram_disp_g = vram + 0x38000;
2692+ if(loading) {
2693+ if(vram_disp_sel & 1) {
2694+ vram_disp_b = vram + 0x28000;
2695+ vram_disp_r = vram + 0x30000;
2696+ vram_disp_g = vram + 0x38000;
28082697 #if defined(SUPPORT_16_COLORS)
2809- vram_disp_e = vram + 0x20000;
2698+ vram_disp_e = vram + 0x20000;
28102699 #endif
2811- } else {
2812- vram_disp_b = vram + 0x08000;
2813- vram_disp_r = vram + 0x10000;
2814- vram_disp_g = vram + 0x18000;
2700+ } else {
2701+ vram_disp_b = vram + 0x08000;
2702+ vram_disp_r = vram + 0x10000;
2703+ vram_disp_g = vram + 0x18000;
28152704 #if defined(SUPPORT_16_COLORS)
2816- vram_disp_e = vram + 0x00000;
2705+ vram_disp_e = vram + 0x00000;
28172706 #endif
2818- }
2819- if(vram_draw_sel & 1) {
2820- vram_draw = vram + 0x20000;
2821- } else {
2822- vram_draw = vram + 0x00000;
2823- }
2707+ }
2708+ if(vram_draw_sel & 1) {
2709+ vram_draw = vram + 0x20000;
2710+ } else {
2711+ vram_draw = vram + 0x00000;
2712+ }
2713+ }
28242714 #endif
2825- return true;
2715+ return true;
28262716 }
28272717
--- a/source/src/vm/pc9801/display.h
+++ b/source/src/vm/pc9801/display.h
@@ -219,9 +219,7 @@ public:
219219 void write_dma_io16(uint32_t addr, uint32_t data);
220220 uint32_t read_dma_io8(uint32_t addr);
221221 uint32_t read_dma_io16(uint32_t addr);
222- void decl_state();
223- void save_state(FILEIO* state_fio);
224- bool load_state(FILEIO* state_fio);
222+ bool process_state(FILEIO* state_fio, bool loading);
225223
226224 // unique functions
227225 void set_context_pic(DEVICE *device)
--- a/source/src/vm/pc9801/dmareg.cpp
+++ b/source/src/vm/pc9801/dmareg.cpp
@@ -82,39 +82,15 @@ uint32_t DMAREG::read_io8(uint32_t addr)
8282 /*
8383 #define STATE_VERSION 1
8484
85-#include "../statesub.h"
86-
87-void DMAREG::decl_state()
85+bool DMAREG::process_state(FILEIO* state_fio, bool loading)
8886 {
89- enter_decl_state(STATE_VERSION);
90-
91- leave_decl_state();
92-}
93-
94-void DMAREG::save_state(FILEIO* state_fio)
95-{
96- if(state_entry != NULL) {
97- state_entry->save_state(state_fio);
98- }
99-// state_fio->FputUint32(STATE_VERSION);
100-// state_fio->FputInt32(this_device_id);
101-
87+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
88+ return false;
89+ }
90+ if(!state_fio->StateCheckInt32(this_device_id)) {
91+ return false;
92+ }
93+ return true;
10294 }
10395
104-bool DMAREG::load_state(FILEIO* state_fio)
105-{
106-
107- bool mb = false;
108- if(state_entry != NULL) {
109- mb = state_entry->load_state(state_fio);
110- }
111- if(!mb) return false;
112-// if(state_fio->FgetUint32() != STATE_VERSION) {
113-// return false;
114-// }
115-// if(state_fio->FgetInt32() != this_device_id) {
116-// return false;
117-// }
118- return true;
119-}
12096 */
--- a/source/src/vm/pc9801/dmareg.h
+++ b/source/src/vm/pc9801/dmareg.h
@@ -33,8 +33,7 @@ public:
3333 // common functions
3434 void write_io8(uint32_t addr, uint32_t data);
3535 uint32_t read_io8(uint32_t addr);
36-// void save_state(FILEIO* state_fio);
37-// bool load_state(FILEIO* state_fio);
36+// bool process_state(FILEIO* state_fio, bool loading);
3837
3938 // unique function
4039 void set_context_dma(DEVICE* device)
--- a/source/src/vm/pc9801/floppy.cpp
+++ b/source/src/vm/pc9801/floppy.cpp
@@ -319,43 +319,25 @@ void FLOPPY::event_callback(int event_id, int err)
319319
320320 #define STATE_VERSION 1
321321
322-void FLOPPY::save_state(FILEIO* state_fio)
322+bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
323323 {
324- state_fio->FputUint32(STATE_VERSION);
325- state_fio->FputInt32(this_device_id);
326-
327-#if defined(SUPPORT_2HD_FDD_IF)
328- state_fio->FputUint8(ctrlreg_2hd);
329-#endif
330-#if defined(SUPPORT_2DD_FDD_IF)
331- state_fio->FputUint8(ctrlreg_2dd);
332-#endif
333-#if defined(SUPPORT_2HD_2DD_FDD_IF)
334- state_fio->FputUint8(ctrlreg);
335- state_fio->FputUint8(modereg);
336-#endif
337- state_fio->FputInt32(timer_id);
338-}
339-
340-bool FLOPPY::load_state(FILEIO* state_fio)
341-{
342- if(state_fio->FgetUint32() != STATE_VERSION) {
324+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
343325 return false;
344326 }
345- if(state_fio->FgetInt32() != this_device_id) {
327+ if(!state_fio->StateCheckInt32(this_device_id)) {
346328 return false;
347329 }
348330 #if defined(SUPPORT_2HD_FDD_IF)
349- ctrlreg_2hd = state_fio->FgetUint8();
331+ state_fio->StateUint8(ctrlreg_2hd);
350332 #endif
351333 #if defined(SUPPORT_2DD_FDD_IF)
352- ctrlreg_2dd = state_fio->FgetUint8();
334+ state_fio->StateUint8(ctrlreg_2dd);
353335 #endif
354336 #if defined(SUPPORT_2HD_2DD_FDD_IF)
355- ctrlreg = state_fio->FgetUint8();
356- modereg = state_fio->FgetUint8();
337+ state_fio->StateUint8(ctrlreg);
338+ state_fio->StateUint8(modereg);
357339 #endif
358- timer_id = state_fio->FgetInt32();
340+ state_fio->StateInt32(timer_id);
359341 return true;
360342 }
361343
--- a/source/src/vm/pc9801/floppy.h
+++ b/source/src/vm/pc9801/floppy.h
@@ -71,8 +71,7 @@ public:
7171 uint32_t read_io8(uint32_t addr);
7272 void write_signal(int id, uint32_t data, uint32_t mask);
7373 void event_callback(int event_id, int err);
74- void save_state(FILEIO* state_fio);
75- bool load_state(FILEIO* state_fio);
74+ bool process_state(FILEIO* state_fio, bool loading);
7675
7776 // unique functions
7877 #if defined(SUPPORT_2HD_FDD_IF)
--- a/source/src/vm/pc9801/fmsound.cpp
+++ b/source/src/vm/pc9801/fmsound.cpp
@@ -84,23 +84,15 @@ uint32_t FMSOUND::read_io8(uint32_t addr)
8484 #ifdef SUPPORT_PC98_OPNA
8585 #define STATE_VERSION 1
8686
87-void FMSOUND::save_state(FILEIO* state_fio)
87+bool FMSOUND::process_state(FILEIO* state_fio, bool loading)
8888 {
89- state_fio->FputUint32(STATE_VERSION);
90- state_fio->FputInt32(this_device_id);
91-
92- state_fio->FputUint8(mask);
93-}
94-
95-bool FMSOUND::load_state(FILEIO* state_fio)
96-{
97- if(state_fio->FgetUint32() != STATE_VERSION) {
89+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
9890 return false;
9991 }
100- if(state_fio->FgetInt32() != this_device_id) {
92+ if(!state_fio->StateCheckInt32(this_device_id)) {
10193 return false;
10294 }
103- mask = state_fio->FgetUint8();
95+ state_fio->StateUint8(mask);
10496 return true;
10597 }
10698 #endif
--- a/source/src/vm/pc9801/fmsound.h
+++ b/source/src/vm/pc9801/fmsound.h
@@ -50,8 +50,7 @@ public:
5050 void write_io8(uint32_t addr, uint32_t data);
5151 uint32_t read_io8(uint32_t addr);
5252 #ifdef SUPPORT_PC98_OPNA
53- void save_state(FILEIO* state_fio);
54- bool load_state(FILEIO* state_fio);
53+ bool process_state(FILEIO* state_fio, bool loading);
5554 #endif
5655
5756 // unique function
--- a/source/src/vm/pc9801/joystick.cpp
+++ b/source/src/vm/pc9801/joystick.cpp
@@ -43,23 +43,15 @@ void JOYSTICK::event_frame()
4343
4444 #define STATE_VERSION 1
4545
46-void JOYSTICK::save_state(FILEIO* state_fio)
46+bool JOYSTICK::process_state(FILEIO* state_fio, bool loading)
4747 {
48- state_fio->FputUint32(STATE_VERSION);
49- state_fio->FputInt32(this_device_id);
50-
51- state_fio->FputUint8(select);
52-}
53-
54-bool JOYSTICK::load_state(FILEIO* state_fio)
55-{
56- if(state_fio->FgetUint32() != STATE_VERSION) {
48+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
5749 return false;
5850 }
59- if(state_fio->FgetInt32() != this_device_id) {
51+ if(!state_fio->StateCheckInt32(this_device_id)) {
6052 return false;
6153 }
62- select = state_fio->FgetUint8();
54+ state_fio->StateUint8(select);
6355 return true;
6456 }
6557
--- a/source/src/vm/pc9801/joystick.h
+++ b/source/src/vm/pc9801/joystick.h
@@ -45,8 +45,7 @@ public:
4545 void initialize();
4646 void write_signal(int id, uint32_t data, uint32_t mask);
4747 void event_frame();
48- void save_state(FILEIO* state_fio);
49- bool load_state(FILEIO* state_fio);
48+ bool process_state(FILEIO* state_fio, bool loading);
5049
5150 // unique function
5251 void set_context_opn(DEVICE* device)
--- a/source/src/vm/pc9801/keyboard.cpp
+++ b/source/src/vm/pc9801/keyboard.cpp
@@ -85,27 +85,17 @@ void KEYBOARD::key_up(int code)
8585
8686 #define STATE_VERSION 1
8787
88-void KEYBOARD::save_state(FILEIO* state_fio)
88+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
8989 {
90- state_fio->FputUint32(STATE_VERSION);
91- state_fio->FputInt32(this_device_id);
92-
93- state_fio->FputBool(kana);
94- state_fio->FputBool(caps);
95- state_fio->Fwrite(flag, sizeof(flag), 1);
96-}
97-
98-bool KEYBOARD::load_state(FILEIO* state_fio)
99-{
100- if(state_fio->FgetUint32() != STATE_VERSION) {
90+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
10191 return false;
10292 }
103- if(state_fio->FgetInt32() != this_device_id) {
93+ if(!state_fio->StateCheckInt32(this_device_id)) {
10494 return false;
10595 }
106- kana = state_fio->FgetBool();
107- caps = state_fio->FgetBool();
108- state_fio->Fread(flag, sizeof(flag), 1);
96+ state_fio->StateBool(kana);
97+ state_fio->StateBool(caps);
98+ state_fio->StateBuffer(flag, sizeof(flag), 1);
10999 return true;
110100 }
111101
--- a/source/src/vm/pc9801/keyboard.h
+++ b/source/src/vm/pc9801/keyboard.h
@@ -44,8 +44,7 @@ public:
4444 // common functions
4545 void initialize();
4646 void reset();
47- void save_state(FILEIO* state_fio);
48- bool load_state(FILEIO* state_fio);
47+ bool process_state(FILEIO* state_fio, bool loading);
4948
5049 // unique functions
5150 void set_context_sio(DEVICE* device)
--- a/source/src/vm/pc9801/membus.cpp
+++ b/source/src/vm/pc9801/membus.cpp
@@ -535,172 +535,73 @@ void MEMBUS::update_nec_ems()
535535
536536 #define STATE_VERSION 4
537537
538-#include "../statesub.h"
539-
540-void MEMBUS::decl_state()
538+bool MEMBUS::process_state(FILEIO* state_fio, bool loading)
541539 {
542- enter_decl_state(STATE_VERSION);
543-
544- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
540+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
541+ return false;
542+ }
543+ if(!state_fio->StateCheckInt32(this_device_id)) {
544+ return false;
545+ }
546+ state_fio->StateBuffer(ram, sizeof(ram), 1);
545547 #if defined(SUPPORT_BIOS_RAM)
546- DECL_STATE_ENTRY_1D_ARRAY(bios_ram, sizeof(bios_ram));
547- DECL_STATE_ENTRY_BOOL(bios_ram_selected);
548+ state_fio->StateBuffer(bios_ram, sizeof(bios_ram), 1);
549+ state_fio->StateBool(bios_ram_selected);
548550 #endif
549551 #if defined(SUPPORT_ITF_ROM)
550- DECL_STATE_ENTRY_BOOL(itf_selected);
552+ state_fio->StateBool(itf_selected);
551553 #endif
552554 #if !defined(SUPPORT_HIRESO)
553-// DECL_STATE_ENTRY_1D_ARRAY(sound_bios_ram, sizeof(sound_bios_ram), 1);
554- DECL_STATE_ENTRY_BOOL(sound_bios_selected);
555-// DECL_STATE_ENTRY_BOOL(sound_bios_ram_selected);
555+// state_fio->StateBuffer(sound_bios_ram, sizeof(sound_bios_ram), 1);
556+ state_fio->StateBool(sound_bios_selected);
557+// state_fio->StateBool(sound_bios_ram_selected);
556558 #if defined(SUPPORT_SASI_IF)
557- DECL_STATE_ENTRY_1D_ARRAY(sasi_bios_ram, sizeof(sasi_bios_ram));
558- DECL_STATE_ENTRY_BOOL(sasi_bios_selected);
559- DECL_STATE_ENTRY_BOOL(sasi_bios_ram_selected);
559+ state_fio->StateBuffer(sasi_bios_ram, sizeof(sasi_bios_ram), 1);
560+ state_fio->StateBool(sasi_bios_selected);
561+ state_fio->StateBool(sasi_bios_ram_selected);
560562 #endif
561563 #if defined(SUPPORT_SCSI_IF)
562- DECL_STATE_ENTRY_1D_ARRAY(scsi_bios_ram, sizeof(scsi_bios_ram));
563- DECL_STATE_ENTRY_BOOL(scsi_bios_selected);
564- DECL_STATE_ENTRY_BOOL(scsi_bios_ram_selected);
564+ state_fio->StateBuffer(scsi_bios_ram, sizeof(scsi_bios_ram), 1);
565+ state_fio->StateBool(scsi_bios_selected);
566+ state_fio->StateBool(scsi_bios_ram_selected);
565567 #endif
566568 #if defined(SUPPORT_IDE_IF)
567-// DECL_STATE_ENTRY_1D_ARRAY(ide_bios_ram, sizeof(ide_bios_ram), 1);
568- DECL_STATE_ENTRY_BOOL(ide_bios_selected);
569-// DECL_STATE_ENTRY_BOOL(ide_bios_ram_selected);
569+// state_fio->StateBuffer(ide_bios_ram, sizeof(ide_bios_ram), 1);
570+ state_fio->StateBool(ide_bios_selected);
571+// state_fio->StateBool(ide_bios_ram_selected);
570572 #endif
571573 #if defined(SUPPORT_NEC_EMS)
572- DECL_STATE_ENTRY_1D_ARRAY(nec_ems, sizeof(nec_ems));
573- DECL_STATE_ENTRY_BOOL(nec_ems_selected);
574+ state_fio->StateBuffer(nec_ems, sizeof(nec_ems), 1);
575+ state_fio->StateBool(nec_ems_selected);
574576 #endif
575577 #endif
576578 #if defined(SUPPORT_24BIT_ADDRESS) || defined(SUPPORT_32BIT_ADDRESS)
577- DECL_STATE_ENTRY_UINT8(dma_access_ctrl);
578- DECL_STATE_ENTRY_UINT32(window_80000h);
579- DECL_STATE_ENTRY_UINT32(window_a0000h);
580-#endif
581- leave_decl_state();
582-
583- // ToDo: Helper.
584-// MEMORY::decl_state();
585-}
586-
587-void MEMBUS::save_state(FILEIO* state_fio)
588-{
589- if(state_entry != NULL) {
590- state_entry->save_state(state_fio);
591- }
592-// state_fio->FputUint32(STATE_VERSION);
593-// state_fio->FputInt32(this_device_id);
594-
595-// state_fio->Fwrite(ram, sizeof(ram), 1);
596-//#if defined(SUPPORT_BIOS_RAM)
597-// state_fio->Fwrite(bios_ram, sizeof(bios_ram), 1);
598-// state_fio->FputBool(bios_ram_selected);
599-//#endif
600-//#if defined(SUPPORT_ITF_ROM)
601-// state_fio->FputBool(itf_selected);
602-//#endif
603-//#if !defined(SUPPORT_HIRESO)
604-//// state_fio->Fwrite(sound_bios_ram, sizeof(sound_bios_ram), 1);
605-// state_fio->FputBool(sound_bios_selected);
606-//// state_fio->FputBool(sound_bios_ram_selected);
607-//#if defined(SUPPORT_SASI_IF)
608-// state_fio->Fwrite(sasi_bios_ram, sizeof(sasi_bios_ram), 1);
609-// state_fio->FputBool(sasi_bios_selected);
610-// state_fio->FputBool(sasi_bios_ram_selected);
611-//#endif
612-//#if defined(SUPPORT_SCSI_IF)
613-// state_fio->Fwrite(scsi_bios_ram, sizeof(scsi_bios_ram), 1);
614-// state_fio->FputBool(scsi_bios_selected);
615-// state_fio->FputBool(scsi_bios_ram_selected);
616-//#endif
617-//#if defined(SUPPORT_IDE_IF)
618-// state_fio->Fwrite(ide_bios_ram, sizeof(ide_bios_ram), 1);
619-// state_fio->FputBool(ide_bios_selected);
620-// state_fio->FputBool(ide_bios_ram_selected);
621-//#endif
622-//#if defined(SUPPORT_NEC_EMS)
623-// state_fio->Fwrite(nec_ems, sizeof(nec_ems), 1);
624-// state_fio->FputBool(nec_ems_selected);
625-//#endif
626-//#endif
627-//#if defined(SUPPORT_24BIT_ADDRESS) || defined(SUPPORT_32BIT_ADDRESS)
628-// state_fio->FputUint8(dma_access_ctrl);
629-// state_fio->FputInt32(window_80000h);
630-// state_fio->FputInt32(window_a0000h);
631-//#endif
632-
633-// MEMORY::save_state(state_fio);
634-}
635-
636-bool MEMBUS::load_state(FILEIO* state_fio)
637-{
638- bool mb = false;
639- if(state_entry != NULL) {
640- mb = state_entry->load_state(state_fio);
641- }
642- if(!mb) return false;
643-// if(state_fio->FgetUint32() != STATE_VERSION) {
644-// return false;
645-// }
646-// if(state_fio->FgetInt32() != this_device_id) {
647-// return false;
648-// }
649-// state_fio->Fread(ram, sizeof(ram), 1);
650-//#if defined(SUPPORT_BIOS_RAM)
651-// state_fio->Fwrite(bios_ram, sizeof(bios_ram), 1);
652-// bios_ram_selected = state_fio->FgetBool();
653-//#endif
654-//#if defined(SUPPORT_ITF_ROM)
655-// itf_selected = state_fio->FgetBool();
656-//#endif
657-//#if !defined(SUPPORT_HIRESO)
658-//// state_fio->Fread(sound_bios_ram, sizeof(sound_bios_ram), 1);
659-// sound_bios_selected = state_fio->FgetBool();
660-//// sound_bios_ram_selected = state_fio->FgetBool();
661-//#if defined(SUPPORT_SASI_IF)
662-// state_fio->Fread(sasi_bios_ram, sizeof(sasi_bios_ram), 1);
663-// sasi_bios_selected = state_fio->FgetBool();
664-// sasi_bios_ram_selected = state_fio->FgetBool();
665-//#endif
666-//#if defined(SUPPORT_SCSI_IF)
667-// state_fio->Fread(scsi_bios_ram, sizeof(scsi_bios_ram), 1);
668-// scsi_bios_selected = state_fio->FgetBool();
669-// scsi_bios_ram_selected = state_fio->FgetBool();
670-//#endif
671-//#if defined(SUPPORT_IDE_IF)
672-//// state_fio->Fread(ide_bios_ram, sizeof(ide_bios_ram), 1);
673-// ide_bios_selected = state_fio->FgetBool();
674-//// ide_bios_ram_selected = state_fio->FgetBool();
675-//#endif
676-//#if defined(SUPPORT_NEC_EMS)
677-// state_fio->Fread(nec_ems, sizeof(nec_ems), 1);
678-// nec_ems_selected = state_fio->FgetBool();
679-//#endif
680-//#endif
681-//#if defined(SUPPORT_24BIT_ADDRESS) || defined(SUPPORT_32BIT_ADDRESS)
682-// dma_access_ctrl = state_fio->FgetUint8();
683-// window_80000h = state_fio->FgetUint32();
684-// window_a0000h = state_fio->FgetUint32();
685-//#endif
686-
687- // post process
688- update_bios();
579+ state_fio->StateUint8(dma_access_ctrl);
580+ state_fio->StateUint32(window_80000h);
581+ state_fio->StateUint32(window_a0000h);
582+#endif
583+ if(!MEMORY::process_state(state_fio, loading)) {
584+ return false;
585+ }
586+
587+ // post process
588+ if(loading) {
589+ update_bios();
689590 #if !defined(SUPPORT_HIRESO)
690- update_sound_bios();
591+ update_sound_bios();
691592 #if defined(SUPPORT_SASI_IF)
692- update_sasi_bios();
593+ update_sasi_bios();
693594 #endif
694595 #if defined(SUPPORT_SCSI_IF)
695- update_scsi_bios();
596+ update_scsi_bios();
696597 #endif
697598 #if defined(SUPPORT_IDE_IF)
698- update_ide_bios();
599+ update_ide_bios();
699600 #endif
700601 #if defined(SUPPORT_EMS)
701- update_nec_ems();
602+ update_nec_ems();
702603 #endif
703604 #endif
704-// return MEMORY::load_state(state_fio);
705- return true;
605+ }
606+ return true;
706607 }
--- a/source/src/vm/pc9801/membus.h
+++ b/source/src/vm/pc9801/membus.h
@@ -129,9 +129,7 @@ public:
129129 uint32_t read_dma_data8(uint32_t addr);
130130 void write_dma_data8(uint32_t addr, uint32_t data);
131131 #endif
132- void decl_state();
133- void save_state(FILEIO* state_fio);
134- bool load_state(FILEIO* state_fio);
132+ bool process_state(FILEIO* state_fio, bool loading);
135133
136134 // unique functions
137135 void set_context_display(DISPLAY* device)
--- a/source/src/vm/pc9801/mouse.cpp
+++ b/source/src/vm/pc9801/mouse.cpp
@@ -127,37 +127,22 @@ void MOUSE::update_mouse()
127127
128128 #define STATE_VERSION 2
129129
130-void MOUSE::save_state(FILEIO* state_fio)
130+bool MOUSE::process_state(FILEIO* state_fio, bool loading)
131131 {
132- state_fio->FputUint32(STATE_VERSION);
133- state_fio->FputInt32(this_device_id);
134-
135- state_fio->FputInt32(ctrlreg);
136- state_fio->FputInt32(freq);
137- state_fio->FputInt32(cur_freq);
138- state_fio->FputInt32(dx);
139- state_fio->FputInt32(dy);
140- state_fio->FputInt32(lx);
141- state_fio->FputInt32(ly);
142- state_fio->FputInt32(register_id);
143-}
144-
145-bool MOUSE::load_state(FILEIO* state_fio)
146-{
147- if(state_fio->FgetUint32() != STATE_VERSION) {
132+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
148133 return false;
149134 }
150- if(state_fio->FgetInt32() != this_device_id) {
135+ if(!state_fio->StateCheckInt32(this_device_id)) {
151136 return false;
152137 }
153- ctrlreg = state_fio->FgetInt32();
154- freq = state_fio->FgetInt32();
155- cur_freq = state_fio->FgetInt32();
156- dx = state_fio->FgetInt32();
157- dy = state_fio->FgetInt32();
158- lx = state_fio->FgetInt32();
159- ly = state_fio->FgetInt32();
160- register_id = state_fio->FgetInt32();
138+ state_fio->StateInt32(ctrlreg);
139+ state_fio->StateInt32(freq);
140+ state_fio->StateInt32(cur_freq);
141+ state_fio->StateInt32(dx);
142+ state_fio->StateInt32(dy);
143+ state_fio->StateInt32(lx);
144+ state_fio->StateInt32(ly);
145+ state_fio->StateInt32(register_id);
161146 return true;
162147 }
163148
--- a/source/src/vm/pc9801/mouse.h
+++ b/source/src/vm/pc9801/mouse.h
@@ -55,8 +55,7 @@ public:
5555 void event_callback(int event_id, int err);
5656 void event_frame();
5757 void write_signal(int id, uint32_t data, uint32_t mask);
58- void save_state(FILEIO* state_fio);
59- bool load_state(FILEIO* state_fio);
58+ bool process_state(FILEIO* state_fio, bool loading);
6059
6160 // unique functions
6261 void set_context_pic(DEVICE* device)
--- a/source/src/vm/pc9801/pc9801.cpp
+++ b/source/src/vm/pc9801/pc9801.cpp
@@ -908,7 +908,6 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
908908 for(DEVICE* device = first_device; device; device = device->next_device) {
909909 device->initialize();
910910 }
911- decl_state();
912911
913912 #if defined(_PC9801) || defined(_PC9801E)
914913 fdc_2hd->get_disk_handler(0)->drive_num = 0;
@@ -1580,78 +1579,40 @@ void VM::update_config()
15801579
15811580 #define STATE_VERSION 13
15821581
1583-#include "../../statesub.h"
1584-#include "../../qt/gui/csp_logger.h"
1585-extern CSP_Logger DLL_PREFIX_I *csp_logger;
1586-
1587-void VM::decl_state(void)
1588-{
1589-#if defined(_PC9801)
1590- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801_HEAD")), csp_logger);
1591-#elif defined(_PC9801E)
1592- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801E_HEAD")), csp_logger);
1593-#elif defined(_PC9801U)
1594- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801U_HEAD")), csp_logger);
1595-#elif defined(_PC9801VF)
1596- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801VF_HEAD")), csp_logger);
1597-#elif defined(_PC9801VM)
1598- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801VF_HEAD")), csp_logger);
1599-#elif defined(_PC98DO)
1600- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC98DO_HEAD")), csp_logger);
1601-#elif defined(_PC9801DOPLUS)
1602- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC98DO_PLUS_HEAD")), csp_logger);
1603-#elif defined(_PC9801VX)
1604- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801VX_HEAD")), csp_logger);
1605-#elif defined(_PC98XL)
1606- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC98XL_HEAD")), csp_logger);
1607-#elif defined(_PC98XA)
1608- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC98XA_HEAD")), csp_logger);
1609-#elif defined(_PC9801RA)
1610- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801RA_HEAD")), csp_logger);
1611-#elif defined(_PC98RL)
1612- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC98RL_HEAD")), csp_logger);
1613-#else
1614- state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801_SERIES_HEAD")), csp_logger);
1615-#endif
1616-
1617- DECL_STATE_ENTRY_BOOL(pit_clock_8mhz);
1618-#if defined(_PC98DO) || defined(_PC98DOPLUS)
1619- DECL_STATE_ENTRY_INT32(boot_mode);
1620-#endif
1621- DECL_STATE_ENTRY_INT32(sound_type);
1622-#if defined(USE_HARD_DISK) && defined(OPEN_HARD_DISK_IN_RESET)
1623- DECL_STATE_ENTRY_MULTI(void, hd_file_path, sizeof(hd_file_path));
1624-#endif
1625- for(DEVICE* device = first_device; device; device = device->next_device) {
1626- device->decl_state();
1627- }
1628-}
1629-
1630-void VM::save_state(FILEIO* state_fio)
1582+bool VM::process_state(FILEIO* state_fio, bool loading)
16311583 {
1632- if(state_entry != NULL) {
1633- state_entry->save_state(state_fio);
1634- }
1635- for(DEVICE* device = first_device; device; device = device->next_device) {
1636- device->save_state(state_fio);
1637- }
1638-}
1639-
1640-bool VM::load_state(FILEIO* state_fio)
1641-{
1642- bool mb = false;
1643- if(state_entry != NULL) {
1644- mb = state_entry->load_state(state_fio);
1645- }
1646- if(!mb) {
1647- emu->out_debug_log("INFO: HEADER DATA ERROR");
1648- return false;
1649- }
1650- for(DEVICE* device = first_device; device; device = device->next_device) {
1651- if(!device->load_state(state_fio)) {
1584+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
1585+ return false;
1586+ }
1587+ for(DEVICE* device = first_device; device; device = device->next_device) {
1588+ // Note: typeid(foo).name is fixed by recent ABI.Not dec 6.
1589+ // const char *name = typeid(*device).name();
1590+ // But, using get_device_name() instead of typeid(foo).name() 20181008 K.O
1591+ const char *name = device->get_device_name();
1592+ int len = strlen(name);
1593+ if(!state_fio->StateCheckInt32(len)) {
1594+ if(loading) {
1595+ printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
1596+ }
16521597 return false;
16531598 }
1654- }
1655- return true;
1599+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
1600+ if(loading) {
1601+ printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
1602+ }
1603+ return false;
1604+ }
1605+ if(!device->process_state(state_fio, loading)) {
1606+ if(loading) {
1607+ printf("Data loading Error: DEVID=%d\n", device->this_device_id);
1608+ }
1609+ return false;
1610+ }
1611+ }
1612+ state_fio->StateBool(pit_clock_8mhz);
1613+#if defined(_PC98DO) || defined(_PC98DOPLUS)
1614+ state_fio->StateInt32(boot_mode);
1615+#endif
1616+ state_fio->StateInt32(sound_type);
1617+ return true;
16561618 }
1657-
--- a/source/src/vm/pc9801/pc9801.h
+++ b/source/src/vm/pc9801/pc9801.h
@@ -609,9 +609,7 @@ public:
609609 bool is_frame_skippable();
610610
611611 void update_config();
612- void decl_state();
613- void save_state(FILEIO* state_fio);
614- bool load_state(FILEIO* state_fio);
612+ bool process_state(FILEIO* state_fio, bool loading);
615613
616614 // ----------------------------------------
617615 // for each device
--- a/source/src/vm/pc9801/sasi.cpp
+++ b/source/src/vm/pc9801/sasi.cpp
@@ -197,27 +197,17 @@ void SASI::write_signal(int id, uint32_t data, uint32_t mask)
197197
198198 #define STATE_VERSION 2
199199
200-void SASI::save_state(FILEIO* state_fio)
200+bool SASI::process_state(FILEIO* state_fio, bool loading)
201201 {
202- state_fio->FputUint32(STATE_VERSION);
203- state_fio->FputInt32(this_device_id);
204-
205- state_fio->FputUint8(ocr);
206- state_fio->FputBool(irq_status);
207- state_fio->FputBool(drq_status);
208-}
209-
210-bool SASI::load_state(FILEIO* state_fio)
211-{
212- if(state_fio->FgetUint32() != STATE_VERSION) {
202+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
213203 return false;
214204 }
215- if(state_fio->FgetInt32() != this_device_id) {
205+ if(!state_fio->StateCheckInt32(this_device_id)) {
216206 return false;
217207 }
218- ocr = state_fio->FgetUint8();
219- irq_status = state_fio->FgetBool();
220- drq_status = state_fio->FgetBool();
208+ state_fio->StateUint8(ocr);
209+ state_fio->StateBool(irq_status);
210+ state_fio->StateBool(drq_status);
221211 return true;
222212 }
223213
--- a/source/src/vm/pc9801/sasi.h
+++ b/source/src/vm/pc9801/sasi.h
@@ -49,8 +49,7 @@ public:
4949 // void write_dma_io8(uint32_t addr, uint32_t data);
5050 // uint32_t read_dma_io8(uint32_t addr);
5151 void write_signal(int id, uint32_t data, uint32_t mask);
52- void save_state(FILEIO* state_fio);
53- bool load_state(FILEIO* state_fio);
52+ bool process_state(FILEIO* state_fio, bool loading);
5453
5554 // unique functions
5655 void set_context_host(DEVICE* device)
Show on old repository browser