summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/mame/drivers/starcrus.c14
-rw-r--r--src/mame/drivers/starshp1.c36
-rw-r--r--src/mame/drivers/statriv2.c10
-rw-r--r--src/mame/drivers/taitosj.c11
-rw-r--r--src/mame/drivers/talbot.c44
-rw-r--r--src/mame/drivers/tank8.c64
-rw-r--r--src/mame/includes/starshp1.h2
-rw-r--r--src/mame/includes/tank8.h10
-rw-r--r--src/mame/video/starshp1.c129
-rw-r--r--src/mame/video/taitosj.c201
-rw-r--r--src/mame/video/tank8.c180
11 files changed, 312 insertions, 389 deletions
diff --git a/src/mame/drivers/starcrus.c b/src/mame/drivers/starcrus.c
index feb585ae739..80678daabec 100644
--- a/src/mame/drivers/starcrus.c
+++ b/src/mame/drivers/starcrus.c
@@ -150,17 +150,6 @@ static GFXDECODE_START( starcrus )
GFXDECODE_END
-static const UINT16 colortable_source[] =
-{
- 0x00, 0x01, /* White on Black */
-};
-static PALETTE_INIT( starcrus )
-{
- palette_set_color(machine,0,MAKE_RGB(0x00,0x00,0x00)); /* Black */
- palette_set_color(machine,1,MAKE_RGB(0xff,0xff,0xff)); /* White */
- memcpy(colortable,colortable_source,sizeof(colortable_source));
-}
-
static const char *const starcrus_sample_names[] =
{
"*starcrus",
@@ -196,9 +185,8 @@ static MACHINE_DRIVER_START( starcrus )
MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 32*8-1)
MDRV_GFXDECODE(starcrus)
MDRV_PALETTE_LENGTH(2)
- MDRV_COLORTABLE_LENGTH(sizeof(colortable_source) / sizeof(colortable_source[0]))
- MDRV_PALETTE_INIT(starcrus)
+ MDRV_PALETTE_INIT(black_and_white)
MDRV_VIDEO_START(starcrus)
MDRV_VIDEO_UPDATE(starcrus)
diff --git a/src/mame/drivers/starshp1.c b/src/mame/drivers/starshp1.c
index e246df59485..cbaa615b9ec 100644
--- a/src/mame/drivers/starshp1.c
+++ b/src/mame/drivers/starshp1.c
@@ -8,7 +8,6 @@ Atari Starship 1 driver
***************************************************************************/
#include "driver.h"
-#include "deprecat.h"
#include "includes/starshp1.h"
int starshp1_attract;
@@ -23,36 +22,6 @@ static INTERRUPT_GEN( starshp1_interrupt )
}
-static void starshp1_write_palette(running_machine *machine, int inverse)
-{
- palette_set_color(machine, inverse ? 7 : 0, MAKE_RGB(0x00, 0x00, 0x00));
- palette_set_color(machine, inverse ? 6 : 1, MAKE_RGB(0x1e, 0x1e, 0x1e));
- palette_set_color(machine, inverse ? 5 : 2, MAKE_RGB(0x4e, 0x4e, 0x4e));
- palette_set_color(machine, inverse ? 4 : 3, MAKE_RGB(0x6c, 0x6c, 0x6c));
- palette_set_color(machine, inverse ? 3 : 4, MAKE_RGB(0x93, 0x93, 0x93));
- palette_set_color(machine, inverse ? 2 : 5, MAKE_RGB(0xb1, 0xb1, 0xb1));
- palette_set_color(machine, inverse ? 1 : 6, MAKE_RGB(0xe1, 0xe1, 0xe1));
- palette_set_color(machine, inverse ? 0 : 7, MAKE_RGB(0xff, 0xff, 0xff));
-}
-
-
-static PALETTE_INIT( starshp1 )
-{
- static const UINT16 colortable_source[] =
- {
- 0, 3, /* for the alpha numerics */
- 0, 2, /* for the sprites (Z=0) */
- 0, 5, /* for the sprites (Z=1) */
- 0, 2, 4, 6, /* for the spaceship (EXPLODE=0) */
- 0, 6, 6, 7 /* for the spaceship (EXPLODE=1) */
- };
-
- starshp1_write_palette(machine, 0);
-
- memcpy(colortable, colortable_source, sizeof(colortable_source));
-}
-
-
static WRITE8_HANDLER( starshp1_audio_w )
{
data &= 1;
@@ -177,7 +146,7 @@ static WRITE8_HANDLER( starshp1_misc_w )
starshp1_starfield_kill = data;
break;
case 4:
- starshp1_write_palette(Machine, data);
+ starshp1_inverse = data;
break;
case 5:
/* BLACK HOLE, not used */
@@ -341,8 +310,7 @@ static MACHINE_DRIVER_START( starshp1 )
MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
MDRV_SCREEN_RAW_PARAMS(STARSHP1_PIXEL_CLOCK, STARSHP1_HTOTAL, STARSHP1_HBEND, STARSHP1_HBSTART, STARSHP1_VTOTAL, STARSHP1_VBEND, STARSHP1_VBSTART)
MDRV_GFXDECODE(starshp1)
- MDRV_PALETTE_LENGTH(8)
- MDRV_COLORTABLE_LENGTH(14)
+ MDRV_PALETTE_LENGTH(19)
MDRV_PALETTE_INIT(starshp1)
MDRV_VIDEO_START(starshp1)
diff --git a/src/mame/drivers/statriv2.c b/src/mame/drivers/statriv2.c
index 10e83de6cb2..e9fdb4cab2e 100644
--- a/src/mame/drivers/statriv2.c
+++ b/src/mame/drivers/statriv2.c
@@ -139,13 +139,10 @@ static PALETTE_INIT(statriv2)
{
int i;
- for (i = 0; i < 8; i++)
- palette_set_color_rgb(machine,i,pal1bit(i >> 2),pal1bit(i >> 0),pal1bit(i >> 1));
-
for (i = 0; i < 64; i++)
{
- colortable[2*i+0] = i % 8;
- colortable[2*i+1] = i / 8;
+ palette_set_color_rgb(machine,2*i+0,pal1bit(i >> 2),pal1bit(i >> 0),pal1bit(i >> 1));
+ palette_set_color_rgb(machine,2*i+1,pal1bit(i >> 5),pal1bit(i >> 4),pal1bit(i >> 3));
}
}
@@ -623,8 +620,7 @@ static MACHINE_DRIVER_START( statriv2 )
MDRV_SCREEN_SIZE(64*8, 32*8)
MDRV_SCREEN_VISIBLE_AREA(4*8, 38*8-1, 0, 32*8-1)
MDRV_GFXDECODE(statriv2)
- MDRV_PALETTE_LENGTH(8)
- MDRV_COLORTABLE_LENGTH(2*64)
+ MDRV_PALETTE_LENGTH(2*64)
MDRV_PALETTE_INIT(statriv2)
MDRV_VIDEO_START(statriv2)
diff --git a/src/mame/drivers/taitosj.c b/src/mame/drivers/taitosj.c
index c8325a08a79..5d877a52ece 100644
--- a/src/mame/drivers/taitosj.c
+++ b/src/mame/drivers/taitosj.c
@@ -206,7 +206,6 @@ extern UINT8 *taitosj_video_priority;
extern UINT8 *taitosj_collision_reg;
extern UINT8 *kikstart_scrollram;
-PALETTE_INIT( taitosj );
READ8_HANDLER( taitosj_gfxrom_r );
WRITE8_HANDLER( taitosj_videoe_w );
WRITE8_HANDLER( taitosj_characterram_w );
@@ -1782,10 +1781,10 @@ static const gfx_layout spritelayout =
static GFXDECODE_START( taitosj )
- GFXDECODE_ENTRY( 0, 0x9000, charlayout, 0, 16 ) /* the game dynamically modifies this */
- GFXDECODE_ENTRY( 0, 0x9000, spritelayout, 0, 16 ) /* the game dynamically modifies this */
- GFXDECODE_ENTRY( 0, 0xa800, charlayout, 0, 16 ) /* the game dynamically modifies this */
- GFXDECODE_ENTRY( 0, 0xa800, spritelayout, 0, 16 ) /* the game dynamically modifies this */
+ GFXDECODE_ENTRY( 0, 0x9000, charlayout, 0, 8 ) /* the game dynamically modifies this */
+ GFXDECODE_ENTRY( 0, 0x9000, spritelayout, 0, 8 ) /* the game dynamically modifies this */
+ GFXDECODE_ENTRY( 0, 0xa800, charlayout, 0, 8 ) /* the game dynamically modifies this */
+ GFXDECODE_ENTRY( 0, 0xa800, spritelayout, 0, 8 ) /* the game dynamically modifies this */
GFXDECODE_END
@@ -1886,9 +1885,7 @@ static MACHINE_DRIVER_START( nomcu )
MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
MDRV_GFXDECODE(taitosj)
MDRV_PALETTE_LENGTH(64)
- MDRV_COLORTABLE_LENGTH(16*8)
- MDRV_PALETTE_INIT(taitosj)
MDRV_VIDEO_START(taitosj)
MDRV_VIDEO_UPDATE(taitosj)
diff --git a/src/mame/drivers/talbot.c b/src/mame/drivers/talbot.c
index 974de6b1da4..9a12139de5a 100644
--- a/src/mame/drivers/talbot.c
+++ b/src/mame/drivers/talbot.c
@@ -192,36 +192,45 @@ static PALETTE_INIT( talbot )
{
int i;
- for (i = 0;i < 32;i++)
- {
- int bit0,bit1,bit2,r,g,b;
+ /* allocate the colortable */
+ machine->colortable = colortable_alloc(machine, 0x20);
+ /* create a lookup table for the palette */
+ for (i = 0; i < 0x20; i++)
+ {
+ int bit0, bit1, bit2;
+ int r, g, b;
/* red component */
- bit0 = (*color_prom >> 0) & 0x01;
- bit1 = (*color_prom >> 1) & 0x01;
- bit2 = (*color_prom >> 2) & 0x01;
+ bit0 = (color_prom[i] >> 0) & 0x01;
+ bit1 = (color_prom[i] >> 1) & 0x01;
+ bit2 = (color_prom[i] >> 2) & 0x01;
r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
+
/* green component */
- bit0 = (*color_prom >> 3) & 0x01;
- bit1 = (*color_prom >> 4) & 0x01;
- bit2 = (*color_prom >> 5) & 0x01;
+ bit0 = (color_prom[i] >> 3) & 0x01;
+ bit1 = (color_prom[i] >> 4) & 0x01;
+ bit2 = (color_prom[i] >> 5) & 0x01;
g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
+
/* blue component */
bit0 = 0;
- bit1 = (*color_prom >> 6) & 0x01;
- bit2 = (*color_prom >> 7) & 0x01;
+ bit1 = (color_prom[i] >> 6) & 0x01;
+ bit2 = (color_prom[i] >> 7) & 0x01;
b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
- palette_set_color(machine,i,MAKE_RGB(r,g,b));
- color_prom++;
+ colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
}
/* color_prom now points to the beginning of the lookup table */
+ color_prom += 0x20;
- /* Colortable entry */
- for(i = 0; i < 0x100; i++)
- colortable[i] = color_prom[i];
+ /* characters map to the upper 16 palette entries */
+ for (i = 0; i < 0x100; i++)
+ {
+ UINT8 ctabentry = color_prom[i] & 0x1f;
+ colortable_entry_set_value(machine->colortable, i, ctabentry);
+ }
}
static MACHINE_DRIVER_START( talbot )
@@ -244,8 +253,7 @@ static MACHINE_DRIVER_START( talbot )
MDRV_SCREEN_SIZE(32*8, 32*8)
MDRV_SCREEN_VISIBLE_AREA(0, 32*8-1, 2*8, 30*8-1)
MDRV_GFXDECODE(talbot)
- MDRV_PALETTE_LENGTH(32)
- MDRV_COLORTABLE_LENGTH(0x100)
+ MDRV_PALETTE_LENGTH(0x100)
MDRV_PALETTE_INIT(talbot)
MDRV_VIDEO_START(talbot)
diff --git a/src/mame/drivers/tank8.c b/src/mame/drivers/tank8.c
index 2e9356fe4ad..fef6ae736de 100644
--- a/src/mame/drivers/tank8.c
+++ b/src/mame/drivers/tank8.c
@@ -20,55 +20,6 @@ void tank8_set_collision(int index)
}
-static void fill_palette(running_machine *machine, int team)
-{
- if (team)
- {
- palette_set_color(machine,0, MAKE_RGB(0xff, 0x00, 0x00)); /* red */
- palette_set_color(machine,2, MAKE_RGB(0xff, 0x00, 0x00)); /* red */
- palette_set_color(machine,4, MAKE_RGB(0xff, 0x00, 0x00)); /* red */
- palette_set_color(machine,6, MAKE_RGB(0xff, 0x00, 0x00)); /* red */
- palette_set_color(machine,1, MAKE_RGB(0x00, 0x00, 0xff)); /* blue */
- palette_set_color(machine,3, MAKE_RGB(0x00, 0x00, 0xff)); /* blue */
- palette_set_color(machine,5, MAKE_RGB(0x00, 0x00, 0xff)); /* blue */
- palette_set_color(machine,7, MAKE_RGB(0x00, 0x00, 0xff)); /* blue */
- }
- else
- {
- palette_set_color(machine,0, MAKE_RGB(0xff, 0x00, 0x00)); /* red */
- palette_set_color(machine,1, MAKE_RGB(0x00, 0x00, 0xff)); /* blue */
- palette_set_color(machine,2, MAKE_RGB(0xff, 0xff, 0x00)); /* yellow */
- palette_set_color(machine,3, MAKE_RGB(0x00, 0xff, 0x00)); /* green */
- palette_set_color(machine,4, MAKE_RGB(0xff, 0x00, 0xff)); /* magenta */
- palette_set_color(machine,5, MAKE_RGB(0xe0, 0xc0, 0x70)); /* puce */
- palette_set_color(machine,6, MAKE_RGB(0x00, 0xff, 0xff)); /* cyan */
- palette_set_color(machine,7, MAKE_RGB(0xff, 0xaa, 0xaa)); /* pink */
- }
-}
-
-
-static PALETTE_INIT( tank8 )
-{
- int i;
-
- fill_palette(machine,0);
-
- palette_set_color(machine, 8, MAKE_RGB(0x00, 0x00, 0x00));
- palette_set_color(machine, 9, MAKE_RGB(0xff, 0xff, 0xff));
-
- for (i = 0; i < 8; i++)
- {
- colortable[2 * i + 0] = 8;
- colortable[2 * i + 1] = i;
- }
-
- colortable[16] = 8;
- colortable[17] = 8;
- colortable[18] = 8;
- colortable[19] = 9;
-}
-
-
static MACHINE_RESET( tank8 )
{
collision_index = 0;
@@ -86,12 +37,6 @@ static WRITE8_HANDLER( tank8_lockout_w )
}
-static WRITE8_HANDLER( tank8_team_w )
-{
- fill_palette(Machine,~data & 1);
-}
-
-
static WRITE8_HANDLER( tank8_int_reset_w )
{
collision_index &= ~0x3f;
@@ -179,7 +124,7 @@ static ADDRESS_MAP_START( tank8_cpu_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x1d02, 0x1d02) AM_WRITE(tank8_explosion_w)
AM_RANGE(0x1d03, 0x1d03) AM_WRITE(tank8_bugle_w)
AM_RANGE(0x1d04, 0x1d04) AM_WRITE(tank8_bug_w)
- AM_RANGE(0x1d05, 0x1d05) AM_WRITE(tank8_team_w)
+ AM_RANGE(0x1d05, 0x1d05) AM_WRITE(MWA8_RAM) AM_BASE(&tank8_team)
AM_RANGE(0x1d06, 0x1d06) AM_WRITE(tank8_attract_w)
AM_RANGE(0x1e00, 0x1e07) AM_WRITE(tank8_motor_w)
@@ -377,8 +322,8 @@ static const gfx_layout tank_layout =
static GFXDECODE_START( tank8 )
GFXDECODE_ENTRY( REGION_GFX1, 0, tile_layout_1, 0, 10 )
GFXDECODE_ENTRY( REGION_GFX1, 0, tile_layout_2, 0, 10 )
- GFXDECODE_ENTRY( REGION_GFX2, 0, tank_layout, 0, 8 )
- GFXDECODE_ENTRY( REGION_GFX3, 0, tank_layout, 0, 8 )
+ GFXDECODE_ENTRY( REGION_GFX2, 0, tank_layout, 0, 8 )
+ GFXDECODE_ENTRY( REGION_GFX3, 0, tank_layout, 0, 8 )
GFXDECODE_END
@@ -398,8 +343,7 @@ static MACHINE_DRIVER_START( tank8 )
MDRV_SCREEN_SIZE(512, 524)
MDRV_SCREEN_VISIBLE_AREA(16, 495, 0, 463)
MDRV_GFXDECODE(tank8)
- MDRV_PALETTE_LENGTH(10)
- MDRV_COLORTABLE_LENGTH(20)
+ MDRV_PALETTE_LENGTH(20)
MDRV_PALETTE_INIT(tank8)
MDRV_VIDEO_START(tank8)
diff --git a/src/mame/includes/starshp1.h b/src/mame/includes/starshp1.h
index 19656c5f9e0..732d9e58ea9 100644
--- a/src/mame/includes/starshp1.h
+++ b/src/mame/includes/starshp1.h
@@ -55,6 +55,7 @@ extern int starshp1_phasor;
extern int starshp1_collision_latch;
extern int starshp1_starfield_kill;
extern int starshp1_mux;
+extern int starshp1_inverse;
READ8_HANDLER( starshp1_rng_r );
@@ -62,6 +63,7 @@ WRITE8_HANDLER( starshp1_sspic_w );
WRITE8_HANDLER( starshp1_ssadd_w );
WRITE8_HANDLER( starshp1_playfield_w );
+PALETTE_INIT( starshp1 );
VIDEO_UPDATE( starshp1 );
VIDEO_EOF( starshp1 );
VIDEO_START( starshp1 );
diff --git a/src/mame/includes/tank8.h b/src/mame/includes/tank8.h
index 6e0f41a2697..6bf3ec1068d 100644
--- a/src/mame/includes/tank8.h
+++ b/src/mame/includes/tank8.h
@@ -35,14 +35,16 @@ void tank8_set_collision(int index);
/*----------- defined in video/tank8.c -----------*/
+PALETTE_INIT( tank8 );
VIDEO_EOF( tank8 );
VIDEO_START( tank8 );
VIDEO_UPDATE( tank8 );
WRITE8_HANDLER( tank8_video_ram_w );
-extern UINT8* tank8_video_ram;
-extern UINT8* tank8_pos_h_ram;
-extern UINT8* tank8_pos_v_ram;
-extern UINT8* tank8_pos_d_ram;
+extern UINT8 *tank8_video_ram;
+extern UINT8 *tank8_pos_h_ram;
+extern UINT8 *tank8_pos_v_ram;
+extern UINT8 *tank8_pos_d_ram;
+extern UINT8 *tank8_team;
diff --git a/src/mame/video/starshp1.c b/src/mame/video/starshp1.c
index 444b5c30022..3cc16ad43d1 100644
--- a/src/mame/video/starshp1.c
+++ b/src/mame/video/starshp1.c
@@ -8,10 +8,10 @@ Atari Starship 1 video emulation
#include "deprecat.h"
#include "includes/starshp1.h"
-UINT8* starshp1_playfield_ram;
-UINT8* starshp1_hpos_ram;
-UINT8* starshp1_vpos_ram;
-UINT8* starshp1_obj_ram;
+UINT8 *starshp1_playfield_ram;
+UINT8 *starshp1_hpos_ram;
+UINT8 *starshp1_vpos_ram;
+UINT8 *starshp1_obj_ram;
int starshp1_ship_explode;
int starshp1_ship_picture;
@@ -29,12 +29,50 @@ int starshp1_starfield_kill;
int starshp1_phasor;
int starshp1_collision_latch;
int starshp1_mux;
+int starshp1_inverse;
-static UINT16* LSFR;
+static UINT16 *LSFR;
-static mame_bitmap* helper;
+static mame_bitmap *helper;
-static tilemap* bg_tilemap;
+static tilemap *bg_tilemap;
+
+
+static void set_pens(colortable_t *colortable)
+{
+ colortable_palette_set_color(colortable, starshp1_inverse ? 7 : 0, MAKE_RGB(0x00, 0x00, 0x00));
+ colortable_palette_set_color(colortable, starshp1_inverse ? 6 : 1, MAKE_RGB(0x1e, 0x1e, 0x1e));
+ colortable_palette_set_color(colortable, starshp1_inverse ? 5 : 2, MAKE_RGB(0x4e, 0x4e, 0x4e));
+ colortable_palette_set_color(colortable, starshp1_inverse ? 4 : 3, MAKE_RGB(0x6c, 0x6c, 0x6c));
+ colortable_palette_set_color(colortable, starshp1_inverse ? 3 : 4, MAKE_RGB(0x93, 0x93, 0x93));
+ colortable_palette_set_color(colortable, starshp1_inverse ? 2 : 5, MAKE_RGB(0xb1, 0xb1, 0xb1));
+ colortable_palette_set_color(colortable, starshp1_inverse ? 1 : 6, MAKE_RGB(0xe1, 0xe1, 0xe1));
+ colortable_palette_set_color(colortable, starshp1_inverse ? 0 : 7, MAKE_RGB(0xff, 0xff, 0xff));
+}
+
+
+PALETTE_INIT( starshp1 )
+{
+ int i;
+
+ static const UINT16 colortable_source[] =
+ {
+ 0, 3, /* 0x00 - 0x01 - alpha numerics */
+ 0, 2, /* 0x02 - 0x03 - sprites (Z=0) */
+ 0, 5, /* 0x04 - 0x05 - sprites (Z=1) */
+ 0, 2, 4, 6, /* 0x06 - 0x09 - spaceship (EXPLODE=0) */
+ 0, 6, 6, 7, /* 0x0a - 0x0d - spaceship (EXPLODE=1) */
+ 5, 2, /* 0x0e - 0x0f - star field */
+ 7, /* 0x10 - phasor */
+ 5, 7 /* 0x11 - circle */
+ };
+
+ /* allocate the colortable */
+ machine->colortable = colortable_alloc(machine, 8);
+
+ for (i = 0; i < sizeof(colortable_source) / sizeof(colortable_source[0]); i++)
+ colortable_entry_set_value(machine->colortable, i, colortable_source[i]);
+}
static TILE_GET_INFO( get_tile_info )
@@ -61,11 +99,10 @@ VIDEO_START( starshp1 )
for (i = 0; i < 0x10000; i++)
{
- int bit =
- (val >> 0xF) ^
- (val >> 0xC) ^
- (val >> 0x7) ^
- (val >> 0x1) ^ 1;
+ int bit = (val >> 0xf) ^
+ (val >> 0xc) ^
+ (val >> 0x7) ^
+ (val >> 0x1) ^ 1;
LSFR[i] = val;
@@ -117,9 +154,7 @@ WRITE8_HANDLER( starshp1_sspic_w )
*/
if (data != 0x87)
- {
starshp1_ship_picture = data;
- }
}
@@ -152,12 +187,8 @@ static void draw_starfield(mame_bitmap* bitmap)
UINT16* pLine = BITMAP_ADDR16(bitmap, y, 0);
for (x = 0; x < bitmap->width; x++)
- {
if ((p[x] & 0x5b56) == 0x5b44)
- {
- pLine[x] = (p[x] & 0x0400) ? 5 : 2;
- }
- }
+ pLine[x] = (p[x] & 0x0400) ? 0x0e : 0x0f;
}
}
@@ -202,13 +233,10 @@ static void draw_spaceship(running_machine *machine, mame_bitmap* bitmap, const
int y = get_sprite_vpos(14);
if (x <= 0)
- {
x -= (xzoom * starshp1_ship_hoffset) >> 16;
- }
+
if (y <= 0)
- {
y -= (yzoom * starshp1_ship_voffset) >> 16;
- }
drawgfxzoom(bitmap, machine->gfx[2],
starshp1_ship_picture & 0x03,
@@ -225,15 +253,13 @@ static void draw_phasor(mame_bitmap* bitmap)
int i;
for (i = 128; i < 240; i++)
- {
if (i >= get_sprite_vpos(13))
{
- *BITMAP_ADDR16(bitmap, i, 2 * i + 0) = 7;
- *BITMAP_ADDR16(bitmap, i, 2 * i + 1) = 7;
- *BITMAP_ADDR16(bitmap, i, 2 * (255 - i) + 0) = 7;
- *BITMAP_ADDR16(bitmap, i, 2 * (255 - i) + 1) = 7;
+ *BITMAP_ADDR16(bitmap, i, 2 * i + 0) = 0x10;
+ *BITMAP_ADDR16(bitmap, i, 2 * i + 1) = 0x10;
+ *BITMAP_ADDR16(bitmap, i, 2 * (255 - i) + 0) = 0x10;
+ *BITMAP_ADDR16(bitmap, i, 2 * (255 - i) + 1) = 0x10;
}
- }
}
@@ -268,19 +294,13 @@ static void draw_circle_line(mame_bitmap *bitmap, int x, int y, int l)
h2 = bitmap->width - 1;
for (x = h1; x <= h2; x++)
- {
if (starshp1_circle_mod)
{
if (p[x] & 1)
- {
- pLine[x] = 5;
- }
+ pLine[x] = 0x11;
}
else
- {
- pLine[x] = 7;
- }
- }
+ pLine[x] = 0x12;
}
}
@@ -307,18 +327,14 @@ static void draw_circle(mame_bitmap* bitmap)
x++;
if (d < 0)
- {
d += 4 * x + 6;
- }
else
- {
d += 4 * (x - y--) + 10;
- }
}
}
-static int spaceship_collision(mame_bitmap* bitmap, rectangle* rect)
+static int spaceship_collision(mame_bitmap *bitmap, rectangle *rect)
{
int x;
int y;
@@ -328,12 +344,8 @@ static int spaceship_collision(mame_bitmap* bitmap, rectangle* rect)
const UINT16* pLine = BITMAP_ADDR16(helper, y, 0);
for (x = rect->min_x; x <= rect->max_x; x++)
- {
if (pLine[x] != 0)
- {
return 1;
- }
- }
}
return 0;
@@ -349,23 +361,24 @@ static int point_in_circle(int x, int y, int center_x, int center_y, int r)
}
-static int circle_collision(rectangle* rect)
+static int circle_collision(rectangle *rect)
{
int center_x = get_circle_hpos();
int center_y = get_circle_vpos();
int r = get_radius();
- return
- point_in_circle(rect->min_x, rect->min_y, center_x, center_y, r) ||
- point_in_circle(rect->min_x, rect->max_y, center_x, center_y, r) ||
- point_in_circle(rect->max_x, rect->min_y, center_x, center_y, r) ||
- point_in_circle(rect->max_x, rect->max_y, center_x, center_y, r);
+ return point_in_circle(rect->min_x, rect->min_y, center_x, center_y, r) ||
+ point_in_circle(rect->min_x, rect->max_y, center_x, center_y, r) ||
+ point_in_circle(rect->max_x, rect->min_y, center_x, center_y, r) ||
+ point_in_circle(rect->max_x, rect->max_y, center_x, center_y, r);
}
VIDEO_UPDATE( starshp1 )
{
+ set_pens(machine->colortable);
+
fillbitmap(bitmap, machine->pens[0], cliprect);
if (starshp1_starfield_kill == 0)
@@ -386,6 +399,7 @@ VIDEO_UPDATE( starshp1 )
if (starshp1_phasor != 0)
draw_phasor(bitmap);
+
return 0;
}
@@ -414,19 +428,14 @@ VIDEO_EOF( starshp1 )
draw_spaceship(machine, helper, &machine->screen[0].visarea);
if (circle_collision(&machine->screen[0].visarea))
- {
starshp1_collision_latch |= 1;
- }
+
if (circle_collision(&rect))
- {
starshp1_collision_latch |= 2;
- }
+
if (spaceship_collision(helper, &rect))
- {
starshp1_collision_latch |= 4;
- }
+
if (spaceship_collision(helper, &machine->screen[0].visarea))
- {
starshp1_collision_latch |= 8;
- }
}
diff --git a/src/mame/video/taitosj.c b/src/mame/video/taitosj.c
index c66aaca7130..0dac2bf2d8a 100644
--- a/src/mame/video/taitosj.c
+++ b/src/mame/video/taitosj.c
@@ -7,12 +7,14 @@
***************************************************************************/
#include "driver.h"
+#include "video/resnet.h"
#define GLOBAL_FLIP_X (*taitosj_video_mode & 0x01)
#define GLOBAL_FLIP_Y (*taitosj_video_mode & 0x02)
#define SPRITE_RAM_PAGE_OFFSET ((*taitosj_video_mode & 0x04) ? 0x80 : 0x00)
#define SPRITES_ON (*taitosj_video_mode & 0x80)
+#define TRANSPARENT_PEN (0x40)
UINT8 *taitosj_videoram_1;
@@ -84,7 +86,7 @@ typedef void (*copy_layer_func_t)(running_machine *, mame_bitmap *,
***************************************************************************/
-static int draworder[32][4];
+static int draw_order[32][4];
/***************************************************************************
@@ -96,96 +98,58 @@ static int draworder[32][4];
The RAM is connected to the RGB output this way:
- bit 0 -- inverter -- 220 ohm resistor -- RED
+ bit 0 -- inverter -- 270 ohm resistor -- RED
bit 7 -- inverter -- 470 ohm resistor -- RED
-- inverter -- 1 kohm resistor -- RED
- -- inverter -- 220 ohm resistor -- GREEN
+ -- inverter -- 270 ohm resistor -- GREEN
-- inverter -- 470 ohm resistor -- GREEN
-- inverter -- 1 kohm resistor -- GREEN
- -- inverter -- 220 ohm resistor -- BLUE
+ -- inverter -- 270 ohm resistor -- BLUE
-- inverter -- 470 ohm resistor -- BLUE
bit 0 -- inverter -- 1 kohm resistor -- BLUE
***************************************************************************/
-PALETTE_INIT( taitosj )
+static void set_pens(running_machine *machine)
{
+ static const int resistances[3] = { 1000, 470, 270 };
+ double rweights[3], gweights[3], bweights[3];
int i;
- #define COLOR(gfxn,offs) (colortable[machine->config->gfxdecodeinfo[gfxn].color_codes_start + offs])
-
- /* all gfx elements use the same palette */
- for (i = 0 ;i < 64; i++)
- {
- /* we create both a "normal" lookup table and one where pen 0 is */
- /* always mapped to color 0. This is needed for transparency. */
-
- COLOR(0, i) = i;
-
- if ((i % 8) == 0)
- COLOR(0, i + 64) = 0;
- else
- COLOR(0, i + 64) = i;
- }
-
- /* do a simple conversion of the PROM into layer priority order. Note that */
- /* this is a simplification, which assumes the PROM encodes a sensible priority */
- /* scheme. */
- color_prom = memory_region(REGION_PROMS);
-
- for (i = 0; i < 32; i++)
- {
- int j, mask;
-
- mask = 0; /* start with all four layers active, so we'll get the highest */
- /* priority one in the first loop */
-
- for (j = 3; j >= 0; j--)
- {
- int data;
-
- data = color_prom[0x10 * (i & 0x0f) + mask];
- if (i & 0x10) data >>= 2;
- data &= 0x03;
- mask |= (1 << data); /* in next loop, we'll see which of the remaining */
- /* layers has top priority when this one is transparent */
- draworder[i][j] = data;
- }
- }
-}
+ /* compute the color output resistor weights */
+ compute_resistor_weights(0, 255, -1.0,
+ 3, resistances, rweights, 0, 0,
+ 3, resistances, gweights, 0, 0,
+ 3, resistances, bweights, 0, 0);
-static void set_colors(running_machine *machine)
-{
- offs_t offs;
-
- for (offs = 0; offs < 0x40; offs++)
+ for (i = 0; i < 0x40; i++)
{
- int bit0,bit1,bit2;
- int r,g,b,val;
+ int bit0, bit1, bit2;
+ int r, g, b, val;
/* red component */
- val = taitosj_paletteram[(offs << 1) | 0x01];
+ val = taitosj_paletteram[(i << 1) | 0x01];
bit0 = (~val >> 6) & 0x01;
bit1 = (~val >> 7) & 0x01;
- val = taitosj_paletteram[(offs << 1) | 0x00];
+ val = taitosj_paletteram[(i << 1) | 0x00];
bit2 = (~val >> 0) & 0x01;
- r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
+ r = combine_3_weights(rweights, bit0, bit1, bit2);
/* green component */
- val = taitosj_paletteram[(offs << 1) | 0x01];
+ val = taitosj_paletteram[(i << 1) | 0x01];
bit0 = (~val >> 3) & 0x01;
bit1 = (~val >> 4) & 0x01;
bit2 = (~val >> 5) & 0x01;
- g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
+ g = combine_3_weights(gweights, bit0, bit1, bit2);
/* blue component */
- val = taitosj_paletteram[(offs << 1) | 0x01];
+ val = taitosj_paletteram[(i << 1) | 0x01];
bit0 = (~val >> 0) & 0x01;
bit1 = (~val >> 1) & 0x01;
bit2 = (~val >> 2) & 0x01;
- b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
+ b = combine_3_weights(bweights, bit0, bit1, bit2);
- palette_set_color(machine, offs, MAKE_RGB(r,g,b));
+ palette_set_color(machine, i, MAKE_RGB(r, g, b));
}
}
@@ -203,6 +167,38 @@ static void taitosj_postload(void)
Start the video hardware emulation.
***************************************************************************/
+
+static void compute_draw_order(void)
+{
+ int i;
+
+ /* do a simple conversion of the PROM into layer priority order. Note that */
+ /* this is a simplification, which assumes the PROM encodes a sensible priority */
+ /* scheme. */
+ for (i = 0; i < 32; i++)
+ {
+ int j;
+ int mask = 0; /* start with all four layers active, so we'll get the highest */
+ /* priority one in the first loop */
+ for (j = 3; j >= 0; j--)
+ {
+ UINT8 *color_prom = memory_region(REGION_PROMS);
+
+ int data = color_prom[0x10 * (i & 0x0f) + mask] & 0x0f;
+
+ if (i & 0x10)
+ data = data >> 2;
+ else
+ data = data & 0x03;
+
+ mask |= (1 << data); /* in next loop, we'll see which of the remaining */
+ /* layers has top priority when this one is transparent */
+ draw_order[i][j] = data;
+ }
+ }
+}
+
+
VIDEO_START( taitosj )
{
int i;
@@ -223,6 +219,8 @@ VIDEO_START( taitosj )
memset(dirtysprite1, 1, sizeof(dirtysprite1));
memset(dirtysprite2, 1, sizeof(dirtysprite2));
+ compute_draw_order();
+
state_save_register_func_postload(taitosj_postload);
}
@@ -339,33 +337,29 @@ static int check_sprite_sprite_bitpattern(running_machine *machine,
}
/* draw the sprites into seperate bitmaps and check overlapping region */
+ fillbitmap(sprite_layer_collbitmap1, TRANSPARENT_PEN, NULL);
drawgfx(sprite_sprite_collbitmap1, get_sprite_gfx_element(machine, which1),
taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 3] & 0x3f,
0,
taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 2] & 0x01,
taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 2] & 0x02,
sx1, sy1,
- 0, TRANSPARENCY_NONE, 0);
+ 0, TRANSPARENCY_PEN, 0);
+ fillbitmap(sprite_sprite_collbitmap2, TRANSPARENT_PEN, NULL);
drawgfx(sprite_sprite_collbitmap2, get_sprite_gfx_element(machine, which2),
taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 3] & 0x3f,
0,
taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 2] & 0x01,
taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 2] & 0x02,
sx2, sy2,
- 0, TRANSPARENCY_NONE, 0);
+ 0, TRANSPARENCY_PEN, 0);
for (y = miny; y < maxy; y++)
- {
for (x = minx; x < maxx; x++)
- {
- if ((*BITMAP_ADDR16(sprite_sprite_collbitmap1, y, x) != machine->pens[0]) &&
- (*BITMAP_ADDR16(sprite_sprite_collbitmap2, y, x) != machine->pens[0]))
- {
+ if ((*BITMAP_ADDR16(sprite_sprite_collbitmap1, y, x) != TRANSPARENT_PEN) &&
+ (*BITMAP_ADDR16(sprite_sprite_collbitmap2, y, x) != TRANSPARENT_PEN))
return 1; /* collided */
- }
- }
- }
return 0;
}
@@ -480,7 +474,7 @@ static void calculate_sprite_areas(running_machine *machine, int *sprites_on, re
static int check_sprite_layer_bitpattern(running_machine *machine, int which, rectangle *sprite_areas)
{
- int y;
+ int y, x;
offs_t offs = which * 4;
int result = 0; /* no collisions */
@@ -497,32 +491,27 @@ static int check_sprite_layer_bitpattern(running_machine *machine, int which, re
int flip_y = (taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x02) ^ GLOBAL_FLIP_Y;
/* draw sprite into a bitmap and check if layers collide */
+ fillbitmap(sprite_layer_collbitmap1, TRANSPARENT_PEN, NULL);
drawgfx(sprite_layer_collbitmap1, get_sprite_gfx_element(machine, which),
taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x3f,
0,
flip_x, flip_y,
0,0,
- 0,TRANSPARENCY_NONE,0);
+ 0,TRANSPARENCY_PEN,0);
for (y = miny; y < maxy; y++)
- {
- int x;
-
for (x = minx; x < maxx; x++)
- {
- if (*BITMAP_ADDR16(sprite_layer_collbitmap1, y - miny, x - minx) != machine->pens[0]) /* is there anything to check for ? */
+ if (*BITMAP_ADDR16(sprite_layer_collbitmap1, y - miny, x - minx) != TRANSPARENT_PEN) /* is there anything to check for ? */
{
- if (check_layer_1 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[0], y, x) != machine->pens[0]))
+ if (check_layer_1 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[0], y, x) != TRANSPARENT_PEN))
result |= 0x01; /* collided with layer 1 */
- if (check_layer_2 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[1], y, x) != machine->pens[0]))
+ if (check_layer_2 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[1], y, x) != TRANSPARENT_PEN))
result |= 0x02; /* collided with layer 2 */
- if (check_layer_3 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[2], y, x) != machine->pens[0]))
+ if (check_layer_3 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[2], y, x) != TRANSPARENT_PEN))
result |= 0x04; /* collided with layer 3 */
}
- }
- }
return result;
}
@@ -588,6 +577,10 @@ static void draw_layers(running_machine *machine)
{
offs_t offs;
+ fillbitmap(taitosj_layer_bitmap[0], TRANSPARENT_PEN, NULL);
+ fillbitmap(taitosj_layer_bitmap[1], TRANSPARENT_PEN, NULL);
+ fillbitmap(taitosj_layer_bitmap[2], TRANSPARENT_PEN, NULL);
+
for (offs = 0; offs < 0x0400; offs++)
{
int sx = offs % 32;
@@ -598,24 +591,24 @@ static void draw_layers(running_machine *machine)
drawgfx(taitosj_layer_bitmap[0],machine->gfx[taitosj_colorbank[0] & 0x08 ? 2 : 0],
taitosj_videoram_1[offs],
- (taitosj_colorbank[0] & 0x07) + 8, /* use transparent pen 0 */
+ taitosj_colorbank[0] & 0x07,
GLOBAL_FLIP_X,GLOBAL_FLIP_Y,
8*sx,8*sy,
- 0,TRANSPARENCY_NONE,0);
+ 0,TRANSPARENCY_PEN,0);
drawgfx(taitosj_layer_bitmap[1],machine->gfx[taitosj_colorbank[0] & 0x80 ? 2 : 0],
taitosj_videoram_2[offs],
- ((taitosj_colorbank[0] >> 4) & 0x07) + 8, /* use transparent pen 0 */
+ (taitosj_colorbank[0] >> 4) & 0x07,
GLOBAL_FLIP_X,GLOBAL_FLIP_Y,
8*sx,8*sy,
- 0,TRANSPARENCY_NONE,0);
+ 0,TRANSPARENCY_PEN,0);
drawgfx(taitosj_layer_bitmap[2],machine->gfx[taitosj_colorbank[1] & 0x08 ? 2 : 0],
taitosj_videoram_3[offs],
- (taitosj_colorbank[1] & 0x07) + 8, /* use transparent pen 0 */
+ taitosj_colorbank[1] & 0x07,
GLOBAL_FLIP_X,GLOBAL_FLIP_Y,
8*sx,8*sy,
- 0,TRANSPARENCY_NONE,0);
+ 0,TRANSPARENCY_PEN,0);
}
}
@@ -704,17 +697,13 @@ static void taitosj_copy_layer(running_machine *machine, mame_bitmap *bitmap, co
scrollx = -(scrollx & 0xf8) + ((scrollx + fudge1[which]) & 7) + fudge2[which];
if (GLOBAL_FLIP_Y)
- {
for (i = 0;i < 32;i++)
scrolly[31 - i] = taitosj_colscrolly[32 * which + i] + taitosj_scroll[2 * which + 1];
- }
else
- {
for (i = 0;i < 32;i++)
scrolly[i] = -taitosj_colscrolly[32 * which + i] - taitosj_scroll[2 * which + 1];
- }
- copyscrollbitmap_trans(bitmap, taitosj_layer_bitmap[which], 1, &scrollx, 32, scrolly, cliprect, machine->pens[0]);
+ copyscrollbitmap_trans(bitmap, taitosj_layer_bitmap[which], 1, &scrollx, 32, scrolly, cliprect, TRANSPARENT_PEN);
/* store parts covered with sprites for sprites/layers collision detection */
for (i = 0; i < 0x20; i++)
@@ -736,29 +725,23 @@ static void kikstart_copy_layer(running_machine *machine, mame_bitmap *bitmap, c
int i, scrolly, scrollx[32 * 8];
for (i = 1; i < 32*8; i++) /* 1-255 ! */
- {
if (GLOBAL_FLIP_Y)
- {
switch (which)
{
- case 0: scrollx[32 * 8 - i] = 0 ;break;
- case 1: scrollx[32 * 8 - i] = kikstart_scrollram[i] + ((taitosj_scroll[2 * which] + 0x0a) & 0xff);break;
- case 2: scrollx[32 * 8 - i] = kikstart_scrollram[0x100 + i] + ((taitosj_scroll[2 * which] + 0xc) & 0xff);break;
+ case 0: scrollx[32 * 8 - i] = 0 ;break;
+ case 1: scrollx[32 * 8 - i] = kikstart_scrollram[i] + ((taitosj_scroll[2 * which] + 0x0a) & 0xff);break;
+ case 2: scrollx[32 * 8 - i] = kikstart_scrollram[0x100 + i] + ((taitosj_scroll[2 * which] + 0xc) & 0xff);break;
}
- }
else
- {
switch (which)
{
- case 0: scrollx[i] = 0 ;break;
- case 1: scrollx[i] = 0xff - kikstart_scrollram[i - 1] - ((taitosj_scroll[2 * which] - 0x10) & 0xff);break;
- case 2: scrollx[i] = 0xff - kikstart_scrollram[0x100 + i - 1] - ((taitosj_scroll[2 * which] - 0x12) & 0xff);break;
+ case 0: scrollx[i] = 0 ;break;
+ case 1: scrollx[i] = 0xff - kikstart_scrollram[i - 1] - ((taitosj_scroll[2 * which] - 0x10) & 0xff);break;
+ case 2: scrollx[i] = 0xff - kikstart_scrollram[0x100 + i - 1] - ((taitosj_scroll[2 * which] - 0x12) & 0xff);break;
}
- }
- }
scrolly = taitosj_scroll[2 * which + 1]; /* always 0 */
- copyscrollbitmap_trans(bitmap, taitosj_layer_bitmap[which], 32 * 8, scrollx, 1, &scrolly, cliprect, machine->pens[0]);
+ copyscrollbitmap_trans(bitmap, taitosj_layer_bitmap[which], 32 * 8, scrollx, 1, &scrolly, cliprect, TRANSPARENT_PEN);
/* store parts covered with sprites for sprites/layers collision detection */
for (i = 0; i < 0x20; i++)
@@ -792,7 +775,7 @@ static void copy_layers(running_machine *machine, mame_bitmap *bitmap, const rec
for (i = 0; i < 4; i++)
{
- int which = draworder[*taitosj_video_priority & 0x1f][i];
+ int which = draw_order[*taitosj_video_priority & 0x1f][i];
copy_layer(machine, bitmap, cliprect, copy_layer_func, which, sprites_on, sprite_areas);
}
@@ -815,7 +798,7 @@ static int video_update_common(running_machine *machine, mame_bitmap *bitmap,
int sprites_on[0x20]; /* 1 if sprite is active */
rectangle sprite_areas[0x20]; /* areas on bitmap (sprite locations) */
- set_colors(machine);
+ set_pens(machine);
decode_modified(machine);
diff --git a/src/mame/video/tank8.c b/src/mame/video/tank8.c
index 91fee801d22..5c0bb5526d9 100644
--- a/src/mame/video/tank8.c
+++ b/src/mame/video/tank8.c
@@ -9,30 +9,82 @@ Atari Tank 8 video emulation
#include "includes/tank8.h"
-UINT8* tank8_video_ram;
-UINT8* tank8_pos_h_ram;
-UINT8* tank8_pos_v_ram;
-UINT8* tank8_pos_d_ram;
+UINT8 *tank8_video_ram;
+UINT8 *tank8_pos_h_ram;
+UINT8 *tank8_pos_v_ram;
+UINT8 *tank8_pos_d_ram;
+UINT8 *tank8_team;
-static tilemap* tilemap1;
-static tilemap* tilemap2;
+static tilemap *tank8_tilemap;
-static mame_bitmap* helper1;
-static mame_bitmap* helper2;
-static mame_bitmap* helper3;
+static mame_bitmap *helper1;
+static mame_bitmap *helper2;
+static mame_bitmap *helper3;
+PALETTE_INIT( tank8 )
+{
+ int i;
+
+ /* allocate the colortable */
+ machine->colortable = colortable_alloc(machine, 0x0a);
+
+ colortable_palette_set_color(machine->colortable, 8, MAKE_RGB(0x00, 0x00, 0x00));
+ colortable_palette_set_color(machine->colortable, 9, MAKE_RGB(0xff, 0xff, 0xff));
+
+ for (i = 0; i < 8; i++)
+ {
+ colortable_entry_set_value(machine->colortable, 2 * i + 0, 8);
+ colortable_entry_set_value(machine->colortable, 2 * i + 1, i);
+ }
+
+ /* walls */
+ colortable_entry_set_value(machine->colortable, 0x10, 8);
+ colortable_entry_set_value(machine->colortable, 0x11, 9);
+
+ /* mines */
+ colortable_entry_set_value(machine->colortable, 0x12, 8);
+ colortable_entry_set_value(machine->colortable, 0x13, 9);
+}
+
+
+static void set_pens(colortable_t *colortable)
+{
+ if (*tank8_team & 0x01)
+ {
+ colortable_palette_set_color(colortable, 0, MAKE_RGB(0xff, 0x00, 0x00)); /* red */
+ colortable_palette_set_color(colortable, 1, MAKE_RGB(0x00, 0x00, 0xff)); /* blue */
+ colortable_palette_set_color(colortable, 2, MAKE_RGB(0xff, 0xff, 0x00)); /* yellow */
+ colortable_palette_set_color(colortable, 3, MAKE_RGB(0x00, 0xff, 0x00)); /* green */
+ colortable_palette_set_color(colortable, 4, MAKE_RGB(0xff, 0x00, 0xff)); /* magenta */
+ colortable_palette_set_color(colortable, 5, MAKE_RGB(0xe0, 0xc0, 0x70)); /* puce */
+ colortable_palette_set_color(colortable, 6, MAKE_RGB(0x00, 0xff, 0xff)); /* cyan */
+ colortable_palette_set_color(colortable, 7, MAKE_RGB(0xff, 0xaa, 0xaa)); /* pink */
+ }
+ else
+ {
+ colortable_palette_set_color(colortable, 0, MAKE_RGB(0xff, 0x00, 0x00)); /* red */
+ colortable_palette_set_color(colortable, 2, MAKE_RGB(0xff, 0x00, 0x00)); /* red */
+ colortable_palette_set_color(colortable, 4, MAKE_RGB(0xff, 0x00, 0x00)); /* red */
+ colortable_palette_set_color(colortable, 6, MAKE_RGB(0xff, 0x00, 0x00)); /* red */
+ colortable_palette_set_color(colortable, 1, MAKE_RGB(0x00, 0x00, 0xff)); /* blue */
+ colortable_palette_set_color(colortable, 3, MAKE_RGB(0x00, 0x00, 0xff)); /* blue */
+ colortable_palette_set_color(colortable, 5, MAKE_RGB(0x00, 0x00, 0xff)); /* blue */
+ colortable_palette_set_color(colortable, 7, MAKE_RGB(0x00, 0x00, 0xff)); /* blue */
+ }
+}
+
+
WRITE8_HANDLER( tank8_video_ram_w )
{
tank8_video_ram[offset] = data;
- tilemap_mark_tile_dirty(tilemap1, offset);
- tilemap_mark_tile_dirty(tilemap2, offset);
+ tilemap_mark_tile_dirty(tank8_tilemap, offset);
}
-static TILE_GET_INFO( tank8_get_tile_info1 )
+static TILE_GET_INFO( tank8_get_tile_info )
{
UINT8 code = tank8_video_ram[tile_index];
@@ -40,49 +92,27 @@ static TILE_GET_INFO( tank8_get_tile_info1 )
if ((code & 0x38) == 0x28)
{
- color = 9; /* walls & mines */
+ if ((code & 7) != 3)
+ color = 8; /* walls */
+ else
+ color = 9; /* mines */
}
else
{
if (tile_index & 0x010)
- {
color |= 1;
- }
+
if (code & 0x80)
- {
color |= 2;
- }
+
if (tile_index & 0x200)
- {
color |= 4;
- }
}
SET_TILE_INFO(code >> 7, code, color, (code & 0x40) ? (TILE_FLIPX | TILE_FLIPY) : 0);
}
-static TILE_GET_INFO( tank8_get_tile_info2 )
-{
- UINT8 code = tank8_video_ram[tile_index];
-
- int color = 8;
-
- if ((code & 0x38) == 0x28)
- {
- if ((code & 7) != 3)
- {
- color = 1; /* walls */
- }
- else
- {
- color = 2; /* mines */
- }
- }
-
- SET_TILE_INFO(code >> 7, code, color, (code & 0x40) ? (TILE_FLIPX | TILE_FLIPY) : 0);
-}
-
VIDEO_START( tank8 )
{
@@ -90,13 +120,11 @@ VIDEO_START( tank8 )
helper2 = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, machine->screen[0].format);
helper3 = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, machine->screen[0].format);
- tilemap1 = tilemap_create(tank8_get_tile_info1, tilemap_scan_rows, 16, 16, 32, 32);
- tilemap2 = tilemap_create(tank8_get_tile_info2, tilemap_scan_rows, 16, 16, 32, 32);
+ tank8_tilemap = tilemap_create(tank8_get_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
/* VBLANK starts on scanline #256 and ends on scanline #24 */
- tilemap_set_scrolly(tilemap1, 0, 2 * 24);
- tilemap_set_scrolly(tilemap2, 0, 2 * 24);
+ tilemap_set_scrolly(tank8_tilemap, 0, 2 * 24);
}
@@ -112,7 +140,7 @@ static int get_y_pos(int n)
}
-static void draw_sprites(running_machine *machine, mame_bitmap* bitmap, const rectangle* cliprect)
+static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
{
int i;
@@ -135,7 +163,7 @@ static void draw_sprites(running_machine *machine, mame_bitmap* bitmap, const re
}
-static void draw_bullets(mame_bitmap* bitmap, const rectangle* cliprect)
+static void draw_bullets(mame_bitmap *bitmap, const rectangle *cliprect)
{
int i;
@@ -162,7 +190,7 @@ static void draw_bullets(mame_bitmap* bitmap, const rectangle* cliprect)
if (rect.max_y > cliprect->max_y)
rect.max_y = cliprect->max_y;
- fillbitmap(bitmap, i, &rect);
+ fillbitmap(bitmap, (i << 1) | 0x01, &rect);
}
}
@@ -175,7 +203,8 @@ static TIMER_CALLBACK( tank8_collision_callback )
VIDEO_UPDATE( tank8 )
{
- tilemap_draw(bitmap, cliprect, tilemap1, 0, 0);
+ set_pens(machine->colortable);
+ tilemap_draw(bitmap, cliprect, tank8_tilemap, 0, 0);
draw_sprites(machine, bitmap, cliprect);
draw_bullets(bitmap, cliprect);
@@ -185,12 +214,12 @@ VIDEO_UPDATE( tank8 )
VIDEO_EOF( tank8 )
{
- const rectangle* clip = &machine->screen[0].visarea;
+ const rectangle *clip = &machine->screen[0].visarea;
int x;
int y;
- tilemap_draw(helper1, clip, tilemap2, 0, 0);
+ tilemap_draw(helper1, clip, tank8_tilemap, 0, 0);
fillbitmap(helper2, 8, clip);
fillbitmap(helper3, 8, clip);
@@ -207,65 +236,62 @@ VIDEO_EOF( tank8 )
const UINT16* p3 = BITMAP_ADDR16(helper3, y, 0);
if (y % 2 != cpu_getcurrentframe() % 2)
- {
continue; /* video display is interlaced */
- }
for (x = clip->min_x; x <= clip->max_x; x++)
{
UINT8 index;
- if (p1[x] == 8)
+ /* neither wall nor mine */
+ if ((p1[x] != 0x11) && (p1[x] != 0x13))
{
- state = 0; continue; /* neither wall nor mine */
+ state = 0;
+ continue;
}
- if (p2[x] == 8 && p3[x] == 8)
+
+ /* neither tank nor bullet */
+ if ((p2[x] == 8) && (p3[x] == 8))
{
- state = 0; continue; /* neither tank nor bullet */
+ state = 0;
+ continue;
}
- if (p3[x] != 8 && p1[x] == 2)
+
+ /* bullets cannot hit mines */
+ if ((p3[x] != 8) && (p1[x] == 0x13))
{
- state = 0; continue; /* bullets cannot hit mines */
+ state = 0;
+ continue;
}
if (state)
- {
continue;
- }
if (p3[x] != 8)
{
- index = p3[x] | 0x18;
+ index = ((p3[x] & ~0x01) >> 1) | 0x18;
if (1)
- {
index |= 0x20;
- }
+
if (0)
- {
index |= 0x40;
- }
+
if (1)
- {
index |= 0x80;
- }
}
else
{
- index = p2[x] | 0x10;
+ int sprite_num = (p2[x] & ~0x01) >> 1;
+ index = sprite_num | 0x10;
- if (p1[x] == 1)
- {
+ if (p1[x] == 0x11)
index |= 0x20;
- }
- if (y - get_y_pos(p2[x]) >= 8)
- {
+
+ if (y - get_y_pos(sprite_num) >= 8)
index |= 0x40; /* collision on bottom side */
- }
- if (x - get_x_pos(p2[x]) >= 8)
- {
+
+ if (x - get_x_pos(sprite_num) >= 8)
index |= 0x80; /* collision on right side */
- }
}
timer_set(video_screen_get_time_until_pos(0, y, x), NULL, index, tank8_collision_callback);