• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

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


Commit MetaInfo

Revision419860f6635a90d0445671d6fc02395ec28d1e32 (tree)
Time2018-07-11 17:28:37
AuthorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[VM][STATE][PHC20][PHC25]PV1000][PV2000][PYUTA][QC10][RX78][SC3000] Apply new state framework to VMs.
[VM][STATE][TK80BS] CMT: OOPs.

Change Summary

Incremental Difference

--- a/source/src/vm/phc20/memory.cpp
+++ b/source/src/vm/phc20/memory.cpp
@@ -158,29 +158,53 @@ void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
158158
159159 #define STATE_VERSION 1
160160
161+#include "../../statesub.h"
162+
163+void MEMORY::decl_state()
164+{
165+ enter_decl_state(STATE_VERSION);
166+
167+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
168+ DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
169+ DECL_STATE_ENTRY_1D_ARRAY(status, sizeof(status));
170+ DECL_STATE_ENTRY_UINT8(sysport);
171+
172+ leave_decl_state();
173+}
174+
161175 void MEMORY::save_state(FILEIO* state_fio)
162176 {
163- state_fio->FputUint32(STATE_VERSION);
164- state_fio->FputInt32(this_device_id);
177+ if(state_entry != NULL) {
178+ state_entry->save_state(state_fio);
179+ }
180+// state_fio->FputUint32(STATE_VERSION);
181+// state_fio->FputInt32(this_device_id);
165182
166- state_fio->Fwrite(ram, sizeof(ram), 1);
167- state_fio->Fwrite(vram, sizeof(vram), 1);
168- state_fio->Fwrite(status, sizeof(status), 1);
169- state_fio->FputUint8(sysport);
183+// state_fio->Fwrite(ram, sizeof(ram), 1);
184+// state_fio->Fwrite(vram, sizeof(vram), 1);
185+// state_fio->Fwrite(status, sizeof(status), 1);
186+// state_fio->FputUint8(sysport);
170187 }
171188
172189 bool MEMORY::load_state(FILEIO* state_fio)
173190 {
174- if(state_fio->FgetUint32() != STATE_VERSION) {
175- return false;
191+ bool mb = false;
192+ if(state_entry != NULL) {
193+ mb = state_entry->load_state(state_fio);
176194 }
177- if(state_fio->FgetInt32() != this_device_id) {
195+ if(!mb) {
178196 return false;
179197 }
180- state_fio->Fread(ram, sizeof(ram), 1);
181- state_fio->Fread(vram, sizeof(vram), 1);
182- state_fio->Fread(status, sizeof(status), 1);
183- sysport = state_fio->FgetUint8();
198+// if(state_fio->FgetUint32() != STATE_VERSION) {
199+// return false;
200+// }
201+// if(state_fio->FgetInt32() != this_device_id) {
202+// return false;
203+// }
204+// state_fio->Fread(ram, sizeof(ram), 1);
205+// state_fio->Fread(vram, sizeof(vram), 1);
206+// state_fio->Fread(status, sizeof(status), 1);
207+// sysport = state_fio->FgetUint8();
184208 return true;
185209 }
186210
--- a/source/src/vm/phc20/memory.h
+++ b/source/src/vm/phc20/memory.h
@@ -48,6 +48,7 @@ public:
4848 uint32_t read_data8(uint32_t addr);
4949 void event_frame();
5050 void write_signal(int id, uint32_t data, uint32_t mask);
51+ void decl_state();
5152 void save_state(FILEIO* state_fio);
5253 bool load_state(FILEIO* state_fio);
5354
--- a/source/src/vm/phc25/keyboard.cpp
+++ b/source/src/vm/phc25/keyboard.cpp
@@ -120,31 +120,54 @@ void KEYBOARD::event_frame()
120120
121121 #define STATE_VERSION 1
122122
123-void KEYBOARD::save_state(FILEIO* state_fio)
123+#include "../../statesub.h"
124+
125+void KEYBOARD::decl_state()
124126 {
125- state_fio->FputUint32(STATE_VERSION);
126- state_fio->FputInt32(this_device_id);
127-
127+ enter_decl_state(STATE_VERSION);
128128 #ifdef _MAP1010
129- state_fio->FputInt32(kana_pressed);
129+ DECL_STATE_ENTRY_INT32(kana_pressed);
130130 #else
131- state_fio->Fwrite(status, sizeof(status), 1);
131+ DECL_STATE_ENTRY_1D_ARRAY(status, sizeof(status));
132132 #endif
133+ leave_decl_state();
134+}
135+
136+void KEYBOARD::save_state(FILEIO* state_fio)
137+{
138+ if(state_entry != NULL) {
139+ state_entry->save_state(state_fio);
140+ }
141+// state_fio->FputUint32(STATE_VERSION);
142+// state_fio->FputInt32(this_device_id);
143+//
144+//#ifdef _MAP1010
145+// state_fio->FputInt32(kana_pressed);
146+//#else
147+// state_fio->Fwrite(status, sizeof(status), 1);
148+//#endif
133149 }
134150
135151 bool KEYBOARD::load_state(FILEIO* state_fio)
136152 {
137- if(state_fio->FgetUint32() != STATE_VERSION) {
138- return false;
153+ bool mb = false;
154+ if(state_entry != NULL) {
155+ mb = state_entry->load_state(state_fio);
139156 }
140- if(state_fio->FgetInt32() != this_device_id) {
157+ if(!mb) {
141158 return false;
142159 }
143-#ifdef _MAP1010
144- kana_pressed = state_fio->FgetInt32();
145-#else
146- state_fio->Fread(status, sizeof(status), 1);
147-#endif
160+// if(state_fio->FgetUint32() != STATE_VERSION) {
161+// return false;
162+// }
163+// if(state_fio->FgetInt32() != this_device_id) {
164+// return false;
165+// }
166+//#ifdef _MAP1010
167+// kana_pressed = state_fio->FgetInt32();
168+//#else
169+// state_fio->Fread(status, sizeof(status), 1);
170+//#endif
148171 return true;
149172 }
150173
--- a/source/src/vm/phc25/keyboard.h
+++ b/source/src/vm/phc25/keyboard.h
@@ -38,6 +38,7 @@ public:
3838 void reset();
3939 uint32_t read_io8(uint32_t addr);
4040 void event_frame();
41+ void decl_state();
4142 void save_state(FILEIO* state_fio);
4243 bool load_state(FILEIO* state_fio);
4344 };
--- a/source/src/vm/phc25/memory.cpp
+++ b/source/src/vm/phc25/memory.cpp
@@ -87,25 +87,47 @@ uint32_t MEMORY::read_data8(uint32_t addr)
8787
8888 #define STATE_VERSION 1
8989
90+#include "../../statesub.h"
91+
92+void MEMORY::decl_state()
93+{
94+ enter_decl_state(STATE_VERSION);
95+
96+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
97+ DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
98+
99+ leave_decl_state();
100+}
101+
90102 void MEMORY::save_state(FILEIO* state_fio)
91103 {
92- state_fio->FputUint32(STATE_VERSION);
93- state_fio->FputInt32(this_device_id);
104+ if(state_entry != NULL) {
105+ state_entry->save_state(state_fio);
106+ }
107+// state_fio->FputUint32(STATE_VERSION);
108+// state_fio->FputInt32(this_device_id);
94109
95- state_fio->Fwrite(ram, sizeof(ram), 1);
96- state_fio->Fwrite(vram, sizeof(vram), 1);
110+// state_fio->Fwrite(ram, sizeof(ram), 1);
111+// state_fio->Fwrite(vram, sizeof(vram), 1);
97112 }
98113
99114 bool MEMORY::load_state(FILEIO* state_fio)
100115 {
101- if(state_fio->FgetUint32() != STATE_VERSION) {
102- return false;
116+ bool mb = false;
117+ if(state_entry != NULL) {
118+ mb = state_entry->load_state(state_fio);
103119 }
104- if(state_fio->FgetInt32() != this_device_id) {
120+ if(!mb) {
105121 return false;
106122 }
107- state_fio->Fread(ram, sizeof(ram), 1);
108- state_fio->Fread(vram, sizeof(vram), 1);
123+// if(state_fio->FgetUint32() != STATE_VERSION) {
124+// return false;
125+// }
126+// if(state_fio->FgetInt32() != this_device_id) {
127+// return false;
128+// }
129+// state_fio->Fread(ram, sizeof(ram), 1);
130+// state_fio->Fread(vram, sizeof(vram), 1);
109131 return true;
110132 }
111133
--- a/source/src/vm/phc25/memory.h
+++ b/source/src/vm/phc25/memory.h
@@ -45,6 +45,7 @@ public:
4545 void reset();
4646 void write_data8(uint32_t addr, uint32_t data);
4747 uint32_t read_data8(uint32_t addr);
48+ void decl_state();
4849 void save_state(FILEIO* state_fio);
4950 bool load_state(FILEIO* state_fio);
5051
--- a/source/src/vm/phc25/system.cpp
+++ b/source/src/vm/phc25/system.cpp
@@ -45,23 +45,44 @@ void SYSTEM::write_signal(int id, uint32_t data, uint32_t mask)
4545
4646 #define STATE_VERSION 1
4747
48+#include "../../statesub.h"
49+
50+void SYSTEM::decl_state()
51+{
52+ enter_decl_state(STATE_VERSION);
53+
54+ DECL_STATE_ENTRY_UINT8(sysport);
55+
56+ leave_decl_state();
57+}
58+
4859 void SYSTEM::save_state(FILEIO* state_fio)
4960 {
50- state_fio->FputUint32(STATE_VERSION);
51- state_fio->FputInt32(this_device_id);
61+ if(state_entry != NULL) {
62+ state_entry->save_state(state_fio);
63+ }
64+// state_fio->FputUint32(STATE_VERSION);
65+// state_fio->FputInt32(this_device_id);
5266
53- state_fio->FputUint8(sysport);
67+// state_fio->FputUint8(sysport);
5468 }
5569
5670 bool SYSTEM::load_state(FILEIO* state_fio)
5771 {
58- if(state_fio->FgetUint32() != STATE_VERSION) {
59- return false;
72+ bool mb = false;
73+ if(state_entry != NULL) {
74+ mb = state_entry->load_state(state_fio);
6075 }
61- if(state_fio->FgetInt32() != this_device_id) {
76+ if(!mb) {
6277 return false;
6378 }
64- sysport = state_fio->FgetUint8();
79+// if(state_fio->FgetUint32() != STATE_VERSION) {
80+// return false;
81+// }
82+// if(state_fio->FgetInt32() != this_device_id) {
83+// return false;
84+// }
85+// sysport = state_fio->FgetUint8();
6586 return true;
6687 }
6788
--- a/source/src/vm/phc25/system.h
+++ b/source/src/vm/phc25/system.h
@@ -37,6 +37,7 @@ public:
3737 void write_io8(uint32_t addr, uint32_t data);
3838 uint32_t read_io8(uint32_t addr);
3939 void write_signal(int id, uint32_t data, uint32_t mask);
40+ void decl_state();
4041 void save_state(FILEIO* state_fio);
4142 bool load_state(FILEIO* state_fio);
4243
--- a/source/src/vm/pv1000/joystick.cpp
+++ b/source/src/vm/pv1000/joystick.cpp
@@ -86,25 +86,47 @@ void JOYSTICK::event_frame()
8686
8787 #define STATE_VERSION 1
8888
89+#include "../../statesub.h"
90+
91+void JOYSTICK::decl_state()
92+{
93+ enter_decl_state(STATE_VERSION);
94+
95+ DECL_STATE_ENTRY_UINT8(column);
96+ DECL_STATE_ENTRY_UINT8(status);
97+
98+ leave_decl_state();
99+}
100+
89101 void JOYSTICK::save_state(FILEIO* state_fio)
90102 {
91- state_fio->FputUint32(STATE_VERSION);
92- state_fio->FputInt32(this_device_id);
103+ if(state_entry != NULL) {
104+ state_entry->save_state(state_fio);
105+ }
106+// state_fio->FputUint32(STATE_VERSION);
107+// state_fio->FputInt32(this_device_id);
93108
94- state_fio->FputUint8(column);
95- state_fio->FputUint8(status);
109+// state_fio->FputUint8(column);
110+// state_fio->FputUint8(status);
96111 }
97112
98113 bool JOYSTICK::load_state(FILEIO* state_fio)
99114 {
100- if(state_fio->FgetUint32() != STATE_VERSION) {
101- return false;
115+ bool mb = false;
116+ if(state_entry != NULL) {
117+ mb = state_entry->load_state(state_fio);
102118 }
103- if(state_fio->FgetInt32() != this_device_id) {
119+ if(!mb) {
104120 return false;
105121 }
106- column = state_fio->FgetUint8();
107- status = state_fio->FgetUint8();
122+// if(state_fio->FgetUint32() != STATE_VERSION) {
123+// return false;
124+// }
125+// if(state_fio->FgetInt32() != this_device_id) {
126+// return false;
127+// }
128+// column = state_fio->FgetUint8();
129+// status = state_fio->FgetUint8();
108130 return true;
109131 }
110132
--- a/source/src/vm/pv1000/joystick.h
+++ b/source/src/vm/pv1000/joystick.h
@@ -35,6 +35,7 @@ public:
3535 void write_io8(uint32_t addr, uint32_t data);
3636 uint32_t read_io8(uint32_t addr);
3737 void event_frame();
38+ void decl_state();
3839 void save_state(FILEIO* state_fio);
3940 bool load_state(FILEIO* state_fio);
4041 };
--- a/source/src/vm/pv1000/psg.cpp
+++ b/source/src/vm/pv1000/psg.cpp
@@ -62,27 +62,48 @@ void PSG::set_volume(int ch, int decibel_l, int decibel_r)
6262
6363 #define STATE_VERSION 1
6464
65-void PSG::save_state(FILEIO* state_fio)
65+#include "../../statesub.h"
66+
67+void PSG::decl_state()
6668 {
67- state_fio->FputUint32(STATE_VERSION);
68- state_fio->FputInt32(this_device_id);
69+ enter_decl_state(STATE_VERSION);
70+
71+ DECL_STATE_ENTRY_INT32_STRIDE((ch[0].period), 3, sizeof(ch[0]));
6972
70- for(int i = 0; i < 3; i++) {
71- state_fio->FputInt32(ch[i].period);
73+ leave_decl_state();
74+}
75+
76+void PSG::save_state(FILEIO* state_fio)
77+{
78+ if(state_entry != NULL) {
79+ state_entry->save_state(state_fio);
7280 }
81+// state_fio->FputUint32(STATE_VERSION);
82+// state_fio->FputInt32(this_device_id);
83+
84+// for(int i = 0; i < 3; i++) {
85+// state_fio->FputInt32(ch[i].period);
86+// }
7387 }
7488
7589 bool PSG::load_state(FILEIO* state_fio)
7690 {
77- if(state_fio->FgetUint32() != STATE_VERSION) {
78- return false;
91+ bool mb = false;
92+ if(state_entry != NULL) {
93+ mb = state_entry->load_state(state_fio);
7994 }
80- if(state_fio->FgetInt32() != this_device_id) {
95+ if(!mb) {
8196 return false;
8297 }
83- for(int i = 0; i < 3; i++) {
84- ch[i].period = state_fio->FgetInt32();
85- }
98+// if(state_fio->FgetUint32() != STATE_VERSION) {
99+// return false;
100+// }
101+// if(state_fio->FgetInt32() != this_device_id) {
102+// return false;
103+// }
104+// for(int i = 0; i < 3; i++) {
105+// ch[i].period = state_fio->FgetInt32();
106+// }
86107 return true;
87108 }
88109
--- a/source/src/vm/pv1000/psg.h
+++ b/source/src/vm/pv1000/psg.h
@@ -38,6 +38,7 @@ public:
3838 void write_io8(uint32_t addr, uint32_t data);
3939 void mix(int32_t* buffer, int cnt);
4040 void set_volume(int ch, int decibel_l, int decibel_r);
41+ void decl_state();
4142 void save_state(FILEIO* state_fio);
4243 bool load_state(FILEIO* state_fio);
4344
--- a/source/src/vm/pv1000/vdp.cpp
+++ b/source/src/vm/pv1000/vdp.cpp
@@ -130,29 +130,60 @@ void VDP::draw_pcg(int x8, int y8, uint16_t top)
130130
131131 #define STATE_VERSION 1
132132
133+#include "../../statesub.h"
134+
135+void VDP::decl_state()
136+{
137+ enter_decl_state(STATE_VERSION);
138+
139+ DECL_STATE_ENTRY_INT32(tmp_vram_size); // (int)(vram - base);
140+ DECL_STATE_ENTRY_INT32(tmp_pcg_size); // (int)(pcg - base);
141+ DECL_STATE_ENTRY_INT32(tmp_pattern_size); // (int)(pattern - base);
142+ DECL_STATE_ENTRY_BOOL(force_pattern);
143+
144+ leave_decl_state();
145+}
146+
133147 void VDP::save_state(FILEIO* state_fio)
134148 {
135- state_fio->FputUint32(STATE_VERSION);
136- state_fio->FputInt32(this_device_id);
149+ tmp_vram_size = (int)(vram - base);
150+ tmp_pcg_size = (int)(pcg - base);
151+ tmp_pattern_size = (int)(pattern - base);
152+
153+ if(state_entry != NULL) {
154+ state_entry->save_state(state_fio);
155+ }
156+// state_fio->FputUint32(STATE_VERSION);
157+// state_fio->FputInt32(this_device_id);
137158
138- state_fio->FputInt32((int)(vram - base));
139- state_fio->FputInt32((int)(pcg - base));
140- state_fio->FputInt32((int)(pattern - base));
141- state_fio->FputBool(force_pattern);
159+// state_fio->FputInt32((int)(vram - base));
160+// state_fio->FputInt32((int)(pcg - base));
161+// state_fio->FputInt32((int)(pattern - base));
162+// state_fio->FputBool(force_pattern);
142163 }
143164
144165 bool VDP::load_state(FILEIO* state_fio)
145166 {
146- if(state_fio->FgetUint32() != STATE_VERSION) {
147- return false;
167+ bool mb = false;
168+ if(state_entry != NULL) {
169+ mb = state_entry->load_state(state_fio);
148170 }
149- if(state_fio->FgetInt32() != this_device_id) {
171+ if(!mb) {
150172 return false;
151173 }
152- vram = base + state_fio->FgetInt32();
153- pcg = base + state_fio->FgetInt32();
154- pattern = base + state_fio->FgetInt32();
155- force_pattern = state_fio->FgetBool();
174+// if(state_fio->FgetUint32() != STATE_VERSION) {
175+// return false;
176+// }
177+// if(state_fio->FgetInt32() != this_device_id) {
178+// return false;
179+// }
180+// vram = base + state_fio->FgetInt32();
181+// pcg = base + state_fio->FgetInt32();
182+// pattern = base + state_fio->FgetInt32();
183+// force_pattern = state_fio->FgetBool();
184+ vram = base + tmp_vram_size;
185+ pcg = base + tmp_pcg_size;
186+ pattern = base + tmp_pattern_size;
156187 return true;
157188 }
158189
--- a/source/src/vm/pv1000/vdp.h
+++ b/source/src/vm/pv1000/vdp.h
@@ -25,6 +25,10 @@ private:
2525 uint8_t* pattern;
2626 uint8_t* base;
2727 bool force_pattern;
28+
29+ int tmp_vram_size;
30+ int tmp_pcg_size;
31+ int tmp_pattern_size;
2832
2933 void draw_pattern(int x8, int y8, uint16_t top);
3034 void draw_pcg(int x8, int y8, uint16_t top);
@@ -42,6 +46,7 @@ public:
4246 void write_io8(uint32_t addr, uint32_t data);
4347 void event_callback(int event_id, int err);
4448 void event_vline(int v, int clock);
49+ void decl_state();
4550 void save_state(FILEIO* state_fio);
4651 bool load_state(FILEIO* state_fio);
4752
--- a/source/src/vm/pv2000/cmt.cpp
+++ b/source/src/vm/pv2000/cmt.cpp
@@ -131,33 +131,59 @@ void CMT::close_tape()
131131
132132 #define STATE_VERSION 1
133133
134+#include "../../statesub.h"
135+
136+void CMT::decl_state()
137+{
138+ enter_decl_state(STATE_VERSION);
139+
140+ DECL_STATE_ENTRY_INT32(bufcnt);
141+ DECL_STATE_ENTRY_1D_ARRAY(buffer, sizeof(buffer));
142+ DECL_STATE_ENTRY_BOOL(play);
143+ DECL_STATE_ENTRY_BOOL(rec);
144+ DECL_STATE_ENTRY_UINT8(start);
145+ DECL_STATE_ENTRY_UINT8(bit);
146+
147+ leave_decl_state();
148+}
149+
134150 void CMT::save_state(FILEIO* state_fio)
135151 {
136- state_fio->FputUint32(STATE_VERSION);
137- state_fio->FputInt32(this_device_id);
152+ if(state_entry != NULL) {
153+ state_entry->save_state(state_fio);
154+ }
155+// state_fio->FputUint32(STATE_VERSION);
156+// state_fio->FputInt32(this_device_id);
138157
139- state_fio->FputInt32(bufcnt);
140- state_fio->Fwrite(buffer, sizeof(buffer), 1);
141- state_fio->FputBool(play);
142- state_fio->FputBool(rec);
143- state_fio->FputUint8(start);
144- state_fio->FputUint8(bit);
158+// state_fio->FputInt32(bufcnt);
159+// state_fio->Fwrite(buffer, sizeof(buffer), 1);
160+// state_fio->FputBool(play);
161+// state_fio->FputBool(rec);
162+// state_fio->FputUint8(start);
163+// state_fio->FputUint8(bit);
145164 }
146165
147166 bool CMT::load_state(FILEIO* state_fio)
148167 {
149- if(state_fio->FgetUint32() != STATE_VERSION) {
150- return false;
168+ bool mb = false;
169+ if(state_entry != NULL) {
170+ mb = state_entry->load_state(state_fio);
151171 }
152- if(state_fio->FgetInt32() != this_device_id) {
172+ if(!mb) {
153173 return false;
154174 }
155- bufcnt = state_fio->FgetInt32();
156- state_fio->Fread(buffer, sizeof(buffer), 1);
157- play = state_fio->FgetBool();
158- rec = state_fio->FgetBool();
159- start = state_fio->FgetUint8();
160- bit = state_fio->FgetUint8();
175+// if(state_fio->FgetUint32() != STATE_VERSION) {
176+// return false;
177+// }
178+// if(state_fio->FgetInt32() != this_device_id) {
179+// return false;
180+// }
181+// bufcnt = state_fio->FgetInt32();
182+// state_fio->Fread(buffer, sizeof(buffer), 1);
183+// play = state_fio->FgetBool();
184+// rec = state_fio->FgetBool();
185+// start = state_fio->FgetUint8();
186+// bit = state_fio->FgetUint8();
161187 return true;
162188 }
163189
--- a/source/src/vm/pv2000/cmt.h
+++ b/source/src/vm/pv2000/cmt.h
@@ -40,6 +40,7 @@ public:
4040 void reset();
4141 void write_io8(uint32_t addr, uint32_t data);
4242 uint32_t read_io8(uint32_t addr);
43+ void decl_state();
4344 void save_state(FILEIO* state_fio);
4445 bool load_state(FILEIO* state_fio);
4546
--- a/source/src/vm/pv2000/keyboard.cpp
+++ b/source/src/vm/pv2000/keyboard.cpp
@@ -110,27 +110,53 @@ void KEYBOARD::key_up(int code)
110110
111111 #define STATE_VERSION 1
112112
113+#include "../../statesub.h"
114+
115+void KEYBOARD::decl_state()
116+{
117+ enter_decl_state(STATE_VERSION);
118+
119+ DECL_STATE_ENTRY_1D_ARRAY(key_stat, sizeof(key_stat));
120+ DECL_STATE_ENTRY_INT32(key_no);
121+ DECL_STATE_ENTRY_BOOL(intr_enb);
122+
123+ leave_decl_state();
124+}
125+
113126 void KEYBOARD::save_state(FILEIO* state_fio)
114127 {
115- state_fio->FputUint32(STATE_VERSION);
116- state_fio->FputInt32(this_device_id);
128+ if(state_entry != NULL) {
129+ state_entry->save_state(state_fio);
130+ }
131+// if(state_entry != NULL) {
132+// state_entry->save_state(state_fio);
133+// }
134+// state_fio->FputUint32(STATE_VERSION);
135+// state_fio->FputInt32(this_device_id);
117136
118- state_fio->Fwrite(key_stat, sizeof(key_stat), 1);
119- state_fio->FputInt32(key_no);
120- state_fio->FputBool(intr_enb);
137+// state_fio->Fwrite(key_stat, sizeof(key_stat), 1);
138+// state_fio->FputInt32(key_no);
139+// state_fio->FputBool(intr_enb);
121140 }
122141
123142 bool KEYBOARD::load_state(FILEIO* state_fio)
124143 {
125- if(state_fio->FgetUint32() != STATE_VERSION) {
126- return false;
144+ bool mb = false;
145+ if(state_entry != NULL) {
146+ mb = state_entry->load_state(state_fio);
127147 }
128- if(state_fio->FgetInt32() != this_device_id) {
148+ if(!mb) {
129149 return false;
130150 }
131- state_fio->Fread(key_stat, sizeof(key_stat), 1);
132- key_no = state_fio->FgetInt32();
133- intr_enb = state_fio->FgetBool();
151+// if(state_fio->FgetUint32() != STATE_VERSION) {
152+// return false;
153+// }
154+// if(state_fio->FgetInt32() != this_device_id) {
155+// return false;
156+// }
157+// state_fio->Fread(key_stat, sizeof(key_stat), 1);
158+// key_no = state_fio->FgetInt32();
159+// intr_enb = state_fio->FgetBool();
134160 return true;
135161 }
136162
--- a/source/src/vm/pv2000/keyboard.h
+++ b/source/src/vm/pv2000/keyboard.h
@@ -36,6 +36,7 @@ public:
3636 void reset();
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/pv2000/printer.cpp
+++ b/source/src/vm/pv2000/printer.cpp
@@ -40,29 +40,53 @@ uint32_t PRINTER::read_io8(uint32_t addr)
4040
4141 #define STATE_VERSION 1
4242
43+#include "../../statesub.h"
44+
45+void PRINTER::decl_state()
46+{
47+ enter_decl_state(STATE_VERSION);
48+
49+ DECL_STATE_ENTRY_UINT8(out);
50+ DECL_STATE_ENTRY_UINT8(ctrl0);
51+ DECL_STATE_ENTRY_UINT8(ctrl1);
52+ DECL_STATE_ENTRY_BOOL(busy);
53+
54+ leave_decl_state();
55+}
56+
4357 void PRINTER::save_state(FILEIO* state_fio)
4458 {
45- state_fio->FputUint32(STATE_VERSION);
46- state_fio->FputInt32(this_device_id);
59+ if(state_entry != NULL) {
60+ state_entry->save_state(state_fio);
61+ }
62+// state_fio->FputUint32(STATE_VERSION);
63+// state_fio->FputInt32(this_device_id);
4764
48- state_fio->FputUint8(out);
49- state_fio->FputUint8(ctrl0);
50- state_fio->FputUint8(ctrl1);
51- state_fio->FputBool(busy);
65+// state_fio->FputUint8(out);
66+// state_fio->FputUint8(ctrl0);
67+// state_fio->FputUint8(ctrl1);
68+// state_fio->FputBool(busy);
5269 }
5370
5471 bool PRINTER::load_state(FILEIO* state_fio)
5572 {
56- if(state_fio->FgetUint32() != STATE_VERSION) {
57- return false;
73+ bool mb = false;
74+ if(state_entry != NULL) {
75+ mb = state_entry->load_state(state_fio);
5876 }
59- if(state_fio->FgetInt32() != this_device_id) {
77+ if(!mb) {
6078 return false;
6179 }
62- out = state_fio->FgetUint8();
63- ctrl0 = state_fio->FgetUint8();
64- ctrl1 = state_fio->FgetUint8();
65- busy = state_fio->FgetBool();
80+// if(state_fio->FgetUint32() != STATE_VERSION) {
81+// return false;
82+// }
83+// if(state_fio->FgetInt32() != this_device_id) {
84+// return false;
85+// }
86+// out = state_fio->FgetUint8();
87+// ctrl0 = state_fio->FgetUint8();
88+// ctrl1 = state_fio->FgetUint8();
89+// busy = state_fio->FgetBool();
6690 return true;
6791 }
6892
--- a/source/src/vm/pv2000/printer.h
+++ b/source/src/vm/pv2000/printer.h
@@ -31,6 +31,7 @@ public:
3131 void initialize();
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/pyuta/memory.cpp
+++ b/source/src/vm/pyuta/memory.cpp
@@ -314,31 +314,56 @@ void MEMORY::close_cart()
314314
315315 #define STATE_VERSION 1
316316
317+#include "../../statesub.h"
318+
319+void MEMORY::decl_state()
320+{
321+ enter_decl_state(STATE_VERSION);
322+
323+ DECL_STATE_ENTRY_BOOL(cmt_signal);
324+ DECL_STATE_ENTRY_BOOL(cmt_remote);
325+ DECL_STATE_ENTRY_BOOL(has_extrom);
326+ DECL_STATE_ENTRY_BOOL(cart_enabled);
327+ DECL_STATE_ENTRY_INT32(ctype);
328+
329+ leave_decl_state();
330+}
331+
317332 void MEMORY::save_state(FILEIO* state_fio)
318333 {
319- state_fio->FputUint32(STATE_VERSION);
320- state_fio->FputInt32(this_device_id);
334+ if(state_entry != NULL) {
335+ state_entry->save_state(state_fio);
336+ }
337+// state_fio->FputUint32(STATE_VERSION);
338+// state_fio->FputInt32(this_device_id);
321339
322- state_fio->FputBool(cmt_signal);
323- state_fio->FputBool(cmt_remote);
324- state_fio->FputBool(has_extrom);
325- state_fio->FputBool(cart_enabled);
326- state_fio->FputInt32(ctype);
340+// state_fio->FputBool(cmt_signal);
341+// state_fio->FputBool(cmt_remote);
342+// state_fio->FputBool(has_extrom);
343+// state_fio->FputBool(cart_enabled);
344+// state_fio->FputInt32(ctype);
327345 }
328346
329347 bool MEMORY::load_state(FILEIO* state_fio)
330348 {
331- if(state_fio->FgetUint32() != STATE_VERSION) {
332- return false;
349+ bool mb = false;
350+ if(state_entry != NULL) {
351+ mb = state_entry->load_state(state_fio);
333352 }
334- if(state_fio->FgetInt32() != this_device_id) {
353+ if(!mb) {
335354 return false;
336355 }
337- cmt_signal = state_fio->FgetBool();
338- cmt_remote = state_fio->FgetBool();
339- has_extrom = state_fio->FgetBool();
340- cart_enabled = state_fio->FgetBool();
341- ctype = state_fio->FgetInt32();
356+// if(state_fio->FgetUint32() != STATE_VERSION) {
357+// return false;
358+// }
359+// if(state_fio->FgetInt32() != this_device_id) {
360+// return false;
361+// }
362+// cmt_signal = state_fio->FgetBool();
363+// cmt_remote = state_fio->FgetBool();
364+// has_extrom = state_fio->FgetBool();
365+// cart_enabled = state_fio->FgetBool();
366+// ctype = state_fio->FgetInt32();
342367
343368 // post process
344369 if(cart_enabled) {
--- a/source/src/vm/pyuta/memory.h
+++ b/source/src/vm/pyuta/memory.h
@@ -50,6 +50,7 @@ public:
5050 void write_io8(uint32_t addr, uint32_t data);
5151 uint32_t read_io8(uint32_t addr);
5252 void write_signal(int id, uint32_t data, uint32_t mask);
53+ void decl_state();
5354 void save_state(FILEIO* state_fio);
5455 bool load_state(FILEIO* state_fio);
5556
--- a/source/src/vm/qc10/display.cpp
+++ b/source/src/vm/qc10/display.cpp
@@ -307,39 +307,68 @@ void DISPLAY::draw_screen()
307307
308308 #define STATE_VERSION 1
309309
310-void DISPLAY::save_state(FILEIO* state_fio)
310+#include "../../statesub.h"
311+
312+void DISPLAY::decl_state()
311313 {
312- state_fio->FputUint32(STATE_VERSION);
313- state_fio->FputInt32(this_device_id);
314-
314+ enter_decl_state(STATE_VERSION);
315+
315316 #ifdef _COLOR_MONITOR
316- state_fio->Fwrite(vram_r, sizeof(vram_r), 1);
317- state_fio->Fwrite(vram_g, sizeof(vram_g), 1);
318- state_fio->Fwrite(vram_b, sizeof(vram_b), 1);
317+ DECL_STATE_ENTRY_1D_ARRAY(vram_r, sizeof(vram_r));
318+ DECL_STATE_ENTRY_1D_ARRAY(vram_g, sizeof(vram_g));
319+ DECL_STATE_ENTRY_1D_ARRAY(vram_b, sizeof(vram_b));
319320 #else
320- state_fio->Fwrite(vram, sizeof(vram), 1);
321+ DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
321322 #endif
322- state_fio->FputUint8(bank);
323- state_fio->FputInt32(blink);
323+ DECL_STATE_ENTRY_UINT8(bank);
324+ DECL_STATE_ENTRY_INT32(blink);
325+
326+ leave_decl_state();
327+}
328+
329+void DISPLAY::save_state(FILEIO* state_fio)
330+{
331+ if(state_entry != NULL) {
332+ state_entry->save_state(state_fio);
333+ }
334+// state_fio->FputUint32(STATE_VERSION);
335+// state_fio->FputInt32(this_device_id);
336+
337+//#ifdef _COLOR_MONITOR
338+// state_fio->Fwrite(vram_r, sizeof(vram_r), 1);
339+// state_fio->Fwrite(vram_g, sizeof(vram_g), 1);
340+// state_fio->Fwrite(vram_b, sizeof(vram_b), 1);
341+//#else
342+// state_fio->Fwrite(vram, sizeof(vram), 1);
343+//#endif
344+// state_fio->FputUint8(bank);
345+// state_fio->FputInt32(blink);
324346 }
325347
326348 bool DISPLAY::load_state(FILEIO* state_fio)
327349 {
328- if(state_fio->FgetUint32() != STATE_VERSION) {
329- return false;
350+ bool mb = false;
351+ if(state_entry != NULL) {
352+ mb = state_entry->load_state(state_fio);
330353 }
331- if(state_fio->FgetInt32() != this_device_id) {
354+ if(!mb) {
332355 return false;
333356 }
334-#ifdef _COLOR_MONITOR
335- state_fio->Fread(vram_r, sizeof(vram_r), 1);
336- state_fio->Fread(vram_g, sizeof(vram_g), 1);
337- state_fio->Fread(vram_b, sizeof(vram_b), 1);
338-#else
339- state_fio->Fread(vram, sizeof(vram), 1);
340-#endif
341- bank = state_fio->FgetUint8();
342- blink = state_fio->FgetInt32();
357+// if(state_fio->FgetUint32() != STATE_VERSION) {
358+// return false;
359+// }
360+// if(state_fio->FgetInt32() != this_device_id) {
361+// return false;
362+// }
363+//#ifdef _COLOR_MONITOR
364+// state_fio->Fread(vram_r, sizeof(vram_r), 1);
365+// state_fio->Fread(vram_g, sizeof(vram_g), 1);
366+// state_fio->Fread(vram_b, sizeof(vram_b), 1);
367+//#else
368+// state_fio->Fread(vram, sizeof(vram), 1);
369+//#endif
370+// bank = state_fio->FgetUint8();
371+// blink = state_fio->FgetInt32();
343372 return true;
344373 }
345374
--- a/source/src/vm/qc10/display.h
+++ b/source/src/vm/qc10/display.h
@@ -54,6 +54,7 @@ public:
5454 void write_io8(uint32_t addr, uint32_t data);
5555 uint32_t read_io8(uint32_t addr);
5656 void event_frame();
57+ void decl_state();
5758 void save_state(FILEIO* state_fio);
5859 bool load_state(FILEIO* state_fio);
5960
--- a/source/src/vm/qc10/keyboard.cpp
+++ b/source/src/vm/qc10/keyboard.cpp
@@ -148,27 +148,50 @@ void KEYBOARD::process_cmd(uint8_t val)
148148
149149 #define STATE_VERSION 1
150150
151+#include "../../statesub.h"
152+
153+void KEYBOARD::decl_state()
154+{
155+ enter_decl_state(STATE_VERSION);
156+
157+ DECL_STATE_ENTRY_1D_ARRAY(led, sizeof(led) / sizeof(bool));
158+ DECL_STATE_ENTRY_BOOL(repeat);
159+ DECL_STATE_ENTRY_BOOL(enable);
160+
161+ leave_decl_state();
162+}
163+
151164 void KEYBOARD::save_state(FILEIO* state_fio)
152165 {
153- state_fio->FputUint32(STATE_VERSION);
154- state_fio->FputInt32(this_device_id);
166+ if(state_entry != NULL) {
167+ state_entry->save_state(state_fio);
168+ }
169+// state_fio->FputUint32(STATE_VERSION);
170+// state_fio->FputInt32(this_device_id);
155171
156- state_fio->Fwrite(led, sizeof(led), 1);
157- state_fio->FputBool(repeat);
158- state_fio->FputBool(enable);
172+// state_fio->Fwrite(led, sizeof(led), 1);
173+// state_fio->FputBool(repeat);
174+// state_fio->FputBool(enable);
159175 }
160176
161177 bool KEYBOARD::load_state(FILEIO* state_fio)
162178 {
163- if(state_fio->FgetUint32() != STATE_VERSION) {
164- return false;
179+ bool mb = false;
180+ if(state_entry != NULL) {
181+ mb = state_entry->load_state(state_fio);
165182 }
166- if(state_fio->FgetInt32() != this_device_id) {
183+ if(!mb) {
167184 return false;
168185 }
169- state_fio->Fread(led, sizeof(led), 1);
170- repeat = state_fio->FgetBool();
171- enable = state_fio->FgetBool();
186+// if(state_fio->FgetUint32() != STATE_VERSION) {
187+// return false;
188+// }
189+// if(state_fio->FgetInt32() != this_device_id) {
190+// return false;
191+// }
192+// state_fio->Fread(led, sizeof(led), 1);
193+// repeat = state_fio->FgetBool();
194+// enable = state_fio->FgetBool();
172195 return true;
173196 }
174197
--- a/source/src/vm/qc10/keyboard.h
+++ b/source/src/vm/qc10/keyboard.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/qc10/memory.cpp
+++ b/source/src/vm/qc10/memory.cpp
@@ -182,43 +182,74 @@ void MEMORY::update_pcm()
182182
183183 #define STATE_VERSION 1
184184
185+#include "../../statesub.h"
186+
187+void MEMORY::decl_state()
188+{
189+ enter_decl_state(STATE_VERSION);
190+
191+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
192+ DECL_STATE_ENTRY_1D_ARRAY(cmos, sizeof(cmos));
193+ DECL_STATE_ENTRY_UINT32(cmos_crc32);
194+ DECL_STATE_ENTRY_UINT8(bank);
195+ DECL_STATE_ENTRY_UINT8(psel);
196+ DECL_STATE_ENTRY_UINT8(csel);
197+ DECL_STATE_ENTRY_BOOL(pcm_on);
198+ DECL_STATE_ENTRY_BOOL(pcm_cont);
199+ DECL_STATE_ENTRY_BOOL(pcm_pit);
200+ DECL_STATE_ENTRY_BOOL(fdc_irq);
201+ DECL_STATE_ENTRY_BOOL(motor);
202+
203+ leave_decl_state();
204+}
205+
185206 void MEMORY::save_state(FILEIO* state_fio)
186207 {
187- state_fio->FputUint32(STATE_VERSION);
188- state_fio->FputInt32(this_device_id);
208+ if(state_entry != NULL) {
209+ state_entry->save_state(state_fio);
210+ }
211+// state_fio->FputUint32(STATE_VERSION);
212+// state_fio->FputInt32(this_device_id);
189213
190- state_fio->Fwrite(ram, sizeof(ram), 1);
191- state_fio->Fwrite(cmos, sizeof(cmos), 1);
192- state_fio->FputUint32(cmos_crc32);
193- state_fio->FputUint8(bank);
194- state_fio->FputUint8(psel);
195- state_fio->FputUint8(csel);
196- state_fio->FputBool(pcm_on);
197- state_fio->FputBool(pcm_cont);
198- state_fio->FputBool(pcm_pit);
199- state_fio->FputBool(fdc_irq);
200- state_fio->FputBool(motor);
214+// state_fio->Fwrite(ram, sizeof(ram), 1);
215+// state_fio->Fwrite(cmos, sizeof(cmos), 1);
216+// state_fio->FputUint32(cmos_crc32);
217+// state_fio->FputUint8(bank);
218+// state_fio->FputUint8(psel);
219+// state_fio->FputUint8(csel);
220+// state_fio->FputBool(pcm_on);
221+// state_fio->FputBool(pcm_cont);
222+// state_fio->FputBool(pcm_pit);
223+// state_fio->FputBool(fdc_irq);
224+// state_fio->FputBool(motor);
201225 }
202226
203227 bool MEMORY::load_state(FILEIO* state_fio)
204228 {
205- if(state_fio->FgetUint32() != STATE_VERSION) {
206- return false;
229+ bool mb = false;
230+ if(state_entry != NULL) {
231+ mb = state_entry->load_state(state_fio);
207232 }
208- if(state_fio->FgetInt32() != this_device_id) {
233+ if(!mb) {
209234 return false;
210235 }
211- state_fio->Fread(ram, sizeof(ram), 1);
212- state_fio->Fread(cmos, sizeof(cmos), 1);
213- cmos_crc32 = state_fio->FgetUint32();
214- bank = state_fio->FgetUint8();
215- psel = state_fio->FgetUint8();
216- csel = state_fio->FgetUint8();
217- pcm_on = state_fio->FgetBool();
218- pcm_cont = state_fio->FgetBool();
219- pcm_pit = state_fio->FgetBool();
220- fdc_irq = state_fio->FgetBool();
221- motor = state_fio->FgetBool();
236+// if(state_fio->FgetUint32() != STATE_VERSION) {
237+// return false;
238+// }
239+// if(state_fio->FgetInt32() != this_device_id) {
240+// return false;
241+// }
242+// state_fio->Fread(ram, sizeof(ram), 1);
243+// state_fio->Fread(cmos, sizeof(cmos), 1);
244+// cmos_crc32 = state_fio->FgetUint32();
245+// bank = state_fio->FgetUint8();
246+// psel = state_fio->FgetUint8();
247+// csel = state_fio->FgetUint8();
248+// pcm_on = state_fio->FgetBool();
249+// pcm_cont = state_fio->FgetBool();
250+// pcm_pit = state_fio->FgetBool();
251+// fdc_irq = state_fio->FgetBool();
252+// motor = state_fio->FgetBool();
222253
223254 // post process
224255 update_map();
--- a/source/src/vm/qc10/memory.h
+++ b/source/src/vm/qc10/memory.h
@@ -58,6 +58,7 @@ public:
5858 void write_io8(uint32_t addr, uint32_t data);
5959 uint32_t read_io8(uint32_t addr);
6060 void write_signal(int id, uint32_t data, uint32_t mask);
61+ void decl_state();
6162 void save_state(FILEIO* state_fio);
6263 bool load_state(FILEIO* state_fio);
6364
--- a/source/src/vm/qc10/mfont.cpp
+++ b/source/src/vm/qc10/mfont.cpp
@@ -94,31 +94,54 @@ uint32_t MFONT::read_io8(uint32_t addr)
9494
9595 #define STATE_VERSION 1
9696
97+#include "../../statesub.h"
98+
99+void MFONT::decl_state()
100+{
101+ enter_decl_state(STATE_VERSION);
102+
103+ DECL_STATE_ENTRY_UINT8(status);
104+ DECL_STATE_ENTRY_FIFO(cmd);
105+ DECL_STATE_ENTRY_FIFO(res);
106+
107+ leave_decl_state();
108+}
109+
97110 void MFONT::save_state(FILEIO* state_fio)
98111 {
99- state_fio->FputUint32(STATE_VERSION);
100- state_fio->FputInt32(this_device_id);
112+ if(state_entry != NULL) {
113+ state_entry->save_state(state_fio);
114+ }
115+// state_fio->FputUint32(STATE_VERSION);
116+// state_fio->FputInt32(this_device_id);
101117
102- state_fio->FputUint8(status);
103- cmd->save_state((void *)state_fio);
104- res->save_state((void *)state_fio);
118+// state_fio->FputUint8(status);
119+// cmd->save_state((void *)state_fio);
120+// res->save_state((void *)state_fio);
105121 }
106122
107123 bool MFONT::load_state(FILEIO* state_fio)
108124 {
109- if(state_fio->FgetUint32() != STATE_VERSION) {
110- return false;
111- }
112- if(state_fio->FgetInt32() != this_device_id) {
113- return false;
114- }
115- status = state_fio->FgetUint8();
116- if(!cmd->load_state((void *)state_fio)) {
117- return false;
125+ bool mb = false;
126+ if(state_entry != NULL) {
127+ mb = state_entry->load_state(state_fio);
118128 }
119- if(!res->load_state((void *)state_fio)) {
129+ if(!mb) {
120130 return false;
121131 }
132+// if(state_fio->FgetUint32() != STATE_VERSION) {
133+// return false;
134+// }
135+// if(state_fio->FgetInt32() != this_device_id) {
136+// return false;
137+// }
138+// status = state_fio->FgetUint8();
139+// if(!cmd->load_state((void *)state_fio)) {
140+// return false;
141+// }
142+// if(!res->load_state((void *)state_fio)) {
143+// return false;
144+// }
122145 return true;
123146 }
124147
--- a/source/src/vm/qc10/mfont.h
+++ b/source/src/vm/qc10/mfont.h
@@ -38,6 +38,7 @@ public:
3838 void release();
3939 void write_io8(uint32_t addr, uint32_t data);
4040 uint32_t read_io8(uint32_t addr);
41+ void decl_state();
4142 void save_state(FILEIO* state_fio);
4243 bool load_state(FILEIO* state_fio);
4344
--- a/source/src/vm/rx78/cmt.cpp
+++ b/source/src/vm/rx78/cmt.cpp
@@ -70,31 +70,56 @@ void CMT::event_frame()
7070
7171 #define STATE_VERSION 1
7272
73+#include "../../statesub.h"
74+
75+void CMT::decl_state()
76+{
77+ enter_decl_state(STATE_VERSION);
78+
79+ DECL_STATE_ENTRY_BOOL(in);
80+ DECL_STATE_ENTRY_BOOL(out);
81+ DECL_STATE_ENTRY_BOOL(remote);
82+ DECL_STATE_ENTRY_BOOL(now_acc);
83+ DECL_STATE_ENTRY_INT32(framecnt);
84+
85+ leave_decl_state();
86+}
87+
7388 void CMT::save_state(FILEIO* state_fio)
7489 {
75- state_fio->FputUint32(STATE_VERSION);
76- state_fio->FputInt32(this_device_id);
90+ if(state_entry != NULL) {
91+ state_entry->save_state(state_fio);
92+ }
93+// state_fio->FputUint32(STATE_VERSION);
94+// state_fio->FputInt32(this_device_id);
7795
78- state_fio->FputBool(in);
79- state_fio->FputBool(out);
80- state_fio->FputBool(remote);
81- state_fio->FputBool(now_acc);
82- state_fio->FputInt32(framecnt);
96+// state_fio->FputBool(in);
97+// state_fio->FputBool(out);
98+// state_fio->FputBool(remote);
99+// state_fio->FputBool(now_acc);
100+// state_fio->FputInt32(framecnt);
83101 }
84102
85103 bool CMT::load_state(FILEIO* state_fio)
86104 {
87- if(state_fio->FgetUint32() != STATE_VERSION) {
88- return false;
105+ bool mb = false;
106+ if(state_entry != NULL) {
107+ mb = state_entry->load_state(state_fio);
89108 }
90- if(state_fio->FgetInt32() != this_device_id) {
109+ if(!mb) {
91110 return false;
92111 }
93- in = state_fio->FgetBool();
94- out = state_fio->FgetBool();
95- remote = state_fio->FgetBool();
96- now_acc = state_fio->FgetBool();
97- framecnt = state_fio->FgetInt32();
112+// if(state_fio->FgetUint32() != STATE_VERSION) {
113+// return false;
114+// }
115+// if(state_fio->FgetInt32() != this_device_id) {
116+// return false;
117+// }
118+// in = state_fio->FgetBool();
119+// out = state_fio->FgetBool();
120+// remote = state_fio->FgetBool();
121+// now_acc = state_fio->FgetBool();
122+// framecnt = state_fio->FgetInt32();
98123 return true;
99124 }
100125
--- a/source/src/vm/rx78/cmt.h
+++ b/source/src/vm/rx78/cmt.h
@@ -38,6 +38,7 @@ public:
3838 uint32_t read_io8(uint32_t addr);
3939 void write_signal(int id, uint32_t data, uint32_t mask);
4040 void event_frame();
41+ void decl_state();
4142 void save_state(FILEIO* state_fio);
4243 bool load_state(FILEIO* state_fio);
4344
--- a/source/src/vm/rx78/keyboard.cpp
+++ b/source/src/vm/rx78/keyboard.cpp
@@ -94,25 +94,47 @@ void KEYBOARD::event_frame()
9494
9595 #define STATE_VERSION 1
9696
97+#include "../../statesub.h"
98+
99+void KEYBOARD::decl_state()
100+{
101+ enter_decl_state(STATE_VERSION);
102+
103+ DECL_STATE_ENTRY_1D_ARRAY(status, sizeof(status));
104+ DECL_STATE_ENTRY_UINT8(column);
105+
106+ leave_decl_state();
107+}
108+
97109 void KEYBOARD::save_state(FILEIO* state_fio)
98110 {
99- state_fio->FputUint32(STATE_VERSION);
100- state_fio->FputInt32(this_device_id);
111+ if(state_entry != NULL) {
112+ state_entry->save_state(state_fio);
113+ }
114+// state_fio->FputUint32(STATE_VERSION);
115+// state_fio->FputInt32(this_device_id);
101116
102- state_fio->Fwrite(status, sizeof(status), 1);
103- state_fio->FputUint8(column);
117+// state_fio->Fwrite(status, sizeof(status), 1);
118+// state_fio->FputUint8(column);
104119 }
105120
106121 bool KEYBOARD::load_state(FILEIO* state_fio)
107122 {
108- if(state_fio->FgetUint32() != STATE_VERSION) {
109- return false;
123+ bool mb = false;
124+ if(state_entry != NULL) {
125+ mb = state_entry->load_state(state_fio);
110126 }
111- if(state_fio->FgetInt32() != this_device_id) {
127+ if(!mb) {
112128 return false;
113129 }
114- state_fio->Fread(status, sizeof(status), 1);
115- column = state_fio->FgetUint8();
130+// if(state_fio->FgetUint32() != STATE_VERSION) {
131+// return false;
132+// }
133+// if(state_fio->FgetInt32() != this_device_id) {
134+// return false;
135+// }
136+// state_fio->Fread(status, sizeof(status), 1);
137+// column = state_fio->FgetUint8();
116138 return true;
117139 }
118140
--- a/source/src/vm/rx78/keyboard.h
+++ b/source/src/vm/rx78/keyboard.h
@@ -33,6 +33,7 @@ public:
3333 void write_io8(uint32_t addr, uint32_t data);
3434 uint32_t read_io8(uint32_t addr);
3535 void event_frame();
36+ void decl_state();
3637 void save_state(FILEIO* state_fio);
3738 bool load_state(FILEIO* state_fio);
3839 };
--- a/source/src/vm/rx78/memory.cpp
+++ b/source/src/vm/rx78/memory.cpp
@@ -137,33 +137,59 @@ void MEMORY::close_cart()
137137
138138 #define STATE_VERSION 1
139139
140+#include "../../statesub.h"
141+
142+void MEMORY::decl_state()
143+{
144+ enter_decl_state(STATE_VERSION);
145+
146+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
147+ DECL_STATE_ENTRY_1D_ARRAY(ext, sizeof(ext));
148+ DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
149+ DECL_STATE_ENTRY_INT32(rpage);
150+ DECL_STATE_ENTRY_INT32(wpage);
151+ DECL_STATE_ENTRY_BOOL(inserted);
152+
153+ leave_decl_state();
154+}
155+
140156 void MEMORY::save_state(FILEIO* state_fio)
141157 {
142- state_fio->FputUint32(STATE_VERSION);
143- state_fio->FputInt32(this_device_id);
158+ if(state_entry != NULL) {
159+ state_entry->save_state(state_fio);
160+ }
161+// state_fio->FputUint32(STATE_VERSION);
162+// state_fio->FputInt32(this_device_id);
144163
145- state_fio->Fwrite(ram, sizeof(ram), 1);
146- state_fio->Fwrite(ext, sizeof(ext), 1);
147- state_fio->Fwrite(vram, sizeof(vram), 1);
148- state_fio->FputInt32(rpage);
149- state_fio->FputInt32(wpage);
150- state_fio->FputBool(inserted);
164+// state_fio->Fwrite(ram, sizeof(ram), 1);
165+// state_fio->Fwrite(ext, sizeof(ext), 1);
166+// state_fio->Fwrite(vram, sizeof(vram), 1);
167+// state_fio->FputInt32(rpage);
168+// state_fio->FputInt32(wpage);
169+// state_fio->FputBool(inserted);
151170 }
152171
153172 bool MEMORY::load_state(FILEIO* state_fio)
154173 {
155- if(state_fio->FgetUint32() != STATE_VERSION) {
156- return false;
174+ bool mb = false;
175+ if(state_entry != NULL) {
176+ mb = state_entry->load_state(state_fio);
157177 }
158- if(state_fio->FgetInt32() != this_device_id) {
178+ if(!mb) {
159179 return false;
160180 }
161- state_fio->Fread(ram, sizeof(ram), 1);
162- state_fio->Fread(ext, sizeof(ext), 1);
163- state_fio->Fread(vram, sizeof(vram), 1);
164- rpage = state_fio->FgetInt32();
165- wpage = state_fio->FgetInt32();
166- inserted = state_fio->FgetBool();
181+// if(state_fio->FgetUint32() != STATE_VERSION) {
182+// return false;
183+// }
184+// if(state_fio->FgetInt32() != this_device_id) {
185+// return false;
186+// }
187+// state_fio->Fread(ram, sizeof(ram), 1);
188+// state_fio->Fread(ext, sizeof(ext), 1);
189+// state_fio->Fread(vram, sizeof(vram), 1);
190+// rpage = state_fio->FgetInt32();
191+// wpage = state_fio->FgetInt32();
192+// inserted = state_fio->FgetBool();
167193 return true;
168194 }
169195
--- a/source/src/vm/rx78/memory.h
+++ b/source/src/vm/rx78/memory.h
@@ -46,6 +46,7 @@ public:
4646 void write_data8(uint32_t addr, uint32_t data);
4747 uint32_t read_data8(uint32_t addr);
4848 void write_io8(uint32_t addr, uint32_t data);
49+ void decl_state();
4950 void save_state(FILEIO* state_fio);
5051 bool load_state(FILEIO* state_fio);
5152
--- a/source/src/vm/rx78/printer.cpp
+++ b/source/src/vm/rx78/printer.cpp
@@ -44,27 +44,50 @@ void PRINTER::write_signal(int id, uint32_t data, uint32_t mask)
4444
4545 #define STATE_VERSION 1
4646
47+#include "../../statesub.h"
48+
49+void PRINTER::decl_state()
50+{
51+ enter_decl_state(STATE_VERSION);
52+
53+ DECL_STATE_ENTRY_BOOL(strobe);
54+ DECL_STATE_ENTRY_BOOL(busy);
55+ DECL_STATE_ENTRY_UINT8(out);
56+
57+ leave_decl_state();
58+}
59+
4760 void PRINTER::save_state(FILEIO* state_fio)
4861 {
49- state_fio->FputUint32(STATE_VERSION);
50- state_fio->FputInt32(this_device_id);
62+ if(state_entry != NULL) {
63+ state_entry->save_state(state_fio);
64+ }
65+// state_fio->FputUint32(STATE_VERSION);
66+// state_fio->FputInt32(this_device_id);
5167
52- state_fio->FputBool(strobe);
53- state_fio->FputBool(busy);
54- state_fio->FputUint8(out);
68+// state_fio->FputBool(strobe);
69+// state_fio->FputBool(busy);
70+// state_fio->FputUint8(out);
5571 }
5672
5773 bool PRINTER::load_state(FILEIO* state_fio)
5874 {
59- if(state_fio->FgetUint32() != STATE_VERSION) {
60- return false;
75+ bool mb = false;
76+ if(state_entry != NULL) {
77+ mb = state_entry->load_state(state_fio);
6178 }
62- if(state_fio->FgetInt32() != this_device_id) {
79+ if(!mb) {
6380 return false;
6481 }
65- strobe = state_fio->FgetBool();
66- busy = state_fio->FgetBool();
67- out = state_fio->FgetUint8();
82+// if(state_fio->FgetUint32() != STATE_VERSION) {
83+// return false;
84+// }
85+// if(state_fio->FgetInt32() != this_device_id) {
86+// return false;
87+// }
88+// strobe = state_fio->FgetBool();
89+// busy = state_fio->FgetBool();
90+// out = state_fio->FgetUint8();
6891 return true;
6992 }
7093
--- a/source/src/vm/rx78/printer.h
+++ b/source/src/vm/rx78/printer.h
@@ -34,6 +34,7 @@ public:
3434 void write_io8(uint32_t addr, uint32_t data);
3535 uint32_t read_io8(uint32_t addr);
3636 void write_signal(int id, uint32_t data, uint32_t mask);
37+ void decl_state();
3738 void save_state(FILEIO* state_fio);
3839 bool load_state(FILEIO* state_fio);
3940 };
--- a/source/src/vm/rx78/vdp.cpp
+++ b/source/src/vm/rx78/vdp.cpp
@@ -158,31 +158,56 @@ void VDP::create_bg()
158158
159159 #define STATE_VERSION 1
160160
161+#include "../../statesub.h"
162+
163+void VDP::decl_state()
164+{
165+ enter_decl_state(STATE_VERSION);
166+
167+ DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette_pc, 17);
168+ DECL_STATE_ENTRY_1D_ARRAY(reg, sizeof(reg));
169+ DECL_STATE_ENTRY_UINT8(bg);
170+ DECL_STATE_ENTRY_UINT8(cmask);
171+ DECL_STATE_ENTRY_UINT8(pmask);
172+
173+ leave_decl_state();
174+}
175+
161176 void VDP::save_state(FILEIO* state_fio)
162177 {
163- state_fio->FputUint32(STATE_VERSION);
164- state_fio->FputInt32(this_device_id);
178+ if(state_entry != NULL) {
179+ state_entry->save_state(state_fio);
180+ }
181+// state_fio->FputUint32(STATE_VERSION);
182+// state_fio->FputInt32(this_device_id);
165183
166- state_fio->Fwrite(palette_pc, sizeof(palette_pc), 1);
167- state_fio->Fwrite(reg, sizeof(reg), 1);
168- state_fio->FputUint8(bg);
169- state_fio->FputUint8(cmask);
170- state_fio->FputUint8(pmask);
184+// state_fio->Fwrite(palette_pc, sizeof(palette_pc), 1);
185+// state_fio->Fwrite(reg, sizeof(reg), 1);
186+// state_fio->FputUint8(bg);
187+// state_fio->FputUint8(cmask);
188+// state_fio->FputUint8(pmask);
171189 }
172190
173191 bool VDP::load_state(FILEIO* state_fio)
174192 {
175- if(state_fio->FgetUint32() != STATE_VERSION) {
176- return false;
193+ bool mb = false;
194+ if(state_entry != NULL) {
195+ mb = state_entry->load_state(state_fio);
177196 }
178- if(state_fio->FgetInt32() != this_device_id) {
197+ if(!mb) {
179198 return false;
180199 }
181- state_fio->Fread(palette_pc, sizeof(palette_pc), 1);
182- state_fio->Fread(reg, sizeof(reg), 1);
183- bg = state_fio->FgetUint8();
184- cmask = state_fio->FgetUint8();
185- pmask = state_fio->FgetUint8();
200+// if(state_fio->FgetUint32() != STATE_VERSION) {
201+// return false;
202+// }
203+// if(state_fio->FgetInt32() != this_device_id) {
204+// return false;
205+// }
206+// state_fio->Fread(palette_pc, sizeof(palette_pc), 1);
207+// state_fio->Fread(reg, sizeof(reg), 1);
208+// bg = state_fio->FgetUint8();
209+// cmask = state_fio->FgetUint8();
210+// pmask = state_fio->FgetUint8();
186211 return true;
187212 }
188213
--- a/source/src/vm/rx78/vdp.h
+++ b/source/src/vm/rx78/vdp.h
@@ -40,6 +40,7 @@ public:
4040 void initialize();
4141 void write_io8(uint32_t addr, uint32_t data);
4242 void event_vline(int v, int clock);
43+ void decl_state();
4344 void save_state(FILEIO* state_fio);
4445 bool load_state(FILEIO* state_fio);
4546
--- a/source/src/vm/sc3000/keyboard.cpp
+++ b/source/src/vm/sc3000/keyboard.cpp
@@ -80,25 +80,47 @@ void KEYBOARD::update_keyboard()
8080
8181 #define STATE_VERSION 1
8282
83+#include "../../statesub.h"
84+
85+void KEYBOARD::decl_state()
86+{
87+ enter_decl_state(STATE_VERSION);
88+
89+ DECL_STATE_ENTRY_UINT8(column);
90+ DECL_STATE_ENTRY_BOOL(break_pressed);
91+
92+ leave_decl_state();
93+}
94+
8395 void KEYBOARD::save_state(FILEIO* state_fio)
8496 {
85- state_fio->FputUint32(STATE_VERSION);
86- state_fio->FputInt32(this_device_id);
97+ if(state_entry != NULL) {
98+ state_entry->save_state(state_fio);
99+ }
100+// state_fio->FputUint32(STATE_VERSION);
101+// state_fio->FputInt32(this_device_id);
87102
88- state_fio->FputUint8(column);
89- state_fio->FputBool(break_pressed);
103+// state_fio->FputUint8(column);
104+// state_fio->FputBool(break_pressed);
90105 }
91106
92107 bool KEYBOARD::load_state(FILEIO* state_fio)
93108 {
94- if(state_fio->FgetUint32() != STATE_VERSION) {
95- return false;
109+ bool mb = false;
110+ if(state_entry != NULL) {
111+ mb = state_entry->load_state(state_fio);
96112 }
97- if(state_fio->FgetInt32() != this_device_id) {
113+ if(!mb) {
98114 return false;
99115 }
100- column = state_fio->FgetUint8();
101- break_pressed = state_fio->FgetBool();
116+// if(state_fio->FgetUint32() != STATE_VERSION) {
117+// return false;
118+// }
119+// if(state_fio->FgetInt32() != this_device_id) {
120+// return false;
121+// }
122+// column = state_fio->FgetUint8();
123+// break_pressed = state_fio->FgetBool();
102124 return true;
103125 }
104126
--- a/source/src/vm/sc3000/keyboard.h
+++ b/source/src/vm/sc3000/keyboard.h
@@ -39,6 +39,7 @@ public:
3939 void initialize();
4040 void event_frame();
4141 void write_signal(int id, uint32_t data, uint32_t mask);
42+ void decl_state();
4243 void save_state(FILEIO* state_fio);
4344 bool load_state(FILEIO* state_fio);
4445
--- a/source/src/vm/sc3000/memory.cpp
+++ b/source/src/vm/sc3000/memory.cpp
@@ -138,29 +138,53 @@ void MEMORY::update_bank()
138138
139139 #define STATE_VERSION 2
140140
141+#include "../../statesub.h"
142+
143+void MEMORY::decl_state()
144+{
145+ enter_decl_state(STATE_VERSION);
146+
147+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
148+ DECL_STATE_ENTRY_BOOL(inserted);
149+ DECL_STATE_ENTRY_BOOL(ram_selected);
150+ DECL_STATE_ENTRY_1D_ARRAY(bank, sizeof(bank));
151+
152+ leave_decl_state();
153+}
154+
141155 void MEMORY::save_state(FILEIO* state_fio)
142156 {
143- state_fio->FputUint32(STATE_VERSION);
144- state_fio->FputInt32(this_device_id);
157+ if(state_entry != NULL) {
158+ state_entry->save_state(state_fio);
159+ }
160+// state_fio->FputUint32(STATE_VERSION);
161+// state_fio->FputInt32(this_device_id);
145162
146- state_fio->Fwrite(ram, sizeof(ram), 1);
147- state_fio->FputBool(inserted);
148- state_fio->FputBool(ram_selected);
149- state_fio->Fwrite(bank, sizeof(bank), 1);
163+// state_fio->Fwrite(ram, sizeof(ram), 1);
164+// state_fio->FputBool(inserted);
165+// state_fio->FputBool(ram_selected);
166+// state_fio->Fwrite(bank, sizeof(bank), 1);
150167 }
151168
152169 bool MEMORY::load_state(FILEIO* state_fio)
153170 {
154- if(state_fio->FgetUint32() != STATE_VERSION) {
155- return false;
171+ bool mb = false;
172+ if(state_entry != NULL) {
173+ mb = state_entry->load_state(state_fio);
156174 }
157- if(state_fio->FgetInt32() != this_device_id) {
175+ if(!mb) {
158176 return false;
159177 }
160- state_fio->Fread(ram, sizeof(ram), 1);
161- inserted = state_fio->FgetBool();
162- ram_selected = state_fio->FgetBool();
163- state_fio->Fread(bank, sizeof(bank), 1);
178+// if(state_fio->FgetUint32() != STATE_VERSION) {
179+// return false;
180+// }
181+// if(state_fio->FgetInt32() != this_device_id) {
182+// return false;
183+// }
184+// state_fio->Fread(ram, sizeof(ram), 1);
185+// inserted = state_fio->FgetBool();
186+// ram_selected = state_fio->FgetBool();
187+// state_fio->Fread(bank, sizeof(bank), 1);
164188
165189 // post process
166190 update_bank();
--- a/source/src/vm/sc3000/memory.h
+++ b/source/src/vm/sc3000/memory.h
@@ -47,6 +47,7 @@ public:
4747 void write_data8(uint32_t addr, uint32_t data);
4848 uint32_t read_data8(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/tk80bs/cmt.cpp
+++ b/source/src/vm/tk80bs/cmt.cpp
@@ -142,35 +142,61 @@ void CMT::release_tape()
142142
143143 #define STATE_VERSION 2
144144
145-void CMT::save_state(FILEIO* state_fio)
145+#include "../../statesub.h"
146+
147+void CMT::decl_state()
146148 {
147- state_fio->FputUint32(STATE_VERSION);
148- state_fio->FputInt32(this_device_id);
149+ enter_decl_state(STATE_VERSION);
149150
150- state_fio->FputBool(mic);
151- state_fio->FputBool(ear);
152- state_fio->FputBool(pulse);
153- state_fio->FputInt32(pulse_count);
151+ DECL_STATE_ENTRY_BOOL(mic);
152+ DECL_STATE_ENTRY_BOOL(ear);
153+ DECL_STATE_ENTRY_BOOL(pulse);
154+ DECL_STATE_ENTRY_INT32(pulse_count);
154155 #if defined(_TK80BS)
155- state_fio->FputBool(play);
156- state_fio->FputBool(rec);
157- state_fio->Fwrite(rec_file_path, sizeof(rec_file_path), 1);
158- if(rec && fio->IsOpened()) {
159- int length_tmp = (int)fio->Ftell();
160- fio->Fseek(0, FILEIO_SEEK_SET);
161- state_fio->FputInt32(length_tmp);
162- while(length_tmp != 0) {
163- uint8_t buffer_tmp[1024];
164- int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
165- fio->Fread(buffer_tmp, length_rw, 1);
166- state_fio->Fwrite(buffer_tmp, length_rw, 1);
167- length_tmp -= length_rw;
168- }
169- } else {
170- state_fio->FputInt32(0);
156+ DECL_STATE_ENTRY_BOOL(play);
157+ DECL_STATE_ENTRY_BOOL(rec);
158+ DECL_STATE_ENTRY_STRING(rec_file_path, sizeof(rec_file_path) / sizeof(_TCHAR));
159+
160+ DECL_STATE_ENTRY_CMT_RECORDING(fio, rec, rec_file_path);
161+
162+ DECL_STATE_ENTRY_INT32(bufcnt);
163+ DECL_STATE_ENTRY_1D_ARRAY(buffer, sizeof(buffer));
164+#endif
165+ leave_decl_state();
166+}
167+
168+void CMT::save_state(FILEIO* state_fio)
169+{
170+ if(state_entry != NULL) {
171+ state_entry->save_state(state_fio);
171172 }
172- state_fio->FputInt32(bufcnt);
173- state_fio->Fwrite(buffer, sizeof(buffer), 1);
173+// state_fio->FputUint32(STATE_VERSION);
174+// state_fio->FputInt32(this_device_id);
175+
176+// state_fio->FputBool(mic);
177+// state_fio->FputBool(ear);
178+// state_fio->FputBool(pulse);
179+// state_fio->FputInt32(pulse_count);
180+#if defined(_TK80BS)
181+// state_fio->FputBool(play);
182+// state_fio->FputBool(rec);
183+// state_fio->Fwrite(rec_file_path, sizeof(rec_file_path), 1);
184+// if(rec && fio->IsOpened()) {
185+// int length_tmp = (int)fio->Ftell();
186+// fio->Fseek(0, FILEIO_SEEK_SET);
187+// state_fio->FputInt32(length_tmp);
188+// while(length_tmp != 0) {
189+// uint8_t buffer_tmp[1024];
190+// int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
191+// fio->Fread(buffer_tmp, length_rw, 1);
192+// state_fio->Fwrite(buffer_tmp, length_rw, 1);
193+// length_tmp -= length_rw;
194+// }
195+// } else {
196+// state_fio->FputInt32(0);
197+// }
198+// state_fio->FputInt32(bufcnt);
199+// state_fio->Fwrite(buffer, sizeof(buffer), 1);
174200 #endif
175201 }
176202
@@ -178,36 +204,43 @@ bool CMT::load_state(FILEIO* state_fio)
178204 {
179205 release_tape();
180206
181- if(state_fio->FgetUint32() != STATE_VERSION) {
182- return false;
207+ bool mb = false;
208+ if(state_entry != NULL) {
209+ mb = state_entry->load_state(state_fio);
183210 }
184- if(state_fio->FgetInt32() != this_device_id) {
211+ if(!mb) {
185212 return false;
186213 }
187- mic = state_fio->FgetBool();
188- ear = state_fio->FgetBool();
189- pulse = state_fio->FgetBool();
190- pulse_count = state_fio->FgetInt32();
191-#if defined(_TK80BS)
192- play = state_fio->FgetBool();
193- rec = state_fio->FgetBool();
194- state_fio->Fread(rec_file_path, sizeof(rec_file_path), 1);
195- int length_tmp = state_fio->FgetInt32();
196- if(rec) {
197- fio->Fopen(rec_file_path, FILEIO_READ_WRITE_NEW_BINARY);
198- while(length_tmp != 0) {
199- uint8_t buffer_tmp[1024];
200- int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
201- state_fio->Fread(buffer_tmp, length_rw, 1);
202- if(fio->IsOpened()) {
203- fio->Fwrite(buffer_tmp, length_rw, 1);
204- }
205- length_tmp -= length_rw;
206- }
207- }
208- bufcnt = state_fio->FgetInt32();
209- state_fio->Fread(buffer, sizeof(buffer), 1);
210-#endif
214+// if(state_fio->FgetUint32() != STATE_VERSION) {
215+// return false;
216+// }
217+// if(state_fio->FgetInt32() != this_device_id) {
218+// return false;
219+// }
220+// mic = state_fio->FgetBool();
221+// ear = state_fio->FgetBool();
222+// pulse = state_fio->FgetBool();
223+// pulse_count = state_fio->FgetInt32();
224+//#if defined(_TK80BS)
225+// play = state_fio->FgetBool();
226+// rec = state_fio->FgetBool();
227+// state_fio->Fread(rec_file_path, sizeof(rec_file_path), 1);
228+// int length_tmp = state_fio->FgetInt32();
229+// if(rec) {
230+// fio->Fopen(rec_file_path, FILEIO_READ_WRITE_NEW_BINARY);
231+// while(length_tmp != 0) {
232+// uint8_t buffer_tmp[1024];
233+// int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
234+// state_fio->Fread(buffer_tmp, length_rw, 1);
235+// if(fio->IsOpened()) {
236+// fio->Fwrite(buffer_tmp, length_rw, 1);
237+// }
238+// length_tmp -= length_rw;
239+// }
240+// }
241+// bufcnt = state_fio->FgetInt32();
242+// state_fio->Fread(buffer, sizeof(buffer), 1);
243+//#endif
211244 return true;
212245 }
213246
--- a/source/src/vm/tk80bs/cmt.h
+++ b/source/src/vm/tk80bs/cmt.h
@@ -61,6 +61,7 @@ public:
6161 #endif
6262 void write_signal(int id, uint32_t data, uint32_t mask);
6363 void event_callback(int event_id, int err);
64+ void decl_state();
6465 void save_state(FILEIO* state_fio);
6566 bool load_state(FILEIO* state_fio);
6667
Show on old repository browser