OSDN Git Service

[VM] Enable to build with more VMs.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Sat, 27 Oct 2018 18:11:34 +0000 (03:11 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Sat, 27 Oct 2018 18:11:34 +0000 (03:11 +0900)
source/src/vm/pc9801/cpureg.cpp
source/src/vm/pc9801/display.cpp
source/src/vm/pc9801/membus.cpp
source/src/vm/pc9801/pc9801.cpp
source/src/vm/pcengine/pce.cpp
source/src/vm/pv1000/pv1000.cpp
source/src/vm/pv2000/pv2000.cpp
source/src/vm/qc10/keyboard.cpp
source/src/vm/rx78/vdp.cpp

index f9186bd..7586ecb 100644 (file)
@@ -116,7 +116,7 @@ bool CPUREG::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateBool(nmi_enabled);
+       state_fio->StateValue(nmi_enabled);
        return true;
 }
 
index e1e7aa2..915a9b0 100644 (file)
@@ -2586,84 +2586,46 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateBuffer(tvram, sizeof(tvram), 1);
-       state_fio->StateBuffer(vram, sizeof(vram), 1);
-#if defined(SUPPORT_2ND_VRAM) && !defined(SUPPORT_HIRESO)
-       state_fio->StateUint8(vram_disp_sel);
-       state_fio->StateUint8(vram_draw_sel);
-#endif
-       //state_fio->StateBuffer(palette_gfx8, sizeof(palette_gfx8), 1);
-       if(loading) {
-               for(int i = 0; i < (sizeof(palette_gfx8) / sizeof(scrntype_t)); i++) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette_gfx8[i] = RGB_COLOR(r, g, b);
-               }
-       } else {
-               for(int i = 0; i < (sizeof(palette_gfx8) / sizeof(scrntype_t)); i++) {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette_gfx8[i]);
-                       g = G_OF_COLOR(palette_gfx8[i]);
-                       b = B_OF_COLOR(palette_gfx8[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       state_fio->StateBuffer(digipal, sizeof(digipal), 1);
-#if defined(SUPPORT_16_COLORS)
-       //state_fio->StateBuffer(palette_gfx16, sizeof(palette_gfx16), 1);      
-       if(loading) {
-               for(int i = 0; i < (sizeof(palette_gfx16) / sizeof(scrntype_t)); i++) {
-                       uint8_t r, g, b;
-                       r = state_fio->FgetUint8();
-                       g = state_fio->FgetUint8();
-                       b = state_fio->FgetUint8();
-                       palette_gfx16[i] = RGB_COLOR(r, g, b);
-               }
-       } else {
-               for(int i = 0; i < (sizeof(palette_gfx16) / sizeof(scrntype_t)); i++) {
-                       uint8_t r, g, b;
-                       r = R_OF_COLOR(palette_gfx16[i]);
-                       g = G_OF_COLOR(palette_gfx16[i]);
-                       b = B_OF_COLOR(palette_gfx16[i]);
-                       state_fio->FputUint8(r);
-                       state_fio->FputUint8(g);
-                       state_fio->FputUint8(b);
-               }
-       }
-       state_fio->StateBuffer(anapal, sizeof(anapal), 1);
-       state_fio->StateUint8(anapal_sel);
-#endif
-       state_fio->StateUint8(crtv);
-       state_fio->StateBuffer(scroll, sizeof(scroll), 1);
-       state_fio->StateBuffer(modereg1, sizeof(modereg1), 1);
-#if defined(SUPPORT_16_COLORS)
-       state_fio->StateBuffer(modereg2, sizeof(modereg2), 1);
-#endif
-#if defined(SUPPORT_GRCG)
-       state_fio->StateUint8(grcg_mode);
-       state_fio->StateUint8(grcg_tile_ptr);
-       state_fio->StateBuffer(grcg_tile, sizeof(grcg_tile), 1);
-#endif
+       state_fio->StateArray(tvram, sizeof(tvram), 1);
+       state_fio->StateArray(vram, sizeof(vram), 1);
+ #if defined(SUPPORT_2ND_VRAM) && !defined(SUPPORT_HIRESO)
+       state_fio->StateValue(vram_disp_sel);
+       state_fio->StateValue(vram_draw_sel);
+ #endif
+       state_fio->StateArrayScrnType_t(palette_gfx8, sizeof(palette_gfx8), 1);
+       state_fio->StateArray(digipal, sizeof(digipal), 1);
+ #if defined(SUPPORT_16_COLORS)
+       state_fio->StateArrayScrnType_t(palette_gfx16, sizeof(palette_gfx16), 1);
+       state_fio->StateArray(&anapal[0][0], sizeof(anapal), 1);
+       state_fio->StateValue(anapal_sel);
+ #endif
+       state_fio->StateValue(crtv);
+       state_fio->StateArray(scroll, sizeof(scroll), 1);
+       state_fio->StateArray(modereg1, sizeof(modereg1), 1);
+ #if defined(SUPPORT_16_COLORS)
+       state_fio->StateArray(modereg2, sizeof(modereg2), 1);
+ #endif
+ #if defined(SUPPORT_GRCG)
+       state_fio->StateValue(grcg_mode);
+       state_fio->StateValue(grcg_tile_ptr);
+       state_fio->StateArray(grcg_tile, sizeof(grcg_tile), 1);
+ #endif
 #if defined(SUPPORT_EGC)
-       state_fio->StateUint16(egc_access);
-       state_fio->StateUint16(egc_fgbg);
-       state_fio->StateUint16(egc_ope);
-       state_fio->StateUint16(egc_fg);
-       state_fio->StateUint16(egc_mask.w);
-       state_fio->StateUint16(egc_bg);
-       state_fio->StateUint16(egc_sft);
-       state_fio->StateUint16(egc_leng);
-       state_fio->StateUint64(egc_lastvram.q);
-       state_fio->StateUint64(egc_patreg.q);
-       state_fio->StateUint64(egc_fgc.q);
-       state_fio->StateUint64(egc_bgc.q);
-       state_fio->StateInt32(egc_func);
-       state_fio->StateUint32(egc_remain);
-       state_fio->StateUint32(egc_stack);
+       state_fio->StateValue(egc_access);
+       state_fio->StateValue(egc_fgbg);
+       state_fio->StateValue(egc_ope);
+       state_fio->StateValue(egc_fg);
+       state_fio->StateValue(egc_mask.w);
+       state_fio->StateValue(egc_bg);
+       state_fio->StateValue(egc_sft);
+       state_fio->StateValue(egc_leng);
+       state_fio->StateValue(egc_lastvram.q);
+       state_fio->StateValue(egc_patreg.q);
+       state_fio->StateValue(egc_fgc.q);
+       state_fio->StateValue(egc_bgc.q);
+       state_fio->StateValue(egc_func);
+       state_fio->StateValue(egc_remain);
+       state_fio->StateValue(egc_stack);
        if(loading) {
                int inptr_ofs = state_fio->FgetInt32_LE();
                int outptr_ofs = state_fio->FgetInt32_LE();
@@ -2675,19 +2637,19 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
                state_fio->FputInt32_LE(inptr_ofs);
                state_fio->FputInt32_LE(outptr_ofs);
        }
-       state_fio->StateUint16(egc_mask2.w);
-       state_fio->StateUint16(egc_srcmask.w);
-       state_fio->StateUint8(egc_srcbit);
-       state_fio->StateUint8(egc_dstbit);
-       state_fio->StateUint8(egc_sft8bitl);
-       state_fio->StateUint8(egc_sft8bitr);
-       state_fio->StateBuffer(egc_buf, sizeof(egc_buf), 1);
-       state_fio->StateUint64(egc_vram_src.q);
-       state_fio->StateUint64(egc_vram_data.q);
-#endif
-       state_fio->StateUint16(font_code);
-       state_fio->StateUint8(font_line);
-//     state_fio->StateUint16(font_lr);
+       state_fio->StateValue(egc_mask2.w);
+       state_fio->StateValue(egc_srcmask.w);
+       state_fio->StateValue(egc_srcbit);
+       state_fio->StateValue(egc_dstbit);
+       state_fio->StateValue(egc_sft8bitl);
+       state_fio->StateValue(egc_sft8bitr);
+       state_fio->StateArray(egc_buf, sizeof(egc_buf), 1);
+       state_fio->StateValue(egc_vram_src.q);
+       state_fio->StateValue(egc_vram_data.q);
+#endif
+       state_fio->StateValue(font_code);
+       state_fio->StateValue(font_line);
+//     state_fio->StateValue(font_lr);
        
        // post process
 #if defined(SUPPORT_2ND_VRAM) && !defined(SUPPORT_HIRESO)
index 155d7d3..ab7698c 100644 (file)
@@ -545,43 +545,44 @@ bool MEMBUS::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateBuffer(ram, sizeof(ram), 1);
-#if defined(SUPPORT_BIOS_RAM)
-       state_fio->StateBuffer(bios_ram, sizeof(bios_ram), 1);
-       state_fio->StateBool(bios_ram_selected);
-#endif
-#if defined(SUPPORT_ITF_ROM)
-       state_fio->StateBool(itf_selected);
-#endif
-#if !defined(SUPPORT_HIRESO)
-//     state_fio->StateBuffer(sound_bios_ram, sizeof(sound_bios_ram), 1);
-       state_fio->StateBool(sound_bios_selected);
-//     state_fio->StateBool(sound_bios_ram_selected);
-#if defined(SUPPORT_SASI_IF)
-       state_fio->StateBuffer(sasi_bios_ram, sizeof(sasi_bios_ram), 1);
-       state_fio->StateBool(sasi_bios_selected);
-       state_fio->StateBool(sasi_bios_ram_selected);
-#endif
-#if defined(SUPPORT_SCSI_IF)
-       state_fio->StateBuffer(scsi_bios_ram, sizeof(scsi_bios_ram), 1);
-       state_fio->StateBool(scsi_bios_selected);
-       state_fio->StateBool(scsi_bios_ram_selected);
-#endif
-#if defined(SUPPORT_IDE_IF)
-//     state_fio->StateBuffer(ide_bios_ram, sizeof(ide_bios_ram), 1);
-       state_fio->StateBool(ide_bios_selected);
-//     state_fio->StateBool(ide_bios_ram_selected);
-#endif
-#if defined(SUPPORT_NEC_EMS)
-       state_fio->StateBuffer(nec_ems, sizeof(nec_ems), 1);
-       state_fio->StateBool(nec_ems_selected);
-#endif
-#endif
-#if defined(SUPPORT_24BIT_ADDRESS) || defined(SUPPORT_32BIT_ADDRESS)
-       state_fio->StateUint8(dma_access_ctrl);
-       state_fio->StateUint32(window_80000h);
-       state_fio->StateUint32(window_a0000h);
-#endif
+       state_fio->StateArray(ram, sizeof(ram), 1);
+ #if defined(SUPPORT_BIOS_RAM)
+       state_fio->StateArray(bios_ram, sizeof(bios_ram), 1);
+       state_fio->StateValue(bios_ram_selected);
+ #endif
+ #if defined(SUPPORT_ITF_ROM)
+       state_fio->StateValue(itf_selected);
+ #endif
+ #if !defined(SUPPORT_HIRESO)
+//     state_fio->StateArray(sound_bios_ram, sizeof(sound_bios_ram), 1);
+       state_fio->StateValue(sound_bios_selected);
+//     state_fio->StateValue(sound_bios_ram_selected);
+ #if defined(SUPPORT_SASI_IF)
+       state_fio->StateArray(sasi_bios_ram, sizeof(sasi_bios_ram), 1);
+       state_fio->StateValue(sasi_bios_selected);
+       state_fio->StateValue(sasi_bios_ram_selected);
+ #endif
+ #if defined(SUPPORT_SCSI_IF)
+       state_fio->StateArray(scsi_bios_ram, sizeof(scsi_bios_ram), 1);
+       state_fio->StateValue(scsi_bios_selected);
+       state_fio->StateValue(scsi_bios_ram_selected);
+ #endif
+ #if defined(SUPPORT_IDE_IF)
+-//    state_fio->StateBool(ide_bios_ram_selected);
+//     state_fio->StateArray(ide_bios_ram, sizeof(ide_bios_ram), 1);
+       state_fio->StateValue(ide_bios_selected);
+//     state_fio->StateValue(ide_bios_ram_selected);
+ #endif
+ #if defined(SUPPORT_NEC_EMS)
+       state_fio->StateArray(nec_ems, sizeof(nec_ems), 1);
+       state_fio->StateValue(nec_ems_selected);
+ #endif
+ #endif
+ #if defined(SUPPORT_24BIT_ADDRESS) || defined(SUPPORT_32BIT_ADDRESS)
+       state_fio->StateValue(dma_access_ctrl);
+       state_fio->StateValue(window_80000h);
+       state_fio->StateValue(window_a0000h);
+ #endif
        if(!MEMORY::process_state(state_fio, loading)) {
                return false;
        }
index 8e21b15..c091e95 100644 (file)
@@ -1636,10 +1636,10 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
                        return false;
                }
        }
-       state_fio->StateBool(pit_clock_8mhz);
+       state_fio->StateValue(pit_clock_8mhz);
 #if defined(_PC98DO) || defined(_PC98DOPLUS)
-       state_fio->StateInt32(boot_mode);
+       state_fio->StateValue(boot_mode);
 #endif
-       state_fio->StateInt32(sound_type);
+       state_fio->StateValue(sound_type);
        return true;
 }
index 949d8f5..4c96286 100644 (file)
@@ -2451,6 +2451,62 @@ void PCE::event_callback(int event_id, int err)
 
 #define STATE_VERSION  5
 
+void process_state_vdc(vdc_t* val, FILEIO* state_fio)
+{
+       state_fio->StateValue(val->dvssr_write);
+       state_fio->StateValue(val->physical_width);
+       state_fio->StateValue(val->physical_height);
+       state_fio->StateArray(val->sprite_ram, sizeof(val->sprite_ram), 1);
+       state_fio->StateValue(val->curline);
+       state_fio->StateValue(val->current_segment);
+       state_fio->StateValue(val->current_segment_line);
+       state_fio->StateValue(val->vblank_triggered);
+       state_fio->StateValue(val->raster_count);
+       state_fio->StateValue(val->satb_countdown);
+       state_fio->StateArray(val->vram, sizeof(val->vram), 1);
+       state_fio->StateValue(val->inc);
+       state_fio->StateValue(val->vdc_register);
+       state_fio->StateValue(val->vdc_latch);
+       state_fio->StateArray(val->vdc_data, sizeof(val->vdc_data), 1);
+       state_fio->StateValue(val->status);
+       state_fio->StateValue(val->y_scroll);
+}
+
+void process_state_vce(vce_t* val, FILEIO* state_fio)
+{
+       state_fio->StateValue(val->vce_control);
+       state_fio->StateValue(val->vce_address);
+       state_fio->StateArray(val->vce_data, sizeof(val->vce_data), 1);
+       state_fio->StateValue(val->current_bitmap_line);
+       state_fio->StateArrayScrnType_t(&val->bmp[0][0], sizeof(val->bmp), 1);
+       state_fio->StateArrayScrnType_t(val->palette, sizeof(val->palette), 1);
+}
+
+void process_state_vpc(vpc_t* val, FILEIO* state_fio)
+{
+       for(int i = 0; i < array_length(val->vpc_prio); i++) {
+               state_fio->StateValue(val->vpc_prio[i].prio);
+               state_fio->StateValue(val->vpc_prio[i].vdc0_enabled);
+               state_fio->StateValue(val->vpc_prio[i].vdc1_enabled);
+       }
+       state_fio->StateArray(val->prio_map, sizeof(val->prio_map), 1);
+       state_fio->StateValue(val->priority);
+       state_fio->StateValue(val->window1);
+       state_fio->StateValue(val->window2);
+       state_fio->StateValue(val->vdc_select);
+}
+
+void process_state_psg(psg_t* val, FILEIO* state_fio)
+{
+       state_fio->StateArray(val->regs, sizeof(val->regs), 1);
+       state_fio->StateArray(val->wav, sizeof(val->wav), 1);
+       state_fio->StateValue(val->wavptr);
+       state_fio->StateValue(val->genptr);
+       state_fio->StateValue(val->remain);
+       state_fio->StateValue(val->noise);
+       state_fio->StateValue(val->randval);
+}
+
 bool PCE::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
@@ -2459,156 +2515,63 @@ bool PCE::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateBool(support_6btn_pad);
-       state_fio->StateBool(support_multi_tap);
-#ifdef SUPPORT_SUPER_GFX
-       state_fio->StateBool(support_sgfx);
-#endif
-#ifdef SUPPORT_CDROM
-       state_fio->StateBool(support_cdrom);
-#endif
-       state_fio->StateBuffer(ram, sizeof(ram), 1);
-       state_fio->StateBuffer(cart + 0x80000, 0x80000, 1);
-#ifdef SUPPORT_BACKUP_RAM
-       state_fio->StateBuffer(backup, sizeof(backup), 1);
-       state_fio->StateUint32(backup_crc32);
-#endif
-       state_fio->StateUint32(bank);
-       state_fio->StateUint8(buffer);
-       state_fio->StateInt32(prev_width);
-       state_fio->StateBool(inserted);
-
-       //state_fio->StateBuffer(vdc, sizeof(vdc), 1);
-       //state_fio->StateBuffer(&vce, sizeof(vce), 1);
-       //state_fio->StateBuffer(&vpc, sizeof(vpc), 1);
-       //state_fio->StateBuffer(psg, sizeof(psg), 1);
-       // vdc
-       for(int i = 0; i < 2; i++) {
-               state_fio->StateInt32(vdc[i].dvssr_write);              /* Set when the DVSSR register has been written to */
-               state_fio->StateInt32(vdc[i].physical_width);           /* Width of the display */
-               state_fio->StateInt32(vdc[i].physical_height);          /* Height of the display */
-               for(int j = 0; j < (64 * 4); j++) {
-                       state_fio->StateUint16(vdc[i].sprite_ram[j]);   /* Sprite RAM */
-               }
-               state_fio->StateInt32(vdc[i].curline);                          /* the current scanline we're on */
-               state_fio->StateInt32(vdc[i].current_segment);          /* current segment of display */
-               state_fio->StateInt32(vdc[i].current_segment_line);     /* current line inside a segment of display */
-               state_fio->StateInt32(vdc[i].vblank_triggered);         /* to indicate whether vblank has been triggered */
-               state_fio->StateInt32(vdc[i].raster_count);             /* counter to compare RCR against */
-               state_fio->StateInt32(vdc[i].satb_countdown);           /* scanlines to wait to trigger the SATB irq */
-               state_fio->StateBuffer((vdc[i].vram), 0x10000, 1);
-               state_fio->StateUint8(vdc[i].inc);
-               state_fio->StateUint8(vdc[i].vdc_register);
-               state_fio->StateUint8(vdc[i].vdc_latch);
-               for(int j = 0; j < 32; j++) {
-                       state_fio->StateUint32(vdc[i].vdc_data[j].d);
-               }
-               state_fio->StateInt32(vdc[i].status);
-               state_fio->StateInt32(vdc[i].y_scroll);
-       }
-       // vce
-       {
-               state_fio->StateUint8(vce.vce_control);         /* VCE control register */
-               state_fio->StateUint32(vce.vce_address.d);              /* Current address in the palette */
-               for(int i = 0; i < 512; i++) {
-                       state_fio->StateUint32(vce.vce_data[i].d);              /* Palette data */
-               }
-               state_fio->StateInt32(vce.current_bitmap_line); /* The current line in the display we are on */
-               //bitmap_ind16 *bmp;
-               for(int i = 0; i < VDC_LPF; i++) {
-                       for(int j = 0; j < VDC_WPF; j++) {
-                               if(loading) {
-                                       uint8_t r, g, b;
-                                       r = state_fio->FgetUint8();
-                                       g = state_fio->FgetUint8();
-                                       b = state_fio->FgetUint8();
-                                       vce.bmp[i][j] = RGB_COLOR(r, g, b);
-                               } else {
-                                       uint8_t r, g, b;
-                                       r = R_OF_COLOR(vce.bmp[i][j]);
-                                       g = G_OF_COLOR(vce.bmp[i][j]);
-                                       b = B_OF_COLOR(vce.bmp[i][j]);
-                                       state_fio->FputUint8(r);
-                                       state_fio->FputUint8(g);
-                                       state_fio->FputUint8(b);
-                               }
-                       }
-               }
-               for(int i = 0; i < 1024; i++) {
-                       if(loading) {
-                               uint8_t r, g, b;
-                               r = state_fio->FgetUint8();
-                               g = state_fio->FgetUint8();
-                               b = state_fio->FgetUint8();
-                               vce.palette[i] = RGB_COLOR(r, g, b);
-                       } else {
-                               uint8_t r, g, b;
-                               r = R_OF_COLOR(vce.palette[i]);
-                               g = G_OF_COLOR(vce.palette[i]);
-                               b = B_OF_COLOR(vce.palette[i]);
-                               state_fio->FputUint8(r);
-                               state_fio->FputUint8(g);
-                               state_fio->FputUint8(b);
-                       }
-               }
-       }
-       // vpc
-       {
-               for(int i = 0; i < 4; i++) {
-                       state_fio->StateUint8(vpc.vpc_prio[i].prio);
-                       state_fio->StateUint8(vpc.vpc_prio[i].vdc0_enabled);
-                       state_fio->StateUint8(vpc.vpc_prio[i].vdc1_enabled);
-               }
-               state_fio->StateBuffer(vpc.prio_map, 512, 1);
-               state_fio->StateUint32(vpc.priority.d);
-               state_fio->StateUint32(vpc.window1.d);
-               state_fio->StateUint32(vpc.window2.d);
-               state_fio->StateUint8(vpc.vdc_select);
-       }
-       // psg
-       {
-               for(int i = 0; i < 8; i++ ){
-                   state_fio->StateBuffer(psg[i].regs, 8, 1);
-                       state_fio->StateBuffer(psg[i].wav, 32, 1);
-                       state_fio->StateUint8(psg[i].wavptr);
-                       state_fio->StateUint32(psg[i].genptr);
-                       state_fio->StateUint32(psg[i].remain);
-                       state_fio->StateBool(psg[i].noise);
-                       state_fio->StateUint32(psg[i].randval);
-               }
-       }
-
-       state_fio->StateUint8(psg_ch);
-       state_fio->StateUint8(psg_vol);
-       state_fio->StateUint8(psg_lfo_freq);
-       state_fio->StateUint8(psg_lfo_ctrl);
-       state_fio->StateUint8(joy_counter);
-       state_fio->StateBool(joy_high_nibble);
-       state_fio->StateBool(joy_second_byte);
+       state_fio->StateValue(support_6btn_pad);
+       state_fio->StateValue(support_multi_tap);
+ #ifdef SUPPORT_SUPER_GFX
+       state_fio->StateValue(support_sgfx);
+ #endif
+ #ifdef SUPPORT_CDROM
+       state_fio->StateValue(support_cdrom);
+ #endif
+       state_fio->StateArray(ram, sizeof(ram), 1);
+       state_fio->StateArray(cart + 0x80000, 0x80000, 1);
+ #ifdef SUPPORT_BACKUP_RAM
+       state_fio->StateArray(backup, sizeof(backup), 1);
+       state_fio->StateValue(backup_crc32);
+ #endif
+       state_fio->StateValue(bank);
+       state_fio->StateValue(buffer);
+       state_fio->StateValue(prev_width);
+       state_fio->StateValue(inserted);
+       for(int i = 0; i < array_length(vdc); i++) {
+               process_state_vdc(&vdc[i], state_fio);
+       }
+       process_state_vce(&vce, state_fio);
+       process_state_vpc(&vpc, state_fio);
+       for(int i = 0; i < array_length(psg); i++) {
+               process_state_psg(&psg[i], state_fio);
+       }
+       state_fio->StateValue(psg_ch);
+       state_fio->StateValue(psg_vol);
+       state_fio->StateValue(psg_lfo_freq);
+       state_fio->StateValue(psg_lfo_ctrl);
+       state_fio->StateValue(joy_counter);
+       state_fio->StateValue(joy_high_nibble);
+       state_fio->StateValue(joy_second_byte);
 #ifdef SUPPORT_CDROM
-       state_fio->StateBuffer(cdrom_ram, sizeof(cdrom_ram), 1);
-       state_fio->StateBuffer(cdrom_regs, sizeof(cdrom_regs), 1);
-       state_fio->StateBool(backup_locked);
-       state_fio->StateBool(irq_status);
-       state_fio->StateBool(drq_status);
-       state_fio->StateBuffer(adpcm_ram, sizeof(adpcm_ram), 1);
-       state_fio->StateInt32(adpcm_read_ptr);
-       state_fio->StateInt32(adpcm_write_ptr);
-       state_fio->StateInt32(adpcm_written);
-       state_fio->StateInt32(adpcm_length);
-       state_fio->StateInt32(adpcm_clock_divider);
-       state_fio->StateUint8(adpcm_read_buf);
-       state_fio->StateUint8(adpcm_write_buf);
-       state_fio->StateBool(adpcm_dma_enabled);
-       state_fio->StateInt32(msm_start_addr);
-       state_fio->StateInt32(msm_end_addr);
-       state_fio->StateInt32(msm_half_addr);
-       state_fio->StateUint8(msm_nibble);
-       state_fio->StateUint8(msm_idle);
-       state_fio->StateDouble(cdda_volume);
-       state_fio->StateDouble(adpcm_volume);
-       state_fio->StateInt32(event_cdda_fader);
-       state_fio->StateInt32(event_adpcm_fader);
+       state_fio->StateArray(cdrom_ram, sizeof(cdrom_ram), 1);
+       state_fio->StateArray(cdrom_regs, sizeof(cdrom_regs), 1);
+       state_fio->StateValue(backup_locked);
+       state_fio->StateValue(irq_status);
+       state_fio->StateValue(drq_status);
+       state_fio->StateArray(adpcm_ram, sizeof(adpcm_ram), 1);
+       state_fio->StateValue(adpcm_read_ptr);
+       state_fio->StateValue(adpcm_write_ptr);
+       state_fio->StateValue(adpcm_written);
+       state_fio->StateValue(adpcm_length);
+       state_fio->StateValue(adpcm_clock_divider);
+       state_fio->StateValue(adpcm_read_buf);
+       state_fio->StateValue(adpcm_write_buf);
+       state_fio->StateValue(adpcm_dma_enabled);
+       state_fio->StateValue(msm_start_addr);
+       state_fio->StateValue(msm_end_addr);
+       state_fio->StateValue(msm_half_addr);
+       state_fio->StateValue(msm_nibble);
+       state_fio->StateValue(msm_idle);
+       state_fio->StateValue(cdda_volume);
+       state_fio->StateValue(adpcm_volume);
+       state_fio->StateValue(event_cdda_fader);
+       state_fio->StateValue(event_adpcm_fader);
 #endif
        return true;
 }
index b1aad67..da56767 100644 (file)
@@ -256,7 +256,7 @@ bool VM::process_state(FILEIO* state_fio, bool loading)
                }
        }
        // Machine specified.
-       state_fio->StateBuffer(mem, sizeof(mem), 1);
-       state_fio->StateBool(inserted);
+       state_fio->StateArray(mem, sizeof(mem), 1);
+       state_fio->StateValue(inserted);
        return true;
 }
index 205328e..04496ed 100644 (file)
@@ -305,8 +305,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 920dc1c..25ee000 100644 (file)
@@ -158,12 +158,9 @@ bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       //state_fio->StateBuffer(led, sizeof(led), 1);
-       for(int i = 0; i < 8; i++) {
-               state_fio->StateBool(led[i]);
-       }
-       state_fio->StateBool(repeat);
-       state_fio->StateBool(enable);
+       state_fio->StateArray(led, sizeof(led), 1);
+       state_fio->StateValue(repeat);
+       state_fio->StateValue(enable);
        return true;
 }
 
index abe3925..6307875 100644 (file)
@@ -168,29 +168,11 @@ bool VDP::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(reg, sizeof(reg), 1);
-       state_fio->StateUint8(bg);
-       state_fio->StateUint8(cmask);
-       state_fio->StateUint8(pmask);
+       state_fio->StateArrayScrnType_t(palette_pc, sizeof(palette_pc), 1);
+       state_fio->StateArray(reg, sizeof(reg), 1);
+       state_fio->StateValue(bg);
+       state_fio->StateValue(cmask);
+       state_fio->StateValue(pmask);
        return true;
 }