OSDN Git Service

[VM] Enable to build with upstream 2018-10-14 @some VMs.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Sat, 27 Oct 2018 17:37:38 +0000 (02:37 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Sat, 27 Oct 2018 17:37:38 +0000 (02:37 +0900)
32 files changed:
source/src/vm/babbage2nd/babbage2nd.cpp
source/src/vm/bubcom80/display.cpp
source/src/vm/familybasic/apu.cpp
source/src/vm/familybasic/apu.h
source/src/vm/familybasic/familybasic.cpp
source/src/vm/familybasic/memory.cpp
source/src/vm/familybasic/ppu.cpp
source/src/vm/fm16pi/fm16pi.cpp
source/src/vm/fmr30/floppy.cpp
source/src/vm/fmr30/serial.cpp
source/src/vm/fmr50/bios.cpp
source/src/vm/fmr50/floppy.cpp
source/src/vm/fmr50/memory.cpp
source/src/vm/fp1100/sub.cpp
source/src/vm/fp1100/sub.h
source/src/vm/fp200/fp200.cpp
source/src/vm/fp200/io.cpp
source/src/vm/hc20/memory.cpp
source/src/vm/jr800/jr800.cpp
source/src/vm/jx/i286.cpp
source/src/vm/jx/i286.h
source/src/vm/jx/jx.cpp
source/src/vm/m5/m5.cpp
source/src/vm/mz2500/crtc.cpp
source/src/vm/mz2500/interrupt.cpp
source/src/vm/mz2500/mz2500.cpp
source/src/vm/mz2800/crtc.cpp
source/src/vm/mz3500/mz3500.cpp
source/src/vm/mz5500/display.cpp
source/src/vm/mz700/memory.cpp
source/src/vm/mz700/quickdisk.cpp
source/src/vm/pasopia/pasopia.cpp

index b16f065..a936c6e 100644 (file)
@@ -266,7 +266,7 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
                }
        }
        // Machine specified.
-       state_fio->StateBuffer(ram, sizeof(ram), 1);
+       state_fio->StateArray(ram, sizeof(ram), 1);
        if(loading) {
                update_config();
        }
index 380e33c..c7875f4 100644 (file)
@@ -821,67 +821,49 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateBuffer(font, sizeof(font), 1);
-       state_fio->StateBuffer(vram, sizeof(vram), 1);
-       state_fio->StateInt32(busreq_clocks);
-       state_fio->StateBool(color);
-       state_fio->StateBool(width40);
-       state_fio->StateUint8(mode);
-       //state_fio->StateBuffer(&crtc, sizeof(crtc), 1);
-       {
-               // crtc
-               /* struct */{
-                       state_fio->StateInt32(crtc.blink.rate);
-                       state_fio->StateInt32(crtc.blink.counter);
-                       state_fio->StateUint8(crtc.blink.cursor);
-                       state_fio->StateUint8(crtc.blink.attrib);
-               } /* blink */;
-               /*struct */{
-                       state_fio->StateInt32(crtc.cursor.type);
-                       state_fio->StateInt32(crtc.cursor.mode);
-                       state_fio->StateInt32(crtc.cursor.x);
-                       state_fio->StateInt32(crtc.cursor.y);
-               } /* cursor */;
-               /*struct */{
-                       state_fio->StateUint8(crtc.attrib.data);
-                       state_fio->StateInt32(crtc.attrib.num);
-                       state_fio->StateBuffer(crtc.attrib.expand, sizeof(crtc.attrib.expand), 1);
-               } /* attrib */;
-               /* struct */{
-                       state_fio->StateBuffer(crtc.text.expand, sizeof(crtc.text.expand), 1);
-               } /*text; */
-               state_fio->StateInt32(crtc.width);
-               state_fio->StateInt32(crtc.height);
-               state_fio->StateInt32(crtc.char_height);
-               state_fio->StateBool(crtc.skip_line);
-               state_fio->StateInt32(crtc.vretrace);
-               state_fio->StateBool(crtc.timing_changed);
-               state_fio->StateBuffer(crtc.buffer, sizeof(crtc.buffer), 1);
-               state_fio->StateInt32(crtc.buffer_ptr);
-               state_fio->StateUint8(crtc.cmd);
-               state_fio->StateInt32(crtc.cmd_ptr);
-               state_fio->StateUint8(crtc.mode);
-               state_fio->StateUint8(crtc.reverse);
-               state_fio->StateUint8(crtc.intr_mask);
-               state_fio->StateUint8(crtc.status);
-               state_fio->StateBool(crtc.vblank);
-       }
-       STORE_DMAC_CONTEXTS();
-       //state_fio->StateBuffer(&dmac, sizeof(dmac), 1);
-       { // dmac
-
-               for(int i = 0; i < 4; i++) {
-                       state_fio->StateUint32(dmac.ch[i].addr.d);
-                       state_fio->StateUint32(dmac.ch[i].count.d);
-                       state_fio->StateUint8(dmac.ch[i].mode);
-                       state_fio->StateInt32(dmac.ch[i].nbytes);
-                       state_fio->StateBool(dmac.ch[i].running);
-               } /* ch[4] */
-               state_fio->StateUint8(dmac.mode);
-               state_fio->StateUint8(dmac.status);
-               state_fio->StateBool(dmac.high_low);
-       }               
-       RESTORE_DMAC_CONTEXTS();
+       state_fio->StateArray(font, sizeof(font), 1);
+       state_fio->StateArray(vram, sizeof(vram), 1);
+       state_fio->StateValue(busreq_clocks);
+       state_fio->StateValue(color);
+       state_fio->StateValue(width40);
+       state_fio->StateValue(mode);
+       state_fio->StateValue(crtc.blink.rate);
+       state_fio->StateValue(crtc.blink.counter);
+       state_fio->StateValue(crtc.blink.cursor);
+       state_fio->StateValue(crtc.blink.attrib);
+       state_fio->StateValue(crtc.cursor.type);
+       state_fio->StateValue(crtc.cursor.mode);
+       state_fio->StateValue(crtc.cursor.x);
+       state_fio->StateValue(crtc.cursor.y);
+       state_fio->StateValue(crtc.attrib.data);
+       state_fio->StateValue(crtc.attrib.num);
+       state_fio->StateArray(&crtc.attrib.expand[0][0], sizeof(crtc.attrib.expand), 1);
+       state_fio->StateArray(&crtc.text.expand[0][0], sizeof(crtc.text.expand), 1);
+       state_fio->StateValue(crtc.width);
+       state_fio->StateValue(crtc.height);
+       state_fio->StateValue(crtc.char_height);
+       state_fio->StateValue(crtc.skip_line);
+       state_fio->StateValue(crtc.vretrace);
+       state_fio->StateValue(crtc.timing_changed);
+       state_fio->StateArray(crtc.buffer, sizeof(crtc.buffer), 1);
+       state_fio->StateValue(crtc.buffer_ptr);
+       state_fio->StateValue(crtc.cmd);
+       state_fio->StateValue(crtc.cmd_ptr);
+       state_fio->StateValue(crtc.mode);
+       state_fio->StateValue(crtc.reverse);
+       state_fio->StateValue(crtc.intr_mask);
+       state_fio->StateValue(crtc.status);
+       state_fio->StateValue(crtc.vblank);
+       for(int i = 0; i < array_length(dmac.ch); i++) {
+               state_fio->StateValue(dmac.ch[i].addr);
+               state_fio->StateValue(dmac.ch[i].count);
+               state_fio->StateValue(dmac.ch[i].mode);
+               state_fio->StateValue(dmac.ch[i].nbytes);
+               state_fio->StateValue(dmac.ch[i].running);
+       }
+       state_fio->StateValue(dmac.mode);
+       state_fio->StateValue(dmac.status);
+       state_fio->StateValue(dmac.high_low);
        return true;
 }
 }
index 9711e12..14aa30b 100644 (file)
@@ -798,108 +798,106 @@ void APU::set_volume(int ch, int decibel_l, int decibel_r)
 
 #define STATE_VERSION  2
 
-void APU::process_state_rectangle(int num, FILEIO* state_fio, bool loading)
+void process_state_rectangle(rectangle_t* val, FILEIO* state_fio)
 {
-       state_fio->StateBuffer(rectangle[num].regs, sizeof(rectangle[0].regs), 1);
-       state_fio->StateBool(rectangle[num].enabled);
-       state_fio->StateInt32(rectangle[num].phaseacc);
-       state_fio->StateInt32(rectangle[num].freq);
-       state_fio->StateInt32(rectangle[num].output_vol);
-       state_fio->StateBool(rectangle[num].fixed_envelope);
-       state_fio->StateBool(rectangle[num].holdnote);
-       state_fio->StateUint8(rectangle[num].volume);
-       state_fio->StateInt32(rectangle[num].sweep_phase);
-       state_fio->StateInt32(rectangle[num].sweep_delay);
-       state_fio->StateBool(rectangle[num].sweep_on);
-       state_fio->StateUint8(rectangle[num].sweep_shifts);
-       state_fio->StateUint8(rectangle[num].sweep_length);
-       state_fio->StateBool(rectangle[num].sweep_inc);
-       state_fio->StateInt32(rectangle[num].freq_limit);
-       state_fio->StateBool(rectangle[num].sweep_complement);
-       state_fio->StateInt32(rectangle[num].env_phase);
-       state_fio->StateInt32(rectangle[num].env_delay);
-       state_fio->StateUint8(rectangle[num].env_vol);
-       state_fio->StateInt32(rectangle[num].vbl_length);
-       state_fio->StateUint8(rectangle[num].adder);
-       state_fio->StateInt32(rectangle[num].duty_flip);
-       state_fio->StateBool(rectangle[num].enabled_cur);
-       state_fio->StateBool(rectangle[num].holdnote_cur);
-       state_fio->StateInt32(rectangle[num].vbl_length_cur);
+       state_fio->StateArray(val->regs, sizeof(val->regs), 1);
+       state_fio->StateValue(val->enabled);
+       state_fio->StateValue(val->phaseacc);
+       state_fio->StateValue(val->freq);
+       state_fio->StateValue(val->output_vol);
+       state_fio->StateValue(val->fixed_envelope);
+       state_fio->StateValue(val->holdnote);
+       state_fio->StateValue(val->volume);
+       state_fio->StateValue(val->sweep_phase);
+       state_fio->StateValue(val->sweep_delay);
+       state_fio->StateValue(val->sweep_on);
+       state_fio->StateValue(val->sweep_shifts);
+       state_fio->StateValue(val->sweep_length);
+       state_fio->StateValue(val->sweep_inc);
+       state_fio->StateValue(val->freq_limit);
+       state_fio->StateValue(val->sweep_complement);
+       state_fio->StateValue(val->env_phase);
+       state_fio->StateValue(val->env_delay);
+       state_fio->StateValue(val->env_vol);
+       state_fio->StateValue(val->vbl_length);
+       state_fio->StateValue(val->adder);
+       state_fio->StateValue(val->duty_flip);
+       state_fio->StateValue(val->enabled_cur);
+       state_fio->StateValue(val->holdnote_cur);
+       state_fio->StateValue(val->vbl_length_cur);
 }
 
-void APU::process_state_triangle(FILEIO* state_fio, bool loading)
+void process_state_triangle(triangle_t* val, FILEIO* state_fio)
 {
-       state_fio->StateBuffer(triangle.regs, sizeof(triangle.regs), 1);
-       state_fio->StateBool(triangle.enabled);
-       state_fio->StateInt32(triangle.freq);
-       state_fio->StateInt32(triangle.phaseacc);
-       state_fio->StateInt32(triangle.output_vol);
-       state_fio->StateUint8(triangle.adder);
-       state_fio->StateBool(triangle.holdnote);
-       state_fio->StateBool(triangle.counter_started);
-       state_fio->StateInt32(triangle.write_latency);
-       state_fio->StateInt32(triangle.vbl_length);
-       state_fio->StateInt32(triangle.linear_length);
-       state_fio->StateBool(triangle.enabled_cur);
-       state_fio->StateBool(triangle.holdnote_cur);
-       state_fio->StateBool(triangle.counter_started_cur);
-       state_fio->StateInt32(triangle.vbl_length_cur);
-       
+       state_fio->StateArray(val->regs, sizeof(val->regs), 1);
+       state_fio->StateValue(val->enabled);
+       state_fio->StateValue(val->freq);
+       state_fio->StateValue(val->phaseacc);
+       state_fio->StateValue(val->output_vol);
+       state_fio->StateValue(val->adder);
+       state_fio->StateValue(val->holdnote);
+       state_fio->StateValue(val->counter_started);
+       state_fio->StateValue(val->write_latency);
+       state_fio->StateValue(val->vbl_length);
+       state_fio->StateValue(val->linear_length);
+       state_fio->StateValue(val->enabled_cur);
+       state_fio->StateValue(val->holdnote_cur);
+       state_fio->StateValue(val->counter_started_cur);
+       state_fio->StateValue(val->vbl_length_cur);
 }
 
-void APU::process_state_noise(FILEIO* state_fio, bool loading)
+void process_state_noise(noise_t* val, FILEIO* state_fio)
 {
-       state_fio->StateBuffer(noise.regs, sizeof(noise.regs), 1);
-       state_fio->StateBool(noise.enabled);
-       state_fio->StateInt32(noise.freq);
-       state_fio->StateInt32(noise.phaseacc);
-       state_fio->StateInt32(noise.output_vol);
-       state_fio->StateInt32(noise.env_phase);
-       state_fio->StateInt32(noise.env_delay);
-       state_fio->StateUint8(noise.env_vol);
-       state_fio->StateBool(noise.fixed_envelope);
-       state_fio->StateBool(noise.holdnote);
-       state_fio->StateUint8(noise.volume);
-       state_fio->StateInt32(noise.vbl_length);
-       state_fio->StateUint8(noise.xor_tap);
-       state_fio->StateBool(noise.enabled_cur);
-       state_fio->StateBool(noise.holdnote_cur);
-       state_fio->StateInt32(noise.vbl_length_cur);
-               
-       state_fio->StateInt32(noise.shift_reg);
-       state_fio->StateInt32(noise.noise_bit);
+       state_fio->StateArray(val->regs, sizeof(val->regs), 1);
+       state_fio->StateValue(val->enabled);
+       state_fio->StateValue(val->freq);
+       state_fio->StateValue(val->phaseacc);
+       state_fio->StateValue(val->output_vol);
+       state_fio->StateValue(val->env_phase);
+       state_fio->StateValue(val->env_delay);
+       state_fio->StateValue(val->env_vol);
+       state_fio->StateValue(val->fixed_envelope);
+       state_fio->StateValue(val->holdnote);
+       state_fio->StateValue(val->volume);
+       state_fio->StateValue(val->vbl_length);
+       state_fio->StateValue(val->xor_tap);
+       state_fio->StateValue(val->enabled_cur);
+       state_fio->StateValue(val->holdnote_cur);
+       state_fio->StateValue(val->vbl_length_cur);
+       state_fio->StateValue(val->shift_reg);
+       state_fio->StateValue(val->noise_bit);
 }
 
-void APU::process_state_dmc(FILEIO* state_fio, bool loading)
+void process_state_dmc(dmc_t* val, FILEIO* state_fio)
 {
-       state_fio->StateBuffer(dmc.regs, sizeof(dmc.regs), 1);
-       state_fio->StateBool(dmc.enabled);
-       state_fio->StateInt32(dmc.freq);
-       state_fio->StateInt32(dmc.phaseacc);
-       state_fio->StateInt32(dmc.output_vol);
-       state_fio->StateUint32(dmc.address);
-       state_fio->StateUint32(dmc.cached_addr);
-       state_fio->StateInt32(dmc.dma_length);
-       state_fio->StateInt32(dmc.cached_dmalength);
-       state_fio->StateUint8(dmc.cur_byte);
-       state_fio->StateBool(dmc.looping);
-       state_fio->StateBool(dmc.irq_gen);
-       state_fio->StateBool(dmc.irq_occurred);
-       state_fio->StateInt32(dmc.freq_cur);
-       state_fio->StateInt32(dmc.phaseacc_cur);
-       state_fio->StateInt32(dmc.dma_length_cur);
-       state_fio->StateInt32(dmc.cached_dmalength_cur);
-       state_fio->StateBool(dmc.enabled_cur);
-       state_fio->StateBool(dmc.looping_cur);
-       state_fio->StateBool(dmc.irq_gen_cur);
-       state_fio->StateBool(dmc.irq_occurred_cur);
+       state_fio->StateArray(val->regs, sizeof(val->regs), 1);
+       state_fio->StateValue(val->enabled);
+       state_fio->StateValue(val->freq);
+       state_fio->StateValue(val->phaseacc);
+       state_fio->StateValue(val->output_vol);
+       state_fio->StateValue(val->address);
+       state_fio->StateValue(val->cached_addr);
+       state_fio->StateValue(val->dma_length);
+       state_fio->StateValue(val->cached_dmalength);
+       state_fio->StateValue(val->cur_byte);
+       state_fio->StateValue(val->looping);
+       state_fio->StateValue(val->irq_gen);
+       state_fio->StateValue(val->irq_occurred);
+       state_fio->StateValue(val->freq_cur);
+       state_fio->StateValue(val->phaseacc_cur);
+       state_fio->StateValue(val->dma_length_cur);
+       state_fio->StateValue(val->cached_dmalength_cur);
+       state_fio->StateValue(val->enabled_cur);
+       state_fio->StateValue(val->looping_cur);
+       state_fio->StateValue(val->irq_gen_cur);
+       state_fio->StateValue(val->irq_occurred_cur);
 }
 
-void APU::process_state_queue(int num, FILEIO* state_fio, bool loading)
+void process_state_queue(queue_t* val, FILEIO* state_fio)
 {
-       state_fio->StateUint32(queue[num].timestamp);
-       state_fio->StateUint32(queue[num].addr);
-       state_fio->StateUint32(queue[num].data);
+       state_fio->StateValue(val->timestamp);
+       state_fio->StateValue(val->addr);
+       state_fio->StateValue(val->data);
 }
 
 bool APU::process_state(FILEIO* state_fio, bool loading)
@@ -910,30 +908,24 @@ bool APU::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       //state_fio->StateBuffer(rectangle, sizeof(rectangle), 1);
-       //state_fio->StateBuffer(&triangle, sizeof(triangle), 1);
-       //state_fio->StateBuffer(&noise, sizeof(noise), 1);
-       //state_fio->StateBuffer(&dmc, sizeof(dmc), 1);
-       for(int i = 0; i < 2; i++) {
-               process_state_rectangle(i, state_fio, loading);
-       }
-       process_state_triangle(state_fio, loading);
-       process_state_noise(state_fio, loading);
-       process_state_dmc(state_fio, loading);
-       
-       state_fio->StateUint32(enable_reg);
-       state_fio->StateUint32(enable_reg_cur);
-       state_fio->StateInt32(count_rate);
-       //state_fio->StateBuffer(queue, sizeof(queue), 1);
-       for(int i = 0; i < APUQUEUE_SIZE; i++) {
-               process_state_queue(i, state_fio, loading);
-       }
-       state_fio->StateInt32(q_head);
-       state_fio->StateInt32(q_tail);
-       state_fio->StateUint32(elapsed_cycles);
-       state_fio->StateDouble(ave);
-       state_fio->StateDouble(max);
-       state_fio->StateDouble(min);
+       for(int i = 0; i < array_length(rectangle); i++) {
+               process_state_rectangle(&rectangle[i], state_fio);
+       }
+       process_state_triangle(&triangle, state_fio);
+       process_state_noise(&noise, state_fio);
+       process_state_dmc(&dmc, state_fio);
+       state_fio->StateValue(enable_reg);
+       state_fio->StateValue(enable_reg_cur);
+       state_fio->StateValue(count_rate);
+       for(int i = 0; i < array_length(queue); i++) {
+               process_state_queue(&queue[i], state_fio);
+       }
+       state_fio->StateValue(q_head);
+       state_fio->StateValue(q_tail);
+       state_fio->StateValue(elapsed_cycles);
+       state_fio->StateValue(ave);
+       state_fio->StateValue(max);
+       state_fio->StateValue(min);
        return true;
 }
 
index 8404dfa..5cb9a04 100644 (file)
@@ -159,12 +159,6 @@ private:
        
        int volume_l, volume_r;
 
-       void process_state_rectangle(int num, FILEIO* state_fio, bool loading);
-       void process_state_triangle(FILEIO* state_fio, bool loading);
-       void process_state_noise(FILEIO* state_fio, bool loading);
-       void process_state_dmc(FILEIO* state_fio, bool loading);
-       void process_state_queue(int num, FILEIO* state_fio, bool loading);
-       
 public:
        APU(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
index 7a647b2..531ce5f 100644 (file)
@@ -349,7 +349,7 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
                }
        }
        // Machine specified.
-       state_fio->StateInt32(boot_mode);
+       state_fio->StateValue(boot_mode);
        if(loading) {
                update_config();
        }
index ce02028..9ffcaf9 100644 (file)
@@ -886,10 +886,16 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateBuffer(save_file_name, sizeof(save_file_name), 1);
-       state_fio->StateBuffer(&header, sizeof(header), 1); // OK?
-       state_fio->StateUint32(rom_size);
-//     state_fio->StateUint32(rom_mask);
+       state_fio->StateArray(save_file_name, sizeof(save_file_name), 1);
+       state_fio->StateArray(header.id, sizeof(header.id), 1);
+       state_fio->StateValue(header.ctrl_z);
+       state_fio->StateValue(header.dummy);
+       state_fio->StateValue(header.num_8k_vrom_banks);
+       state_fio->StateValue(header.flags_1);
+       state_fio->StateValue(header.flags_2);
+       state_fio->StateArray(header.reserved, sizeof(header.reserved), 1);
+       state_fio->StateValue(rom_size);
+//     state_fio->StateValue(rom_mask);
        if(loading) {
                rom_mask = (rom_size / 0x2000) - 1;
                if(rom != NULL) {
@@ -897,41 +903,35 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
                }
                rom = (uint8_t *)malloc(rom_size);
        }
-       state_fio->StateBuffer(rom, rom_size, 1);
-       state_fio->StateBuffer(ram, sizeof(ram), 1);
-       state_fio->StateBuffer(save_ram, sizeof(save_ram), 1);
-       state_fio->StateUint32(save_ram_crc32);
-       //state_fio->StateBuffer(banks, sizeof(banks), 1);
-       for(int i = 0; i < (sizeof(banks) / sizeof(uint32_t)); i++) {
-               state_fio->StateUint32(banks[i]);
-       }
-       state_fio->StateUint16(dma_addr);
-       state_fio->StateUint8(frame_irq_enabled);
-       //state_fio->StateBuffer(mmc5_wram_bank, sizeof(mmc5_wram_bank), 1);
-       for(int i = 0; i < (sizeof(mmc5_wram_bank) / sizeof(uint32_t)); i++) {
-               state_fio->StateUint32(mmc5_wram_bank[i]);
-       }
-       state_fio->StateBuffer(mmc5_chr_reg, sizeof(mmc5_chr_reg), 1);
-       state_fio->StateUint32(mmc5_value0);
-       state_fio->StateUint32(mmc5_value0);
-       state_fio->StateUint8(mmc5_wram_protect0);
-       state_fio->StateUint8(mmc5_wram_protect1);
-       state_fio->StateUint8(mmc5_prg_size);
-       state_fio->StateUint8(mmc5_chr_size);
-       state_fio->StateUint8(mmc5_gfx_mode);
-//     state_fio->StateUint8(mmc5_split_control);
-//     state_fio->StateUint8(mmc5_split_bank);
-       state_fio->StateUint8(mmc5_irq_enabled);
-       state_fio->StateUint8(mmc5_irq_status);
-       state_fio->StateUint32(mmc5_irq_line);
-       state_fio->StateUint8(vrc7_irq_enabled);
-       state_fio->StateUint8(vrc7_irq_counter);
-       state_fio->StateUint8(vrc7_irq_latch);
-       state_fio->StateBool(pad_strobe);
-       state_fio->StateUint8(pad1_bits);
-       state_fio->StateUint8(pad2_bits);
-       state_fio->StateBool(kb_out);
-       state_fio->StateUint8(kb_scan);
+       state_fio->StateArray(rom, rom_size, 1);
+       state_fio->StateArray(ram, sizeof(ram), 1);
+       state_fio->StateArray(save_ram, sizeof(save_ram), 1);
+       state_fio->StateValue(save_ram_crc32);
+       state_fio->StateArray(banks, sizeof(banks), 1);
+       state_fio->StateValue(dma_addr);
+       state_fio->StateValue(frame_irq_enabled);
+       state_fio->StateArray(mmc5_wram_bank, sizeof(mmc5_wram_bank), 1);
+       state_fio->StateArray(&mmc5_chr_reg[0][0], sizeof(mmc5_chr_reg), 1);
+       state_fio->StateValue(mmc5_value0);
+       state_fio->StateValue(mmc5_value0);
+       state_fio->StateValue(mmc5_wram_protect0);
+       state_fio->StateValue(mmc5_wram_protect1);
+       state_fio->StateValue(mmc5_prg_size);
+       state_fio->StateValue(mmc5_chr_size);
+       state_fio->StateValue(mmc5_gfx_mode);
+//     state_fio->StateValue(mmc5_split_control);
+//     state_fio->StateValue(mmc5_split_bank);
+       state_fio->StateValue(mmc5_irq_enabled);
+       state_fio->StateValue(mmc5_irq_status);
+       state_fio->StateValue(mmc5_irq_line);
+       state_fio->StateValue(vrc7_irq_enabled);
+       state_fio->StateValue(vrc7_irq_counter);
+       state_fio->StateValue(vrc7_irq_latch);
+       state_fio->StateValue(pad_strobe);
+       state_fio->StateValue(pad1_bits);
+       state_fio->StateValue(pad2_bits);
+       state_fio->StateValue(kb_out);
+       state_fio->StateValue(kb_scan);
        
        // post process
        if(loading) {
index af627d9..34581cd 100644 (file)
@@ -673,34 +673,18 @@ bool PPU::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       //state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
-       if(loading) {
-               for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette_pc[i] = RGB_COLOR(r, g, b);
-               }
-       } else {
-               for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette_pc[i]);
-                       g = G_OF_COLOR(palette_pc[i]);
-                       b = B_OF_COLOR(palette_pc[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       state_fio->StateBuffer(solid_buf, sizeof(solid_buf), 1);
-       state_fio->StateBuffer(&header, sizeof(header), 1); // OK?
-//     state_fio->StateBuffer(banks, sizeof(banks), 1);
-       for(int i = 0; i < (sizeof(banks) / sizeof(uint32_t)); i++) {
-               state_fio->StateUint32(banks[i]);
-       }
-       state_fio->StateUint32(chr_rom_size);
-//     state_fio->StateInt32(chr_rom_mask);
+       state_fio->StateArrayScrnType_t(palette_pc, sizeof(palette_pc), 1);
+       state_fio->StateArray(solid_buf, sizeof(solid_buf), 1);
+       state_fio->StateArray(header.id, sizeof(header.id), 1);
+       state_fio->StateValue(header.ctrl_z);
+       state_fio->StateValue(header.dummy);
+       state_fio->StateValue(header.num_8k_vrom_banks);
+       state_fio->StateValue(header.flags_1);
+       state_fio->StateValue(header.flags_2);
+       state_fio->StateArray(header.reserved, sizeof(header.reserved), 1);
+       state_fio->StateArray(banks, sizeof(banks), 1);
+       state_fio->StateValue(chr_rom_size);
+//     state_fio->StateValue(chr_rom_mask);
        if(loading) {
                chr_rom_mask = (chr_rom_size / 0x400) - 1;
                if(chr_rom != NULL) {
@@ -708,22 +692,22 @@ bool PPU::process_state(FILEIO* state_fio, bool loading)
                }
                chr_rom = (uint8_t *)malloc(chr_rom_size);
        }
-       state_fio->StateBuffer(chr_rom, chr_rom_size, 1);
-       state_fio->StateBuffer(name_tables, sizeof(name_tables), 1);
-       state_fio->StateBuffer(spr_ram, sizeof(spr_ram), 1);
-       state_fio->StateBuffer(bg_pal, sizeof(bg_pal), 1);
-       state_fio->StateBuffer(spr_pal, sizeof(spr_pal), 1);
-       state_fio->StateUint8(spr_ram_rw_ptr);
-       state_fio->StateBuffer(regs, sizeof(regs), 1);
-       state_fio->StateUint16(bg_pattern_table_addr);
-       state_fio->StateUint16(spr_pattern_table_addr);
-       state_fio->StateUint16(ppu_addr_inc);
-       state_fio->StateUint8(rgb_bak);
-       state_fio->StateBool(toggle_2005_2006);
-       state_fio->StateUint8(read_2007_buffer);
-       state_fio->StateUint16(loopy_v);
-       state_fio->StateUint16(loopy_t);
-       state_fio->StateUint8(loopy_x);
+       state_fio->StateArray(chr_rom, chr_rom_size, 1);
+       state_fio->StateArray(name_tables, sizeof(name_tables), 1);
+       state_fio->StateArray(spr_ram, sizeof(spr_ram), 1);
+       state_fio->StateArray(bg_pal, sizeof(bg_pal), 1);
+       state_fio->StateArray(spr_pal, sizeof(spr_pal), 1);
+       state_fio->StateValue(spr_ram_rw_ptr);
+       state_fio->StateArray(regs, sizeof(regs), 1);
+       state_fio->StateValue(bg_pattern_table_addr);
+       state_fio->StateValue(spr_pattern_table_addr);
+       state_fio->StateValue(ppu_addr_inc);
+       state_fio->StateValue(rgb_bak);
+       state_fio->StateValue(toggle_2005_2006);
+       state_fio->StateValue(read_2007_buffer);
+       state_fio->StateValue(loopy_v);
+       state_fio->StateValue(loopy_t);
+       state_fio->StateValue(loopy_x);
        
        // post process
        if(loading) {
index b7b7ddb..7f6e0e6 100644 (file)
@@ -453,6 +453,6 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
                }
        }
        // Machine specified.
-       state_fio->StateBuffer(ram, sizeof(ram), 1);
+       state_fio->StateArray(ram, sizeof(ram), 1);
        return true;
 }
index 2698659..703326d 100644 (file)
@@ -107,15 +107,12 @@ bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateUint8(fdcr);
-       state_fio->StateUint8(fdsl);
-       state_fio->StateUint8(fdst);
-       state_fio->StateInt32(drvsel);
-       state_fio->StateBool(irq);
-       //state_fio->StateBuffer(changed, sizeof(changed), 1);
-       for(int i = 0; i < (sizeof(changed) / sizeof(bool)); i++) {
-               state_fio->StateBool(changed[i]);
-       }
+       state_fio->StateValue(fdcr);
+       state_fio->StateValue(fdsl);
+       state_fio->StateValue(fdst);
+       state_fio->StateValue(drvsel);
+       state_fio->StateValue(irq);
+       state_fio->StateArray(changed, sizeof(changed), 1);
        return true;
 }
 
index 243ea40..477b7df 100644 (file)
@@ -152,13 +152,13 @@ bool SERIAL::process_state(FILEIO* state_fio, bool loading)
                return false;
        }
        //state_fio->StateBuffer(sioctrl, sizeof(sioctrl), 1);
-       for(int i = 0; i < 4; i++) {
-               state_fio->StateUint8(sioctrl[i].baud);
-               state_fio->StateUint8(sioctrl[i].ctrl);
-               state_fio->StateBool(sioctrl[i].rxrdy);
-               state_fio->StateBool(sioctrl[i].txrdy);
-               state_fio->StateUint8(sioctrl[i].intmask);
-               state_fio->StateUint8(sioctrl[i].intstat);
+       for(int i = 0; i < 4; i++) {    
+               state_fio->StateValue(sioctrl[i].baud);
+               state_fio->StateValue(sioctrl[i].ctrl);
+               state_fio->StateValue(sioctrl[i].rxrdy);
+               state_fio->StateValue(sioctrl[i].txrdy);
+               state_fio->StateValue(sioctrl[i].intmask);
+               state_fio->StateValue(sioctrl[i].intstat);
        }
        return true;
 }
index 34a2d85..f8f34ed 100644 (file)
@@ -1161,17 +1161,11 @@ bool BIOS::process_state(FILEIO* state_fio, bool loading)
                        return false;
                }
        }
-       state_fio->StateInt32(secnum);
-       state_fio->StateInt32(timeout);
-       state_fio->StateBuffer(drive_mode1, sizeof(drive_mode1), 1);
-       //state_fio->StateBuffer(drive_mode2, sizeof(drive_mode2), 1);
-       for(int i = 0; i < (sizeof(drive_mode2) / sizeof(uint16_t)); i++) {
-               state_fio->StateUint16(drive_mode2[i]);
-       }
-       //state_fio->StateBuffer(scsi_blocks, sizeof(scsi_blocks), 1);
-       for(int i = 0; i < (sizeof(scsi_blocks) / sizeof(int)); i++) {
-               state_fio->StateInt32(scsi_blocks[i]);
-       }
+       state_fio->StateValue(secnum);
+       state_fio->StateValue(timeout);
+       state_fio->StateArray(drive_mode1, sizeof(drive_mode1), 1);
+       state_fio->StateArray(drive_mode2, sizeof(drive_mode2), 1);
+       state_fio->StateArray(scsi_blocks, sizeof(scsi_blocks), 1);
        return true;
 }
 
index 4242a3a..0552afd 100644 (file)
@@ -123,14 +123,11 @@ bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateInt32(drvreg);
-       state_fio->StateInt32(drvsel);
-       state_fio->StateBool(irq);
-       state_fio->StateBool(irqmsk);
-       //state_fio->StateBuffer(changed, sizeof(changed), 1);
-       for(int i = 0; i < (sizeof(changed) / sizeof(bool)); i++) {
-               state_fio->StateBool(changed[i]);
-       }
+       state_fio->StateValue(drvreg);
+       state_fio->StateValue(drvsel);
+       state_fio->StateValue(irq);
+       state_fio->StateValue(irqmsk);
+       state_fio->StateArray(changed, sizeof(changed), 1);
        return true;
 }
 
index 1e0d5f8..1522039 100644 (file)
@@ -1223,94 +1223,58 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateBuffer(ram, sizeof(ram), 1);
-       state_fio->StateBuffer(vram, sizeof(vram), 1);
-       state_fio->StateBuffer(cvram, sizeof(cvram), 1);
-#ifdef _FMR60
-       state_fio->StateBuffer(avram, sizeof(avram), 1);
-#else
-       state_fio->StateBuffer(kvram, sizeof(kvram), 1);
-#endif
-       state_fio->StateUint8(machine_id);
-       state_fio->StateUint8(protect);
-       state_fio->StateUint8(rst);
-       state_fio->StateUint8(mainmem);
-       state_fio->StateUint8(rplane);
-       state_fio->StateUint8(wplane);
-       state_fio->StateUint8(dma_addr_reg);
-       state_fio->StateUint8(dma_wrap_reg);
-       state_fio->StateUint32(dma_addr_mask);
-       state_fio->StateBool(disp);
-       state_fio->StateBool(vsync);
-       state_fio->StateInt32(blink);
-       state_fio->StateBuffer(apal, sizeof(apal), 1);
-       state_fio->StateUint8(apalsel);
-       state_fio->StateBuffer(dpal, sizeof(dpal), 1);
-       state_fio->StateUint8(outctrl);
+       state_fio->StateArray(ram, sizeof(ram), 1);
+       state_fio->StateArray(vram, sizeof(vram), 1);
+       state_fio->StateArray(cvram, sizeof(cvram), 1);
+ #ifdef _FMR60
+       state_fio->StateArray(avram, sizeof(avram), 1);
+ #else
+       state_fio->StateArray(kvram, sizeof(kvram), 1);
+ #endif
+       state_fio->StateValue(machine_id);
+       state_fio->StateValue(protect);
+       state_fio->StateValue(rst);
+       state_fio->StateValue(mainmem);
+       state_fio->StateValue(rplane);
+       state_fio->StateValue(wplane);
+       state_fio->StateValue(dma_addr_reg);
+       state_fio->StateValue(dma_wrap_reg);
+       state_fio->StateValue(dma_addr_mask);
+       state_fio->StateValue(disp);
+       state_fio->StateValue(vsync);
+       state_fio->StateValue(blink);
+       state_fio->StateArray(&apal[0][0], sizeof(apal), 1);
+       state_fio->StateValue(apalsel);
+       state_fio->StateArray(dpal, sizeof(dpal), 1);
+       state_fio->StateValue(outctrl);
 #ifndef _FMR60
-       state_fio->StateUint8(pagesel);
-       state_fio->StateUint8(ankcg);
-       state_fio->StateUint8(dispctrl);
-       state_fio->StateUint8(mix);
-       state_fio->StateUint16(accaddr);
-       state_fio->StateUint16(dispaddr);
-       state_fio->StateInt32(kj_h);
-       state_fio->StateInt32(kj_l);
-       state_fio->StateInt32(kj_ofs);
-       state_fio->StateInt32(kj_row);
-       state_fio->StateUint8(cmdreg);
-       state_fio->StateUint8(imgcol);
-       state_fio->StateUint8(maskreg);
-       state_fio->StateBuffer(compreg, sizeof(compreg), 1);
-       state_fio->StateUint8(compbit);
-       state_fio->StateUint8(bankdis);
-       state_fio->StateBuffer(tilereg, sizeof(tilereg), 1);
-       state_fio->StateUint16(lofs);
-       state_fio->StateUint16(lsty);
-       state_fio->StateUint16(lsx);
-       state_fio->StateUint16(lsy);
-       state_fio->StateUint16(lex);
-       state_fio->StateUint16(ley);
+       state_fio->StateValue(pagesel);
+       state_fio->StateValue(ankcg);
+       state_fio->StateValue(dispctrl);
+       state_fio->StateValue(mix);
+       state_fio->StateValue(accaddr);
+       state_fio->StateValue(dispaddr);
+       state_fio->StateValue(kj_h);
+       state_fio->StateValue(kj_l);
+       state_fio->StateValue(kj_ofs);
+       state_fio->StateValue(kj_row);
+       state_fio->StateValue(cmdreg);
+       state_fio->StateValue(imgcol);
+       state_fio->StateValue(maskreg);
+       state_fio->StateArray(compreg, sizeof(compreg), 1);
+       state_fio->StateValue(compbit);
+       state_fio->StateValue(bankdis);
+       state_fio->StateArray(tilereg, sizeof(tilereg), 1);
+       state_fio->StateValue(lofs);
+       state_fio->StateValue(lsty);
+       state_fio->StateValue(lsx);
+       state_fio->StateValue(lsy);
+       state_fio->StateValue(lex);
+       state_fio->StateValue(ley);
 #endif
-       //state_fio->StateBuffer(palette_cg, sizeof(palette_cg), 1);
-       if(loading) {
-               for(int i = 0; i < (sizeof(palette_cg) / sizeof(scrntype_t)); i++) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette_cg[i] = RGB_COLOR(r, g, b);
-               }
-       } else {
-               for(int i = 0; i < (sizeof(palette_cg) / sizeof(scrntype_t)); i++) {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette_cg[i]);
-                       g = G_OF_COLOR(palette_cg[i]);
-                       b = B_OF_COLOR(palette_cg[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       if(loading) {
-               for(int i = 0; i < (sizeof(palette_txt) / sizeof(scrntype_t)); i++) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette_txt[i] = RGB_COLOR(r, g, b);
-               }
-       } else {
-               for(int i = 0; i < (sizeof(palette_txt) / sizeof(scrntype_t)); i++) {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette_txt[i]);
-                       g = G_OF_COLOR(palette_txt[i]);
-                       b = B_OF_COLOR(palette_txt[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
+       state_fio->StateArrayScrnType_t(palette_cg, sizeof(palette_cg), 1);
+//     state_fio->StateArrayScrnType_t(palette_txt, sizeof(palette_txt), 1);
+
        // post process
        if(loading) {
                update_bank();
index ce670cf..67fad08 100644 (file)
@@ -526,61 +526,6 @@ void SUB::draw_screen()
        }
 }
 
-
-#define PROCESS_STATE_74LS74(foo)                      \
-       {                                                                                       \
-               state_fio->StateBool(foo.in_d);                 \
-               state_fio->StateBool(foo.in_ck);                \
-               state_fio->StateBool(foo.in_s);                 \
-               state_fio->StateBool(foo.in_r);                 \
-               state_fio->StateBool(foo.out_q);                \
-               state_fio->StateBool(foo.out_nq);               \
-               state_fio->StateBool(foo.tmp_ck);               \
-       }
-
-#define PROCESS_STATE_74LS151(foo)             \
-       {                                                                                       \
-               state_fio->StateBool(foo.in_d0);                \
-               state_fio->StateBool(foo.in_d1);                \
-               state_fio->StateBool(foo.in_d2);                \
-               state_fio->StateBool(foo.in_d3);                \
-               state_fio->StateBool(foo.in_d4);                \
-               state_fio->StateBool(foo.in_d5);                \
-               state_fio->StateBool(foo.in_d6);                \
-               state_fio->StateBool(foo.in_d7);                \
-               state_fio->StateBool(foo.in_a);                 \
-               state_fio->StateBool(foo.in_b);                 \
-               state_fio->StateBool(foo.in_c);                 \
-               state_fio->StateBool(foo.in_s);                 \
-               state_fio->StateBool(foo.out_y);                \
-               state_fio->StateBool(foo.out_ny);               \
-       }
-
-#define PROCESS_STATE_74LS93(foo)                      \
-       {                                                                                       \
-               state_fio->StateBool(foo.in_a);                 \
-               state_fio->StateBool(foo.in_b);                 \
-               state_fio->StateBool(foo.in_rc1);               \
-               state_fio->StateBool(foo.in_rc2);               \
-               state_fio->StateBool(foo.out_qa);               \
-               state_fio->StateBool(foo.out_qb);               \
-               state_fio->StateBool(foo.out_qc);               \
-               state_fio->StateBool(foo.tmp_a);                \
-               state_fio->StateBool(foo.tmp_b);                \
-               state_fio->StateUint8(foo.counter_a);   \
-               state_fio->StateUint8(foo.counter_b);   \
-       }
-
-#define PROCESS_STATE_4024(foo)                        \
-       {                                                                                       \
-               state_fio->StateBool(foo.in_ck);                \
-               state_fio->StateBool(foo.in_clr);               \
-               state_fio->StateBool(foo.out_q5);               \
-               state_fio->StateBool(foo.out_q6);               \
-               state_fio->StateBool(foo.tmp_ck);               \
-               state_fio->StateUint8(foo.counter);             \
-       }
-
 #define STATE_VERSION  3
 
 void process_state_ls74(ls74_t* val, FILEIO* state_fio)
@@ -645,40 +590,29 @@ bool SUB::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateBuffer(ram, sizeof(ram), 1);
-       state_fio->StateBuffer(vram_b, sizeof(vram_b), 1);
-       state_fio->StateBuffer(vram_r, sizeof(vram_r), 1);
-       state_fio->StateBuffer(vram_g, sizeof(vram_g), 1);
-       state_fio->StateUint8(pa);
-       state_fio->StateUint8(pb);
-       state_fio->StateUint8(pc);
-       state_fio->StateUint8(comm_data);
-       state_fio->StateBool(so);
-       state_fio->StateUint8(clock);
-       //state_fio->StateBuffer(&b16_1, sizeof(b16_1), 1);
-       //state_fio->StateBuffer(&b16_2, sizeof(b16_2), 1);
-       //state_fio->StateBuffer(&g21_1, sizeof(g21_1), 1);
-       //state_fio->StateBuffer(&g21_2, sizeof(g21_2), 1);
-       PROCESS_STATE_74LS74(b16_1);
-       PROCESS_STATE_74LS74(b16_2);
-       PROCESS_STATE_74LS74(g21_1);
-       PROCESS_STATE_74LS74(g21_2);
-       
-       //state_fio->StateBuffer(&c15, sizeof(c15), 1);
-       PROCESS_STATE_74LS151(c15);
-       
-       //state_fio->StateBuffer(&c16, sizeof(c16), 1);
-       PROCESS_STATE_74LS93(c16);
-       
-       //state_fio->StateBuffer(&f21, sizeof(f21), 1);
-       PROCESS_STATE_4024(f21);
-       
-       state_fio->StateUint8(key_sel);
-       state_fio->StateUint8(key_data);
-       state_fio->StateUint8(color_reg);
-       state_fio->StateBool(hsync);
-       state_fio->StateBool(wait);
-       state_fio->StateUint8(cblink);
+       state_fio->StateArray(ram, sizeof(ram), 1);
+       state_fio->StateArray(vram_b, sizeof(vram_b), 1);
+       state_fio->StateArray(vram_r, sizeof(vram_r), 1);
+       state_fio->StateArray(vram_g, sizeof(vram_g), 1);
+       state_fio->StateValue(pa);
+       state_fio->StateValue(pb);
+       state_fio->StateValue(pc);
+       state_fio->StateValue(comm_data);
+       state_fio->StateValue(so);
+       state_fio->StateValue(clock);
+       process_state_ls74(&b16_1, state_fio);
+       process_state_ls74(&b16_2, state_fio);
+       process_state_ls74(&g21_1, state_fio);
+       process_state_ls74(&g21_2, state_fio);
+       process_state_ls151(&c15, state_fio);
+       process_state_ls93(&c16, state_fio);
+       process_state_tc4024bp(&f21, state_fio);
+       state_fio->StateValue(key_sel);
+       state_fio->StateValue(key_data);
+       state_fio->StateValue(color_reg);
+       state_fio->StateValue(hsync);
+       state_fio->StateValue(wait);
+       state_fio->StateValue(cblink);
        return true;
 }
 
index 7a2282d..84c683a 100644 (file)
@@ -24,6 +24,104 @@ class HD46505;
 
 namespace FP1100 {
        
+// 74LS74
+typedef struct ls74_s {
+       bool in_d, in_ck, in_s, in_r;
+       bool out_q, out_nq;
+       bool tmp_ck;
+       void update()
+       {
+               if(!in_s && in_r) {
+                       out_q = true;
+                       out_nq = false;
+               } else if(in_s && !in_r) {
+                       out_q = false;
+                       out_nq = true;
+               } else if(!in_s && !in_r) {
+                       out_q = out_nq = true; // undetermined
+               } else if(!tmp_ck && in_ck) {
+                       out_q = in_d;
+                       out_nq = !in_d;
+               }
+               tmp_ck = in_ck;
+       }
+} ls74_t;
+
+// 74LS151
+typedef struct ls151_s {
+       bool in_d0, in_d1, in_d2, in_d3, in_d4, in_d5, in_d6, in_d7;
+       bool in_a, in_b, in_c, in_s;
+       bool out_y, out_ny;
+       void update()
+       {
+               if(in_s) {
+                       out_y = false;
+               } else if(!in_a && !in_b && !in_c) {
+                       out_y = in_d0;
+               } else if( in_a && !in_b && !in_c) {
+                       out_y = in_d1;
+               } else if(!in_a &&  in_b && !in_c) {
+                       out_y = in_d2;
+               } else if( in_a &&  in_b && !in_c) {
+                       out_y = in_d3;
+               } else if(!in_a && !in_b &&  in_c) {
+                       out_y = in_d4;
+               } else if( in_a && !in_b &&  in_c) {
+                       out_y = in_d5;
+               } else if(!in_a &&  in_b &&  in_c) {
+                       out_y = in_d6;
+               } else if( in_a &&  in_b &&  in_c) {
+                       out_y = in_d7;
+               }
+               out_ny = !out_y;
+       }
+} ls151_t;
+
+// 74LS93
+typedef struct ls93_s {
+       bool in_a, in_b, in_rc1, in_rc2;
+       bool out_qa, out_qb, out_qc;
+       bool tmp_a, tmp_b;
+       uint8_t counter_a, counter_b;
+       void update()
+       {
+               if(in_rc1 && in_rc2) {
+                       counter_a = counter_b = 0;
+               } else {
+                       if(tmp_a && !in_a) {
+                               counter_a++;
+                       }
+                       if(tmp_b && !in_b) {
+                               counter_b++;
+                       }
+               }
+               tmp_a = in_a;
+               tmp_b = in_b;
+               out_qa = ((counter_a & 1) != 0);
+               out_qb = ((counter_b & 1) != 0);
+               out_qc = ((counter_b & 2) != 0);
+       }
+} ls93_t;
+
+// TC4024BP
+typedef struct tc4024bp_s {
+       bool in_ck, in_clr;
+       bool out_q5, out_q6;
+       bool tmp_ck;
+       uint8_t counter;
+       void update()
+       {
+               if(in_clr) {
+                       counter = 0;
+               } else if(tmp_ck && !in_ck) {
+                       counter++;
+               }
+               tmp_ck = in_ck;
+               out_q5 = ((counter & 0x10) != 0);
+               out_q6 = ((counter & 0x20) != 0);
+       }
+} tc4024bp_t;
+
 class SUB : public DEVICE
 {
 private:
index 8bc4a62..d1af015 100644 (file)
@@ -357,6 +357,6 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
                        return false;
                }
        }
-       state_fio->StateBuffer(ram, sizeof(ram), 1);
+       state_fio->StateArray(ram, sizeof(ram), 1);
        return true;
 }
index c1d7fad..78c4e56 100644 (file)
@@ -586,61 +586,61 @@ void IO::draw_screen()
        }
 }
 
-#define PROCESS_STATE_74LS74(foo)                              \
-       {                                                                                       \
-               state_fio->StateBool(foo.in_d);                 \
-               state_fio->StateBool(foo.in_ck);                \
-               state_fio->StateBool(foo.in_s);                 \
-               state_fio->StateBool(foo.in_r);                 \
-               state_fio->StateBool(foo.out_q);                \
-               state_fio->StateBool(foo.out_nq);               \
-               state_fio->StateBool(foo.tmp_ck);               \
-       }
+#define STATE_VERSION  3
 
-#define PROCESS_STATE_74LS151(foo)                             \
-       {                                                                                       \
-               state_fio->StateBool(foo.in_d0);                \
-               state_fio->StateBool(foo.in_d1);                \
-               state_fio->StateBool(foo.in_d2);                \
-               state_fio->StateBool(foo.in_d3);                \
-               state_fio->StateBool(foo.in_d4);                \
-               state_fio->StateBool(foo.in_d5);                \
-               state_fio->StateBool(foo.in_d6);                \
-               state_fio->StateBool(foo.in_d7);                \
-               state_fio->StateBool(foo.in_a);                 \
-               state_fio->StateBool(foo.in_b);                 \
-               state_fio->StateBool(foo.in_c);                 \
-               state_fio->StateBool(foo.in_s);                 \
-               state_fio->StateBool(foo.out_y);                \
-               state_fio->StateBool(foo.out_ny);               \
-       }
+void process_state_ls74(ls74_t* val, FILEIO* state_fio)
+{
+       state_fio->StateValue(val->in_d);
+       state_fio->StateValue(val->in_ck);
+       state_fio->StateValue(val->in_s);
+       state_fio->StateValue(val->in_r);
+       state_fio->StateValue(val->out_q);
+       state_fio->StateValue(val->out_nq);
+       state_fio->StateValue(val->tmp_ck);
+}
 
-#define PROCESS_STATE_74LS93(foo)                              \
-       {                                                                                       \
-               state_fio->StateBool(foo.in_a);                 \
-               state_fio->StateBool(foo.in_b);                 \
-               state_fio->StateBool(foo.in_rc1);               \
-               state_fio->StateBool(foo.in_rc2);               \
-               state_fio->StateBool(foo.out_qa);               \
-               state_fio->StateBool(foo.out_qb);               \
-               state_fio->StateBool(foo.out_qc);               \
-               state_fio->StateBool(foo.tmp_a);                \
-               state_fio->StateBool(foo.tmp_b);                \
-               state_fio->StateUint8(foo.counter_a);   \
-               state_fio->StateUint8(foo.counter_b);   \
-       }
+void process_state_ls151(ls151_t* val, FILEIO* state_fio)
+{
+       state_fio->StateValue(val->in_d0);
+       state_fio->StateValue(val->in_d1);
+       state_fio->StateValue(val->in_d2);
+       state_fio->StateValue(val->in_d3);
+       state_fio->StateValue(val->in_d4);
+       state_fio->StateValue(val->in_d5);
+       state_fio->StateValue(val->in_d6);
+       state_fio->StateValue(val->in_d7);
+       state_fio->StateValue(val->in_a);
+       state_fio->StateValue(val->in_b);
+       state_fio->StateValue(val->in_c);
+       state_fio->StateValue(val->in_s);
+       state_fio->StateValue(val->out_y);
+       state_fio->StateValue(val->out_ny);
+}
 
-#define PROCESS_STATE_4024(foo)                        \
-       {                                                                                       \
-               state_fio->StateBool(foo.in_ck);                \
-               state_fio->StateBool(foo.in_clr);               \
-               state_fio->StateBool(foo.out_q5);               \
-               state_fio->StateBool(foo.out_q6);               \
-               state_fio->StateBool(foo.tmp_ck);               \
-               state_fio->StateUint8(foo.counter);             \
-       }
+void process_state_ls93(ls93_t* val, FILEIO* state_fio)
+{
+       state_fio->StateValue(val->in_a);
+       state_fio->StateValue(val->in_b);
+       state_fio->StateValue(val->in_rc1);
+       state_fio->StateValue(val->in_rc2);
+       state_fio->StateValue(val->out_qa);
+       state_fio->StateValue(val->out_qb);
+       state_fio->StateValue(val->out_qc);
+       state_fio->StateValue(val->tmp_a);
+       state_fio->StateValue(val->tmp_b);
+       state_fio->StateValue(val->counter_a);
+       state_fio->StateValue(val->counter_b);
+}
 
-#define STATE_VERSION  4
+void process_state_tc4024bp(tc4024bp_t* val, FILEIO* state_fio)
+{
+       state_fio->StateValue(val->in_ck);
+       state_fio->StateValue(val->in_clr);
+       state_fio->StateValue(val->out_q5);
+       state_fio->StateValue(val->out_q6);
+       state_fio->StateValue(val->tmp_ck);
+       state_fio->StateValue(val->counter);
+}
 
 bool IO::process_state(FILEIO* state_fio, bool loading)
 {
@@ -654,23 +654,22 @@ bool IO::process_state(FILEIO* state_fio, bool loading)
        if(loading) {
                close_tape();
        }
-       //state_fio->StateBuffer(lcd, sizeof(lcd), 1);
-       for(int i = 0; i < 2; i++) {
-               state_fio->StateBuffer(&(lcd[i].ram), 0x400, 1);
-               state_fio->StateInt32(lcd[i].offset);
-               state_fio->StateInt32(lcd[i].cursor);
-       }               
-       state_fio->StateInt32(lcd_status);
-       state_fio->StateInt32(lcd_addr);
-       state_fio->StateBool(lcd_text);
-       state_fio->StateBool(cmt_selected);
-       state_fio->StateUint8(cmt_mode);
-       state_fio->StateBool(cmt_play_ready);
-       state_fio->StateBool(cmt_play_signal);
-       state_fio->StateBool(cmt_rec_ready);
-       state_fio->StateBool(cmt_rec);
-       state_fio->StateBool(cmt_is_wav);
-       state_fio->StateBuffer(cmt_rec_file_path, sizeof(cmt_rec_file_path), 1);
+       for(int i = 0; i < array_length(lcd); i++) {
+               state_fio->StateArray(lcd[i].ram, sizeof(lcd[i].ram), 1);
+               state_fio->StateValue(lcd[i].offset);
+               state_fio->StateValue(lcd[i].cursor);
+       }
+       state_fio->StateValue(lcd_status);
+       state_fio->StateValue(lcd_addr);
+       state_fio->StateValue(lcd_text);
+       state_fio->StateValue(cmt_selected);
+       state_fio->StateValue(cmt_mode);
+       state_fio->StateValue(cmt_play_ready);
+       state_fio->StateValue(cmt_play_signal);
+       state_fio->StateValue(cmt_rec_ready);
+       state_fio->StateValue(cmt_rec);
+       state_fio->StateValue(cmt_is_wav);
+       state_fio->StateArray(cmt_rec_file_path, sizeof(cmt_rec_file_path), 1);
        if(loading) {
                int length_tmp = state_fio->FgetInt32_LE();
                if(cmt_rec) {
@@ -701,27 +700,17 @@ bool IO::process_state(FILEIO* state_fio, bool loading)
                        state_fio->FputInt32_LE(0);
                }
        }
-       state_fio->StateInt32(cmt_bufcnt);
-       state_fio->StateBuffer(cmt_buffer, cmt_bufcnt, 1);
-       state_fio->StateUint8(cmt_clock);
-       
-       //state_fio->StateBuffer(&b16_1, sizeof(b16_1), 1);
-       //state_fio->StateBuffer(&b16_2, sizeof(b16_2), 1);
-       //state_fio->StateBuffer(&g21_1, sizeof(g21_1), 1);
-       //state_fio->StateBuffer(&g21_2, sizeof(g21_2), 1);
-       PROCESS_STATE_74LS74(b16_1);
-       PROCESS_STATE_74LS74(b16_2);
-       PROCESS_STATE_74LS74(g21_1);
-       PROCESS_STATE_74LS74(g21_2);
-       
-       //state_fio->StateBuffer(&c15, sizeof(c15), 1);
-       PROCESS_STATE_74LS151(c15);
-       
-       //state_fio->StateBuffer(&c16, sizeof(c16), 1);
-       PROCESS_STATE_74LS93(c16);
-       //state_fio->StateBuffer(&f21, sizeof(f21), 1);
-       PROCESS_STATE_4024(f21);
-       state_fio->StateUint8(key_column);
+       state_fio->StateValue(cmt_bufcnt);
+       state_fio->StateArray(cmt_buffer, cmt_bufcnt, 1);
+       state_fio->StateValue(cmt_clock);
+       process_state_ls74(&b16_1, state_fio);
+       process_state_ls74(&b16_2, state_fio);
+       process_state_ls74(&g21_1, state_fio);
+       process_state_ls74(&g21_2, state_fio);
+       process_state_ls151(&c15, state_fio);
+       process_state_ls93(&c16, state_fio);
+       process_state_tc4024bp(&f21, state_fio);
+       state_fio->StateValue(key_column);
        return true;
 }
 
index 2631589..33b5a0b 100644 (file)
@@ -821,33 +821,32 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
                state_fio->FputBool(wbank[0x8000 >> 13] == ext);
                state_fio->FputBool(rbank[0x8000 >> 13] == ext);
        }
-       state_fio->StateBuffer(rom, sizeof(rom), 1);
-       state_fio->StateBuffer(ram, sizeof(ram), 1);
-       state_fio->StateBuffer(ext, sizeof(ext), 1);
+       state_fio->StateArray(rom, sizeof(rom), 1);
+//     state_fio->StateArray(ram, sizeof(ram), 1);
+       state_fio->StateArray(ext, sizeof(ext), 1);
        if(!cmd_buf->process_state((void *)state_fio, loading)) {
                return false;
        }
-       state_fio->StateBool(sio_select);
-       state_fio->StateBool(special_cmd_masked);
-       state_fio->StateBuffer(slave_mem, sizeof(slave_mem), 1);
-       //state_fio->StateBuffer(sound, sizeof(sound), 1);
-       for(int i = 0; i < 256; i++) {
-               state_fio->StateDouble(sound[i].freq);
-               state_fio->StateInt32(sound[i].period);
-               state_fio->StateInt32(sound[i].remain);
-       }               
-       state_fio->StateInt32(sound_ptr);
-       state_fio->StateInt32(sound_count);
-       state_fio->StateUint8(sound_reply);
-       state_fio->StateDouble(sound_freq);
-       state_fio->StateBuffer(key_stat, sizeof(key_stat), 1);
-       state_fio->StateBuffer(key_flag, sizeof(key_flag), 1);
-       state_fio->StateInt32(key_data);
-       state_fio->StateInt32(key_strobe);
-       state_fio->StateInt32(key_intmask);
-       state_fio->StateBool(cmt_play);
-       state_fio->StateBool(cmt_rec);
-       state_fio->StateBuffer(cmt_file_path, sizeof(cmt_file_path), 1);
+       state_fio->StateValue(sio_select);
+       state_fio->StateValue(special_cmd_masked);
+       state_fio->StateArray(slave_mem, sizeof(slave_mem), 1);
+       for(int i = 0; i < array_length(sound); i++) {
+               state_fio->StateValue(sound[i].freq);
+               state_fio->StateValue(sound[i].period);
+               state_fio->StateValue(sound[i].remain);
+       }
+       state_fio->StateValue(sound_ptr);
+       state_fio->StateValue(sound_count);
+       state_fio->StateValue(sound_reply);
+       state_fio->StateValue(sound_freq);
+       state_fio->StateArray(key_stat, sizeof(key_stat), 1);
+       state_fio->StateArray(key_flag, sizeof(key_flag), 1);
+       state_fio->StateValue(key_data);
+       state_fio->StateValue(key_strobe);
+       state_fio->StateValue(key_intmask);
+       state_fio->StateValue(cmt_play);
+       state_fio->StateValue(cmt_rec);
+       state_fio->StateArray(cmt_file_path, sizeof(cmt_file_path), 1);
        if(loading) {
                int length_tmp = state_fio->FgetInt32_LE();
                if(cmt_rec) {
@@ -878,19 +877,18 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
                        state_fio->FputInt32_LE(0);
                }
        }
-       state_fio->StateInt32(cmt_count);
-       state_fio->StateBuffer(cmt_buffer, sizeof(cmt_buffer), 1);
-       //state_fio->StateBuffer(lcd, sizeof(lcd), 1);
-       for(int i = 0; i < (sizeof(lcd) / sizeof(lcd_t)); i++) {
-               state_fio->StateBuffer(lcd[i].buffer, 0x80, 1);
-               state_fio->StateInt32(lcd[i].bank);
-               state_fio->StateInt32(lcd[i].addr);
-       }               
-       state_fio->StateUint8(lcd_select);
-       state_fio->StateUint8(lcd_data);
-       state_fio->StateInt32(lcd_clock);
-       state_fio->StateInt32(int_status);
-       state_fio->StateInt32(int_mask);
+       state_fio->StateValue(cmt_count);
+       state_fio->StateArray(cmt_buffer, sizeof(cmt_buffer), 1);
+       for(int i = 0; i < array_length(lcd); i++) {
+               state_fio->StateArray(lcd[i].buffer, sizeof(lcd[i].buffer), 1);
+               state_fio->StateValue(lcd[i].bank);
+               state_fio->StateValue(lcd[i].addr);
+       }
+       state_fio->StateValue(lcd_select);
+       state_fio->StateValue(lcd_data);
+       state_fio->StateValue(lcd_clock);
+       state_fio->StateValue(int_status);
+       state_fio->StateValue(int_mask);
        
        // post process
        if(loading) {
index 0fa2ad9..933ca95 100644 (file)
@@ -318,6 +318,6 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
                        return false;
                }
        }
-       state_fio->StateBuffer(ram, sizeof(ram), 1);
+       state_fio->StateArray(ram, sizeof(ram), 1);
        return true;
 }
index 3b30ddc..522d0be 100644 (file)
@@ -419,162 +419,58 @@ int I286::get_shutdown_flag()
 
 #define STATE_VERSION  5
 
-void I286::process_state_cpustate(FILEIO* state_fio, bool loading)
-{
-#if defined(HAS_I86) || defined(HAS_I88) || defined(HAS_I186) || defined(HAS_V30)
-       struct i8086_state *cpustate = (struct i8086_state *)opaque;
-
-       state_fio->StateBuffer(&(cpustate->regs.b[0]), 16, 1);
-       state_fio->StateUint32(cpustate->pc);
-       state_fio->StateUint32(cpustate->prevpc);
-       for(int i = 0; i < 4; i++) {
-               state_fio->StateUint32(cpustate->base[i]);
-       }
-       for(int i = 0; i < 4; i++) {
-               state_fio->StateUint16(cpustate->sregs[i]);
-       }
-       state_fio->StateUint16(cpustate->flags);
-       state_fio->StateInt32(cpustate->AuxVal);
-       state_fio->StateInt32(cpustate->OverVal);
-       state_fio->StateInt32(cpustate->SignVal);
-       state_fio->StateInt32(cpustate->ZeroVal);
-       state_fio->StateInt32(cpustate->CarryVal);
-       state_fio->StateInt32(cpustate->DirVal);
-       state_fio->StateUint8(cpustate->ParityVal);
-       state_fio->StateUint8(cpustate->TF);
-       state_fio->StateUint8(cpustate->IF);
-       state_fio->StateUint8(cpustate->MF);
-       
-       state_fio->StateUint8(cpustate->int_vector);
-       state_fio->StateInt8(cpustate->nmi_state);
-       state_fio->StateInt8(cpustate->irq_state);
-       state_fio->StateInt8(cpustate->test_state);
-       state_fio->StateUint8(cpustate->rep_in_progress);
-       state_fio->StateInt32(cpustate->extra_cycles);
-
-       state_fio->StateInt32(cpustate->halted);
-       state_fio->StateInt32(cpustate->busreq);
-
-       state_fio->StateUint16(cpustate->ip);
-       state_fio->StateUint32(cpustate->sp);
-
-  #ifdef USE_DEBUGGER
-       state_fio->StateUint64(cpustate->total_icount);
-  #endif
-       state_fio->StateInt32(cpustate->icount);
-
-       state_fio->StateUint8(cpustate->seg_prefix);
-       state_fio->StateUint8(cpustate->prefix_seg);
-       state_fio->StateUint32(cpustate->ea);
-       state_fio->StateUint16(cpustate->eo);
-       state_fio->StateUint8(cpustate->ea_seg);
-
-#elif defined(HAS_I286)
-
-       struct i80286_state *cpustate = (struct i80286_state *)opaque;
-
-       state_fio->StateBuffer(&(cpustate->regs.b[0]), 16, 1);
-       state_fio->StateUint32(cpustate->amask);
-       state_fio->StateUint32(cpustate->pc);
-       state_fio->StateUint32(cpustate->prevpc);
-       state_fio->StateUint16(cpustate->flags);
-       state_fio->StateUint16(cpustate->msw);
-       for(int i = 0; i < 4; i++) {
-               state_fio->StateUint32(cpustate->base[i]);
-       }
-       for(int i = 0; i < 4; i++) {
-               state_fio->StateUint16(cpustate->sregs[i]);
-       }
-       for(int i = 0; i < 4; i++) {
-               state_fio->StateUint16(cpustate->limit[i]);
-       }
-       state_fio->StateBuffer(cpustate->rights, 4, 1);
-       for(int i = 0; i < 4; i++) {
-               state_fio->StateBool(cpustate->valid[i]);
-       }
-       state_fio->StateUint32(cpustate->gdtr.base);
-       state_fio->StateUint16(cpustate->gdtr.limit);
-
-       state_fio->StateUint32(cpustate->idtr.base);
-       state_fio->StateUint16(cpustate->idtr.limit);
-
-       state_fio->StateUint16(cpustate->ldtr.sel);
-       state_fio->StateUint32(cpustate->ldtr.base);
-       state_fio->StateUint16(cpustate->ldtr.limit);
-       state_fio->StateUint8(cpustate->ldtr.rights);
-       
-       state_fio->StateUint16(cpustate->tr.sel);
-       state_fio->StateUint32(cpustate->tr.base);
-       state_fio->StateUint16(cpustate->tr.limit);
-       state_fio->StateUint8(cpustate->tr.rights);
-
-       
-       state_fio->StateInt32(cpustate->AuxVal);
-       state_fio->StateInt32(cpustate->OverVal);
-       state_fio->StateInt32(cpustate->SignVal);
-       state_fio->StateInt32(cpustate->ZeroVal);
-       state_fio->StateInt32(cpustate->CarryVal);
-       state_fio->StateInt32(cpustate->DirVal);
-       state_fio->StateUint8(cpustate->ParityVal);
-       state_fio->StateUint8(cpustate->TF);
-       state_fio->StateUint8(cpustate->IF);
-       state_fio->StateUint8(cpustate->MF);
-       
-       state_fio->StateInt8(cpustate->nmi_state);
-       state_fio->StateInt8(cpustate->irq_state);
-       state_fio->StateInt8(cpustate->test_state);
-       state_fio->StateUint8(cpustate->rep_in_progress);
-       state_fio->StateInt32(cpustate->extra_cycles);
-
-       state_fio->StateInt32(cpustate->halted);
-       state_fio->StateInt32(cpustate->busreq);
-       state_fio->StateInt32(cpustate->trap_level);
-       state_fio->StateInt32(cpustate->shutdown);
-
-  #ifdef USE_DEBUGGER
-       state_fio->StateUint64(cpustate->total_icount);
-  #endif
-       state_fio->StateInt32(cpustate->icount);
-
-       state_fio->StateUint8(cpustate->seg_prefix);
-       state_fio->StateUint8(cpustate->prefix_seg);
-       state_fio->StateUint32(cpustate->ea);
-       state_fio->StateUint16(cpustate->eo);
-       state_fio->StateUint8(cpustate->ea_seg);
-#endif
-}
-
 bool I286::process_state(FILEIO* state_fio, bool loading)
 {
+       cpu_state *cpustate = (cpu_state *)opaque;
+       
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
        }
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       //state_fio->StateBuffer(opaque, sizeof(cpu_state), 1);
-       process_state_cpustate(state_fio, loading);
-       
-       // post process
-       if(loading) {
-               cpu_state *cpustate = (cpu_state *)opaque;
-               cpustate->pic = d_pic;
-               cpustate->program = d_mem;
-               cpustate->io = d_io;
-#ifdef I86_PSEUDO_BIOS
-               cpustate->bios = d_bios;
-#endif
-#ifdef SINGLE_MODE_DMA
-               cpustate->dma = d_dma;
+       state_fio->StateArray(cpustate->regs.w, sizeof(cpustate->regs.w), 1);
+       state_fio->StateValue(cpustate->pc);
+       state_fio->StateValue(cpustate->prevpc);
+       state_fio->StateArray(cpustate->base, sizeof(cpustate->base), 1);
+       state_fio->StateArray(cpustate->sregs, sizeof(cpustate->sregs), 1);
+       state_fio->StateValue(cpustate->flags);
+       state_fio->StateValue(cpustate->AuxVal);
+       state_fio->StateValue(cpustate->OverVal);
+       state_fio->StateValue(cpustate->SignVal);
+       state_fio->StateValue(cpustate->ZeroVal);
+       state_fio->StateValue(cpustate->CarryVal);
+       state_fio->StateValue(cpustate->DirVal);
+       state_fio->StateValue(cpustate->ParityVal);
+       state_fio->StateValue(cpustate->TF);
+       state_fio->StateValue(cpustate->IF);
+       state_fio->StateValue(cpustate->MF);
+       state_fio->StateValue(cpustate->int_vector);
+       state_fio->StateValue(cpustate->nmi_state);
+       state_fio->StateValue(cpustate->irq_state);
+       state_fio->StateValue(cpustate->test_state);
+       state_fio->StateValue(cpustate->rep_in_progress);
+       state_fio->StateValue(cpustate->extra_cycles);
+       state_fio->StateValue(cpustate->halted);
+       state_fio->StateValue(cpustate->busreq);
+       state_fio->StateValue(cpustate->ip);
+       state_fio->StateValue(cpustate->sp);
+#ifdef USE_DEBUGGER
+       state_fio->StateValue(cpustate->total_icount);
 #endif
+       state_fio->StateValue(cpustate->icount);
+       state_fio->StateValue(cpustate->seg_prefix);
+       state_fio->StateValue(cpustate->prefix_seg);
+       state_fio->StateValue(cpustate->ea);
+       state_fio->StateValue(cpustate->eo);
+       state_fio->StateValue(cpustate->ea_seg);
+       
 #ifdef USE_DEBUGGER
-               cpustate->emu = emu;
-               cpustate->debugger = d_debugger;
-               cpustate->program_stored = d_mem;
-               cpustate->io_stored = d_io;
+       // post process
+       if(loading) {
                cpustate->prev_total_icount = cpustate->total_icount;
-#endif
        }
+#endif
        return true;
 }
 
index fd61368..f31d4f3 100644 (file)
@@ -105,7 +105,6 @@ public:
        void get_debug_regs_info(_TCHAR *buffer, size_t buffer_len);
        int debug_dasm(uint32_t pc, _TCHAR *buffer, size_t buffer_len);
 #endif
-       void process_state_cpustate(FILEIO* state_fio, bool loading);
        bool process_state(FILEIO* state_fio, bool loading);
        
        // unique function
index 36d305a..94b2509 100644 (file)
@@ -386,7 +386,7 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
                        return false;
                }
        }
-       state_fio->StateBuffer(ram, sizeof(ram), 1);
+       state_fio->StateArray(ram, sizeof(ram), 1);
        return true;
 }
 
index 7d7cb1d..7e8958b 100644 (file)
@@ -363,8 +363,8 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
                }
        }
        // Machine specified.
-       state_fio->StateBuffer(ram, sizeof(ram), 1);
-       state_fio->StateBuffer(ext, sizeof(ext), 1);
-       state_fio->StateBool(inserted);
+       state_fio->StateArray(ram, sizeof(ram), 1);
+       state_fio->StateArray(ext, sizeof(ext), 1);
+       state_fio->StateValue(inserted);
        return true;
 }
index 60b4a92..c6198c4 100644 (file)
@@ -1702,245 +1702,61 @@ bool CRTC::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateBool(scan_line);
-       state_fio->StateBool(scan_tmp);
-       state_fio->StateBool(monitor_200line);
-       state_fio->StateBool(monitor_digital);
-       state_fio->StateBool(monitor_tmp);
-       state_fio->StateUint8(textreg_num);
-       state_fio->StateBuffer(textreg, sizeof(textreg), 1);
-       state_fio->StateUint8(cgreg_num);
-       state_fio->StateBuffer(cgreg, sizeof(cgreg), 1);
-       state_fio->StateUint8(scrn_size);
-       state_fio->StateUint8(cg_mask);
-       state_fio->StateUint8(cg_mask256);
-       state_fio->StateBool(cg_mask256_init);
-       state_fio->StateBool(font_size);
-       state_fio->StateBool(column_size);
-       state_fio->StateBuffer(latch, sizeof(latch), 1);
-       state_fio->StateUint16(GDEVS);
-       state_fio->StateUint16(GDEVE);
-       state_fio->StateUint8(GDEHS);
-       state_fio->StateUint8(GDEHE);
-       state_fio->StateInt32(GDEHSC);
-       state_fio->StateInt32(GDEHEC);
-       state_fio->StateBool(hblank);
-       state_fio->StateBool(vblank);
-       state_fio->StateBool(blink);
-       state_fio->StateUint8(clear_flag);
-       state_fio->StateBuffer(palette_reg, sizeof(palette_reg), 1);
-       state_fio->StateBool(pal_select);
-       state_fio->StateBool(screen_mask);
-       state_fio->StateBuffer(priority16, sizeof(priority16), 1);
-       //state_fio->StateBuffer(palette16, sizeof(palette16), 1);
-       for(int i = 0; i < (sizeof(palette16) / sizeof(scrntype_t)); i++) {
-               if(loading) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette16[i] = RGB_COLOR(r, g, b);
-               } else {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette16[i]);
-                       g = G_OF_COLOR(palette16[i]);
-                       b = B_OF_COLOR(palette16[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       //state_fio->StateBuffer(palette4096, sizeof(palette4096), 1);
-       for(int i = 0; i < (sizeof(palette4096) / sizeof(scrntype_t)); i++) {
-               if(loading) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette4096[i] = RGB_COLOR(r, g, b);
-               } else {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette4096[i]);
-                       g = G_OF_COLOR(palette4096[i]);
-                       b = B_OF_COLOR(palette4096[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       state_fio->StateBuffer(palette4096r, sizeof(palette4096r), 1);
-       state_fio->StateBuffer(palette4096g, sizeof(palette4096g), 1);
-       state_fio->StateBuffer(palette4096b, sizeof(palette4096b), 1);
-       //state_fio->StateBuffer(palette16txt, sizeof(palette16txt), 1);
-       for(int i = 0; i < (sizeof(palette16txt) / sizeof(scrntype_t)); i++) {
-               if(loading) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette16txt[i] = RGB_COLOR(r, g, b);
-               } else {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette16txt[i]);
-                       g = G_OF_COLOR(palette16txt[i]);
-                       b = B_OF_COLOR(palette16txt[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       //state_fio->StateBuffer(palette4096txt, sizeof(palette4096txt), 1);
-       for(int i = 0; i < (sizeof(palette4096txt) / sizeof(scrntype_t)); i++) {
-               if(loading) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette4096txt[i] = RGB_COLOR(r, g, b);
-               } else {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette4096txt[i]);
-                       g = G_OF_COLOR(palette4096txt[i]);
-                       b = B_OF_COLOR(palette4096txt[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       //state_fio->StateBuffer(palette16pri, sizeof(palette16pri), 1);
-       for(int i = 0; i < 16; i++) {
-               for(int j = 0; j < 9; j++) {
-                       if(loading) {
-                               uint8_t r, g, b;
-                               r = state_fio->FgetUint8();
-                               g = state_fio->FgetUint8();
-                               b = state_fio->FgetUint8();
-                               palette16pri[i][j] = RGB_COLOR(r, g, b);
-                       } else {
-                               uint8_t r, g, b;
-                               r = R_OF_COLOR(palette16pri[i][j]);
-                               g = G_OF_COLOR(palette16pri[i][j]);
-                               b = B_OF_COLOR(palette16pri[i][j]);
-                               state_fio->FputUint8(r);
-                               state_fio->FputUint8(g);
-                               state_fio->FputUint8(b);
-                       }
-               }
-       }
-       //state_fio->StateBuffer(palette4096pri, sizeof(palette4096pri), 1);
-       for(int i = 0; i < 16; i++) {
-               for(int j = 0; j < 9; j++) {
-                       if(loading) {
-                               uint8_t r, g, b;
-                               r = state_fio->FgetUint8();
-                               g = state_fio->FgetUint8();
-                               b = state_fio->FgetUint8();
-                               palette4096pri[i][j] = RGB_COLOR(r, g, b);
-                       } else {
-                               uint8_t r, g, b;
-                               r = R_OF_COLOR(palette4096pri[i][j]);
-                               g = G_OF_COLOR(palette4096pri[i][j]);
-                               b = B_OF_COLOR(palette4096pri[i][j]);
-                               state_fio->FputUint8(r);
-                               state_fio->FputUint8(g);
-                               state_fio->FputUint8(b);
-                       }
-               }
-       }
-
-       state_fio->StateUint8(prev16);
-       state_fio->StateBool(update16);
-       //state_fio->StateBuffer(priority256, sizeof(priority256), 1);
-       for(int i = 0; i < 256; i++) {
-               for(int j = 0; j < (16 + 64); j++) {
-                       state_fio->StateUint16(priority256[i][j]);
-               }
-       }
-       //state_fio->StateBuffer(palette256, sizeof(palette256), 1);
-       for(int i = 0; i < (sizeof(palette256) / sizeof(scrntype_t)); i++) {
-               if(loading) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette256[i] = RGB_COLOR(r, g, b);
-               } else {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette256[i]);
-                       g = G_OF_COLOR(palette256[i]);
-                       b = B_OF_COLOR(palette256[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       //state_fio->StateBuffer(palette256txt, sizeof(palette256txt), 1);
-       for(int i = 0; i < (sizeof(palette256txt) / sizeof(scrntype_t)); i++) {
-               if(loading) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette256txt[i] = RGB_COLOR(r, g, b);
-               } else {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette256txt[i]);
-                       g = G_OF_COLOR(palette256txt[i]);
-                       b = B_OF_COLOR(palette256txt[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       //state_fio->StateBuffer(palette256pri, sizeof(palette256pri), 1);
-       for(int i = 0; i < 256; i++) {
-               for(int j = 0; j < (16 + 64); j++) {
-                       if(loading) {
-                               uint8_t r, g, b;
-                               r = state_fio->FgetUint8();
-                               g = state_fio->FgetUint8();
-                               b = state_fio->FgetUint8();
-                               palette256pri[i][j] = RGB_COLOR(r, g, b);
-                       } else {
-                               uint8_t r, g, b;
-                               r = R_OF_COLOR(palette256pri[i][j]);
-                               g = G_OF_COLOR(palette256pri[i][j]);
-                               b = B_OF_COLOR(palette256pri[i][j]);
-                               state_fio->FputUint8(r);
-                               state_fio->FputUint8(g);
-                               state_fio->FputUint8(b);
-                       }
-               }
-       }
-       //state_fio->StateUint32((uint32_t)prev256);
-       if(loading) {
-               uint8_t r, g, b;
-               r = state_fio->FgetUint8();
-               g = state_fio->FgetUint8();
-               b = state_fio->FgetUint8();
-               prev256 = RGB_COLOR(r, g, b);
-       } else {
-               uint8_t r, g, b;
-               r = R_OF_COLOR(prev256);
-               g = G_OF_COLOR(prev256);
-               b = B_OF_COLOR(prev256);
-               state_fio->FputUint8(r);
-               state_fio->FputUint8(g);
-               state_fio->FputUint8(b);
-       }
-       state_fio->StateBool(update256);
-       //state_fio->StateBuffer(map_addr, sizeof(map_addr), 1);
-       for(int i = 0; i < 400; i++) {
-               for(int j = 0; j < 80; j++) {
-                       state_fio->StateUint16(map_addr[i][j]);
-               }
-       }
-       state_fio->StateBuffer(map_hdsc, sizeof(map_hdsc), 1);
-       state_fio->StateBuffer(text_matrix, sizeof(text_matrix), 1);
-       state_fio->StateBuffer(text_matrixw, sizeof(text_matrixw), 1);
-       state_fio->StateUint8(trans_color);
-       state_fio->StateBool(map_init);
-       state_fio->StateBool(trans_init);
+       state_fio->StateValue(scan_line);
+       state_fio->StateValue(scan_tmp);
+       state_fio->StateValue(monitor_200line);
+       state_fio->StateValue(monitor_digital);
+       state_fio->StateValue(monitor_tmp);
+       state_fio->StateValue(textreg_num);
+       state_fio->StateArray(textreg, sizeof(textreg), 1);
+       state_fio->StateValue(cgreg_num);
+       state_fio->StateArray(cgreg, sizeof(cgreg), 1);
+       state_fio->StateValue(scrn_size);
+       state_fio->StateValue(cg_mask);
+       state_fio->StateValue(cg_mask256);
+       state_fio->StateValue(cg_mask256_init);
+       state_fio->StateValue(font_size);
+       state_fio->StateValue(column_size);
+       state_fio->StateArray(latch, sizeof(latch), 1);
+       state_fio->StateValue(GDEVS);
+       state_fio->StateValue(GDEVE);
+       state_fio->StateValue(GDEHS);
+       state_fio->StateValue(GDEHE);
+       state_fio->StateValue(GDEHSC);
+       state_fio->StateValue(GDEHEC);
+       state_fio->StateValue(hblank);
+       state_fio->StateValue(vblank);
+       state_fio->StateValue(blink);
+       state_fio->StateValue(clear_flag);
+       state_fio->StateArray(palette_reg, sizeof(palette_reg), 1);
+       state_fio->StateValue(pal_select);
+       state_fio->StateValue(screen_mask);
+       state_fio->StateArray(&priority16[0][0], sizeof(priority16), 1);
+       state_fio->StateArrayScrnType_t(palette16, sizeof(palette16), 1);
+       state_fio->StateArrayScrnType_t(palette4096, sizeof(palette4096), 1);
+       state_fio->StateArray(palette4096r, sizeof(palette4096r), 1);
+       state_fio->StateArray(palette4096g, sizeof(palette4096g), 1);
+       state_fio->StateArray(palette4096b, sizeof(palette4096b), 1);
+       state_fio->StateArrayScrnType_t(palette16txt, sizeof(palette16txt), 1);
+       state_fio->StateArrayScrnType_t(palette4096txt, sizeof(palette4096txt), 1);
+       state_fio->StateArrayScrnType_t(&palette16pri[0][0], sizeof(palette16pri), 1);
+       state_fio->StateArrayScrnType_t(&palette4096pri[0][0], sizeof(palette4096pri), 1);
+       state_fio->StateValue(prev16);
+       state_fio->StateValue(update16);
+       state_fio->StateArray(&priority256[0][0], sizeof(priority256), 1);
+       state_fio->StateArrayScrnType_t(palette256, sizeof(palette256), 1);
+       state_fio->StateArrayScrnType_t(palette256txt, sizeof(palette256txt), 1);
+       state_fio->StateArrayScrnType_t(&palette256pri[0][0], sizeof(palette256pri), 1);
+//     state_fio->StateValue((uint32_t)prev256);
+       state_fio->StateValueScrnType_t(prev256);
+       state_fio->StateValue(update256);
+       state_fio->StateArray(&map_addr[0][0], sizeof(map_addr), 1);
+       state_fio->StateArray(&map_hdsc[0][0], sizeof(map_hdsc), 1);
+       state_fio->StateArray(&text_matrix[0][0][0], sizeof(text_matrix), 1);
+       state_fio->StateArray(&text_matrixw[0][0][0], sizeof(text_matrixw), 1);
+       state_fio->StateValue(trans_color);
+       state_fio->StateValue(map_init);
+       state_fio->StateValue(trans_init);
        return true;
 }
 
index ae425eb..e8c7ddf 100644 (file)
@@ -181,18 +181,17 @@ bool INTERRUPT::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateUint8(select);
-       //state_fio->StateBuffer(irq, sizeof(irq), 1);
-       for(int i = 0; i < 4; i++) {
-               state_fio->StateUint8(irq[i].vector);
-               state_fio->StateBool(irq[i].enb_intr);
-               state_fio->StateBool(irq[i].req_intr);
-               state_fio->StateBool(irq[i].in_service);
+       state_fio->StateValue(select);
+       for(int i = 0; i < array_length(irq); i++) {
+               state_fio->StateValue(irq[i].vector);
+               state_fio->StateValue(irq[i].enb_intr);
+               state_fio->StateValue(irq[i].req_intr);
+               state_fio->StateValue(irq[i].in_service);
        }
-       state_fio->StateInt32(req_intr_ch);
-       state_fio->StateBool(iei);
-       state_fio->StateBool(oei);
-       state_fio->StateUint32(intr_bit);
+       state_fio->StateValue(req_intr_ch);
+       state_fio->StateValue(iei);
+       state_fio->StateValue(oei);
+       state_fio->StateValue(intr_bit);
        return true;
 }
 
index 7eb515e..4bd816d 100644 (file)
@@ -635,6 +635,6 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
                }
        }
        // Machine specified.
-       state_fio->StateInt32(monitor_type);
+       state_fio->StateValue(monitor_type);
        return true;
 }
index 909e0cb..bd59fc6 100644 (file)
@@ -1327,161 +1327,50 @@ bool CRTC::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateUint8(textreg_num);
-       state_fio->StateBuffer(textreg, sizeof(textreg), 1);
-       state_fio->StateBuffer(rmwreg_num, sizeof(rmwreg_num), 1);
-       state_fio->StateBuffer(rmwreg, sizeof(rmwreg), 1);
-       state_fio->StateUint8(cgreg_num);
-       state_fio->StateBuffer(cgreg, sizeof(cgreg), 1);
-       state_fio->StateUint8(scrn_size);
-       state_fio->StateUint8(cg_mask);
-       state_fio->StateBool(font_size);
-       state_fio->StateBool(column_size);
-       state_fio->StateBuffer(latch, sizeof(latch), 1);
-       state_fio->StateUint16(GDEVS);
-       state_fio->StateUint16(GDEVE);
-       state_fio->StateUint8(GDEHS);
-       state_fio->StateUint8(GDEHE);
-       state_fio->StateInt32(GDEHSC);
-       state_fio->StateInt32(GDEHEC);
-       state_fio->StateBool(blank);
-       state_fio->StateBool(hblank);
-       state_fio->StateBool(vblank);
-       state_fio->StateBool(blink);
-       state_fio->StateUint8(clear_flag);
-       state_fio->StateBuffer(palette_reg, sizeof(palette_reg), 1);
-       state_fio->StateBool(pal_select);
-       state_fio->StateBool(screen_mask);
-       state_fio->StateBuffer(priority16, sizeof(priority16), 1);
-       //state_fio->StateBuffer(palette16, sizeof(palette16), 1);
-       for(int i = 0; i < (sizeof(palette16) / sizeof(scrntype_t)); i++) {
-               if(loading) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette16[i] = RGB_COLOR(r, g, b);
-               } else {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette16[i]);
-                       g = G_OF_COLOR(palette16[i]);
-                       b = B_OF_COLOR(palette16[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       //state_fio->StateBuffer(palette4096, sizeof(palette4096), 1);
-       for(int i = 0; i < (sizeof(palette4096) / sizeof(scrntype_t)); i++) {
-               if(loading) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette4096[i] = RGB_COLOR(r, g, b);
-               } else {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette4096[i]);
-                       g = G_OF_COLOR(palette4096[i]);
-                       b = B_OF_COLOR(palette4096[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       state_fio->StateBuffer(palette4096r, sizeof(palette4096r), 1);
-       state_fio->StateBuffer(palette4096g, sizeof(palette4096g), 1);
-       state_fio->StateBuffer(palette4096b, sizeof(palette4096b), 1);
-       //state_fio->StateBuffer(palette16txt, sizeof(palette16txt), 1);
-       for(int i = 0; i < (sizeof(palette16txt) / sizeof(scrntype_t)); i++) {
-               if(loading) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette16txt[i] = RGB_COLOR(r, g, b);
-               } else {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette16txt[i]);
-                       g = G_OF_COLOR(palette16txt[i]);
-                       b = B_OF_COLOR(palette16txt[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       //state_fio->StateBuffer(palette4096txt, sizeof(palette4096txt), 1);
-       for(int i = 0; i < (sizeof(palette4096txt) / sizeof(scrntype_t)); i++) {
-               if(loading) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette4096txt[i] = RGB_COLOR(r, g, b);
-               } else {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette4096txt[i]);
-                       g = G_OF_COLOR(palette4096txt[i]);
-                       b = B_OF_COLOR(palette4096txt[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       //state_fio->StateBuffer(palette16pri, sizeof(palette16pri), 1);
-       for(int i = 0; i < 16; i++) {
-               for(int j = 0; j < 9; j++) {
-                       if(loading) {
-                               uint8_t r, g, b;
-                               r = state_fio->FgetUint8();
-                               g = state_fio->FgetUint8();
-                               b = state_fio->FgetUint8();
-                               palette16pri[i][j] = RGB_COLOR(r, g, b);
-                       } else {
-                               uint8_t r, g, b;
-                               r = R_OF_COLOR(palette16pri[i][j]);
-                               g = G_OF_COLOR(palette16pri[i][j]);
-                               b = B_OF_COLOR(palette16pri[i][j]);
-                               state_fio->FputUint8(r);
-                               state_fio->FputUint8(g);
-                               state_fio->FputUint8(b);
-                       }
-               }
-       }
-       //state_fio->StateBuffer(palette4096pri, sizeof(palette4096pri), 1);
-       for(int i = 0; i < 16; i++) {
-               for(int j = 0; j < 9; j++) {
-                       if(loading) {
-                               uint8_t r, g, b;
-                               r = state_fio->FgetUint8();
-                               g = state_fio->FgetUint8();
-                               b = state_fio->FgetUint8();
-                               palette4096pri[i][j] = RGB_COLOR(r, g, b);
-                       } else {
-                               uint8_t r, g, b;
-                               r = R_OF_COLOR(palette4096pri[i][j]);
-                               g = G_OF_COLOR(palette4096pri[i][j]);
-                               b = B_OF_COLOR(palette4096pri[i][j]);
-                               state_fio->FputUint8(r);
-                               state_fio->FputUint8(g);
-                               state_fio->FputUint8(b);
-                       }
-               }
-       }
-       state_fio->StateUint8(prev16);
-       state_fio->StateBool(update16);
-       //state_fio->StateBuffer(map_addr, sizeof(map_addr), 1);
-       for(int i = 0; i < 400; i++) {
-               for(int j = 0; j < 80; j++) {
-                       state_fio->StateUint32(map_addr[i][j]);
-               }
-       }
-       state_fio->StateBuffer(map_hdsc, sizeof(map_hdsc), 1);
-       state_fio->StateBuffer(text_matrix, sizeof(text_matrix), 1);
-       state_fio->StateBuffer(text_matrixw, sizeof(text_matrixw), 1);
-       state_fio->StateUint8(trans_color);
-       state_fio->StateBool(map_init);
-       state_fio->StateBool(trans_init);
+       state_fio->StateValue(textreg_num);
+       state_fio->StateArray(textreg, sizeof(textreg), 1);
+       state_fio->StateArray(rmwreg_num, sizeof(rmwreg_num), 1);
+       state_fio->StateArray(&rmwreg[0][0], sizeof(rmwreg), 1);
+       state_fio->StateValue(cgreg_num);
+       state_fio->StateArray(cgreg, sizeof(cgreg), 1);
+       state_fio->StateValue(scrn_size);
+       state_fio->StateValue(cg_mask);
+       state_fio->StateValue(font_size);
+       state_fio->StateValue(column_size);
+       state_fio->StateArray(&latch[0][0], sizeof(latch), 1);
+       state_fio->StateValue(GDEVS);
+       state_fio->StateValue(GDEVE);
+       state_fio->StateValue(GDEHS);
+       state_fio->StateValue(GDEHE);
+       state_fio->StateValue(GDEHSC);
+       state_fio->StateValue(GDEHEC);
+       state_fio->StateValue(blank);
+       state_fio->StateValue(hblank);
+       state_fio->StateValue(vblank);
+       state_fio->StateValue(blink);
+       state_fio->StateValue(clear_flag);
+       state_fio->StateArray(palette_reg, sizeof(palette_reg), 1);
+       state_fio->StateValue(pal_select);
+       state_fio->StateValue(screen_mask);
+       state_fio->StateArray(&priority16[0][0], sizeof(priority16), 1);
+       state_fio->StateArrayScrnType_t(palette16, sizeof(palette16), 1);
+       state_fio->StateArrayScrnType_t(palette4096, sizeof(palette4096), 1);
+       state_fio->StateArray(palette4096r, sizeof(palette4096r), 1);
+       state_fio->StateArray(palette4096g, sizeof(palette4096g), 1);
+       state_fio->StateArray(palette4096b, sizeof(palette4096b), 1);
+       state_fio->StateArrayScrnType_t(palette16txt, sizeof(palette16txt), 1);
+       state_fio->StateArrayScrnType_t(palette4096txt, sizeof(palette4096txt), 1);
+       state_fio->StateArrayScrnType_t(&palette16pri[0][0], sizeof(palette16pri), 1);
+       state_fio->StateArrayScrnType_t(&palette4096pri[0][0], sizeof(palette4096pri), 1);
+       state_fio->StateValue(prev16);
+       state_fio->StateValue(update16);
+       state_fio->StateArray(&map_addr[0][0], sizeof(map_addr), 1);
+       state_fio->StateArray(&map_hdsc[0][0], sizeof(map_hdsc), 1);
+       state_fio->StateArray(&text_matrix[0][0][0], sizeof(text_matrix), 1);
+       state_fio->StateArray(&text_matrixw[0][0][0], sizeof(text_matrixw), 1);
+       state_fio->StateValue(trans_color);
+       state_fio->StateValue(map_init);
+       state_fio->StateValue(trans_init);
        return true;
 }
 
index a888ccc..aa7bb49 100644 (file)
@@ -497,6 +497,6 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
                }
        }
        // Machine specified.
-       state_fio->StateUint8(halt);
+       state_fio->StateValue(halt);
        return true;
 }
index b3bfcc6..43526f0 100644 (file)
@@ -510,41 +510,18 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       //state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
-       for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
-               if(loading) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette_pc[i] = RGB_COLOR(r, g, b);
-               } else {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette_pc[i]);
-                       g = G_OF_COLOR(palette_pc[i]);
-                       b = B_OF_COLOR(palette_pc[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       state_fio->StateBuffer(palette, sizeof(palette), 1);
-       state_fio->StateBuffer(back, sizeof(back), 1);
-       state_fio->StateBuffer(reverse, sizeof(reverse), 1);
-       state_fio->StateUint8(rno);
-       state_fio->StateBuffer(wregs, sizeof(wregs), 1);
-       //state_fio->StateBuffer(pri, sizeof(pri), 1);
-       for(int i = 0; i < (sizeof(pri) / sizeof(int)); i++) {
-               state_fio->StateInt32(pri[i]);
-       }
-       //state_fio->StateBuffer(vma, sizeof(vma), 1);
-       for(int i = 0; i < (sizeof(vma) / sizeof(int)); i++) {
-               state_fio->StateInt32(vma[i]);
-       }
-       state_fio->StateBuffer(vds, sizeof(vds), 1);
-       state_fio->StateUint8(mode_r);
-       state_fio->StateUint8(mode_c);
-       state_fio->StateUint8(mode_p);
+       state_fio->StateArrayScrnType_t(palette_pc, sizeof(palette_pc), 1);
+       state_fio->StateArray(palette, sizeof(palette), 1);
+       state_fio->StateArray(back, sizeof(back), 1);
+       state_fio->StateArray(reverse, sizeof(reverse), 1);
+       state_fio->StateValue(rno);
+       state_fio->StateArray(wregs, sizeof(wregs), 1);
+       state_fio->StateArray(pri, sizeof(pri), 1);
+       state_fio->StateArray(vma, sizeof(vma), 1);
+       state_fio->StateArray(vds, sizeof(vds), 1);
+       state_fio->StateValue(mode_r);
+       state_fio->StateValue(mode_c);
+       state_fio->StateValue(mode_p);
        return true;
 }
 
index daa4e89..aee7f44 100644 (file)
@@ -1085,93 +1085,55 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
                return false;
        }
 #if defined(_MZ700)
-       state_fio->StateBuffer(pcg + 0x400, 0x400, 1);
-       state_fio->StateBuffer(pcg + 0xc00, 0x400, 1);
+       state_fio->StateArray(pcg + 0x400, 0x400, 1);
+       state_fio->StateArray(pcg + 0xc00, 0x400, 1);
 #elif defined(_MZ1500)
-       state_fio->StateBuffer(pcg, sizeof(pcg), 1);
+       state_fio->StateArray(pcg, sizeof(pcg), 1);
 #endif
-       state_fio->StateBuffer(ram, sizeof(ram), 1);
-       state_fio->StateBuffer(vram, sizeof(vram), 1);
-       state_fio->StateUint8(mem_bank);
+       state_fio->StateArray(ram, sizeof(ram), 1);
+       state_fio->StateArray(vram, sizeof(vram), 1);
+       state_fio->StateValue(mem_bank);
 #if defined(_MZ700)
-       state_fio->StateUint8(pcg_data);
-       state_fio->StateUint8(pcg_addr);
-       state_fio->StateUint8(pcg_ctrl);
+       state_fio->StateValue(pcg_data);
+       state_fio->StateValue(pcg_addr);
+       state_fio->StateValue(pcg_ctrl);
 #elif defined(_MZ800)
-       state_fio->StateUint8(wf);
-       state_fio->StateUint8(rf);
-       state_fio->StateUint8(dmd);
-       state_fio->StateUint32(vram_addr_top);
-       state_fio->StateBool(is_mz800);
+       state_fio->StateValue(wf);
+       state_fio->StateValue(rf);
+       state_fio->StateValue(dmd);
+       state_fio->StateValue(vram_addr_top);
+       state_fio->StateValue(is_mz800);
 #elif defined(_MZ1500)
-       state_fio->StateUint8(pcg_bank);
+       state_fio->StateValue(pcg_bank);
 #endif
 #if defined(_MZ800)
-       state_fio->StateUint16(sof);
-       state_fio->StateUint8(sw);
-       state_fio->StateUint8(ssa);
-       state_fio->StateUint8(sea);
-       state_fio->StateUint8(palette_sw);
-       state_fio->StateBuffer(palette, sizeof(palette), 1);
-       state_fio->StateBuffer(palette16, sizeof(palette16), 1);
+       state_fio->StateValue(sof);
+       state_fio->StateValue(sw);
+       state_fio->StateValue(ssa);
+       state_fio->StateValue(sea);
+       state_fio->StateValue(palette_sw);
+       state_fio->StateArray(palette, sizeof(palette), 1);
+       state_fio->StateArray(palette16, sizeof(palette16), 1);
 #elif defined(_MZ1500)
-       state_fio->StateUint8(priority);
-       state_fio->StateBuffer(palette, sizeof(palette), 1);
+       state_fio->StateValue(priority);
+       state_fio->StateArray(palette, sizeof(palette), 1);
 #endif
-       state_fio->StateBool(blink);
-       state_fio->StateBool(tempo);
-       state_fio->StateBool(hblank);
-       state_fio->StateBool(hsync);
-       state_fio->StateBool(vblank);
-       state_fio->StateBool(vsync);
-#if defined(_MZ700) || defined(_MZ1500)
-       state_fio->StateBool(hblank_vram);
-#endif
-#if defined(_MZ1500)
-       state_fio->StateBool(hblank_pcg);
-#endif
-#if defined(_MZ800)
-       //state_fio->StateBuffer(palette_mz800_pc, sizeof(palette_mz800_pc), 1);
-       if(loading) {
-               for(int i = 0; i < (sizeof(palette_mz800_pc) / sizeof(scrntype_t)); i++) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette_mz800_pc[i] = RGB_COLOR(r, g, b);
-               }
-       } else {
-               for(int i = 0; i < (sizeof(palette_mz800_pc) / sizeof(scrntype_t)); i++) {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette_mz800_pc[i]);
-                       g = G_OF_COLOR(palette_mz800_pc[i]);
-                       b = B_OF_COLOR(palette_mz800_pc[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-#endif
-       //state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
-       if(loading) {
-               for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette_pc[i] = RGB_COLOR(r, g, b);
-               }
-       } else {
-               for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette_pc[i]);
-                       g = G_OF_COLOR(palette_pc[i]);
-                       b = B_OF_COLOR(palette_pc[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
+       state_fio->StateValue(blink);
+       state_fio->StateValue(tempo);
+       state_fio->StateValue(hblank);
+       state_fio->StateValue(hsync);
+       state_fio->StateValue(vblank);
+       state_fio->StateValue(vsync);
+ #if defined(_MZ700) || defined(_MZ1500)
+       state_fio->StateValue(hblank_vram);
+ #endif
+ #if defined(_MZ1500)
+       state_fio->StateValue(hblank_pcg);
+ #endif
+ #if defined(_MZ800)
+       state_fio->StateArrayScrnType_t(palette_mz800_pc, sizeof(palette_mz800_pc), 1);
+ #endif
+       state_fio->StateArrayScrnType_t(palette_pc, sizeof(palette_pc), 1);
        
        // post process
        if(loading) {
index 203af22..f82f9dd 100644 (file)
@@ -570,26 +570,23 @@ bool QUICKDISK::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateBuffer(file_path, sizeof(file_path), 1);
-       state_fio->StateBool(insert);
-       state_fio->StateBool(protect);
-       state_fio->StateBool(home);
-       state_fio->StateBool(modified);
-       state_fio->StateBool(accessed);
-       //state_fio->StateBuffer(buffer, sizeof(buffer), 1);
-       for(int i = 0; i < QUICKDISK_BUFFER_SIZE; i++) {
-               state_fio->StateUint16(buffer[i]);
-       }
-       state_fio->StateInt32(buffer_ptr);
-       state_fio->StateInt32(write_ptr);
-       state_fio->StateBool(first_data);
-       state_fio->StateBool(send_break);
-       state_fio->StateBool(wrga);
-       state_fio->StateBool(mton);
-       state_fio->StateBool(sync);
-       state_fio->StateBool(motor_on);
-       state_fio->StateInt32(restore_id);
-       state_fio->StateInt32(end_id);
+       state_fio->StateArray(file_path, sizeof(file_path), 1);
+       state_fio->StateValue(insert);
+       state_fio->StateValue(protect);
+       state_fio->StateValue(home);
+       state_fio->StateValue(modified);
+       state_fio->StateValue(accessed);
+       state_fio->StateArray(buffer, sizeof(buffer), 1);
+       state_fio->StateValue(buffer_ptr);
+       state_fio->StateValue(write_ptr);
+       state_fio->StateValue(first_data);
+       state_fio->StateValue(send_break);
+       state_fio->StateValue(wrga);
+       state_fio->StateValue(mton);
+       state_fio->StateValue(sync);
+       state_fio->StateValue(motor_on);
+       state_fio->StateValue(restore_id);
+       state_fio->StateValue(end_id);
        return true;
 }
 
index c2d93ce..64878e3 100644 (file)
@@ -481,6 +481,6 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
                }
        }
        // Machine specified.
-       state_fio->StateInt32(boot_mode);
+       state_fio->StateValue(boot_mode);
        return true;
 }