Further code cleanup.

Flipped Pooyan so it behaves more like Time Pilot.
Fixed Time Pilot sprite offset.
Changed tutankhm video rendering to be destination-based.
This commit is contained in:
Aaron Giles 2008-01-29 18:47:28 +00:00
parent b7c8c89e4e
commit dc7e9bba99
5 changed files with 282 additions and 154 deletions

View File

@ -20,12 +20,14 @@
#define MASTER_CLOCK XTAL_14_31818MHz
static READ8_HANDLER( timeplt_portB_r );
static WRITE8_HANDLER( timeplt_filter_w );
static UINT8 timeplt_last_irq_state;
static int timeplt_last_irq_state;
/*************************************
*
* Initialization
*
*************************************/
static SOUND_START( timeplt )
{
@ -34,6 +36,94 @@ static SOUND_START( timeplt )
}
/*************************************
*
* Sound timer
*
*************************************/
/* The timer clock which feeds the upper 4 bits of */
/* AY-3-8910 port A is based on the same clock */
/* feeding the sound CPU Z80. It is a divide by */
/* 5120, formed by a standard divide by 512, */
/* followed by a divide by 10 using a 4 bit */
/* bi-quinary count sequence. (See LS90 data sheet */
/* for an example). */
/* */
/* Bit 4 comes from the output of the divide by 1024 */
/* 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 */
/* Bit 5 comes from the QC output of the LS90 producing a sequence of */
/* 0, 0, 1, 1, 0, 0, 1, 1, 1, 0 */
/* Bit 6 comes from the QD output of the LS90 producing a sequence of */
/* 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 */
/* Bit 7 comes from the QA output of the LS90 producing a sequence of */
/* 0, 0, 0, 0, 0, 1, 1, 1, 1, 1 */
static READ8_HANDLER( timeplt_portB_r )
{
static const int timeplt_timer[10] =
{
0x00, 0x10, 0x20, 0x30, 0x40, 0x90, 0xa0, 0xb0, 0xa0, 0xd0
};
return timeplt_timer[(activecpu_gettotalcycles64() / 512) % 10];
}
/*************************************
*
* Filter controls
*
*************************************/
static void filter_w(int chip, int channel, int data)
{
int C = 0;
if (data & 1) C += 220000; /* 220000pF = 0.220uF */
if (data & 2) C += 47000; /* 47000pF = 0.047uF */
filter_rc_set_RC(3*chip + channel,FLT_RC_LOWPASS, 1000,5100,0,CAP_P(C));
}
static WRITE8_HANDLER( timeplt_filter_w )
{
filter_w(0, 0, (offset >> 6) & 3);
filter_w(0, 1, (offset >> 8) & 3);
filter_w(0, 2, (offset >> 10) & 3);
filter_w(1, 0, (offset >> 0) & 3);
filter_w(1, 1, (offset >> 2) & 3);
filter_w(1, 2, (offset >> 4) & 3);
}
/*************************************
*
* External interfaces
*
*************************************/
WRITE8_HANDLER( timeplt_sh_irqtrigger_w )
{
if (timeplt_last_irq_state == 0 && data)
{
/* setting bit 0 low then high triggers IRQ on the sound CPU */
cpunum_set_input_line_and_vector(Machine, 1,0,HOLD_LINE,0xff);
}
timeplt_last_irq_state = data;
}
/*************************************
*
* Memory maps
*
*************************************/
static ADDRESS_MAP_START( timeplt_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x2fff) AM_ROM
AM_RANGE(0x3000, 0x33ff) AM_MIRROR(0x0c00) AM_RAM
@ -56,6 +146,13 @@ static ADDRESS_MAP_START( locomotn_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_END
/*************************************
*
* Sound chip interfaces
*
*************************************/
static const struct AY8910interface timeplt_ay8910_interface =
{
soundlatch_r,
@ -63,66 +160,12 @@ static const struct AY8910interface timeplt_ay8910_interface =
};
/* The timer clock which feeds the upper 4 bits of */
/* AY-3-8910 port A is based on the same clock */
/* feeding the sound CPU Z80. It is a divide by */
/* 5120, formed by a standard divide by 512, */
/* followed by a divide by 10 using a 4 bit */
/* bi-quinary count sequence. (See LS90 data sheet */
/* for an example). */
/* */
/* Bit 4 comes from the output of the divide by 1024 */
/* 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 */
/* Bit 5 comes from the QC output of the LS90 producing a sequence of */
/* 0, 0, 1, 1, 0, 0, 1, 1, 1, 0 */
/* Bit 6 comes from the QD output of the LS90 producing a sequence of */
/* 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 */
/* Bit 7 comes from the QA output of the LS90 producing a sequence of */
/* 0, 0, 0, 0, 0, 1, 1, 1, 1, 1 */
static const int timeplt_timer[10] =
{
0x00, 0x10, 0x20, 0x30, 0x40, 0x90, 0xa0, 0xb0, 0xa0, 0xd0
};
static READ8_HANDLER( timeplt_portB_r )
{
return timeplt_timer[(activecpu_gettotalcycles64() / 512) % 10];
}
static void filter_w(int chip, int channel, int data)
{
int C = 0;
if (data & 1) C += 220000; /* 220000pF = 0.220uF */
if (data & 2) C += 47000; /* 47000pF = 0.047uF */
filter_rc_set_RC(3*chip + channel,FLT_RC_LOWPASS, 1000,5100,0,CAP_P(C));
}
static WRITE8_HANDLER( timeplt_filter_w )
{
filter_w(0, 0, (offset >> 6) & 3);
filter_w(0, 1, (offset >> 8) & 3);
filter_w(0, 2, (offset >> 10) & 3);
filter_w(1, 0, (offset >> 0) & 3);
filter_w(1, 1, (offset >> 2) & 3);
filter_w(1, 2, (offset >> 4) & 3);
}
WRITE8_HANDLER( timeplt_sh_irqtrigger_w )
{
if (timeplt_last_irq_state == 0 && data)
{
/* setting bit 0 low then high triggers IRQ on the sound CPU */
cpunum_set_input_line_and_vector(Machine, 1,0,HOLD_LINE,0xff);
}
timeplt_last_irq_state = data;
}
/*************************************
*
* Machine drivers
*
*************************************/
MACHINE_DRIVER_START( timeplt_sound )

View File

@ -329,6 +329,6 @@ ROM_END
*
*************************************/
GAME( 1982, pooyan, 0, pooyan, pooyan, 0, ROT270, "Konami", "Pooyan", GAME_SUPPORTS_SAVE )
GAME( 1982, pooyans, pooyan, pooyan, pooyan, 0, ROT270, "[Konami] (Stern license)", "Pooyan (Stern)", GAME_SUPPORTS_SAVE )
GAME( 1982, pootan, pooyan, pooyan, pooyan, 0, ROT270, "bootleg", "Pootan", GAME_SUPPORTS_SAVE )
GAME( 1982, pooyan, 0, pooyan, pooyan, 0, ROT90, "Konami", "Pooyan", GAME_SUPPORTS_SAVE )
GAME( 1982, pooyans, pooyan, pooyan, pooyan, 0, ROT90, "[Konami] (Stern license)", "Pooyan (Stern)", GAME_SUPPORTS_SAVE )
GAME( 1982, pootan, pooyan, pooyan, pooyan, 0, ROT90, "bootleg", "Pootan", GAME_SUPPORTS_SAVE )

View File

@ -29,6 +29,7 @@ static tilemap *bg_tilemap;
bit 0 -- 1 kohm resistor -- RED
***************************************************************************/
PALETTE_INIT( pooyan )
{
rgb_t palette[32];
@ -69,42 +70,71 @@ PALETTE_INIT( pooyan )
palette_set_color(machine, i, palette[(*color_prom++ & 0x0f) + 0x10]);
}
/*************************************
*
* Tilemap info callback
*
*************************************/
static TILE_GET_INFO( get_bg_tile_info )
{
int attr = colorram[tile_index];
int code = videoram[tile_index];
int color = attr & 0x0f;
int flags = TILE_FLIPYX(attr >> 6);
SET_TILE_INFO(0, code, color, flags);
}
/*************************************
*
* Video startup
*
*************************************/
VIDEO_START( pooyan )
{
bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows, TILEMAP_TYPE_PEN, 8,8, 32,32);
}
/*************************************
*
* Memory write handlers
*
*************************************/
WRITE8_HANDLER( pooyan_videoram_w )
{
videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
}
WRITE8_HANDLER( pooyan_colorram_w )
{
colorram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
}
WRITE8_HANDLER( pooyan_flipscreen_w )
{
if (flip_screen != (data & 0x01))
{
flip_screen_set(data & 0x01);
tilemap_mark_all_tiles_dirty(ALL_TILEMAPS);
}
flip_screen_set(~data & 0x01);
}
static TILE_GET_INFO( get_bg_tile_info )
{
int attr = colorram[tile_index];
int code = videoram[tile_index] + 8 * (attr & 0x20);
int color = attr & 0x0f;
int flags = ((attr & 0x40) ? TILE_FLIPX : 0) | ((attr & 0x80) ? TILE_FLIPY : 0);
SET_TILE_INFO(0, code, color, flags);
}
VIDEO_START( pooyan )
{
bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows,
TILEMAP_TYPE_PEN, 8, 8, 32, 32);
}
/*************************************
*
* Sprite rendering
*
*************************************/
static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
{
@ -112,17 +142,33 @@ static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const re
for (offs = 0x10;offs < 0x40;offs += 2)
{
int sx = spriteram[offs];
int sy = 240 - spriteram_2[offs + 1];
int code = spriteram[offs + 1];
int color = spriteram_2[offs] & 0x0f;
int flipx = ~spriteram_2[offs] & 0x40;
int flipy = spriteram_2[offs] & 0x80;
/* Sprite flipscreen is supported by software */
drawgfx(bitmap,machine->gfx[1],
spriteram[offs + 1],
spriteram_2[offs] & 0x0f,
spriteram_2[offs] & 0x40, ~spriteram_2[offs] & 0x80,
240-spriteram[offs], spriteram_2[offs + 1],
code,
color,
flipx, flipy,
sx, sy,
cliprect,
TRANSPARENCY_PEN, 0);
}
}
/*************************************
*
* Video update
*
*************************************/
VIDEO_UPDATE( pooyan )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);

View File

@ -1,3 +1,11 @@
/***************************************************************************
Time Pilot
driver by Nicola Salmoria
***************************************************************************/
#include "driver.h"
#include "timeplt.h"
@ -32,6 +40,7 @@ static emu_timer *scanline_timer;
bit 0 -- not connected
***************************************************************************/
PALETTE_INIT( timeplt )
{
rgb_t palette[32];
@ -78,37 +87,39 @@ PALETTE_INIT( timeplt )
/***************************************************************************
Callbacks for the TileMap code
***************************************************************************/
/*************************************
*
* Tilemap info callback
*
*************************************/
static TILE_GET_INFO( get_tile_info )
{
UINT8 attr = colorram[tile_index];
int attr = colorram[tile_index];
int code = videoram[tile_index] + 8 * (attr & 0x20);
int color = attr & 0x1f;
int flags = TILE_FLIPYX(attr >> 6);
tileinfo->category = (attr & 0x10) >> 4;
SET_TILE_INFO(
0,
videoram[tile_index] + ((attr & 0x20) << 3),
attr & 0x1f,
TILE_FLIPYX(attr >> 6));
SET_TILE_INFO(0, code, color, flags);
}
/***************************************************************************
Start the video hardware emulation.
***************************************************************************/
/*************************************
*
* Per-scanline callback
*
*************************************/
static TIMER_CALLBACK( scanline_interrupt )
{
int scanline = param;
video_screen_update_partial(0, scanline - 1);
/* we need to use partial updates to handle multiplexed sprites */
video_screen_update_partial(0, scanline);
/* only need to hit on visible scanlines */
scanline++;
if (scanline > machine->screen[0].visarea.max_y)
scanline = machine->screen[0].visarea.min_y;
@ -116,21 +127,29 @@ static TIMER_CALLBACK( scanline_interrupt )
}
/*************************************
*
* Video startup
*
*************************************/
VIDEO_START( timeplt )
{
bg_tilemap = tilemap_create(get_tile_info,tilemap_scan_rows,TILEMAP_TYPE_PEN,8,8,32,32);
/* create a timer for scanline updates */
scanline_timer = timer_alloc(scanline_interrupt, NULL);
timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_never);
}
/***************************************************************************
Memory handlers
***************************************************************************/
/*************************************
*
* Memory write handlers
*
*************************************/
WRITE8_HANDLER( timeplt_videoram_w )
{
@ -138,17 +157,20 @@ WRITE8_HANDLER( timeplt_videoram_w )
tilemap_mark_tile_dirty(bg_tilemap,offset);
}
WRITE8_HANDLER( timeplt_colorram_w )
{
colorram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap,offset);
}
WRITE8_HANDLER( timeplt_flipscreen_w )
{
flip_screen_set(~data & 1);
}
READ8_HANDLER( timeplt_scanline_r )
{
return video_screen_get_vpos(0);
@ -156,30 +178,27 @@ READ8_HANDLER( timeplt_scanline_r )
/***************************************************************************
Display refresh
***************************************************************************/
/*************************************
*
* Sprite rendering
*
*************************************/
static void draw_sprites(running_machine *machine, mame_bitmap *bitmap,const rectangle *cliprect)
{
const gfx_element *gfx = machine->gfx[1];
int offs;
for (offs = 0x3e;offs >= 0x10;offs -= 2)
{
int code,color,sx,sy,flipx,flipy;
int sx = spriteram[offs];
int sy = 241 - spriteram_2[offs + 1];
sx = spriteram[offs];
sy = 240 - spriteram_2[offs + 1];
int code = spriteram[offs + 1];
int color = spriteram_2[offs] & 0x3f;
int flipx = ~spriteram_2[offs] & 0x40;
int flipy = spriteram_2[offs] & 0x80;
code = spriteram[offs + 1];
color = spriteram_2[offs] & 0x3f;
flipx = ~spriteram_2[offs] & 0x40;
flipy = spriteram_2[offs] & 0x80;
drawgfx(bitmap,gfx,
drawgfx(bitmap,machine->gfx[1],
code,
color,
flipx,flipy,
@ -188,6 +207,14 @@ static void draw_sprites(running_machine *machine, mame_bitmap *bitmap,const rec
}
}
/*************************************
*
* Video update
*
*************************************/
VIDEO_UPDATE( timeplt )
{
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);

View File

@ -22,6 +22,12 @@ static UINT8 tutankhm_flip_screen_y;
/*************************************
*
* Write handlers
*
*************************************/
WRITE8_HANDLER( tutankhm_flip_screen_x_w )
{
tutankhm_flip_screen_x = data & 0x01;
@ -34,6 +40,13 @@ WRITE8_HANDLER( tutankhm_flip_screen_y_w )
}
/*************************************
*
* Palette management
*
*************************************/
static void get_pens(pen_t *pens)
{
offs_t i;
@ -47,6 +60,13 @@ static void get_pens(pen_t *pens)
}
/*************************************
*
* Video startup
*
*************************************/
VIDEO_START( tutankhm )
{
state_save_register_global_array(junofrst_blitterdata);
@ -55,42 +75,34 @@ VIDEO_START( tutankhm )
}
/*************************************
*
* Video update
*
*************************************/
VIDEO_UPDATE( tutankhm )
{
int xorx = tutankhm_flip_screen_x ? 255 : 0;
int xory = tutankhm_flip_screen_y ? 255 : 0;
pen_t pens[NUM_PENS];
offs_t offs;
int x, y;
get_pens(pens);
for (offs = 0; offs < videoram_size; offs++)
for (y = cliprect->min_y; y <= cliprect->max_y; y++)
{
int i;
UINT8 data = videoram[offs];
UINT8 y = offs >> 7;
UINT8 x = offs << 1;
for (i = 0; i < 2; i++)
UINT32 *dst = BITMAP_ADDR32(bitmap, y, 0);
for (x = cliprect->min_x; x <= cliprect->max_x; x++)
{
UINT8 sy = y;
UINT8 sx = x;
pen_t pen = pens[data & 0x0f];
/* adjust for scrolling */
if (x < 192)
{
sy = sy - *tutankhm_scroll;
}
if (tutankhm_flip_screen_y) sy = 255 - sy;
if (tutankhm_flip_screen_x) sx = 255 - sx;
*BITMAP_ADDR32(bitmap, sy, sx) = pen;
x = x + 1;
data = data >> 4;
UINT8 effx = x ^ xorx;
UINT8 yscroll = (effx < 192) ? *tutankhm_scroll : 0;
UINT8 effy = (y ^ xory) + yscroll;
UINT8 vrambyte = videoram[effy * 128 + effx / 2];
UINT8 shifted = vrambyte >> (4 * (effx % 2));
dst[x] = pens[shifted & 0x0f];
}
}