Aliens: save the banks, palette RAM, the K051960 and the K007232 in save states (#2051)

This commit is contained in:
Federico Pereira
2026-10-09 06:02:54 -04:00
committed by GitHub
parent 0fe5665808
commit 155d68254c
4 changed files with 45 additions and 9 deletions
+21 -6
View File
@@ -8,6 +8,7 @@ Preliminary driver by:
***************************************************************************/
#include "driver.h"
#include "state.h"
#include "vidhrdw/generic.h"
#include "cpu/konami/konami.h" /* for the callback and the firq irq definition */
#include "vidhrdw/konamiic.h"
@@ -434,26 +435,33 @@ ROM_END
***************************************************************************/
static void aliens_banking( int lines )
static int aliens_rombank = 0x10; /* CPU ROM bank lines, kept for save states */
static void aliens_rombank_set(void)
{
unsigned char *RAM = memory_region(REGION_CPU1);
int lines = aliens_rombank;
int offs = 0x18000;
if (lines & 0x10) offs -= 0x8000;
offs += (lines & 0x0f)*0x2000;
cpu_setbank( 1, &RAM[offs] );
}
static void aliens_banking( int lines )
{
aliens_rombank = lines;
aliens_rombank_set();
}
static MACHINE_INIT( aliens )
{
unsigned char *RAM = memory_region(REGION_CPU1);
konami_cpu_setlines_callback = aliens_banking;
/* init the default bank */
cpu_setbank( 1, &RAM[0x10000] );
/* init the default bank (0x10000) */
aliens_rombank = 0x10;
aliens_rombank_set();
}
@@ -462,6 +470,13 @@ static DRIVER_INIT( aliens )
{
konami_rom_deinterleave_2(REGION_GFX1);
konami_rom_deinterleave_2(REGION_GFX2);
/* Save the ROM bank and the work RAM / palette switch, and map the
saved bank again after loading, so a loaded save state runs the
right code */
state_save_register_int("aliens", 0, "rombank", &aliens_rombank);
state_save_register_int("aliens", 0, "palette_selected", &palette_selected);
state_save_register_func_postload(aliens_rombank_set);
}
+11
View File
@@ -24,6 +24,7 @@ added external port callback, and functions to set the volume of the channels
#include "driver.h"
#include "state.h"
#include <math.h>
@@ -339,6 +340,16 @@ int K007232_sh_start(const struct MachineSound *msound)
pcm_chan[j] = stream_init_multi(2,name,vol,Machine->sample_rate,
j,KDAC_A_update);
/* Save the channels and the registers, so a loaded save state keeps
its sound (the sample ROM pointers do not change) */
state_save_register_UINT8 ("K007232", j, "vol", &kpcm[j].vol[0][0], KDAC_A_PCM_MAX * 2);
state_save_register_UINT32("K007232", j, "addr", kpcm[j].addr, KDAC_A_PCM_MAX);
state_save_register_UINT32("K007232", j, "start", kpcm[j].start, KDAC_A_PCM_MAX);
state_save_register_UINT32("K007232", j, "step", kpcm[j].step, KDAC_A_PCM_MAX);
state_save_register_UINT32("K007232", j, "bank", kpcm[j].bank, KDAC_A_PCM_MAX);
state_save_register_INT32 ("K007232", j, "play", kpcm[j].play, KDAC_A_PCM_MAX);
state_save_register_UINT8 ("K007232", j, "wreg", kpcm[j].wreg, 0x10);
}
KDAC_A_make_fncode();
+2
View File
@@ -1,4 +1,5 @@
#include "driver.h"
#include "state.h"
#include "vidhrdw/konamiic.h"
@@ -56,6 +57,7 @@ VIDEO_START( aliens )
paletteram = auto_malloc(0x400);
if (!paletteram)
return 1;
state_save_register_UINT8("aliens", 0, "paletteram", paletteram, 0x400);
layer_colorbase[0] = 0;
layer_colorbase[1] = 4;
+11 -3
View File
@@ -2413,6 +2413,7 @@ static int K051960_spriteflip,K051960_readroms;
static unsigned char K051960_spriterombank[3];
static unsigned char *K051960_ram;
static int K051960_irq_enabled, K051960_nmi_enabled;
static int K051937_counter;
int K051960_vh_start(int gfx_memory_region,int plane0,int plane1,int plane2,int plane3,
@@ -2480,6 +2481,15 @@ int K051960_vh_start(int gfx_memory_region,int plane0,int plane1,int plane2,int
if (!K051960_ram) return 1;
memset(K051960_ram,0,0x400);
state_save_register_UINT8("K051960", 0, "memory", K051960_ram, 0x400);
state_save_register_int ("K051960", 0, "romoffset", &K051960_romoffset);
state_save_register_int ("K051960", 0, "flip", &K051960_spriteflip);
state_save_register_int ("K051960", 0, "readroms", &K051960_readroms);
state_save_register_UINT8("K051960", 0, "rombank", K051960_spriterombank, 3);
state_save_register_int ("K051960", 0, "irqen", &K051960_irq_enabled);
state_save_register_int ("K051960", 0, "nmien", &K051960_nmi_enabled);
state_save_register_int ("K051960", 0, "counter", &K051937_counter);
return 0;
}
@@ -2546,10 +2556,8 @@ READ_HANDLER( K051937_r )
{
if (offset == 0)
{
static int counter;
/* some games need bit 0 to pulse */
return (counter++) & 1;
return (K051937_counter++) & 1;
}
/*logerror("%04x: read unknown 051937 address %x\n",activecpu_get_pc(),offset);*/
return 0;