A little more cleaning in the irem games.

This commit is contained in:
Aaron Giles 2008-02-01 15:42:55 +00:00
parent 7d30fb91df
commit b8997f5e04
7 changed files with 240 additions and 207 deletions

1
.gitattributes vendored
View file

@ -2207,6 +2207,7 @@ src/mame/includes/lwings.h svneol=native#text/plain
src/mame/includes/m107.h svneol=native#text/plain
src/mame/includes/m52.h svneol=native#text/plain
src/mame/includes/m57.h svneol=native#text/plain
src/mame/includes/m58.h svneol=native#text/plain
src/mame/includes/m62.h svneol=native#text/plain
src/mame/includes/m72.h svneol=native#text/plain
src/mame/includes/m92.h svneol=native#text/plain

View file

@ -84,7 +84,25 @@ extern VIDEO_UPDATE( gberet );
extern VIDEO_UPDATE( gberetb );
static int enable_NMI, enable_IRQ;
static UINT8 nmi_enable, irq_enable;
/* Interrupt Generators */
static INTERRUPT_GEN( gberet_interrupt )
{
if (cpu_getiloops() == 0)
{
if (irq_enable)
cpunum_set_input_line(machine, 0, 0, HOLD_LINE);
}
if (cpu_getiloops() % 2)
{
if (nmi_enable)
cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
}
}
/* Read/Write Handlers */
@ -98,8 +116,8 @@ static WRITE8_HANDLER( gberet_coin_counter_w )
static WRITE8_HANDLER( gberet_flipscreen_w )
{
enable_NMI = data & 0x01;
enable_IRQ = data & 0x04;
nmi_enable = data & 0x01;
irq_enable = data & 0x04;
flip_screen_set(data & 0x08);
}
@ -119,8 +137,8 @@ static WRITE8_HANDLER( mrgoemon_coin_counter_w )
static WRITE8_HANDLER( mrgoemon_flipscreen_w )
{
enable_NMI = data & 0x01;
enable_IRQ = data & 0x02;
nmi_enable = data & 0x01;
irq_enable = data & 0x02;
flip_screen_set(data & 0x08);
}
@ -528,23 +546,6 @@ static GFXDECODE_START( gberetb )
GFXDECODE_ENTRY( REGION_GFX2, 0, gberetb_spritelayout, 16*16, 16 )
GFXDECODE_END
/* Interrupt Generators */
static INTERRUPT_GEN( gberet_interrupt )
{
if (cpu_getiloops() == 0)
{
if (enable_IRQ)
cpunum_set_input_line(machine, 0, 0, HOLD_LINE);
}
if (cpu_getiloops() % 2)
{
if (enable_NMI)
cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
}
}
/* Machine Drivers */
static MACHINE_DRIVER_START( gberet )

View file

@ -1,32 +1,27 @@
/****************************************************************************
10 Yard Fight Driver.
L Taylor
J Clegg
Irem M58 hardware
Loosely based on the Kung Fu Master driver.
L Taylor
J Clegg
Loosely based on the Kung Fu Master driver.
****************************************************************************/
#include "driver.h"
#include "m58.h"
#include "audio/irem.h"
#define MASTER_CLOCK XTAL_18_432MHz
extern UINT8 *yard_scroll_x_low;
extern UINT8 *yard_scroll_x_high;
extern UINT8 *yard_scroll_y_low;
extern UINT8 *yard_score_panel_disabled;
extern WRITE8_HANDLER( yard_videoram_w );
extern WRITE8_HANDLER( yard_scroll_panel_w );
extern PALETTE_INIT( yard );
extern VIDEO_START( yard );
extern VIDEO_UPDATE( yard );
/* Read/Write Handlers */
/*************************************
*
* Outputs
*
*************************************/
static WRITE8_HANDLER( yard_flipscreen_w )
{
@ -36,7 +31,13 @@ static WRITE8_HANDLER( yard_flipscreen_w )
coin_counter_w(1, data & 0x20);
}
/* Memory Map */
/*************************************
*
* Memory maps
*
*************************************/
static ADDRESS_MAP_START( yard_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x5fff) AM_ROM
@ -55,7 +56,13 @@ static ADDRESS_MAP_START( yard_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xe000, 0xefff) AM_RAM
ADDRESS_MAP_END
/* Input Ports */
/*************************************
*
* Port definitions
*
*************************************/
static INPUT_PORTS_START( yard )
PORT_START_TAG("IN0")
@ -160,18 +167,13 @@ static INPUT_PORTS_START( vsyard )
PORT_DIPSETTING( 0x00, DEF_STR( Yes ) )
INPUT_PORTS_END
/* Graphics Layouts */
static const gfx_layout charlayout =
{
8, 8,
RGN_FRAC(1,3),
3,
{ RGN_FRAC(2,3), RGN_FRAC(1,3), RGN_FRAC(0,3) },
{ 0, 1, 2, 3, 4, 5, 6, 7 },
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
8*8
};
/*************************************
*
* Graphics layouts
*
*************************************/
static const gfx_layout spritelayout =
{
@ -179,22 +181,24 @@ static const gfx_layout spritelayout =
RGN_FRAC(1,3),
3,
{ RGN_FRAC(2,3), RGN_FRAC(1,3), RGN_FRAC(0,3) },
{ 0, 1, 2, 3, 4, 5, 6, 7,
16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7 },
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
{ STEP8(0,1), STEP8(16*8,1) },
{ STEP16(0,8) },
32*8
};
/* Graphics Decode Information */
static GFXDECODE_START( yard )
GFXDECODE_ENTRY( REGION_GFX1, 0, charlayout, 0, 32 )
GFXDECODE_ENTRY( REGION_GFX2, 0, spritelayout, 256, 32 )
GFXDECODE_ENTRY( REGION_GFX1, 0, gfx_8x8x3_planar, 0, 32 )
GFXDECODE_ENTRY( REGION_GFX2, 0, spritelayout, 512, 32 )
GFXDECODE_END
/* Machine Driver */
/*************************************
*
* Machine drivers
*
*************************************/
static MACHINE_DRIVER_START( yard )
@ -221,7 +225,13 @@ static MACHINE_DRIVER_START( yard )
MACHINE_DRIVER_END
/* ROMs */
/*************************************
*
* ROM definitions
*
*************************************/
ROM_START( 10yard )
ROM_REGION( 0x10000, REGION_CPU1, 0 )
ROM_LOAD( "yf-a-3p-b", 0x0000, 0x2000, CRC(2e205ec2) SHA1(fcfa08f45423b35f2c99d4e6b5474ab1b3a84fec) )
@ -358,7 +368,13 @@ ROM_START( vs10yarj )
ROM_LOAD( "yard.2m", 0x0420, 0x0100, CRC(45384397) SHA1(e4c662ee81aef63efd8b4a45f85c4a78dc2d419e) ) /* radar palette high 4 bits */
ROM_END
/* Game Drivers */
/*************************************
*
* Game drivers
*
*************************************/
GAME( 1983, 10yard, 0, yard, yard, 0, ROT0, "Irem", "10-Yard Fight (World)", 0 )
GAME( 1983, 10yardj, 10yard, yard, yard, 0, ROT0, "Irem", "10-Yard Fight (Japan)", 0 )

19
src/mame/includes/m58.h Normal file
View file

@ -0,0 +1,19 @@
/*************************************************************************
Irem M58 hardware
*************************************************************************/
/*----------- defined in video/m58.c -----------*/
extern UINT8 *yard_scroll_x_low;
extern UINT8 *yard_scroll_x_high;
extern UINT8 *yard_scroll_y_low;
extern UINT8 *yard_score_panel_disabled;
WRITE8_HANDLER( yard_videoram_w );
WRITE8_HANDLER( yard_scroll_panel_w );
PALETTE_INIT( yard );
VIDEO_START( yard );
VIDEO_UPDATE( yard );

View file

@ -27,66 +27,70 @@ static tilemap* bg_tilemap;
PALETTE_INIT( m52 )
{
const UINT8 *char_pal = color_prom + 0x000;
const UINT8 *back_pal = color_prom + 0x200;
const UINT8 *sprite_pal = color_prom + 0x220;
const UINT8 *sprite_table = color_prom + 0x240;
static const int resistances_3[3] = { 1000, 470, 220 };
static const int resistances_2[2] = { 470, 220 };
double weights_r[3], weights_g[3], weights_b[3];
double weights_r[3], weights_g[3], weights_b[3], scale;
int i;
machine->colortable = colortable_alloc(machine, 512+32+32);
/* compute palette information for characters/backgrounds */
compute_resistor_weights(0, 255, -1.0,
scale = compute_resistor_weights(0, 255, -1.0,
3, resistances_3, weights_r, 0, 0,
3, resistances_3, weights_g, 0, 0,
2, resistances_2, weights_b, 0, 0);
2, resistances_2, weights_b, 0, 0);
/* character palette */
for (i = 0;i < 512;i++)
for (i = 0; i < 512; i++)
{
UINT8 promval = color_prom[i];
UINT8 promval = char_pal[i];
int r = combine_3_weights(weights_r, BIT(promval,0), BIT(promval,1), BIT(promval,2));
int g = combine_3_weights(weights_g, BIT(promval,3), BIT(promval,4), BIT(promval,5));
int b = combine_2_weights(weights_b, BIT(promval,6), BIT(promval,7));
colortable_palette_set_color(machine->colortable,i,MAKE_RGB(r,g,b));
colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r,g,b));
}
/* background palette */
for (i = 0;i < 32;i++)
for (i = 0; i < 32; i++)
{
UINT8 promval = color_prom[512+i];
UINT8 promval = back_pal[i];
int r = combine_3_weights(weights_r, BIT(promval,0), BIT(promval,1), BIT(promval,2));
int g = combine_3_weights(weights_g, BIT(promval,3), BIT(promval,4), BIT(promval,5));
int b = combine_2_weights(weights_b, BIT(promval,6), BIT(promval,7));
colortable_palette_set_color(machine->colortable,i+512,MAKE_RGB(r,g,b));
colortable_palette_set_color(machine->colortable, 512+i, MAKE_RGB(r,g,b));
}
/* compute palette information for sprites */
compute_resistor_weights(0, 255, -1.0,
compute_resistor_weights(0, 255, scale,
2, resistances_2, weights_r, 470, 0,
3, resistances_3, weights_g, 470, 0,
3, resistances_3, weights_b, 470, 0);
/* sprite palette */
for (i = 0;i < 32;i++)
for (i = 0; i < 32; i++)
{
UINT8 promval = color_prom[512+32+i];
UINT8 promval = sprite_pal[i];
int r = combine_2_weights(weights_r, BIT(promval,6), BIT(promval,7));
int g = combine_3_weights(weights_g, BIT(promval,3), BIT(promval,4), BIT(promval,5));
int b = combine_3_weights(weights_b, BIT(promval,0), BIT(promval,1), BIT(promval,2));
colortable_palette_set_color(machine->colortable,i+512+32,MAKE_RGB(r,g,b));
colortable_palette_set_color(machine->colortable, 512+32+i, MAKE_RGB(r,g,b));
}
/* character lookup table */
for (i = 0;i < 512;i++)
colortable_entry_set_value(machine->colortable,i,i);
for (i = 0; i < 512; i++)
colortable_entry_set_value(machine->colortable, i, i);
/* sprite lookup table */
for (i = 0;i < 16*4;i++)
for (i = 0; i < 16*4; i++)
{
UINT8 promval = color_prom[512+32+32+((i & 3) | ((i & ~3) << 1))];
UINT8 promval = sprite_table[(i & 3) | ((i & ~3) << 1)];
colortable_entry_set_value(machine->colortable, 512+i, 512+32+promval);
}

View file

@ -349,24 +349,9 @@ static void create_palette_lookup(void)
palette_lookup = auto_malloc(256 * sizeof(*palette_lookup));
for (i = 0; i < 256; i++)
{
int bit0,bit1,bit2,r,g,b;
/* red component */
bit0 = (i >> 0) & 0x01;
bit1 = (i >> 1) & 0x01;
bit2 = (i >> 2) & 0x01;
r = combine_3_weights(weights_r, bit0, bit1, bit2);
/* green component */
bit0 = (i >> 3) & 0x01;
bit1 = (i >> 4) & 0x01;
bit2 = (i >> 5) & 0x01;
g = combine_3_weights(weights_g, bit0, bit1, bit2);
/* blue component */
bit0 = (i >> 6) & 0x01;
bit1 = (i >> 7) & 0x01;
b = combine_2_weights(weights_b, bit0, bit1);
int r = combine_3_weights(weights_r, BIT(i,0), BIT(i,1), BIT(i,2));
int g = combine_3_weights(weights_g, BIT(i,3), BIT(i,4), BIT(i,5));
int b = combine_2_weights(weights_b, BIT(i,6), BIT(i,7));
palette_lookup[i] = MAKE_RGB(r, g, b);
}

View file

@ -1,18 +1,13 @@
/***************************************************************************
video.c
10 Yard Fight
L Taylor
J Clegg
Functions to emulate the video hardware of the machine.
Irem M58 hardware
***************************************************************************/
#include "driver.h"
#include "deprecat.h"
#include "m58.h"
#include "video/resnet.h"
UINT8 *yard_scroll_x_low;
UINT8 *yard_scroll_x_high;
@ -23,136 +18,107 @@ static mame_bitmap *scroll_panel_bitmap;
static tilemap *bg_tilemap;
#define SCROLL_PANEL_WIDTH (14*4)
#define RADAR_PALETTE_BASE (256+256)
#define RADAR_PALETTE_BASE (256)
/***************************************************************************
Convert the color PROMs into a more useable format.
/*************************************
*
* Palette configuration
*
*************************************/
10 Yard Fight has two 256x4 character palette PROMs, one 32x8 sprite
palette PROM, one 256x4 sprite color lookup table PROM, and two 256x4
radar palette PROMs.
I don't know for sure how the palette PROMs are connected to the RGB
output, but it's probably something like this; note that RED and BLUE
are swapped wrt the usual configuration.
bit 7 -- 220 ohm resistor -- RED
-- 470 ohm resistor -- RED
-- 220 ohm resistor -- GREEN
-- 470 ohm resistor -- GREEN
-- 1 kohm resistor -- GREEN
-- 220 ohm resistor -- BLUE
-- 470 ohm resistor -- BLUE
bit 0 -- 1 kohm resistor -- BLUE
***************************************************************************/
PALETTE_INIT( yard )
{
const UINT8 *char_lopal = color_prom + 0x000;
const UINT8 *char_hipal = color_prom + 0x100;
const UINT8 *sprite_pal = color_prom + 0x200;
const UINT8 *sprite_table = color_prom + 0x220;
const UINT8 *radar_lopal = color_prom + 0x320;
const UINT8 *radar_hipal = color_prom + 0x420;
static const int resistances_3[3] = { 1000, 470, 220 };
static const int resistances_2[2] = { 470, 220 };
double weights_r[3], weights_g[3], weights_b[3], scale;
int i;
machine->colortable = colortable_alloc(machine, 256+16+256);
machine->colortable = colortable_alloc(machine, 256+256+16);
/* compute palette information for characters/radar */
scale = compute_resistor_weights(0, 255, -1.0,
2, resistances_2, weights_r, 0, 0,
3, resistances_3, weights_g, 0, 0,
3, resistances_3, weights_b, 0, 0);
/* character palette */
for (i = 0;i < 256;i++)
for (i = 0; i < 256; i++)
{
int bit0,bit1,bit2,r,g,b;
UINT8 promval = (char_lopal[i] & 0x0f) | (char_hipal[i] << 4);
int r = combine_2_weights(weights_r, BIT(promval,6), BIT(promval,7));
int g = combine_3_weights(weights_g, BIT(promval,3), BIT(promval,4), BIT(promval,5));
int b = combine_3_weights(weights_b, BIT(promval,0), BIT(promval,1), BIT(promval,2));
/* red component */
bit0 = 0;
bit1 = (color_prom[256] >> 2) & 0x01;
bit2 = (color_prom[256] >> 3) & 0x01;
r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* green component */
bit0 = (color_prom[0] >> 3) & 0x01;
bit1 = (color_prom[256] >> 0) & 0x01;
bit2 = (color_prom[256] >> 1) & 0x01;
g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* blue component */
bit0 = (color_prom[0] >> 0) & 0x01;
bit1 = (color_prom[0] >> 1) & 0x01;
bit2 = (color_prom[0] >> 2) & 0x01;
b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
colortable_palette_set_color(machine->colortable,i,MAKE_RGB(r,g,b));
colortable_entry_set_value(machine->colortable,i,i);
color_prom++;
colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r,g,b));
}
color_prom += 256;
/* color_prom now points to the beginning of the sprite palette */
/* sprite palette */
for (i = 0;i < 16;i++)
{
int bit0,bit1,bit2,r,g,b;
/* red component */
bit0 = 0;
bit1 = (*color_prom >> 6) & 0x01;
bit2 = (*color_prom >> 7) & 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;
g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* blue component */
bit0 = (*color_prom >> 0) & 0x01;
bit1 = (*color_prom >> 1) & 0x01;
bit2 = (*color_prom >> 2) & 0x01;
b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
colortable_palette_set_color(machine->colortable,256+i,MAKE_RGB(r,g,b));
color_prom++;
}
color_prom += 16;
/* color_prom now points to the beginning of the sprite lookup table */
/* sprite lookup table */
for (i = 0;i < 256;i++)
colortable_entry_set_value(machine->colortable,256+i,256+(*color_prom++ & 0x0f));
/* color_prom now points to the beginning of the radar palette */
/* radar palette */
for (i = 0;i < 256;i++)
for (i = 0; i < 256; i++)
{
int bit0,bit1,bit2,r,g,b;
UINT8 promval = (radar_lopal[i] & 0x0f) | (radar_hipal[i] << 4);
int r = combine_2_weights(weights_r, BIT(promval,6), BIT(promval,7));
int g = combine_3_weights(weights_g, BIT(promval,3), BIT(promval,4), BIT(promval,5));
int b = combine_3_weights(weights_b, BIT(promval,0), BIT(promval,1), BIT(promval,2));
/* red component */
bit0 = 0;
bit1 = (color_prom[256] >> 2) & 0x01;
bit2 = (color_prom[256] >> 3) & 0x01;
r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* green component */
bit0 = (color_prom[0] >> 3) & 0x01;
bit1 = (color_prom[256] >> 0) & 0x01;
bit2 = (color_prom[256] >> 1) & 0x01;
g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* blue component */
bit0 = (color_prom[0] >> 0) & 0x01;
bit1 = (color_prom[0] >> 1) & 0x01;
bit2 = (color_prom[0] >> 2) & 0x01;
b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
colortable_palette_set_color(machine->colortable, 256+i, MAKE_RGB(r,g,b));
}
colortable_palette_set_color(machine->colortable,256+16+i,MAKE_RGB(r,g,b));
colortable_entry_set_value(machine->colortable,256+256+i,256+16+i);
/* compute palette information for sprites */
scale = compute_resistor_weights(0, 255, scale,
2, resistances_2, weights_r, 470, 0,
3, resistances_3, weights_g, 470, 0,
3, resistances_3, weights_b, 470, 0);
color_prom++;
/* sprite palette */
for (i = 0; i < 16; i++)
{
UINT8 promval = sprite_pal[i];
int r = combine_2_weights(weights_r, BIT(promval,6), BIT(promval,7));
int g = combine_3_weights(weights_g, BIT(promval,3), BIT(promval,4), BIT(promval,5));
int b = combine_3_weights(weights_b, BIT(promval,0), BIT(promval,1), BIT(promval,2));
colortable_palette_set_color(machine->colortable, 256+256+i, MAKE_RGB(r,g,b));
}
/* character lookup table */
for (i = 0; i < 256; i++)
colortable_entry_set_value(machine->colortable, i, i);
/* radar lookup table */
for (i = 0; i < 256; i++)
colortable_entry_set_value(machine->colortable, 256+i, 256+i);
/* sprite lookup table */
for (i = 0; i < 256; i++)
{
UINT8 promval = sprite_table[i] & 0x0f;
colortable_entry_set_value(machine->colortable, 256+256+i, 256+256+promval);
}
}
/*************************************
*
* Video RAM access
*
*************************************/
WRITE8_HANDLER( yard_videoram_w )
{
videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset / 2);
}
WRITE8_HANDLER( yard_scroll_panel_w )
{
int sx,sy,i;
@ -175,6 +141,14 @@ WRITE8_HANDLER( yard_scroll_panel_w )
}
}
/*************************************
*
* Tilemap info callback
*
*************************************/
static TILE_GET_INFO( yard_get_bg_tile_info )
{
int offs = tile_index * 2;
@ -186,6 +160,7 @@ static TILE_GET_INFO( yard_get_bg_tile_info )
SET_TILE_INFO(0, code, color, flags);
}
static UINT32 yard_tilemap_scan_rows( UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows )
{
/* logical (col,row) -> memory offset */
@ -195,6 +170,14 @@ static UINT32 yard_tilemap_scan_rows( UINT32 col, UINT32 row, UINT32 num_cols, U
return row*32 + col;
}
/*************************************
*
* Video startup
*
*************************************/
VIDEO_START( yard )
{
bg_tilemap = tilemap_create(yard_get_bg_tile_info, yard_tilemap_scan_rows, TILEMAP_TYPE_PEN, 8, 8, 64, 32);
@ -204,7 +187,15 @@ VIDEO_START( yard )
scroll_panel_bitmap = auto_bitmap_alloc(SCROLL_PANEL_WIDTH, machine->screen[0].height, machine->screen[0].format);
}
#define DRAW_SPRITE(code, sy) drawgfx(bitmap, machine->gfx[1], code, color, flipx, flipy, sx, sy, cliprect, TRANSPARENCY_PENS, colortable_get_transpen_mask(machine->colortable, machine->gfx[1], color, 256));
/*************************************
*
* Sprite rendering
*
*************************************/
#define DRAW_SPRITE(code, sy) drawgfx(bitmap, machine->gfx[1], code, color, flipx, flipy, sx, sy, cliprect, TRANSPARENCY_PENS, colortable_get_transpen_mask(machine->colortable, machine->gfx[1], color, 512));
static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect )
{
@ -251,6 +242,14 @@ static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const re
}
}
/*************************************
*
* Radar panel rendering
*
*************************************/
static void draw_panel( running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect )
{
if (! *yard_score_panel_disabled)
@ -277,6 +276,14 @@ static void draw_panel( running_machine *machine, mame_bitmap *bitmap, const rec
}
}
/*************************************
*
* Video update
*
*************************************/
VIDEO_UPDATE( yard )
{
tilemap_set_scrollx(bg_tilemap, 0, (*yard_scroll_x_high * 0x100) + *yard_scroll_x_low);