summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mame/drivers/1943.cpp111
-rw-r--r--src/mame/includes/1943.h52
-rw-r--r--src/mame/video/1943.cpp177
3 files changed, 192 insertions, 148 deletions
diff --git a/src/mame/drivers/1943.cpp b/src/mame/drivers/1943.cpp
index 0f68850bff5..06e45fa4abb 100644
--- a/src/mame/drivers/1943.cpp
+++ b/src/mame/drivers/1943.cpp
@@ -38,18 +38,17 @@
#include "machine/gen_latch.h"
#include "machine/watchdog.h"
#include "sound/2203intf.h"
-#include "screen.h"
#include "speaker.h"
/* Protection Handlers */
-WRITE8_MEMBER(_1943_state::c1943_protection_w)
+void _1943_state::protection_w(u8 data)
{
m_prot_value = data;
}
-READ8_MEMBER(_1943_state::c1943_protection_r)
+u8 _1943_state::protection_r()
{
// The game crashes (through a jump to 0x8000) if the return value is not what it expects..
@@ -94,7 +93,7 @@ READ8_MEMBER(_1943_state::c1943_protection_r)
}
// The bootleg expects 0x00 to be returned from the protection reads because the protection has been patched out.
-READ8_MEMBER(_1943_state::_1943b_c007_r)
+u8 _1943_state::_1943b_c007_r()
{
return 0;
}
@@ -105,23 +104,23 @@ READ8_MEMBER(_1943_state::_1943b_c007_r)
void _1943_state::c1943_map(address_map &map)
{
map(0x0000, 0x7fff).rom();
- map(0x8000, 0xbfff).bankr("bank1");
+ map(0x8000, 0xbfff).bankr("mainbank");
map(0xc000, 0xc000).portr("SYSTEM");
map(0xc001, 0xc001).portr("P1");
map(0xc002, 0xc002).portr("P2");
map(0xc003, 0xc003).portr("DSWA");
map(0xc004, 0xc004).portr("DSWB");
- map(0xc007, 0xc007).r(FUNC(_1943_state::c1943_protection_r));
+ map(0xc007, 0xc007).r(FUNC(_1943_state::protection_r));
map(0xc800, 0xc800).w("soundlatch", FUNC(generic_latch_8_device::write));
- map(0xc804, 0xc804).w(FUNC(_1943_state::c1943_c804_w)); // ROM bank switch, screen flip
+ map(0xc804, 0xc804).w(FUNC(_1943_state::c804_w)); // ROM bank switch, screen flip
map(0xc806, 0xc806).w("watchdog", FUNC(watchdog_timer_device::reset_w));
- map(0xc807, 0xc807).w(FUNC(_1943_state::c1943_protection_w));
- map(0xd000, 0xd3ff).ram().w(FUNC(_1943_state::c1943_videoram_w)).share("videoram");
- map(0xd400, 0xd7ff).ram().w(FUNC(_1943_state::c1943_colorram_w)).share("colorram");
+ map(0xc807, 0xc807).w(FUNC(_1943_state::protection_w));
+ map(0xd000, 0xd3ff).ram().w(FUNC(_1943_state::videoram_w)).share("videoram");
+ map(0xd400, 0xd7ff).ram().w(FUNC(_1943_state::colorram_w)).share("colorram");
map(0xd800, 0xd801).ram().share("scrollx");
map(0xd802, 0xd802).ram().share("scrolly");
map(0xd803, 0xd804).ram().share("bgscrollx");
- map(0xd806, 0xd806).w(FUNC(_1943_state::c1943_d806_w)); // sprites, bg1, bg2 enable
+ map(0xd806, 0xd806).w(FUNC(_1943_state::d806_w)); // sprites, bg1, bg2 enable
map(0xd808, 0xd808).nopw(); // ???
map(0xd868, 0xd868).nopw(); // ???
map(0xd888, 0xd888).nopw(); // ???
@@ -230,58 +229,34 @@ INPUT_PORTS_END
static const gfx_layout charlayout =
{
8,8, /* 8*8 characters */
- 2048, /* 2048 characters */
+ RGN_FRAC(1,1), /* 2048 characters */
2, /* 2 bits per pixel */
{ 4, 0 },
- { 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3 },
- { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
+ { STEP4(0,1), STEP4(4*2,1) },
+ { STEP8(0,4*2*2) },
16*8 /* every char takes 16 consecutive bytes */
};
static const gfx_layout tilelayout =
{
32,32, /* 32*32 tiles */
- 512, /* 512 tiles */
+ RGN_FRAC(1,2),
4, /* 4 bits per pixel */
- { 512*256*8+4, 512*256*8+0, 4, 0 },
- { 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3,
- 64*8+0, 64*8+1, 64*8+2, 64*8+3, 65*8+0, 65*8+1, 65*8+2, 65*8+3,
- 128*8+0, 128*8+1, 128*8+2, 128*8+3, 129*8+0, 129*8+1, 129*8+2, 129*8+3,
- 192*8+0, 192*8+1, 192*8+2, 192*8+3, 193*8+0, 193*8+1, 193*8+2, 193*8+3 },
- { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
- 8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16,
- 16*16, 17*16, 18*16, 19*16, 20*16, 21*16, 22*16, 23*16,
- 24*16, 25*16, 26*16, 27*16, 28*16, 29*16, 30*16, 31*16 },
- 256*8 /* every tile takes 256 consecutive bytes */
-};
-
-static const gfx_layout bgtilelayout =
-{
- 32,32, /* 32*32 tiles */
- 128, /* 128 tiles */
- 4, /* 4 bits per pixel */
- { 128*256*8+4, 128*256*8+0, 4, 0 },
- { 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3,
- 64*8+0, 64*8+1, 64*8+2, 64*8+3, 65*8+0, 65*8+1, 65*8+2, 65*8+3,
- 128*8+0, 128*8+1, 128*8+2, 128*8+3, 129*8+0, 129*8+1, 129*8+2, 129*8+3,
- 192*8+0, 192*8+1, 192*8+2, 192*8+3, 193*8+0, 193*8+1, 193*8+2, 193*8+3 },
- { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
- 8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16,
- 16*16, 17*16, 18*16, 19*16, 20*16, 21*16, 22*16, 23*16,
- 24*16, 25*16, 26*16, 27*16, 28*16, 29*16, 30*16, 31*16 },
+ { RGN_FRAC(1,2)+4, RGN_FRAC(1,2)+0, 4, 0 },
+ { STEP4(0,1), STEP4(4*2,1), STEP4(4*2*2*32,1), STEP4(4*2*2*32+4*2,1),
+ STEP4(4*2*2*64,1), STEP4(4*2*2*64+4*2,1), STEP4(4*2*2*96,1), STEP4(4*2*2*96+4*2,1) },
+ { STEP32(0,4*2*2) },
256*8 /* every tile takes 256 consecutive bytes */
};
static const gfx_layout spritelayout =
{
16,16, /* 16*16 sprites */
- 2048, /* 2048 sprites */
+ RGN_FRAC(1,2), /* 2048 sprites */
4, /* 4 bits per pixel */
- { 2048*64*8+4, 2048*64*8+0, 4, 0 },
- { 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3,
- 32*8+0, 32*8+1, 32*8+2, 32*8+3, 33*8+0, 33*8+1, 33*8+2, 33*8+3 },
- { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
- 8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
+ { RGN_FRAC(1,2)+4, RGN_FRAC(1,2)+0, 4, 0 },
+ { STEP4(0,1), STEP4(4*2,1), STEP4(4*2*2*16,1), STEP4(4*2*2*16+4*2,1) },
+ { STEP16(0,4*2*2) },
64*8 /* every sprite takes 64 consecutive bytes */
};
@@ -290,7 +265,7 @@ static const gfx_layout spritelayout =
static GFXDECODE_START( gfx_1943 )
GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 32 )
GFXDECODE_ENTRY( "gfx2", 0, tilelayout, 32*4, 16 )
- GFXDECODE_ENTRY( "gfx3", 0, bgtilelayout, 32*4+16*16, 16 )
+ GFXDECODE_ENTRY( "gfx3", 0, tilelayout, 32*4+16*16, 16 )
GFXDECODE_ENTRY( "gfx4", 0, spritelayout, 32*4+16*16+16*16, 16 )
GFXDECODE_END
@@ -325,13 +300,13 @@ void _1943_state::_1943(machine_config &config)
WATCHDOG_TIMER(config, "watchdog");
// video hardware
- screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
- screen.set_refresh_hz(60);
- screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
- screen.set_size(32*8, 32*8);
- screen.set_visarea(0*8, 32*8-1, 2*8, 30*8-1);
- screen.set_screen_update(FUNC(_1943_state::screen_update_1943));
- screen.set_palette(m_palette);
+ SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
+ m_screen->set_refresh_hz(60);
+ m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0));
+ m_screen->set_size(32*8, 32*8);
+ m_screen->set_visarea(0*8, 32*8-1, 2*8, 30*8-1);
+ m_screen->set_screen_update(FUNC(_1943_state::screen_update));
+ m_screen->set_palette(m_palette);
GFXDECODE(config, m_gfxdecode, m_palette, gfx_1943);
PALETTE(config, m_palette, FUNC(_1943_state::_1943_palette), 32*4+16*16+16*16+16*16, 256);
@@ -395,7 +370,7 @@ ROM_START( 1943 )
ROM_LOAD( "bm12.12c", 0x30000, 0x8000, CRC(5e7efdb7) SHA1(fef271a38dc1a9e45a0c6e27e28e713c77c8f8c9) )
ROM_LOAD( "bm13.14c", 0x38000, 0x8000, CRC(1143829a) SHA1(2b3a65e354a205c05a87f783e9938b64bc62396f) )
- ROM_REGION( 0x10000, "gfx5", 0 ) /* tilemaps */
+ ROM_REGION( 0x10000, "tilerom", 0 ) /* tilemaps */
ROM_LOAD( "bm14.5f", 0x0000, 0x8000, CRC(4d3c6401) SHA1(ce4f6dbf8fa030ad45cbb5afd58df27fed2d4618) ) /* front background */
ROM_LOAD( "bm23.8k", 0x8000, 0x8000, CRC(a52aecbd) SHA1(45b0283d84d394c16c35802463ca95d70d1062d4) ) /* back background */
@@ -453,7 +428,7 @@ ROM_START( 1943u )
ROM_LOAD( "bm12.12c", 0x30000, 0x8000, CRC(5e7efdb7) SHA1(fef271a38dc1a9e45a0c6e27e28e713c77c8f8c9) )
ROM_LOAD( "bm13.14c", 0x38000, 0x8000, CRC(1143829a) SHA1(2b3a65e354a205c05a87f783e9938b64bc62396f) )
- ROM_REGION( 0x10000, "gfx5", 0 ) /* tilemaps */
+ ROM_REGION( 0x10000, "tilerom", 0 ) /* tilemaps */
ROM_LOAD( "bm14.5f", 0x0000, 0x8000, CRC(4d3c6401) SHA1(ce4f6dbf8fa030ad45cbb5afd58df27fed2d4618) ) /* front background */
ROM_LOAD( "bm23.8k", 0x8000, 0x8000, CRC(a52aecbd) SHA1(45b0283d84d394c16c35802463ca95d70d1062d4) ) /* back background */
@@ -511,7 +486,7 @@ ROM_START( 1943ua )
ROM_LOAD( "bm12.12c", 0x30000, 0x8000, CRC(5e7efdb7) SHA1(fef271a38dc1a9e45a0c6e27e28e713c77c8f8c9) )
ROM_LOAD( "bm13.14c", 0x38000, 0x8000, CRC(1143829a) SHA1(2b3a65e354a205c05a87f783e9938b64bc62396f) )
- ROM_REGION( 0x10000, "gfx5", 0 ) /* tilemaps */
+ ROM_REGION( 0x10000, "tilerom", 0 ) /* tilemaps */
ROM_LOAD( "bm14.5f", 0x0000, 0x8000, CRC(4d3c6401) SHA1(ce4f6dbf8fa030ad45cbb5afd58df27fed2d4618) ) /* front background */
ROM_LOAD( "bm23.8k", 0x8000, 0x8000, CRC(a52aecbd) SHA1(45b0283d84d394c16c35802463ca95d70d1062d4) ) /* back background */
@@ -569,7 +544,7 @@ ROM_START( 1943j )
ROM_LOAD( "bm12.12c", 0x30000, 0x8000, CRC(5e7efdb7) SHA1(fef271a38dc1a9e45a0c6e27e28e713c77c8f8c9) )
ROM_LOAD( "bm13.14c", 0x38000, 0x8000, CRC(1143829a) SHA1(2b3a65e354a205c05a87f783e9938b64bc62396f) )
- ROM_REGION( 0x10000, "gfx5", 0 ) /* tilemaps */
+ ROM_REGION( 0x10000, "tilerom", 0 ) /* tilemaps */
ROM_LOAD( "bm14.5f", 0x0000, 0x8000, CRC(4d3c6401) SHA1(ce4f6dbf8fa030ad45cbb5afd58df27fed2d4618) ) /* front background */
ROM_LOAD( "bm23.8k", 0x8000, 0x8000, CRC(a52aecbd) SHA1(45b0283d84d394c16c35802463ca95d70d1062d4) ) /* back background */
@@ -627,7 +602,7 @@ ROM_START( 1943ja )
ROM_LOAD( "bm12.12c", 0x30000, 0x8000, CRC(5e7efdb7) SHA1(fef271a38dc1a9e45a0c6e27e28e713c77c8f8c9) )
ROM_LOAD( "bm13.14c", 0x38000, 0x8000, CRC(1143829a) SHA1(2b3a65e354a205c05a87f783e9938b64bc62396f) )
- ROM_REGION( 0x10000, "gfx5", 0 ) /* tilemaps */
+ ROM_REGION( 0x10000, "tilerom", 0 ) /* tilemaps */
ROM_LOAD( "bm14.5f", 0x0000, 0x8000, CRC(4d3c6401) SHA1(ce4f6dbf8fa030ad45cbb5afd58df27fed2d4618) ) /* front background */
ROM_LOAD( "bm23.8k", 0x8000, 0x8000, CRC(a52aecbd) SHA1(45b0283d84d394c16c35802463ca95d70d1062d4) ) /* back background */
@@ -685,7 +660,7 @@ ROM_START( 1943jah )
ROM_LOAD( "bm12.12c", 0x30000, 0x8000, CRC(5e7efdb7) SHA1(fef271a38dc1a9e45a0c6e27e28e713c77c8f8c9) )
ROM_LOAD( "bm13.14c", 0x38000, 0x8000, CRC(1143829a) SHA1(2b3a65e354a205c05a87f783e9938b64bc62396f) )
- ROM_REGION( 0x10000, "gfx5", 0 ) /* tilemaps */
+ ROM_REGION( 0x10000, "tilerom", 0 ) /* tilemaps */
ROM_LOAD( "bm14.5f", 0x0000, 0x8000, CRC(4d3c6401) SHA1(ce4f6dbf8fa030ad45cbb5afd58df27fed2d4618) ) /* front background */
ROM_LOAD( "bm23.8k", 0x8000, 0x8000, CRC(a52aecbd) SHA1(45b0283d84d394c16c35802463ca95d70d1062d4) ) /* back background */
@@ -743,7 +718,7 @@ ROM_START( 1943kai )
ROM_LOAD( "bmk12.12c", 0x30000, 0x8000, CRC(0f50c001) SHA1(0e6367d3f0ba39a00ee0fa6e42ae9d43d12da23d) )
ROM_LOAD( "bmk13.14c", 0x38000, 0x8000, CRC(fd1acf8e) SHA1(88477ff1e5fbbca251d8cd4f241b42618ba64a80) )
- ROM_REGION( 0x10000, "gfx5", 0 ) /* tilemaps */
+ ROM_REGION( 0x10000, "tilerom", 0 ) /* tilemaps */
ROM_LOAD( "bmk14.5f", 0x0000, 0x8000, CRC(cf0f5a53) SHA1(dc50f3f937f52910dbd0cedbc232acfed0aa6a42) ) /* front background */
ROM_LOAD( "bmk23.8k", 0x8000, 0x8000, CRC(17f77ef9) SHA1(8ebb4b440042436ec2db52bad808cced832db77c) ) /* back background */
@@ -801,7 +776,7 @@ ROM_START( 1943mii ) /* Prototype, location test or limited release? - PCB had g
ROM_LOAD( "12.12c", 0x30000, 0x8000, CRC(0f50c001) SHA1(0e6367d3f0ba39a00ee0fa6e42ae9d43d12da23d) )
ROM_LOAD( "13.14c", 0x38000, 0x8000, CRC(f065f619) SHA1(d45b3a7ce306b3dc7b2ccea2484c13c1ff08a0f7) )
- ROM_REGION( 0x10000, "gfx5", 0 ) /* tilemaps */
+ ROM_REGION( 0x10000, "tilerom", 0 ) /* tilemaps */
ROM_LOAD( "14.5f", 0x0000, 0x8000, CRC(02a899f1) SHA1(0f094d925a6e38e922eb487af80da9c9ee7613aa) ) /* front background */
ROM_LOAD( "23.8k", 0x8000, 0x8000, CRC(b6dfdf85) SHA1(c223ae136f67e5f9910cbfa49b9827e5122e018e) ) /* back background */
@@ -855,7 +830,7 @@ ROM_START( 1943b )
ROM_LOAD( "bm12.12c", 0x30000, 0x8000, CRC(5e7efdb7) SHA1(fef271a38dc1a9e45a0c6e27e28e713c77c8f8c9) )
ROM_LOAD( "bm13.14c", 0x38000, 0x8000, CRC(1143829a) SHA1(2b3a65e354a205c05a87f783e9938b64bc62396f) )
- ROM_REGION( 0x10000, "gfx5", 0 ) /* tilemaps */
+ ROM_REGION( 0x10000, "tilerom", 0 ) /* tilemaps */
ROM_LOAD( "bm14.5f", 0x0000, 0x8000, CRC(4d3c6401) SHA1(ce4f6dbf8fa030ad45cbb5afd58df27fed2d4618) ) /* front background */
ROM_LOAD( "bm23.8k", 0x8000, 0x8000, CRC(a52aecbd) SHA1(45b0283d84d394c16c35802463ca95d70d1062d4) ) /* back background */
@@ -911,7 +886,7 @@ ROM_START( 1943bj )
ROM_LOAD( "bm12.12c", 0x30000, 0x8000, CRC(5e7efdb7) SHA1(fef271a38dc1a9e45a0c6e27e28e713c77c8f8c9) )
ROM_LOAD( "bm13.14c", 0x38000, 0x8000, CRC(1143829a) SHA1(2b3a65e354a205c05a87f783e9938b64bc62396f) )
- ROM_REGION( 0x10000, "gfx5", 0 ) /* tilemaps */
+ ROM_REGION( 0x10000, "tilerom", 0 ) /* tilemaps */
/* front background */
ROM_LOAD( "bm14.5f", 0x0000, 0x8000, CRC(4d3c6401) SHA1(ce4f6dbf8fa030ad45cbb5afd58df27fed2d4618) )
/* back background probably same gfx different layout */
@@ -935,15 +910,15 @@ ROM_END
void _1943_state::init_1943()
{
- uint8_t *ROM = memregion("maincpu")->base();
- membank("bank1")->configure_entries(0, 8, &ROM[0x10000], 0x4000);
+ u8 *ROM = memregion("maincpu")->base();
+ m_mainbank->configure_entries(0, 8, &ROM[0x10000], 0x4000);
}
void _1943_state::init_1943b()
{
init_1943();
- m_maincpu->space(AS_PROGRAM).install_read_handler(0xc007, 0xc007, read8_delegate(FUNC(_1943_state::_1943b_c007_r),this));
+ m_maincpu->space(AS_PROGRAM).install_read_handler(0xc007, 0xc007, read8smo_delegate(FUNC(_1943_state::_1943b_c007_r),this));
}
/* Game Drivers */
diff --git a/src/mame/includes/1943.h b/src/mame/includes/1943.h
index d543513fe5c..9ab1d6715fc 100644
--- a/src/mame/includes/1943.h
+++ b/src/mame/includes/1943.h
@@ -11,6 +11,7 @@
#pragma once
#include "emupal.h"
+#include "screen.h"
class _1943_state : public driver_device
{
@@ -25,7 +26,11 @@ public:
m_bgscrollx(*this, "bgscrollx"),
m_spriteram(*this, "spriteram"),
m_gfxdecode(*this, "gfxdecode"),
- m_palette(*this, "palette")
+ m_palette(*this, "palette"),
+ m_screen(*this, "screen"),
+ m_tilerom(*this, "tilerom"),
+ m_proms(*this, "proms"),
+ m_mainbank(*this, "mainbank")
{ }
void _1943(machine_config &config);
@@ -36,14 +41,18 @@ public:
private:
/* devices / memory pointers */
required_device<cpu_device> m_maincpu;
- required_shared_ptr<uint8_t> m_videoram;
- required_shared_ptr<uint8_t> m_colorram;
- required_shared_ptr<uint8_t> m_scrollx;
- required_shared_ptr<uint8_t> m_scrolly;
- required_shared_ptr<uint8_t> m_bgscrollx;
- required_shared_ptr<uint8_t> m_spriteram;
+ required_shared_ptr<u8> m_videoram;
+ required_shared_ptr<u8> m_colorram;
+ required_shared_ptr<u8> m_scrollx;
+ required_shared_ptr<u8> m_scrolly;
+ required_shared_ptr<u8> m_bgscrollx;
+ required_shared_ptr<u8> m_spriteram;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
+ required_device<screen_device> m_screen;
+ required_region_ptr<u8> m_tilerom;
+ required_region_ptr<u8> m_proms;
+ required_memory_bank m_mainbank;
/* video-related */
tilemap_t *m_fg_tilemap;
@@ -55,25 +64,28 @@ private:
int m_bg2_on;
/* protection */
- uint8_t m_prot_value;
- DECLARE_WRITE8_MEMBER(c1943_protection_w);
- DECLARE_READ8_MEMBER(c1943_protection_r);
- DECLARE_READ8_MEMBER(_1943b_c007_r);
+ u8 m_prot_value;
+ void protection_w(u8 data);
+ u8 protection_r();
+ u8 _1943b_c007_r();
- DECLARE_WRITE8_MEMBER(c1943_videoram_w);
- DECLARE_WRITE8_MEMBER(c1943_colorram_w);
- DECLARE_WRITE8_MEMBER(c1943_c804_w);
- DECLARE_WRITE8_MEMBER(c1943_d806_w);
+ void videoram_w(offs_t offset, u8 data);
+ void colorram_w(offs_t offset, u8 data);
+ void c804_w(u8 data);
+ void d806_w(u8 data);
- TILE_GET_INFO_MEMBER(c1943_get_bg2_tile_info);
- TILE_GET_INFO_MEMBER(c1943_get_bg_tile_info);
- TILE_GET_INFO_MEMBER(c1943_get_fg_tile_info);
+ TILE_GET_INFO_MEMBER(get_bg2_tile_info);
+ TILE_GET_INFO_MEMBER(get_bg_tile_info);
+ TILE_GET_INFO_MEMBER(get_fg_tile_info);
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
void _1943_palette(palette_device &palette) const;
- uint32_t screen_update_1943(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
- void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority);
+ u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
+ void _1943_drawgfx(bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,
+ u32 code,u32 color,bool flipx,bool flipy,int offsx,int offsy,
+ u8 transparent_color);
+ void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
void c1943_map(address_map &map);
void sound_map(address_map &map);
diff --git a/src/mame/video/1943.cpp b/src/mame/video/1943.cpp
index 16cc09cf95f..d7262dec3a8 100644
--- a/src/mame/video/1943.cpp
+++ b/src/mame/video/1943.cpp
@@ -49,7 +49,7 @@ other 2 bits (output & 0x0c) unknown
void _1943_state::_1943_palette(palette_device &palette) const
{
- const uint8_t *color_prom = memregion("proms")->base();
+ const u8 *color_prom = m_proms;
for (int i = 0; i < 0x100; i++)
{
int bit0, bit1, bit2, bit3;
@@ -59,21 +59,21 @@ void _1943_state::_1943_palette(palette_device &palette) const
bit1 = (color_prom[i + 0x000] >> 1) & 0x01;
bit2 = (color_prom[i + 0x000] >> 2) & 0x01;
bit3 = (color_prom[i + 0x000] >> 3) & 0x01;
- int const r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
+ const int r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
// green component
bit0 = (color_prom[i + 0x100] >> 0) & 0x01;
bit1 = (color_prom[i + 0x100] >> 1) & 0x01;
bit2 = (color_prom[i + 0x100] >> 2) & 0x01;
bit3 = (color_prom[i + 0x100] >> 3) & 0x01;
- int const g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
+ const int g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
// blue component
bit0 = (color_prom[i + 0x200] >> 0) & 0x01;
bit1 = (color_prom[i + 0x200] >> 1) & 0x01;
bit2 = (color_prom[i + 0x200] >> 2) & 0x01;
bit3 = (color_prom[i + 0x200] >> 3) & 0x01;
- int const b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
+ const int b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
palette.set_indirect_color(i, rgb_t(r, g, b));
}
@@ -84,14 +84,14 @@ void _1943_state::_1943_palette(palette_device &palette) const
// characters use colors 0x40-0x4f
for (int i = 0x00; i < 0x80; i++)
{
- uint8_t const ctabentry = (color_prom[i] & 0x0f) | 0x40;
+ const u8 ctabentry = (color_prom[i] & 0x0f) | 0x40;
palette.set_pen_indirect(i, ctabentry);
}
// foreground tiles use colors 0x00-0x3f
for (int i = 0x80; i < 0x180; i++)
{
- uint8_t const ctabentry =
+ const u8 ctabentry =
((color_prom[0x200 + (i - 0x080)] & 0x03) << 4) |
((color_prom[0x100 + (i - 0x080)] & 0x0f) << 0);
palette.set_pen_indirect(i, ctabentry);
@@ -100,7 +100,7 @@ void _1943_state::_1943_palette(palette_device &palette) const
// background tiles also use colors 0x00-0x3f
for (int i = 0x180; i < 0x280; i++)
{
- uint8_t const ctabentry =
+ const u8 ctabentry =
((color_prom[0x400 + (i - 0x180)] & 0x03) << 4) |
((color_prom[0x300 + (i - 0x180)] & 0x0f) << 0);
palette.set_pen_indirect(i, ctabentry);
@@ -111,7 +111,7 @@ void _1943_state::_1943_palette(palette_device &palette) const
but we handle it differently for speed reasons */
for (int i = 0x280; i < 0x380; i++)
{
- uint8_t const ctabentry =
+ const u8 ctabentry =
((color_prom[0x600 + (i - 0x280)] & 0x07) << 4) |
((color_prom[0x500 + (i - 0x280)] & 0x0f) << 0) |
0x80;
@@ -119,26 +119,26 @@ void _1943_state::_1943_palette(palette_device &palette) const
}
}
-WRITE8_MEMBER(_1943_state::c1943_videoram_w)
+void _1943_state::videoram_w(offs_t offset, u8 data)
{
m_videoram[offset] = data;
m_fg_tilemap->mark_tile_dirty(offset);
}
-WRITE8_MEMBER(_1943_state::c1943_colorram_w)
+void _1943_state::colorram_w(offs_t offset, u8 data)
{
m_colorram[offset] = data;
m_fg_tilemap->mark_tile_dirty(offset);
}
-WRITE8_MEMBER(_1943_state::c1943_c804_w)
+void _1943_state::c804_w(u8 data)
{
/* bits 0 and 1 are coin counters */
machine().bookkeeping().coin_counter_w(0, data & 0x01);
machine().bookkeeping().coin_counter_w(1, data & 0x02);
/* bits 2, 3 and 4 select the ROM bank */
- membank("bank1")->set_entry((data & 0x1c) >> 2);
+ m_mainbank->set_entry((data & 0x1c) >> 2);
/* bit 5 resets the sound CPU - we ignore it */
@@ -149,7 +149,7 @@ WRITE8_MEMBER(_1943_state::c1943_c804_w)
m_char_on = data & 0x80;
}
-WRITE8_MEMBER(_1943_state::c1943_d806_w)
+void _1943_state::d806_w(u8 data)
{
/* bit 4 enables bg 1 */
m_bg1_on = data & 0x10;
@@ -161,47 +161,43 @@ WRITE8_MEMBER(_1943_state::c1943_d806_w)
m_obj_on = data & 0x40;
}
-TILE_GET_INFO_MEMBER(_1943_state::c1943_get_bg2_tile_info)
+TILE_GET_INFO_MEMBER(_1943_state::get_bg2_tile_info)
{
- uint8_t *tilerom = memregion("gfx5")->base() + 0x8000;
-
- int offs = tile_index * 2;
- int attr = tilerom[offs + 1];
- int code = tilerom[offs];
- int color = (attr & 0x3c) >> 2;
- int flags = TILE_FLIPYX((attr & 0xc0) >> 6);
+ const int offs = 0x8000 + (tile_index * 2);
+ const u8 attr = m_tilerom[offs + 1];
+ const u32 code = m_tilerom[offs];
+ const u32 color = (attr & 0x3c) >> 2;
+ const int flags = TILE_FLIPYX((attr & 0xc0) >> 6);
SET_TILE_INFO_MEMBER(2, code, color, flags);
}
-TILE_GET_INFO_MEMBER(_1943_state::c1943_get_bg_tile_info)
+TILE_GET_INFO_MEMBER(_1943_state::get_bg_tile_info)
{
- uint8_t *tilerom = memregion("gfx5")->base();
-
- int offs = tile_index * 2;
- int attr = tilerom[offs + 1];
- int code = tilerom[offs] + ((attr & 0x01) << 8);
- int color = (attr & 0x3c) >> 2;
- int flags = TILE_FLIPYX((attr & 0xc0) >> 6);
+ const int offs = tile_index * 2;
+ const u8 attr = m_tilerom[offs + 1];
+ const u32 code = m_tilerom[offs] + ((attr & 0x01) << 8);
+ const u32 color = (attr & 0x3c) >> 2;
+ const int flags = TILE_FLIPYX((attr & 0xc0) >> 6);
tileinfo.group = color;
SET_TILE_INFO_MEMBER(1, code, color, flags);
}
-TILE_GET_INFO_MEMBER(_1943_state::c1943_get_fg_tile_info)
+TILE_GET_INFO_MEMBER(_1943_state::get_fg_tile_info)
{
- int attr = m_colorram[tile_index];
- int code = m_videoram[tile_index] + ((attr & 0xe0) << 3);
- int color = attr & 0x1f;
+ const u8 attr = m_colorram[tile_index];
+ const u32 code = m_videoram[tile_index] + ((attr & 0xe0) << 3);
+ const u32 color = attr & 0x1f;
SET_TILE_INFO_MEMBER(0, code, color, 0);
}
void _1943_state::video_start()
{
- m_bg2_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(_1943_state::c1943_get_bg2_tile_info),this), TILEMAP_SCAN_COLS, 32, 32, 2048, 8);
- m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(_1943_state::c1943_get_bg_tile_info),this), TILEMAP_SCAN_COLS, 32, 32, 2048, 8);
- m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(_1943_state::c1943_get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
+ m_bg2_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(_1943_state::get_bg2_tile_info),this), TILEMAP_SCAN_COLS, 32, 32, 2048, 8);
+ m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(_1943_state::get_bg_tile_info),this), TILEMAP_SCAN_COLS, 32, 32, 2048, 8);
+ m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(_1943_state::get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
m_bg_tilemap->configure_groups(*m_gfxdecode->gfx(1), 0x0f);
m_fg_tilemap->set_transparent_pen(0);
@@ -212,15 +208,87 @@ void _1943_state::video_start()
save_item(NAME(m_bg2_on));
}
-void _1943_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
+void _1943_state::_1943_drawgfx(bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,
+ u32 code,u32 color,bool flipx,bool flipy,int offsx,int offsy,
+ u8 transparent_color)
{
- int offs;
+ bitmap_ind8 &priority_bitmap = m_screen->priority();
+ /* Start drawing */
+ const u16 pal = gfx->colorbase() + gfx->granularity() * (color % gfx->colors());
+ const u8 *source_base = gfx->get_data(code % gfx->elements());
+
+ const int xinc = flipx ? -1 : 1;
+ const int yinc = flipy ? -1 : 1;
+
+ int x_index_base = flipx ? gfx->width() - 1 : 0;
+ int y_index = flipy ? gfx->height() - 1 : 0;
+
+ // start coordinates
+ int sx = offsx;
+ int sy = offsy;
+
+ // end coordinates
+ int ex = sx + gfx->width();
+ int ey = sy + gfx->height();
+
+ if (sx < clip.min_x)
+ { // clip left
+ const int pixels = clip.min_x - sx;
+ sx += pixels;
+ x_index_base += xinc * pixels;
+ }
+ if (sy < clip.min_y)
+ { // clip top
+ const int pixels = clip.min_y - sy;
+ sy += pixels;
+ y_index += yinc * pixels;
+ }
+ // NS 980211 - fixed incorrect clipping
+ if (ex > clip.max_x + 1)
+ { // clip right
+ ex = clip.max_x + 1;
+ }
+ if (ey > clip.max_y + 1)
+ { // clip bottom
+ ey = clip.max_y + 1;
+ }
- for (offs = m_spriteram.bytes() - 32; offs >= 0; offs -= 32)
+ if (ex > sx)
+ { // skip if inner loop doesn't draw anything
+ for (int y = sy; y < ey; y++)
+ {
+ const u8 *source = source_base + y_index * gfx->rowbytes();
+ u16 *dest = &dest_bmp.pix16(y);
+ u8 *pri = &priority_bitmap.pix8(y);
+ int x_index = x_index_base;
+ for (int x = sx; x < ex; x++)
+ {
+ if (!(pri[x] & 0x80))
+ {
+ u8 c = source[x_index];
+ if (c != transparent_color)
+ {
+ // the priority is actually selected by bit 3 of BMPROM.07
+ if (((pri[x] & 2) == 0) || ((m_proms[0x900 + c + (color << 4)] & 0x08) == 0))
+ dest[x] = pal + c;
+
+ pri[x] = 0xff; // mark it 'already drawn'
+ }
+ }
+ x_index += xinc;
+ }
+ y_index += yinc;
+ }
+ }
+}
+
+void _1943_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
+{
+ for (int offs = 0; offs <= m_spriteram.bytes(); offs += 32)
{
- int attr = m_spriteram[offs + 1];
- int code = m_spriteram[offs] + ((attr & 0xe0) << 3);
- int color = attr & 0x0f;
+ const u8 attr = m_spriteram[offs + 1];
+ const u32 code = m_spriteram[offs] + ((attr & 0xe0) << 3);
+ const u32 color = attr & 0x0f;
int sx = m_spriteram[offs + 3] - ((attr & 0x10) << 4);
int sy = m_spriteram[offs + 2];
@@ -230,39 +298,28 @@ void _1943_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect,
sy = 240 - sy;
}
- // the priority is actually selected by bit 3 of BMPROM.07
- if (priority)
- {
- if (color != 0x0a && color != 0x0b)
- m_gfxdecode->gfx(3)->transpen(bitmap,cliprect, code, color, flip_screen(), flip_screen(), sx, sy, 0);
- }
- else
- {
- if (color == 0x0a || color == 0x0b)
- m_gfxdecode->gfx(3)->transpen(bitmap,cliprect, code, color, flip_screen(), flip_screen(), sx, sy, 0);
- }
+ _1943_drawgfx(bitmap,cliprect, m_gfxdecode->gfx(3), code, color, flip_screen(), flip_screen(), sx, sy, 0);
}
}
-uint32_t _1943_state::screen_update_1943(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
+u32 _1943_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
m_bg2_tilemap->set_scrollx(0, m_bgscrollx[0] + 256 * m_bgscrollx[1]);
m_bg_tilemap->set_scrollx(0, m_scrollx[0] + 256 * m_scrollx[1]);
m_bg_tilemap->set_scrolly(0, m_scrolly[0]);
+ screen.priority().fill(0, cliprect);
+
if (m_bg2_on)
- m_bg2_tilemap->draw(screen, bitmap, cliprect, 0, 0);
+ m_bg2_tilemap->draw(screen, bitmap, cliprect, 0, 1);
else
bitmap.fill(m_palette->black_pen(), cliprect);
- if (m_obj_on)
- draw_sprites(bitmap, cliprect, 0);
-
if (m_bg1_on)
- m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
+ m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 2);
if (m_obj_on)
- draw_sprites(bitmap, cliprect, 1);
+ draw_sprites(bitmap, cliprect);
if (m_char_on)
m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0);