• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: コミット

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


コミットメタ情報

リビジョン1664531c66d5e1b5e0f71cba47ba5c7ebed2d1c3 (tree)
日時2018-10-28 02:37:38
作者K.Ohta <whatisthis.sowhat@gmai...>
コミッターK.Ohta

ログメッセージ

[VM] Enable to build with upstream 2018-10-14 @some VMs.

変更サマリ

差分

--- a/source/src/vm/babbage2nd/babbage2nd.cpp
+++ b/source/src/vm/babbage2nd/babbage2nd.cpp
@@ -266,7 +266,7 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
266266 }
267267 }
268268 // Machine specified.
269- state_fio->StateBuffer(ram, sizeof(ram), 1);
269+ state_fio->StateArray(ram, sizeof(ram), 1);
270270 if(loading) {
271271 update_config();
272272 }
--- a/source/src/vm/bubcom80/display.cpp
+++ b/source/src/vm/bubcom80/display.cpp
@@ -821,67 +821,49 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
821821 if(!state_fio->StateCheckInt32(this_device_id)) {
822822 return false;
823823 }
824- state_fio->StateBuffer(font, sizeof(font), 1);
825- state_fio->StateBuffer(vram, sizeof(vram), 1);
826- state_fio->StateInt32(busreq_clocks);
827- state_fio->StateBool(color);
828- state_fio->StateBool(width40);
829- state_fio->StateUint8(mode);
830- //state_fio->StateBuffer(&crtc, sizeof(crtc), 1);
831- {
832- // crtc
833- /* struct */{
834- state_fio->StateInt32(crtc.blink.rate);
835- state_fio->StateInt32(crtc.blink.counter);
836- state_fio->StateUint8(crtc.blink.cursor);
837- state_fio->StateUint8(crtc.blink.attrib);
838- } /* blink */;
839- /*struct */{
840- state_fio->StateInt32(crtc.cursor.type);
841- state_fio->StateInt32(crtc.cursor.mode);
842- state_fio->StateInt32(crtc.cursor.x);
843- state_fio->StateInt32(crtc.cursor.y);
844- } /* cursor */;
845- /*struct */{
846- state_fio->StateUint8(crtc.attrib.data);
847- state_fio->StateInt32(crtc.attrib.num);
848- state_fio->StateBuffer(crtc.attrib.expand, sizeof(crtc.attrib.expand), 1);
849- } /* attrib */;
850- /* struct */{
851- state_fio->StateBuffer(crtc.text.expand, sizeof(crtc.text.expand), 1);
852- } /*text; */
853- state_fio->StateInt32(crtc.width);
854- state_fio->StateInt32(crtc.height);
855- state_fio->StateInt32(crtc.char_height);
856- state_fio->StateBool(crtc.skip_line);
857- state_fio->StateInt32(crtc.vretrace);
858- state_fio->StateBool(crtc.timing_changed);
859- state_fio->StateBuffer(crtc.buffer, sizeof(crtc.buffer), 1);
860- state_fio->StateInt32(crtc.buffer_ptr);
861- state_fio->StateUint8(crtc.cmd);
862- state_fio->StateInt32(crtc.cmd_ptr);
863- state_fio->StateUint8(crtc.mode);
864- state_fio->StateUint8(crtc.reverse);
865- state_fio->StateUint8(crtc.intr_mask);
866- state_fio->StateUint8(crtc.status);
867- state_fio->StateBool(crtc.vblank);
868- }
869- STORE_DMAC_CONTEXTS();
870- //state_fio->StateBuffer(&dmac, sizeof(dmac), 1);
871- { // dmac
872-
873- for(int i = 0; i < 4; i++) {
874- state_fio->StateUint32(dmac.ch[i].addr.d);
875- state_fio->StateUint32(dmac.ch[i].count.d);
876- state_fio->StateUint8(dmac.ch[i].mode);
877- state_fio->StateInt32(dmac.ch[i].nbytes);
878- state_fio->StateBool(dmac.ch[i].running);
879- } /* ch[4] */
880- state_fio->StateUint8(dmac.mode);
881- state_fio->StateUint8(dmac.status);
882- state_fio->StateBool(dmac.high_low);
883- }
884- RESTORE_DMAC_CONTEXTS();
824+ state_fio->StateArray(font, sizeof(font), 1);
825+ state_fio->StateArray(vram, sizeof(vram), 1);
826+ state_fio->StateValue(busreq_clocks);
827+ state_fio->StateValue(color);
828+ state_fio->StateValue(width40);
829+ state_fio->StateValue(mode);
830+ state_fio->StateValue(crtc.blink.rate);
831+ state_fio->StateValue(crtc.blink.counter);
832+ state_fio->StateValue(crtc.blink.cursor);
833+ state_fio->StateValue(crtc.blink.attrib);
834+ state_fio->StateValue(crtc.cursor.type);
835+ state_fio->StateValue(crtc.cursor.mode);
836+ state_fio->StateValue(crtc.cursor.x);
837+ state_fio->StateValue(crtc.cursor.y);
838+ state_fio->StateValue(crtc.attrib.data);
839+ state_fio->StateValue(crtc.attrib.num);
840+ state_fio->StateArray(&crtc.attrib.expand[0][0], sizeof(crtc.attrib.expand), 1);
841+ state_fio->StateArray(&crtc.text.expand[0][0], sizeof(crtc.text.expand), 1);
842+ state_fio->StateValue(crtc.width);
843+ state_fio->StateValue(crtc.height);
844+ state_fio->StateValue(crtc.char_height);
845+ state_fio->StateValue(crtc.skip_line);
846+ state_fio->StateValue(crtc.vretrace);
847+ state_fio->StateValue(crtc.timing_changed);
848+ state_fio->StateArray(crtc.buffer, sizeof(crtc.buffer), 1);
849+ state_fio->StateValue(crtc.buffer_ptr);
850+ state_fio->StateValue(crtc.cmd);
851+ state_fio->StateValue(crtc.cmd_ptr);
852+ state_fio->StateValue(crtc.mode);
853+ state_fio->StateValue(crtc.reverse);
854+ state_fio->StateValue(crtc.intr_mask);
855+ state_fio->StateValue(crtc.status);
856+ state_fio->StateValue(crtc.vblank);
857+ for(int i = 0; i < array_length(dmac.ch); i++) {
858+ state_fio->StateValue(dmac.ch[i].addr);
859+ state_fio->StateValue(dmac.ch[i].count);
860+ state_fio->StateValue(dmac.ch[i].mode);
861+ state_fio->StateValue(dmac.ch[i].nbytes);
862+ state_fio->StateValue(dmac.ch[i].running);
863+ }
864+ state_fio->StateValue(dmac.mode);
865+ state_fio->StateValue(dmac.status);
866+ state_fio->StateValue(dmac.high_low);
885867 return true;
886868 }
887869 }
--- a/source/src/vm/familybasic/apu.cpp
+++ b/source/src/vm/familybasic/apu.cpp
@@ -798,108 +798,106 @@ void APU::set_volume(int ch, int decibel_l, int decibel_r)
798798
799799 #define STATE_VERSION 2
800800
801-void APU::process_state_rectangle(int num, FILEIO* state_fio, bool loading)
801+void process_state_rectangle(rectangle_t* val, FILEIO* state_fio)
802802 {
803- state_fio->StateBuffer(rectangle[num].regs, sizeof(rectangle[0].regs), 1);
804- state_fio->StateBool(rectangle[num].enabled);
805- state_fio->StateInt32(rectangle[num].phaseacc);
806- state_fio->StateInt32(rectangle[num].freq);
807- state_fio->StateInt32(rectangle[num].output_vol);
808- state_fio->StateBool(rectangle[num].fixed_envelope);
809- state_fio->StateBool(rectangle[num].holdnote);
810- state_fio->StateUint8(rectangle[num].volume);
811- state_fio->StateInt32(rectangle[num].sweep_phase);
812- state_fio->StateInt32(rectangle[num].sweep_delay);
813- state_fio->StateBool(rectangle[num].sweep_on);
814- state_fio->StateUint8(rectangle[num].sweep_shifts);
815- state_fio->StateUint8(rectangle[num].sweep_length);
816- state_fio->StateBool(rectangle[num].sweep_inc);
817- state_fio->StateInt32(rectangle[num].freq_limit);
818- state_fio->StateBool(rectangle[num].sweep_complement);
819- state_fio->StateInt32(rectangle[num].env_phase);
820- state_fio->StateInt32(rectangle[num].env_delay);
821- state_fio->StateUint8(rectangle[num].env_vol);
822- state_fio->StateInt32(rectangle[num].vbl_length);
823- state_fio->StateUint8(rectangle[num].adder);
824- state_fio->StateInt32(rectangle[num].duty_flip);
825- state_fio->StateBool(rectangle[num].enabled_cur);
826- state_fio->StateBool(rectangle[num].holdnote_cur);
827- state_fio->StateInt32(rectangle[num].vbl_length_cur);
803+ state_fio->StateArray(val->regs, sizeof(val->regs), 1);
804+ state_fio->StateValue(val->enabled);
805+ state_fio->StateValue(val->phaseacc);
806+ state_fio->StateValue(val->freq);
807+ state_fio->StateValue(val->output_vol);
808+ state_fio->StateValue(val->fixed_envelope);
809+ state_fio->StateValue(val->holdnote);
810+ state_fio->StateValue(val->volume);
811+ state_fio->StateValue(val->sweep_phase);
812+ state_fio->StateValue(val->sweep_delay);
813+ state_fio->StateValue(val->sweep_on);
814+ state_fio->StateValue(val->sweep_shifts);
815+ state_fio->StateValue(val->sweep_length);
816+ state_fio->StateValue(val->sweep_inc);
817+ state_fio->StateValue(val->freq_limit);
818+ state_fio->StateValue(val->sweep_complement);
819+ state_fio->StateValue(val->env_phase);
820+ state_fio->StateValue(val->env_delay);
821+ state_fio->StateValue(val->env_vol);
822+ state_fio->StateValue(val->vbl_length);
823+ state_fio->StateValue(val->adder);
824+ state_fio->StateValue(val->duty_flip);
825+ state_fio->StateValue(val->enabled_cur);
826+ state_fio->StateValue(val->holdnote_cur);
827+ state_fio->StateValue(val->vbl_length_cur);
828828 }
829829
830-void APU::process_state_triangle(FILEIO* state_fio, bool loading)
830+void process_state_triangle(triangle_t* val, FILEIO* state_fio)
831831 {
832- state_fio->StateBuffer(triangle.regs, sizeof(triangle.regs), 1);
833- state_fio->StateBool(triangle.enabled);
834- state_fio->StateInt32(triangle.freq);
835- state_fio->StateInt32(triangle.phaseacc);
836- state_fio->StateInt32(triangle.output_vol);
837- state_fio->StateUint8(triangle.adder);
838- state_fio->StateBool(triangle.holdnote);
839- state_fio->StateBool(triangle.counter_started);
840- state_fio->StateInt32(triangle.write_latency);
841- state_fio->StateInt32(triangle.vbl_length);
842- state_fio->StateInt32(triangle.linear_length);
843- state_fio->StateBool(triangle.enabled_cur);
844- state_fio->StateBool(triangle.holdnote_cur);
845- state_fio->StateBool(triangle.counter_started_cur);
846- state_fio->StateInt32(triangle.vbl_length_cur);
847-
832+ state_fio->StateArray(val->regs, sizeof(val->regs), 1);
833+ state_fio->StateValue(val->enabled);
834+ state_fio->StateValue(val->freq);
835+ state_fio->StateValue(val->phaseacc);
836+ state_fio->StateValue(val->output_vol);
837+ state_fio->StateValue(val->adder);
838+ state_fio->StateValue(val->holdnote);
839+ state_fio->StateValue(val->counter_started);
840+ state_fio->StateValue(val->write_latency);
841+ state_fio->StateValue(val->vbl_length);
842+ state_fio->StateValue(val->linear_length);
843+ state_fio->StateValue(val->enabled_cur);
844+ state_fio->StateValue(val->holdnote_cur);
845+ state_fio->StateValue(val->counter_started_cur);
846+ state_fio->StateValue(val->vbl_length_cur);
848847 }
849848
850-void APU::process_state_noise(FILEIO* state_fio, bool loading)
849+void process_state_noise(noise_t* val, FILEIO* state_fio)
851850 {
852- state_fio->StateBuffer(noise.regs, sizeof(noise.regs), 1);
853- state_fio->StateBool(noise.enabled);
854- state_fio->StateInt32(noise.freq);
855- state_fio->StateInt32(noise.phaseacc);
856- state_fio->StateInt32(noise.output_vol);
857- state_fio->StateInt32(noise.env_phase);
858- state_fio->StateInt32(noise.env_delay);
859- state_fio->StateUint8(noise.env_vol);
860- state_fio->StateBool(noise.fixed_envelope);
861- state_fio->StateBool(noise.holdnote);
862- state_fio->StateUint8(noise.volume);
863- state_fio->StateInt32(noise.vbl_length);
864- state_fio->StateUint8(noise.xor_tap);
865- state_fio->StateBool(noise.enabled_cur);
866- state_fio->StateBool(noise.holdnote_cur);
867- state_fio->StateInt32(noise.vbl_length_cur);
868-
869- state_fio->StateInt32(noise.shift_reg);
870- state_fio->StateInt32(noise.noise_bit);
851+ state_fio->StateArray(val->regs, sizeof(val->regs), 1);
852+ state_fio->StateValue(val->enabled);
853+ state_fio->StateValue(val->freq);
854+ state_fio->StateValue(val->phaseacc);
855+ state_fio->StateValue(val->output_vol);
856+ state_fio->StateValue(val->env_phase);
857+ state_fio->StateValue(val->env_delay);
858+ state_fio->StateValue(val->env_vol);
859+ state_fio->StateValue(val->fixed_envelope);
860+ state_fio->StateValue(val->holdnote);
861+ state_fio->StateValue(val->volume);
862+ state_fio->StateValue(val->vbl_length);
863+ state_fio->StateValue(val->xor_tap);
864+ state_fio->StateValue(val->enabled_cur);
865+ state_fio->StateValue(val->holdnote_cur);
866+ state_fio->StateValue(val->vbl_length_cur);
867+ state_fio->StateValue(val->shift_reg);
868+ state_fio->StateValue(val->noise_bit);
871869 }
872870
873-void APU::process_state_dmc(FILEIO* state_fio, bool loading)
871+void process_state_dmc(dmc_t* val, FILEIO* state_fio)
874872 {
875- state_fio->StateBuffer(dmc.regs, sizeof(dmc.regs), 1);
876- state_fio->StateBool(dmc.enabled);
877- state_fio->StateInt32(dmc.freq);
878- state_fio->StateInt32(dmc.phaseacc);
879- state_fio->StateInt32(dmc.output_vol);
880- state_fio->StateUint32(dmc.address);
881- state_fio->StateUint32(dmc.cached_addr);
882- state_fio->StateInt32(dmc.dma_length);
883- state_fio->StateInt32(dmc.cached_dmalength);
884- state_fio->StateUint8(dmc.cur_byte);
885- state_fio->StateBool(dmc.looping);
886- state_fio->StateBool(dmc.irq_gen);
887- state_fio->StateBool(dmc.irq_occurred);
888- state_fio->StateInt32(dmc.freq_cur);
889- state_fio->StateInt32(dmc.phaseacc_cur);
890- state_fio->StateInt32(dmc.dma_length_cur);
891- state_fio->StateInt32(dmc.cached_dmalength_cur);
892- state_fio->StateBool(dmc.enabled_cur);
893- state_fio->StateBool(dmc.looping_cur);
894- state_fio->StateBool(dmc.irq_gen_cur);
895- state_fio->StateBool(dmc.irq_occurred_cur);
873+ state_fio->StateArray(val->regs, sizeof(val->regs), 1);
874+ state_fio->StateValue(val->enabled);
875+ state_fio->StateValue(val->freq);
876+ state_fio->StateValue(val->phaseacc);
877+ state_fio->StateValue(val->output_vol);
878+ state_fio->StateValue(val->address);
879+ state_fio->StateValue(val->cached_addr);
880+ state_fio->StateValue(val->dma_length);
881+ state_fio->StateValue(val->cached_dmalength);
882+ state_fio->StateValue(val->cur_byte);
883+ state_fio->StateValue(val->looping);
884+ state_fio->StateValue(val->irq_gen);
885+ state_fio->StateValue(val->irq_occurred);
886+ state_fio->StateValue(val->freq_cur);
887+ state_fio->StateValue(val->phaseacc_cur);
888+ state_fio->StateValue(val->dma_length_cur);
889+ state_fio->StateValue(val->cached_dmalength_cur);
890+ state_fio->StateValue(val->enabled_cur);
891+ state_fio->StateValue(val->looping_cur);
892+ state_fio->StateValue(val->irq_gen_cur);
893+ state_fio->StateValue(val->irq_occurred_cur);
896894 }
897895
898-void APU::process_state_queue(int num, FILEIO* state_fio, bool loading)
896+void process_state_queue(queue_t* val, FILEIO* state_fio)
899897 {
900- state_fio->StateUint32(queue[num].timestamp);
901- state_fio->StateUint32(queue[num].addr);
902- state_fio->StateUint32(queue[num].data);
898+ state_fio->StateValue(val->timestamp);
899+ state_fio->StateValue(val->addr);
900+ state_fio->StateValue(val->data);
903901 }
904902
905903 bool APU::process_state(FILEIO* state_fio, bool loading)
@@ -910,30 +908,24 @@ bool APU::process_state(FILEIO* state_fio, bool loading)
910908 if(!state_fio->StateCheckInt32(this_device_id)) {
911909 return false;
912910 }
913- //state_fio->StateBuffer(rectangle, sizeof(rectangle), 1);
914- //state_fio->StateBuffer(&triangle, sizeof(triangle), 1);
915- //state_fio->StateBuffer(&noise, sizeof(noise), 1);
916- //state_fio->StateBuffer(&dmc, sizeof(dmc), 1);
917- for(int i = 0; i < 2; i++) {
918- process_state_rectangle(i, state_fio, loading);
919- }
920- process_state_triangle(state_fio, loading);
921- process_state_noise(state_fio, loading);
922- process_state_dmc(state_fio, loading);
923-
924- state_fio->StateUint32(enable_reg);
925- state_fio->StateUint32(enable_reg_cur);
926- state_fio->StateInt32(count_rate);
927- //state_fio->StateBuffer(queue, sizeof(queue), 1);
928- for(int i = 0; i < APUQUEUE_SIZE; i++) {
929- process_state_queue(i, state_fio, loading);
930- }
931- state_fio->StateInt32(q_head);
932- state_fio->StateInt32(q_tail);
933- state_fio->StateUint32(elapsed_cycles);
934- state_fio->StateDouble(ave);
935- state_fio->StateDouble(max);
936- state_fio->StateDouble(min);
911+ for(int i = 0; i < array_length(rectangle); i++) {
912+ process_state_rectangle(&rectangle[i], state_fio);
913+ }
914+ process_state_triangle(&triangle, state_fio);
915+ process_state_noise(&noise, state_fio);
916+ process_state_dmc(&dmc, state_fio);
917+ state_fio->StateValue(enable_reg);
918+ state_fio->StateValue(enable_reg_cur);
919+ state_fio->StateValue(count_rate);
920+ for(int i = 0; i < array_length(queue); i++) {
921+ process_state_queue(&queue[i], state_fio);
922+ }
923+ state_fio->StateValue(q_head);
924+ state_fio->StateValue(q_tail);
925+ state_fio->StateValue(elapsed_cycles);
926+ state_fio->StateValue(ave);
927+ state_fio->StateValue(max);
928+ state_fio->StateValue(min);
937929 return true;
938930 }
939931
--- a/source/src/vm/familybasic/apu.h
+++ b/source/src/vm/familybasic/apu.h
@@ -159,12 +159,6 @@ private:
159159
160160 int volume_l, volume_r;
161161
162- void process_state_rectangle(int num, FILEIO* state_fio, bool loading);
163- void process_state_triangle(FILEIO* state_fio, bool loading);
164- void process_state_noise(FILEIO* state_fio, bool loading);
165- void process_state_dmc(FILEIO* state_fio, bool loading);
166- void process_state_queue(int num, FILEIO* state_fio, bool loading);
167-
168162 public:
169163 APU(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
170164 {
--- a/source/src/vm/familybasic/familybasic.cpp
+++ b/source/src/vm/familybasic/familybasic.cpp
@@ -349,7 +349,7 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
349349 }
350350 }
351351 // Machine specified.
352- state_fio->StateInt32(boot_mode);
352+ state_fio->StateValue(boot_mode);
353353 if(loading) {
354354 update_config();
355355 }
--- a/source/src/vm/familybasic/memory.cpp
+++ b/source/src/vm/familybasic/memory.cpp
@@ -886,10 +886,16 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
886886 if(!state_fio->StateCheckInt32(this_device_id)) {
887887 return false;
888888 }
889- state_fio->StateBuffer(save_file_name, sizeof(save_file_name), 1);
890- state_fio->StateBuffer(&header, sizeof(header), 1); // OK?
891- state_fio->StateUint32(rom_size);
892-// state_fio->StateUint32(rom_mask);
889+ state_fio->StateArray(save_file_name, sizeof(save_file_name), 1);
890+ state_fio->StateArray(header.id, sizeof(header.id), 1);
891+ state_fio->StateValue(header.ctrl_z);
892+ state_fio->StateValue(header.dummy);
893+ state_fio->StateValue(header.num_8k_vrom_banks);
894+ state_fio->StateValue(header.flags_1);
895+ state_fio->StateValue(header.flags_2);
896+ state_fio->StateArray(header.reserved, sizeof(header.reserved), 1);
897+ state_fio->StateValue(rom_size);
898+// state_fio->StateValue(rom_mask);
893899 if(loading) {
894900 rom_mask = (rom_size / 0x2000) - 1;
895901 if(rom != NULL) {
@@ -897,41 +903,35 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
897903 }
898904 rom = (uint8_t *)malloc(rom_size);
899905 }
900- state_fio->StateBuffer(rom, rom_size, 1);
901- state_fio->StateBuffer(ram, sizeof(ram), 1);
902- state_fio->StateBuffer(save_ram, sizeof(save_ram), 1);
903- state_fio->StateUint32(save_ram_crc32);
904- //state_fio->StateBuffer(banks, sizeof(banks), 1);
905- for(int i = 0; i < (sizeof(banks) / sizeof(uint32_t)); i++) {
906- state_fio->StateUint32(banks[i]);
907- }
908- state_fio->StateUint16(dma_addr);
909- state_fio->StateUint8(frame_irq_enabled);
910- //state_fio->StateBuffer(mmc5_wram_bank, sizeof(mmc5_wram_bank), 1);
911- for(int i = 0; i < (sizeof(mmc5_wram_bank) / sizeof(uint32_t)); i++) {
912- state_fio->StateUint32(mmc5_wram_bank[i]);
913- }
914- state_fio->StateBuffer(mmc5_chr_reg, sizeof(mmc5_chr_reg), 1);
915- state_fio->StateUint32(mmc5_value0);
916- state_fio->StateUint32(mmc5_value0);
917- state_fio->StateUint8(mmc5_wram_protect0);
918- state_fio->StateUint8(mmc5_wram_protect1);
919- state_fio->StateUint8(mmc5_prg_size);
920- state_fio->StateUint8(mmc5_chr_size);
921- state_fio->StateUint8(mmc5_gfx_mode);
922-// state_fio->StateUint8(mmc5_split_control);
923-// state_fio->StateUint8(mmc5_split_bank);
924- state_fio->StateUint8(mmc5_irq_enabled);
925- state_fio->StateUint8(mmc5_irq_status);
926- state_fio->StateUint32(mmc5_irq_line);
927- state_fio->StateUint8(vrc7_irq_enabled);
928- state_fio->StateUint8(vrc7_irq_counter);
929- state_fio->StateUint8(vrc7_irq_latch);
930- state_fio->StateBool(pad_strobe);
931- state_fio->StateUint8(pad1_bits);
932- state_fio->StateUint8(pad2_bits);
933- state_fio->StateBool(kb_out);
934- state_fio->StateUint8(kb_scan);
906+ state_fio->StateArray(rom, rom_size, 1);
907+ state_fio->StateArray(ram, sizeof(ram), 1);
908+ state_fio->StateArray(save_ram, sizeof(save_ram), 1);
909+ state_fio->StateValue(save_ram_crc32);
910+ state_fio->StateArray(banks, sizeof(banks), 1);
911+ state_fio->StateValue(dma_addr);
912+ state_fio->StateValue(frame_irq_enabled);
913+ state_fio->StateArray(mmc5_wram_bank, sizeof(mmc5_wram_bank), 1);
914+ state_fio->StateArray(&mmc5_chr_reg[0][0], sizeof(mmc5_chr_reg), 1);
915+ state_fio->StateValue(mmc5_value0);
916+ state_fio->StateValue(mmc5_value0);
917+ state_fio->StateValue(mmc5_wram_protect0);
918+ state_fio->StateValue(mmc5_wram_protect1);
919+ state_fio->StateValue(mmc5_prg_size);
920+ state_fio->StateValue(mmc5_chr_size);
921+ state_fio->StateValue(mmc5_gfx_mode);
922+// state_fio->StateValue(mmc5_split_control);
923+// state_fio->StateValue(mmc5_split_bank);
924+ state_fio->StateValue(mmc5_irq_enabled);
925+ state_fio->StateValue(mmc5_irq_status);
926+ state_fio->StateValue(mmc5_irq_line);
927+ state_fio->StateValue(vrc7_irq_enabled);
928+ state_fio->StateValue(vrc7_irq_counter);
929+ state_fio->StateValue(vrc7_irq_latch);
930+ state_fio->StateValue(pad_strobe);
931+ state_fio->StateValue(pad1_bits);
932+ state_fio->StateValue(pad2_bits);
933+ state_fio->StateValue(kb_out);
934+ state_fio->StateValue(kb_scan);
935935
936936 // post process
937937 if(loading) {
--- a/source/src/vm/familybasic/ppu.cpp
+++ b/source/src/vm/familybasic/ppu.cpp
@@ -673,34 +673,18 @@ bool PPU::process_state(FILEIO* state_fio, bool loading)
673673 if(!state_fio->StateCheckInt32(this_device_id)) {
674674 return false;
675675 }
676- //state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
677- if(loading) {
678- for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
679- uint8_t r, g, b;
680- r = state_fio->FgetUint8();
681- g = state_fio->FgetUint8();
682- b = state_fio->FgetUint8();
683- palette_pc[i] = RGB_COLOR(r, g, b);
684- }
685- } else {
686- for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
687- uint8_t r, g, b;
688- r = R_OF_COLOR(palette_pc[i]);
689- g = G_OF_COLOR(palette_pc[i]);
690- b = B_OF_COLOR(palette_pc[i]);
691- state_fio->FputUint8(r);
692- state_fio->FputUint8(g);
693- state_fio->FputUint8(b);
694- }
695- }
696- state_fio->StateBuffer(solid_buf, sizeof(solid_buf), 1);
697- state_fio->StateBuffer(&header, sizeof(header), 1); // OK?
698-// state_fio->StateBuffer(banks, sizeof(banks), 1);
699- for(int i = 0; i < (sizeof(banks) / sizeof(uint32_t)); i++) {
700- state_fio->StateUint32(banks[i]);
701- }
702- state_fio->StateUint32(chr_rom_size);
703-// state_fio->StateInt32(chr_rom_mask);
676+ state_fio->StateArrayScrnType_t(palette_pc, sizeof(palette_pc), 1);
677+ state_fio->StateArray(solid_buf, sizeof(solid_buf), 1);
678+ state_fio->StateArray(header.id, sizeof(header.id), 1);
679+ state_fio->StateValue(header.ctrl_z);
680+ state_fio->StateValue(header.dummy);
681+ state_fio->StateValue(header.num_8k_vrom_banks);
682+ state_fio->StateValue(header.flags_1);
683+ state_fio->StateValue(header.flags_2);
684+ state_fio->StateArray(header.reserved, sizeof(header.reserved), 1);
685+ state_fio->StateArray(banks, sizeof(banks), 1);
686+ state_fio->StateValue(chr_rom_size);
687+// state_fio->StateValue(chr_rom_mask);
704688 if(loading) {
705689 chr_rom_mask = (chr_rom_size / 0x400) - 1;
706690 if(chr_rom != NULL) {
@@ -708,22 +692,22 @@ bool PPU::process_state(FILEIO* state_fio, bool loading)
708692 }
709693 chr_rom = (uint8_t *)malloc(chr_rom_size);
710694 }
711- state_fio->StateBuffer(chr_rom, chr_rom_size, 1);
712- state_fio->StateBuffer(name_tables, sizeof(name_tables), 1);
713- state_fio->StateBuffer(spr_ram, sizeof(spr_ram), 1);
714- state_fio->StateBuffer(bg_pal, sizeof(bg_pal), 1);
715- state_fio->StateBuffer(spr_pal, sizeof(spr_pal), 1);
716- state_fio->StateUint8(spr_ram_rw_ptr);
717- state_fio->StateBuffer(regs, sizeof(regs), 1);
718- state_fio->StateUint16(bg_pattern_table_addr);
719- state_fio->StateUint16(spr_pattern_table_addr);
720- state_fio->StateUint16(ppu_addr_inc);
721- state_fio->StateUint8(rgb_bak);
722- state_fio->StateBool(toggle_2005_2006);
723- state_fio->StateUint8(read_2007_buffer);
724- state_fio->StateUint16(loopy_v);
725- state_fio->StateUint16(loopy_t);
726- state_fio->StateUint8(loopy_x);
695+ state_fio->StateArray(chr_rom, chr_rom_size, 1);
696+ state_fio->StateArray(name_tables, sizeof(name_tables), 1);
697+ state_fio->StateArray(spr_ram, sizeof(spr_ram), 1);
698+ state_fio->StateArray(bg_pal, sizeof(bg_pal), 1);
699+ state_fio->StateArray(spr_pal, sizeof(spr_pal), 1);
700+ state_fio->StateValue(spr_ram_rw_ptr);
701+ state_fio->StateArray(regs, sizeof(regs), 1);
702+ state_fio->StateValue(bg_pattern_table_addr);
703+ state_fio->StateValue(spr_pattern_table_addr);
704+ state_fio->StateValue(ppu_addr_inc);
705+ state_fio->StateValue(rgb_bak);
706+ state_fio->StateValue(toggle_2005_2006);
707+ state_fio->StateValue(read_2007_buffer);
708+ state_fio->StateValue(loopy_v);
709+ state_fio->StateValue(loopy_t);
710+ state_fio->StateValue(loopy_x);
727711
728712 // post process
729713 if(loading) {
--- a/source/src/vm/fm16pi/fm16pi.cpp
+++ b/source/src/vm/fm16pi/fm16pi.cpp
@@ -453,6 +453,6 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
453453 }
454454 }
455455 // Machine specified.
456- state_fio->StateBuffer(ram, sizeof(ram), 1);
456+ state_fio->StateArray(ram, sizeof(ram), 1);
457457 return true;
458458 }
--- a/source/src/vm/fmr30/floppy.cpp
+++ b/source/src/vm/fmr30/floppy.cpp
@@ -107,15 +107,12 @@ bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
107107 if(!state_fio->StateCheckInt32(this_device_id)) {
108108 return false;
109109 }
110- state_fio->StateUint8(fdcr);
111- state_fio->StateUint8(fdsl);
112- state_fio->StateUint8(fdst);
113- state_fio->StateInt32(drvsel);
114- state_fio->StateBool(irq);
115- //state_fio->StateBuffer(changed, sizeof(changed), 1);
116- for(int i = 0; i < (sizeof(changed) / sizeof(bool)); i++) {
117- state_fio->StateBool(changed[i]);
118- }
110+ state_fio->StateValue(fdcr);
111+ state_fio->StateValue(fdsl);
112+ state_fio->StateValue(fdst);
113+ state_fio->StateValue(drvsel);
114+ state_fio->StateValue(irq);
115+ state_fio->StateArray(changed, sizeof(changed), 1);
119116 return true;
120117 }
121118
--- a/source/src/vm/fmr30/serial.cpp
+++ b/source/src/vm/fmr30/serial.cpp
@@ -152,13 +152,13 @@ bool SERIAL::process_state(FILEIO* state_fio, bool loading)
152152 return false;
153153 }
154154 //state_fio->StateBuffer(sioctrl, sizeof(sioctrl), 1);
155- for(int i = 0; i < 4; i++) {
156- state_fio->StateUint8(sioctrl[i].baud);
157- state_fio->StateUint8(sioctrl[i].ctrl);
158- state_fio->StateBool(sioctrl[i].rxrdy);
159- state_fio->StateBool(sioctrl[i].txrdy);
160- state_fio->StateUint8(sioctrl[i].intmask);
161- state_fio->StateUint8(sioctrl[i].intstat);
155+ for(int i = 0; i < 4; i++) {
156+ state_fio->StateValue(sioctrl[i].baud);
157+ state_fio->StateValue(sioctrl[i].ctrl);
158+ state_fio->StateValue(sioctrl[i].rxrdy);
159+ state_fio->StateValue(sioctrl[i].txrdy);
160+ state_fio->StateValue(sioctrl[i].intmask);
161+ state_fio->StateValue(sioctrl[i].intstat);
162162 }
163163 return true;
164164 }
--- a/source/src/vm/fmr50/bios.cpp
+++ b/source/src/vm/fmr50/bios.cpp
@@ -1161,17 +1161,11 @@ bool BIOS::process_state(FILEIO* state_fio, bool loading)
11611161 return false;
11621162 }
11631163 }
1164- state_fio->StateInt32(secnum);
1165- state_fio->StateInt32(timeout);
1166- state_fio->StateBuffer(drive_mode1, sizeof(drive_mode1), 1);
1167- //state_fio->StateBuffer(drive_mode2, sizeof(drive_mode2), 1);
1168- for(int i = 0; i < (sizeof(drive_mode2) / sizeof(uint16_t)); i++) {
1169- state_fio->StateUint16(drive_mode2[i]);
1170- }
1171- //state_fio->StateBuffer(scsi_blocks, sizeof(scsi_blocks), 1);
1172- for(int i = 0; i < (sizeof(scsi_blocks) / sizeof(int)); i++) {
1173- state_fio->StateInt32(scsi_blocks[i]);
1174- }
1164+ state_fio->StateValue(secnum);
1165+ state_fio->StateValue(timeout);
1166+ state_fio->StateArray(drive_mode1, sizeof(drive_mode1), 1);
1167+ state_fio->StateArray(drive_mode2, sizeof(drive_mode2), 1);
1168+ state_fio->StateArray(scsi_blocks, sizeof(scsi_blocks), 1);
11751169 return true;
11761170 }
11771171
--- a/source/src/vm/fmr50/floppy.cpp
+++ b/source/src/vm/fmr50/floppy.cpp
@@ -123,14 +123,11 @@ bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
123123 if(!state_fio->StateCheckInt32(this_device_id)) {
124124 return false;
125125 }
126- state_fio->StateInt32(drvreg);
127- state_fio->StateInt32(drvsel);
128- state_fio->StateBool(irq);
129- state_fio->StateBool(irqmsk);
130- //state_fio->StateBuffer(changed, sizeof(changed), 1);
131- for(int i = 0; i < (sizeof(changed) / sizeof(bool)); i++) {
132- state_fio->StateBool(changed[i]);
133- }
126+ state_fio->StateValue(drvreg);
127+ state_fio->StateValue(drvsel);
128+ state_fio->StateValue(irq);
129+ state_fio->StateValue(irqmsk);
130+ state_fio->StateArray(changed, sizeof(changed), 1);
134131 return true;
135132 }
136133
--- a/source/src/vm/fmr50/memory.cpp
+++ b/source/src/vm/fmr50/memory.cpp
@@ -1223,94 +1223,58 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
12231223 if(!state_fio->StateCheckInt32(this_device_id)) {
12241224 return false;
12251225 }
1226- state_fio->StateBuffer(ram, sizeof(ram), 1);
1227- state_fio->StateBuffer(vram, sizeof(vram), 1);
1228- state_fio->StateBuffer(cvram, sizeof(cvram), 1);
1229-#ifdef _FMR60
1230- state_fio->StateBuffer(avram, sizeof(avram), 1);
1231-#else
1232- state_fio->StateBuffer(kvram, sizeof(kvram), 1);
1233-#endif
1234- state_fio->StateUint8(machine_id);
1235- state_fio->StateUint8(protect);
1236- state_fio->StateUint8(rst);
1237- state_fio->StateUint8(mainmem);
1238- state_fio->StateUint8(rplane);
1239- state_fio->StateUint8(wplane);
1240- state_fio->StateUint8(dma_addr_reg);
1241- state_fio->StateUint8(dma_wrap_reg);
1242- state_fio->StateUint32(dma_addr_mask);
1243- state_fio->StateBool(disp);
1244- state_fio->StateBool(vsync);
1245- state_fio->StateInt32(blink);
1246- state_fio->StateBuffer(apal, sizeof(apal), 1);
1247- state_fio->StateUint8(apalsel);
1248- state_fio->StateBuffer(dpal, sizeof(dpal), 1);
1249- state_fio->StateUint8(outctrl);
1226+ state_fio->StateArray(ram, sizeof(ram), 1);
1227+ state_fio->StateArray(vram, sizeof(vram), 1);
1228+ state_fio->StateArray(cvram, sizeof(cvram), 1);
1229+ #ifdef _FMR60
1230+ state_fio->StateArray(avram, sizeof(avram), 1);
1231+ #else
1232+ state_fio->StateArray(kvram, sizeof(kvram), 1);
1233+ #endif
1234+ state_fio->StateValue(machine_id);
1235+ state_fio->StateValue(protect);
1236+ state_fio->StateValue(rst);
1237+ state_fio->StateValue(mainmem);
1238+ state_fio->StateValue(rplane);
1239+ state_fio->StateValue(wplane);
1240+ state_fio->StateValue(dma_addr_reg);
1241+ state_fio->StateValue(dma_wrap_reg);
1242+ state_fio->StateValue(dma_addr_mask);
1243+ state_fio->StateValue(disp);
1244+ state_fio->StateValue(vsync);
1245+ state_fio->StateValue(blink);
1246+ state_fio->StateArray(&apal[0][0], sizeof(apal), 1);
1247+ state_fio->StateValue(apalsel);
1248+ state_fio->StateArray(dpal, sizeof(dpal), 1);
1249+ state_fio->StateValue(outctrl);
12501250 #ifndef _FMR60
1251- state_fio->StateUint8(pagesel);
1252- state_fio->StateUint8(ankcg);
1253- state_fio->StateUint8(dispctrl);
1254- state_fio->StateUint8(mix);
1255- state_fio->StateUint16(accaddr);
1256- state_fio->StateUint16(dispaddr);
1257- state_fio->StateInt32(kj_h);
1258- state_fio->StateInt32(kj_l);
1259- state_fio->StateInt32(kj_ofs);
1260- state_fio->StateInt32(kj_row);
1261- state_fio->StateUint8(cmdreg);
1262- state_fio->StateUint8(imgcol);
1263- state_fio->StateUint8(maskreg);
1264- state_fio->StateBuffer(compreg, sizeof(compreg), 1);
1265- state_fio->StateUint8(compbit);
1266- state_fio->StateUint8(bankdis);
1267- state_fio->StateBuffer(tilereg, sizeof(tilereg), 1);
1268- state_fio->StateUint16(lofs);
1269- state_fio->StateUint16(lsty);
1270- state_fio->StateUint16(lsx);
1271- state_fio->StateUint16(lsy);
1272- state_fio->StateUint16(lex);
1273- state_fio->StateUint16(ley);
1251+ state_fio->StateValue(pagesel);
1252+ state_fio->StateValue(ankcg);
1253+ state_fio->StateValue(dispctrl);
1254+ state_fio->StateValue(mix);
1255+ state_fio->StateValue(accaddr);
1256+ state_fio->StateValue(dispaddr);
1257+ state_fio->StateValue(kj_h);
1258+ state_fio->StateValue(kj_l);
1259+ state_fio->StateValue(kj_ofs);
1260+ state_fio->StateValue(kj_row);
1261+ state_fio->StateValue(cmdreg);
1262+ state_fio->StateValue(imgcol);
1263+ state_fio->StateValue(maskreg);
1264+ state_fio->StateArray(compreg, sizeof(compreg), 1);
1265+ state_fio->StateValue(compbit);
1266+ state_fio->StateValue(bankdis);
1267+ state_fio->StateArray(tilereg, sizeof(tilereg), 1);
1268+ state_fio->StateValue(lofs);
1269+ state_fio->StateValue(lsty);
1270+ state_fio->StateValue(lsx);
1271+ state_fio->StateValue(lsy);
1272+ state_fio->StateValue(lex);
1273+ state_fio->StateValue(ley);
12741274 #endif
1275- //state_fio->StateBuffer(palette_cg, sizeof(palette_cg), 1);
1276- if(loading) {
1277- for(int i = 0; i < (sizeof(palette_cg) / sizeof(scrntype_t)); i++) {
1278- uint8_t r, g, b;
1279- r = state_fio->FgetUint8();
1280- g = state_fio->FgetUint8();
1281- b = state_fio->FgetUint8();
1282- palette_cg[i] = RGB_COLOR(r, g, b);
1283- }
1284- } else {
1285- for(int i = 0; i < (sizeof(palette_cg) / sizeof(scrntype_t)); i++) {
1286- uint8_t r, g, b;
1287- r = R_OF_COLOR(palette_cg[i]);
1288- g = G_OF_COLOR(palette_cg[i]);
1289- b = B_OF_COLOR(palette_cg[i]);
1290- state_fio->FputUint8(r);
1291- state_fio->FputUint8(g);
1292- state_fio->FputUint8(b);
1293- }
1294- }
1295- if(loading) {
1296- for(int i = 0; i < (sizeof(palette_txt) / sizeof(scrntype_t)); i++) {
1297- uint8_t r, g, b;
1298- r = state_fio->FgetUint8();
1299- g = state_fio->FgetUint8();
1300- b = state_fio->FgetUint8();
1301- palette_txt[i] = RGB_COLOR(r, g, b);
1302- }
1303- } else {
1304- for(int i = 0; i < (sizeof(palette_txt) / sizeof(scrntype_t)); i++) {
1305- uint8_t r, g, b;
1306- r = R_OF_COLOR(palette_txt[i]);
1307- g = G_OF_COLOR(palette_txt[i]);
1308- b = B_OF_COLOR(palette_txt[i]);
1309- state_fio->FputUint8(r);
1310- state_fio->FputUint8(g);
1311- state_fio->FputUint8(b);
1312- }
1313- }
1275+ state_fio->StateArrayScrnType_t(palette_cg, sizeof(palette_cg), 1);
1276+// state_fio->StateArrayScrnType_t(palette_txt, sizeof(palette_txt), 1);
1277+
13141278 // post process
13151279 if(loading) {
13161280 update_bank();
--- a/source/src/vm/fp1100/sub.cpp
+++ b/source/src/vm/fp1100/sub.cpp
@@ -526,61 +526,6 @@ void SUB::draw_screen()
526526 }
527527 }
528528
529-
530-#define PROCESS_STATE_74LS74(foo) \
531- { \
532- state_fio->StateBool(foo.in_d); \
533- state_fio->StateBool(foo.in_ck); \
534- state_fio->StateBool(foo.in_s); \
535- state_fio->StateBool(foo.in_r); \
536- state_fio->StateBool(foo.out_q); \
537- state_fio->StateBool(foo.out_nq); \
538- state_fio->StateBool(foo.tmp_ck); \
539- }
540-
541-#define PROCESS_STATE_74LS151(foo) \
542- { \
543- state_fio->StateBool(foo.in_d0); \
544- state_fio->StateBool(foo.in_d1); \
545- state_fio->StateBool(foo.in_d2); \
546- state_fio->StateBool(foo.in_d3); \
547- state_fio->StateBool(foo.in_d4); \
548- state_fio->StateBool(foo.in_d5); \
549- state_fio->StateBool(foo.in_d6); \
550- state_fio->StateBool(foo.in_d7); \
551- state_fio->StateBool(foo.in_a); \
552- state_fio->StateBool(foo.in_b); \
553- state_fio->StateBool(foo.in_c); \
554- state_fio->StateBool(foo.in_s); \
555- state_fio->StateBool(foo.out_y); \
556- state_fio->StateBool(foo.out_ny); \
557- }
558-
559-#define PROCESS_STATE_74LS93(foo) \
560- { \
561- state_fio->StateBool(foo.in_a); \
562- state_fio->StateBool(foo.in_b); \
563- state_fio->StateBool(foo.in_rc1); \
564- state_fio->StateBool(foo.in_rc2); \
565- state_fio->StateBool(foo.out_qa); \
566- state_fio->StateBool(foo.out_qb); \
567- state_fio->StateBool(foo.out_qc); \
568- state_fio->StateBool(foo.tmp_a); \
569- state_fio->StateBool(foo.tmp_b); \
570- state_fio->StateUint8(foo.counter_a); \
571- state_fio->StateUint8(foo.counter_b); \
572- }
573-
574-#define PROCESS_STATE_4024(foo) \
575- { \
576- state_fio->StateBool(foo.in_ck); \
577- state_fio->StateBool(foo.in_clr); \
578- state_fio->StateBool(foo.out_q5); \
579- state_fio->StateBool(foo.out_q6); \
580- state_fio->StateBool(foo.tmp_ck); \
581- state_fio->StateUint8(foo.counter); \
582- }
583-
584529 #define STATE_VERSION 3
585530
586531 void process_state_ls74(ls74_t* val, FILEIO* state_fio)
@@ -645,40 +590,29 @@ bool SUB::process_state(FILEIO* state_fio, bool loading)
645590 if(!state_fio->StateCheckInt32(this_device_id)) {
646591 return false;
647592 }
648- state_fio->StateBuffer(ram, sizeof(ram), 1);
649- state_fio->StateBuffer(vram_b, sizeof(vram_b), 1);
650- state_fio->StateBuffer(vram_r, sizeof(vram_r), 1);
651- state_fio->StateBuffer(vram_g, sizeof(vram_g), 1);
652- state_fio->StateUint8(pa);
653- state_fio->StateUint8(pb);
654- state_fio->StateUint8(pc);
655- state_fio->StateUint8(comm_data);
656- state_fio->StateBool(so);
657- state_fio->StateUint8(clock);
658- //state_fio->StateBuffer(&b16_1, sizeof(b16_1), 1);
659- //state_fio->StateBuffer(&b16_2, sizeof(b16_2), 1);
660- //state_fio->StateBuffer(&g21_1, sizeof(g21_1), 1);
661- //state_fio->StateBuffer(&g21_2, sizeof(g21_2), 1);
662- PROCESS_STATE_74LS74(b16_1);
663- PROCESS_STATE_74LS74(b16_2);
664- PROCESS_STATE_74LS74(g21_1);
665- PROCESS_STATE_74LS74(g21_2);
666-
667- //state_fio->StateBuffer(&c15, sizeof(c15), 1);
668- PROCESS_STATE_74LS151(c15);
669-
670- //state_fio->StateBuffer(&c16, sizeof(c16), 1);
671- PROCESS_STATE_74LS93(c16);
672-
673- //state_fio->StateBuffer(&f21, sizeof(f21), 1);
674- PROCESS_STATE_4024(f21);
675-
676- state_fio->StateUint8(key_sel);
677- state_fio->StateUint8(key_data);
678- state_fio->StateUint8(color_reg);
679- state_fio->StateBool(hsync);
680- state_fio->StateBool(wait);
681- state_fio->StateUint8(cblink);
593+ state_fio->StateArray(ram, sizeof(ram), 1);
594+ state_fio->StateArray(vram_b, sizeof(vram_b), 1);
595+ state_fio->StateArray(vram_r, sizeof(vram_r), 1);
596+ state_fio->StateArray(vram_g, sizeof(vram_g), 1);
597+ state_fio->StateValue(pa);
598+ state_fio->StateValue(pb);
599+ state_fio->StateValue(pc);
600+ state_fio->StateValue(comm_data);
601+ state_fio->StateValue(so);
602+ state_fio->StateValue(clock);
603+ process_state_ls74(&b16_1, state_fio);
604+ process_state_ls74(&b16_2, state_fio);
605+ process_state_ls74(&g21_1, state_fio);
606+ process_state_ls74(&g21_2, state_fio);
607+ process_state_ls151(&c15, state_fio);
608+ process_state_ls93(&c16, state_fio);
609+ process_state_tc4024bp(&f21, state_fio);
610+ state_fio->StateValue(key_sel);
611+ state_fio->StateValue(key_data);
612+ state_fio->StateValue(color_reg);
613+ state_fio->StateValue(hsync);
614+ state_fio->StateValue(wait);
615+ state_fio->StateValue(cblink);
682616 return true;
683617 }
684618
--- a/source/src/vm/fp1100/sub.h
+++ b/source/src/vm/fp1100/sub.h
@@ -24,6 +24,104 @@ class HD46505;
2424
2525 namespace FP1100 {
2626
27+// 74LS74
28+typedef struct ls74_s {
29+ bool in_d, in_ck, in_s, in_r;
30+ bool out_q, out_nq;
31+ bool tmp_ck;
32+ void update()
33+ {
34+ if(!in_s && in_r) {
35+ out_q = true;
36+ out_nq = false;
37+ } else if(in_s && !in_r) {
38+ out_q = false;
39+ out_nq = true;
40+ } else if(!in_s && !in_r) {
41+ out_q = out_nq = true; // undetermined
42+ } else if(!tmp_ck && in_ck) {
43+ out_q = in_d;
44+ out_nq = !in_d;
45+ }
46+ tmp_ck = in_ck;
47+ }
48+} ls74_t;
49+
50+// 74LS151
51+typedef struct ls151_s {
52+ bool in_d0, in_d1, in_d2, in_d3, in_d4, in_d5, in_d6, in_d7;
53+ bool in_a, in_b, in_c, in_s;
54+ bool out_y, out_ny;
55+ void update()
56+ {
57+ if(in_s) {
58+ out_y = false;
59+ } else if(!in_a && !in_b && !in_c) {
60+ out_y = in_d0;
61+ } else if( in_a && !in_b && !in_c) {
62+ out_y = in_d1;
63+ } else if(!in_a && in_b && !in_c) {
64+ out_y = in_d2;
65+ } else if( in_a && in_b && !in_c) {
66+ out_y = in_d3;
67+ } else if(!in_a && !in_b && in_c) {
68+ out_y = in_d4;
69+ } else if( in_a && !in_b && in_c) {
70+ out_y = in_d5;
71+ } else if(!in_a && in_b && in_c) {
72+ out_y = in_d6;
73+ } else if( in_a && in_b && in_c) {
74+ out_y = in_d7;
75+ }
76+ out_ny = !out_y;
77+ }
78+} ls151_t;
79+
80+// 74LS93
81+typedef struct ls93_s {
82+ bool in_a, in_b, in_rc1, in_rc2;
83+ bool out_qa, out_qb, out_qc;
84+ bool tmp_a, tmp_b;
85+ uint8_t counter_a, counter_b;
86+ void update()
87+ {
88+ if(in_rc1 && in_rc2) {
89+ counter_a = counter_b = 0;
90+ } else {
91+ if(tmp_a && !in_a) {
92+ counter_a++;
93+ }
94+ if(tmp_b && !in_b) {
95+ counter_b++;
96+ }
97+ }
98+ tmp_a = in_a;
99+ tmp_b = in_b;
100+ out_qa = ((counter_a & 1) != 0);
101+ out_qb = ((counter_b & 1) != 0);
102+ out_qc = ((counter_b & 2) != 0);
103+ }
104+} ls93_t;
105+
106+// TC4024BP
107+typedef struct tc4024bp_s {
108+ bool in_ck, in_clr;
109+ bool out_q5, out_q6;
110+ bool tmp_ck;
111+ uint8_t counter;
112+ void update()
113+ {
114+ if(in_clr) {
115+ counter = 0;
116+ } else if(tmp_ck && !in_ck) {
117+ counter++;
118+ }
119+ tmp_ck = in_ck;
120+ out_q5 = ((counter & 0x10) != 0);
121+ out_q6 = ((counter & 0x20) != 0);
122+ }
123+} tc4024bp_t;
124+
27125 class SUB : public DEVICE
28126 {
29127 private:
--- a/source/src/vm/fp200/fp200.cpp
+++ b/source/src/vm/fp200/fp200.cpp
@@ -357,6 +357,6 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
357357 return false;
358358 }
359359 }
360- state_fio->StateBuffer(ram, sizeof(ram), 1);
360+ state_fio->StateArray(ram, sizeof(ram), 1);
361361 return true;
362362 }
--- a/source/src/vm/fp200/io.cpp
+++ b/source/src/vm/fp200/io.cpp
@@ -586,61 +586,61 @@ void IO::draw_screen()
586586 }
587587 }
588588
589-#define PROCESS_STATE_74LS74(foo) \
590- { \
591- state_fio->StateBool(foo.in_d); \
592- state_fio->StateBool(foo.in_ck); \
593- state_fio->StateBool(foo.in_s); \
594- state_fio->StateBool(foo.in_r); \
595- state_fio->StateBool(foo.out_q); \
596- state_fio->StateBool(foo.out_nq); \
597- state_fio->StateBool(foo.tmp_ck); \
598- }
589+#define STATE_VERSION 3
599590
600-#define PROCESS_STATE_74LS151(foo) \
601- { \
602- state_fio->StateBool(foo.in_d0); \
603- state_fio->StateBool(foo.in_d1); \
604- state_fio->StateBool(foo.in_d2); \
605- state_fio->StateBool(foo.in_d3); \
606- state_fio->StateBool(foo.in_d4); \
607- state_fio->StateBool(foo.in_d5); \
608- state_fio->StateBool(foo.in_d6); \
609- state_fio->StateBool(foo.in_d7); \
610- state_fio->StateBool(foo.in_a); \
611- state_fio->StateBool(foo.in_b); \
612- state_fio->StateBool(foo.in_c); \
613- state_fio->StateBool(foo.in_s); \
614- state_fio->StateBool(foo.out_y); \
615- state_fio->StateBool(foo.out_ny); \
616- }
591+void process_state_ls74(ls74_t* val, FILEIO* state_fio)
592+{
593+ state_fio->StateValue(val->in_d);
594+ state_fio->StateValue(val->in_ck);
595+ state_fio->StateValue(val->in_s);
596+ state_fio->StateValue(val->in_r);
597+ state_fio->StateValue(val->out_q);
598+ state_fio->StateValue(val->out_nq);
599+ state_fio->StateValue(val->tmp_ck);
600+}
617601
618-#define PROCESS_STATE_74LS93(foo) \
619- { \
620- state_fio->StateBool(foo.in_a); \
621- state_fio->StateBool(foo.in_b); \
622- state_fio->StateBool(foo.in_rc1); \
623- state_fio->StateBool(foo.in_rc2); \
624- state_fio->StateBool(foo.out_qa); \
625- state_fio->StateBool(foo.out_qb); \
626- state_fio->StateBool(foo.out_qc); \
627- state_fio->StateBool(foo.tmp_a); \
628- state_fio->StateBool(foo.tmp_b); \
629- state_fio->StateUint8(foo.counter_a); \
630- state_fio->StateUint8(foo.counter_b); \
631- }
602+void process_state_ls151(ls151_t* val, FILEIO* state_fio)
603+{
604+ state_fio->StateValue(val->in_d0);
605+ state_fio->StateValue(val->in_d1);
606+ state_fio->StateValue(val->in_d2);
607+ state_fio->StateValue(val->in_d3);
608+ state_fio->StateValue(val->in_d4);
609+ state_fio->StateValue(val->in_d5);
610+ state_fio->StateValue(val->in_d6);
611+ state_fio->StateValue(val->in_d7);
612+ state_fio->StateValue(val->in_a);
613+ state_fio->StateValue(val->in_b);
614+ state_fio->StateValue(val->in_c);
615+ state_fio->StateValue(val->in_s);
616+ state_fio->StateValue(val->out_y);
617+ state_fio->StateValue(val->out_ny);
618+}
632619
633-#define PROCESS_STATE_4024(foo) \
634- { \
635- state_fio->StateBool(foo.in_ck); \
636- state_fio->StateBool(foo.in_clr); \
637- state_fio->StateBool(foo.out_q5); \
638- state_fio->StateBool(foo.out_q6); \
639- state_fio->StateBool(foo.tmp_ck); \
640- state_fio->StateUint8(foo.counter); \
641- }
620+void process_state_ls93(ls93_t* val, FILEIO* state_fio)
621+{
622+ state_fio->StateValue(val->in_a);
623+ state_fio->StateValue(val->in_b);
624+ state_fio->StateValue(val->in_rc1);
625+ state_fio->StateValue(val->in_rc2);
626+ state_fio->StateValue(val->out_qa);
627+ state_fio->StateValue(val->out_qb);
628+ state_fio->StateValue(val->out_qc);
629+ state_fio->StateValue(val->tmp_a);
630+ state_fio->StateValue(val->tmp_b);
631+ state_fio->StateValue(val->counter_a);
632+ state_fio->StateValue(val->counter_b);
633+}
642634
643-#define STATE_VERSION 4
635+void process_state_tc4024bp(tc4024bp_t* val, FILEIO* state_fio)
636+{
637+ state_fio->StateValue(val->in_ck);
638+ state_fio->StateValue(val->in_clr);
639+ state_fio->StateValue(val->out_q5);
640+ state_fio->StateValue(val->out_q6);
641+ state_fio->StateValue(val->tmp_ck);
642+ state_fio->StateValue(val->counter);
643+}
644644
645645 bool IO::process_state(FILEIO* state_fio, bool loading)
646646 {
@@ -654,23 +654,22 @@ bool IO::process_state(FILEIO* state_fio, bool loading)
654654 if(loading) {
655655 close_tape();
656656 }
657- //state_fio->StateBuffer(lcd, sizeof(lcd), 1);
658- for(int i = 0; i < 2; i++) {
659- state_fio->StateBuffer(&(lcd[i].ram), 0x400, 1);
660- state_fio->StateInt32(lcd[i].offset);
661- state_fio->StateInt32(lcd[i].cursor);
662- }
663- state_fio->StateInt32(lcd_status);
664- state_fio->StateInt32(lcd_addr);
665- state_fio->StateBool(lcd_text);
666- state_fio->StateBool(cmt_selected);
667- state_fio->StateUint8(cmt_mode);
668- state_fio->StateBool(cmt_play_ready);
669- state_fio->StateBool(cmt_play_signal);
670- state_fio->StateBool(cmt_rec_ready);
671- state_fio->StateBool(cmt_rec);
672- state_fio->StateBool(cmt_is_wav);
673- state_fio->StateBuffer(cmt_rec_file_path, sizeof(cmt_rec_file_path), 1);
657+ for(int i = 0; i < array_length(lcd); i++) {
658+ state_fio->StateArray(lcd[i].ram, sizeof(lcd[i].ram), 1);
659+ state_fio->StateValue(lcd[i].offset);
660+ state_fio->StateValue(lcd[i].cursor);
661+ }
662+ state_fio->StateValue(lcd_status);
663+ state_fio->StateValue(lcd_addr);
664+ state_fio->StateValue(lcd_text);
665+ state_fio->StateValue(cmt_selected);
666+ state_fio->StateValue(cmt_mode);
667+ state_fio->StateValue(cmt_play_ready);
668+ state_fio->StateValue(cmt_play_signal);
669+ state_fio->StateValue(cmt_rec_ready);
670+ state_fio->StateValue(cmt_rec);
671+ state_fio->StateValue(cmt_is_wav);
672+ state_fio->StateArray(cmt_rec_file_path, sizeof(cmt_rec_file_path), 1);
674673 if(loading) {
675674 int length_tmp = state_fio->FgetInt32_LE();
676675 if(cmt_rec) {
@@ -701,27 +700,17 @@ bool IO::process_state(FILEIO* state_fio, bool loading)
701700 state_fio->FputInt32_LE(0);
702701 }
703702 }
704- state_fio->StateInt32(cmt_bufcnt);
705- state_fio->StateBuffer(cmt_buffer, cmt_bufcnt, 1);
706- state_fio->StateUint8(cmt_clock);
707-
708- //state_fio->StateBuffer(&b16_1, sizeof(b16_1), 1);
709- //state_fio->StateBuffer(&b16_2, sizeof(b16_2), 1);
710- //state_fio->StateBuffer(&g21_1, sizeof(g21_1), 1);
711- //state_fio->StateBuffer(&g21_2, sizeof(g21_2), 1);
712- PROCESS_STATE_74LS74(b16_1);
713- PROCESS_STATE_74LS74(b16_2);
714- PROCESS_STATE_74LS74(g21_1);
715- PROCESS_STATE_74LS74(g21_2);
716-
717- //state_fio->StateBuffer(&c15, sizeof(c15), 1);
718- PROCESS_STATE_74LS151(c15);
719-
720- //state_fio->StateBuffer(&c16, sizeof(c16), 1);
721- PROCESS_STATE_74LS93(c16);
722- //state_fio->StateBuffer(&f21, sizeof(f21), 1);
723- PROCESS_STATE_4024(f21);
724- state_fio->StateUint8(key_column);
703+ state_fio->StateValue(cmt_bufcnt);
704+ state_fio->StateArray(cmt_buffer, cmt_bufcnt, 1);
705+ state_fio->StateValue(cmt_clock);
706+ process_state_ls74(&b16_1, state_fio);
707+ process_state_ls74(&b16_2, state_fio);
708+ process_state_ls74(&g21_1, state_fio);
709+ process_state_ls74(&g21_2, state_fio);
710+ process_state_ls151(&c15, state_fio);
711+ process_state_ls93(&c16, state_fio);
712+ process_state_tc4024bp(&f21, state_fio);
713+ state_fio->StateValue(key_column);
725714 return true;
726715 }
727716
--- a/source/src/vm/hc20/memory.cpp
+++ b/source/src/vm/hc20/memory.cpp
@@ -821,33 +821,32 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
821821 state_fio->FputBool(wbank[0x8000 >> 13] == ext);
822822 state_fio->FputBool(rbank[0x8000 >> 13] == ext);
823823 }
824- state_fio->StateBuffer(rom, sizeof(rom), 1);
825- state_fio->StateBuffer(ram, sizeof(ram), 1);
826- state_fio->StateBuffer(ext, sizeof(ext), 1);
824+ state_fio->StateArray(rom, sizeof(rom), 1);
825+// state_fio->StateArray(ram, sizeof(ram), 1);
826+ state_fio->StateArray(ext, sizeof(ext), 1);
827827 if(!cmd_buf->process_state((void *)state_fio, loading)) {
828828 return false;
829829 }
830- state_fio->StateBool(sio_select);
831- state_fio->StateBool(special_cmd_masked);
832- state_fio->StateBuffer(slave_mem, sizeof(slave_mem), 1);
833- //state_fio->StateBuffer(sound, sizeof(sound), 1);
834- for(int i = 0; i < 256; i++) {
835- state_fio->StateDouble(sound[i].freq);
836- state_fio->StateInt32(sound[i].period);
837- state_fio->StateInt32(sound[i].remain);
838- }
839- state_fio->StateInt32(sound_ptr);
840- state_fio->StateInt32(sound_count);
841- state_fio->StateUint8(sound_reply);
842- state_fio->StateDouble(sound_freq);
843- state_fio->StateBuffer(key_stat, sizeof(key_stat), 1);
844- state_fio->StateBuffer(key_flag, sizeof(key_flag), 1);
845- state_fio->StateInt32(key_data);
846- state_fio->StateInt32(key_strobe);
847- state_fio->StateInt32(key_intmask);
848- state_fio->StateBool(cmt_play);
849- state_fio->StateBool(cmt_rec);
850- state_fio->StateBuffer(cmt_file_path, sizeof(cmt_file_path), 1);
830+ state_fio->StateValue(sio_select);
831+ state_fio->StateValue(special_cmd_masked);
832+ state_fio->StateArray(slave_mem, sizeof(slave_mem), 1);
833+ for(int i = 0; i < array_length(sound); i++) {
834+ state_fio->StateValue(sound[i].freq);
835+ state_fio->StateValue(sound[i].period);
836+ state_fio->StateValue(sound[i].remain);
837+ }
838+ state_fio->StateValue(sound_ptr);
839+ state_fio->StateValue(sound_count);
840+ state_fio->StateValue(sound_reply);
841+ state_fio->StateValue(sound_freq);
842+ state_fio->StateArray(key_stat, sizeof(key_stat), 1);
843+ state_fio->StateArray(key_flag, sizeof(key_flag), 1);
844+ state_fio->StateValue(key_data);
845+ state_fio->StateValue(key_strobe);
846+ state_fio->StateValue(key_intmask);
847+ state_fio->StateValue(cmt_play);
848+ state_fio->StateValue(cmt_rec);
849+ state_fio->StateArray(cmt_file_path, sizeof(cmt_file_path), 1);
851850 if(loading) {
852851 int length_tmp = state_fio->FgetInt32_LE();
853852 if(cmt_rec) {
@@ -878,19 +877,18 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
878877 state_fio->FputInt32_LE(0);
879878 }
880879 }
881- state_fio->StateInt32(cmt_count);
882- state_fio->StateBuffer(cmt_buffer, sizeof(cmt_buffer), 1);
883- //state_fio->StateBuffer(lcd, sizeof(lcd), 1);
884- for(int i = 0; i < (sizeof(lcd) / sizeof(lcd_t)); i++) {
885- state_fio->StateBuffer(lcd[i].buffer, 0x80, 1);
886- state_fio->StateInt32(lcd[i].bank);
887- state_fio->StateInt32(lcd[i].addr);
888- }
889- state_fio->StateUint8(lcd_select);
890- state_fio->StateUint8(lcd_data);
891- state_fio->StateInt32(lcd_clock);
892- state_fio->StateInt32(int_status);
893- state_fio->StateInt32(int_mask);
880+ state_fio->StateValue(cmt_count);
881+ state_fio->StateArray(cmt_buffer, sizeof(cmt_buffer), 1);
882+ for(int i = 0; i < array_length(lcd); i++) {
883+ state_fio->StateArray(lcd[i].buffer, sizeof(lcd[i].buffer), 1);
884+ state_fio->StateValue(lcd[i].bank);
885+ state_fio->StateValue(lcd[i].addr);
886+ }
887+ state_fio->StateValue(lcd_select);
888+ state_fio->StateValue(lcd_data);
889+ state_fio->StateValue(lcd_clock);
890+ state_fio->StateValue(int_status);
891+ state_fio->StateValue(int_mask);
894892
895893 // post process
896894 if(loading) {
--- a/source/src/vm/jr800/jr800.cpp
+++ b/source/src/vm/jr800/jr800.cpp
@@ -318,6 +318,6 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
318318 return false;
319319 }
320320 }
321- state_fio->StateBuffer(ram, sizeof(ram), 1);
321+ state_fio->StateArray(ram, sizeof(ram), 1);
322322 return true;
323323 }
--- a/source/src/vm/jx/i286.cpp
+++ b/source/src/vm/jx/i286.cpp
@@ -419,162 +419,58 @@ int I286::get_shutdown_flag()
419419
420420 #define STATE_VERSION 5
421421
422-void I286::process_state_cpustate(FILEIO* state_fio, bool loading)
423-{
424-#if defined(HAS_I86) || defined(HAS_I88) || defined(HAS_I186) || defined(HAS_V30)
425- struct i8086_state *cpustate = (struct i8086_state *)opaque;
426-
427- state_fio->StateBuffer(&(cpustate->regs.b[0]), 16, 1);
428- state_fio->StateUint32(cpustate->pc);
429- state_fio->StateUint32(cpustate->prevpc);
430- for(int i = 0; i < 4; i++) {
431- state_fio->StateUint32(cpustate->base[i]);
432- }
433- for(int i = 0; i < 4; i++) {
434- state_fio->StateUint16(cpustate->sregs[i]);
435- }
436- state_fio->StateUint16(cpustate->flags);
437- state_fio->StateInt32(cpustate->AuxVal);
438- state_fio->StateInt32(cpustate->OverVal);
439- state_fio->StateInt32(cpustate->SignVal);
440- state_fio->StateInt32(cpustate->ZeroVal);
441- state_fio->StateInt32(cpustate->CarryVal);
442- state_fio->StateInt32(cpustate->DirVal);
443- state_fio->StateUint8(cpustate->ParityVal);
444- state_fio->StateUint8(cpustate->TF);
445- state_fio->StateUint8(cpustate->IF);
446- state_fio->StateUint8(cpustate->MF);
447-
448- state_fio->StateUint8(cpustate->int_vector);
449- state_fio->StateInt8(cpustate->nmi_state);
450- state_fio->StateInt8(cpustate->irq_state);
451- state_fio->StateInt8(cpustate->test_state);
452- state_fio->StateUint8(cpustate->rep_in_progress);
453- state_fio->StateInt32(cpustate->extra_cycles);
454-
455- state_fio->StateInt32(cpustate->halted);
456- state_fio->StateInt32(cpustate->busreq);
457-
458- state_fio->StateUint16(cpustate->ip);
459- state_fio->StateUint32(cpustate->sp);
460-
461- #ifdef USE_DEBUGGER
462- state_fio->StateUint64(cpustate->total_icount);
463- #endif
464- state_fio->StateInt32(cpustate->icount);
465-
466- state_fio->StateUint8(cpustate->seg_prefix);
467- state_fio->StateUint8(cpustate->prefix_seg);
468- state_fio->StateUint32(cpustate->ea);
469- state_fio->StateUint16(cpustate->eo);
470- state_fio->StateUint8(cpustate->ea_seg);
471-
472-#elif defined(HAS_I286)
473-
474- struct i80286_state *cpustate = (struct i80286_state *)opaque;
475-
476- state_fio->StateBuffer(&(cpustate->regs.b[0]), 16, 1);
477- state_fio->StateUint32(cpustate->amask);
478- state_fio->StateUint32(cpustate->pc);
479- state_fio->StateUint32(cpustate->prevpc);
480- state_fio->StateUint16(cpustate->flags);
481- state_fio->StateUint16(cpustate->msw);
482- for(int i = 0; i < 4; i++) {
483- state_fio->StateUint32(cpustate->base[i]);
484- }
485- for(int i = 0; i < 4; i++) {
486- state_fio->StateUint16(cpustate->sregs[i]);
487- }
488- for(int i = 0; i < 4; i++) {
489- state_fio->StateUint16(cpustate->limit[i]);
490- }
491- state_fio->StateBuffer(cpustate->rights, 4, 1);
492- for(int i = 0; i < 4; i++) {
493- state_fio->StateBool(cpustate->valid[i]);
494- }
495- state_fio->StateUint32(cpustate->gdtr.base);
496- state_fio->StateUint16(cpustate->gdtr.limit);
497-
498- state_fio->StateUint32(cpustate->idtr.base);
499- state_fio->StateUint16(cpustate->idtr.limit);
500-
501- state_fio->StateUint16(cpustate->ldtr.sel);
502- state_fio->StateUint32(cpustate->ldtr.base);
503- state_fio->StateUint16(cpustate->ldtr.limit);
504- state_fio->StateUint8(cpustate->ldtr.rights);
505-
506- state_fio->StateUint16(cpustate->tr.sel);
507- state_fio->StateUint32(cpustate->tr.base);
508- state_fio->StateUint16(cpustate->tr.limit);
509- state_fio->StateUint8(cpustate->tr.rights);
510-
511-
512- state_fio->StateInt32(cpustate->AuxVal);
513- state_fio->StateInt32(cpustate->OverVal);
514- state_fio->StateInt32(cpustate->SignVal);
515- state_fio->StateInt32(cpustate->ZeroVal);
516- state_fio->StateInt32(cpustate->CarryVal);
517- state_fio->StateInt32(cpustate->DirVal);
518- state_fio->StateUint8(cpustate->ParityVal);
519- state_fio->StateUint8(cpustate->TF);
520- state_fio->StateUint8(cpustate->IF);
521- state_fio->StateUint8(cpustate->MF);
522-
523- state_fio->StateInt8(cpustate->nmi_state);
524- state_fio->StateInt8(cpustate->irq_state);
525- state_fio->StateInt8(cpustate->test_state);
526- state_fio->StateUint8(cpustate->rep_in_progress);
527- state_fio->StateInt32(cpustate->extra_cycles);
528-
529- state_fio->StateInt32(cpustate->halted);
530- state_fio->StateInt32(cpustate->busreq);
531- state_fio->StateInt32(cpustate->trap_level);
532- state_fio->StateInt32(cpustate->shutdown);
533-
534- #ifdef USE_DEBUGGER
535- state_fio->StateUint64(cpustate->total_icount);
536- #endif
537- state_fio->StateInt32(cpustate->icount);
538-
539- state_fio->StateUint8(cpustate->seg_prefix);
540- state_fio->StateUint8(cpustate->prefix_seg);
541- state_fio->StateUint32(cpustate->ea);
542- state_fio->StateUint16(cpustate->eo);
543- state_fio->StateUint8(cpustate->ea_seg);
544-#endif
545-}
546-
547422 bool I286::process_state(FILEIO* state_fio, bool loading)
548423 {
424+ cpu_state *cpustate = (cpu_state *)opaque;
425+
549426 if(!state_fio->StateCheckUint32(STATE_VERSION)) {
550427 return false;
551428 }
552429 if(!state_fio->StateCheckInt32(this_device_id)) {
553430 return false;
554431 }
555- //state_fio->StateBuffer(opaque, sizeof(cpu_state), 1);
556- process_state_cpustate(state_fio, loading);
557-
558- // post process
559- if(loading) {
560- cpu_state *cpustate = (cpu_state *)opaque;
561- cpustate->pic = d_pic;
562- cpustate->program = d_mem;
563- cpustate->io = d_io;
564-#ifdef I86_PSEUDO_BIOS
565- cpustate->bios = d_bios;
566-#endif
567-#ifdef SINGLE_MODE_DMA
568- cpustate->dma = d_dma;
432+ state_fio->StateArray(cpustate->regs.w, sizeof(cpustate->regs.w), 1);
433+ state_fio->StateValue(cpustate->pc);
434+ state_fio->StateValue(cpustate->prevpc);
435+ state_fio->StateArray(cpustate->base, sizeof(cpustate->base), 1);
436+ state_fio->StateArray(cpustate->sregs, sizeof(cpustate->sregs), 1);
437+ state_fio->StateValue(cpustate->flags);
438+ state_fio->StateValue(cpustate->AuxVal);
439+ state_fio->StateValue(cpustate->OverVal);
440+ state_fio->StateValue(cpustate->SignVal);
441+ state_fio->StateValue(cpustate->ZeroVal);
442+ state_fio->StateValue(cpustate->CarryVal);
443+ state_fio->StateValue(cpustate->DirVal);
444+ state_fio->StateValue(cpustate->ParityVal);
445+ state_fio->StateValue(cpustate->TF);
446+ state_fio->StateValue(cpustate->IF);
447+ state_fio->StateValue(cpustate->MF);
448+ state_fio->StateValue(cpustate->int_vector);
449+ state_fio->StateValue(cpustate->nmi_state);
450+ state_fio->StateValue(cpustate->irq_state);
451+ state_fio->StateValue(cpustate->test_state);
452+ state_fio->StateValue(cpustate->rep_in_progress);
453+ state_fio->StateValue(cpustate->extra_cycles);
454+ state_fio->StateValue(cpustate->halted);
455+ state_fio->StateValue(cpustate->busreq);
456+ state_fio->StateValue(cpustate->ip);
457+ state_fio->StateValue(cpustate->sp);
458+#ifdef USE_DEBUGGER
459+ state_fio->StateValue(cpustate->total_icount);
569460 #endif
461+ state_fio->StateValue(cpustate->icount);
462+ state_fio->StateValue(cpustate->seg_prefix);
463+ state_fio->StateValue(cpustate->prefix_seg);
464+ state_fio->StateValue(cpustate->ea);
465+ state_fio->StateValue(cpustate->eo);
466+ state_fio->StateValue(cpustate->ea_seg);
467+
570468 #ifdef USE_DEBUGGER
571- cpustate->emu = emu;
572- cpustate->debugger = d_debugger;
573- cpustate->program_stored = d_mem;
574- cpustate->io_stored = d_io;
469+ // post process
470+ if(loading) {
575471 cpustate->prev_total_icount = cpustate->total_icount;
576-#endif
577472 }
473+#endif
578474 return true;
579475 }
580476
--- a/source/src/vm/jx/i286.h
+++ b/source/src/vm/jx/i286.h
@@ -105,7 +105,6 @@ public:
105105 void get_debug_regs_info(_TCHAR *buffer, size_t buffer_len);
106106 int debug_dasm(uint32_t pc, _TCHAR *buffer, size_t buffer_len);
107107 #endif
108- void process_state_cpustate(FILEIO* state_fio, bool loading);
109108 bool process_state(FILEIO* state_fio, bool loading);
110109
111110 // unique function
--- a/source/src/vm/jx/jx.cpp
+++ b/source/src/vm/jx/jx.cpp
@@ -386,7 +386,7 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
386386 return false;
387387 }
388388 }
389- state_fio->StateBuffer(ram, sizeof(ram), 1);
389+ state_fio->StateArray(ram, sizeof(ram), 1);
390390 return true;
391391 }
392392
--- a/source/src/vm/m5/m5.cpp
+++ b/source/src/vm/m5/m5.cpp
@@ -363,8 +363,8 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
363363 }
364364 }
365365 // Machine specified.
366- state_fio->StateBuffer(ram, sizeof(ram), 1);
367- state_fio->StateBuffer(ext, sizeof(ext), 1);
368- state_fio->StateBool(inserted);
366+ state_fio->StateArray(ram, sizeof(ram), 1);
367+ state_fio->StateArray(ext, sizeof(ext), 1);
368+ state_fio->StateValue(inserted);
369369 return true;
370370 }
--- a/source/src/vm/mz2500/crtc.cpp
+++ b/source/src/vm/mz2500/crtc.cpp
@@ -1702,245 +1702,61 @@ bool CRTC::process_state(FILEIO* state_fio, bool loading)
17021702 if(!state_fio->StateCheckInt32(this_device_id)) {
17031703 return false;
17041704 }
1705- state_fio->StateBool(scan_line);
1706- state_fio->StateBool(scan_tmp);
1707- state_fio->StateBool(monitor_200line);
1708- state_fio->StateBool(monitor_digital);
1709- state_fio->StateBool(monitor_tmp);
1710- state_fio->StateUint8(textreg_num);
1711- state_fio->StateBuffer(textreg, sizeof(textreg), 1);
1712- state_fio->StateUint8(cgreg_num);
1713- state_fio->StateBuffer(cgreg, sizeof(cgreg), 1);
1714- state_fio->StateUint8(scrn_size);
1715- state_fio->StateUint8(cg_mask);
1716- state_fio->StateUint8(cg_mask256);
1717- state_fio->StateBool(cg_mask256_init);
1718- state_fio->StateBool(font_size);
1719- state_fio->StateBool(column_size);
1720- state_fio->StateBuffer(latch, sizeof(latch), 1);
1721- state_fio->StateUint16(GDEVS);
1722- state_fio->StateUint16(GDEVE);
1723- state_fio->StateUint8(GDEHS);
1724- state_fio->StateUint8(GDEHE);
1725- state_fio->StateInt32(GDEHSC);
1726- state_fio->StateInt32(GDEHEC);
1727- state_fio->StateBool(hblank);
1728- state_fio->StateBool(vblank);
1729- state_fio->StateBool(blink);
1730- state_fio->StateUint8(clear_flag);
1731- state_fio->StateBuffer(palette_reg, sizeof(palette_reg), 1);
1732- state_fio->StateBool(pal_select);
1733- state_fio->StateBool(screen_mask);
1734- state_fio->StateBuffer(priority16, sizeof(priority16), 1);
1735- //state_fio->StateBuffer(palette16, sizeof(palette16), 1);
1736- for(int i = 0; i < (sizeof(palette16) / sizeof(scrntype_t)); i++) {
1737- if(loading) {
1738- uint8_t r, g, b;
1739- r = state_fio->FgetUint8();
1740- g = state_fio->FgetUint8();
1741- b = state_fio->FgetUint8();
1742- palette16[i] = RGB_COLOR(r, g, b);
1743- } else {
1744- uint8_t r, g, b;
1745- r = R_OF_COLOR(palette16[i]);
1746- g = G_OF_COLOR(palette16[i]);
1747- b = B_OF_COLOR(palette16[i]);
1748- state_fio->FputUint8(r);
1749- state_fio->FputUint8(g);
1750- state_fio->FputUint8(b);
1751- }
1752- }
1753- //state_fio->StateBuffer(palette4096, sizeof(palette4096), 1);
1754- for(int i = 0; i < (sizeof(palette4096) / sizeof(scrntype_t)); i++) {
1755- if(loading) {
1756- uint8_t r, g, b;
1757- r = state_fio->FgetUint8();
1758- g = state_fio->FgetUint8();
1759- b = state_fio->FgetUint8();
1760- palette4096[i] = RGB_COLOR(r, g, b);
1761- } else {
1762- uint8_t r, g, b;
1763- r = R_OF_COLOR(palette4096[i]);
1764- g = G_OF_COLOR(palette4096[i]);
1765- b = B_OF_COLOR(palette4096[i]);
1766- state_fio->FputUint8(r);
1767- state_fio->FputUint8(g);
1768- state_fio->FputUint8(b);
1769- }
1770- }
1771- state_fio->StateBuffer(palette4096r, sizeof(palette4096r), 1);
1772- state_fio->StateBuffer(palette4096g, sizeof(palette4096g), 1);
1773- state_fio->StateBuffer(palette4096b, sizeof(palette4096b), 1);
1774- //state_fio->StateBuffer(palette16txt, sizeof(palette16txt), 1);
1775- for(int i = 0; i < (sizeof(palette16txt) / sizeof(scrntype_t)); i++) {
1776- if(loading) {
1777- uint8_t r, g, b;
1778- r = state_fio->FgetUint8();
1779- g = state_fio->FgetUint8();
1780- b = state_fio->FgetUint8();
1781- palette16txt[i] = RGB_COLOR(r, g, b);
1782- } else {
1783- uint8_t r, g, b;
1784- r = R_OF_COLOR(palette16txt[i]);
1785- g = G_OF_COLOR(palette16txt[i]);
1786- b = B_OF_COLOR(palette16txt[i]);
1787- state_fio->FputUint8(r);
1788- state_fio->FputUint8(g);
1789- state_fio->FputUint8(b);
1790- }
1791- }
1792- //state_fio->StateBuffer(palette4096txt, sizeof(palette4096txt), 1);
1793- for(int i = 0; i < (sizeof(palette4096txt) / sizeof(scrntype_t)); i++) {
1794- if(loading) {
1795- uint8_t r, g, b;
1796- r = state_fio->FgetUint8();
1797- g = state_fio->FgetUint8();
1798- b = state_fio->FgetUint8();
1799- palette4096txt[i] = RGB_COLOR(r, g, b);
1800- } else {
1801- uint8_t r, g, b;
1802- r = R_OF_COLOR(palette4096txt[i]);
1803- g = G_OF_COLOR(palette4096txt[i]);
1804- b = B_OF_COLOR(palette4096txt[i]);
1805- state_fio->FputUint8(r);
1806- state_fio->FputUint8(g);
1807- state_fio->FputUint8(b);
1808- }
1809- }
1810- //state_fio->StateBuffer(palette16pri, sizeof(palette16pri), 1);
1811- for(int i = 0; i < 16; i++) {
1812- for(int j = 0; j < 9; j++) {
1813- if(loading) {
1814- uint8_t r, g, b;
1815- r = state_fio->FgetUint8();
1816- g = state_fio->FgetUint8();
1817- b = state_fio->FgetUint8();
1818- palette16pri[i][j] = RGB_COLOR(r, g, b);
1819- } else {
1820- uint8_t r, g, b;
1821- r = R_OF_COLOR(palette16pri[i][j]);
1822- g = G_OF_COLOR(palette16pri[i][j]);
1823- b = B_OF_COLOR(palette16pri[i][j]);
1824- state_fio->FputUint8(r);
1825- state_fio->FputUint8(g);
1826- state_fio->FputUint8(b);
1827- }
1828- }
1829- }
1830- //state_fio->StateBuffer(palette4096pri, sizeof(palette4096pri), 1);
1831- for(int i = 0; i < 16; i++) {
1832- for(int j = 0; j < 9; j++) {
1833- if(loading) {
1834- uint8_t r, g, b;
1835- r = state_fio->FgetUint8();
1836- g = state_fio->FgetUint8();
1837- b = state_fio->FgetUint8();
1838- palette4096pri[i][j] = RGB_COLOR(r, g, b);
1839- } else {
1840- uint8_t r, g, b;
1841- r = R_OF_COLOR(palette4096pri[i][j]);
1842- g = G_OF_COLOR(palette4096pri[i][j]);
1843- b = B_OF_COLOR(palette4096pri[i][j]);
1844- state_fio->FputUint8(r);
1845- state_fio->FputUint8(g);
1846- state_fio->FputUint8(b);
1847- }
1848- }
1849- }
1850-
1851- state_fio->StateUint8(prev16);
1852- state_fio->StateBool(update16);
1853- //state_fio->StateBuffer(priority256, sizeof(priority256), 1);
1854- for(int i = 0; i < 256; i++) {
1855- for(int j = 0; j < (16 + 64); j++) {
1856- state_fio->StateUint16(priority256[i][j]);
1857- }
1858- }
1859- //state_fio->StateBuffer(palette256, sizeof(palette256), 1);
1860- for(int i = 0; i < (sizeof(palette256) / sizeof(scrntype_t)); i++) {
1861- if(loading) {
1862- uint8_t r, g, b;
1863- r = state_fio->FgetUint8();
1864- g = state_fio->FgetUint8();
1865- b = state_fio->FgetUint8();
1866- palette256[i] = RGB_COLOR(r, g, b);
1867- } else {
1868- uint8_t r, g, b;
1869- r = R_OF_COLOR(palette256[i]);
1870- g = G_OF_COLOR(palette256[i]);
1871- b = B_OF_COLOR(palette256[i]);
1872- state_fio->FputUint8(r);
1873- state_fio->FputUint8(g);
1874- state_fio->FputUint8(b);
1875- }
1876- }
1877- //state_fio->StateBuffer(palette256txt, sizeof(palette256txt), 1);
1878- for(int i = 0; i < (sizeof(palette256txt) / sizeof(scrntype_t)); i++) {
1879- if(loading) {
1880- uint8_t r, g, b;
1881- r = state_fio->FgetUint8();
1882- g = state_fio->FgetUint8();
1883- b = state_fio->FgetUint8();
1884- palette256txt[i] = RGB_COLOR(r, g, b);
1885- } else {
1886- uint8_t r, g, b;
1887- r = R_OF_COLOR(palette256txt[i]);
1888- g = G_OF_COLOR(palette256txt[i]);
1889- b = B_OF_COLOR(palette256txt[i]);
1890- state_fio->FputUint8(r);
1891- state_fio->FputUint8(g);
1892- state_fio->FputUint8(b);
1893- }
1894- }
1895- //state_fio->StateBuffer(palette256pri, sizeof(palette256pri), 1);
1896- for(int i = 0; i < 256; i++) {
1897- for(int j = 0; j < (16 + 64); j++) {
1898- if(loading) {
1899- uint8_t r, g, b;
1900- r = state_fio->FgetUint8();
1901- g = state_fio->FgetUint8();
1902- b = state_fio->FgetUint8();
1903- palette256pri[i][j] = RGB_COLOR(r, g, b);
1904- } else {
1905- uint8_t r, g, b;
1906- r = R_OF_COLOR(palette256pri[i][j]);
1907- g = G_OF_COLOR(palette256pri[i][j]);
1908- b = B_OF_COLOR(palette256pri[i][j]);
1909- state_fio->FputUint8(r);
1910- state_fio->FputUint8(g);
1911- state_fio->FputUint8(b);
1912- }
1913- }
1914- }
1915- //state_fio->StateUint32((uint32_t)prev256);
1916- if(loading) {
1917- uint8_t r, g, b;
1918- r = state_fio->FgetUint8();
1919- g = state_fio->FgetUint8();
1920- b = state_fio->FgetUint8();
1921- prev256 = RGB_COLOR(r, g, b);
1922- } else {
1923- uint8_t r, g, b;
1924- r = R_OF_COLOR(prev256);
1925- g = G_OF_COLOR(prev256);
1926- b = B_OF_COLOR(prev256);
1927- state_fio->FputUint8(r);
1928- state_fio->FputUint8(g);
1929- state_fio->FputUint8(b);
1930- }
1931- state_fio->StateBool(update256);
1932- //state_fio->StateBuffer(map_addr, sizeof(map_addr), 1);
1933- for(int i = 0; i < 400; i++) {
1934- for(int j = 0; j < 80; j++) {
1935- state_fio->StateUint16(map_addr[i][j]);
1936- }
1937- }
1938- state_fio->StateBuffer(map_hdsc, sizeof(map_hdsc), 1);
1939- state_fio->StateBuffer(text_matrix, sizeof(text_matrix), 1);
1940- state_fio->StateBuffer(text_matrixw, sizeof(text_matrixw), 1);
1941- state_fio->StateUint8(trans_color);
1942- state_fio->StateBool(map_init);
1943- state_fio->StateBool(trans_init);
1705+ state_fio->StateValue(scan_line);
1706+ state_fio->StateValue(scan_tmp);
1707+ state_fio->StateValue(monitor_200line);
1708+ state_fio->StateValue(monitor_digital);
1709+ state_fio->StateValue(monitor_tmp);
1710+ state_fio->StateValue(textreg_num);
1711+ state_fio->StateArray(textreg, sizeof(textreg), 1);
1712+ state_fio->StateValue(cgreg_num);
1713+ state_fio->StateArray(cgreg, sizeof(cgreg), 1);
1714+ state_fio->StateValue(scrn_size);
1715+ state_fio->StateValue(cg_mask);
1716+ state_fio->StateValue(cg_mask256);
1717+ state_fio->StateValue(cg_mask256_init);
1718+ state_fio->StateValue(font_size);
1719+ state_fio->StateValue(column_size);
1720+ state_fio->StateArray(latch, sizeof(latch), 1);
1721+ state_fio->StateValue(GDEVS);
1722+ state_fio->StateValue(GDEVE);
1723+ state_fio->StateValue(GDEHS);
1724+ state_fio->StateValue(GDEHE);
1725+ state_fio->StateValue(GDEHSC);
1726+ state_fio->StateValue(GDEHEC);
1727+ state_fio->StateValue(hblank);
1728+ state_fio->StateValue(vblank);
1729+ state_fio->StateValue(blink);
1730+ state_fio->StateValue(clear_flag);
1731+ state_fio->StateArray(palette_reg, sizeof(palette_reg), 1);
1732+ state_fio->StateValue(pal_select);
1733+ state_fio->StateValue(screen_mask);
1734+ state_fio->StateArray(&priority16[0][0], sizeof(priority16), 1);
1735+ state_fio->StateArrayScrnType_t(palette16, sizeof(palette16), 1);
1736+ state_fio->StateArrayScrnType_t(palette4096, sizeof(palette4096), 1);
1737+ state_fio->StateArray(palette4096r, sizeof(palette4096r), 1);
1738+ state_fio->StateArray(palette4096g, sizeof(palette4096g), 1);
1739+ state_fio->StateArray(palette4096b, sizeof(palette4096b), 1);
1740+ state_fio->StateArrayScrnType_t(palette16txt, sizeof(palette16txt), 1);
1741+ state_fio->StateArrayScrnType_t(palette4096txt, sizeof(palette4096txt), 1);
1742+ state_fio->StateArrayScrnType_t(&palette16pri[0][0], sizeof(palette16pri), 1);
1743+ state_fio->StateArrayScrnType_t(&palette4096pri[0][0], sizeof(palette4096pri), 1);
1744+ state_fio->StateValue(prev16);
1745+ state_fio->StateValue(update16);
1746+ state_fio->StateArray(&priority256[0][0], sizeof(priority256), 1);
1747+ state_fio->StateArrayScrnType_t(palette256, sizeof(palette256), 1);
1748+ state_fio->StateArrayScrnType_t(palette256txt, sizeof(palette256txt), 1);
1749+ state_fio->StateArrayScrnType_t(&palette256pri[0][0], sizeof(palette256pri), 1);
1750+// state_fio->StateValue((uint32_t)prev256);
1751+ state_fio->StateValueScrnType_t(prev256);
1752+ state_fio->StateValue(update256);
1753+ state_fio->StateArray(&map_addr[0][0], sizeof(map_addr), 1);
1754+ state_fio->StateArray(&map_hdsc[0][0], sizeof(map_hdsc), 1);
1755+ state_fio->StateArray(&text_matrix[0][0][0], sizeof(text_matrix), 1);
1756+ state_fio->StateArray(&text_matrixw[0][0][0], sizeof(text_matrixw), 1);
1757+ state_fio->StateValue(trans_color);
1758+ state_fio->StateValue(map_init);
1759+ state_fio->StateValue(trans_init);
19441760 return true;
19451761 }
19461762
--- a/source/src/vm/mz2500/interrupt.cpp
+++ b/source/src/vm/mz2500/interrupt.cpp
@@ -181,18 +181,17 @@ bool INTERRUPT::process_state(FILEIO* state_fio, bool loading)
181181 if(!state_fio->StateCheckInt32(this_device_id)) {
182182 return false;
183183 }
184- state_fio->StateUint8(select);
185- //state_fio->StateBuffer(irq, sizeof(irq), 1);
186- for(int i = 0; i < 4; i++) {
187- state_fio->StateUint8(irq[i].vector);
188- state_fio->StateBool(irq[i].enb_intr);
189- state_fio->StateBool(irq[i].req_intr);
190- state_fio->StateBool(irq[i].in_service);
184+ state_fio->StateValue(select);
185+ for(int i = 0; i < array_length(irq); i++) {
186+ state_fio->StateValue(irq[i].vector);
187+ state_fio->StateValue(irq[i].enb_intr);
188+ state_fio->StateValue(irq[i].req_intr);
189+ state_fio->StateValue(irq[i].in_service);
191190 }
192- state_fio->StateInt32(req_intr_ch);
193- state_fio->StateBool(iei);
194- state_fio->StateBool(oei);
195- state_fio->StateUint32(intr_bit);
191+ state_fio->StateValue(req_intr_ch);
192+ state_fio->StateValue(iei);
193+ state_fio->StateValue(oei);
194+ state_fio->StateValue(intr_bit);
196195 return true;
197196 }
198197
--- a/source/src/vm/mz2500/mz2500.cpp
+++ b/source/src/vm/mz2500/mz2500.cpp
@@ -635,6 +635,6 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
635635 }
636636 }
637637 // Machine specified.
638- state_fio->StateInt32(monitor_type);
638+ state_fio->StateValue(monitor_type);
639639 return true;
640640 }
--- a/source/src/vm/mz2800/crtc.cpp
+++ b/source/src/vm/mz2800/crtc.cpp
@@ -1327,161 +1327,50 @@ bool CRTC::process_state(FILEIO* state_fio, bool loading)
13271327 if(!state_fio->StateCheckInt32(this_device_id)) {
13281328 return false;
13291329 }
1330- state_fio->StateUint8(textreg_num);
1331- state_fio->StateBuffer(textreg, sizeof(textreg), 1);
1332- state_fio->StateBuffer(rmwreg_num, sizeof(rmwreg_num), 1);
1333- state_fio->StateBuffer(rmwreg, sizeof(rmwreg), 1);
1334- state_fio->StateUint8(cgreg_num);
1335- state_fio->StateBuffer(cgreg, sizeof(cgreg), 1);
1336- state_fio->StateUint8(scrn_size);
1337- state_fio->StateUint8(cg_mask);
1338- state_fio->StateBool(font_size);
1339- state_fio->StateBool(column_size);
1340- state_fio->StateBuffer(latch, sizeof(latch), 1);
1341- state_fio->StateUint16(GDEVS);
1342- state_fio->StateUint16(GDEVE);
1343- state_fio->StateUint8(GDEHS);
1344- state_fio->StateUint8(GDEHE);
1345- state_fio->StateInt32(GDEHSC);
1346- state_fio->StateInt32(GDEHEC);
1347- state_fio->StateBool(blank);
1348- state_fio->StateBool(hblank);
1349- state_fio->StateBool(vblank);
1350- state_fio->StateBool(blink);
1351- state_fio->StateUint8(clear_flag);
1352- state_fio->StateBuffer(palette_reg, sizeof(palette_reg), 1);
1353- state_fio->StateBool(pal_select);
1354- state_fio->StateBool(screen_mask);
1355- state_fio->StateBuffer(priority16, sizeof(priority16), 1);
1356- //state_fio->StateBuffer(palette16, sizeof(palette16), 1);
1357- for(int i = 0; i < (sizeof(palette16) / sizeof(scrntype_t)); i++) {
1358- if(loading) {
1359- uint8_t r, g, b;
1360- r = state_fio->FgetUint8();
1361- g = state_fio->FgetUint8();
1362- b = state_fio->FgetUint8();
1363- palette16[i] = RGB_COLOR(r, g, b);
1364- } else {
1365- uint8_t r, g, b;
1366- r = R_OF_COLOR(palette16[i]);
1367- g = G_OF_COLOR(palette16[i]);
1368- b = B_OF_COLOR(palette16[i]);
1369- state_fio->FputUint8(r);
1370- state_fio->FputUint8(g);
1371- state_fio->FputUint8(b);
1372- }
1373- }
1374- //state_fio->StateBuffer(palette4096, sizeof(palette4096), 1);
1375- for(int i = 0; i < (sizeof(palette4096) / sizeof(scrntype_t)); i++) {
1376- if(loading) {
1377- uint8_t r, g, b;
1378- r = state_fio->FgetUint8();
1379- g = state_fio->FgetUint8();
1380- b = state_fio->FgetUint8();
1381- palette4096[i] = RGB_COLOR(r, g, b);
1382- } else {
1383- uint8_t r, g, b;
1384- r = R_OF_COLOR(palette4096[i]);
1385- g = G_OF_COLOR(palette4096[i]);
1386- b = B_OF_COLOR(palette4096[i]);
1387- state_fio->FputUint8(r);
1388- state_fio->FputUint8(g);
1389- state_fio->FputUint8(b);
1390- }
1391- }
1392- state_fio->StateBuffer(palette4096r, sizeof(palette4096r), 1);
1393- state_fio->StateBuffer(palette4096g, sizeof(palette4096g), 1);
1394- state_fio->StateBuffer(palette4096b, sizeof(palette4096b), 1);
1395- //state_fio->StateBuffer(palette16txt, sizeof(palette16txt), 1);
1396- for(int i = 0; i < (sizeof(palette16txt) / sizeof(scrntype_t)); i++) {
1397- if(loading) {
1398- uint8_t r, g, b;
1399- r = state_fio->FgetUint8();
1400- g = state_fio->FgetUint8();
1401- b = state_fio->FgetUint8();
1402- palette16txt[i] = RGB_COLOR(r, g, b);
1403- } else {
1404- uint8_t r, g, b;
1405- r = R_OF_COLOR(palette16txt[i]);
1406- g = G_OF_COLOR(palette16txt[i]);
1407- b = B_OF_COLOR(palette16txt[i]);
1408- state_fio->FputUint8(r);
1409- state_fio->FputUint8(g);
1410- state_fio->FputUint8(b);
1411- }
1412- }
1413- //state_fio->StateBuffer(palette4096txt, sizeof(palette4096txt), 1);
1414- for(int i = 0; i < (sizeof(palette4096txt) / sizeof(scrntype_t)); i++) {
1415- if(loading) {
1416- uint8_t r, g, b;
1417- r = state_fio->FgetUint8();
1418- g = state_fio->FgetUint8();
1419- b = state_fio->FgetUint8();
1420- palette4096txt[i] = RGB_COLOR(r, g, b);
1421- } else {
1422- uint8_t r, g, b;
1423- r = R_OF_COLOR(palette4096txt[i]);
1424- g = G_OF_COLOR(palette4096txt[i]);
1425- b = B_OF_COLOR(palette4096txt[i]);
1426- state_fio->FputUint8(r);
1427- state_fio->FputUint8(g);
1428- state_fio->FputUint8(b);
1429- }
1430- }
1431- //state_fio->StateBuffer(palette16pri, sizeof(palette16pri), 1);
1432- for(int i = 0; i < 16; i++) {
1433- for(int j = 0; j < 9; j++) {
1434- if(loading) {
1435- uint8_t r, g, b;
1436- r = state_fio->FgetUint8();
1437- g = state_fio->FgetUint8();
1438- b = state_fio->FgetUint8();
1439- palette16pri[i][j] = RGB_COLOR(r, g, b);
1440- } else {
1441- uint8_t r, g, b;
1442- r = R_OF_COLOR(palette16pri[i][j]);
1443- g = G_OF_COLOR(palette16pri[i][j]);
1444- b = B_OF_COLOR(palette16pri[i][j]);
1445- state_fio->FputUint8(r);
1446- state_fio->FputUint8(g);
1447- state_fio->FputUint8(b);
1448- }
1449- }
1450- }
1451- //state_fio->StateBuffer(palette4096pri, sizeof(palette4096pri), 1);
1452- for(int i = 0; i < 16; i++) {
1453- for(int j = 0; j < 9; j++) {
1454- if(loading) {
1455- uint8_t r, g, b;
1456- r = state_fio->FgetUint8();
1457- g = state_fio->FgetUint8();
1458- b = state_fio->FgetUint8();
1459- palette4096pri[i][j] = RGB_COLOR(r, g, b);
1460- } else {
1461- uint8_t r, g, b;
1462- r = R_OF_COLOR(palette4096pri[i][j]);
1463- g = G_OF_COLOR(palette4096pri[i][j]);
1464- b = B_OF_COLOR(palette4096pri[i][j]);
1465- state_fio->FputUint8(r);
1466- state_fio->FputUint8(g);
1467- state_fio->FputUint8(b);
1468- }
1469- }
1470- }
1471- state_fio->StateUint8(prev16);
1472- state_fio->StateBool(update16);
1473- //state_fio->StateBuffer(map_addr, sizeof(map_addr), 1);
1474- for(int i = 0; i < 400; i++) {
1475- for(int j = 0; j < 80; j++) {
1476- state_fio->StateUint32(map_addr[i][j]);
1477- }
1478- }
1479- state_fio->StateBuffer(map_hdsc, sizeof(map_hdsc), 1);
1480- state_fio->StateBuffer(text_matrix, sizeof(text_matrix), 1);
1481- state_fio->StateBuffer(text_matrixw, sizeof(text_matrixw), 1);
1482- state_fio->StateUint8(trans_color);
1483- state_fio->StateBool(map_init);
1484- state_fio->StateBool(trans_init);
1330+ state_fio->StateValue(textreg_num);
1331+ state_fio->StateArray(textreg, sizeof(textreg), 1);
1332+ state_fio->StateArray(rmwreg_num, sizeof(rmwreg_num), 1);
1333+ state_fio->StateArray(&rmwreg[0][0], sizeof(rmwreg), 1);
1334+ state_fio->StateValue(cgreg_num);
1335+ state_fio->StateArray(cgreg, sizeof(cgreg), 1);
1336+ state_fio->StateValue(scrn_size);
1337+ state_fio->StateValue(cg_mask);
1338+ state_fio->StateValue(font_size);
1339+ state_fio->StateValue(column_size);
1340+ state_fio->StateArray(&latch[0][0], sizeof(latch), 1);
1341+ state_fio->StateValue(GDEVS);
1342+ state_fio->StateValue(GDEVE);
1343+ state_fio->StateValue(GDEHS);
1344+ state_fio->StateValue(GDEHE);
1345+ state_fio->StateValue(GDEHSC);
1346+ state_fio->StateValue(GDEHEC);
1347+ state_fio->StateValue(blank);
1348+ state_fio->StateValue(hblank);
1349+ state_fio->StateValue(vblank);
1350+ state_fio->StateValue(blink);
1351+ state_fio->StateValue(clear_flag);
1352+ state_fio->StateArray(palette_reg, sizeof(palette_reg), 1);
1353+ state_fio->StateValue(pal_select);
1354+ state_fio->StateValue(screen_mask);
1355+ state_fio->StateArray(&priority16[0][0], sizeof(priority16), 1);
1356+ state_fio->StateArrayScrnType_t(palette16, sizeof(palette16), 1);
1357+ state_fio->StateArrayScrnType_t(palette4096, sizeof(palette4096), 1);
1358+ state_fio->StateArray(palette4096r, sizeof(palette4096r), 1);
1359+ state_fio->StateArray(palette4096g, sizeof(palette4096g), 1);
1360+ state_fio->StateArray(palette4096b, sizeof(palette4096b), 1);
1361+ state_fio->StateArrayScrnType_t(palette16txt, sizeof(palette16txt), 1);
1362+ state_fio->StateArrayScrnType_t(palette4096txt, sizeof(palette4096txt), 1);
1363+ state_fio->StateArrayScrnType_t(&palette16pri[0][0], sizeof(palette16pri), 1);
1364+ state_fio->StateArrayScrnType_t(&palette4096pri[0][0], sizeof(palette4096pri), 1);
1365+ state_fio->StateValue(prev16);
1366+ state_fio->StateValue(update16);
1367+ state_fio->StateArray(&map_addr[0][0], sizeof(map_addr), 1);
1368+ state_fio->StateArray(&map_hdsc[0][0], sizeof(map_hdsc), 1);
1369+ state_fio->StateArray(&text_matrix[0][0][0], sizeof(text_matrix), 1);
1370+ state_fio->StateArray(&text_matrixw[0][0][0], sizeof(text_matrixw), 1);
1371+ state_fio->StateValue(trans_color);
1372+ state_fio->StateValue(map_init);
1373+ state_fio->StateValue(trans_init);
14851374 return true;
14861375 }
14871376
--- a/source/src/vm/mz3500/mz3500.cpp
+++ b/source/src/vm/mz3500/mz3500.cpp
@@ -497,6 +497,6 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
497497 }
498498 }
499499 // Machine specified.
500- state_fio->StateUint8(halt);
500+ state_fio->StateValue(halt);
501501 return true;
502502 }
--- a/source/src/vm/mz5500/display.cpp
+++ b/source/src/vm/mz5500/display.cpp
@@ -510,41 +510,18 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
510510 if(!state_fio->StateCheckInt32(this_device_id)) {
511511 return false;
512512 }
513- //state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
514- for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
515- if(loading) {
516- uint8_t r, g, b;
517- r = state_fio->FgetUint8();
518- g = state_fio->FgetUint8();
519- b = state_fio->FgetUint8();
520- palette_pc[i] = RGB_COLOR(r, g, b);
521- } else {
522- uint8_t r, g, b;
523- r = R_OF_COLOR(palette_pc[i]);
524- g = G_OF_COLOR(palette_pc[i]);
525- b = B_OF_COLOR(palette_pc[i]);
526- state_fio->FputUint8(r);
527- state_fio->FputUint8(g);
528- state_fio->FputUint8(b);
529- }
530- }
531- state_fio->StateBuffer(palette, sizeof(palette), 1);
532- state_fio->StateBuffer(back, sizeof(back), 1);
533- state_fio->StateBuffer(reverse, sizeof(reverse), 1);
534- state_fio->StateUint8(rno);
535- state_fio->StateBuffer(wregs, sizeof(wregs), 1);
536- //state_fio->StateBuffer(pri, sizeof(pri), 1);
537- for(int i = 0; i < (sizeof(pri) / sizeof(int)); i++) {
538- state_fio->StateInt32(pri[i]);
539- }
540- //state_fio->StateBuffer(vma, sizeof(vma), 1);
541- for(int i = 0; i < (sizeof(vma) / sizeof(int)); i++) {
542- state_fio->StateInt32(vma[i]);
543- }
544- state_fio->StateBuffer(vds, sizeof(vds), 1);
545- state_fio->StateUint8(mode_r);
546- state_fio->StateUint8(mode_c);
547- state_fio->StateUint8(mode_p);
513+ state_fio->StateArrayScrnType_t(palette_pc, sizeof(palette_pc), 1);
514+ state_fio->StateArray(palette, sizeof(palette), 1);
515+ state_fio->StateArray(back, sizeof(back), 1);
516+ state_fio->StateArray(reverse, sizeof(reverse), 1);
517+ state_fio->StateValue(rno);
518+ state_fio->StateArray(wregs, sizeof(wregs), 1);
519+ state_fio->StateArray(pri, sizeof(pri), 1);
520+ state_fio->StateArray(vma, sizeof(vma), 1);
521+ state_fio->StateArray(vds, sizeof(vds), 1);
522+ state_fio->StateValue(mode_r);
523+ state_fio->StateValue(mode_c);
524+ state_fio->StateValue(mode_p);
548525 return true;
549526 }
550527
--- a/source/src/vm/mz700/memory.cpp
+++ b/source/src/vm/mz700/memory.cpp
@@ -1085,93 +1085,55 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
10851085 return false;
10861086 }
10871087 #if defined(_MZ700)
1088- state_fio->StateBuffer(pcg + 0x400, 0x400, 1);
1089- state_fio->StateBuffer(pcg + 0xc00, 0x400, 1);
1088+ state_fio->StateArray(pcg + 0x400, 0x400, 1);
1089+ state_fio->StateArray(pcg + 0xc00, 0x400, 1);
10901090 #elif defined(_MZ1500)
1091- state_fio->StateBuffer(pcg, sizeof(pcg), 1);
1091+ state_fio->StateArray(pcg, sizeof(pcg), 1);
10921092 #endif
1093- state_fio->StateBuffer(ram, sizeof(ram), 1);
1094- state_fio->StateBuffer(vram, sizeof(vram), 1);
1095- state_fio->StateUint8(mem_bank);
1093+ state_fio->StateArray(ram, sizeof(ram), 1);
1094+ state_fio->StateArray(vram, sizeof(vram), 1);
1095+ state_fio->StateValue(mem_bank);
10961096 #if defined(_MZ700)
1097- state_fio->StateUint8(pcg_data);
1098- state_fio->StateUint8(pcg_addr);
1099- state_fio->StateUint8(pcg_ctrl);
1097+ state_fio->StateValue(pcg_data);
1098+ state_fio->StateValue(pcg_addr);
1099+ state_fio->StateValue(pcg_ctrl);
11001100 #elif defined(_MZ800)
1101- state_fio->StateUint8(wf);
1102- state_fio->StateUint8(rf);
1103- state_fio->StateUint8(dmd);
1104- state_fio->StateUint32(vram_addr_top);
1105- state_fio->StateBool(is_mz800);
1101+ state_fio->StateValue(wf);
1102+ state_fio->StateValue(rf);
1103+ state_fio->StateValue(dmd);
1104+ state_fio->StateValue(vram_addr_top);
1105+ state_fio->StateValue(is_mz800);
11061106 #elif defined(_MZ1500)
1107- state_fio->StateUint8(pcg_bank);
1107+ state_fio->StateValue(pcg_bank);
11081108 #endif
11091109 #if defined(_MZ800)
1110- state_fio->StateUint16(sof);
1111- state_fio->StateUint8(sw);
1112- state_fio->StateUint8(ssa);
1113- state_fio->StateUint8(sea);
1114- state_fio->StateUint8(palette_sw);
1115- state_fio->StateBuffer(palette, sizeof(palette), 1);
1116- state_fio->StateBuffer(palette16, sizeof(palette16), 1);
1110+ state_fio->StateValue(sof);
1111+ state_fio->StateValue(sw);
1112+ state_fio->StateValue(ssa);
1113+ state_fio->StateValue(sea);
1114+ state_fio->StateValue(palette_sw);
1115+ state_fio->StateArray(palette, sizeof(palette), 1);
1116+ state_fio->StateArray(palette16, sizeof(palette16), 1);
11171117 #elif defined(_MZ1500)
1118- state_fio->StateUint8(priority);
1119- state_fio->StateBuffer(palette, sizeof(palette), 1);
1118+ state_fio->StateValue(priority);
1119+ state_fio->StateArray(palette, sizeof(palette), 1);
11201120 #endif
1121- state_fio->StateBool(blink);
1122- state_fio->StateBool(tempo);
1123- state_fio->StateBool(hblank);
1124- state_fio->StateBool(hsync);
1125- state_fio->StateBool(vblank);
1126- state_fio->StateBool(vsync);
1127-#if defined(_MZ700) || defined(_MZ1500)
1128- state_fio->StateBool(hblank_vram);
1129-#endif
1130-#if defined(_MZ1500)
1131- state_fio->StateBool(hblank_pcg);
1132-#endif
1133-#if defined(_MZ800)
1134- //state_fio->StateBuffer(palette_mz800_pc, sizeof(palette_mz800_pc), 1);
1135- if(loading) {
1136- for(int i = 0; i < (sizeof(palette_mz800_pc) / sizeof(scrntype_t)); i++) {
1137- uint8_t r, g, b;
1138- r = state_fio->FgetUint8();
1139- g = state_fio->FgetUint8();
1140- b = state_fio->FgetUint8();
1141- palette_mz800_pc[i] = RGB_COLOR(r, g, b);
1142- }
1143- } else {
1144- for(int i = 0; i < (sizeof(palette_mz800_pc) / sizeof(scrntype_t)); i++) {
1145- uint8_t r, g, b;
1146- r = R_OF_COLOR(palette_mz800_pc[i]);
1147- g = G_OF_COLOR(palette_mz800_pc[i]);
1148- b = B_OF_COLOR(palette_mz800_pc[i]);
1149- state_fio->FputUint8(r);
1150- state_fio->FputUint8(g);
1151- state_fio->FputUint8(b);
1152- }
1153- }
1154-#endif
1155- //state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
1156- if(loading) {
1157- for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
1158- uint8_t r, g, b;
1159- r = state_fio->FgetUint8();
1160- g = state_fio->FgetUint8();
1161- b = state_fio->FgetUint8();
1162- palette_pc[i] = RGB_COLOR(r, g, b);
1163- }
1164- } else {
1165- for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
1166- uint8_t r, g, b;
1167- r = R_OF_COLOR(palette_pc[i]);
1168- g = G_OF_COLOR(palette_pc[i]);
1169- b = B_OF_COLOR(palette_pc[i]);
1170- state_fio->FputUint8(r);
1171- state_fio->FputUint8(g);
1172- state_fio->FputUint8(b);
1173- }
1174- }
1121+ state_fio->StateValue(blink);
1122+ state_fio->StateValue(tempo);
1123+ state_fio->StateValue(hblank);
1124+ state_fio->StateValue(hsync);
1125+ state_fio->StateValue(vblank);
1126+ state_fio->StateValue(vsync);
1127+ #if defined(_MZ700) || defined(_MZ1500)
1128+ state_fio->StateValue(hblank_vram);
1129+ #endif
1130+ #if defined(_MZ1500)
1131+ state_fio->StateValue(hblank_pcg);
1132+ #endif
1133+ #if defined(_MZ800)
1134+ state_fio->StateArrayScrnType_t(palette_mz800_pc, sizeof(palette_mz800_pc), 1);
1135+ #endif
1136+ state_fio->StateArrayScrnType_t(palette_pc, sizeof(palette_pc), 1);
11751137
11761138 // post process
11771139 if(loading) {
--- a/source/src/vm/mz700/quickdisk.cpp
+++ b/source/src/vm/mz700/quickdisk.cpp
@@ -570,26 +570,23 @@ bool QUICKDISK::process_state(FILEIO* state_fio, bool loading)
570570 if(!state_fio->StateCheckInt32(this_device_id)) {
571571 return false;
572572 }
573- state_fio->StateBuffer(file_path, sizeof(file_path), 1);
574- state_fio->StateBool(insert);
575- state_fio->StateBool(protect);
576- state_fio->StateBool(home);
577- state_fio->StateBool(modified);
578- state_fio->StateBool(accessed);
579- //state_fio->StateBuffer(buffer, sizeof(buffer), 1);
580- for(int i = 0; i < QUICKDISK_BUFFER_SIZE; i++) {
581- state_fio->StateUint16(buffer[i]);
582- }
583- state_fio->StateInt32(buffer_ptr);
584- state_fio->StateInt32(write_ptr);
585- state_fio->StateBool(first_data);
586- state_fio->StateBool(send_break);
587- state_fio->StateBool(wrga);
588- state_fio->StateBool(mton);
589- state_fio->StateBool(sync);
590- state_fio->StateBool(motor_on);
591- state_fio->StateInt32(restore_id);
592- state_fio->StateInt32(end_id);
573+ state_fio->StateArray(file_path, sizeof(file_path), 1);
574+ state_fio->StateValue(insert);
575+ state_fio->StateValue(protect);
576+ state_fio->StateValue(home);
577+ state_fio->StateValue(modified);
578+ state_fio->StateValue(accessed);
579+ state_fio->StateArray(buffer, sizeof(buffer), 1);
580+ state_fio->StateValue(buffer_ptr);
581+ state_fio->StateValue(write_ptr);
582+ state_fio->StateValue(first_data);
583+ state_fio->StateValue(send_break);
584+ state_fio->StateValue(wrga);
585+ state_fio->StateValue(mton);
586+ state_fio->StateValue(sync);
587+ state_fio->StateValue(motor_on);
588+ state_fio->StateValue(restore_id);
589+ state_fio->StateValue(end_id);
593590 return true;
594591 }
595592
--- a/source/src/vm/pasopia/pasopia.cpp
+++ b/source/src/vm/pasopia/pasopia.cpp
@@ -481,6 +481,6 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
481481 }
482482 }
483483 // Machine specified.
484- state_fio->StateInt32(boot_mode);
484+ state_fio->StateValue(boot_mode);
485485 return true;
486486 }
旧リポジトリブラウザで表示