diff options
Diffstat (limited to 'src/mame/video/starshp1.c')
-rw-r--r-- | src/mame/video/starshp1.c | 129 |
1 files changed, 69 insertions, 60 deletions
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; - } } |