From a7d1114325ee6be34654b4faded25c6f106dcb3a Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Thu, 19 Nov 2009 08:40:17 +0000 Subject: [PATCH] Added driver_data struct and save states to battlex.c, carjmbre.c, popper.c and spaceg.c ...some Omori love ;) --- .gitattributes | 3 + src/mame/drivers/battlex.c | 151 +++++++++++++++++---------- src/mame/drivers/carjmbre.c | 119 ++++++++++++++------- src/mame/drivers/popper.c | 137 ++++++++++++++++--------- src/mame/drivers/spaceg.c | 166 +++++++++++++++++++----------- src/mame/includes/battlex.h | 30 ++++++ src/mame/includes/carjmbre.h | 32 ++++++ src/mame/includes/popper.h | 40 ++++++++ src/mame/video/battlex.c | 65 +++++++----- src/mame/video/carjmbre.c | 102 +++++++++--------- src/mame/video/popper.c | 194 +++++++++++++++++++---------------- 11 files changed, 675 insertions(+), 364 deletions(-) create mode 100644 src/mame/includes/battlex.h create mode 100644 src/mame/includes/carjmbre.h create mode 100644 src/mame/includes/popper.h diff --git a/.gitattributes b/.gitattributes index 944b22d8093..c1c9cbd992f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2326,6 +2326,7 @@ src/mame/includes/badlands.h svneol=native#text/plain src/mame/includes/bagman.h svneol=native#text/plain src/mame/includes/balsente.h svneol=native#text/plain src/mame/includes/batman.h svneol=native#text/plain +src/mame/includes/battlex.h svneol=native#text/plain src/mame/includes/beathead.h svneol=native#text/plain src/mame/includes/beezer.h svneol=native#text/plain src/mame/includes/bigevglf.h svneol=native#text/plain @@ -2339,6 +2340,7 @@ src/mame/includes/buggychl.h svneol=native#text/plain src/mame/includes/bzone.h svneol=native#text/plain src/mame/includes/canyon.h svneol=native#text/plain src/mame/includes/capbowl.h svneol=native#text/plain +src/mame/includes/carjmbre.h svneol=native#text/plain src/mame/includes/carpolo.h svneol=native#text/plain src/mame/includes/cave.h svneol=native#text/plain src/mame/includes/ccastles.h svneol=native#text/plain @@ -2519,6 +2521,7 @@ src/mame/includes/policetr.h svneol=native#text/plain src/mame/includes/polyplay.h svneol=native#text/plain src/mame/includes/poolshrk.h svneol=native#text/plain src/mame/includes/pooyan.h svneol=native#text/plain +src/mame/includes/popper.h svneol=native#text/plain src/mame/includes/psikyosh.h svneol=native#text/plain src/mame/includes/psx.h svneol=native#text/plain src/mame/includes/qix.h svneol=native#text/plain diff --git a/src/mame/drivers/battlex.c b/src/mame/drivers/battlex.c index da4bc55df37..764d53842af 100644 --- a/src/mame/drivers/battlex.c +++ b/src/mame/drivers/battlex.c @@ -1,68 +1,65 @@ -/* battlex.c - by David Haywood +/*************************************************************************** -Stephh's notes : + Omori Battle Cross - - I don't know exactly how to call the "Free Play" Dip Switch 8( - It's effect is the following : - * you need to insert at least one credit and start a game - * when the game is over, you can start another games WITHOUT - inserting another coins - Note that the number of credits is decremented though. - Credits are BCD coded on 3 bytes (0x000000-0x999999) at addresses - 0xa039 (LSB), 0xa03a and 0xa03b (MSB), but only the LSB is displayed. + driver by David Haywood - - Setting the flipscreen dip to ON also hides the copyright message (?) + Stephh's notes : -TO DO : + - I don't know exactly how to call the "Free Play" Dip Switch 8( + It's effect is the following : + * you need to insert at least one credit and start a game + * when the game is over, you can start another games WITHOUT + inserting another coins + Note that the number of credits is decremented though. + Credits are BCD coded on 3 bytes (0x000000-0x999999) at addresses + 0xa039 (LSB), 0xa03a and 0xa03b (MSB), but only the LSB is displayed. - - missing starfield + - Setting the flipscreen dip to ON also hides the copyright message (?) - - game speed, its seems to be controlled by the IRQ's, how fast should it - be? firing seems frustratingly inconsistant + TO DO : - - colors match Tim's screen shots, but there's no guarantee RGB are in the - correct order. -*/ + - missing starfield -/* + - game speed, its seems to be controlled by the IRQ's, how fast should it + be? firing seems frustratingly inconsistant -Battle Cross (c)1982 Omori + - colors match Tim's screen shots, but there's no guarantee RGB are in the + correct order. -CPU: Z80A -Sound: AY-3-8910 -Other: 93419 (in socket marked 93219) +**************************************************************************** -RAM: 4116(x12), 2114(x2), 2114(x6) -PROMS: none + Battle Cross (c)1982 Omori -XTAL: 10.0 MHz + CPU: Z80A + Sound: AY-3-8910 + Other: 93419 (in socket marked 93219) -*/ + RAM: 4116(x12), 2114(x2), 2114(x6) + PROMS: none + + XTAL: 10.0 MHz + +***************************************************************************/ #include "driver.h" #include "cpu/z80/z80.h" #include "deprecat.h" #include "sound/ay8910.h" +#include "battlex.h" -extern WRITE8_HANDLER( battlex_palette_w ); -extern WRITE8_HANDLER( battlex_videoram_w ); -extern WRITE8_HANDLER( battlex_scroll_x_lsb_w ); -extern WRITE8_HANDLER( battlex_scroll_x_msb_w ); -extern WRITE8_HANDLER( battlex_flipscreen_w ); - -extern PALETTE_INIT( battlex ); -extern VIDEO_START( battlex ); -extern VIDEO_UPDATE( battlex ); - - -/*** MEMORY & PORT READ / WRITE **********************************************/ +/************************************* + * + * Memory maps + * + *************************************/ static ADDRESS_MAP_START( battlex_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x5fff) AM_ROM - AM_RANGE(0x8000, 0x8fff) AM_RAM_WRITE(battlex_videoram_w) AM_BASE(&videoram) - AM_RANGE(0x9000, 0x91ff) AM_RAM AM_BASE(&spriteram) + AM_RANGE(0x8000, 0x8fff) AM_RAM_WRITE(battlex_videoram_w) AM_BASE_MEMBER(battlex_state, videoram) + AM_RANGE(0x9000, 0x91ff) AM_RAM AM_BASE_MEMBER(battlex_state, spriteram) AM_RANGE(0xa000, 0xa3ff) AM_RAM AM_RANGE(0xe000, 0xe03f) AM_RAM_WRITE(battlex_palette_w) ADDRESS_MAP_END @@ -87,7 +84,11 @@ static ADDRESS_MAP_START( io_map, ADDRESS_SPACE_IO, 8 ) AM_RANGE(0x33, 0x33) AM_WRITE(battlex_scroll_x_msb_w) ADDRESS_MAP_END -/*** INPUT PORTS *************************************************************/ +/************************************* + * + * Input ports + * + *************************************/ static INPUT_PORTS_START( battlex ) PORT_START("DSW1") /* IN0 */ @@ -158,9 +159,14 @@ static INPUT_PORTS_START( battlex ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) INPUT_PORTS_END -/*** GFX DECODE **************************************************************/ +/************************************* + * + * Graphics definitions + * + *************************************/ + static const gfx_layout battlex_charlayout = { 8,8, @@ -192,16 +198,34 @@ static GFXDECODE_START( battlex ) GFXDECODE_ENTRY( "gfx2", 0, battlex_spritelayout, 16*8, 8 ) GFXDECODE_END -/*** MACHINE DRIVERS *********************************************************/ + +/************************************* + * + * Machine driver + * + *************************************/ + +static MACHINE_RESET( battlex ) +{ + battlex_state *state = (battlex_state *)machine->driver_data; + + state->scroll_lsb = 0; + state->scroll_msb = 0; +} static MACHINE_DRIVER_START( battlex ) + /* driver data */ + MDRV_DRIVER_DATA(battlex_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", Z80,10000000/2 ) /* 10 MHz, divided ? (Z80A CPU) */ MDRV_CPU_PROGRAM_MAP(battlex_map) MDRV_CPU_IO_MAP(io_map) MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,8) /* controls game speed? */ + MDRV_MACHINE_RESET(battlex) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(56) /* The video syncs at 15.8k H and 56 V (www.klov.com) */ @@ -223,7 +247,11 @@ static MACHINE_DRIVER_START( battlex ) MACHINE_DRIVER_END -/*** ROM LOADING *************************************************************/ +/************************************* + * + * ROM definition + * + *************************************/ ROM_START( battlex ) ROM_REGION( 0x10000, "maincpu", 0 ) @@ -250,11 +278,18 @@ ROM_START( battlex ) ROM_LOAD( "2732.e", 0x0000, 0x1000, CRC(126842b7) SHA1(2da4f64e077232c1dd0853d07d801f9781517850) ) ROM_END + +/************************************* + * + * Driver initialization + * + *************************************/ + static DRIVER_INIT( battlex ) { - UINT8 *cold = memory_region ( machine, "user1" ); - UINT8 *mskd = memory_region ( machine, "user2" ); - UINT8 *dest = memory_region ( machine, "gfx1" ); + UINT8 *cold = memory_region(machine, "user1"); + UINT8 *mskd = memory_region(machine, "user2"); + UINT8 *dest = memory_region(machine, "gfx1"); int outcount; @@ -267,22 +302,28 @@ static DRIVER_INIT( battlex ) int bitmask = 0x01; int bitcount; - for (bitcount = 0;bitcount < 8 ; bitcount ++) + for (bitcount = 0; bitcount < 8 ; bitcount ++) { int bit, col; - bit = (mskd[outcount*8+linecount] & bitmask) >> bitcount; + bit = (mskd[outcount * 8 + linecount] & bitmask) >> bitcount; - if (bit) col = (cold[outcount*8+(linecount&~1)+(bitcount/4)] & 0x0f) << 4; - else col = (cold[outcount*8+(linecount&~1)+(bitcount/4)] & 0xf0); + if (bit) + col = (cold[outcount * 8 + (linecount & ~1) + (bitcount / 4)] & 0x0f) << 4; + else + col = (cold[outcount * 8 + (linecount & ~1) + (bitcount / 4)] & 0xf0); - dest[outcount*32 + linecount*4 + bitcount /2] |= (col >> (4*(bitcount & 1))); + dest[outcount * 32 + linecount * 4 + bitcount /2] |= (col >> (4 * (bitcount & 1))); bitmask = bitmask << 1; } } } } -/*** GAME DRIVERS ************************************************************/ -GAME( 1982, battlex, 0, battlex, battlex, battlex, ROT180, "Omori Electric", "Battle Cross", GAME_IMPERFECT_GRAPHICS ) +/************************************* + * + * Game driver + * + *************************************/ +GAME( 1982, battlex, 0, battlex, battlex, battlex, ROT180, "Omori Electric", "Battle Cross", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/carjmbre.c b/src/mame/drivers/carjmbre.c index 523c626c534..064700df634 100644 --- a/src/mame/drivers/carjmbre.c +++ b/src/mame/drivers/carjmbre.c @@ -1,29 +1,30 @@ -/* -Car Jamboree -Omori Electric CAD (OEC) 1981 +/*************************************************************************** -c14 c.d19 -c13 c.d18 c10 -c12 c9 -c11 2125 2125 - 2125 2125 - 2125 2125 2114 2114 - 2125 2125 2114 2114 - 2125 2125 c8 - 2125 2125 c7 - c6 - c5 - c4 - c3 -5101 c2 -5101 c1 - 6116 -18.432MHz - 6116 -Z80A c15 - Z80A - 8910 SW - 8910 + Car Jamboree + Omori Electric CAD (OEC) 1981 + + c14 c.d19 + c13 c.d18 c10 + c12 c9 + c11 2125 2125 + 2125 2125 + 2125 2125 2114 2114 + 2125 2125 2114 2114 + 2125 2125 c8 + 2125 2125 c7 + c6 + c5 + c4 + c3 + 5101 c2 + 5101 c1 + 6116 + 18.432MHz + 6116 + Z80A c15 + Z80A + 8910 SW + 8910 Notes: @@ -38,20 +39,19 @@ Notes: - colours are wrong, sprites and characters only using one of the proms - background colour calculation is a guess -*/ + +***************************************************************************/ #include "driver.h" #include "cpu/z80/z80.h" #include "sound/ay8910.h" +#include "carjmbre.h" -WRITE8_HANDLER( carjmbre_flipscreen_w ); -WRITE8_HANDLER( carjmbre_bgcolor_w ); -WRITE8_HANDLER( carjmbre_videoram_w ); - -PALETTE_INIT( carjmbre ); -VIDEO_START( carjmbre ); -VIDEO_UPDATE( carjmbre ); - +/************************************* + * + * Memory maps + * + *************************************/ static ADDRESS_MAP_START( carjmbre_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM @@ -62,8 +62,8 @@ static ADDRESS_MAP_START( carjmbre_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x8807, 0x8807) AM_WRITE(carjmbre_flipscreen_w) AM_RANGE(0x8fc1, 0x8fc1) AM_WRITENOP //overrun during initial screen clear AM_RANGE(0x8fe1, 0x8fe1) AM_WRITENOP //overrun during initial screen clear - AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(carjmbre_videoram_w) AM_BASE(&videoram) - AM_RANGE(0x9800, 0x985f) AM_WRITE(SMH_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size) + AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(carjmbre_videoram_w) AM_BASE_MEMBER(carjmbre_state, videoram) + AM_RANGE(0x9800, 0x985f) AM_WRITE(SMH_RAM) AM_BASE_MEMBER(carjmbre_state, spriteram) AM_SIZE(&spriteram_size) AM_RANGE(0x9880, 0x98df) AM_WRITE(SMH_RAM) //spriteram mirror AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P1") AM_RANGE(0xa800, 0xa800) AM_READ_PORT("P2") @@ -92,6 +92,12 @@ static ADDRESS_MAP_START( carjmbre_sound_io_map, ADDRESS_SPACE_IO, 8 ) AM_RANGE(0x32, 0x32) AM_WRITENOP //?? written before and after 0x31 with same value ADDRESS_MAP_END +/************************************* + * + * Input ports + * + *************************************/ + static INPUT_PORTS_START( carjmbre ) PORT_START("P1") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) //coin error if held high for 1s @@ -138,6 +144,12 @@ static INPUT_PORTS_START( carjmbre ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) INPUT_PORTS_END +/************************************* + * + * Graphics definitions + * + *************************************/ + static const gfx_layout carjmbre_charlayout = { 8,8, @@ -165,13 +177,33 @@ static GFXDECODE_START( carjmbre ) GFXDECODE_ENTRY( "gfx2", 0, carjmbre_spritelayout, 0, 16 ) GFXDECODE_END + +/************************************* + * + * Machine driver + * + *************************************/ + +static MACHINE_RESET( carjmbre ) +{ + carjmbre_state *state = (carjmbre_state *)machine->driver_data; + + state->flipscreen = 0; + state->bgcolor = 0; +} + static MACHINE_DRIVER_START( carjmbre ) + /* driver data */ + MDRV_DRIVER_DATA(carjmbre_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", Z80,18432000/6) MDRV_CPU_PROGRAM_MAP(carjmbre_map) MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse) + MDRV_MACHINE_RESET(carjmbre) + MDRV_CPU_ADD("audiocpu", Z80, 1500000) MDRV_CPU_PROGRAM_MAP(carjmbre_sound_map) MDRV_CPU_IO_MAP(carjmbre_sound_io_map) @@ -180,7 +212,7 @@ static MACHINE_DRIVER_START( carjmbre ) /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) - MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) + MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) MDRV_SCREEN_SIZE(32*8, 32*8) MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) @@ -202,6 +234,12 @@ static MACHINE_DRIVER_START( carjmbre ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.12) MACHINE_DRIVER_END +/************************************* + * + * ROM definition + * + *************************************/ + ROM_START( carjmbre ) ROM_REGION( 0x10000, "maincpu", 0 ) ROM_LOAD( "c1", 0x0000, 0x1000, CRC(62b21739) SHA1(710e5c52f27603aa8f864f6f28d7272f21271d60) ) @@ -231,5 +269,10 @@ ROM_START( carjmbre ) ROM_LOAD( "c.d18", 0x0020, 0x0020, CRC(7b9ed1b0) SHA1(ec5e1f56e5a2fc726083866c08ac0e1de0ed6ace) ) ROM_END -GAME( 1983, carjmbre, 0, carjmbre, carjmbre, 0, ROT90, "Omori Electric Co., Ltd.", "Car Jamboree", GAME_IMPERFECT_COLORS ) +/************************************* + * + * Game driver + * + *************************************/ +GAME( 1983, carjmbre, 0, carjmbre, carjmbre, 0, ROT90, "Omori Electric Co., Ltd.", "Car Jamboree", GAME_IMPERFECT_COLORS | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/popper.c b/src/mame/drivers/popper.c index 3bcab1655e6..24299c85901 100644 --- a/src/mame/drivers/popper.c +++ b/src/mame/drivers/popper.c @@ -1,24 +1,26 @@ -/* -Popper +/*************************************************************************** -Omori Electric CAD (OEC) 1983 + Popper + + Omori Electric CAD (OEC) 1983 -PPR-12 + PPR-12 -18.432MHz 6148 6148 - 6148 4148 - 2128 - 2128 - 2128 - 2128 - p3 p6 -z80A p2 p5 - p0 p1 p4 - z80A - 8910 - 8910 SW2 SW1 p.m4 p.m3 + 18.432MHz 6148 6148 + 6148 4148 + 2128 + 2128 + 2128 + 2128 + p3 p6 + z80A p2 p5 + p0 p1 p4 + z80A + 8910 + 8910 SW2 SW1 p.m4 p.m3 + Notes: @@ -76,28 +78,21 @@ Notes: - the game freezes in much the same way as the stop dip switch when the coin inputs are high (a short PORT_IMPULSE duration will still cause a hitch), so potentially there's a coin lockout mechanism -*/ + +***************************************************************************/ #include "driver.h" #include "cpu/z80/z80.h" #include "deprecat.h" #include "sound/ay8910.h" +#include "popper.h" -extern UINT8 *popper_videoram, *popper_attribram, *popper_ol_videoram, *popper_ol_attribram, *popper_spriteram; -extern size_t popper_spriteram_size; - -WRITE8_HANDLER( popper_videoram_w ); -WRITE8_HANDLER( popper_attribram_w ); -WRITE8_HANDLER( popper_ol_videoram_w ); -WRITE8_HANDLER( popper_ol_attribram_w ); -WRITE8_HANDLER( popper_flipscreen_w ); -WRITE8_HANDLER( popper_e002_w ); -WRITE8_HANDLER( popper_gfx_bank_w ); - -PALETTE_INIT( popper ); -VIDEO_START( popper ); -VIDEO_UPDATE( popper ); +/************************************* + * + * Memory handlers + * + *************************************/ //e000 e001 e002 e003 //76543210 76543210 76543210 76543210 @@ -128,18 +123,18 @@ VIDEO_UPDATE( popper ); // -------x sound static READ8_HANDLER( popper_input_ports_r ) { - UINT8 data=0; + UINT8 data = 0; switch (offset) { // player inputs dsw1 dsw2 - case 0: data=input_port_read(space->machine, "IN0") | ((input_port_read(space->machine, "DSW1") & 0x02)<<5) | ((input_port_read(space->machine, "DSW2") & 0x01)<<4); break; - case 1: data=input_port_read(space->machine, "IN1") | ((input_port_read(space->machine, "DSW1") & 0x01)<<6) | ((input_port_read(space->machine, "DSW2") & 0x02)<<3); break; - case 2: data=input_port_read(space->machine, "IN2") | ((input_port_read(space->machine, "DSW1") & 0x08)<<3) | ((input_port_read(space->machine, "DSW2") & 0x04)<<2); break; - case 3: data=input_port_read(space->machine, "IN3") | ((input_port_read(space->machine, "DSW1") & 0x04)<<4) | ((input_port_read(space->machine, "DSW2") & 0x08)<<1); break; - case 4: data= ((input_port_read(space->machine, "DSW1") & 0x20)<<2) | ((input_port_read(space->machine, "DSW2") & 0x10)<<1); break; - case 5: data= ((input_port_read(space->machine, "DSW1") & 0x10)<<3) | ((input_port_read(space->machine, "DSW2") & 0x20)<<0); break; - case 6: data= ((input_port_read(space->machine, "DSW1") & 0x80)<<0) | ((input_port_read(space->machine, "DSW2") & 0x40)>>1); break; - case 7: data= ((input_port_read(space->machine, "DSW1") & 0x40)<<1) | ((input_port_read(space->machine, "DSW2") & 0x80)>>2); break; + case 0: data = input_port_read(space->machine, "IN0") | ((input_port_read(space->machine, "DSW1") & 0x02) << 5) | ((input_port_read(space->machine, "DSW2") & 0x01) << 4); break; + case 1: data = input_port_read(space->machine, "IN1") | ((input_port_read(space->machine, "DSW1") & 0x01) << 6) | ((input_port_read(space->machine, "DSW2") & 0x02) << 3); break; + case 2: data = input_port_read(space->machine, "IN2") | ((input_port_read(space->machine, "DSW1") & 0x08) << 3) | ((input_port_read(space->machine, "DSW2") & 0x04) << 2); break; + case 3: data = input_port_read(space->machine, "IN3") | ((input_port_read(space->machine, "DSW1") & 0x04) << 4) | ((input_port_read(space->machine, "DSW2") & 0x08) << 1); break; + case 4: data = ((input_port_read(space->machine, "DSW1") & 0x20) << 2) | ((input_port_read(space->machine, "DSW2") & 0x10) << 1); break; + case 5: data = ((input_port_read(space->machine, "DSW1") & 0x10) << 3) | ((input_port_read(space->machine, "DSW2") & 0x20) << 0); break; + case 6: data = ((input_port_read(space->machine, "DSW1") & 0x80) << 0) | ((input_port_read(space->machine, "DSW2") & 0x40) >> 1); break; + case 7: data = ((input_port_read(space->machine, "DSW1") & 0x40) << 1) | ((input_port_read(space->machine, "DSW2") & 0x80) >> 2); break; } return data; } @@ -150,16 +145,22 @@ static READ8_HANDLER( popper_soundcpu_nmi_r ) return 0; } +/************************************* + * + * Memory maps + * + *************************************/ + static ADDRESS_MAP_START( popper_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x5fff) AM_ROM AM_RANGE(0xc000, 0xc1bf) AM_RAM - AM_RANGE(0xc1c0, 0xc1ff) AM_RAM_WRITE(popper_ol_videoram_w) AM_BASE(&popper_ol_videoram) - AM_RANGE(0xc200, 0xc61f) AM_RAM_WRITE(popper_videoram_w) AM_BASE(&popper_videoram) + AM_RANGE(0xc1c0, 0xc1ff) AM_RAM_WRITE(popper_ol_videoram_w) AM_BASE_MEMBER(popper_state, ol_videoram) + AM_RANGE(0xc200, 0xc61f) AM_RAM_WRITE(popper_videoram_w) AM_BASE_MEMBER(popper_state, videoram) AM_RANGE(0xc620, 0xc9bf) AM_RAM - AM_RANGE(0xc9c0, 0xc9ff) AM_RAM_WRITE(popper_ol_attribram_w) AM_BASE(&popper_ol_attribram) - AM_RANGE(0xca00, 0xce1f) AM_RAM_WRITE(popper_attribram_w) AM_BASE(&popper_attribram) + AM_RANGE(0xc9c0, 0xc9ff) AM_RAM_WRITE(popper_ol_attribram_w) AM_BASE_MEMBER(popper_state, ol_attribram) + AM_RANGE(0xca00, 0xce1f) AM_RAM_WRITE(popper_attribram_w) AM_BASE_MEMBER(popper_state, attribram) AM_RANGE(0xce20, 0xcfff) AM_RAM - AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_BASE(&popper_spriteram) AM_SIZE(&popper_spriteram_size) + AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_BASE_MEMBER(popper_state, spriteram) AM_SIZE(&spriteram_size) AM_RANGE(0xd800, 0xdfff) AM_RAM AM_SHARE(1) AM_RANGE(0xe000, 0xe007) AM_READ(popper_input_ports_r) AM_RANGE(0xe000, 0xe000) AM_WRITE(interrupt_enable_w) @@ -185,6 +186,12 @@ static ADDRESS_MAP_START( popper_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0xd800, 0xdfff) AM_RAM AM_SHARE(1) ADDRESS_MAP_END +/************************************* + * + * Input ports + * + *************************************/ + static INPUT_PORTS_START( popper ) PORT_START("IN0") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) @@ -258,6 +265,12 @@ static INPUT_PORTS_START( popper ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) INPUT_PORTS_END +/************************************* + * + * Graphics definitions + * + *************************************/ + static const gfx_layout popper_charlayout = { 8,8, @@ -285,8 +298,26 @@ static GFXDECODE_START( popper ) GFXDECODE_ENTRY( "gfx2", 0, popper_spritelayout, 0, 16 ) GFXDECODE_END +/************************************* + * + * Machine driver + * + *************************************/ + +static MACHINE_RESET( popper ) +{ + popper_state *state = (popper_state *)machine->driver_data; + + state->flipscreen = 0; + state->e002 = 0; + state->gfx_bank = 0; +} + static MACHINE_DRIVER_START( popper ) + /* driver data */ + MDRV_DRIVER_DATA(popper_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", Z80,18432000/6) MDRV_CPU_PROGRAM_MAP(popper_map) @@ -298,6 +329,8 @@ static MACHINE_DRIVER_START( popper ) MDRV_QUANTUM_TIME(HZ(1800)) + MDRV_MACHINE_RESET(popper) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) @@ -324,6 +357,12 @@ static MACHINE_DRIVER_START( popper ) MACHINE_DRIVER_END +/************************************* + * + * ROM definition + * + *************************************/ + ROM_START( popper ) ROM_REGION( 0x10000, "maincpu", 0 ) ROM_LOAD( "p1", 0x0000, 0x2000, CRC(56881b70) SHA1(d3ade7a54a6cb8a0babf0d667a6b27f492a739dc) ) @@ -346,4 +385,10 @@ ROM_START( popper ) ROM_END -GAME( 1983, popper, 0, popper, popper, 0, ROT90, "Omori Electric Co., Ltd.", "Popper", GAME_IMPERFECT_COLORS ) +/************************************* + * + * Game driver + * + *************************************/ + +GAME( 1983, popper, 0, popper, popper, 0, ROT90, "Omori Electric Co., Ltd.", "Popper", GAME_IMPERFECT_COLORS | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/spaceg.c b/src/mame/drivers/spaceg.c index 2e61047cfcf..8b5d3b2c593 100644 --- a/src/mame/drivers/spaceg.c +++ b/src/mame/drivers/spaceg.c @@ -1,10 +1,5 @@ -#include "driver.h" -#include "cpu/z80/z80.h" -#include "sound/dac.h" -#include "sound/sn76496.h" +/************************************************************************************** - -/* Space Guerrilla PCB Layout -------------------------- @@ -164,94 +159,114 @@ Notes: DIP24- Unpopulated position for DIP24 IC All ROMs type 2708 (DIP24) -*/ +**************************************************************************************/ + +#include "driver.h" +#include "cpu/z80/z80.h" +#include "sound/dac.h" +#include "sound/sn76496.h" +/************************************* + * + * Driver data + * + *************************************/ +typedef struct _spaceg_state spaceg_state; +struct _spaceg_state +{ + UINT8 * videoram; + UINT8 * unkram; + UINT8 * io9400; + UINT8 * io9401; +}; -static UINT8 *unkram; - -static UINT8 *io9400; -static UINT8 *io9401; +/************************************* + * + * Video emulation + * + *************************************/ static PALETTE_INIT( spaceg ) { int i; - for (i=0; i<128; i++) + for (i = 0; i < 128; i++) palette_set_color (machine, i, MAKE_RGB(0x00,0x00,0x00)); - palette_set_color (machine,0, MAKE_RGB(0x00,0x00,0x00)); //ok czarny - palette_set_color (machine,1, MAKE_RGB(0x7f,0x00,0x00));//??? - palette_set_color (machine,2, MAKE_RGB(0xff,0xff,0xff)); //ok+ bialy - palette_set_color (machine,3, MAKE_RGB(0xff,0x00,0x00)); //ok j.czerw. - palette_set_color (machine,4, MAKE_RGB(0x3f,0x3f,0xff)); //ok j.niebieski - palette_set_color (machine,5, MAKE_RGB(0x3f,0xff,0x3f)); //ok j.zielony - palette_set_color (machine,6, MAKE_RGB(0xff,0xbf,0xbf)); //ok+ 'majtki' - palette_set_color (machine,7, MAKE_RGB(0xff,0xff,0x00)); //ok+ zolty + palette_set_color (machine, 0, MAKE_RGB(0x00,0x00,0x00)); //ok czarny + palette_set_color (machine, 1, MAKE_RGB(0x7f,0x00,0x00));//??? + palette_set_color (machine, 2, MAKE_RGB(0xff,0xff,0xff)); //ok+ bialy + palette_set_color (machine, 3, MAKE_RGB(0xff,0x00,0x00)); //ok j.czerw. + palette_set_color (machine, 4, MAKE_RGB(0x3f,0x3f,0xff)); //ok j.niebieski + palette_set_color (machine, 5, MAKE_RGB(0x3f,0xff,0x3f)); //ok j.zielony + palette_set_color (machine, 6, MAKE_RGB(0xff,0xbf,0xbf)); //ok+ 'majtki' + palette_set_color (machine, 7, MAKE_RGB(0xff,0xff,0x00)); //ok+ zolty - palette_set_color (machine,8, MAKE_RGB(0xff,0x7f,0x00)); //ok+ pomaranczowy - palette_set_color (machine,9, MAKE_RGB(0x3f,0xbf,0xff)); //ok j.niebieski (ciemniejszy od 13) - palette_set_color (machine,10,MAKE_RGB(0x3f,0xbf,0x3f)); //ok+ c.zielony - palette_set_color (machine,11,MAKE_RGB(0x00,0xff,0x00)); //ok j.zielony - palette_set_color (machine,12,MAKE_RGB(0x7f,0x00,0x00)); //ok brazowy (c.czerw) - palette_set_color (machine,13,MAKE_RGB(0x7f,0xbf,0xff)); //ok j.niebieski (jasniejszy od 9) - palette_set_color (machine,14,MAKE_RGB(0x00,0xff,0xff));//??? - palette_set_color (machine,15,MAKE_RGB(0x7f,0x7f,0x7f));//??? + palette_set_color (machine, 8, MAKE_RGB(0xff,0x7f,0x00)); //ok+ pomaranczowy + palette_set_color (machine, 9, MAKE_RGB(0x3f,0xbf,0xff)); //ok j.niebieski (ciemniejszy od 13) + palette_set_color (machine, 10, MAKE_RGB(0x3f,0xbf,0x3f)); //ok+ c.zielony + palette_set_color (machine, 11, MAKE_RGB(0x00,0xff,0x00)); //ok j.zielony + palette_set_color (machine, 12, MAKE_RGB(0x7f,0x00,0x00)); //ok brazowy (c.czerw) + palette_set_color (machine, 13, MAKE_RGB(0x7f,0xbf,0xff)); //ok j.niebieski (jasniejszy od 9) + palette_set_color (machine, 14, MAKE_RGB(0x00,0xff,0xff));//??? + palette_set_color (machine, 15, MAKE_RGB(0x7f,0x7f,0x7f));//??? } static WRITE8_HANDLER( zvideoram_w ) { + spaceg_state *state = (spaceg_state *)space->machine->driver_data; int col; - col = unkram[0x400]; + col = state->unkram[0x400]; - if (col>0x0f) popmessage("color>0x0f =%2d",col); + if (col > 0x0f) + popmessage("color > 0x0f = %2d", col); - col &=0x0f; + col &= 0x0f; - switch(*io9401) + switch (*state->io9401) { case 0x0d: /* 1101 */ - videoram[offset] &= ~data; - data = videoram[offset]; + state->videoram[offset] &= ~data; + data = state->videoram[offset]; break; case 0x01: /* 0001 */ case 0x00: /* 0000 */ - videoram[offset] = data; + state->videoram[offset] = data; break; default: - logerror("mode =%02x pc=%04x\n",*io9401,cpu_get_pc(space->cpu) ); - popmessage("mode =%02x pc=%04x\n",*io9401,cpu_get_pc(space->cpu) ); + logerror("mode = %02x pc = %04x\n", *state->io9401, cpu_get_pc(space->cpu)); + popmessage("mode = %02x pc = %04x\n", *state->io9401, cpu_get_pc(space->cpu)); return; } - unkram [offset] = col; + state->unkram[offset] = col; } static READ8_HANDLER(spaceg_colorram_r) { + spaceg_state *state = (spaceg_state *)space->machine->driver_data; + int rgbcolor; -int rgbcolor; - - if (offset<0x400) + if (offset < 0x400) { - rgbcolor = (unkram[offset]<<1) | ((offset &0x100)>>8); + rgbcolor = (state->unkram[offset] << 1) | ((offset &0x100) >> 8); - if ((offset>=0x200) && (offset<0x220)) /* 0xa200- 0xa21f */ + if ((offset >= 0x200) && (offset < 0x220)) /* 0xa200- 0xa21f */ { /* palette 1 */ int col_ind = offset & 0x1f; palette_set_color_rgb(space->machine, 0x10 + 0x00 + col_ind, pal3bit(rgbcolor >> 0), pal3bit(rgbcolor >> 6), pal3bit(rgbcolor >> 3)); } - else - if ((offset>=0x300) && (offset<0x320)) /* 0xa300- 0xa31f */ + else if ((offset >= 0x300) && (offset < 0x320)) /* 0xa300- 0xa31f */ { /* palette 2 */ int col_ind = offset & 0x1f; @@ -261,29 +276,29 @@ int rgbcolor; logerror("palette? read from unkram offset = %04x\n",offset); } -if (*io9401!=0x40) - logerror("unkram read in mode: 9401 = %02x (offset=%04x)\n",*io9401,offset); + if (*state->io9401 != 0x40) + logerror("unkram read in mode: 9401 = %02x (offset = %04x)\n", *state->io9401, offset); - - return unkram[offset]; + return state->unkram[offset]; } static VIDEO_UPDATE( spaceg ) { + spaceg_state *state = (spaceg_state *)screen->machine->driver_data; offs_t offs; for (offs = 0; offs < 0x2000; offs++) { int i; - UINT8 data = videoram[offs]; + UINT8 data = state->videoram[offs]; int y = offs & 0xff; - UINT8 x = ((offs >> 8) << 3) - ((*io9400 & 0xe0) >> 5); + UINT8 x = ((offs >> 8) << 3) - ((*state->io9400 & 0xe0) >> 5); for (i = 0; i < 8; i++) { - *BITMAP_ADDR16(bitmap, y, x) = (data & 0x80) ? unkram[offs] : 0; + *BITMAP_ADDR16(bitmap, y, x) = (data & 0x80) ? state->unkram[offs] : 0; x++; data <<= 1; @@ -294,16 +309,22 @@ static VIDEO_UPDATE( spaceg ) } +/************************************* + * + * Memory maps + * + *************************************/ + static ADDRESS_MAP_START( spaceg_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_ROM AM_RANGE(0x3000, 0x3fff) AM_ROM AM_RANGE(0x7000, 0x77ff) AM_RAM - AM_RANGE(0xa000, 0xbfff) AM_READWRITE(spaceg_colorram_r, SMH_RAM) AM_BASE(&unkram) - AM_RANGE(0xc000, 0xdfff) AM_RAM_WRITE(zvideoram_w) AM_BASE(&videoram) + AM_RANGE(0xa000, 0xbfff) AM_READWRITE(spaceg_colorram_r, SMH_RAM) AM_BASE_MEMBER(spaceg_state, unkram) + AM_RANGE(0xc000, 0xdfff) AM_RAM_WRITE(zvideoram_w) AM_BASE_MEMBER(spaceg_state, videoram) - AM_RANGE(0x9400, 0x9400) AM_WRITE(SMH_RAM) AM_BASE(&io9400) /* gfx ctrl */ - AM_RANGE(0x9401, 0x9401) AM_WRITE(SMH_RAM) AM_BASE(&io9401) /* gfx ctrl */ + AM_RANGE(0x9400, 0x9400) AM_WRITE(SMH_RAM) AM_BASE_MEMBER(spaceg_state, io9400) /* gfx ctrl */ + AM_RANGE(0x9401, 0x9401) AM_WRITE(SMH_RAM) AM_BASE_MEMBER(spaceg_state, io9401) /* gfx ctrl */ /* 9402 - bits 0 and 1 probably control the lamps under the player 1 and player 2 start buttons bit 2 - unknown - @@ -321,6 +342,12 @@ ADDRESS_MAP_END +/************************************* + * + * Input ports + * + *************************************/ + static INPUT_PORTS_START( spaceg ) PORT_START("9800") PORT_DIPUNUSED( 0x01, IP_ACTIVE_HIGH ) /* was related to coinage */ @@ -360,8 +387,17 @@ static INPUT_PORTS_START( spaceg ) INPUT_PORTS_END +/************************************* + * + * Machine driver + * + *************************************/ + static MACHINE_DRIVER_START( spaceg ) + /* driver data */ + MDRV_DRIVER_DATA(spaceg_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", Z80,2500000) /* 2.5 MHz */ MDRV_CPU_PROGRAM_MAP(spaceg_map) @@ -396,11 +432,11 @@ static MACHINE_DRIVER_START( spaceg ) MACHINE_DRIVER_END -/*************************************************************************** - - Game driver(s) - -***************************************************************************/ +/************************************* + * + * ROM definition + * + *************************************/ ROM_START( spaceg ) ROM_REGION( 0x10000, "maincpu", 0 ) @@ -419,4 +455,10 @@ ROM_START( spaceg ) ROM_END -GAME( 1979, spaceg, 0, spaceg, spaceg, 0, ROT270, "Omori", "Space Guerrilla", GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND ) +/************************************* + * + * Game driver + * + *************************************/ + +GAME( 1979, spaceg, 0, spaceg, spaceg, 0, ROT270, "Omori", "Space Guerrilla", GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/includes/battlex.h b/src/mame/includes/battlex.h new file mode 100644 index 00000000000..1f994ad9c91 --- /dev/null +++ b/src/mame/includes/battlex.h @@ -0,0 +1,30 @@ +/*************************************************************************** + + Battle Cross + +***************************************************************************/ + +typedef struct _battlex_state battlex_state; +struct _battlex_state +{ + /* memory pointers */ + UINT8 * videoram; + UINT8 * spriteram; + + /* video-related */ + tilemap *bg_tilemap; + int scroll_lsb, scroll_msb; +}; + + +/*----------- defined in video/battlex.c -----------*/ + +extern WRITE8_HANDLER( battlex_palette_w ); +extern WRITE8_HANDLER( battlex_videoram_w ); +extern WRITE8_HANDLER( battlex_scroll_x_lsb_w ); +extern WRITE8_HANDLER( battlex_scroll_x_msb_w ); +extern WRITE8_HANDLER( battlex_flipscreen_w ); + +extern PALETTE_INIT( battlex ); +extern VIDEO_START( battlex ); +extern VIDEO_UPDATE( battlex ); diff --git a/src/mame/includes/carjmbre.h b/src/mame/includes/carjmbre.h new file mode 100644 index 00000000000..e791fcab41f --- /dev/null +++ b/src/mame/includes/carjmbre.h @@ -0,0 +1,32 @@ +/*************************************************************************** + + carjmbre + +***************************************************************************/ + +typedef struct _carjmbre_state carjmbre_state; +struct _carjmbre_state +{ + /* memory pointers */ + UINT8 * videoram; + UINT8 * spriteram; + + /* video-related */ + tilemap *cj_tilemap; + UINT8 flipscreen; + UINT16 bgcolor; +}; + + + +/*----------- defined in video/carjmbre.c -----------*/ + +WRITE8_HANDLER( carjmbre_flipscreen_w ); +WRITE8_HANDLER( carjmbre_bgcolor_w ); +WRITE8_HANDLER( carjmbre_videoram_w ); + +PALETTE_INIT( carjmbre ); +VIDEO_START( carjmbre ); +VIDEO_UPDATE( carjmbre ); + + diff --git a/src/mame/includes/popper.h b/src/mame/includes/popper.h new file mode 100644 index 00000000000..6ea8b9523ab --- /dev/null +++ b/src/mame/includes/popper.h @@ -0,0 +1,40 @@ +/*************************************************************************** + + Popper + +***************************************************************************/ + +typedef struct _popper_state popper_state; +struct _popper_state +{ + /* memory pointers */ + UINT8 * videoram; + UINT8 * ol_videoram; + UINT8 * attribram; + UINT8 * ol_attribram; + UINT8 * spriteram; +// size_t spriteram_size; + + /* video-related */ + tilemap *p123_tilemap, *p0_tilemap; + tilemap *ol_p123_tilemap, *ol_p0_tilemap; + INT32 flipscreen, e002, gfx_bank; + rectangle tilemap_clip; +}; + + +/*----------- defined in video/popper.c -----------*/ + +WRITE8_HANDLER( popper_videoram_w ); +WRITE8_HANDLER( popper_attribram_w ); +WRITE8_HANDLER( popper_ol_videoram_w ); +WRITE8_HANDLER( popper_ol_attribram_w ); +WRITE8_HANDLER( popper_flipscreen_w ); +WRITE8_HANDLER( popper_e002_w ); +WRITE8_HANDLER( popper_gfx_bank_w ); + +PALETTE_INIT( popper ); +VIDEO_START( popper ); +VIDEO_UPDATE( popper ); + + diff --git a/src/mame/video/battlex.c b/src/mame/video/battlex.c index 4ec0949007c..a3f60c79ad7 100644 --- a/src/mame/video/battlex.c +++ b/src/mame/video/battlex.c @@ -1,17 +1,19 @@ +/*************************************************************************** + + Video emulation for Omori Battle Cross + +***************************************************************************/ + #include "driver.h" - -static int battlex_scroll_lsb; -static int battlex_scroll_msb; - -static tilemap *bg_tilemap; +#include "battlex.h" PALETTE_INIT( battlex ) { - int i,col; + int i, col; - for (col = 0;col < 8;col++) + for (col = 0; col < 8; col++) { - for (i = 0;i < 16;i++) + for (i = 0; i < 16; i++) { int data = i | col; int g = pal1bit(data >> 0); @@ -28,30 +30,33 @@ PALETTE_INIT( battlex ) } #endif - palette_set_color(machine, i + 16 * col,MAKE_RGB(r,g,b)); + palette_set_color(machine, i + 16 * col, MAKE_RGB(r,g,b)); } } } WRITE8_HANDLER( battlex_palette_w ) { - palette_set_color_rgb(space->machine,16*8 + offset,pal1bit(data >> 2),pal1bit(data >> 0),pal1bit(data >> 1)); + palette_set_color_rgb(space->machine, 16 * 8 + offset, pal1bit(data >> 2), pal1bit(data >> 0), pal1bit(data >> 1)); } WRITE8_HANDLER( battlex_scroll_x_lsb_w ) { - battlex_scroll_lsb = data; + battlex_state *state = (battlex_state *)space->machine->driver_data; + state->scroll_lsb = data; } WRITE8_HANDLER( battlex_scroll_x_msb_w ) { - battlex_scroll_msb = data; + battlex_state *state = (battlex_state *)space->machine->driver_data; + state->scroll_msb = data; } WRITE8_HANDLER( battlex_videoram_w ) { - videoram[offset] = data; - tilemap_mark_tile_dirty(bg_tilemap, offset / 2); + battlex_state *state = (battlex_state *)space->machine->driver_data; + state->videoram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2); } WRITE8_HANDLER( battlex_flipscreen_w ) @@ -69,25 +74,30 @@ WRITE8_HANDLER( battlex_flipscreen_w ) static TILE_GET_INFO( get_bg_tile_info ) { - int tile = videoram[tile_index*2] | (((videoram[tile_index*2+1] & 0x01)) << 8); - int color = (videoram[tile_index*2+1] & 0x0e) >> 1; + battlex_state *state = (battlex_state *)machine->driver_data; + int tile = state->videoram[tile_index * 2] | (((state->videoram[tile_index * 2 + 1] & 0x01)) << 8); + int color = (state->videoram[tile_index * 2 + 1] & 0x0e) >> 1; - SET_TILE_INFO(0,tile,color,0); + SET_TILE_INFO(0, tile, color, 0); } VIDEO_START( battlex ) { - bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, - 8, 8, 64, 32); + battlex_state *state = (battlex_state *)machine->driver_data; + + state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 64, 32); + state_save_register_global(machine, state->scroll_lsb); + state_save_register_global(machine, state->scroll_msb); } -static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) { + battlex_state *state = (battlex_state *)machine->driver_data; const gfx_element *gfx = machine->gfx[1]; - UINT8 *source = spriteram; - UINT8 *finish = spriteram + 0x200; + UINT8 *source = state->spriteram; + UINT8 *finish = state->spriteram + 0x200; - while( sourcemachine->driver_data; + + tilemap_set_scrollx(state->bg_tilemap, 0, state->scroll_lsb | (state->scroll_msb << 8)); + tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0); draw_sprites(screen->machine, bitmap, cliprect); return 0; } diff --git a/src/mame/video/carjmbre.c b/src/mame/video/carjmbre.c index 7f44f72ee0e..54295b1ac73 100644 --- a/src/mame/video/carjmbre.c +++ b/src/mame/video/carjmbre.c @@ -1,20 +1,18 @@ -/* -Car Jamboree -Omori Electric CAD (OEC) 1981 -*/ +/*************************************************************************** + + Car Jamboree + Omori Electric CAD (OEC) 1981 + +***************************************************************************/ #include "driver.h" - -static tilemap *carjmbre_tilemap; - -static UINT8 carjmbre_flipscreen; -static UINT16 carjmbre_bgcolor; +#include "carjmbre.h" PALETTE_INIT( carjmbre ) { - int i,bit0,bit1,bit2,r,g,b; + int i, bit0, bit1, bit2, r, g, b; - for (i = 0;i < machine->config->total_colors; i++) + for (i = 0; i < machine->config->total_colors; i++) { /* red component */ bit0 = (*color_prom >> 0) & 0x01; @@ -32,63 +30,73 @@ PALETTE_INIT( carjmbre ) bit2 = (*color_prom >> 7) & 0x01; b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - palette_set_color(machine,i,MAKE_RGB(r,g,b)); + palette_set_color(machine, i, MAKE_RGB(r,g,b)); color_prom++; } } WRITE8_HANDLER( carjmbre_flipscreen_w ) { - carjmbre_flipscreen = data?(TILEMAP_FLIPX|TILEMAP_FLIPY):0; - tilemap_set_flip_all( space->machine,carjmbre_flipscreen ); + carjmbre_state *state = (carjmbre_state *)space->machine->driver_data; + + state->flipscreen = data ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0; + tilemap_set_flip_all(space->machine, state->flipscreen); } WRITE8_HANDLER( carjmbre_bgcolor_w ) { - int oldbg,i; + carjmbre_state *state = (carjmbre_state *)space->machine->driver_data; + int oldbg, i; - oldbg=carjmbre_bgcolor; + oldbg = state->bgcolor; - carjmbre_bgcolor&=0xff00>>(offset*8); - carjmbre_bgcolor|=((~data)&0xff)<<(offset*8); + state->bgcolor &= 0xff00 >> (offset * 8); + state->bgcolor |= ((~data) & 0xff) << (offset * 8); - if(oldbg!=carjmbre_bgcolor) + if ( oldbg != state->bgcolor) { - for (i=0;i<64;i+=4) - palette_set_color_rgb(space->machine, i, (carjmbre_bgcolor&0xff)*0x50, (carjmbre_bgcolor&0xff)*0x50, (carjmbre_bgcolor&0xff)!=0?0x50:0); + for (i = 0; i < 64; i += 4) + palette_set_color_rgb(space->machine, i, (state->bgcolor & 0xff) * 0x50, + (state->bgcolor & 0xff) * 0x50, (state->bgcolor & 0xff)!=0 ? 0x50 : 0); } } -static TILE_GET_INFO( get_carjmbre_tile_info ){ - UINT32 tile_number = videoram[tile_index] & 0xFF; - UINT8 attr = videoram[tile_index+0x400]; +static TILE_GET_INFO( get_carjmbre_tile_info ) +{ + carjmbre_state *state = (carjmbre_state *)machine->driver_data; + UINT32 tile_number = state->videoram[tile_index] & 0xff; + UINT8 attr = state->videoram[tile_index + 0x400]; tile_number += (attr & 0x80) << 1; /* bank */ SET_TILE_INFO( 0, tile_number, - (attr&0x7), + (attr & 0x7), 0); } -WRITE8_HANDLER( carjmbre_videoram_w ){ - videoram[offset] = data; - tilemap_mark_tile_dirty(carjmbre_tilemap,offset&0x3ff); +WRITE8_HANDLER( carjmbre_videoram_w ) +{ + carjmbre_state *state = (carjmbre_state *)space->machine->driver_data; + + state->videoram[offset] = data; + tilemap_mark_tile_dirty(state->cj_tilemap, offset & 0x3ff); } VIDEO_START( carjmbre ) { + carjmbre_state *state = (carjmbre_state *)machine->driver_data; - carjmbre_tilemap = tilemap_create( machine, get_carjmbre_tile_info,tilemap_scan_rows,8,8,32,32 ); - - state_save_register_global(machine, carjmbre_flipscreen); - state_save_register_global(machine, carjmbre_bgcolor); + state->cj_tilemap = tilemap_create(machine, get_carjmbre_tile_info, tilemap_scan_rows, 8, 8, 32, 32); + state_save_register_global(machine, state->flipscreen); + state_save_register_global(machine, state->bgcolor); } VIDEO_UPDATE( carjmbre ) { - int offs,troffs,sx,sy,flipx,flipy; + carjmbre_state *state = (carjmbre_state *)screen->machine->driver_data; + int offs, troffs, sx, sy, flipx, flipy; //colorram //76543210 @@ -97,7 +105,7 @@ VIDEO_UPDATE( carjmbre ) //----x--- ?? probably colour, only used for ramp and pond //-----xxx colour - tilemap_draw( bitmap,cliprect,carjmbre_tilemap,0,0 ); + tilemap_draw(bitmap, cliprect, state->cj_tilemap, 0, 0); //spriteram[offs] //+0 y pos @@ -110,32 +118,32 @@ VIDEO_UPDATE( carjmbre ) //----x--- ?? probably colour //-----xxx colour //+3 x pos - for (offs = spriteram_size-4; offs >= 0; offs-=4) + for (offs = spriteram_size - 4; offs >= 0; offs -= 4) { //before copying the sprites to spriteram the game reorders the first //sprite to last, sprite ordering is incorrect if this isn't undone - troffs=(offs-4+spriteram_size)%spriteram_size; + troffs = (offs - 4 + spriteram_size) % spriteram_size; //unused sprites are marked with ypos <= 0x02 (or >= 0xfd if screen flipped) - if (spriteram[troffs] > 0x02 && spriteram[troffs] < 0xfd) + if (state->spriteram[troffs] > 0x02 && state->spriteram[troffs] < 0xfd) { { - sx = spriteram[troffs+3]-7; - sy = 241-spriteram[troffs]; - flipx = (spriteram[troffs+2]&0x40)>>6; - flipy = (spriteram[troffs+2]&0x80)>>7; + sx = state->spriteram[troffs + 3] - 7; + sy = 241 - state->spriteram[troffs]; + flipx = (state->spriteram[troffs + 2] & 0x40) >> 6; + flipy = (state->spriteram[troffs + 2] & 0x80) >> 7; - if (carjmbre_flipscreen) + if (state->flipscreen) { - sx = (256+(226-sx))%256; - sy = 242-sy; + sx = (256 + (226 - sx)) % 256; + sy = 242 - sy; flipx = !flipx; flipy = !flipy; } - drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1], - spriteram[troffs+1], - spriteram[troffs+2]&0x07, + drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[1], + state->spriteram[troffs + 1], + state->spriteram[troffs + 2] & 0x07, flipx,flipy, sx,sy,0); } diff --git a/src/mame/video/popper.c b/src/mame/video/popper.c index 664404a2820..0ed36285a13 100644 --- a/src/mame/video/popper.c +++ b/src/mame/video/popper.c @@ -1,16 +1,14 @@ -/* -Popper -Omori Electric CAD (OEC) 1983 -*/ +/*************************************************************************** + + Popper + + Omori Electric CAD (OEC) 1983 + +***************************************************************************/ #include "driver.h" #include "video/resnet.h" - -static tilemap *popper_p123_tilemap, *popper_p0_tilemap, *popper_ol_p123_tilemap, *popper_ol_p0_tilemap; -UINT8 *popper_videoram, *popper_attribram, *popper_ol_videoram, *popper_ol_attribram, *popper_spriteram; -size_t popper_spriteram_size; -static INT32 popper_flipscreen, popper_e002, popper_gfx_bank; -static rectangle tilemap_clip; +#include "popper.h" /*************************************************************************** @@ -58,150 +56,167 @@ PALETTE_INIT( popper ) WRITE8_HANDLER( popper_ol_videoram_w ) { - popper_ol_videoram[offset] = data; - tilemap_mark_tile_dirty(popper_ol_p123_tilemap,offset); - tilemap_mark_tile_dirty(popper_ol_p0_tilemap,offset); + popper_state *state = (popper_state *)space->machine->driver_data; + + state->ol_videoram[offset] = data; + tilemap_mark_tile_dirty(state->ol_p123_tilemap, offset); + tilemap_mark_tile_dirty(state->ol_p0_tilemap, offset); } WRITE8_HANDLER( popper_videoram_w ) { - popper_videoram[offset] = data; - tilemap_mark_tile_dirty(popper_p123_tilemap,offset); - tilemap_mark_tile_dirty(popper_p0_tilemap,offset); + popper_state *state = (popper_state *)space->machine->driver_data; + + state->videoram[offset] = data; + tilemap_mark_tile_dirty(state->p123_tilemap, offset); + tilemap_mark_tile_dirty(state->p0_tilemap, offset); } WRITE8_HANDLER( popper_ol_attribram_w ) { - popper_ol_attribram[offset] = data; - tilemap_mark_tile_dirty(popper_ol_p123_tilemap,offset); - tilemap_mark_tile_dirty(popper_ol_p0_tilemap,offset); + popper_state *state = (popper_state *)space->machine->driver_data; + + state->ol_attribram[offset] = data; + tilemap_mark_tile_dirty(state->ol_p123_tilemap, offset); + tilemap_mark_tile_dirty(state->ol_p0_tilemap, offset); } WRITE8_HANDLER( popper_attribram_w ) { - popper_attribram[offset] = data; - tilemap_mark_tile_dirty(popper_p123_tilemap,offset); - tilemap_mark_tile_dirty(popper_p0_tilemap,offset); + popper_state *state = (popper_state *)space->machine->driver_data; + + state->attribram[offset] = data; + tilemap_mark_tile_dirty(state->p123_tilemap, offset); + tilemap_mark_tile_dirty(state->p0_tilemap, offset); } WRITE8_HANDLER( popper_flipscreen_w ) { - popper_flipscreen = data; - tilemap_set_flip_all( space->machine,popper_flipscreen?(TILEMAP_FLIPX|TILEMAP_FLIPY):0 ); + popper_state *state = (popper_state *)space->machine->driver_data; - tilemap_clip = *video_screen_get_visible_area(space->machine->primary_screen); + state->flipscreen = data; + tilemap_set_flip_all(space->machine, state->flipscreen ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0); - if (popper_flipscreen) - tilemap_clip.min_x=tilemap_clip.max_x-15; + if (state->flipscreen) + state->tilemap_clip.min_x = state->tilemap_clip.max_x - 15; else - tilemap_clip.max_x=15; + state->tilemap_clip.max_x = 15; } WRITE8_HANDLER( popper_e002_w ) { - popper_e002 = data; + popper_state *state = (popper_state *)space->machine->driver_data; + state->e002 = data; } WRITE8_HANDLER( popper_gfx_bank_w ) { - if (popper_gfx_bank != data) + popper_state *state = (popper_state *)space->machine->driver_data; + + if (state->gfx_bank != data) { - popper_gfx_bank = data; + state->gfx_bank = data; tilemap_mark_all_tiles_dirty_all(space->machine); } } static TILE_GET_INFO( get_popper_p123_tile_info ) { - UINT32 tile_number = popper_videoram[tile_index]; - UINT8 attr = popper_attribram[tile_index]; - tile_number += popper_gfx_bank << 8; + popper_state *state = (popper_state *)machine->driver_data; + UINT32 tile_number = state->videoram[tile_index]; + UINT8 attr = state->attribram[tile_index]; + tile_number += state->gfx_bank << 8; SET_TILE_INFO( 0, tile_number, - (attr&0xf), + (attr & 0xf), 0); - tileinfo->group = (attr & 0x80)>>7; + tileinfo->group = (attr & 0x80) >> 7; } static TILE_GET_INFO( get_popper_p0_tile_info ) { - UINT32 tile_number = popper_videoram[tile_index]; - UINT8 attr = popper_attribram[tile_index]; - tile_number += popper_gfx_bank << 8; + popper_state *state = (popper_state *)machine->driver_data; + UINT32 tile_number = state->videoram[tile_index]; + UINT8 attr = state->attribram[tile_index]; + tile_number += state->gfx_bank << 8; //pen 0 only in front if colour set as well - tileinfo->group = (attr&0x70) ? ((attr & 0x80)>>7) : 0; + tileinfo->group = (attr & 0x70) ? ((attr & 0x80) >> 7) : 0; SET_TILE_INFO( 0, tile_number, - ((attr&0x70)>>4)+8, + ((attr & 0x70) >> 4) + 8, 0); } static TILE_GET_INFO( get_popper_ol_p123_tile_info ) { - UINT32 tile_number = popper_ol_videoram[tile_index]; - UINT8 attr = popper_ol_attribram[tile_index]; - tile_number += popper_gfx_bank << 8; + popper_state *state = (popper_state *)machine->driver_data; + UINT32 tile_number = state->ol_videoram[tile_index]; + UINT8 attr = state->ol_attribram[tile_index]; + tile_number += state->gfx_bank << 8; SET_TILE_INFO( 0, tile_number, - (attr&0xf), + (attr & 0xf), 0); - tileinfo->group = (attr & 0x80)>>7; + tileinfo->group = (attr & 0x80) >> 7; } static TILE_GET_INFO( get_popper_ol_p0_tile_info ) { - UINT32 tile_number = popper_ol_videoram[tile_index]; - UINT8 attr = popper_ol_attribram[tile_index]; - tile_number += popper_gfx_bank << 8; + popper_state *state = (popper_state *)machine->driver_data; + UINT32 tile_number = state->ol_videoram[tile_index]; + UINT8 attr = state->ol_attribram[tile_index]; + tile_number += state->gfx_bank << 8; //pen 0 only in front if colour set as well - tileinfo->group = (attr&0x70) ? ((attr & 0x80)>>7) : 0; + tileinfo->group = (attr & 0x70) ? ((attr & 0x80) >> 7) : 0; SET_TILE_INFO( 0, tile_number, - ((attr&0x70)>>4)+8, + ((attr & 0x70) >> 4) + 8, 0); } VIDEO_START( popper ) { - popper_p123_tilemap = tilemap_create( machine, get_popper_p123_tile_info, tilemap_scan_cols,8,8,33,32 ); - popper_p0_tilemap = tilemap_create( machine, get_popper_p0_tile_info, tilemap_scan_cols,8,8,33,32 ); - popper_ol_p123_tilemap = tilemap_create( machine, get_popper_ol_p123_tile_info,tilemap_scan_cols,8,8,2 ,32 ); - popper_ol_p0_tilemap = tilemap_create( machine, get_popper_ol_p0_tile_info, tilemap_scan_cols,8,8,2 ,32 ); + popper_state *state = (popper_state *)machine->driver_data; + state->p123_tilemap = tilemap_create(machine, get_popper_p123_tile_info, tilemap_scan_cols, 8, 8, 33, 32 ); + state->p0_tilemap = tilemap_create(machine, get_popper_p0_tile_info, tilemap_scan_cols, 8, 8, 33, 32); + state->ol_p123_tilemap = tilemap_create(machine, get_popper_ol_p123_tile_info, tilemap_scan_cols, 8, 8, 2, 32); + state->ol_p0_tilemap = tilemap_create(machine, get_popper_ol_p0_tile_info, tilemap_scan_cols, 8, 8, 2, 32); - tilemap_set_transmask(popper_p123_tilemap, 0,0x0f,0x01); - tilemap_set_transmask(popper_p123_tilemap, 1,0x01,0x0f); - tilemap_set_transmask(popper_p0_tilemap, 0,0x0f,0x0e); - tilemap_set_transmask(popper_p0_tilemap, 1,0x0e,0x0f); - tilemap_set_transmask(popper_ol_p123_tilemap,0,0x0f,0x01); - tilemap_set_transmask(popper_ol_p123_tilemap,1,0x01,0x0f); - tilemap_set_transmask(popper_ol_p0_tilemap, 0,0x0f,0x0e); - tilemap_set_transmask(popper_ol_p0_tilemap, 1,0x0e,0x0f); + tilemap_set_transmask(state->p123_tilemap, 0, 0x0f, 0x01); + tilemap_set_transmask(state->p123_tilemap, 1, 0x01, 0x0f); + tilemap_set_transmask(state->p0_tilemap, 0, 0x0f, 0x0e); + tilemap_set_transmask(state->p0_tilemap, 1, 0x0e, 0x0f); + tilemap_set_transmask(state->ol_p123_tilemap, 0, 0x0f, 0x01); + tilemap_set_transmask(state->ol_p123_tilemap, 1, 0x01, 0x0f); + tilemap_set_transmask(state->ol_p0_tilemap, 0, 0x0f, 0x0e); + tilemap_set_transmask(state->ol_p0_tilemap, 1, 0x0e, 0x0f); - tilemap_clip = *video_screen_get_visible_area(machine->primary_screen); + state->tilemap_clip = *video_screen_get_visible_area(machine->primary_screen); - state_save_register_global(machine, popper_flipscreen); -// state_save_register_global(machine, popper_e002); - state_save_register_global(machine, popper_gfx_bank); + state_save_register_global(machine, state->flipscreen); + state_save_register_global(machine, state->e002); + state_save_register_global(machine, state->gfx_bank); } -static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect ) { - int offs,sx,sy,flipx,flipy; + popper_state *state = (popper_state *)machine->driver_data; + int offs, sx, sy, flipx, flipy; - for (offs = 0; offs < popper_spriteram_size-4; offs += 4) + for (offs = 0; offs < spriteram_size - 4; offs += 4) { //if y position is in the current strip - if(popper_spriteram[offs+1] && (((popper_spriteram[offs]+(popper_flipscreen?2:0))&0xf0) == (0x0f-offs/0x80)<<4)) + if (state->spriteram[offs + 1] && (((state->spriteram[offs] + (state->flipscreen ? 2 : 0)) & 0xf0) == (0x0f - offs / 0x80) << 4)) { //offs y pos //offs+1 sprite number @@ -213,12 +228,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan //----xxxx colour //offs+3 x pos - sx = popper_spriteram[offs+3]; - sy = 240-popper_spriteram[offs]; - flipx = (popper_spriteram[offs+2]&0x40)>>6; - flipy = (popper_spriteram[offs+2]&0x80)>>7; + sx = state->spriteram[offs + 3]; + sy = 240 - state->spriteram[offs]; + flipx = (state->spriteram[offs + 2] & 0x40) >> 6; + flipy = (state->spriteram[offs + 2] & 0x80) >> 7; - if (popper_flipscreen) + if (state->flipscreen) { sx = 248 - sx; sy = 242 - sy; @@ -226,9 +241,9 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan flipy = !flipy; } - drawgfx_transpen(bitmap,cliprect,machine->gfx[1], - popper_spriteram[offs+1], - (popper_spriteram[offs+2]&0x0f), + drawgfx_transpen(bitmap, cliprect, machine->gfx[1], + state->spriteram[offs + 1], + (state->spriteram[offs + 2] & 0x0f), flipx,flipy, sx,sy,0); } @@ -237,7 +252,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan VIDEO_UPDATE( popper ) { - rectangle finalclip = tilemap_clip; + popper_state *state = (popper_state *)screen->machine->driver_data; + rectangle finalclip = state->tilemap_clip; sect_rect(&finalclip, cliprect); //attribram @@ -246,16 +262,16 @@ VIDEO_UPDATE( popper ) //-xxx---- colour for pen 0 (from second prom?) //----xxxx colour for pens 1,2,3 - tilemap_draw( bitmap,cliprect,popper_p123_tilemap, TILEMAP_DRAW_LAYER1,0 ); - tilemap_draw( bitmap,cliprect,popper_p0_tilemap, TILEMAP_DRAW_LAYER1,0 ); - tilemap_draw( bitmap,&finalclip,popper_ol_p123_tilemap,TILEMAP_DRAW_LAYER1,0 ); - tilemap_draw( bitmap,&finalclip,popper_ol_p0_tilemap, TILEMAP_DRAW_LAYER1,0 ); + tilemap_draw(bitmap, cliprect, state->p123_tilemap, TILEMAP_DRAW_LAYER1, 0); + tilemap_draw(bitmap, cliprect, state->p0_tilemap, TILEMAP_DRAW_LAYER1, 0); + tilemap_draw(bitmap, &finalclip, state->ol_p123_tilemap, TILEMAP_DRAW_LAYER1, 0); + tilemap_draw(bitmap, &finalclip, state->ol_p0_tilemap, TILEMAP_DRAW_LAYER1, 0); - draw_sprites(screen->machine, bitmap,cliprect); + draw_sprites(screen->machine, bitmap, cliprect); - tilemap_draw( bitmap,cliprect,popper_p123_tilemap, TILEMAP_DRAW_LAYER0,0 ); - tilemap_draw( bitmap,cliprect,popper_p0_tilemap, TILEMAP_DRAW_LAYER0,0 ); - tilemap_draw( bitmap,&finalclip,popper_ol_p123_tilemap,TILEMAP_DRAW_LAYER0,0 ); - tilemap_draw( bitmap,&finalclip,popper_ol_p0_tilemap, TILEMAP_DRAW_LAYER0,0 ); + tilemap_draw(bitmap, cliprect, state->p123_tilemap, TILEMAP_DRAW_LAYER0, 0); + tilemap_draw(bitmap, cliprect, state->p0_tilemap, TILEMAP_DRAW_LAYER0, 0); + tilemap_draw(bitmap, &finalclip, state->ol_p123_tilemap, TILEMAP_DRAW_LAYER0, 0); + tilemap_draw(bitmap, &finalclip, state->ol_p0_tilemap, TILEMAP_DRAW_LAYER0, 0); return 0; }