• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

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


Commit MetaInfo

Revisionaf49f62be4b11dfdbad909a36ee434eb7da132c0 (tree)
Time2018-07-06 04:58:02
AuthorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[VM][MZ5500][WIP] Applying new state framework.WIP.

Change Summary

Incremental Difference

--- a/source/src/vm/mz5500/display.cpp
+++ b/source/src/vm/mz5500/display.cpp
@@ -500,45 +500,77 @@ void DISPLAY::update_palette()
500500
501501 #define STATE_VERSION 1
502502
503+#include "../../statesub.h"
504+
505+void DISPLAY::decl_state()
506+{
507+ enter_decl_state(STATE_VERSION);
508+
509+ DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette_pc, sizeof(palette_pc) / sizeof(scrntype_t));
510+ DECL_STATE_ENTRY_1D_ARRAY(palette, sizeof(palette));
511+ DECL_STATE_ENTRY_1D_ARRAY(back, sizeof(back));
512+ DECL_STATE_ENTRY_1D_ARRAY(reverse, sizeof(reverse));
513+ DECL_STATE_ENTRY_UINT8(rno);
514+ DECL_STATE_ENTRY_1D_ARRAY(wregs, sizeof(wregs));
515+ DECL_STATE_ENTRY_1D_ARRAY(pri, sizeof(pri) / sizeof(int));
516+ DECL_STATE_ENTRY_1D_ARRAY(vma, sizeof(vma) / sizeof(int));
517+ DECL_STATE_ENTRY_1D_ARRAY(vds, sizeof(vds));
518+ DECL_STATE_ENTRY_UINT8(mode_r);
519+ DECL_STATE_ENTRY_UINT8(mode_c);
520+ DECL_STATE_ENTRY_UINT8(mode_p);
521+
522+ leave_decl_state();
523+}
524+
503525 void DISPLAY::save_state(FILEIO* state_fio)
504526 {
505- state_fio->FputUint32(STATE_VERSION);
506- state_fio->FputInt32(this_device_id);
527+ if(state_entry != NULL) {
528+ state_entry->save_state(state_fio);
529+ }
530+// state_fio->FputUint32(STATE_VERSION);
531+// state_fio->FputInt32(this_device_id);
507532
508- state_fio->Fwrite(palette_pc, sizeof(palette_pc), 1);
509- state_fio->Fwrite(palette, sizeof(palette), 1);
510- state_fio->Fwrite(back, sizeof(back), 1);
511- state_fio->Fwrite(reverse, sizeof(reverse), 1);
512- state_fio->FputUint8(rno);
513- state_fio->Fwrite(wregs, sizeof(wregs), 1);
514- state_fio->Fwrite(pri, sizeof(pri), 1);
515- state_fio->Fwrite(vma, sizeof(vma), 1);
516- state_fio->Fwrite(vds, sizeof(vds), 1);
517- state_fio->FputUint8(mode_r);
518- state_fio->FputUint8(mode_c);
519- state_fio->FputUint8(mode_p);
533+// state_fio->Fwrite(palette_pc, sizeof(palette_pc), 1);
534+// state_fio->Fwrite(palette, sizeof(palette), 1);
535+// state_fio->Fwrite(back, sizeof(back), 1);
536+// state_fio->Fwrite(reverse, sizeof(reverse), 1);
537+// state_fio->FputUint8(rno);
538+// state_fio->Fwrite(wregs, sizeof(wregs), 1);
539+// state_fio->Fwrite(pri, sizeof(pri), 1);
540+// state_fio->Fwrite(vma, sizeof(vma), 1);
541+// state_fio->Fwrite(vds, sizeof(vds), 1);
542+// state_fio->FputUint8(mode_r);
543+// state_fio->FputUint8(mode_c);
544+// state_fio->FputUint8(mode_p);
520545 }
521546
522547 bool DISPLAY::load_state(FILEIO* state_fio)
523548 {
524- if(state_fio->FgetUint32() != STATE_VERSION) {
525- return false;
549+ bool mb = false;
550+ if(state_entry != NULL) {
551+ mb = state_entry->load_state(state_fio);
526552 }
527- if(state_fio->FgetInt32() != this_device_id) {
553+ if(!mb) {
528554 return false;
529555 }
530- state_fio->Fread(palette_pc, sizeof(palette_pc), 1);
531- state_fio->Fread(palette, sizeof(palette), 1);
532- state_fio->Fread(back, sizeof(back), 1);
533- state_fio->Fread(reverse, sizeof(reverse), 1);
534- rno = state_fio->FgetUint8();
535- state_fio->Fread(wregs, sizeof(wregs), 1);
536- state_fio->Fread(pri, sizeof(pri), 1);
537- state_fio->Fread(vma, sizeof(vma), 1);
538- state_fio->Fread(vds, sizeof(vds), 1);
539- mode_r = state_fio->FgetUint8();
540- mode_c = state_fio->FgetUint8();
541- mode_p = state_fio->FgetUint8();
556+// if(state_fio->FgetUint32() != STATE_VERSION) {
557+// return false;
558+// }
559+// if(state_fio->FgetInt32() != this_device_id) {
560+// return false;
561+// }
562+// state_fio->Fread(palette_pc, sizeof(palette_pc), 1);
563+// state_fio->Fread(palette, sizeof(palette), 1);
564+// state_fio->Fread(back, sizeof(back), 1);
565+// state_fio->Fread(reverse, sizeof(reverse), 1);
566+// rno = state_fio->FgetUint8();
567+// state_fio->Fread(wregs, sizeof(wregs), 1);
568+// state_fio->Fread(pri, sizeof(pri), 1);
569+// state_fio->Fread(vma, sizeof(vma), 1);
570+// state_fio->Fread(vds, sizeof(vds), 1);
571+// mode_r = state_fio->FgetUint8();
572+// mode_c = state_fio->FgetUint8();
573+// mode_p = state_fio->FgetUint8();
542574 return true;
543575 }
544576
--- a/source/src/vm/mz5500/display.h
+++ b/source/src/vm/mz5500/display.h
@@ -53,6 +53,7 @@ public:
5353 void initialize();
5454 void write_io8(uint32_t addr, uint32_t data);
5555 uint32_t read_io8(uint32_t addr);
56+ void decl_state();
5657 void save_state(FILEIO* state_fio);
5758 bool load_state(FILEIO* state_fio);
5859
--- a/source/src/vm/mz5500/keyboard.cpp
+++ b/source/src/vm/mz5500/keyboard.cpp
@@ -466,51 +466,84 @@ void KEYBOARD::process(int cmd)
466466
467467 #define STATE_VERSION 1
468468
469+#include "../../statesub.h"
470+
471+void KEYBOARD::decl_state()
472+{
473+ enter_decl_state(STATE_VERSION);
474+
475+ DECL_STATE_ENTRY_FIFO(key_buf);
476+ DECL_STATE_ENTRY_FIFO(rsp_buf);
477+ DECL_STATE_ENTRY_BOOL(caps);
478+ DECL_STATE_ENTRY_BOOL(kana);
479+ DECL_STATE_ENTRY_BOOL(graph);
480+ DECL_STATE_ENTRY_INT32(dk);
481+ DECL_STATE_ENTRY_INT32(srk);
482+ DECL_STATE_ENTRY_INT32(dc);
483+ DECL_STATE_ENTRY_INT32(stc);
484+ DECL_STATE_ENTRY_INT32(send);
485+ DECL_STATE_ENTRY_INT32(recv);
486+ DECL_STATE_ENTRY_INT32(phase);
487+ DECL_STATE_ENTRY_INT32(timeout);
488+
489+ leave_decl_state();
490+}
491+
469492 void KEYBOARD::save_state(FILEIO* state_fio)
470493 {
471- state_fio->FputUint32(STATE_VERSION);
472- state_fio->FputInt32(this_device_id);
494+ if(state_entry != NULL) {
495+ state_entry->save_state(state_fio);
496+ }
497+// state_fio->FputUint32(STATE_VERSION);
498+// state_fio->FputInt32(this_device_id);
473499
474- key_buf->save_state((void *)state_fio);
475- rsp_buf->save_state((void *)state_fio);
476- state_fio->FputBool(caps);
477- state_fio->FputBool(kana);
478- state_fio->FputBool(graph);
479- state_fio->FputInt32(dk);
480- state_fio->FputInt32(srk);
481- state_fio->FputInt32(dc);
482- state_fio->FputInt32(stc);
483- state_fio->FputInt32(send);
484- state_fio->FputInt32(recv);
485- state_fio->FputInt32(phase);
486- state_fio->FputInt32(timeout);
500+// key_buf->save_state((void *)state_fio);
501+// rsp_buf->save_state((void *)state_fio);
502+// state_fio->FputBool(caps);
503+// state_fio->FputBool(kana);
504+// state_fio->FputBool(graph);
505+// state_fio->FputInt32(dk);
506+// state_fio->FputInt32(srk);
507+// state_fio->FputInt32(dc);
508+// state_fio->FputInt32(stc);
509+// state_fio->FputInt32(send);
510+// state_fio->FputInt32(recv);
511+// state_fio->FputInt32(phase);
512+// state_fio->FputInt32(timeout);
487513 }
488514
489515 bool KEYBOARD::load_state(FILEIO* state_fio)
490516 {
491- if(state_fio->FgetUint32() != STATE_VERSION) {
492- return false;
493- }
494- if(state_fio->FgetInt32() != this_device_id) {
495- return false;
496- }
497- if(!key_buf->load_state((void *)state_fio)) {
498- return false;
517+ bool mb = false;
518+ if(state_entry != NULL) {
519+ mb = state_entry->load_state(state_fio);
499520 }
500- if(!rsp_buf->load_state((void *)state_fio)) {
521+ if(!mb) {
501522 return false;
502523 }
503- caps = state_fio->FgetBool();
504- kana = state_fio->FgetBool();
505- graph = state_fio->FgetBool();
506- dk = state_fio->FgetInt32();
507- srk = state_fio->FgetInt32();
508- dc = state_fio->FgetInt32();
509- stc = state_fio->FgetInt32();
510- send = state_fio->FgetInt32();
511- recv = state_fio->FgetInt32();
512- phase = state_fio->FgetInt32();
513- timeout = state_fio->FgetInt32();
524+// if(state_fio->FgetUint32() != STATE_VERSION) {
525+// return false;
526+// }
527+// if(state_fio->FgetInt32() != this_device_id) {
528+// return false;
529+// }
530+// if(!key_buf->load_state((void *)state_fio)) {
531+// return false;
532+// }
533+// if(!rsp_buf->load_state((void *)state_fio)) {
534+// return false;
535+// }
536+// caps = state_fio->FgetBool();
537+// kana = state_fio->FgetBool();
538+// graph = state_fio->FgetBool();
539+// dk = state_fio->FgetInt32();
540+// srk = state_fio->FgetInt32();
541+// dc = state_fio->FgetInt32();
542+// stc = state_fio->FgetInt32();
543+// send = state_fio->FgetInt32();
544+// recv = state_fio->FgetInt32();
545+// phase = state_fio->FgetInt32();
546+// timeout = state_fio->FgetInt32();
514547 return true;
515548 }
516549
--- a/source/src/vm/mz5500/keyboard.h
+++ b/source/src/vm/mz5500/keyboard.h
@@ -48,6 +48,7 @@ public:
4848 void reset();
4949 void write_signal(int id, uint32_t data, uint32_t mask);
5050 void event_frame();
51+ void decl_state();
5152 void save_state(FILEIO* state_fio);
5253 bool load_state(FILEIO* state_fio);
5354
--- a/source/src/vm/mz5500/memory.cpp
+++ b/source/src/vm/mz5500/memory.cpp
@@ -190,37 +190,65 @@ void MEMORY::update_bank()
190190
191191 #define STATE_VERSION 1
192192
193-void MEMORY::save_state(FILEIO* state_fio)
193+#include "../../statesub.h"
194+
195+void MEMORY::decl_state()
194196 {
195- state_fio->FputUint32(STATE_VERSION);
196- state_fio->FputInt32(this_device_id);
197-
198- state_fio->Fwrite(ram, sizeof(ram), 1);
199- state_fio->Fwrite(vram, sizeof(vram), 1);
197+ enter_decl_state(STATE_VERSION);
198+
199+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
200+ DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
200201 #if defined(_MZ6500) || defined(_MZ6550)
201- state_fio->Fwrite(mz1r32, sizeof(mz1r32), 1);
202+ DECL_STATE_ENTRY_1D_ARRAY(mz1r32, sizeof(mz1r32));
202203 #endif
203- state_fio->FputUint8(bank1);
204- state_fio->FputUint8(bank2);
205- state_fio->FputUint32(haddr);
204+ DECL_STATE_ENTRY_UINT8(bank1);
205+ DECL_STATE_ENTRY_UINT8(bank2);
206+ DECL_STATE_ENTRY_UINT32(haddr);
207+
208+ leave_decl_state();
209+}
210+
211+void MEMORY::save_state(FILEIO* state_fio)
212+{
213+ if(state_entry != NULL) {
214+ state_entry->save_state(state_fio);
215+ }
216+// state_fio->FputUint32(STATE_VERSION);
217+// state_fio->FputInt32(this_device_id);
218+
219+// state_fio->Fwrite(ram, sizeof(ram), 1);
220+// state_fio->Fwrite(vram, sizeof(vram), 1);
221+//#if defined(_MZ6500) || defined(_MZ6550)
222+// state_fio->Fwrite(mz1r32, sizeof(mz1r32), 1);
223+//#endif
224+// state_fio->FputUint8(bank1);
225+// state_fio->FputUint8(bank2);
226+// state_fio->FputUint32(haddr);
206227 }
207228
208229 bool MEMORY::load_state(FILEIO* state_fio)
209230 {
210- if(state_fio->FgetUint32() != STATE_VERSION) {
211- return false;
231+ bool mb = false;
232+ if(state_entry != NULL) {
233+ mb = state_entry->load_state(state_fio);
212234 }
213- if(state_fio->FgetInt32() != this_device_id) {
235+ if(!mb) {
214236 return false;
215237 }
216- state_fio->Fread(ram, sizeof(ram), 1);
217- state_fio->Fread(vram, sizeof(vram), 1);
218-#if defined(_MZ6500) || defined(_MZ6550)
219- state_fio->Fread(mz1r32, sizeof(mz1r32), 1);
220-#endif
221- bank1 = state_fio->FgetUint8();
222- bank2 = state_fio->FgetUint8();
223- haddr = state_fio->FgetUint32();
238+// if(state_fio->FgetUint32() != STATE_VERSION) {
239+// return false;
240+// }
241+// if(state_fio->FgetInt32() != this_device_id) {
242+// return false;
243+// }
244+// state_fio->Fread(ram, sizeof(ram), 1);
245+// state_fio->Fread(vram, sizeof(vram), 1);
246+//#if defined(_MZ6500) || defined(_MZ6550)
247+// state_fio->Fread(mz1r32, sizeof(mz1r32), 1);
248+//#endif
249+// bank1 = state_fio->FgetUint8();
250+// bank2 = state_fio->FgetUint8();
251+// haddr = state_fio->FgetUint32();
224252
225253 // post process
226254 update_bank();
--- a/source/src/vm/mz5500/memory.h
+++ b/source/src/vm/mz5500/memory.h
@@ -66,6 +66,7 @@ public:
6666 void write_signal(int id, uint32_t data, uint32_t mask);
6767 void write_io8(uint32_t addr, uint32_t data);
6868 uint32_t read_io8(uint32_t addr);
69+ void decl_state();
6970 void save_state(FILEIO* state_fio);
7071 bool load_state(FILEIO* state_fio);
7172
Show on old repository browser