summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Angelo Salese <angelosa@users.noreply.github.com>2010-03-19 18:01:59 +0000
committer Angelo Salese <angelosa@users.noreply.github.com>2010-03-19 18:01:59 +0000
commitcd5f1f4011854544fbe3dc8f7248e0a8303d7e12 (patch)
tree45cfd8d3de919cc359d1295d1556945c02bb9463
parent99c61e359250a3d7bea67c51407cd85abe3f6b99 (diff)
First step in refactoring the video system in metro.c driver [David Haywood]
-rw-r--r--src/emu/tilemap.c10
-rw-r--r--src/emu/tilemap.h3
-rw-r--r--src/mame/drivers/metro.c78
-rw-r--r--src/mame/includes/metro.h6
-rw-r--r--src/mame/mamedriv.c4
-rw-r--r--src/mame/video/metro.c337
6 files changed, 229 insertions, 209 deletions
diff --git a/src/emu/tilemap.c b/src/emu/tilemap.c
index b145596ae06..44a40867722 100644
--- a/src/emu/tilemap.c
+++ b/src/emu/tilemap.c
@@ -450,6 +450,16 @@ void tilemap_set_enable(tilemap_t *tmap, int enable)
tmap->enable = (enable != 0);
}
+/*-------------------------------------------------
+ tilemap_get_scrolldx - return the enable flag
+ for the tilemap
+-------------------------------------------------*/
+
+int tilemap_get_enable(tilemap_t *tmap)
+{
+ return tmap->enable;
+}
+
/*-------------------------------------------------
tilemap_set_flip - set a global flip for the
diff --git a/src/emu/tilemap.h b/src/emu/tilemap.h
index 740477b50ec..2fb60d3bcae 100644
--- a/src/emu/tilemap.h
+++ b/src/emu/tilemap.h
@@ -439,6 +439,9 @@ void tilemap_set_palette_offset(tilemap_t *tmap, UINT32 offset);
/* set an enable flag for the tilemap; if 0, requests to draw the tilemap are ignored */
void tilemap_set_enable(tilemap_t *tmap, int enable);
+/* return enable flag for the tilemap */
+int tilemap_get_enable(tilemap_t *tmap);
+
/* set a global flip for the tilemap */
void tilemap_set_flip(tilemap_t *tmap, UINT32 attributes);
diff --git a/src/mame/drivers/metro.c b/src/mame/drivers/metro.c
index fc1a3d42baa..5d51f82107b 100644
--- a/src/mame/drivers/metro.c
+++ b/src/mame/drivers/metro.c
@@ -54,11 +54,17 @@ Not dumped yet:
To Do:
-- 1 pixel granularity in the window's placement (8 pixels now, see daitorid and msgogo title)
- Coin lockout
- Some gfx problems in ladykill, 3kokushi, puzzli, gakusai
+ - Seems related to how we handle windows and wrapping
- Are the 16x16 tiles used by Mouja a Imagetek 14300-only feature?
-- Flip screen doesn't work correctly in Mouja due to asymmetrical visible area
+- Interrupt timing needs figuring out properly, having it incorrect
+ causes scrolling glitches in some games. Test cases Mouse Go Go
+ title screen, GunMaster title screen. Changing it can cause
+ excessive slowdown in said games however.
+- Bang Bang Ball / Bubble Buster slow to a crawl when you press a
+ button between levels, on a real PCB it speeds up instead (related
+ to above?)
Notes:
@@ -214,6 +220,24 @@ static INTERRUPT_GEN( bangball_interrupt )
update_irq_state(device->machine);
}
+static INTERRUPT_GEN( msgogo_interrupt )
+{
+ metro_state *state = (metro_state *)device->machine->driver_data;
+
+ switch (cpu_getiloops(device))
+ {
+ case 10:
+ state->requested_int[0] = 1;
+ update_irq_state(device->machine);
+ break;
+
+ case 224:
+ state->requested_int[4] = 1;
+ update_irq_state(device->machine);
+ break;
+ }
+}
+
static TIMER_CALLBACK( vblank_end_callback )
{
@@ -3637,7 +3661,7 @@ static MACHINE_DRIVER_START( msgogo )
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M68000, 16000000)
MDRV_CPU_PROGRAM_MAP(msgogo_map)
- MDRV_CPU_VBLANK_INT("screen", bangball_interrupt)
+ MDRV_CPU_VBLANK_INT_HACK(msgogo_interrupt,262) /* ? */
MDRV_MACHINE_START(metro)
MDRV_MACHINE_RESET(metro)
@@ -4280,7 +4304,8 @@ static MACHINE_DRIVER_START( pururun )
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M68000, 12000000)
MDRV_CPU_PROGRAM_MAP(pururun_map)
- MDRV_CPU_VBLANK_INT_HACK(metro_interrupt,10) /* ? */
+ //MDRV_CPU_VBLANK_INT_HACK(msgogo_interrupt,262) /* fixes the title screen scroll in GunMaster, but makes the game painfully slow */
+ MDRV_CPU_VBLANK_INT_HACK(metro_interrupt,10) /* ? */
MDRV_CPU_ADD("audiocpu", UPD7810, 12000000)
MDRV_CPU_CONFIG(metro_cpu_config)
@@ -4873,10 +4898,12 @@ Notes:
*/
+
+/* The MASK roms weren't dumped from this set, but it's safe to assume they're the same in this case */
ROM_START( gstrik2 )
ROM_REGION( 0x200000, "maincpu", 0 ) /* 68000 */
- ROM_LOAD16_BYTE( "prg0.107", 0x000000, 0x80000, CRC(e60a8c19) SHA1(19be6cfcb60ede6fd4eb2e14914b174107c4b52d) )
- ROM_LOAD16_BYTE( "prg1.108", 0x000001, 0x80000, CRC(853f6f7c) SHA1(8fb9d7cd0390f620560a1669bb13f2033eed7c81) )
+ ROM_LOAD16_BYTE( "hum_003_g2f.rom1.u107", 0x000000, 0x80000, CRC(2712d9ca) SHA1(efa967de931728534a663fa1529e92003afbb3e9) )
+ ROM_LOAD16_BYTE( "hum_003_g2f.rom2.u108", 0x000001, 0x80000, CRC(86785c64) SHA1(ef172d6e859a68eb80f7c127b61883d50eefb0fe) )
ROM_LOAD16_BYTE( "prg2.109", 0x100000, 0x80000, CRC(ead86919) SHA1(eb9b68dff4e08d90ac90043c7f3021914caa007d) )
ROM_LOAD16_BYTE( "prg3.110", 0x100001, 0x80000, CRC(e0b026e3) SHA1(05f75c0432efda3dec0372199382e310bb268fba) )
@@ -4913,25 +4940,25 @@ ROM_START( gstrik2 )
/* ROM7.27 not populated? */
ROM_END
-ROM_START( gstrik2e )
+ROM_START( gstrik2j )
ROM_REGION( 0x200000, "maincpu", 0 ) /* 68000 */
- ROM_LOAD16_BYTE( "hum_003_g2f.rom1.u107", 0x000000, 0x80000, CRC(2712d9ca) SHA1(efa967de931728534a663fa1529e92003afbb3e9) )
- ROM_LOAD16_BYTE( "hum_003_g2f.rom2.u108", 0x000001, 0x80000, CRC(86785c64) SHA1(ef172d6e859a68eb80f7c127b61883d50eefb0fe) )
- ROM_LOAD16_BYTE( "prg2.109", 0x100000, 0x80000, BAD_DUMP CRC(ead86919) SHA1(eb9b68dff4e08d90ac90043c7f3021914caa007d) )
- ROM_LOAD16_BYTE( "prg3.110", 0x100001, 0x80000, BAD_DUMP CRC(e0b026e3) SHA1(05f75c0432efda3dec0372199382e310bb268fba) )
+ ROM_LOAD16_BYTE( "prg0.107", 0x000000, 0x80000, CRC(e60a8c19) SHA1(19be6cfcb60ede6fd4eb2e14914b174107c4b52d) )
+ ROM_LOAD16_BYTE( "prg1.108", 0x000001, 0x80000, CRC(853f6f7c) SHA1(8fb9d7cd0390f620560a1669bb13f2033eed7c81) )
+ ROM_LOAD16_BYTE( "prg2.109", 0x100000, 0x80000, CRC(ead86919) SHA1(eb9b68dff4e08d90ac90043c7f3021914caa007d) )
+ ROM_LOAD16_BYTE( "prg3.110", 0x100001, 0x80000, CRC(e0b026e3) SHA1(05f75c0432efda3dec0372199382e310bb268fba) )
ROM_REGION( 0x20000, "audiocpu", 0 ) /* Z80 */
- ROM_LOAD( "sprg.30", 0x0000, 0x20000, BAD_DUMP CRC(aeef6045) SHA1(61b8c89ca495d3aac79e53413a85dd203db816f3) )
+ ROM_LOAD( "sprg.30", 0x0000, 0x20000, CRC(aeef6045) SHA1(61b8c89ca495d3aac79e53413a85dd203db816f3) )
ROM_REGION( 0x1000000, "gfx1", 0 ) /* Gfx + Data (Addressable by CPU & Blitter) */
- ROMX_LOAD( "chr0.80", 0x0000000, 0x200000, BAD_DUMP CRC(f63a52a9) SHA1(1ad52bb3a051eaffe8fb6ba49d4fc1d0b6144156) , ROM_GROUPWORD | ROM_SKIP(6))
- ROMX_LOAD( "chr1.79", 0x0000002, 0x200000, BAD_DUMP CRC(4110c184) SHA1(90ccb3d50eff7a655336cfa9c072f7213589e64c) , ROM_GROUPWORD | ROM_SKIP(6))
- ROMX_LOAD( "chr2.78", 0x0000004, 0x200000, BAD_DUMP CRC(ddb4b9ee) SHA1(0e2c151c3690b9c3d298dda8842e283660d37386) , ROM_GROUPWORD | ROM_SKIP(6))
- ROMX_LOAD( "chr3.77", 0x0000006, 0x200000, BAD_DUMP CRC(5ab367db) SHA1(adf8749451f4583f8e9e00ab61f3408d804a7265) , ROM_GROUPWORD | ROM_SKIP(6))
- ROMX_LOAD( "chr4.84", 0x0800000, 0x200000, BAD_DUMP CRC(77d7ef99) SHA1(8f5cf72f5919fe9363e7549e0bb1b3ee633cec3b) , ROM_GROUPWORD | ROM_SKIP(6))
- ROMX_LOAD( "chr5.83", 0x0800002, 0x200000, BAD_DUMP CRC(a4d49e95) SHA1(9789bacba7876100e0f0293f54c81def545ed068) , ROM_GROUPWORD | ROM_SKIP(6))
- ROMX_LOAD( "chr6.82", 0x0800004, 0x200000, BAD_DUMP CRC(32eb33b0) SHA1(2ea06484ca326b44a35ee470343147a9d91d5626) , ROM_GROUPWORD | ROM_SKIP(6))
- ROMX_LOAD( "chr7.81", 0x0800006, 0x200000, BAD_DUMP CRC(2d30a21e) SHA1(749e86b7935ef71556eaee4caf6f954634e9bcbf) , ROM_GROUPWORD | ROM_SKIP(6))
+ ROMX_LOAD( "chr0.80", 0x0000000, 0x200000, CRC(f63a52a9) SHA1(1ad52bb3a051eaffe8fb6ba49d4fc1d0b6144156) , ROM_GROUPWORD | ROM_SKIP(6))
+ ROMX_LOAD( "chr1.79", 0x0000002, 0x200000, CRC(4110c184) SHA1(90ccb3d50eff7a655336cfa9c072f7213589e64c) , ROM_GROUPWORD | ROM_SKIP(6))
+ ROMX_LOAD( "chr2.78", 0x0000004, 0x200000, CRC(ddb4b9ee) SHA1(0e2c151c3690b9c3d298dda8842e283660d37386) , ROM_GROUPWORD | ROM_SKIP(6))
+ ROMX_LOAD( "chr3.77", 0x0000006, 0x200000, CRC(5ab367db) SHA1(adf8749451f4583f8e9e00ab61f3408d804a7265) , ROM_GROUPWORD | ROM_SKIP(6))
+ ROMX_LOAD( "chr4.84", 0x0800000, 0x200000, CRC(77d7ef99) SHA1(8f5cf72f5919fe9363e7549e0bb1b3ee633cec3b) , ROM_GROUPWORD | ROM_SKIP(6))
+ ROMX_LOAD( "chr5.83", 0x0800002, 0x200000, CRC(a4d49e95) SHA1(9789bacba7876100e0f0293f54c81def545ed068) , ROM_GROUPWORD | ROM_SKIP(6))
+ ROMX_LOAD( "chr6.82", 0x0800004, 0x200000, CRC(32eb33b0) SHA1(2ea06484ca326b44a35ee470343147a9d91d5626) , ROM_GROUPWORD | ROM_SKIP(6))
+ ROMX_LOAD( "chr7.81", 0x0800006, 0x200000, CRC(2d30a21e) SHA1(749e86b7935ef71556eaee4caf6f954634e9bcbf) , ROM_GROUPWORD | ROM_SKIP(6))
/* not populated */
// ROMX_LOAD( "chr8.88", 0x1000000, 0x200000, CRC() SHA1() , ROM_GROUPWORD | ROM_SKIP(6))
// ROMX_LOAD( "chr9.87", 0x1000002, 0x200000, CRC() SHA1() , ROM_GROUPWORD | ROM_SKIP(6))
@@ -4943,16 +4970,17 @@ ROM_START( gstrik2e )
// ROMX_LOAD( "chr15.89", 0x1800006, 0x200000, CRC() SHA1() , ROM_GROUPWORD | ROM_SKIP(6))
ROM_REGION( 0x200000, "gfx3", 0 ) /* 053936 gfx data */
- ROM_LOAD( "psacrom.60", 0x000000, 0x200000, BAD_DUMP CRC(73f1f279) SHA1(1135b2b1eb4c52249bc12ee178340bbb202a94c8) )
+ ROM_LOAD( "psacrom.60", 0x000000, 0x200000, CRC(73f1f279) SHA1(1135b2b1eb4c52249bc12ee178340bbb202a94c8) )
ROM_REGION( 0x200000, "ymsnd.deltat", 0 ) /* Samples */
- ROM_LOAD( "sndpcm-b.22", 0x000000, 0x200000, BAD_DUMP CRC(a5d844d2) SHA1(18d644545f0844e66aa53775b67b0a29c7b7c31b) )
+ ROM_LOAD( "sndpcm-b.22", 0x000000, 0x200000, CRC(a5d844d2) SHA1(18d644545f0844e66aa53775b67b0a29c7b7c31b) )
ROM_REGION( 0x400000, "ymsnd", 0 ) /* ? YRW801-M ? */
- ROM_LOAD( "sndpcm-a.23", 0x000000, 0x200000, BAD_DUMP CRC(e6d32373) SHA1(8a79d4ea8b27d785fffd80e38d5ae73b7cea7304) )
+ ROM_LOAD( "sndpcm-a.23", 0x000000, 0x200000, CRC(e6d32373) SHA1(8a79d4ea8b27d785fffd80e38d5ae73b7cea7304) )
/* ROM7.27 not populated? */
ROM_END
+
/***************************************************************************
Daitoride
@@ -6202,8 +6230,8 @@ GAME( 1995, puzzli, 0, daitorid, puzzli, daitorid, ROT0, "Metro /
GAME( 1996, 3kokushi, 0, 3kokushi, 3kokushi, karatour, ROT0, "Mitchell", "Sankokushi (Japan)", GAME_IMPERFECT_GRAPHICS )
GAME( 1996, balcube, 0, balcube, balcube, balcube, ROT0, "Metro", "Bal Cube", 0 )
GAME( 1996, bangball, 0, bangball, bangball, balcube, ROT0, "Banpresto / Kunihiko Tashiro+Goodhouse", "Bang Bang Ball (v1.05)", 0 )
-GAME( 1996, gstrik2, 0, gstrik2, gstrik2, blzntrnd, ROT0, "Human Amusement", "Grand Striker 2 (Japan)", GAME_IMPERFECT_GRAPHICS ) // priority between rounds
-GAME( 1996, gstrik2e, gstrik2, gstrik2, gstrik2, blzntrnd, ROT0, "Human Amusement", "Grand Striker 2 (Europe and Oceania)", GAME_IMPERFECT_GRAPHICS )
+GAME( 1996, gstrik2, 0, gstrik2, gstrik2, blzntrnd, ROT0, "Human Amusement", "Grand Striker 2 (Europe and Oceania)", GAME_IMPERFECT_GRAPHICS )
+GAME( 1996, gstrik2j, gstrik2, gstrik2, gstrik2, blzntrnd, ROT0, "Human Amusement", "Grand Striker 2 (Japan)", GAME_IMPERFECT_GRAPHICS ) // priority between rounds
GAME( 1999, batlbubl, bangball, batlbubl, batlbubl, balcube, ROT0, "Limenko", "Battle Bubble (v2.00)", 0 )
GAME( 1996, mouja, 0, mouja, mouja, mouja, ROT0, "Etona", "Mouja (Japan)", GAME_NO_COCKTAIL )
GAME( 1997, gakusai, 0, gakusai, gakusai, gakusai, ROT0, "MakeSoft", "Mahjong Gakuensai (Japan)", GAME_IMPERFECT_GRAPHICS )
diff --git a/src/mame/includes/metro.h b/src/mame/includes/metro.h
index ac044094882..3aad966cbd2 100644
--- a/src/mame/includes/metro.h
+++ b/src/mame/includes/metro.h
@@ -35,13 +35,15 @@ public:
size_t spriteram_size;
size_t tiletable_size;
-
+ int flip_screen;
// UINT16 * paletteram; // currently this uses generic palette handling
/* video-related */
tilemap_t *k053936_tilemap;
tilemap_t *bg_tilemap[3];
- tilemap_t *tilemap_16x16[3];
+ tilemap_t *bg_tilemap_16x16[3];
+
+
int support_8bpp, support_16x16;
int has_zoom;
int sprite_xoffs, sprite_yoffs;
diff --git a/src/mame/mamedriv.c b/src/mame/mamedriv.c
index ba08548cadd..fee8a8059db 100644
--- a/src/mame/mamedriv.c
+++ b/src/mame/mamedriv.c
@@ -2411,7 +2411,7 @@ V-V TP-027
DRIVER( agalletj ) /* (c) 1996 Banpresto / Gazelle (country is in EEPROM) */
DRIVER( agalletk ) /* (c) 1996 Banpresto / Gazelle (country is in EEPROM) */
DRIVER( agallett ) /* (c) 1996 Banpresto / Gazelle (country is in EEPROM) */
- DRIVER( agalleth ) /* (c) 1996 Banpresto / Gazelle (country is in EEPROM) */
+ DRIVER( agalleth ) /* (c) 1996 Banpresto / Gazelle (country is in EEPROM) */
DRIVER( hotdogst ) /* (c) 1996 Marble */
DRIVER( ddonpach ) /* (c) 1997 Atlus/Cave */
DRIVER( ddonpachj ) /* (c) 1997 Atlus/Cave */
@@ -8030,7 +8030,7 @@ Other Sun games
DRIVER( gakusai2 ) /* (c) 1998 MakeSoft */
DRIVER( blzntrnd ) /* (c) 1994 Human Amusement */
DRIVER( gstrik2 ) /* (c) 1996 Human Amusement */
- DRIVER( gstrik2e )
+ DRIVER( gstrik2j )
DRIVER( hyprduel ) /* (c) 1993 Technosoft (World) */
DRIVER( hyprdelj ) /* (c) 1993 Technosoft (Japan) */
DRIVER( magerror ) /* (c) 1994 Technosoft (Japan) (Arcade TV Game List - P.100, Left, 13 from Bottom) */
diff --git a/src/mame/video/metro.c b/src/mame/video/metro.c
index d5e3af432bc..1293b2ddbd3 100644
--- a/src/mame/video/metro.c
+++ b/src/mame/video/metro.c
@@ -101,22 +101,6 @@ static TILEMAP_MAPPER( tilemap_scan_gstrik2 )
}
-/***************************************************************************
-
-
- Palette GGGGGRRRRRBBBBBx
-
-
-***************************************************************************/
-
-#ifdef UNUSED_FUNCTION
-WRITE16_HANDLER( metro_paletteram_w )
-{
- data = COMBINE_DATA(&space->machine->generic.paletteram.u16[offset]);
- palette_set_color_rgb(space->machine, offset, pal5bit(data >> 6), pal5bit(data >> 11), pal5bit(data >> 1));
-}
-#endif
-
/***************************************************************************
@@ -148,16 +132,13 @@ WRITE16_HANDLER( metro_paletteram_w )
***************************************************************************/
/* A 2048 x 2048 virtual tilemap */
-#define BIG_NX 0x100
-#define BIG_NY 0x100
+#define BIG_NX (0x100)
+#define BIG_NY (0x100)
/* A smaller 512 x 256 window defines the actual tilemap */
#define WIN_NX (0x40)
#define WIN_NY (0x20)
-//#define WIN_NX (0x40 + 1)
-//#define WIN_NY (0x20 + 1)
-
/* 8x8x4 tiles only */
INLINE void get_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, int layer, UINT16 *vram )
@@ -167,10 +148,6 @@ INLINE void get_tile_info( running_machine *machine, tile_data *tileinfo, int ti
int table_index;
UINT32 tile;
- /* The actual tile index depends on the window */
- tile_index = ((tile_index / WIN_NX + state->window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX +
- ((tile_index % WIN_NX + state->window[layer * 2 + 1] / 8) % BIG_NX);
-
/* Fetch the code */
code = vram[tile_index];
@@ -184,11 +161,11 @@ INLINE void get_tile_info( running_machine *machine, tile_data *tileinfo, int ti
tileinfo->pen_data = state->empty_tiles + _code * 16 * 16;
tileinfo->palette_base = ((code & 0x0ff0)) + 0x1000;
tileinfo->flags = 0;
- tileinfo->group = 0;
+ tileinfo->category = 0;
}
else
{
- tileinfo->group = 0;
+ tileinfo->category = 0;
SET_TILE_INFO(
0,
(tile & 0xfffff) + (code & 0xf),
@@ -197,7 +174,6 @@ INLINE void get_tile_info( running_machine *machine, tile_data *tileinfo, int ti
}
}
-
/* 8x8x4 or 8x8x8 tiles. It's the tile's color that decides: if its low 4
bits are high ($f,$1f,$2f etc) the tile is 8bpp, otherwise it's 4bpp */
INLINE void get_tile_info_8bit( running_machine *machine, tile_data *tileinfo, int tile_index, int layer, UINT16 *vram )
@@ -207,10 +183,6 @@ INLINE void get_tile_info_8bit( running_machine *machine, tile_data *tileinfo, i
int table_index;
UINT32 tile;
- /* The actual tile index depends on the window */
- tile_index = ((tile_index / WIN_NX + state->window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX +
- ((tile_index % WIN_NX + state->window[layer * 2 + 1] / 8) % BIG_NX);
-
/* Fetch the code */
code = vram[tile_index];
@@ -224,11 +196,11 @@ INLINE void get_tile_info_8bit( running_machine *machine, tile_data *tileinfo, i
tileinfo->pen_data = state->empty_tiles + _code * 16 * 16;
tileinfo->palette_base = ((code & 0x0ff0)) + 0x1000;
tileinfo->flags = 0;
- tileinfo->group = 0;
+ tileinfo->category = 0;
}
else if ((tile & 0x00f00000) == 0x00f00000) /* draw tile as 8bpp */
{
- tileinfo->group = 1;
+ tileinfo->category = 1;
SET_TILE_INFO(
1,
(tile & 0xfffff) + 2*(code & 0xf),
@@ -237,7 +209,7 @@ INLINE void get_tile_info_8bit( running_machine *machine, tile_data *tileinfo, i
}
else
{
- tileinfo->group = 0;
+ tileinfo->category = 0;
SET_TILE_INFO(
0,
(tile & 0xfffff) + (code & 0xf),
@@ -255,10 +227,6 @@ INLINE void get_tile_info_16x16_8bit( running_machine *machine, tile_data *tilei
int table_index;
UINT32 tile;
- /* The actual tile index depends on the window */
- tile_index = ((tile_index / WIN_NX + state->window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX +
- ((tile_index % WIN_NX + state->window[layer * 2 + 1] / 8) % BIG_NX);
-
/* Fetch the code */
code = vram[tile_index];
@@ -272,11 +240,11 @@ INLINE void get_tile_info_16x16_8bit( running_machine *machine, tile_data *tilei
tileinfo->pen_data = state->empty_tiles + _code * 16 * 16;
tileinfo->palette_base = ((code & 0x0ff0)) + 0x1000;
tileinfo->flags = 0;
- tileinfo->group = 0;
+ tileinfo->category = 0;
}
else if ((tile & 0x00f00000) == 0x00f00000) /* draw tile as 8bpp */
{
- tileinfo->group = 1;
+ tileinfo->category = 1;
SET_TILE_INFO(
3,
(tile & 0xfffff) + 8*(code & 0xf),
@@ -285,7 +253,7 @@ INLINE void get_tile_info_16x16_8bit( running_machine *machine, tile_data *tilei
}
else
{
- tileinfo->group = 0;
+ tileinfo->category = 0;
SET_TILE_INFO(
2,
(tile & 0xfffff) + 4*(code & 0xf),
@@ -295,27 +263,16 @@ INLINE void get_tile_info_16x16_8bit( running_machine *machine, tile_data *tilei
}
}
-
INLINE void metro_vram_w( running_machine *machine, offs_t offset, UINT16 data, UINT16 mem_mask, int layer, UINT16 *vram )
{
metro_state *state = (metro_state *)machine->driver_data;
COMBINE_DATA(&vram[offset]);
- {
- /* Account for the window */
- int col = (offset % BIG_NX) - ((state->window[layer * 2 + 1] / 8) % BIG_NX);
- int row = (offset / BIG_NX) - ((state->window[layer * 2 + 0] / 8) % BIG_NY);
- if (col < -(BIG_NX-WIN_NX)) col += (BIG_NX-WIN_NX) + WIN_NX;
- if (row < -(BIG_NY-WIN_NY)) row += (BIG_NY-WIN_NY) + WIN_NY;
- if ((col >= 0) && (col < WIN_NX) && (row >= 0) && (row < WIN_NY))
- {
- tilemap_mark_tile_dirty(state->bg_tilemap[layer], row * WIN_NX + col);
- if (state->tilemap_16x16[layer])
- tilemap_mark_tile_dirty(state->tilemap_16x16[layer], row * WIN_NX + col);
- }
- }
-}
+ tilemap_mark_tile_dirty(state->bg_tilemap[layer], offset);
+ if (state->bg_tilemap_16x16[layer])
+ tilemap_mark_tile_dirty(state->bg_tilemap_16x16[layer], offset);
+}
static TILE_GET_INFO( get_tile_info_0 ) { metro_state *state = (metro_state *)machine->driver_data; get_tile_info(machine, tileinfo, tile_index, 0, state->vram_0); }
@@ -330,6 +287,7 @@ static TILE_GET_INFO( get_tile_info_0_16x16_8bit ) { metro_state *state = (metro
static TILE_GET_INFO( get_tile_info_1_16x16_8bit ) { metro_state *state = (metro_state *)machine->driver_data; get_tile_info_16x16_8bit(machine, tileinfo, tile_index, 1, state->vram_1); }
static TILE_GET_INFO( get_tile_info_2_16x16_8bit ) { metro_state *state = (metro_state *)machine->driver_data; get_tile_info_16x16_8bit(machine, tileinfo, tile_index, 2, state->vram_2); }
+
WRITE16_HANDLER( metro_vram_0_w ) { metro_state *state = (metro_state *)space->machine->driver_data; metro_vram_w(space->machine, offset, data, mem_mask, 0, state->vram_0); }
WRITE16_HANDLER( metro_vram_1_w ) { metro_state *state = (metro_state *)space->machine->driver_data; metro_vram_w(space->machine, offset, data, mem_mask, 1, state->vram_1); }
WRITE16_HANDLER( metro_vram_2_w ) { metro_state *state = (metro_state *)space->machine->driver_data; metro_vram_w(space->machine, offset, data, mem_mask, 2, state->vram_2); }
@@ -340,15 +298,8 @@ WRITE16_HANDLER( metro_vram_2_w ) { metro_state *state = (metro_state *)space->m
WRITE16_HANDLER( metro_window_w )
{
metro_state *state = (metro_state *)space->machine->driver_data;
- UINT16 olddata = state->window[offset];
- UINT16 newdata = COMBINE_DATA(&state->window[offset]);
- if (newdata != olddata)
- {
- offset /= 2;
- tilemap_mark_all_tiles_dirty(state->bg_tilemap[offset]);
- if (state->tilemap_16x16[offset])
- tilemap_mark_all_tiles_dirty(state->tilemap_16x16[offset]);
- }
+ COMBINE_DATA(&state->window[offset]);
+
}
@@ -374,20 +325,21 @@ static void dirty_tiles( running_machine *machine, int layer, UINT16 *vram )
{
metro_state *state = (metro_state *)machine->driver_data;
int col, row;
+ int offset = 0;
- for (row = 0; row < WIN_NY; row++)
+ for (row = 0; row < BIG_NY; row++)
{
- for (col = 0; col < WIN_NX; col++)
+ for (col = 0; col < BIG_NX; col++)
{
- int offset = (col + state->window[layer * 2 + 1] / 8) % BIG_NX +
- ((row + state->window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX;
UINT16 code = vram[offset];
+ offset++;
+
if (!(code & 0x8000) && state->dirtyindex[(code & 0x1ff0) >> 4])
{
- tilemap_mark_tile_dirty(state->bg_tilemap[layer], row * WIN_NX + col);
- if (state->tilemap_16x16[layer])
- tilemap_mark_tile_dirty(state->tilemap_16x16[layer], row * WIN_NX + col);
+ tilemap_mark_tile_dirty(state->bg_tilemap[layer], offset);
+ if (state->bg_tilemap_16x16[layer])
+ tilemap_mark_tile_dirty(state->bg_tilemap_16x16[layer], offset);
}
}
}
@@ -431,22 +383,13 @@ VIDEO_START( metro_14100 )
state->tiletable_old = auto_alloc_array(machine, UINT16, state->tiletable_size / 2);
state->dirtyindex = auto_alloc_array(machine, UINT8, state->tiletable_size / 4);
- state->bg_tilemap[0] = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 8, 8, WIN_NX, WIN_NY);
- state->bg_tilemap[1] = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 8, 8, WIN_NX, WIN_NY);
- state->bg_tilemap[2] = tilemap_create(machine, get_tile_info_2, tilemap_scan_rows, 8, 8, WIN_NX, WIN_NY);
+ state->bg_tilemap[0] = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 8, 8, BIG_NX, BIG_NY);
+ state->bg_tilemap[1] = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 8, 8, BIG_NX, BIG_NY);
+ state->bg_tilemap[2] = tilemap_create(machine, get_tile_info_2, tilemap_scan_rows, 8, 8, BIG_NX, BIG_NY);
- state->tilemap_16x16[0] = NULL;
- state->tilemap_16x16[1] = NULL;
- state->tilemap_16x16[2] = NULL;
-
- tilemap_map_pen_to_layer(state->bg_tilemap[0], 0, 15, TILEMAP_PIXEL_TRANSPARENT);
- tilemap_map_pen_to_layer(state->bg_tilemap[0], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
-
- tilemap_map_pen_to_layer(state->bg_tilemap[1], 0, 15, TILEMAP_PIXEL_TRANSPARENT);
- tilemap_map_pen_to_layer(state->bg_tilemap[1], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
-
- tilemap_map_pen_to_layer(state->bg_tilemap[2], 0, 15, TILEMAP_PIXEL_TRANSPARENT);
- tilemap_map_pen_to_layer(state->bg_tilemap[2], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
+ state->bg_tilemap_16x16[0] = NULL;
+ state->bg_tilemap_16x16[1] = NULL;
+ state->bg_tilemap_16x16[2] = NULL;
state_save_register_global_pointer(machine, state->tiletable_old, state->tiletable_size / 2);
state_save_register_postload(machine, metro_tile_dirty_postload, NULL);
@@ -465,22 +408,13 @@ VIDEO_START( metro_14220 )
state->tiletable_old = auto_alloc_array(machine, UINT16, state->tiletable_size / 2);
state->dirtyindex = auto_alloc_array(machine, UINT8, state->tiletable_size / 4);
- state->bg_tilemap[0] = tilemap_create(machine, get_tile_info_0_8bit, tilemap_scan_rows, 8, 8, WIN_NX, WIN_NY);
- state->bg_tilemap[1] = tilemap_create(machine, get_tile_info_1_8bit, tilemap_scan_rows, 8, 8, WIN_NX, WIN_NY);
- state->bg_tilemap[2] = tilemap_create(machine, get_tile_info_2_8bit, tilemap_scan_rows, 8, 8, WIN_NX, WIN_NY);
-
- state->tilemap_16x16[0] = NULL;
- state->tilemap_16x16[1] = NULL;
- state->tilemap_16x16[2] = NULL;
+ state->bg_tilemap[0] = tilemap_create(machine, get_tile_info_0_8bit, tilemap_scan_rows, 8, 8, BIG_NX, BIG_NY);
+ state->bg_tilemap[1] = tilemap_create(machine, get_tile_info_1_8bit, tilemap_scan_rows, 8, 8, BIG_NX, BIG_NY);
+ state->bg_tilemap[2] = tilemap_create(machine, get_tile_info_2_8bit, tilemap_scan_rows, 8, 8, BIG_NX, BIG_NY);
- tilemap_map_pen_to_layer(state->bg_tilemap[0], 0, 15, TILEMAP_PIXEL_TRANSPARENT);
- tilemap_map_pen_to_layer(state->bg_tilemap[0], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
-
- tilemap_map_pen_to_layer(state->bg_tilemap[1], 0, 15, TILEMAP_PIXEL_TRANSPARENT);
- tilemap_map_pen_to_layer(state->bg_tilemap[1], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
-
- tilemap_map_pen_to_layer(state->bg_tilemap[2], 0, 15, TILEMAP_PIXEL_TRANSPARENT);
- tilemap_map_pen_to_layer(state->bg_tilemap[2], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
+ state->bg_tilemap_16x16[0] = NULL;
+ state->bg_tilemap_16x16[1] = NULL;
+ state->bg_tilemap_16x16[2] = NULL;
tilemap_set_scrolldx(state->bg_tilemap[0], -2, 2);
tilemap_set_scrolldx(state->bg_tilemap[1], -2, 2);
@@ -503,31 +437,13 @@ VIDEO_START( metro_14300 )
state->tiletable_old = auto_alloc_array(machine, UINT16, state->tiletable_size / 2);
state->dirtyindex = auto_alloc_array(machine, UINT8, state->tiletable_size / 4);
- state->bg_tilemap[0] = tilemap_create(machine, get_tile_info_0_8bit, tilemap_scan_rows, 8, 8, WIN_NX, WIN_NY);
- state->bg_tilemap[1] = tilemap_create(machine, get_tile_info_1_8bit, tilemap_scan_rows, 8, 8, WIN_NX, WIN_NY);
- state->bg_tilemap[2] = tilemap_create(machine, get_tile_info_2_8bit, tilemap_scan_rows, 8, 8, WIN_NX, WIN_NY);
-
- state->tilemap_16x16[0] = tilemap_create(machine, get_tile_info_0_16x16_8bit, tilemap_scan_rows, 16, 16, WIN_NX, WIN_NY);
- state->tilemap_16x16[1] = tilemap_create(machine, get_tile_info_1_16x16_8bit, tilemap_scan_rows, 16, 16, WIN_NX, WIN_NY);
- state->tilemap_16x16[2] = tilemap_create(machine, get_tile_info_2_16x16_8bit, tilemap_scan_rows, 16, 16, WIN_NX, WIN_NY);
-
- tilemap_map_pen_to_layer(state->bg_tilemap[0], 0, 15, TILEMAP_PIXEL_TRANSPARENT);
- tilemap_map_pen_to_layer(state->bg_tilemap[0], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
-
- tilemap_map_pen_to_layer(state->bg_tilemap[1], 0, 15, TILEMAP_PIXEL_TRANSPARENT);
- tilemap_map_pen_to_layer(state->bg_tilemap[1], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
-
- tilemap_map_pen_to_layer(state->bg_tilemap[2], 0, 15, TILEMAP_PIXEL_TRANSPARENT);
- tilemap_map_pen_to_layer(state->bg_tilemap[2], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
-
- tilemap_map_pen_to_layer(state->tilemap_16x16[0], 0, 15, TILEMAP_PIXEL_TRANSPARENT);
- tilemap_map_pen_to_layer(state->tilemap_16x16[0], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
-
- tilemap_map_pen_to_layer(state->tilemap_16x16[1], 0, 15, TILEMAP_PIXEL_TRANSPARENT);
- tilemap_map_pen_to_layer(state->tilemap_16x16[1], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
+ state->bg_tilemap[0] = tilemap_create(machine, get_tile_info_0_8bit, tilemap_scan_rows, 8, 8, BIG_NX, BIG_NY);
+ state->bg_tilemap[1] = tilemap_create(machine, get_tile_info_1_8bit, tilemap_scan_rows, 8, 8, BIG_NX, BIG_NY);
+ state->bg_tilemap[2] = tilemap_create(machine, get_tile_info_2_8bit, tilemap_scan_rows, 8, 8, BIG_NX, BIG_NY);
- tilemap_map_pen_to_layer(state->tilemap_16x16[2], 0, 15, TILEMAP_PIXEL_TRANSPARENT);
- tilemap_map_pen_to_layer(state->tilemap_16x16[2], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
+ state->bg_tilemap_16x16[0] = tilemap_create(machine, get_tile_info_0_16x16_8bit, tilemap_scan_rows, 16, 16, BIG_NX, BIG_NY);
+ state->bg_tilemap_16x16[1] = tilemap_create(machine, get_tile_info_1_16x16_8bit, tilemap_scan_rows, 16, 16, BIG_NX, BIG_NY);
+ state->bg_tilemap_16x16[2] = tilemap_create(machine, get_tile_info_2_16x16_8bit, tilemap_scan_rows, 16, 16, BIG_NX, BIG_NY);
state_save_register_global_pointer(machine, state->tiletable_old, state->tiletable_size / 2);
state_save_register_postload(machine, metro_tile_dirty_postload, NULL);
@@ -712,7 +628,7 @@ void metro_draw_sprites( running_machine *machine, bitmap_t *bitmap, const recta
gfxdata = base_gfx + (8 * 8 * 4 / 8) * (((attr & 0x000f) << 16) + code);
- if (flip_screen_get(machine))
+ if (state->flip_screen)
{
flipx = !flipx; x = max_x - x - width;
flipy = !flipy; y = max_y - y - height;
@@ -772,66 +688,127 @@ void metro_draw_sprites( running_machine *machine, bitmap_t *bitmap, const recta
***************************************************************************/
-static void draw_tilemap( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, tilemap_t *tmap, UINT32 flags, UINT32 priority,
+/* copy a 'window' from the large 2048x2048 (or 4096x4096 for 16x16 tiles) tilemap */
+
+static void draw_tilemap( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, tilemap_t *tmap, UINT32 flags, UINT32 pcode,
int sx, int sy, int wx, int wy ) // scroll & window values
{
-#if 1
- tilemap_set_scrollx(tmap, 0, sx - wx + (wx & 7));
- tilemap_set_scrolly(tmap, 0, sy - wy + (wy & 7));
- tilemap_draw(bitmap, cliprect, tmap, flags, priority);
-#else
- int x, y, i;
- const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen);
-
- /* sub tile placement */
-// sx = sx - (wx & ~7) + (wx & 7);
- sx = sx - wx;
- sx = ((sx & 0x7fff) - (sx & 0x8000)) % ((WIN_NX - 1) * 8);
-
-// sy = sy - (wy & ~7) + (wy & 7);
- sy = sy - wy;
- sy = ((sy & 0x7fff) - (sy & 0x8000)) % ((WIN_NY - 1) * 8);
-
- /* splitting point */
- x = (WIN_NX - 1) * 8 - sx;
-
- y = (WIN_NY - 1) * 8 - sy;
-
- for (i = 0; i < 4 ; i++)
- {
- rectangle clip;
+ metro_state *state = (metro_state *)machine->driver_data;
- tilemap_set_scrollx(tmap, 0, sx + ((i & 1) ? -x : 0));
- tilemap_set_scrolly(tmap, 0, sy + ((i & 2) ? -y : 0));
+ UINT16 *srcpixline;
+ UINT8 *srcflgline;
+ int y;
- clip.min_x = x - ((i & 1) ? 0 : (WIN_NX - 1) * 8);
- clip.min_y = y - ((i & 2) ? 0 : (WIN_NY - 1) * 8);
+ bitmap_t *pixdata = tilemap_get_pixmap(tmap);
+ bitmap_t *flgdata = tilemap_get_flagsmap(tmap);
+ bitmap_t *priority_bitmap = machine->priority_bitmap;
- clip.max_x = clip.min_x + (WIN_NX - 1) * 8 - 1;
- clip.max_y = clip.min_y + (WIN_NY - 1) * 8 - 1;
+ int width = pixdata->width;
+ int height = pixdata->height;
+
+ int scrwidth = bitmap->width;
+ int scrheight = bitmap->height;
- if (clip.min_x > visarea->max_x) continue;
- if (clip.min_y > visarea->max_y) continue;
+ int windowwidth = width >> 2;
+ int windowheight = height >> 3;
- if (clip.max_x < visarea->min_x) continue;
- if (clip.max_y < visarea->min_y) continue;
+ if (tilemap_get_enable(tmap)==0) return;
- if (clip.min_x < visarea->min_x) clip.min_x = visarea->min_x;
- if (clip.max_x > visarea->max_x) clip.max_x = visarea->max_x;
+ if (!state->flip_screen)
+ {
+ sx -= tilemap_get_scrolldx(tmap);
+ sy -= tilemap_get_scrolldy(tmap);
+ }
+ else
+ {
+ sx += tilemap_get_scrolldx(tmap);
+ sy += tilemap_get_scrolldy(tmap);
+ }
- if (clip.min_y < visarea->min_y) clip.min_y = visarea->min_y;
- if (clip.max_y > visarea->max_y) clip.max_y = visarea->max_y;
+ for (y=0;y<scrheight;y++)
+ {
+ int scrolly = (sy+y-wy)&(windowheight-1);
+ int x;
+ UINT16* dst;
+ UINT8 *priority_baseaddr;
+
+ srcpixline = BITMAP_ADDR16(pixdata,(wy+scrolly)&(height-1), 0);
+ srcflgline = BITMAP_ADDR8(flgdata,(wy+scrolly)&(height-1), 0);
+
+ if (!state->flip_screen)
+ {
+ dst = BITMAP_ADDR16(bitmap, y, 0);
+ priority_baseaddr = BITMAP_ADDR8(priority_bitmap, y, 0);
- /* The clip region's width must be a multiple of 8!
- This fact renderes the function useless, as far as
- we are concerned! */
- tilemap_set_clip(tmap, &clip);
- tilemap_draw(bitmap, cliprect, tmap, flags, priority);
+ for (x=0;x<scrwidth;x++)
+ {
+ int scrollx = (sx+x-wx)&(windowwidth-1);
+ UINT16 dat;
+ UINT8 flg;
+
+ dat = srcpixline[(wx+scrollx)&(width-1)];
+ flg = srcflgline[(wx+scrollx)&(width-1)];
+
+
+ if (flg&0xf) // check category bits to see if we're 4bpp/8bpp
+ {
+ // 8bpp tile data
+ if ((dat&0xff) != 0xff)
+ {
+ dst[x] = dat;
+ priority_baseaddr[x] = (priority_baseaddr[x] & (pcode >> 8)) | pcode;
+ }
+ }
+ else
+ {
+ // 4bpp tile data
+ if ((dat&0xf) != 0xf)
+ {
+ dst[x] = dat;
+ priority_baseaddr[x] = (priority_baseaddr[x] & (pcode >> 8)) | pcode;
+
+ }
+ }
+ }
+ }
+ else // flipped case
+ {
+ dst = BITMAP_ADDR16(bitmap, scrheight-y-1, 0);
+ priority_baseaddr = BITMAP_ADDR8(priority_bitmap, scrheight-y-1, 0);
+
+ for (x=0;x<scrwidth;x++)
+ {
+ int scrollx = (sx+x-wx)&(windowwidth-1);
+ UINT16 dat;
+ UINT8 flg;
+
+ dat = srcpixline[(wx+scrollx)&(width-1)];
+ flg = srcflgline[(wx+scrollx)&(width-1)];
+
+
+ if (flg&0xf) // check category bits to see if we're 4bpp/8bpp
+ {
+ // 8bpp tile data
+ if ((dat&0xff) != 0xff)
+ {
+ dst[scrwidth-x-1] = dat;
+ priority_baseaddr[scrwidth-x-1] = (priority_baseaddr[scrwidth-x-1] & (pcode >> 8)) | pcode;
+ }
+ }
+ else
+ {
+ // 4bpp tile data
+ if ((dat&0xf) != 0xf)
+ {
+ dst[scrwidth-x-1] = dat;
+ priority_baseaddr[scrwidth-x-1] = (priority_baseaddr[scrwidth-x-1] & (pcode >> 8)) | pcode;
+ }
+ }
+ }
+ }
}
-#endif
}
-
/* Draw all the layers that match the given priority */
static void draw_layers( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri, int layers_ctrl )
{
@@ -850,10 +827,9 @@ static void draw_layers( running_machine *machine, bitmap_t *bitmap, const recta
if (BIT(layers_ctrl, layer)) // for debug
{
- /* Only *one* of tilemap_16x16 & tilemap is enabled at any given time! */
draw_tilemap(machine, bitmap, cliprect, state->bg_tilemap[layer], 0, 1 << (3 - pri), sx, sy, wx, wy);
- if (state->tilemap_16x16[layer])
- draw_tilemap(machine, bitmap, cliprect, state->tilemap_16x16[layer], 0, 1 << (3 - pri), sx, sy, wx, wy);
+ if (state->bg_tilemap_16x16[layer])
+ draw_tilemap(machine, bitmap, cliprect, state->bg_tilemap_16x16[layer], 0, 1 << (3 - pri), sx, sy, wx, wy);
}
}
}
@@ -913,7 +889,8 @@ VIDEO_UPDATE( metro )
if (screenctrl & 2)
return 0;
- flip_screen_set(screen->machine, screenctrl & 1);
+ //flip_screen_set(screen->machine, screenctrl & 1);
+ state->flip_screen = screenctrl & 1;
/* If the game supports 16x16 tiles, make sure that the
16x16 and 8x8 tilemaps of a given layer are not simultaneously
@@ -927,7 +904,7 @@ VIDEO_UPDATE( metro )
int big = screenctrl & (0x0020 << layer);
tilemap_set_enable(state->bg_tilemap[layer],!big);
- tilemap_set_enable(state->tilemap_16x16[layer], big);
+ tilemap_set_enable(state->bg_tilemap_16x16[layer], big);
}
}