H6280: register CPU state; battlera/actfancr: save HuC6270 VDC and driver state (#2177)

The H6280 core registered nothing with the save-state system, and the
HuC6270 video chip of the battlera board (VRAM, registers, palette,
scanline/IRQ bookkeeping) and the driver's port select / ADPCM toggle
were not registered either. After a state load the CPU kept running
from its own PC, registers, MMR bank map and timer, and the screen was
drawn from the old VRAM, so netplay guests saw a blank or diverging
screen and rewind / run-ahead diverged.

- h6280.c: register PPC/PC/SP/ZP/EA, A/X/Y/P, the 8 MMR registers, the
  IRQ mask, timer status/ack/value/load, extra cycles and the IRQ lines
  (plus NZ with LAZY_FLAGS) per CPU in h6280_init(), as m6809_init() does.
- battlera_vidhrdw.c: register VRAM, the 20 VDC registers, the VDC
  pointers and flags, last_line (was a function-local static) and the
  palette RAM; a postload handler marks everything dirty and rebuilds
  the palette.
- battlera.c: register control_port_select, msm5205next and the ADPCM
  toggle (was a function-local static) from a new DRIVER_INIT.

Co-authored-by: Squirbie <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-10-29 06:06:22 -04:00
1 parent c6a2aa4700
commit dfc61f1689
3 files changed
+77 -6

No files matched your search

+26
View File
@@ -60,6 +60,7 @@
#include "memory.h"
#include "cpuintrf.h"
#include "state.h"
#include "mamedbg.h"
#include "h6280.h"
@@ -138,6 +139,31 @@ UINT8 H6280_debug_mmr[8];
/*****************************************************************************/
void h6280_init(void)
{
int cpu = cpu_getactivecpu();
state_save_register_UINT32("h6280", cpu, "PPC", &h6280.ppc.d, 1);
state_save_register_UINT32("h6280", cpu, "PC", &h6280.pc.d, 1);
state_save_register_UINT32("h6280", cpu, "SP", &h6280.sp.d, 1);
state_save_register_UINT32("h6280", cpu, "ZP", &h6280.zp.d, 1);
state_save_register_UINT32("h6280", cpu, "EA", &h6280.ea.d, 1);
state_save_register_UINT8("h6280", cpu, "A", &h6280.a, 1);
state_save_register_UINT8("h6280", cpu, "X", &h6280.x, 1);
state_save_register_UINT8("h6280", cpu, "Y", &h6280.y, 1);
state_save_register_UINT8("h6280", cpu, "P", &h6280.p, 1);
state_save_register_UINT8("h6280", cpu, "MMR", h6280.mmr, 8);
state_save_register_UINT8("h6280", cpu, "IRQ_MASK", &h6280.irq_mask, 1);
state_save_register_UINT8("h6280", cpu, "TIMER_STATUS", &h6280.timer_status, 1);
state_save_register_UINT8("h6280", cpu, "TIMER_ACK", &h6280.timer_ack, 1);
state_save_register_int("h6280", cpu, "TIMER_VALUE", &h6280.timer_value);
state_save_register_int("h6280", cpu, "TIMER_LOAD", &h6280.timer_load);
state_save_register_int("h6280", cpu, "EXTRA_CYCLES", &h6280.extra_cycles);
state_save_register_int("h6280", cpu, "NMI_STATE", &h6280.nmi_state);
state_save_register_int("h6280", cpu, "IRQ1_STATE", &h6280.irq_state[0]);
state_save_register_int("h6280", cpu, "IRQ2_STATE", &h6280.irq_state[1]);
state_save_register_int("h6280", cpu, "IRQT_STATE", &h6280.irq_state[2]);
#if LAZY_FLAGS
state_save_register_int("h6280", cpu, "NZ", &h6280.NZ);
#endif
}
void h6280_reset(void *param)
+13 -4
View File
@@ -23,6 +23,7 @@
#include "driver.h"
#include "vidhrdw/generic.h"
#include "cpu/h6280/h6280.h"
#include "state.h"
VIDEO_UPDATE( battlera );
VIDEO_START( battlera );
@@ -107,11 +108,10 @@ static WRITE_HANDLER( YM2203_w )
}
static int msm5205next;
static int toggle;
static void battlera_adpcm_int(int data)
{
static int toggle;
MSM5205_data_w(0,msm5205next >> 4);
msm5205next<<=4;
@@ -368,5 +368,14 @@ ROM_END
/******************************************************************************/
GAMEX( 1988, battlera, 0, battlera, battlera, 0, ROT0, "Data East Corporation", "Battle Rangers (World)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
GAMEX( 1988, bldwolf, battlera, battlera, battlera, 0, ROT0, "Data East USA", "Bloody Wolf (US)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
static DRIVER_INIT( battlera )
{
state_save_register_int("battlera", 0, "control_port_select", &control_port_select);
state_save_register_int("battlera", 0, "msm5205next", &msm5205next);
state_save_register_int("battlera", 0, "adpcm_toggle", &toggle);
}
/******************************************************************************/
GAMEX( 1988, battlera, 0, battlera, battlera, battlera, ROT0, "Data East Corporation", "Battle Rangers (World)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
GAMEX( 1988, bldwolf, battlera, battlera, battlera, battlera, ROT0, "Data East USA", "Bloody Wolf (US)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
+38 -2
View File
@@ -10,6 +10,7 @@
#include "driver.h"
#include "vidhrdw/generic.h"
#include "cpu/h6280/h6280.h"
#include "state.h"
static int HuC6270_registers[20];
static int VDC_register,vram_ptr;
@@ -18,6 +19,9 @@ static struct mame_bitmap *tile_bitmap,*front_bitmap;
static int current_scanline,inc_value;
static int irq_enable,rcr_enable,sb_enable,bb_enable,bldwolf_vblank;
static int last_line;
static void battlera_postload(void);
@@ -45,10 +49,44 @@ VIDEO_START( battlera )
inc_value=1;
current_scanline=0;
irq_enable=rcr_enable=sb_enable=bb_enable=0;
last_line=0;
state_save_register_UINT8("battlera_video", 0, "HuC6270_vram", HuC6270_vram, 0x20000);
state_save_register_INT32("battlera_video", 0, "HuC6270_registers", (INT32 *)HuC6270_registers, 20);
state_save_register_int("battlera_video", 0, "VDC_register", &VDC_register);
state_save_register_int("battlera_video", 0, "vram_ptr", &vram_ptr);
state_save_register_int("battlera_video", 0, "current_scanline", &current_scanline);
state_save_register_int("battlera_video", 0, "inc_value", &inc_value);
state_save_register_int("battlera_video", 0, "irq_enable", &irq_enable);
state_save_register_int("battlera_video", 0, "rcr_enable", &rcr_enable);
state_save_register_int("battlera_video", 0, "sb_enable", &sb_enable);
state_save_register_int("battlera_video", 0, "bb_enable", &bb_enable);
state_save_register_int("battlera_video", 0, "bldwolf_vblank", &bldwolf_vblank);
state_save_register_int("battlera_video", 0, "last_line", &last_line);
state_save_register_UINT8("battlera_video", 0, "paletteram", paletteram, 0x400);
state_save_register_func_postload(battlera_postload);
return 0;
}
static void battlera_postload(void)
{
int offs,r,g,b,pal_word;
memset(tile_dirty,1,0x1000);
memset(sprite_dirty,1,0x400);
memset(vram_dirty,1,0x1000);
for (offs = 0; offs < 0x400; offs += 2)
{
pal_word=paletteram[offs] | (paletteram[offs+1]<<8);
r = ((pal_word >> 3) & 7) << 5;
g = ((pal_word >> 6) & 7) << 5;
b = ((pal_word >> 0) & 7) << 5;
palette_set_color(offs/2, r, g, b);
}
}
/******************************************************************************/
WRITE_HANDLER( battlera_palette_w )
@@ -436,8 +474,6 @@ void battlera_raster_partial_refresh(struct mame_bitmap *bitmap,int start_line,i
INTERRUPT_GEN( battlera_interrupt )
{
static int last_line=0;
current_scanline=255-cpu_getiloops(); /* 8 lines clipped at top */
/* If raster interrupt occurs, refresh screen _up_ to this point */