Common Source Code Project for Qt (a.k.a for FM-7).
Revision | 7fc095b6611c43312d90eb6741f78f1fbb0100ca (tree) |
---|---|
Zeit | 2018-10-14 18:16:24 |
Autor | K.Ohta <whatisthis.sowhat@gmai...> |
Commiter | K.Ohta |
[VM][PC9801] Enable to build PC-9801 with upstream 2018-10-05.
@@ -106,31 +106,19 @@ void CMT::release_tape() | ||
106 | 106 | |
107 | 107 | #define STATE_VERSION 1 |
108 | 108 | |
109 | -void CMT::save_state(FILEIO* state_fio) | |
109 | +bool CMT::process_state(FILEIO* state_fio, bool loading) | |
110 | 110 | { |
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)) { | |
124 | 112 | return false; |
125 | 113 | } |
126 | - if(state_fio->FgetInt32() != this_device_id) { | |
114 | + if(!state_fio->StateCheckInt32(this_device_id)) { | |
127 | 115 | return false; |
128 | 116 | } |
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); | |
134 | 122 | return true; |
135 | 123 | } |
136 | 124 |
@@ -48,8 +48,7 @@ public: | ||
48 | 48 | void reset(); |
49 | 49 | void write_io8(uint32_t addr, uint32_t data); |
50 | 50 | 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); | |
53 | 52 | |
54 | 53 | // unique functions |
55 | 54 | void set_context_sio(DEVICE* device) |
@@ -106,42 +106,14 @@ uint32_t CPUREG::read_io8(uint32_t addr) | ||
106 | 106 | |
107 | 107 | #define STATE_VERSION 1 |
108 | 108 | |
109 | -#include "../statesub.h" | |
110 | - | |
111 | -void CPUREG::decl_state() | |
109 | +bool CPUREG::process_state(FILEIO* state_fio, bool loading) | |
112 | 110 | { |
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; | |
118 | 119 | } |
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 | - |
@@ -45,9 +45,7 @@ public: | ||
45 | 45 | void reset(); |
46 | 46 | void write_io8(uint32_t addr, uint32_t data); |
47 | 47 | 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); | |
51 | 49 | |
52 | 50 | // unique function |
53 | 51 | #if defined(SUPPORT_32BIT_ADDRESS) |
@@ -2576,252 +2576,142 @@ void DISPLAY::draw_gfx_screen() | ||
2576 | 2576 | |
2577 | 2577 | #define STATE_VERSION 3 |
2578 | 2578 | |
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); | |
2596 | 2589 | #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); | |
2602 | 2614 | #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); | |
2610 | 2641 | #if defined(SUPPORT_16_COLORS) |
2611 | - DECL_STATE_ENTRY_1D_ARRAY(modereg2, sizeof(modereg2)); | |
2642 | + state_fio->StateBuffer(modereg2, sizeof(modereg2), 1); | |
2612 | 2643 | #endif |
2613 | 2644 | #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); | |
2661 | 2648 | #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 | |
2799 | 2649 | #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 | |
2803 | 2691 | #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; | |
2808 | 2697 | #if defined(SUPPORT_16_COLORS) |
2809 | - vram_disp_e = vram + 0x20000; | |
2698 | + vram_disp_e = vram + 0x20000; | |
2810 | 2699 | #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; | |
2815 | 2704 | #if defined(SUPPORT_16_COLORS) |
2816 | - vram_disp_e = vram + 0x00000; | |
2705 | + vram_disp_e = vram + 0x00000; | |
2817 | 2706 | #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 | + } | |
2824 | 2714 | #endif |
2825 | - return true; | |
2715 | + return true; | |
2826 | 2716 | } |
2827 | 2717 |
@@ -219,9 +219,7 @@ public: | ||
219 | 219 | void write_dma_io16(uint32_t addr, uint32_t data); |
220 | 220 | uint32_t read_dma_io8(uint32_t addr); |
221 | 221 | 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); | |
225 | 223 | |
226 | 224 | // unique functions |
227 | 225 | void set_context_pic(DEVICE *device) |
@@ -82,39 +82,15 @@ uint32_t DMAREG::read_io8(uint32_t addr) | ||
82 | 82 | /* |
83 | 83 | #define STATE_VERSION 1 |
84 | 84 | |
85 | -#include "../statesub.h" | |
86 | - | |
87 | -void DMAREG::decl_state() | |
85 | +bool DMAREG::process_state(FILEIO* state_fio, bool loading) | |
88 | 86 | { |
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; | |
102 | 94 | } |
103 | 95 | |
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 | -} | |
120 | 96 | */ |
@@ -33,8 +33,7 @@ public: | ||
33 | 33 | // common functions |
34 | 34 | void write_io8(uint32_t addr, uint32_t data); |
35 | 35 | 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); | |
38 | 37 | |
39 | 38 | // unique function |
40 | 39 | void set_context_dma(DEVICE* device) |
@@ -319,43 +319,25 @@ void FLOPPY::event_callback(int event_id, int err) | ||
319 | 319 | |
320 | 320 | #define STATE_VERSION 1 |
321 | 321 | |
322 | -void FLOPPY::save_state(FILEIO* state_fio) | |
322 | +bool FLOPPY::process_state(FILEIO* state_fio, bool loading) | |
323 | 323 | { |
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)) { | |
343 | 325 | return false; |
344 | 326 | } |
345 | - if(state_fio->FgetInt32() != this_device_id) { | |
327 | + if(!state_fio->StateCheckInt32(this_device_id)) { | |
346 | 328 | return false; |
347 | 329 | } |
348 | 330 | #if defined(SUPPORT_2HD_FDD_IF) |
349 | - ctrlreg_2hd = state_fio->FgetUint8(); | |
331 | + state_fio->StateUint8(ctrlreg_2hd); | |
350 | 332 | #endif |
351 | 333 | #if defined(SUPPORT_2DD_FDD_IF) |
352 | - ctrlreg_2dd = state_fio->FgetUint8(); | |
334 | + state_fio->StateUint8(ctrlreg_2dd); | |
353 | 335 | #endif |
354 | 336 | #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); | |
357 | 339 | #endif |
358 | - timer_id = state_fio->FgetInt32(); | |
340 | + state_fio->StateInt32(timer_id); | |
359 | 341 | return true; |
360 | 342 | } |
361 | 343 |
@@ -71,8 +71,7 @@ public: | ||
71 | 71 | uint32_t read_io8(uint32_t addr); |
72 | 72 | void write_signal(int id, uint32_t data, uint32_t mask); |
73 | 73 | 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); | |
76 | 75 | |
77 | 76 | // unique functions |
78 | 77 | #if defined(SUPPORT_2HD_FDD_IF) |
@@ -84,23 +84,15 @@ uint32_t FMSOUND::read_io8(uint32_t addr) | ||
84 | 84 | #ifdef SUPPORT_PC98_OPNA |
85 | 85 | #define STATE_VERSION 1 |
86 | 86 | |
87 | -void FMSOUND::save_state(FILEIO* state_fio) | |
87 | +bool FMSOUND::process_state(FILEIO* state_fio, bool loading) | |
88 | 88 | { |
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)) { | |
98 | 90 | return false; |
99 | 91 | } |
100 | - if(state_fio->FgetInt32() != this_device_id) { | |
92 | + if(!state_fio->StateCheckInt32(this_device_id)) { | |
101 | 93 | return false; |
102 | 94 | } |
103 | - mask = state_fio->FgetUint8(); | |
95 | + state_fio->StateUint8(mask); | |
104 | 96 | return true; |
105 | 97 | } |
106 | 98 | #endif |
@@ -50,8 +50,7 @@ public: | ||
50 | 50 | void write_io8(uint32_t addr, uint32_t data); |
51 | 51 | uint32_t read_io8(uint32_t addr); |
52 | 52 | #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); | |
55 | 54 | #endif |
56 | 55 | |
57 | 56 | // unique function |
@@ -43,23 +43,15 @@ void JOYSTICK::event_frame() | ||
43 | 43 | |
44 | 44 | #define STATE_VERSION 1 |
45 | 45 | |
46 | -void JOYSTICK::save_state(FILEIO* state_fio) | |
46 | +bool JOYSTICK::process_state(FILEIO* state_fio, bool loading) | |
47 | 47 | { |
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)) { | |
57 | 49 | return false; |
58 | 50 | } |
59 | - if(state_fio->FgetInt32() != this_device_id) { | |
51 | + if(!state_fio->StateCheckInt32(this_device_id)) { | |
60 | 52 | return false; |
61 | 53 | } |
62 | - select = state_fio->FgetUint8(); | |
54 | + state_fio->StateUint8(select); | |
63 | 55 | return true; |
64 | 56 | } |
65 | 57 |
@@ -45,8 +45,7 @@ public: | ||
45 | 45 | void initialize(); |
46 | 46 | void write_signal(int id, uint32_t data, uint32_t mask); |
47 | 47 | 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); | |
50 | 49 | |
51 | 50 | // unique function |
52 | 51 | void set_context_opn(DEVICE* device) |
@@ -85,27 +85,17 @@ void KEYBOARD::key_up(int code) | ||
85 | 85 | |
86 | 86 | #define STATE_VERSION 1 |
87 | 87 | |
88 | -void KEYBOARD::save_state(FILEIO* state_fio) | |
88 | +bool KEYBOARD::process_state(FILEIO* state_fio, bool loading) | |
89 | 89 | { |
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)) { | |
101 | 91 | return false; |
102 | 92 | } |
103 | - if(state_fio->FgetInt32() != this_device_id) { | |
93 | + if(!state_fio->StateCheckInt32(this_device_id)) { | |
104 | 94 | return false; |
105 | 95 | } |
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); | |
109 | 99 | return true; |
110 | 100 | } |
111 | 101 |
@@ -44,8 +44,7 @@ public: | ||
44 | 44 | // common functions |
45 | 45 | void initialize(); |
46 | 46 | 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); | |
49 | 48 | |
50 | 49 | // unique functions |
51 | 50 | void set_context_sio(DEVICE* device) |
@@ -535,172 +535,73 @@ void MEMBUS::update_nec_ems() | ||
535 | 535 | |
536 | 536 | #define STATE_VERSION 4 |
537 | 537 | |
538 | -#include "../statesub.h" | |
539 | - | |
540 | -void MEMBUS::decl_state() | |
538 | +bool MEMBUS::process_state(FILEIO* state_fio, bool loading) | |
541 | 539 | { |
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); | |
545 | 547 | #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); | |
548 | 550 | #endif |
549 | 551 | #if defined(SUPPORT_ITF_ROM) |
550 | - DECL_STATE_ENTRY_BOOL(itf_selected); | |
552 | + state_fio->StateBool(itf_selected); | |
551 | 553 | #endif |
552 | 554 | #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); | |
556 | 558 | #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); | |
560 | 562 | #endif |
561 | 563 | #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); | |
565 | 567 | #endif |
566 | 568 | #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); | |
570 | 572 | #endif |
571 | 573 | #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); | |
574 | 576 | #endif |
575 | 577 | #endif |
576 | 578 | #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(); | |
689 | 590 | #if !defined(SUPPORT_HIRESO) |
690 | - update_sound_bios(); | |
591 | + update_sound_bios(); | |
691 | 592 | #if defined(SUPPORT_SASI_IF) |
692 | - update_sasi_bios(); | |
593 | + update_sasi_bios(); | |
693 | 594 | #endif |
694 | 595 | #if defined(SUPPORT_SCSI_IF) |
695 | - update_scsi_bios(); | |
596 | + update_scsi_bios(); | |
696 | 597 | #endif |
697 | 598 | #if defined(SUPPORT_IDE_IF) |
698 | - update_ide_bios(); | |
599 | + update_ide_bios(); | |
699 | 600 | #endif |
700 | 601 | #if defined(SUPPORT_EMS) |
701 | - update_nec_ems(); | |
602 | + update_nec_ems(); | |
702 | 603 | #endif |
703 | 604 | #endif |
704 | -// return MEMORY::load_state(state_fio); | |
705 | - return true; | |
605 | + } | |
606 | + return true; | |
706 | 607 | } |
@@ -129,9 +129,7 @@ public: | ||
129 | 129 | uint32_t read_dma_data8(uint32_t addr); |
130 | 130 | void write_dma_data8(uint32_t addr, uint32_t data); |
131 | 131 | #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); | |
135 | 133 | |
136 | 134 | // unique functions |
137 | 135 | void set_context_display(DISPLAY* device) |
@@ -127,37 +127,22 @@ void MOUSE::update_mouse() | ||
127 | 127 | |
128 | 128 | #define STATE_VERSION 2 |
129 | 129 | |
130 | -void MOUSE::save_state(FILEIO* state_fio) | |
130 | +bool MOUSE::process_state(FILEIO* state_fio, bool loading) | |
131 | 131 | { |
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)) { | |
148 | 133 | return false; |
149 | 134 | } |
150 | - if(state_fio->FgetInt32() != this_device_id) { | |
135 | + if(!state_fio->StateCheckInt32(this_device_id)) { | |
151 | 136 | return false; |
152 | 137 | } |
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); | |
161 | 146 | return true; |
162 | 147 | } |
163 | 148 |
@@ -55,8 +55,7 @@ public: | ||
55 | 55 | void event_callback(int event_id, int err); |
56 | 56 | void event_frame(); |
57 | 57 | 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); | |
60 | 59 | |
61 | 60 | // unique functions |
62 | 61 | void set_context_pic(DEVICE* device) |
@@ -908,7 +908,6 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) | ||
908 | 908 | for(DEVICE* device = first_device; device; device = device->next_device) { |
909 | 909 | device->initialize(); |
910 | 910 | } |
911 | - decl_state(); | |
912 | 911 | |
913 | 912 | #if defined(_PC9801) || defined(_PC9801E) |
914 | 913 | fdc_2hd->get_disk_handler(0)->drive_num = 0; |
@@ -1580,78 +1579,40 @@ void VM::update_config() | ||
1580 | 1579 | |
1581 | 1580 | #define STATE_VERSION 13 |
1582 | 1581 | |
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) | |
1631 | 1583 | { |
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 | + } | |
1652 | 1597 | return false; |
1653 | 1598 | } |
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; | |
1656 | 1618 | } |
1657 | - |
@@ -609,9 +609,7 @@ public: | ||
609 | 609 | bool is_frame_skippable(); |
610 | 610 | |
611 | 611 | 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); | |
615 | 613 | |
616 | 614 | // ---------------------------------------- |
617 | 615 | // for each device |
@@ -197,27 +197,17 @@ void SASI::write_signal(int id, uint32_t data, uint32_t mask) | ||
197 | 197 | |
198 | 198 | #define STATE_VERSION 2 |
199 | 199 | |
200 | -void SASI::save_state(FILEIO* state_fio) | |
200 | +bool SASI::process_state(FILEIO* state_fio, bool loading) | |
201 | 201 | { |
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)) { | |
213 | 203 | return false; |
214 | 204 | } |
215 | - if(state_fio->FgetInt32() != this_device_id) { | |
205 | + if(!state_fio->StateCheckInt32(this_device_id)) { | |
216 | 206 | return false; |
217 | 207 | } |
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); | |
221 | 211 | return true; |
222 | 212 | } |
223 | 213 |
@@ -49,8 +49,7 @@ public: | ||
49 | 49 | // void write_dma_io8(uint32_t addr, uint32_t data); |
50 | 50 | // uint32_t read_dma_io8(uint32_t addr); |
51 | 51 | 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); | |
54 | 53 | |
55 | 54 | // unique functions |
56 | 55 | void set_context_host(DEVICE* device) |