mirror of
https://github.com/holub/mame
synced 2025-07-04 09:28:51 +03:00
Color table removal
This commit is contained in:
parent
e49ffe3289
commit
c35974fbdc
@ -12,12 +12,16 @@ Ikki (c) 1985 Sun Electronics
|
|||||||
#include "deprecat.h"
|
#include "deprecat.h"
|
||||||
#include "sound/sn76496.h"
|
#include "sound/sn76496.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern UINT8 *ikki_scroll;
|
||||||
|
|
||||||
PALETTE_INIT( ikki );
|
PALETTE_INIT( ikki );
|
||||||
|
VIDEO_START( ikki );
|
||||||
VIDEO_UPDATE( ikki );
|
VIDEO_UPDATE( ikki );
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
WRITE8_HANDLER( ikki_scroll_w );
|
|
||||||
WRITE8_HANDLER( ikki_scrn_ctrl_w );
|
WRITE8_HANDLER( ikki_scrn_ctrl_w );
|
||||||
|
|
||||||
static READ8_HANDLER( ikki_e000_r )
|
static READ8_HANDLER( ikki_e000_r )
|
||||||
@ -50,7 +54,7 @@ static ADDRESS_MAP_START( ikki_cpu1, ADDRESS_SPACE_PROGRAM, 8 )
|
|||||||
AM_RANGE(0xe005, 0xe005) AM_READ(input_port_3_r) /* player2 */
|
AM_RANGE(0xe005, 0xe005) AM_READ(input_port_3_r) /* player2 */
|
||||||
AM_RANGE(0xe008, 0xe008) AM_WRITE(ikki_scrn_ctrl_w)
|
AM_RANGE(0xe008, 0xe008) AM_WRITE(ikki_scrn_ctrl_w)
|
||||||
AM_RANGE(0xe009, 0xe009) AM_WRITE(ikki_coin_counters)
|
AM_RANGE(0xe009, 0xe009) AM_WRITE(ikki_coin_counters)
|
||||||
AM_RANGE(0xe00a, 0xe00b) AM_WRITE(ikki_scroll_w)
|
AM_RANGE(0xe00a, 0xe00b) AM_WRITE(MWA8_RAM) AM_BASE(&ikki_scroll)
|
||||||
ADDRESS_MAP_END
|
ADDRESS_MAP_END
|
||||||
|
|
||||||
static ADDRESS_MAP_START( ikki_cpu2, ADDRESS_SPACE_PROGRAM, 8 )
|
static ADDRESS_MAP_START( ikki_cpu2, ADDRESS_SPACE_PROGRAM, 8 )
|
||||||
@ -208,11 +212,10 @@ static MACHINE_DRIVER_START( ikki )
|
|||||||
MDRV_SCREEN_SIZE(32*8, 32*8)
|
MDRV_SCREEN_SIZE(32*8, 32*8)
|
||||||
MDRV_SCREEN_VISIBLE_AREA(1*8, 31*8-1, 2*8, 30*8-1)
|
MDRV_SCREEN_VISIBLE_AREA(1*8, 31*8-1, 2*8, 30*8-1)
|
||||||
MDRV_GFXDECODE(ikki)
|
MDRV_GFXDECODE(ikki)
|
||||||
MDRV_PALETTE_LENGTH(256+1)
|
MDRV_PALETTE_LENGTH(1024)
|
||||||
MDRV_COLORTABLE_LENGTH(1024)
|
|
||||||
|
|
||||||
MDRV_PALETTE_INIT(ikki)
|
MDRV_PALETTE_INIT(ikki)
|
||||||
MDRV_VIDEO_START(generic)
|
MDRV_VIDEO_START(ikki)
|
||||||
MDRV_VIDEO_UPDATE(ikki)
|
MDRV_VIDEO_UPDATE(ikki)
|
||||||
|
|
||||||
/* sound hardware */
|
/* sound hardware */
|
||||||
|
@ -10,41 +10,53 @@ Video hardware driver by Uki
|
|||||||
|
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
|
|
||||||
static UINT8 ikki_flipscreen, ikki_scroll[2];
|
UINT8 *ikki_scroll;
|
||||||
|
|
||||||
|
static mame_bitmap *sprite_bitmap;
|
||||||
|
static UINT8 ikki_flipscreen;
|
||||||
|
static int punch_through_pen;
|
||||||
|
|
||||||
PALETTE_INIT( ikki )
|
PALETTE_INIT( ikki )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i<256; i++)
|
/* allocate the colortable - extra pen for the punch through pen */
|
||||||
{
|
machine->colortable = colortable_alloc(machine, 0x101);
|
||||||
palette_set_color_rgb(machine,i,pal4bit(color_prom[0]),pal4bit(color_prom[256]),pal4bit(color_prom[2*256]));
|
|
||||||
|
|
||||||
color_prom++;
|
/* create a lookup table for the palette */
|
||||||
|
for (i = 0; i < 0x100; i++)
|
||||||
|
{
|
||||||
|
int r = pal4bit(color_prom[i + 0x000]);
|
||||||
|
int g = pal4bit(color_prom[i + 0x100]);
|
||||||
|
int b = pal4bit(color_prom[i + 0x200]);
|
||||||
|
|
||||||
|
colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 256th color is not drawn on screen */
|
|
||||||
/* this is used for special transparent function */
|
|
||||||
palette_set_color(machine,256,MAKE_RGB(0,0,1));
|
|
||||||
|
|
||||||
color_prom += 2*256;
|
|
||||||
|
|
||||||
/* color_prom now points to the beginning of the lookup table */
|
/* color_prom now points to the beginning of the lookup table */
|
||||||
|
color_prom += 0x300;
|
||||||
|
|
||||||
/* sprites lookup table */
|
/* sprites lookup table */
|
||||||
for (i=0; i<512; i++)
|
for (i = 0; i < 0x200; i++)
|
||||||
{
|
{
|
||||||
int d = 255-*(color_prom++);
|
UINT16 ctabentry = color_prom[i] ^ 0xff;
|
||||||
if ( ((i % 8) == 7) && (d == 0) )
|
|
||||||
*(colortable++) = 256; /* special transparent */
|
if (((i & 0x07) == 0x07) && (ctabentry == 0))
|
||||||
else
|
{
|
||||||
*(colortable++) = d; /* normal color */
|
/* punch through */
|
||||||
|
punch_through_pen = i;
|
||||||
|
ctabentry = 0x100;
|
||||||
|
}
|
||||||
|
|
||||||
|
colortable_entry_set_value(machine->colortable, i, ctabentry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bg lookup table */
|
/* bg lookup table */
|
||||||
for (i=0; i<512; i++)
|
for (i = 0x200; i < 0x400; i++)
|
||||||
*(colortable++) = *(color_prom++);
|
{
|
||||||
|
UINT8 ctabentry = color_prom[i];
|
||||||
|
colortable_entry_set_value(machine->colortable, i, ctabentry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WRITE8_HANDLER( ikki_scroll_w )
|
WRITE8_HANDLER( ikki_scroll_w )
|
||||||
@ -57,35 +69,91 @@ WRITE8_HANDLER( ikki_scrn_ctrl_w )
|
|||||||
ikki_flipscreen = (data >> 2) & 1;
|
ikki_flipscreen = (data >> 2) & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
|
||||||
|
{
|
||||||
|
int y;
|
||||||
|
offs_t offs;
|
||||||
|
|
||||||
|
fillbitmap(sprite_bitmap, punch_through_pen, cliprect);
|
||||||
|
|
||||||
|
for (offs = 0; offs < 0x800; offs += 4)
|
||||||
|
{
|
||||||
|
int code = (spriteram[offs + 2] & 0x80) | (spriteram[offs + 1] >> 1);
|
||||||
|
int color = spriteram[offs + 2] & 0x3f;
|
||||||
|
|
||||||
|
int x = spriteram[offs + 3];
|
||||||
|
y = spriteram[offs + 0];
|
||||||
|
|
||||||
|
if (ikki_flipscreen)
|
||||||
|
x = 240 - x;
|
||||||
|
else
|
||||||
|
y = 224 - y;
|
||||||
|
|
||||||
|
x = x & 0xff;
|
||||||
|
y = y & 0xff;
|
||||||
|
|
||||||
|
if (x > 248)
|
||||||
|
x = x - 256;
|
||||||
|
|
||||||
|
if (y > 240)
|
||||||
|
y = y - 256;
|
||||||
|
|
||||||
|
drawgfx(sprite_bitmap,machine->gfx[1],
|
||||||
|
code, color,
|
||||||
|
ikki_flipscreen,ikki_flipscreen,
|
||||||
|
x,y,
|
||||||
|
cliprect, TRANSPARENCY_PENS,
|
||||||
|
colortable_get_transpen_mask(machine->colortable, machine->gfx[1], color, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* copy the sprite bitmap into the main bitmap, skipping the transparent pixels */
|
||||||
|
for (y = cliprect->min_y; y <= cliprect->max_y; y++)
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
|
||||||
|
for (x = cliprect->min_x; x <= cliprect->max_x; x++)
|
||||||
|
{
|
||||||
|
UINT16 pen = *BITMAP_ADDR16(sprite_bitmap, y, x);
|
||||||
|
|
||||||
|
if (colortable_entry_get_value(machine->colortable, pen) != 0x100)
|
||||||
|
*BITMAP_ADDR16(bitmap, y, x) = pen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VIDEO_START( ikki )
|
||||||
|
{
|
||||||
|
sprite_bitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, machine->screen[0].format);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
VIDEO_UPDATE( ikki )
|
VIDEO_UPDATE( ikki )
|
||||||
{
|
{
|
||||||
|
offs_t offs;
|
||||||
int offs,chr,col,px,py,f,bank,d;
|
|
||||||
UINT8 *VIDEOATTR = memory_region( REGION_USER1 );
|
UINT8 *VIDEOATTR = memory_region( REGION_USER1 );
|
||||||
|
|
||||||
f = ikki_flipscreen;
|
|
||||||
|
|
||||||
/* draw bg layer */
|
/* draw bg layer */
|
||||||
|
|
||||||
for (offs=0; offs<(videoram_size/2); offs++)
|
for (offs=0; offs<(videoram_size/2); offs++)
|
||||||
{
|
{
|
||||||
int sx,sy;
|
int color, bank;
|
||||||
|
|
||||||
sx = offs / 32;
|
int sx = offs / 32;
|
||||||
sy = offs % 32;
|
int sy = offs % 32;
|
||||||
|
int y = sy*8;
|
||||||
|
int x = sx*8;
|
||||||
|
|
||||||
py = sy*8;
|
int d = VIDEOATTR[ sx ];
|
||||||
px = sx*8;
|
|
||||||
|
|
||||||
d = VIDEOATTR[ sx ];
|
|
||||||
|
|
||||||
switch (d)
|
switch (d)
|
||||||
{
|
{
|
||||||
case 0x02: /* scroll area */
|
case 0x02: /* scroll area */
|
||||||
px = sx*8 - ikki_scroll[1];
|
x = sx*8 - ikki_scroll[1];
|
||||||
if (px<0)
|
if (x<0)
|
||||||
px=px+8*22;
|
x=x+8*22;
|
||||||
py = (sy*8 + ~ikki_scroll[0]) & 0xff;
|
y = (sy*8 + ~ikki_scroll[0]) & 0xff;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x03: /* non-scroll area */
|
case 0x03: /* non-scroll area */
|
||||||
@ -104,95 +172,57 @@ VIDEO_UPDATE( ikki )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f != 0)
|
if (ikki_flipscreen)
|
||||||
{
|
{
|
||||||
px = 248-px;
|
x = 248-x;
|
||||||
py = 248-py;
|
y = 248-y;
|
||||||
}
|
}
|
||||||
|
|
||||||
col = videoram[offs*2];
|
color = videoram[offs*2];
|
||||||
bank = (col & 0xe0) << 3;
|
bank = (color & 0xe0) << 3;
|
||||||
col = ((col & 0x1f)<<0) | ((col & 0x80) >> 2);
|
color = ((color & 0x1f)<<0) | ((color & 0x80) >> 2);
|
||||||
|
|
||||||
drawgfx(bitmap,machine->gfx[0],
|
drawgfx(bitmap,machine->gfx[0],
|
||||||
videoram[offs*2+1] + bank,
|
videoram[offs*2+1] + bank,
|
||||||
col,
|
color,
|
||||||
f,f,
|
ikki_flipscreen,ikki_flipscreen,
|
||||||
px,py,
|
x,y,
|
||||||
cliprect,TRANSPARENCY_NONE,0);
|
cliprect,TRANSPARENCY_NONE,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw sprites */
|
draw_sprites(machine, bitmap, cliprect);
|
||||||
|
|
||||||
fillbitmap(tmpbitmap, machine->pens[256], 0);
|
|
||||||
|
|
||||||
/* c060 - c0ff */
|
|
||||||
for (offs=0x00; offs<0x800; offs +=4)
|
|
||||||
{
|
|
||||||
chr = spriteram[offs+1] >> 1 ;
|
|
||||||
col = spriteram[offs+2];
|
|
||||||
|
|
||||||
px = spriteram[offs+3];
|
|
||||||
py = spriteram[offs+0];
|
|
||||||
|
|
||||||
chr += (col & 0x80);
|
|
||||||
col = (col & 0x3f) >> 0 ;
|
|
||||||
|
|
||||||
if (f==0)
|
|
||||||
py = 224-py;
|
|
||||||
else
|
|
||||||
px = 240-px;
|
|
||||||
|
|
||||||
px = px & 0xff;
|
|
||||||
py = py & 0xff;
|
|
||||||
|
|
||||||
if (px>248)
|
|
||||||
px = px-256;
|
|
||||||
if (py>240)
|
|
||||||
py = py-256;
|
|
||||||
|
|
||||||
drawgfx(tmpbitmap,machine->gfx[1],
|
|
||||||
chr,
|
|
||||||
col,
|
|
||||||
f,f,
|
|
||||||
px,py,
|
|
||||||
cliprect,TRANSPARENCY_COLOR,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
copybitmap_trans(bitmap,tmpbitmap,0,0,0,0,cliprect,machine->pens[256]);
|
|
||||||
|
|
||||||
|
|
||||||
/* mask sprites */
|
/* mask sprites */
|
||||||
|
|
||||||
for (offs=0; offs<(videoram_size/2); offs++)
|
for (offs=0; offs<(videoram_size/2); offs++)
|
||||||
{
|
{
|
||||||
int sx,sy;
|
int sx = offs / 32;
|
||||||
|
int sy = offs % 32;
|
||||||
|
|
||||||
sx = offs / 32;
|
int d = VIDEOATTR[ sx ];
|
||||||
sy = offs % 32;
|
|
||||||
|
|
||||||
d = VIDEOATTR[ sx ];
|
|
||||||
|
|
||||||
if ( (d == 0) || (d == 0x0d) )
|
if ( (d == 0) || (d == 0x0d) )
|
||||||
{
|
{
|
||||||
py = sy*8;
|
int color, bank;
|
||||||
px = sx*8;
|
|
||||||
|
|
||||||
if (f != 0)
|
int y = sy*8;
|
||||||
|
int x = sx*8;
|
||||||
|
|
||||||
|
if (ikki_flipscreen)
|
||||||
{
|
{
|
||||||
px = 248-px;
|
x = 248-x;
|
||||||
py = 248-py;
|
y = 248-y;
|
||||||
}
|
}
|
||||||
|
|
||||||
col = videoram[offs*2];
|
color = videoram[offs*2];
|
||||||
bank = (col & 0xe0) << 3;
|
bank = (color & 0xe0) << 3;
|
||||||
col = ((col & 0x1f)<<0) | ((col & 0x80) >> 2);
|
color = ((color & 0x1f)<<0) | ((color & 0x80) >> 2);
|
||||||
|
|
||||||
drawgfx(bitmap,machine->gfx[0],
|
drawgfx(bitmap,machine->gfx[0],
|
||||||
videoram[offs*2+1] + bank,
|
videoram[offs*2+1] + bank,
|
||||||
col,
|
color,
|
||||||
f,f,
|
ikki_flipscreen,ikki_flipscreen,
|
||||||
px,py,
|
x,y,
|
||||||
cliprect,TRANSPARENCY_NONE,0);
|
cliprect,TRANSPARENCY_NONE,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user