mirror of
https://github.com/holub/mame
synced 2025-04-23 17:00:53 +03:00
Simplifies Star Fire driver
This commit is contained in:
parent
4930b2dbfd
commit
4b6ceec3f9
@ -49,42 +49,11 @@ starfira has one less rom in total than starfire but everything passes as
|
||||
|
||||
|
||||
|
||||
UINT8 *starfire_videoram;
|
||||
UINT8 *starfire_colorram;
|
||||
|
||||
static UINT8 fireone_select;
|
||||
static read8_handler input_read;
|
||||
|
||||
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* Video updates
|
||||
*
|
||||
*************************************/
|
||||
|
||||
#define SCANLINE_UPDATE_CHUNK 8
|
||||
|
||||
static TIMER_CALLBACK( update_callback )
|
||||
{
|
||||
int scanline = param;
|
||||
|
||||
/* update the previous chunk of scanlines */
|
||||
starfire_video_update(scanline, SCANLINE_UPDATE_CHUNK);
|
||||
scanline += SCANLINE_UPDATE_CHUNK;
|
||||
if (scanline >= machine->screen[0].height)
|
||||
scanline = 32;
|
||||
timer_set(video_screen_get_time_until_pos(0, scanline + SCANLINE_UPDATE_CHUNK - 1, 0), NULL, scanline, update_callback);
|
||||
}
|
||||
|
||||
|
||||
static MACHINE_RESET( starfire )
|
||||
{
|
||||
timer_set(video_screen_get_time_until_pos(0, 32 + SCANLINE_UPDATE_CHUNK - 1, 0), NULL, 32, update_callback);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* Scratch RAM, mapped into video RAM
|
||||
@ -181,18 +150,11 @@ static READ8_HANDLER( fireone_input_r )
|
||||
*
|
||||
*************************************/
|
||||
|
||||
static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 )
|
||||
AM_RANGE(0x0000, 0x7fff) AM_READ(MRA8_ROM)
|
||||
AM_RANGE(0x8000, 0x9fff) AM_READ(starfire_scratch_r)
|
||||
AM_RANGE(0xa000, 0xbfff) AM_READ(starfire_colorram_r)
|
||||
AM_RANGE(0xc000, 0xffff) AM_READ(starfire_videoram_r)
|
||||
ADDRESS_MAP_END
|
||||
|
||||
static ADDRESS_MAP_START( writemem, ADDRESS_SPACE_PROGRAM, 8 )
|
||||
AM_RANGE(0x0000, 0x7fff) AM_WRITE(MWA8_ROM)
|
||||
AM_RANGE(0x8000, 0x9fff) AM_WRITE(starfire_scratch_w)
|
||||
AM_RANGE(0xa000, 0xbfff) AM_WRITE(starfire_colorram_w) AM_BASE(&starfire_colorram)
|
||||
AM_RANGE(0xc000, 0xffff) AM_WRITE(starfire_videoram_w) AM_BASE(&starfire_videoram)
|
||||
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
|
||||
AM_RANGE(0x0000, 0x7fff) AM_ROM
|
||||
AM_RANGE(0x8000, 0x9fff) AM_READWRITE(starfire_scratch_r, starfire_scratch_w)
|
||||
AM_RANGE(0xa000, 0xbfff) AM_READWRITE(MRA8_RAM, starfire_colorram_w) AM_BASE(&starfire_colorram)
|
||||
AM_RANGE(0xc000, 0xffff) AM_READWRITE(starfire_videoram_r, starfire_videoram_w) AM_BASE(&starfire_videoram)
|
||||
ADDRESS_MAP_END
|
||||
|
||||
|
||||
@ -302,21 +264,18 @@ static MACHINE_DRIVER_START( starfire )
|
||||
|
||||
/* basic machine hardware */
|
||||
MDRV_CPU_ADD(Z80, STARFIRE_CPU_CLOCK)
|
||||
MDRV_CPU_PROGRAM_MAP(readmem,writemem)
|
||||
MDRV_CPU_PROGRAM_MAP(main_map,0)
|
||||
MDRV_CPU_VBLANK_INT(nmi_line_pulse,1)
|
||||
|
||||
MDRV_MACHINE_RESET(starfire)
|
||||
|
||||
/* video hardware */
|
||||
MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
|
||||
MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
|
||||
MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
|
||||
MDRV_SCREEN_RAW_PARAMS(STARFIRE_PIXEL_CLOCK, STARFIRE_HTOTAL, STARFIRE_HBEND, STARFIRE_HBSTART, STARFIRE_VTOTAL, STARFIRE_VBEND, STARFIRE_VBSTART)
|
||||
MDRV_PALETTE_LENGTH(64)
|
||||
|
||||
MDRV_VIDEO_START(starfire)
|
||||
MDRV_VIDEO_UPDATE(starfire)
|
||||
|
||||
/* sound hardware */
|
||||
/* audio hardware */
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
|
||||
@ -406,6 +365,9 @@ static DRIVER_INIT( starfire )
|
||||
static DRIVER_INIT( fireone )
|
||||
{
|
||||
input_read = fireone_input_r;
|
||||
|
||||
/* register for state saving */
|
||||
state_save_register_global(fireone_select);
|
||||
}
|
||||
|
||||
|
||||
@ -416,7 +378,7 @@ static DRIVER_INIT( fireone )
|
||||
*
|
||||
*************************************/
|
||||
|
||||
GAME( 1979, starfire, 0, starfire, starfire, starfire, ROT0, "Exidy", "Star Fire (set 1)", GAME_NO_SOUND )
|
||||
GAME( 1979, starfira, starfire, starfire, starfire, starfire, ROT0, "Exidy", "Star Fire (set 2)", GAME_NO_SOUND )
|
||||
GAME( 1979, fireone, 0, starfire, fireone, fireone, ROT0, "Exidy", "Fire One", GAME_NO_SOUND )
|
||||
GAME( 1979, starfir2, 0, starfire, starfire, starfire, ROT0, "Exidy", "Star Fire 2", GAME_NO_SOUND )
|
||||
GAME( 1979, starfire, 0, starfire, starfire, starfire, ROT0, "Exidy", "Star Fire (set 1)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
|
||||
GAME( 1979, starfira, starfire, starfire, starfire, starfire, ROT0, "Exidy", "Star Fire (set 2)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
|
||||
GAME( 1979, fireone, 0, starfire, fireone, fireone, ROT0, "Exidy", "Fire One", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
|
||||
GAME( 1979, starfir2, 0, starfire, starfire, starfire, ROT0, "Exidy", "Star Fire 2", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
|
||||
|
@ -10,22 +10,17 @@
|
||||
#define STARFIRE_VBSTART (0x100)
|
||||
|
||||
|
||||
/*----------- defined in drivers/starfire.c -----------*/
|
||||
/*----------- defined in video/starfire.c -----------*/
|
||||
|
||||
extern UINT8 *starfire_videoram;
|
||||
extern UINT8 *starfire_colorram;
|
||||
|
||||
|
||||
/*----------- defined in video/starfire.c -----------*/
|
||||
|
||||
VIDEO_UPDATE( starfire );
|
||||
VIDEO_START( starfire );
|
||||
void starfire_video_update(int scanline, int count);
|
||||
|
||||
WRITE8_HANDLER( starfire_videoram_w );
|
||||
READ8_HANDLER( starfire_videoram_r );
|
||||
WRITE8_HANDLER( starfire_colorram_w );
|
||||
READ8_HANDLER( starfire_colorram_r );
|
||||
WRITE8_HANDLER( starfire_vidctrl_w );
|
||||
WRITE8_HANDLER( starfire_vidctrl1_w );
|
||||
|
||||
|
@ -5,15 +5,19 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "driver.h"
|
||||
#include "deprecat.h"
|
||||
#include "includes/starfire.h"
|
||||
|
||||
|
||||
#define NUM_PENS (0x40)
|
||||
|
||||
|
||||
UINT8 *starfire_videoram;
|
||||
UINT8 *starfire_colorram;
|
||||
|
||||
/* local allocated storage */
|
||||
static UINT8 *scanline_dirty;
|
||||
|
||||
static UINT8 starfire_vidctrl;
|
||||
static UINT8 starfire_vidctrl1;
|
||||
static UINT8 starfire_color;
|
||||
static UINT16 starfire_colors[NUM_PENS];
|
||||
|
||||
|
||||
|
||||
@ -25,16 +29,11 @@ static UINT8 starfire_color;
|
||||
|
||||
VIDEO_START( starfire )
|
||||
{
|
||||
/* make a temporary bitmap */
|
||||
tmpbitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, machine->screen[0].format);
|
||||
|
||||
/* make a dirty array */
|
||||
scanline_dirty = auto_malloc(STARFIRE_VTOTAL);
|
||||
|
||||
/* reset videoram */
|
||||
memset(starfire_videoram, 0, 0x2000);
|
||||
memset(starfire_colorram, 0, 0x2000);
|
||||
memset(scanline_dirty, 1, 256);
|
||||
/* register for state saving */
|
||||
state_save_register_global(starfire_vidctrl);
|
||||
state_save_register_global(starfire_vidctrl1);
|
||||
state_save_register_global(starfire_color);
|
||||
state_save_register_global_array(starfire_colors);
|
||||
}
|
||||
|
||||
|
||||
@ -74,12 +73,17 @@ WRITE8_HANDLER( starfire_colorram_w )
|
||||
starfire_colorram[offset & ~0x100] = data;
|
||||
starfire_colorram[offset | 0x100] = data;
|
||||
|
||||
/* don't modify the palette unless the TRANS bit is set */
|
||||
starfire_color = data & 0x1f;
|
||||
if (!(starfire_vidctrl1 & 0x40))
|
||||
return;
|
||||
|
||||
palette_set_color_rgb(Machine, palette_index, pal3bit((data << 1) & 0x06) | ((offset >> 8) & 0x01), pal3bit(data >> 5), pal3bit(data >> 2));
|
||||
/* don't modify the palette unless the TRANS bit is set */
|
||||
if (starfire_vidctrl1 & 0x40)
|
||||
{
|
||||
video_screen_update_partial(0, video_screen_get_vpos(0));
|
||||
|
||||
starfire_colors[palette_index] = ((((data << 1) & 0x06) | ((offset >> 8) & 0x01)) << 6) |
|
||||
(((data >> 5) & 0x07) << 3) |
|
||||
((data >> 2) & 0x07);
|
||||
}
|
||||
}
|
||||
|
||||
/* handle writes to the rest of color RAM */
|
||||
@ -87,16 +91,10 @@ WRITE8_HANDLER( starfire_colorram_w )
|
||||
{
|
||||
/* set RAM based on CDRM */
|
||||
starfire_colorram[offset] = (starfire_vidctrl1 & 0x80) ? starfire_color : (data & 0x1f);
|
||||
scanline_dirty[offset & 0xff] = 1;
|
||||
starfire_color = data & 0x1f;
|
||||
}
|
||||
}
|
||||
|
||||
READ8_HANDLER( starfire_colorram_r )
|
||||
{
|
||||
return starfire_colorram[offset];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************
|
||||
@ -174,7 +172,6 @@ WRITE8_HANDLER( starfire_videoram_w )
|
||||
/* final output */
|
||||
starfire_videoram[offset1] = dalu >> 8;
|
||||
starfire_videoram[offset2] = dalu;
|
||||
scanline_dirty[offset1 & 0xff] = 1;
|
||||
|
||||
/* color output */
|
||||
if (!(offset & 0x2000) && !(starfire_vidctrl1 & 0x80))
|
||||
@ -220,58 +217,53 @@ READ8_HANDLER( starfire_videoram_r )
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* Periodic screen refresh callback
|
||||
* Standard screen refresh callback
|
||||
*
|
||||
*************************************/
|
||||
|
||||
void starfire_video_update(int scanline, int count)
|
||||
static void get_pens(pen_t *pens)
|
||||
{
|
||||
UINT8 *pix = &starfire_videoram[scanline];
|
||||
UINT8 *col = &starfire_colorram[scanline];
|
||||
offs_t offs;
|
||||
|
||||
for (offs = 0; offs < NUM_PENS; offs++)
|
||||
{
|
||||
UINT16 color = starfire_colors[offs];
|
||||
|
||||
pens[offs] = MAKE_RGB(pal3bit(color >> 6), pal3bit(color >> 3), pal3bit(color >> 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VIDEO_UPDATE( starfire )
|
||||
{
|
||||
pen_t pens[NUM_PENS];
|
||||
|
||||
UINT8 *pix = &starfire_videoram[cliprect->min_y - 32];
|
||||
UINT8 *col = &starfire_colorram[cliprect->min_y - 32];
|
||||
int x, y;
|
||||
|
||||
/* update any dirty scanlines in this range */
|
||||
get_pens(pens);
|
||||
|
||||
for (x = 0; x < 256; x += 8)
|
||||
{
|
||||
for (y = 0; y < count; y++)
|
||||
if ((scanline + y) < STARFIRE_VTOTAL && scanline_dirty[scanline + y])
|
||||
{
|
||||
int data = pix[y];
|
||||
int color = col[y];
|
||||
for (y = cliprect->min_y; y <= cliprect->max_y ; y++)
|
||||
{
|
||||
int data = pix[y];
|
||||
int color = col[y];
|
||||
|
||||
*BITMAP_ADDR16(tmpbitmap, scanline + y, x + 0) = color | ((data >> 2) & 0x20);
|
||||
*BITMAP_ADDR16(tmpbitmap, scanline + y, x + 1) = color | ((data >> 1) & 0x20);
|
||||
*BITMAP_ADDR16(tmpbitmap, scanline + y, x + 2) = color | ((data >> 0) & 0x20);
|
||||
*BITMAP_ADDR16(tmpbitmap, scanline + y, x + 3) = color | ((data << 1) & 0x20);
|
||||
*BITMAP_ADDR16(tmpbitmap, scanline + y, x + 4) = color | ((data << 2) & 0x20);
|
||||
*BITMAP_ADDR16(tmpbitmap, scanline + y, x + 5) = color | ((data << 3) & 0x20);
|
||||
*BITMAP_ADDR16(tmpbitmap, scanline + y, x + 6) = color | ((data << 4) & 0x20);
|
||||
*BITMAP_ADDR16(tmpbitmap, scanline + y, x + 7) = color | ((data << 5) & 0x20);
|
||||
}
|
||||
*BITMAP_ADDR32(bitmap, y, x + 0) = pens[color | ((data >> 2) & 0x20)];
|
||||
*BITMAP_ADDR32(bitmap, y, x + 1) = pens[color | ((data >> 1) & 0x20)];
|
||||
*BITMAP_ADDR32(bitmap, y, x + 2) = pens[color | ((data >> 0) & 0x20)];
|
||||
*BITMAP_ADDR32(bitmap, y, x + 3) = pens[color | ((data << 1) & 0x20)];
|
||||
*BITMAP_ADDR32(bitmap, y, x + 4) = pens[color | ((data << 2) & 0x20)];
|
||||
*BITMAP_ADDR32(bitmap, y, x + 5) = pens[color | ((data << 3) & 0x20)];
|
||||
*BITMAP_ADDR32(bitmap, y, x + 6) = pens[color | ((data << 4) & 0x20)];
|
||||
*BITMAP_ADDR32(bitmap, y, x + 7) = pens[color | ((data << 5) & 0x20)];
|
||||
}
|
||||
|
||||
pix += 256;
|
||||
col += 256;
|
||||
}
|
||||
|
||||
/* mark them not dirty anymore */
|
||||
for (y = 0; y < count; y++)
|
||||
if ((scanline + y) < STARFIRE_VTOTAL)
|
||||
scanline_dirty[scanline + y] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* Standard screen refresh callback
|
||||
*
|
||||
*************************************/
|
||||
|
||||
VIDEO_UPDATE( starfire )
|
||||
{
|
||||
/* copy the bitmap, remapping the colors */
|
||||
copybitmap_remap(bitmap, tmpbitmap, 0, 0, 0, 0, &machine->screen[0].visarea, TRANSPARENCY_NONE, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user