nbmj8900.c: added save state support (nw)

This commit is contained in:
Ivan Vangelista 2015-05-09 08:48:20 +02:00
parent bdf5d552f3
commit a9d1c3d38e
3 changed files with 81 additions and 48 deletions

View File

@ -93,15 +93,15 @@ DRIVER_INIT_MEMBER(nbmj8900_state,togenkyo)
static ADDRESS_MAP_START( ohpaipee_map, AS_PROGRAM, 8, nbmj8900_state )
AM_RANGE(0x0000, 0xefff) AM_ROM
AM_RANGE(0xf000, 0xf00f) AM_READWRITE(nbmj8900_clut_r, nbmj8900_clut_w)
AM_RANGE(0xf400, 0xf5ff) AM_READWRITE(nbmj8900_palette_type1_r, nbmj8900_palette_type1_w)
AM_RANGE(0xf000, 0xf00f) AM_READWRITE(clut_r, clut_w)
AM_RANGE(0xf400, 0xf5ff) AM_READWRITE(palette_type1_r, palette_type1_w)
AM_RANGE(0xf800, 0xffff) AM_RAM
ADDRESS_MAP_END
static ADDRESS_MAP_START( togenkyo_map, AS_PROGRAM, 8, nbmj8900_state )
AM_RANGE(0x0000, 0xefff) AM_ROM
AM_RANGE(0xf000, 0xf00f) AM_READWRITE(nbmj8900_clut_r, nbmj8900_clut_w)
AM_RANGE(0xf400, 0xf5ff) AM_READWRITE(nbmj8900_palette_type1_r, nbmj8900_palette_type1_w)
AM_RANGE(0xf000, 0xf00f) AM_READWRITE(clut_r, clut_w)
AM_RANGE(0xf400, 0xf5ff) AM_READWRITE(palette_type1_r, palette_type1_w)
AM_RANGE(0xf800, 0xffff) AM_RAM
ADDRESS_MAP_END
@ -109,11 +109,11 @@ static ADDRESS_MAP_START( ohpaipee_io_map, AS_IO, 8, nbmj8900_state )
ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE(0x00, 0x7f) AM_DEVREAD("nb1413m3", nb1413m3_device, sndrom_r)
AM_RANGE(0x00, 0x00) AM_DEVWRITE("nb1413m3", nb1413m3_device, nmi_clock_w)
AM_RANGE(0x20, 0x27) AM_WRITE(nbmj8900_blitter_w)
AM_RANGE(0x20, 0x27) AM_WRITE(blitter_w)
AM_RANGE(0x40, 0x40) AM_WRITE(nbmj8900_clutsel_w)
AM_RANGE(0x60, 0x60) AM_WRITE(nbmj8900_romsel_w)
AM_RANGE(0x70, 0x70) AM_WRITE(nbmj8900_scrolly_w)
AM_RANGE(0x40, 0x40) AM_WRITE(clutsel_w)
AM_RANGE(0x60, 0x60) AM_WRITE(romsel_w)
AM_RANGE(0x70, 0x70) AM_WRITE(scrolly_w)
AM_RANGE(0x80, 0x81) AM_DEVREADWRITE("ymsnd", ym3812_device, read, write)
@ -123,7 +123,7 @@ static ADDRESS_MAP_START( ohpaipee_io_map, AS_IO, 8, nbmj8900_state )
AM_RANGE(0xb0, 0xb0) AM_DEVREADWRITE("nb1413m3", nb1413m3_device, inputport2_r, sndrombank1_w)
AM_RANGE(0xc0, 0xc0) AM_DEVREAD("nb1413m3", nb1413m3_device, inputport3_r)
AM_RANGE(0xd0, 0xd0) AM_DEVWRITE("dac", dac_device, write_unsigned8)
AM_RANGE(0xe0, 0xe0) AM_WRITE(nbmj8900_vramsel_w)
AM_RANGE(0xe0, 0xe0) AM_WRITE(vramsel_w)
AM_RANGE(0xf0, 0xf0) AM_DEVREAD("nb1413m3", nb1413m3_device, dipsw1_r)
AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE("nb1413m3", nb1413m3_device, dipsw2_r, outcoin_w)
ADDRESS_MAP_END
@ -316,7 +316,7 @@ static MACHINE_CONFIG_START( ohpaipee, nbmj8900_state )
MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
MCFG_SCREEN_SIZE(512, 256)
MCFG_SCREEN_VISIBLE_AREA(0, 512-1, 8, 248-1)
MCFG_SCREEN_UPDATE_DRIVER(nbmj8900_state, screen_update_nbmj8900)
MCFG_SCREEN_UPDATE_DRIVER(nbmj8900_state, screen_update)
MCFG_SCREEN_PALETTE("palette")
MCFG_PALETTE_ADD("palette", 256)
@ -391,5 +391,5 @@ ROM_START( togenkyo )
ROM_END
// YEAR, NAME, PARENT, MACHINE, INPUT, INIT, MONITOR,COMPANY,FULLNAME,FLAGS)
GAME( 1989, ohpaipee, 0, ohpaipee, ohpaipee, nbmj8900_state, ohpaipee, ROT270, "Nichibutsu", "Oh! Paipee (Japan 890227)", GAME_IMPERFECT_GRAPHICS )
GAME( 1989, togenkyo, 0, togenkyo, togenkyo, nbmj8900_state, togenkyo, ROT0, "Nichibutsu", "Tougenkyou (Japan 890418)", 0 )
GAME( 1989, ohpaipee, 0, ohpaipee, ohpaipee, nbmj8900_state, ohpaipee, ROT270, "Nichibutsu", "Oh! Paipee (Japan 890227)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
GAME( 1989, togenkyo, 0, togenkyo, togenkyo, nbmj8900_state, togenkyo, ROT0, "Nichibutsu", "Tougenkyou (Japan 890418)", GAME_SUPPORTS_SAVE )

View File

@ -46,27 +46,32 @@ public:
UINT8 *m_palette_ptr;
UINT8 *m_clut;
int m_flipscreen_old;
DECLARE_READ8_MEMBER(nbmj8900_palette_type1_r);
DECLARE_WRITE8_MEMBER(nbmj8900_palette_type1_w);
DECLARE_READ8_MEMBER(nbmj8900_palette_type2_r);
DECLARE_WRITE8_MEMBER(nbmj8900_palette_type2_w);
DECLARE_READ8_MEMBER(nbmj8900_palette_type3_r);
DECLARE_WRITE8_MEMBER(nbmj8900_palette_type3_w);
DECLARE_WRITE8_MEMBER(nbmj8900_clutsel_w);
DECLARE_READ8_MEMBER(nbmj8900_clut_r);
DECLARE_WRITE8_MEMBER(nbmj8900_clut_w);
DECLARE_WRITE8_MEMBER(nbmj8900_blitter_w);
DECLARE_WRITE8_MEMBER(nbmj8900_scrolly_w);
DECLARE_WRITE8_MEMBER(nbmj8900_vramsel_w);
DECLARE_WRITE8_MEMBER(nbmj8900_romsel_w);
emu_timer *m_blitter_timer;
DECLARE_READ8_MEMBER(palette_type1_r);
DECLARE_WRITE8_MEMBER(palette_type1_w);
DECLARE_READ8_MEMBER(palette_type2_r);
DECLARE_WRITE8_MEMBER(palette_type2_w);
DECLARE_READ8_MEMBER(palette_type3_r);
DECLARE_WRITE8_MEMBER(palette_type3_w);
DECLARE_WRITE8_MEMBER(clutsel_w);
DECLARE_READ8_MEMBER(clut_r);
DECLARE_WRITE8_MEMBER(clut_w);
DECLARE_WRITE8_MEMBER(blitter_w);
DECLARE_WRITE8_MEMBER(scrolly_w);
DECLARE_WRITE8_MEMBER(vramsel_w);
DECLARE_WRITE8_MEMBER(romsel_w);
DECLARE_DRIVER_INIT(togenkyo);
DECLARE_DRIVER_INIT(ohpaipee);
virtual void video_start();
UINT32 screen_update_nbmj8900(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void nbmj8900_vramflip(int vram);
UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void vramflip(int vram);
void update_pixel0(int x, int y);
void update_pixel1(int x, int y);
void nbmj8900_gfxdraw();
void gfxdraw();
void postload();
protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);

View File

@ -16,12 +16,12 @@
******************************************************************************/
READ8_MEMBER(nbmj8900_state::nbmj8900_palette_type1_r)
READ8_MEMBER(nbmj8900_state::palette_type1_r)
{
return m_palette_ptr[offset];
}
WRITE8_MEMBER(nbmj8900_state::nbmj8900_palette_type1_w)
WRITE8_MEMBER(nbmj8900_state::palette_type1_w)
{
int r, g, b;
@ -39,12 +39,12 @@ WRITE8_MEMBER(nbmj8900_state::nbmj8900_palette_type1_w)
}
#ifdef UNUSED_FUNCTION
READ8_MEMBER(nbmj8900_state::nbmj8900_palette_type2_r)
READ8_MEMBER(nbmj8900_state::palette_type2_r)
{
return m_palette_ptr[offset];
}
WRITE8_MEMBER(nbmj8900_state::nbmj8900_palette_type2_w)
WRITE8_MEMBER(nbmj8900_state::palette_type2_w)
{
int r, g, b;
@ -61,12 +61,12 @@ WRITE8_MEMBER(nbmj8900_state::nbmj8900_palette_type2_w)
m_palette->set_pen_color((offset & 0x0ff), pal4bit(r), pal4bit(g), pal4bit(b));
}
READ8_MEMBER(nbmj8900_state::nbmj8900_palette_type3_r)
READ8_MEMBER(nbmj8900_state::palette_type3_r)
{
return m_palette_ptr[offset];
}
WRITE8_MEMBER(nbmj8900_state::nbmj8900_palette_type3_w)
WRITE8_MEMBER(nbmj8900_state::palette_type3_w)
{
int r, g, b;
@ -84,17 +84,17 @@ WRITE8_MEMBER(nbmj8900_state::nbmj8900_palette_type3_w)
}
#endif
WRITE8_MEMBER(nbmj8900_state::nbmj8900_clutsel_w)
WRITE8_MEMBER(nbmj8900_state::clutsel_w)
{
m_clutsel = data;
}
READ8_MEMBER(nbmj8900_state::nbmj8900_clut_r)
READ8_MEMBER(nbmj8900_state::clut_r)
{
return m_clut[offset];
}
WRITE8_MEMBER(nbmj8900_state::nbmj8900_clut_w)
WRITE8_MEMBER(nbmj8900_state::clut_w)
{
m_clut[((m_clutsel & 0x7f) * 0x10) + (offset & 0x0f)] = data;
}
@ -103,7 +103,7 @@ WRITE8_MEMBER(nbmj8900_state::nbmj8900_clut_w)
******************************************************************************/
WRITE8_MEMBER(nbmj8900_state::nbmj8900_blitter_w)
WRITE8_MEMBER(nbmj8900_state::blitter_w)
{
switch (offset)
{
@ -114,25 +114,25 @@ WRITE8_MEMBER(nbmj8900_state::nbmj8900_blitter_w)
case 0x04: m_blitter_sizex = data; break;
case 0x05: m_blitter_sizey = data;
/* writing here also starts the blit */
nbmj8900_gfxdraw();
gfxdraw();
break;
case 0x06: m_blitter_direction_x = (data & 0x01) ? 1 : 0;
m_blitter_direction_y = (data & 0x02) ? 1 : 0;
m_flipscreen = (data & 0x04) ? 1 : 0;
m_dispflag = (data & 0x08) ? 0 : 1;
if (m_gfxdraw_mode) nbmj8900_vramflip(1);
nbmj8900_vramflip(0);
if (m_gfxdraw_mode) vramflip(1);
vramflip(0);
break;
case 0x07: break;
}
}
WRITE8_MEMBER(nbmj8900_state::nbmj8900_scrolly_w)
WRITE8_MEMBER(nbmj8900_state::scrolly_w)
{
m_scrolly = data;
}
WRITE8_MEMBER(nbmj8900_state::nbmj8900_vramsel_w)
WRITE8_MEMBER(nbmj8900_state::vramsel_w)
{
/* protection - not sure about this */
m_nb1413m3->m_sndromrgntag = (data & 0x20) ? "protdata" : "voice";
@ -140,7 +140,7 @@ WRITE8_MEMBER(nbmj8900_state::nbmj8900_vramsel_w)
m_vram = data;
}
WRITE8_MEMBER(nbmj8900_state::nbmj8900_romsel_w)
WRITE8_MEMBER(nbmj8900_state::romsel_w)
{
m_gfxrom = (data & 0x0f);
@ -157,7 +157,7 @@ WRITE8_MEMBER(nbmj8900_state::nbmj8900_romsel_w)
******************************************************************************/
void nbmj8900_state::nbmj8900_vramflip(int vram)
void nbmj8900_state::vramflip(int vram)
{
int x, y;
unsigned char color1, color2;
@ -209,7 +209,7 @@ void nbmj8900_state::device_timer(emu_timer &timer, device_timer_id id, int para
}
}
void nbmj8900_state::nbmj8900_gfxdraw()
void nbmj8900_state::gfxdraw()
{
unsigned char *GFX = memregion("gfx")->base();
@ -357,7 +357,7 @@ void nbmj8900_state::nbmj8900_gfxdraw()
}
m_nb1413m3->m_busyflag = 0;
timer_set(attotime::from_nsec(2500) * m_nb1413m3->m_busyctr, TIMER_BLITTER);
m_blitter_timer->adjust(attotime::from_nsec(2500) * m_nb1413m3->m_busyctr);
}
/******************************************************************************
@ -368,6 +368,8 @@ void nbmj8900_state::video_start()
{
m_screen_width = m_screen->width();
m_screen_height = m_screen->height();
m_blitter_timer = timer_alloc(TIMER_BLITTER);
m_screen->register_screen_bitmap(m_tmpbitmap0);
m_screen->register_screen_bitmap(m_tmpbitmap1);
@ -379,13 +381,39 @@ void nbmj8900_state::video_start()
memset(m_videoram1, 0xff, (m_screen_width * m_screen_height * sizeof(UINT8)));
// m_palette->pen(0x07f) = 0xff; /* palette_transparent_pen */
m_gfxdraw_mode = 1;
m_screen_refresh = 1;
save_item(NAME(m_scrolly));
save_item(NAME(m_blitter_destx));
save_item(NAME(m_blitter_desty));
save_item(NAME(m_blitter_sizex));
save_item(NAME(m_blitter_sizey));
save_item(NAME(m_blitter_src_addr));
save_item(NAME(m_blitter_direction_x));
save_item(NAME(m_blitter_direction_y));
save_item(NAME(m_vram));
save_item(NAME(m_gfxrom));
save_item(NAME(m_dispflag));
save_item(NAME(m_flipscreen));
save_item(NAME(m_clutsel));
//save_item(NAME(m_gfxdraw_mode)); //always 1?
save_pointer(NAME(m_videoram0), m_screen_width * m_screen_height);
save_pointer(NAME(m_videoram1), m_screen_width * m_screen_height);
save_pointer(NAME(m_palette_ptr), 0x200);
save_pointer(NAME(m_clut), 0x800);
save_item(NAME(m_flipscreen_old));
}
void nbmj8900_state::postload()
{
m_screen_refresh = 1;
}
/******************************************************************************
******************************************************************************/
UINT32 nbmj8900_state::screen_update_nbmj8900(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
UINT32 nbmj8900_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
int x, y;