• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

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


Commit MetaInfo

Revision485f897f1474f2028d0b2b2e679f6bd9e10a8532 (tree)
Time2018-07-05 17:11:59
AuthorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[VM][STATE] Apply new state framework to MZ80B, MZ2200 and MZ2500.

Change Summary

Incremental Difference

--- a/source/src/vm/mz2500/crtc.cpp
+++ b/source/src/vm/mz2500/crtc.cpp
@@ -1692,129 +1692,203 @@ void CRTC::create_addr_map(int xmax, int ymax)
16921692
16931693 #define STATE_VERSION 1
16941694
1695+#include "../../statesub.h"
1696+
1697+void CRTC::decl_state()
1698+{
1699+ enter_decl_state(STATE_VERSION);
1700+
1701+ DECL_STATE_ENTRY_BOOL(scan_line);
1702+ DECL_STATE_ENTRY_BOOL(scan_tmp);
1703+ DECL_STATE_ENTRY_BOOL(monitor_200line);
1704+ DECL_STATE_ENTRY_BOOL(monitor_digital);
1705+ DECL_STATE_ENTRY_BOOL(monitor_tmp);
1706+ DECL_STATE_ENTRY_UINT8(textreg_num);
1707+ DECL_STATE_ENTRY_1D_ARRAY(textreg, sizeof(textreg));
1708+ DECL_STATE_ENTRY_UINT8(cgreg_num);
1709+ DECL_STATE_ENTRY_1D_ARRAY(cgreg, sizeof(cgreg));
1710+ DECL_STATE_ENTRY_UINT8(scrn_size);
1711+ DECL_STATE_ENTRY_UINT8(cg_mask);
1712+ DECL_STATE_ENTRY_UINT8(cg_mask256);
1713+ DECL_STATE_ENTRY_BOOL(cg_mask256_init);
1714+ DECL_STATE_ENTRY_BOOL(font_size);
1715+ DECL_STATE_ENTRY_BOOL(column_size);
1716+ DECL_STATE_ENTRY_1D_ARRAY(latch, sizeof(latch));
1717+ DECL_STATE_ENTRY_UINT16(GDEVS);
1718+ DECL_STATE_ENTRY_UINT16(GDEVE);
1719+ DECL_STATE_ENTRY_UINT8(GDEHS);
1720+ DECL_STATE_ENTRY_UINT8(GDEHE);
1721+ DECL_STATE_ENTRY_INT32(GDEHSC);
1722+ DECL_STATE_ENTRY_INT32(GDEHEC);
1723+ DECL_STATE_ENTRY_BOOL(hblank);
1724+ DECL_STATE_ENTRY_BOOL(vblank);
1725+ DECL_STATE_ENTRY_BOOL(blink);
1726+ DECL_STATE_ENTRY_UINT8(clear_flag);
1727+ DECL_STATE_ENTRY_1D_ARRAY(palette_reg, sizeof(palette_reg));
1728+ DECL_STATE_ENTRY_BOOL(pal_select);
1729+ DECL_STATE_ENTRY_BOOL(screen_mask);
1730+ DECL_STATE_ENTRY_2D_ARRAY(priority16, 16, 9);
1731+ // ToDo: scrntype_t
1732+ DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette16, sizeof(palette16) / sizeof(scrntype_t));
1733+ DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette4096, sizeof(palette4096) / sizeof(scrntype_t));
1734+ DECL_STATE_ENTRY_1D_ARRAY(palette4096r, sizeof(palette4096r));
1735+ DECL_STATE_ENTRY_1D_ARRAY(palette4096g, sizeof(palette4096g));
1736+ DECL_STATE_ENTRY_1D_ARRAY(palette4096b, sizeof(palette4096b));
1737+ DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette16txt, sizeof(palette16txt) / sizeof(scrntype_t));
1738+ DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette4096txt, sizeof(palette4096txt) / sizeof(scrntype_t));
1739+ DECL_STATE_ENTRY_SCRNTYPE_T_2D_ARRAY(palette16pri, 16, 9);
1740+ DECL_STATE_ENTRY_SCRNTYPE_T_2D_ARRAY(palette4096pri, 16, 9);
1741+ DECL_STATE_ENTRY_UINT8(prev16);
1742+ DECL_STATE_ENTRY_BOOL(update16);
1743+ DECL_STATE_ENTRY_2D_ARRAY(priority256, 256, 16+64);
1744+ DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette256, sizeof(palette256) / sizeof(scrntype_t));
1745+ DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette256txt, sizeof(palette256txt) / sizeof(scrntype_t));
1746+ DECL_STATE_ENTRY_SCRNTYPE_T_2D_ARRAY(palette256pri, 256, 16+64);
1747+ DECL_STATE_ENTRY_SCRNTYPE_T(prev256);
1748+ DECL_STATE_ENTRY_BOOL(update256);
1749+ DECL_STATE_ENTRY_2D_ARRAY(map_addr, 400, 80);
1750+ DECL_STATE_ENTRY_2D_ARRAY(map_hdsc, 400, 80);
1751+ DECL_STATE_ENTRY_3D_ARRAY(text_matrix, 256, 8, 8);
1752+ DECL_STATE_ENTRY_3D_ARRAY(text_matrixw, 256, 8, 8);
1753+ DECL_STATE_ENTRY_UINT8(trans_color);
1754+ DECL_STATE_ENTRY_BOOL(map_init);
1755+ DECL_STATE_ENTRY_BOOL(trans_init);
1756+ leave_decl_state();
1757+}
1758+
16951759 void CRTC::save_state(FILEIO* state_fio)
16961760 {
1697- state_fio->FputUint32(STATE_VERSION);
1698- state_fio->FputInt32(this_device_id);
1761+ if(state_entry != NULL) {
1762+ state_entry->save_state(state_fio);
1763+ }
1764+// state_fio->FputUint32(STATE_VERSION);
1765+// state_fio->FputInt32(this_device_id);
16991766
1700- state_fio->FputBool(scan_line);
1701- state_fio->FputBool(scan_tmp);
1702- state_fio->FputBool(monitor_200line);
1703- state_fio->FputBool(monitor_digital);
1704- state_fio->FputBool(monitor_tmp);
1705- state_fio->FputUint8(textreg_num);
1706- state_fio->Fwrite(textreg, sizeof(textreg), 1);
1707- state_fio->FputUint8(cgreg_num);
1708- state_fio->Fwrite(cgreg, sizeof(cgreg), 1);
1709- state_fio->FputUint8(scrn_size);
1710- state_fio->FputUint8(cg_mask);
1711- state_fio->FputUint8(cg_mask256);
1712- state_fio->FputBool(cg_mask256_init);
1713- state_fio->FputBool(font_size);
1714- state_fio->FputBool(column_size);
1715- state_fio->Fwrite(latch, sizeof(latch), 1);
1716- state_fio->FputUint16(GDEVS);
1717- state_fio->FputUint16(GDEVE);
1718- state_fio->FputUint8(GDEHS);
1719- state_fio->FputUint8(GDEHE);
1720- state_fio->FputInt32(GDEHSC);
1721- state_fio->FputInt32(GDEHEC);
1722- state_fio->FputBool(hblank);
1723- state_fio->FputBool(vblank);
1724- state_fio->FputBool(blink);
1725- state_fio->FputUint8(clear_flag);
1726- state_fio->Fwrite(palette_reg, sizeof(palette_reg), 1);
1727- state_fio->FputBool(pal_select);
1728- state_fio->FputBool(screen_mask);
1729- state_fio->Fwrite(priority16, sizeof(priority16), 1);
1730- state_fio->Fwrite(palette16, sizeof(palette16), 1);
1731- state_fio->Fwrite(palette4096, sizeof(palette4096), 1);
1732- state_fio->Fwrite(palette4096r, sizeof(palette4096r), 1);
1733- state_fio->Fwrite(palette4096g, sizeof(palette4096g), 1);
1734- state_fio->Fwrite(palette4096b, sizeof(palette4096b), 1);
1735- state_fio->Fwrite(palette16txt, sizeof(palette16txt), 1);
1736- state_fio->Fwrite(palette4096txt, sizeof(palette4096txt), 1);
1737- state_fio->Fwrite(palette16pri, sizeof(palette16pri), 1);
1738- state_fio->Fwrite(palette4096pri, sizeof(palette4096pri), 1);
1739- state_fio->FputUint8(prev16);
1740- state_fio->FputBool(update16);
1741- state_fio->Fwrite(priority256, sizeof(priority256), 1);
1742- state_fio->Fwrite(palette256, sizeof(palette256), 1);
1743- state_fio->Fwrite(palette256txt, sizeof(palette256txt), 1);
1744- state_fio->Fwrite(palette256pri, sizeof(palette256pri), 1);
1745- state_fio->FputUint32((uint32_t)prev256);
1746- state_fio->FputBool(update256);
1747- state_fio->Fwrite(map_addr, sizeof(map_addr), 1);
1748- state_fio->Fwrite(map_hdsc, sizeof(map_hdsc), 1);
1749- state_fio->Fwrite(text_matrix, sizeof(text_matrix), 1);
1750- state_fio->Fwrite(text_matrixw, sizeof(text_matrixw), 1);
1751- state_fio->FputUint8(trans_color);
1752- state_fio->FputBool(map_init);
1753- state_fio->FputBool(trans_init);
1767+// state_fio->FputBool(scan_line);
1768+// state_fio->FputBool(scan_tmp);
1769+// state_fio->FputBool(monitor_200line);
1770+// state_fio->FputBool(monitor_digital);
1771+// state_fio->FputBool(monitor_tmp);
1772+// state_fio->FputUint8(textreg_num);
1773+// state_fio->Fwrite(textreg, sizeof(textreg), 1);
1774+// state_fio->FputUint8(cgreg_num);
1775+// state_fio->Fwrite(cgreg, sizeof(cgreg), 1);
1776+// state_fio->FputUint8(scrn_size);
1777+// state_fio->FputUint8(cg_mask);
1778+// state_fio->FputUint8(cg_mask256);
1779+// state_fio->FputBool(cg_mask256_init);
1780+// state_fio->FputBool(font_size);
1781+// state_fio->FputBool(column_size);
1782+// state_fio->Fwrite(latch, sizeof(latch), 1);
1783+// state_fio->FputUint16(GDEVS);
1784+// state_fio->FputUint16(GDEVE);
1785+// state_fio->FputUint8(GDEHS);
1786+// state_fio->FputUint8(GDEHE);
1787+// state_fio->FputInt32(GDEHSC);
1788+// state_fio->FputInt32(GDEHEC);
1789+// state_fio->FputBool(hblank);
1790+// state_fio->FputBool(vblank);
1791+// state_fio->FputBool(blink);
1792+// state_fio->FputUint8(clear_flag);
1793+// state_fio->Fwrite(palette_reg, sizeof(palette_reg), 1);
1794+// state_fio->FputBool(pal_select);
1795+// state_fio->FputBool(screen_mask);
1796+// state_fio->Fwrite(priority16, sizeof(priority16), 1);
1797+// state_fio->Fwrite(palette16, sizeof(palette16), 1);
1798+// state_fio->Fwrite(palette4096, sizeof(palette4096), 1);
1799+// state_fio->Fwrite(palette4096r, sizeof(palette4096r), 1);
1800+// state_fio->Fwrite(palette4096g, sizeof(palette4096g), 1);
1801+// state_fio->Fwrite(palette4096b, sizeof(palette4096b), 1);
1802+// state_fio->Fwrite(palette16txt, sizeof(palette16txt), 1);
1803+// state_fio->Fwrite(palette4096txt, sizeof(palette4096txt), 1);
1804+// state_fio->Fwrite(palette16pri, sizeof(palette16pri), 1);
1805+// state_fio->Fwrite(palette4096pri, sizeof(palette4096pri), 1);
1806+// state_fio->FputUint8(prev16);
1807+// state_fio->FputBool(update16);
1808+// state_fio->Fwrite(priority256, sizeof(priority256), 1);
1809+// state_fio->Fwrite(palette256, sizeof(palette256), 1);
1810+// state_fio->Fwrite(palette256txt, sizeof(palette256txt), 1);
1811+// state_fio->Fwrite(palette256pri, sizeof(palette256pri), 1);
1812+// state_fio->FputUint32((uint32_t)prev256);
1813+// state_fio->FputBool(update256);
1814+// state_fio->Fwrite(map_addr, sizeof(map_addr), 1);
1815+// state_fio->Fwrite(map_hdsc, sizeof(map_hdsc), 1);
1816+// state_fio->Fwrite(text_matrix, sizeof(text_matrix), 1);
1817+// state_fio->Fwrite(text_matrixw, sizeof(text_matrixw), 1);
1818+// state_fio->FputUint8(trans_color);
1819+// state_fio->FputBool(map_init);
1820+// state_fio->FputBool(trans_init);
17541821 }
17551822
17561823 bool CRTC::load_state(FILEIO* state_fio)
17571824 {
1758- if(state_fio->FgetUint32() != STATE_VERSION) {
1759- return false;
1825+ bool mb = false;
1826+ if(state_entry != NULL) {
1827+ mb = state_entry->load_state(state_fio);
17601828 }
1761- if(state_fio->FgetInt32() != this_device_id) {
1829+ if(!mb) {
17621830 return false;
17631831 }
1764- scan_line = state_fio->FgetBool();
1765- scan_tmp = state_fio->FgetBool();
1766- monitor_200line = state_fio->FgetBool();
1767- monitor_digital = state_fio->FgetBool();
1768- monitor_tmp = state_fio->FgetBool();
1769- textreg_num = state_fio->FgetUint8();
1770- state_fio->Fread(textreg, sizeof(textreg), 1);
1771- cgreg_num = state_fio->FgetUint8();
1772- state_fio->Fread(cgreg, sizeof(cgreg), 1);
1773- scrn_size = state_fio->FgetUint8();
1774- cg_mask = state_fio->FgetUint8();
1775- cg_mask256 = state_fio->FgetUint8();
1776- cg_mask256_init = state_fio->FgetBool();
1777- font_size = state_fio->FgetBool();
1778- column_size = state_fio->FgetBool();
1779- state_fio->Fread(latch, sizeof(latch), 1);
1780- GDEVS = state_fio->FgetUint16();
1781- GDEVE = state_fio->FgetUint16();
1782- GDEHS = state_fio->FgetUint8();
1783- GDEHE = state_fio->FgetUint8();
1784- GDEHSC = state_fio->FgetInt32();
1785- GDEHEC = state_fio->FgetInt32();
1786- hblank = state_fio->FgetBool();
1787- vblank = state_fio->FgetBool();
1788- blink = state_fio->FgetBool();
1789- clear_flag = state_fio->FgetUint8();
1790- state_fio->Fread(palette_reg, sizeof(palette_reg), 1);
1791- pal_select = state_fio->FgetBool();
1792- screen_mask = state_fio->FgetBool();
1793- state_fio->Fread(priority16, sizeof(priority16), 1);
1794- state_fio->Fread(palette16, sizeof(palette16), 1);
1795- state_fio->Fread(palette4096, sizeof(palette4096), 1);
1796- state_fio->Fread(palette4096r, sizeof(palette4096r), 1);
1797- state_fio->Fread(palette4096g, sizeof(palette4096g), 1);
1798- state_fio->Fread(palette4096b, sizeof(palette4096b), 1);
1799- state_fio->Fread(palette16txt, sizeof(palette16txt), 1);
1800- state_fio->Fread(palette4096txt, sizeof(palette4096txt), 1);
1801- state_fio->Fread(palette16pri, sizeof(palette16pri), 1);
1802- state_fio->Fread(palette4096pri, sizeof(palette4096pri), 1);
1803- prev16 = state_fio->FgetUint8();
1804- update16 = state_fio->FgetBool();
1805- state_fio->Fread(priority256, sizeof(priority256), 1);
1806- state_fio->Fread(palette256, sizeof(palette256), 1);
1807- state_fio->Fread(palette256txt, sizeof(palette256txt), 1);
1808- state_fio->Fread(palette256pri, sizeof(palette256pri), 1);
1809- prev256 = (scrntype_t)state_fio->FgetUint32();
1810- update256 = state_fio->FgetBool();
1811- state_fio->Fread(map_addr, sizeof(map_addr), 1);
1812- state_fio->Fread(map_hdsc, sizeof(map_hdsc), 1);
1813- state_fio->Fread(text_matrix, sizeof(text_matrix), 1);
1814- state_fio->Fread(text_matrixw, sizeof(text_matrixw), 1);
1815- trans_color = state_fio->FgetUint8();
1816- map_init = state_fio->FgetBool();
1817- trans_init = state_fio->FgetBool();
1832+// if(state_fio->FgetUint32() != STATE_VERSION) {
1833+// return false;
1834+// }
1835+// if(state_fio->FgetInt32() != this_device_id) {
1836+// return false;
1837+// }
1838+// scan_line = state_fio->FgetBool();
1839+// scan_tmp = state_fio->FgetBool();
1840+// monitor_200line = state_fio->FgetBool();
1841+// monitor_digital = state_fio->FgetBool();
1842+// monitor_tmp = state_fio->FgetBool();
1843+// textreg_num = state_fio->FgetUint8();
1844+// state_fio->Fread(textreg, sizeof(textreg), 1);
1845+// cgreg_num = state_fio->FgetUint8();
1846+// state_fio->Fread(cgreg, sizeof(cgreg), 1);
1847+// scrn_size = state_fio->FgetUint8();
1848+// cg_mask = state_fio->FgetUint8();
1849+// cg_mask256 = state_fio->FgetUint8();
1850+// cg_mask256_init = state_fio->FgetBool();
1851+// font_size = state_fio->FgetBool();
1852+// column_size = state_fio->FgetBool();
1853+// state_fio->Fread(latch, sizeof(latch), 1);
1854+// GDEVS = state_fio->FgetUint16();
1855+// GDEVE = state_fio->FgetUint16();
1856+// GDEHS = state_fio->FgetUint8();
1857+// GDEHE = state_fio->FgetUint8();
1858+// GDEHSC = state_fio->FgetInt32();
1859+// GDEHEC = state_fio->FgetInt32();
1860+// hblank = state_fio->FgetBool();
1861+// vblank = state_fio->FgetBool();
1862+// blink = state_fio->FgetBool();
1863+// clear_flag = state_fio->FgetUint8();
1864+// state_fio->Fread(palette_reg, sizeof(palette_reg), 1);
1865+// pal_select = state_fio->FgetBool();
1866+// screen_mask = state_fio->FgetBool();
1867+// state_fio->Fread(priority16, sizeof(priority16), 1);
1868+// state_fio->Fread(palette16, sizeof(palette16), 1);
1869+// state_fio->Fread(palette4096, sizeof(palette4096), 1);
1870+// state_fio->Fread(palette4096r, sizeof(palette4096r), 1);
1871+// state_fio->Fread(palette4096g, sizeof(palette4096g), 1);
1872+// state_fio->Fread(palette4096b, sizeof(palette4096b), 1);
1873+// state_fio->Fread(palette16txt, sizeof(palette16txt), 1);
1874+// state_fio->Fread(palette4096txt, sizeof(palette4096txt), 1);
1875+// state_fio->Fread(palette16pri, sizeof(palette16pri), 1);
1876+// state_fio->Fread(palette4096pri, sizeof(palette4096pri), 1);
1877+// prev16 = state_fio->FgetUint8();
1878+// update16 = state_fio->FgetBool();
1879+// state_fio->Fread(priority256, sizeof(priority256), 1);
1880+// state_fio->Fread(palette256, sizeof(palette256), 1);
1881+// state_fio->Fread(palette256txt, sizeof(palette256txt), 1);
1882+// state_fio->Fread(palette256pri, sizeof(palette256pri), 1);
1883+// prev256 = (scrntype_t)state_fio->FgetUint32();
1884+// update256 = state_fio->FgetBool();
1885+// state_fio->Fread(map_addr, sizeof(map_addr), 1);
1886+// state_fio->Fread(map_hdsc, sizeof(map_hdsc), 1);
1887+// state_fio->Fread(text_matrix, sizeof(text_matrix), 1);
1888+// state_fio->Fread(text_matrixw, sizeof(text_matrixw), 1);
1889+// trans_color = state_fio->FgetUint8();
1890+// map_init = state_fio->FgetBool();
1891+// trans_init = state_fio->FgetBool();
18181892 return true;
18191893 }
18201894
--- a/source/src/vm/mz2500/crtc.h
+++ b/source/src/vm/mz2500/crtc.h
@@ -119,6 +119,7 @@ public:
119119 void event_callback(int event_id, int err);
120120 void event_vline(int v, int clock);
121121 void update_config();
122+ void decl_state();
122123 void save_state(FILEIO* state_fio);
123124 bool load_state(FILEIO* state_fio);
124125
--- a/source/src/vm/mz2500/floppy.cpp
+++ b/source/src/vm/mz2500/floppy.cpp
@@ -49,23 +49,44 @@ void FLOPPY::write_signal(int id, uint32_t data, uint32_t mask)
4949
5050 #define STATE_VERSION 1
5151
52+#include "../../statesub.h"
53+
54+void FLOPPY::decl_state()
55+{
56+ enter_decl_state(STATE_VERSION);
57+
58+ DECL_STATE_ENTRY_BOOL(reversed);
59+
60+ leave_decl_state();
61+}
62+
5263 void FLOPPY::save_state(FILEIO* state_fio)
5364 {
54- state_fio->FputUint32(STATE_VERSION);
55- state_fio->FputInt32(this_device_id);
65+ if(state_entry != NULL) {
66+ state_entry->save_state(state_fio);
67+ }
68+// state_fio->FputUint32(STATE_VERSION);
69+// state_fio->FputInt32(this_device_id);
5670
57- state_fio->FputBool(reversed);
71+// state_fio->FputBool(reversed);
5872 }
5973
6074 bool FLOPPY::load_state(FILEIO* state_fio)
6175 {
62- if(state_fio->FgetUint32() != STATE_VERSION) {
63- return false;
76+ bool mb = false;
77+ if(state_entry != NULL) {
78+ mb = state_entry->load_state(state_fio);
6479 }
65- if(state_fio->FgetInt32() != this_device_id) {
80+ if(!mb) {
6681 return false;
6782 }
68- reversed = state_fio->FgetBool();
83+// if(state_fio->FgetUint32() != STATE_VERSION) {
84+// return false;
85+// }
86+// if(state_fio->FgetInt32() != this_device_id) {
87+// return false;
88+// }
89+// reversed = state_fio->FgetBool();
6990 return true;
7091 }
7192 #endif
--- a/source/src/vm/mz2500/floppy.h
+++ b/source/src/vm/mz2500/floppy.h
@@ -40,6 +40,7 @@ public:
4040 void write_io8(uint32_t addr, uint32_t data);
4141 #ifdef _MZ2500
4242 void write_signal(int id, uint32_t data, uint32_t mask);
43+ void decl_state();
4344 void save_state(FILEIO* state_fio);
4445 bool load_state(FILEIO* state_fio);
4546 #endif
--- a/source/src/vm/mz2500/interrupt.cpp
+++ b/source/src/vm/mz2500/interrupt.cpp
@@ -172,33 +172,65 @@ void INTERRUPT::notify_intr_reti()
172172
173173 #define STATE_VERSION 1
174174
175+#include "../../statesub.h"
176+
177+void INTERRUPT::decl_state()
178+{
179+ enter_decl_state(STATE_VERSION);
180+
181+ DECL_STATE_ENTRY_UINT8(select);
182+ {
183+ DECL_STATE_ENTRY_UINT8_STRIDE((irq[0].vector), 4, sizeof(irq[0]));
184+ DECL_STATE_ENTRY_BOOL_STRIDE((irq[0].enb_intr), 4, sizeof(irq[0]));
185+ DECL_STATE_ENTRY_BOOL_STRIDE((irq[0].req_intr), 4, sizeof(irq[0]));
186+ DECL_STATE_ENTRY_BOOL_STRIDE((irq[0].in_service), 4, sizeof(irq[0]));
187+ }
188+ DECL_STATE_ENTRY_INT32(req_intr_ch);
189+ DECL_STATE_ENTRY_BOOL(iei);
190+ DECL_STATE_ENTRY_BOOL(oei);
191+ DECL_STATE_ENTRY_UINT32(intr_bit);
192+
193+ leave_decl_state();
194+}
195+
196+
175197 void INTERRUPT::save_state(FILEIO* state_fio)
176198 {
177- state_fio->FputUint32(STATE_VERSION);
178- state_fio->FputInt32(this_device_id);
199+ if(state_entry != NULL) {
200+ state_entry->save_state(state_fio);
201+ }
202+// state_fio->FputUint32(STATE_VERSION);
203+// state_fio->FputInt32(this_device_id);
179204
180- state_fio->FputUint8(select);
181- state_fio->Fwrite(irq, sizeof(irq), 1);
182- state_fio->FputInt32(req_intr_ch);
183- state_fio->FputBool(iei);
184- state_fio->FputBool(oei);
185- state_fio->FputUint32(intr_bit);
205+// state_fio->FputUint8(select);
206+// state_fio->Fwrite(irq, sizeof(irq), 1);
207+// state_fio->FputInt32(req_intr_ch);
208+// state_fio->FputBool(iei);
209+// state_fio->FputBool(oei);
210+// state_fio->FputUint32(intr_bit);
186211 }
187212
188213 bool INTERRUPT::load_state(FILEIO* state_fio)
189214 {
190- if(state_fio->FgetUint32() != STATE_VERSION) {
191- return false;
215+ bool mb = false;
216+ if(state_entry != NULL) {
217+ mb = state_entry->load_state(state_fio);
192218 }
193- if(state_fio->FgetInt32() != this_device_id) {
219+ if(!mb) {
194220 return false;
195221 }
196- select = state_fio->FgetUint8();
197- state_fio->Fread(irq, sizeof(irq), 1);
198- req_intr_ch = state_fio->FgetInt32();
199- iei = state_fio->FgetBool();
200- oei = state_fio->FgetBool();
201- intr_bit = state_fio->FgetUint32();
222+// if(state_fio->FgetUint32() != STATE_VERSION) {
223+// return false;
224+// }
225+// if(state_fio->FgetInt32() != this_device_id) {
226+// return false;
227+// }
228+// select = state_fio->FgetUint8();
229+// state_fio->Fread(irq, sizeof(irq), 1);
230+// req_intr_ch = state_fio->FgetInt32();
231+// iei = state_fio->FgetBool();
232+// oei = state_fio->FgetBool();
233+// intr_bit = state_fio->FgetUint32();
202234 return true;
203235 }
204236
--- a/source/src/vm/mz2500/interrupt.h
+++ b/source/src/vm/mz2500/interrupt.h
@@ -51,6 +51,7 @@ public:
5151 void reset();
5252 void write_io8(uint32_t addr, uint32_t data);
5353 void write_signal(int id, uint32_t data, uint32_t mask);
54+ void decl_state();
5455 void save_state(FILEIO* state_fio);
5556 bool load_state(FILEIO* state_fio);
5657
--- a/source/src/vm/mz2500/joystick.cpp
+++ b/source/src/vm/mz2500/joystick.cpp
@@ -53,23 +53,44 @@ uint32_t JOYSTICK::read_io8(uint32_t addr)
5353
5454 #define STATE_VERSION 2
5555
56-void JOYSTICK::save_state(FILEIO* state_fio)
56+#include "../../statesub.h"
57+
58+void JOYSTICK::decl_state()
5759 {
58- state_fio->FputUint32(STATE_VERSION);
59- state_fio->FputInt32(this_device_id);
60+ enter_decl_state(STATE_VERSION);
61+
62+ DECL_STATE_ENTRY_UINT32(mode);
6063
61- state_fio->FputUint32(mode);
64+ leave_decl_state();
65+}
66+
67+void JOYSTICK::save_state(FILEIO* state_fio)
68+{
69+ if(state_entry != NULL) {
70+ state_entry->save_state(state_fio);
71+ }
72+// state_fio->FputUint32(STATE_VERSION);
73+// state_fio->FputInt32(this_device_id);
74+//
75+// state_fio->FputUint32(mode);
6276 }
6377
6478 bool JOYSTICK::load_state(FILEIO* state_fio)
6579 {
66- if(state_fio->FgetUint32() != STATE_VERSION) {
67- return false;
80+ bool mb = false;
81+ if(state_entry != NULL) {
82+ mb = state_entry->load_state(state_fio);
6883 }
69- if(state_fio->FgetInt32() != this_device_id) {
84+ if(!mb) {
7085 return false;
7186 }
72- mode = state_fio->FgetUint32();
87+// if(state_fio->FgetUint32() != STATE_VERSION) {
88+// return false;
89+// }
90+// if(state_fio->FgetInt32() != this_device_id) {
91+// return false;
92+// }
93+// mode = state_fio->FgetUint32();
7394 return true;
7495 }
7596
--- a/source/src/vm/mz2500/joystick.h
+++ b/source/src/vm/mz2500/joystick.h
@@ -30,6 +30,7 @@ public:
3030 void initialize();
3131 void write_io8(uint32_t addr, uint32_t data);
3232 uint32_t read_io8(uint32_t addr);
33+ void decl_state();
3334 void save_state(FILEIO* state_fio);
3435 bool load_state(FILEIO* state_fio);
3536 };
--- a/source/src/vm/mz2500/keyboard.cpp
+++ b/source/src/vm/mz2500/keyboard.cpp
@@ -75,23 +75,44 @@ void KEYBOARD::create_keystat()
7575
7676 #define STATE_VERSION 1
7777
78+#include "../../statesub.h"
79+
80+void KEYBOARD::decl_state()
81+{
82+ enter_decl_state(STATE_VERSION);
83+
84+ DECL_STATE_ENTRY_UINT8(column);
85+
86+ leave_decl_state();
87+}
88+
7889 void KEYBOARD::save_state(FILEIO* state_fio)
7990 {
80- state_fio->FputUint32(STATE_VERSION);
81- state_fio->FputInt32(this_device_id);
91+ if(state_entry != NULL) {
92+ state_entry->save_state(state_fio);
93+ }
94+// state_fio->FputUint32(STATE_VERSION);
95+// state_fio->FputInt32(this_device_id);
8296
83- state_fio->FputUint8(column);
97+// state_fio->FputUint8(column);
8498 }
8599
86100 bool KEYBOARD::load_state(FILEIO* state_fio)
87101 {
88- if(state_fio->FgetUint32() != STATE_VERSION) {
89- return false;
102+ bool mb = false;
103+ if(state_entry != NULL) {
104+ mb = state_entry->load_state(state_fio);
90105 }
91- if(state_fio->FgetInt32() != this_device_id) {
106+ if(!mb) {
92107 return false;
93108 }
94- column = state_fio->FgetUint8();
109+// if(state_fio->FgetUint32() != STATE_VERSION) {
110+// return false;
111+// }
112+// if(state_fio->FgetInt32() != this_device_id) {
113+// return false;
114+// }
115+// column = state_fio->FgetUint8();
95116 return true;
96117 }
97118
--- a/source/src/vm/mz2500/keyboard.h
+++ b/source/src/vm/mz2500/keyboard.h
@@ -40,6 +40,7 @@ public:
4040 void initialize();
4141 void write_signal(int id, uint32_t data, uint32_t mask);
4242 void event_frame();
43+ void decl_state();
4344 void save_state(FILEIO* state_fio);
4445 bool load_state(FILEIO* state_fio);
4546
--- a/source/src/vm/mz2500/memory.cpp
+++ b/source/src/vm/mz2500/memory.cpp
@@ -330,45 +330,77 @@ void MEMORY::set_map(uint8_t data)
330330
331331 #define STATE_VERSION 1
332332
333+#include "../../statesub.h"
334+
335+void MEMORY::decl_state()
336+{
337+ enter_decl_state(STATE_VERSION);
338+
339+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
340+ DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
341+ DECL_STATE_ENTRY_1D_ARRAY(tvram, sizeof(tvram));
342+ DECL_STATE_ENTRY_1D_ARRAY(pcg, sizeof(pcg));
343+ DECL_STATE_ENTRY_UINT8(bank);
344+ DECL_STATE_ENTRY_1D_ARRAY(page, sizeof(page));
345+ DECL_STATE_ENTRY_UINT8(dic_bank);
346+ DECL_STATE_ENTRY_UINT8(kanji_bank);
347+ DECL_STATE_ENTRY_BOOL(blank);
348+ DECL_STATE_ENTRY_BOOL(hblank);
349+ DECL_STATE_ENTRY_BOOL(vblank);
350+ DECL_STATE_ENTRY_BOOL(busreq);
351+
352+ leave_decl_state();
353+}
354+
333355 void MEMORY::save_state(FILEIO* state_fio)
334356 {
335- state_fio->FputUint32(STATE_VERSION);
336- state_fio->FputInt32(this_device_id);
357+ if(state_entry != NULL) {
358+ state_entry->save_state(state_fio);
359+ }
360+// state_fio->FputUint32(STATE_VERSION);
361+// state_fio->FputInt32(this_device_id);
337362
338- state_fio->Fwrite(ram, sizeof(ram), 1);
339- state_fio->Fwrite(vram, sizeof(vram), 1);
340- state_fio->Fwrite(tvram, sizeof(tvram), 1);
341- state_fio->Fwrite(pcg, sizeof(pcg), 1);
342- state_fio->FputUint8(bank);
343- state_fio->Fwrite(page, sizeof(page), 1);
344- state_fio->FputUint8(dic_bank);
345- state_fio->FputUint8(kanji_bank);
346- state_fio->FputBool(blank);
347- state_fio->FputBool(hblank);
348- state_fio->FputBool(vblank);
349- state_fio->FputBool(busreq);
363+// state_fio->Fwrite(ram, sizeof(ram), 1);
364+// state_fio->Fwrite(vram, sizeof(vram), 1);
365+// state_fio->Fwrite(tvram, sizeof(tvram), 1);
366+// state_fio->Fwrite(pcg, sizeof(pcg), 1);
367+// state_fio->FputUint8(bank);
368+// state_fio->Fwrite(page, sizeof(page), 1);
369+// state_fio->FputUint8(dic_bank);
370+// state_fio->FputUint8(kanji_bank);
371+// state_fio->FputBool(blank);
372+// state_fio->FputBool(hblank);
373+// state_fio->FputBool(vblank);
374+// state_fio->FputBool(busreq);
350375 }
351376
352377 bool MEMORY::load_state(FILEIO* state_fio)
353378 {
354- if(state_fio->FgetUint32() != STATE_VERSION) {
355- return false;
379+ bool mb = false;
380+ if(state_entry != NULL) {
381+ mb = state_entry->load_state(state_fio);
356382 }
357- if(state_fio->FgetInt32() != this_device_id) {
383+ if(!mb) {
358384 return false;
359385 }
360- state_fio->Fread(ram, sizeof(ram), 1);
361- state_fio->Fread(vram, sizeof(vram), 1);
362- state_fio->Fread(tvram, sizeof(tvram), 1);
363- state_fio->Fread(pcg, sizeof(pcg), 1);
364- bank = state_fio->FgetUint8();
365- state_fio->Fread(page, sizeof(page), 1);
366- dic_bank = state_fio->FgetUint8();
367- kanji_bank = state_fio->FgetUint8();
368- blank = state_fio->FgetBool();
369- hblank = state_fio->FgetBool();
370- vblank = state_fio->FgetBool();
371- busreq = state_fio->FgetBool();
386+// if(state_fio->FgetUint32() != STATE_VERSION) {
387+// return false;
388+// }
389+// if(state_fio->FgetInt32() != this_device_id) {
390+// return false;
391+// }
392+// state_fio->Fread(ram, sizeof(ram), 1);
393+// state_fio->Fread(vram, sizeof(vram), 1);
394+// state_fio->Fread(tvram, sizeof(tvram), 1);
395+// state_fio->Fread(pcg, sizeof(pcg), 1);
396+// bank = state_fio->FgetUint8();
397+// state_fio->Fread(page, sizeof(page), 1);
398+// dic_bank = state_fio->FgetUint8();
399+// kanji_bank = state_fio->FgetUint8();
400+// blank = state_fio->FgetBool();
401+// hblank = state_fio->FgetBool();
402+// vblank = state_fio->FgetBool();
403+// busreq = state_fio->FgetBool();
372404
373405 // post process
374406 uint8_t bank_tmp = bank;
--- a/source/src/vm/mz2500/memory.h
+++ b/source/src/vm/mz2500/memory.h
@@ -68,6 +68,7 @@ public:
6868 void write_io8(uint32_t addr, uint32_t data);
6969 uint32_t read_io8(uint32_t addr);
7070 void write_signal(int id, uint32_t data, uint32_t mask);
71+ void decl_state();
7172 void save_state(FILEIO* state_fio);
7273 bool load_state(FILEIO* state_fio);
7374
--- a/source/src/vm/mz2500/memory80b.cpp
+++ b/source/src/vm/mz2500/memory80b.cpp
@@ -624,57 +624,94 @@ void MEMORY::draw_screen()
624624
625625 #define STATE_VERSION 3
626626
627-void MEMORY::save_state(FILEIO* state_fio)
627+#include "../../statesub.h"
628+
629+void MEMORY::decl_state()
628630 {
629- state_fio->FputUint32(STATE_VERSION);
630- state_fio->FputInt32(this_device_id);
631-
632- state_fio->Fwrite(ram, sizeof(ram), 1);
633- state_fio->Fwrite(vram, sizeof(vram), 1);
634- state_fio->Fwrite(tvram, sizeof(tvram), 1);
635- state_fio->FputBool(ipl_selected);
636- state_fio->FputUint8(vram_sel);
637- state_fio->FputUint8(vram_page);
638- state_fio->FputUint8(back_color);
639- state_fio->FputUint8(text_color);
640- state_fio->FputUint8(vram_mask);
641- state_fio->FputBool(width80);
642- state_fio->FputBool(reverse);
643- state_fio->FputBool(vgate);
644- state_fio->FputBool(hblank);
631+ enter_decl_state(STATE_VERSION);
632+
633+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
634+ DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
635+ DECL_STATE_ENTRY_1D_ARRAY(tvram, sizeof(tvram));
636+ DECL_STATE_ENTRY_BOOL(ipl_selected);
637+ DECL_STATE_ENTRY_UINT8(vram_sel);
638+ DECL_STATE_ENTRY_UINT8(vram_page);
639+ DECL_STATE_ENTRY_UINT8(back_color);
640+ DECL_STATE_ENTRY_UINT8(text_color);
641+ DECL_STATE_ENTRY_UINT8(vram_mask);
642+ DECL_STATE_ENTRY_BOOL(width80);
643+ DECL_STATE_ENTRY_BOOL(reverse);
644+ DECL_STATE_ENTRY_BOOL(vgate);
645+ DECL_STATE_ENTRY_BOOL(hblank);
645646 #ifdef _MZ80B
646- state_fio->Fwrite(pio3039_palette, sizeof(pio3039_palette), 1);
647- state_fio->FputBool(pio3039_txt_sw);
648- state_fio->FputUint8(pio3039_data);
647+ DECL_STATE_ENTRY_1D_ARRAY(pio3039_palette, sizeof(pio3039_palette));
648+ DECL_STATE_ENTRY_BOOL(pio3039_txt_sw);
649+ DECL_STATE_ENTRY_UINT8(pio3039_data);
649650 #endif
651+ leave_decl_state();
652+}
653+
654+void MEMORY::save_state(FILEIO* state_fio)
655+{
656+ if(state_entry != NULL) {
657+ state_entry->save_state(state_fio);
658+ }
659+// state_fio->FputUint32(STATE_VERSION);
660+// state_fio->FputInt32(this_device_id);
661+
662+// state_fio->Fwrite(ram, sizeof(ram), 1);
663+// state_fio->Fwrite(vram, sizeof(vram), 1);
664+// state_fio->Fwrite(tvram, sizeof(tvram), 1);
665+// state_fio->FputBool(ipl_selected);
666+// state_fio->FputUint8(vram_sel);
667+// state_fio->FputUint8(vram_page);
668+// state_fio->FputUint8(back_color);
669+// state_fio->FputUint8(text_color);
670+// state_fio->FputUint8(vram_mask);
671+// state_fio->FputBool(width80);
672+// state_fio->FputBool(reverse);
673+// state_fio->FputBool(vgate);
674+// state_fio->FputBool(hblank);
675+//#ifdef _MZ80B
676+// state_fio->Fwrite(pio3039_palette, sizeof(pio3039_palette), 1);
677+// state_fio->FputBool(pio3039_txt_sw);
678+// state_fio->FputUint8(pio3039_data);
679+//#endif
650680 }
651681
652682 bool MEMORY::load_state(FILEIO* state_fio)
653683 {
654- if(state_fio->FgetUint32() != STATE_VERSION) {
655- return false;
684+ bool mb = false;
685+ if(state_entry != NULL) {
686+ mb = state_entry->load_state(state_fio);
656687 }
657- if(state_fio->FgetInt32() != this_device_id) {
688+ if(!mb) {
658689 return false;
659690 }
660- state_fio->Fread(ram, sizeof(ram), 1);
661- state_fio->Fread(vram, sizeof(vram), 1);
662- state_fio->Fread(tvram, sizeof(tvram), 1);
663- ipl_selected = state_fio->FgetBool();
664- vram_sel = state_fio->FgetUint8();
665- vram_page = state_fio->FgetUint8();
666- back_color = state_fio->FgetUint8();
667- text_color = state_fio->FgetUint8();
668- vram_mask = state_fio->FgetUint8();
669- width80 = state_fio->FgetBool();
670- reverse = state_fio->FgetBool();
671- vgate = state_fio->FgetBool();
672- hblank = state_fio->FgetBool();
673-#ifdef _MZ80B
674- state_fio->Fread(pio3039_palette, sizeof(pio3039_palette), 1);
675- pio3039_txt_sw = state_fio->FgetBool();
676- pio3039_data = state_fio->FgetUint8();
677-#endif
691+// if(state_fio->FgetUint32() != STATE_VERSION) {
692+// return false;
693+// }
694+// if(state_fio->FgetInt32() != this_device_id) {
695+// return false;
696+// }
697+// state_fio->Fread(ram, sizeof(ram), 1);
698+// state_fio->Fread(vram, sizeof(vram), 1);
699+// state_fio->Fread(tvram, sizeof(tvram), 1);
700+// ipl_selected = state_fio->FgetBool();
701+// vram_sel = state_fio->FgetUint8();
702+// vram_page = state_fio->FgetUint8();
703+// back_color = state_fio->FgetUint8();
704+// text_color = state_fio->FgetUint8();
705+// vram_mask = state_fio->FgetUint8();
706+// width80 = state_fio->FgetBool();
707+// reverse = state_fio->FgetBool();
708+// vgate = state_fio->FgetBool();
709+// hblank = state_fio->FgetBool();
710+//#ifdef _MZ80B
711+// state_fio->Fread(pio3039_palette, sizeof(pio3039_palette), 1);
712+// pio3039_txt_sw = state_fio->FgetBool();
713+// pio3039_data = state_fio->FgetUint8();
714+//#endif
678715
679716 // post process
680717 if(ipl_selected) {
--- a/source/src/vm/mz2500/memory80b.h
+++ b/source/src/vm/mz2500/memory80b.h
@@ -98,6 +98,7 @@ public:
9898 void write_signal(int id, uint32_t data, uint32_t mask);
9999 void event_vline(int v, int clock);
100100 void event_callback(int event_id, int err);
101+ void decl_state();
101102 void save_state(FILEIO* state_fio);
102103 bool load_state(FILEIO* state_fio);
103104
--- a/source/src/vm/mz2500/mouse.cpp
+++ b/source/src/vm/mz2500/mouse.cpp
@@ -40,23 +40,43 @@ void MOUSE::write_signal(int id, uint32_t data, uint32_t mask)
4040
4141 #define STATE_VERSION 1
4242
43+#include "../../statesub.h"
44+
45+void MOUSE::decl_state()
46+{
47+ enter_decl_state(STATE_VERSION);
48+
49+ DECL_STATE_ENTRY_BOOL(select);
50+
51+ leave_decl_state();
52+}
4353 void MOUSE::save_state(FILEIO* state_fio)
4454 {
45- state_fio->FputUint32(STATE_VERSION);
46- state_fio->FputInt32(this_device_id);
55+ if(state_entry != NULL) {
56+ state_entry->save_state(state_fio);
57+ }
58+// state_fio->FputUint32(STATE_VERSION);
59+// state_fio->FputInt32(this_device_id);
4760
48- state_fio->FputBool(select);
61+// state_fio->FputBool(select);
4962 }
5063
5164 bool MOUSE::load_state(FILEIO* state_fio)
5265 {
53- if(state_fio->FgetUint32() != STATE_VERSION) {
54- return false;
66+ bool mb = false;
67+ if(state_entry != NULL) {
68+ mb = state_entry->load_state(state_fio);
5569 }
56- if(state_fio->FgetInt32() != this_device_id) {
70+ if(!mb) {
5771 return false;
5872 }
59- select = state_fio->FgetBool();
73+// if(state_fio->FgetUint32() != STATE_VERSION) {
74+// return false;
75+// }
76+// if(state_fio->FgetInt32() != this_device_id) {
77+// return false;
78+// }
79+// select = state_fio->FgetBool();
6080 return true;
6181 }
6282
--- a/source/src/vm/mz2500/mouse.h
+++ b/source/src/vm/mz2500/mouse.h
@@ -36,6 +36,7 @@ public:
3636 // common functions
3737 void initialize();
3838 void write_signal(int id, uint32_t data, uint32_t mask);
39+ void decl_state();
3940 void save_state(FILEIO* state_fio);
4041 bool load_state(FILEIO* state_fio);
4142
--- a/source/src/vm/mz2500/mz1e30.cpp
+++ b/source/src/vm/mz2500/mz1e30.cpp
@@ -142,27 +142,50 @@ void MZ1E30::write_signal(int id, uint32_t data, uint32_t mask)
142142
143143 #define STATE_VERSION 2
144144
145+#include "../../statesub.h"
146+
147+void MZ1E30::decl_state()
148+{
149+ enter_decl_state(STATE_VERSION);
150+
151+ DECL_STATE_ENTRY_UINT32(rom_address);
152+ DECL_STATE_ENTRY_BOOL(irq_status);
153+ DECL_STATE_ENTRY_BOOL(drq_status);
154+
155+ leave_decl_state();
156+}
157+
145158 void MZ1E30::save_state(FILEIO* state_fio)
146159 {
147- state_fio->FputUint32(STATE_VERSION);
148- state_fio->FputInt32(this_device_id);
160+ if(state_entry != NULL) {
161+ state_entry->save_state(state_fio);
162+ }
163+// state_fio->FputUint32(STATE_VERSION);
164+// state_fio->FputInt32(this_device_id);
149165
150- state_fio->FputUint32(rom_address);
151- state_fio->FputBool(irq_status);
152- state_fio->FputBool(drq_status);
166+// state_fio->FputUint32(rom_address);
167+// state_fio->FputBool(irq_status);
168+// state_fio->FputBool(drq_status);
153169 }
154170
155171 bool MZ1E30::load_state(FILEIO* state_fio)
156172 {
157- if(state_fio->FgetUint32() != STATE_VERSION) {
158- return false;
173+ bool mb = false;
174+ if(state_entry != NULL) {
175+ mb = state_entry->load_state(state_fio);
159176 }
160- if(state_fio->FgetInt32() != this_device_id) {
177+ if(!mb) {
161178 return false;
162179 }
163- rom_address = state_fio->FgetUint32();
164- irq_status = state_fio->FgetBool();
165- drq_status = state_fio->FgetBool();
180+// if(state_fio->FgetUint32() != STATE_VERSION) {
181+// return false;
182+// }
183+// if(state_fio->FgetInt32() != this_device_id) {
184+// return false;
185+// }
186+// rom_address = state_fio->FgetUint32();
187+// irq_status = state_fio->FgetBool();
188+// drq_status = state_fio->FgetBool();
166189 return true;
167190 }
168191
--- a/source/src/vm/mz2500/mz1e30.h
+++ b/source/src/vm/mz2500/mz1e30.h
@@ -46,6 +46,7 @@ public:
4646 void write_dma_io8(uint32_t addr, uint32_t data);
4747 uint32_t read_dma_io8(uint32_t addr);
4848 void write_signal(int id, uint32_t data, uint32_t mask);
49+ void decl_state();
4950 void save_state(FILEIO* state_fio);
5051 bool load_state(FILEIO* state_fio);
5152
--- a/source/src/vm/mz2500/mz1m01.cpp
+++ b/source/src/vm/mz2500/mz1m01.cpp
@@ -113,25 +113,47 @@ void MZ1M01::write_signal(int id, uint32_t data, uint32_t mask)
113113
114114 #define STATE_VERSION 1
115115
116+#include "../../statesub.h"
117+
118+void MZ1M01::decl_state()
119+{
120+ enter_decl_state(STATE_VERSION);
121+
122+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
123+ DECL_STATE_ENTRY_1D_ARRAY(port, sizeof(port));
124+
125+ leave_decl_state();
126+}
127+
116128 void MZ1M01::save_state(FILEIO* state_fio)
117129 {
118- state_fio->FputUint32(STATE_VERSION);
119- state_fio->FputInt32(this_device_id);
130+ if(state_entry != NULL) {
131+ state_entry->save_state(state_fio);
132+ }
133+// state_fio->FputUint32(STATE_VERSION);
134+// state_fio->FputInt32(this_device_id);
120135
121- state_fio->Fwrite(ram, sizeof(ram), 1);
122- state_fio->Fwrite(port, sizeof(port), 1);
136+// state_fio->Fwrite(ram, sizeof(ram), 1);
137+// state_fio->Fwrite(port, sizeof(port), 1);
123138 }
124139
125140 bool MZ1M01::load_state(FILEIO* state_fio)
126141 {
127- if(state_fio->FgetUint32() != STATE_VERSION) {
128- return false;
142+ bool mb = false;
143+ if(state_entry != NULL) {
144+ mb = state_entry->load_state(state_fio);
129145 }
130- if(state_fio->FgetInt32() != this_device_id) {
146+ if(!mb) {
131147 return false;
132148 }
133- state_fio->Fread(ram, sizeof(ram), 1);
134- state_fio->Fread(port, sizeof(port), 1);
149+// if(state_fio->FgetUint32() != STATE_VERSION) {
150+// return false;
151+// }
152+// if(state_fio->FgetInt32() != this_device_id) {
153+// return false;
154+// }
155+// state_fio->Fread(ram, sizeof(ram), 1);
156+// state_fio->Fread(port, sizeof(port), 1);
135157 return true;
136158 }
137159
--- a/source/src/vm/mz2500/mz1m01.h
+++ b/source/src/vm/mz2500/mz1m01.h
@@ -47,6 +47,7 @@ public:
4747 void write_io8(uint32_t addr, uint32_t data);
4848 uint32_t read_io8(uint32_t addr);
4949 void write_signal(int id, uint32_t data, uint32_t mask);
50+ void decl_state();
5051 void save_state(FILEIO* state_fio);
5152 bool load_state(FILEIO* state_fio);
5253
--- a/source/src/vm/mz2500/mz1r12.cpp
+++ b/source/src/vm/mz2500/mz1r12.cpp
@@ -77,29 +77,53 @@ uint32_t MZ1R12::read_io8(uint32_t addr)
7777
7878 #define STATE_VERSION 1
7979
80+#include "../../statesub.h"
81+
82+void MZ1R12::decl_state()
83+{
84+ enter_decl_state(STATE_VERSION);
85+
86+ DECL_STATE_ENTRY_1D_ARRAY(sram, sizeof(sram));
87+ DECL_STATE_ENTRY_BOOL(read_only);
88+ DECL_STATE_ENTRY_UINT16(address);
89+ DECL_STATE_ENTRY_UINT32(crc32);
90+
91+ leave_decl_state();
92+}
93+
8094 void MZ1R12::save_state(FILEIO* state_fio)
8195 {
82- state_fio->FputUint32(STATE_VERSION);
83- state_fio->FputInt32(this_device_id);
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);
84101
85- state_fio->Fwrite(sram, sizeof(sram), 1);
86- state_fio->FputBool(read_only);
87- state_fio->FputUint16(address);
88- state_fio->FputUint32(crc32);
102+// state_fio->Fwrite(sram, sizeof(sram), 1);
103+// state_fio->FputBool(read_only);
104+// state_fio->FputUint16(address);
105+// state_fio->FputUint32(crc32);
89106 }
90107
91108 bool MZ1R12::load_state(FILEIO* state_fio)
92109 {
93- if(state_fio->FgetUint32() != STATE_VERSION) {
94- return false;
110+ bool mb = false;
111+ if(state_entry != NULL) {
112+ mb = state_entry->load_state(state_fio);
95113 }
96- if(state_fio->FgetInt32() != this_device_id) {
114+ if(!mb) {
97115 return false;
98116 }
99- state_fio->Fread(sram, sizeof(sram), 1);
100- read_only = state_fio->FgetBool();
101- address = state_fio->FgetUint16();
102- crc32 = state_fio->FgetUint32();
117+// if(state_fio->FgetUint32() != STATE_VERSION) {
118+// return false;
119+// }
120+// if(state_fio->FgetInt32() != this_device_id) {
121+// return false;
122+// }
123+// state_fio->Fread(sram, sizeof(sram), 1);
124+// read_only = state_fio->FgetBool();
125+// address = state_fio->FgetUint16();
126+// crc32 = state_fio->FgetUint32();
103127 return true;
104128 }
105129
--- a/source/src/vm/mz2500/mz1r12.h
+++ b/source/src/vm/mz2500/mz1r12.h
@@ -35,6 +35,7 @@ public:
3535 void release();
3636 void write_io8(uint32_t addr, uint32_t data);
3737 uint32_t read_io8(uint32_t addr);
38+ void decl_state();
3839 void save_state(FILEIO* state_fio);
3940 bool load_state(FILEIO* state_fio);
4041 };
--- a/source/src/vm/mz2500/mz1r13.cpp
+++ b/source/src/vm/mz2500/mz1r13.cpp
@@ -72,25 +72,47 @@ uint32_t MZ1R13::read_io8(uint32_t addr)
7272
7373 #define STATE_VERSION 1
7474
75+#include "../../statesub.h"
76+
77+void MZ1R13::decl_state()
78+{
79+ enter_decl_state(STATE_VERSION);
80+
81+ DECL_STATE_ENTRY_UINT16(address);
82+ DECL_STATE_ENTRY_BOOL(select_kanji);
83+
84+ leave_decl_state();
85+}
86+
7587 void MZ1R13::save_state(FILEIO* state_fio)
7688 {
77- state_fio->FputUint32(STATE_VERSION);
78- state_fio->FputInt32(this_device_id);
89+ if(state_entry != NULL) {
90+ state_entry->save_state(state_fio);
91+ }
92+// state_fio->FputUint32(STATE_VERSION);
93+// state_fio->FputInt32(this_device_id);
7994
80- state_fio->FputUint16(address);
81- state_fio->FputBool(select_kanji);
95+// state_fio->FputUint16(address);
96+// state_fio->FputBool(select_kanji);
8297 }
8398
8499 bool MZ1R13::load_state(FILEIO* state_fio)
85100 {
86- if(state_fio->FgetUint32() != STATE_VERSION) {
87- return false;
101+ bool mb = false;
102+ if(state_entry != NULL) {
103+ mb = state_entry->load_state(state_fio);
88104 }
89- if(state_fio->FgetInt32() != this_device_id) {
105+ if(!mb) {
90106 return false;
91107 }
92- address = state_fio->FgetUint16();
93- select_kanji = state_fio->FgetBool();
108+// if(state_fio->FgetUint32() != STATE_VERSION) {
109+// return false;
110+// }
111+// if(state_fio->FgetInt32() != this_device_id) {
112+// return false;
113+// }
114+// address = state_fio->FgetUint16();
115+// select_kanji = state_fio->FgetBool();
94116 return true;
95117 }
96118
--- a/source/src/vm/mz2500/mz1r13.h
+++ b/source/src/vm/mz2500/mz1r13.h
@@ -36,6 +36,7 @@ public:
3636 void initialize();
3737 void write_io8(uint32_t addr, uint32_t data);
3838 uint32_t read_io8(uint32_t addr);
39+ void decl_state();
3940 void save_state(FILEIO* state_fio);
4041 bool load_state(FILEIO* state_fio);
4142 };
--- a/source/src/vm/mz2500/mz1r37.cpp
+++ b/source/src/vm/mz2500/mz1r37.cpp
@@ -54,25 +54,47 @@ uint32_t MZ1R37::read_io8(uint32_t addr)
5454
5555 #define STATE_VERSION 1
5656
57+#include "../../statesub.h"
58+
59+void MZ1R37::decl_state()
60+{
61+ enter_decl_state(STATE_VERSION);
62+
63+ DECL_STATE_ENTRY_1D_ARRAY(buffer, EMM_SIZE);
64+ DECL_STATE_ENTRY_UINT32(address);
65+
66+ leave_decl_state();
67+}
68+
5769 void MZ1R37::save_state(FILEIO* state_fio)
5870 {
59- state_fio->FputUint32(STATE_VERSION);
60- state_fio->FputInt32(this_device_id);
71+ if(state_entry != NULL) {
72+ state_entry->save_state(state_fio);
73+ }
74+// state_fio->FputUint32(STATE_VERSION);
75+// state_fio->FputInt32(this_device_id);
6176
62- state_fio->Fwrite(buffer, EMM_SIZE, 1);
63- state_fio->FputUint32(address);
77+// state_fio->Fwrite(buffer, EMM_SIZE, 1);
78+// state_fio->FputUint32(address);
6479 }
6580
6681 bool MZ1R37::load_state(FILEIO* state_fio)
6782 {
68- if(state_fio->FgetUint32() != STATE_VERSION) {
69- return false;
83+ bool mb = false;
84+ if(state_entry != NULL) {
85+ mb = state_entry->load_state(state_fio);
7086 }
71- if(state_fio->FgetInt32() != this_device_id) {
87+ if(!mb) {
7288 return false;
7389 }
74- state_fio->Fread(buffer, EMM_SIZE, 1);
75- address = state_fio->FgetUint32();
90+// if(state_fio->FgetUint32() != STATE_VERSION) {
91+// return false;
92+// }
93+// if(state_fio->FgetInt32() != this_device_id) {
94+// return false;
95+// }
96+// state_fio->Fread(buffer, EMM_SIZE, 1);
97+// address = state_fio->FgetUint32();
7698 return true;
7799 }
78100
--- a/source/src/vm/mz2500/mz1r37.h
+++ b/source/src/vm/mz2500/mz1r37.h
@@ -31,6 +31,7 @@ public:
3131 void release();
3232 void write_io8(uint32_t addr, uint32_t data);
3333 uint32_t read_io8(uint32_t addr);
34+ void decl_state();
3435 void save_state(FILEIO* state_fio);
3536 bool load_state(FILEIO* state_fio);
3637 };
--- a/source/src/vm/mz2500/serial.cpp
+++ b/source/src/vm/mz2500/serial.cpp
@@ -69,23 +69,44 @@ uint32_t SERIAL::read_io8(uint32_t addr)
6969
7070 #define STATE_VERSION 1
7171
72+#include "../../statesub.h"
73+
74+void SERIAL::decl_state()
75+{
76+ enter_decl_state(STATE_VERSION);
77+
78+ DECL_STATE_ENTRY_BOOL(addr_a0);
79+
80+ leave_decl_state();
81+}
82+
7283 void SERIAL::save_state(FILEIO* state_fio)
7384 {
74- state_fio->FputUint32(STATE_VERSION);
75- state_fio->FputInt32(this_device_id);
85+ if(state_entry != NULL) {
86+ state_entry->save_state(state_fio);
87+ }
88+// state_fio->FputUint32(STATE_VERSION);
89+// state_fio->FputInt32(this_device_id);
7690
77- state_fio->FputBool(addr_a0);
91+// state_fio->FputBool(addr_a0);
7892 }
7993
8094 bool SERIAL::load_state(FILEIO* state_fio)
8195 {
82- if(state_fio->FgetUint32() != STATE_VERSION) {
83- return false;
96+ bool mb = false;
97+ if(state_entry != NULL) {
98+ mb = state_entry->load_state(state_fio);
8499 }
85- if(state_fio->FgetInt32() != this_device_id) {
100+ if(!mb) {
86101 return false;
87102 }
88- addr_a0 = state_fio->FgetBool();
103+// if(state_fio->FgetUint32() != STATE_VERSION) {
104+// return false;
105+// }
106+// if(state_fio->FgetInt32() != this_device_id) {
107+// return false;
108+// }
109+// addr_a0 = state_fio->FgetBool();
89110 return true;
90111 }
91112
--- a/source/src/vm/mz2500/serial.h
+++ b/source/src/vm/mz2500/serial.h
@@ -33,6 +33,7 @@ public:
3333 void reset();
3434 void write_io8(uint32_t addr, uint32_t data);
3535 uint32_t read_io8(uint32_t addr);
36+ void decl_state();
3637 void save_state(FILEIO* state_fio);
3738 bool load_state(FILEIO* state_fio);
3839
Show on old repository browser