This commit is contained in:
twinaphex 2014-03-09 04:09:51 +01:00
parent 6b5dcd8da2
commit cbba81f652
6 changed files with 2 additions and 1147 deletions

View File

@ -1530,7 +1530,7 @@
<ClCompile Include="..\..\..\vidhrdw\nyny_vidhrdw.c" />
<ClCompile Include="..\..\..\vidhrdw\offtwall_vidhrdw.c" />
<ClCompile Include="..\..\..\vidhrdw\ohmygod_vidhrdw.c" />
<ClCompile Include="..\..\..\vidhrdw\ojankohs.c" />
<ClCompile Include="..\..\..\vidhrdw\ojankohs_vidhrdw.c" />
<ClCompile Include="..\..\..\vidhrdw\omegaf_vidhrdw.c" />
<ClCompile Include="..\..\..\vidhrdw\oneshot_vidhrdw.c" />
<ClCompile Include="..\..\..\vidhrdw\orbit_vidhrdw.c" />

View File

@ -1,422 +0,0 @@
/* Macross Plus - Vidhrdw
see DRIVER file for notes */
#include "driver.h"
#include "vidhrdw/generic.h"
data32_t *macrossp_scra_videoram, *macrossp_scra_videoregs;
data32_t *macrossp_scrb_videoram, *macrossp_scrb_videoregs;
data32_t *macrossp_scrc_videoram, *macrossp_scrc_videoregs;
data32_t *macrossp_text_videoram, *macrossp_text_videoregs;
data32_t *macrossp_spriteram;
static data32_t *spriteram_old,*spriteram_old2;
static struct tilemap *macrossp_scra_tilemap, *macrossp_scrb_tilemap,*macrossp_scrc_tilemap, *macrossp_text_tilemap;
/*** SCR A LAYER ***/
WRITE32_HANDLER( macrossp_scra_videoram_w )
{
COMBINE_DATA(&macrossp_scra_videoram[offset]);
tilemap_mark_tile_dirty(macrossp_scra_tilemap,offset);
}
static void get_macrossp_scra_tile_info(int tile_index)
{
UINT32 attr,tileno,color;
attr = macrossp_scra_videoram[tile_index];
tileno = attr & 0x0000ffff;
switch (macrossp_scra_videoregs[0] & 0x00000c00)
{
case 0x00000800:
color = (attr & 0x000e0000) >> 15;
break;
case 0x00000400:
color = (attr & 0x003e0000) >> 17;
break;
default:
color = rand() & 7;
break;
}
SET_TILE_INFO(1,tileno,color,TILE_FLIPYX((attr & 0xc0000000) >> 30))
}
/*** SCR B LAYER ***/
WRITE32_HANDLER( macrossp_scrb_videoram_w )
{
COMBINE_DATA(&macrossp_scrb_videoram[offset]);
tilemap_mark_tile_dirty(macrossp_scrb_tilemap,offset);
}
static void get_macrossp_scrb_tile_info(int tile_index)
{
UINT32 attr,tileno,color;
attr = macrossp_scrb_videoram[tile_index];
tileno = attr & 0x0000ffff;
switch (macrossp_scrb_videoregs[0] & 0x00000c00)
{
case 0x00000800:
color = (attr & 0x000e0000) >> 15;
break;
case 0x00000400:
color = (attr & 0x003e0000) >> 17;
break;
default:
color = rand() & 7;
break;
}
SET_TILE_INFO(2,tileno,color,TILE_FLIPYX((attr & 0xc0000000) >> 30))
}
/*** SCR C LAYER ***/
WRITE32_HANDLER( macrossp_scrc_videoram_w )
{
COMBINE_DATA(&macrossp_scrc_videoram[offset]);
tilemap_mark_tile_dirty(macrossp_scrc_tilemap,offset);
}
static void get_macrossp_scrc_tile_info(int tile_index)
{
UINT32 attr,tileno,color;
attr = macrossp_scrc_videoram[tile_index];
tileno = attr & 0x0000ffff;
switch (macrossp_scrc_videoregs[0] & 0x00000c00)
{
case 0x00000800:
color = (attr & 0x000e0000) >> 15;
break;
case 0x00000400:
color = (attr & 0x003e0000) >> 17;
break;
default:
color = rand() & 7;
break;
}
SET_TILE_INFO(3,tileno,color,TILE_FLIPYX((attr & 0xc0000000) >> 30))
}
/*** TEXT LAYER ***/
WRITE32_HANDLER( macrossp_text_videoram_w )
{
COMBINE_DATA(&macrossp_text_videoram[offset]);
tilemap_mark_tile_dirty(macrossp_text_tilemap,offset);
}
static void get_macrossp_text_tile_info(int tile_index)
{
UINT32 tileno, colour;
tileno = macrossp_text_videoram[tile_index] & 0x0000ffff;
colour = (macrossp_text_videoram[tile_index] & 0x00fe0000) >> 17;
SET_TILE_INFO(4,tileno,colour,0)
}
/*** VIDEO START / UPDATE ***/
VIDEO_START(macrossp)
{
spriteram_old = auto_malloc(spriteram_size);
spriteram_old2 = auto_malloc(spriteram_size);
if (!spriteram_old || !spriteram_old2)
return 1;
memset(spriteram_old,0,spriteram_size);
memset(spriteram_old2,0,spriteram_size);
macrossp_text_tilemap = tilemap_create(get_macrossp_text_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,16,16,64,64);
macrossp_scra_tilemap = tilemap_create(get_macrossp_scra_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,16,16,64,64);
macrossp_scrb_tilemap = tilemap_create(get_macrossp_scrb_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,16,16,64,64);
macrossp_scrc_tilemap = tilemap_create(get_macrossp_scrc_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,16,16,64,64);
if (!macrossp_text_tilemap || !macrossp_scra_tilemap || !macrossp_scrb_tilemap || !macrossp_scrc_tilemap)
return 1;
tilemap_set_transparent_pen(macrossp_text_tilemap,0);
tilemap_set_transparent_pen(macrossp_scra_tilemap,0);
tilemap_set_transparent_pen(macrossp_scrb_tilemap,0);
tilemap_set_transparent_pen(macrossp_scrc_tilemap,0);
Machine->gfx[0]->color_granularity=64;
Machine->gfx[1]->color_granularity=64;
Machine->gfx[2]->color_granularity=64;
Machine->gfx[3]->color_granularity=64;
alpha_set_level(0x80); /* guess */
return 0;
}
static void macrossp_drawsprites( struct mame_bitmap *bitmap, const struct rectangle *cliprect, int priority )
{
const struct GfxElement *gfx = Machine->gfx[0];
// data32_t *source = macrossp_spriteram;
data32_t *source = spriteram_old2; /* buffers by two frames */
data32_t *finish = source + spriteram_size/4;
while( source<finish )
{
/*
--hh hhyy yyyy yyyy CCww wwxx xxxx xxxx
---- --zz zzzz zzzz ---- --ZZ ZZZZ ZZZZ
fFa- pp-- cccc c--- tttt tttt tttt tttt
*/
int wide = (source[0] & 0x00003c00) >> 10;
int high = (source[0] & 0x3c000000) >> 26;
int xpos = (source[0] & 0x000003ff) >> 0;
int ypos = (source[0] & 0x03ff0000) >> 16;
int xzoom = (source[1] & 0x000003ff) >> 0; /* 0x100 is zoom factor of 1.0 */
int yzoom = (source[1] & 0x03ff0000) >> 16;
int col;
int tileno = (source[2] & 0x0000ffff) >> 0;
int flipx = (source[2] & 0x40000000) >> 30;
int flipy = (source[2] & 0x80000000) >> 31;
int trans = (source[2] & 0x20000000)?TRANSPARENCY_ALPHA:TRANSPARENCY_PEN; /* alpha blending enable? */
int loopno = 0;
int xcnt,ycnt;
int xoffset,yoffset;
int pri = (source[2] & 0x0c000000) >> 26;
if (pri == priority)
{
switch (source[0] & 0x0000c000)
{
case 0x00008000:
col = (source[2] & 0x00380000) >> 17;
break;
case 0x00004000:
col = (source[2] & 0x00f80000) >> 19;
break;
default:
col = rand();
break;
}
if (xpos > 0x1ff) xpos -=0x400;
if (ypos > 0x1ff) ypos -=0x400;
if (!flipx) {
if (!flipy) { /* noxflip, noyflip */
yoffset = 0; /* I'm doing this so rounding errors are cumulative, still looks a touch crappy when multiple sprites used together */
for (ycnt = 0; ycnt <= high; ycnt++) {
xoffset = 0;
for (xcnt = 0; xcnt <= wide; xcnt++) {
drawgfxzoom(bitmap,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,cliprect,trans,0,xzoom*0x100,yzoom*0x100);
xoffset += ((xzoom*16 + (1<<7)) >> 8);
loopno++;
}
yoffset += ((yzoom*16 + (1<<7)) >> 8);
}
}else{ /* noxflip, flipy */
yoffset = ((high*yzoom*16) >> 8);
for (ycnt = high; ycnt >= 0; ycnt--) {
xoffset = 0;
for (xcnt = 0; xcnt <= wide; xcnt++) {
drawgfxzoom(bitmap,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,cliprect,trans,0,xzoom*0x100,yzoom*0x100);
xoffset += ((xzoom*16 + (1<<7)) >> 8);
loopno++;
}
yoffset -= ((yzoom*16 + (1<<7)) >> 8);
}
}
}else{
if (!flipy) { /* xflip, noyflip */
yoffset = 0;
for (ycnt = 0; ycnt <= high; ycnt++) {
xoffset = ((wide*xzoom*16) >> 8);
for (xcnt = wide; xcnt >= 0; xcnt--) {
drawgfxzoom(bitmap,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,cliprect,trans,0,xzoom*0x100,yzoom*0x100);
xoffset -= ((xzoom*16 + (1<<7)) >> 8);
loopno++;
}
yoffset += ((yzoom*16 + (1<<7)) >> 8);
}
}else{ /* xflip, yflip */
yoffset = ((high*yzoom*16) >> 8);
for (ycnt = high; ycnt >= 0; ycnt--) {
xoffset = ((wide*xzoom*16) >> 8);
for (xcnt = wide; xcnt >=0 ; xcnt--) {
drawgfxzoom(bitmap,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,cliprect,trans,0,xzoom*0x100,yzoom*0x100);
xoffset -= ((xzoom*16 + (1<<7)) >> 8);
loopno++;
}
yoffset -= ((yzoom*16 + (1<<7)) >> 8);
}
}
}
}
source += 3;
}
}
static void draw_layer(struct mame_bitmap *bitmap, const struct rectangle *cliprect, int layer)
{
struct tilemap *tm;
data32_t *vr;
switch (layer)
{
case 0:
default:
tm = macrossp_scra_tilemap;
vr = macrossp_scra_videoregs;
break;
case 1:
tm = macrossp_scrb_tilemap;
vr = macrossp_scrb_videoregs;
break;
case 2:
tm = macrossp_scrc_tilemap;
vr = macrossp_scrc_videoregs;
break;
}
if ((vr[2] & 0xf0000000) == 0xe0000000) /* zoom enable (guess, surely wrong) */
{
int startx,starty,inc;
startx = (vr[1] & 0x0000ffff) << 16;
starty = (vr[1] & 0xffff0000) >> 0;
inc = (vr[2] & 0x00ff0000) >> 6,
/* WRONG! */
/* scroll register contain position relative to the center of the screen, so adjust */
startx -= (368/2) * inc;
starty -= (240/2) * inc;
tilemap_draw_roz(bitmap,cliprect,tm,
startx,starty,inc,0,0,inc,
1, /* wraparound */
0,0);
}
else
{
tilemap_set_scrollx( tm, 0, ((vr[0] & 0x000003ff) >> 0 ) );
tilemap_set_scrolly( tm, 0, ((vr[0] & 0x03ff0000) >> 16) );
tilemap_draw(bitmap,cliprect,tm,0,0);
}
}
/* useful function to sort the three tile layers by priority order */
static void sortlayers(int *layer,int *pri)
{
#define SWAP(a,b) \
if (pri[a] >= pri[b]) \
{ \
int t; \
t = pri[a]; pri[a] = pri[b]; pri[b] = t; \
t = layer[a]; layer[a] = layer[b]; layer[b] = t; \
}
SWAP(0,1)
SWAP(0,2)
SWAP(1,2)
}
VIDEO_UPDATE(macrossp)
{
int layers[3],layerpri[3];
fillbitmap(bitmap,get_black_pen(),cliprect);
layers[0] = 0;
layerpri[0] = (macrossp_scra_videoregs[0] & 0x0000c000) >> 14;
layers[1] = 1;
layerpri[1] = (macrossp_scrb_videoregs[0] & 0x0000c000) >> 14;
layers[2] = 2;
layerpri[2] = (macrossp_scrc_videoregs[0] & 0x0000c000) >> 14;
sortlayers(layers, layerpri);
draw_layer(bitmap,cliprect,layers[0]);
macrossp_drawsprites(bitmap,cliprect,0);
draw_layer(bitmap,cliprect,layers[1]);
macrossp_drawsprites(bitmap,cliprect,1);
draw_layer(bitmap,cliprect,layers[2]);
macrossp_drawsprites(bitmap,cliprect,2);
macrossp_drawsprites(bitmap,cliprect,3);
tilemap_draw(bitmap,cliprect,macrossp_text_tilemap,0,0);
#if 0
usrintf_showmessage ("scra - %08x %08x %08x\nscrb - %08x %08x %08x\nscrc - %08x %08x %08x",
macrossp_scra_videoregs[0]&0xffff33ff, // yyyyxxxx
macrossp_scra_videoregs[1], // ??? more scrolling?
macrossp_scra_videoregs[2], // 08 - 0b
macrossp_scrb_videoregs[0]&0xffff33ff, // 00 - 03
macrossp_scrb_videoregs[1], // 04 - 07
macrossp_scrb_videoregs[2], // 08 - 0b
macrossp_scrc_videoregs[0]&0xffff33ff, // 00 - 03
macrossp_scrc_videoregs[1], // 04 - 07
macrossp_scrc_videoregs[2]);// 08 - 0b
#endif
}
VIDEO_EOF( macrossp )
{
/* looks like sprites are *two* frames ahead, like nmk16 */
memcpy(spriteram_old2,spriteram_old,spriteram_size);
memcpy(spriteram_old,macrossp_spriteram,spriteram_size);
}

View File

@ -1,204 +0,0 @@
#include "driver.h"
#include "vidhrdw/generic.h"
UINT8 *mnchmobl_vreg;
UINT8 *mnchmobl_status_vram;
UINT8 *mnchmobl_sprite_xpos;
UINT8 *mnchmobl_sprite_attr;
UINT8 *mnchmobl_sprite_tile;
static int mnchmobl_palette_bank;
static int flipscreen;
PALETTE_INIT( mnchmobl )
{
int i;
for (i = 0;i < Machine->drv->total_colors;i++)
{
int bit0,bit1,bit2,r,g,b;
/* red component */
bit0 = (color_prom[i] >> 0) & 0x01;
bit1 = (color_prom[i] >> 1) & 0x01;
bit2 = (color_prom[i] >> 2) & 0x01;
r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* green component */
bit0 = (color_prom[i] >> 3) & 0x01;
bit1 = (color_prom[i] >> 4) & 0x01;
bit2 = (color_prom[i] >> 5) & 0x01;
g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* blue component */
bit0 = (color_prom[i] >> 6) & 0x01;
bit1 = (color_prom[i] >> 7) & 0x01;
b = 0x4f * bit0 + 0xa8 * bit1;
palette_set_color(i,r,g,b);
}
}
WRITE_HANDLER( mnchmobl_palette_bank_w )
{
if( mnchmobl_palette_bank!=(data&0x3) )
{
memset( dirtybuffer, 1, 0x100 );
mnchmobl_palette_bank = data&0x3;
}
}
WRITE_HANDLER( mnchmobl_flipscreen_w )
{
if( flipscreen!=data )
{
memset( dirtybuffer, 1, 0x100 );
flipscreen = data;
}
}
READ_HANDLER( mnchmobl_sprite_xpos_r ){ return mnchmobl_sprite_xpos[offset]; }
WRITE_HANDLER( mnchmobl_sprite_xpos_w ){ mnchmobl_sprite_xpos[offset] = data; }
READ_HANDLER( mnchmobl_sprite_attr_r ){ return mnchmobl_sprite_attr[offset]; }
WRITE_HANDLER( mnchmobl_sprite_attr_w ){ mnchmobl_sprite_attr[offset] = data; }
READ_HANDLER( mnchmobl_sprite_tile_r ){ return mnchmobl_sprite_tile[offset]; }
WRITE_HANDLER( mnchmobl_sprite_tile_w ){ mnchmobl_sprite_tile[offset] = data; }
VIDEO_START( mnchmobl )
{
dirtybuffer = auto_malloc(0x100);
tmpbitmap = auto_bitmap_alloc(512,512);
if( dirtybuffer && tmpbitmap )
{
memset( dirtybuffer, 1, 0x100 );
return 0;
}
return 1;
}
READ_HANDLER( mnchmobl_videoram_r )
{
return videoram[offset];
}
WRITE_HANDLER( mnchmobl_videoram_w )
{
offset = offset&0xff; /* mirror the two banks? */
if( videoram[offset]!=data )
{
videoram[offset] = data;
dirtybuffer[offset] = 1;
}
}
static void draw_status( struct mame_bitmap *bitmap )
{
struct rectangle clip = Machine->visible_area;
const struct GfxElement *gfx = Machine->gfx[0];
int row;
for( row=0; row<4; row++ )
{
int sy,sx = (row&1)*8;
const unsigned char *source = mnchmobl_status_vram + (row&1)*32;
if( row<=1 )
{
source+=2*32;
sx+=256+32+16;
}
for( sy=0; sy<256; sy+=8 )
{
drawgfx( bitmap, gfx,
*source++,
0, /* color */
0,0, /* no flip */
sx,sy,
&clip,
TRANSPARENCY_NONE, 0 );
}
}
}
static void draw_background( struct mame_bitmap *bitmap )
{
/*
ROM B1.2C contains 256 tilemaps defining 4x4 configurations of
the tiles in ROM B2.2B
*/
unsigned char *tile_data = memory_region(REGION_GFX2);
const struct GfxElement *gfx = Machine->gfx[1];
int offs;
for( offs=0; offs<0x100; offs++ )
{
if( dirtybuffer[offs] )
{
int sy = (offs%16)*32;
int sx = (offs/16)*32;
int tile_number = videoram[offs];
int row,col;
dirtybuffer[offs] = 0;
for( row=0; row<4; row++ )
{
for( col=0; col<4; col++ )
{
drawgfx( tmpbitmap,gfx,
tile_data[col+tile_number*4+row*0x400],
mnchmobl_palette_bank,
0,0, /* flip */
sx+col*8, sy+row*8,
0, TRANSPARENCY_NONE, 0 );
}
}
}
}
{
int scrollx = -(mnchmobl_vreg[6]*2+(mnchmobl_vreg[7]>>7))-64-128-16;
int scrolly = 0;
copyscrollbitmap(bitmap,tmpbitmap,
1,&scrollx,1,&scrolly,
&Machine->visible_area,TRANSPARENCY_NONE,0);
}
}
static void draw_sprites( struct mame_bitmap *bitmap )
{
const struct rectangle *clip = &Machine->visible_area;
int scroll = mnchmobl_vreg[6];
int flags = mnchmobl_vreg[7]; /* XB?????? */
int xadjust = - 128-16 - ((flags&0x80)?1:0);
int bank = (flags&0x40)?1:0;
const struct GfxElement *gfx = Machine->gfx[2+bank];
int color_base = mnchmobl_palette_bank*4+3;
int i;
for( i=0; i<0x200; i++ )
{
int tile_number = mnchmobl_sprite_tile[i]; /* ETTTTTTT */
int attributes = mnchmobl_sprite_attr[i]; /* XYYYYYCC */
int sx = mnchmobl_sprite_xpos[i]; /* XXXXXXX? */
int sy = (i/0x40)*0x20; /* Y YY------ */
sy += (attributes>>2)&0x1f;
if( tile_number != 0xff && (attributes&0x80) )
{
sx = (sx>>1) | (tile_number&0x80);
sx = 2*((-32-scroll - sx)&0xff)+xadjust;
drawgfx( bitmap, gfx,
0x7f - (tile_number&0x7f),
color_base-(attributes&0x03),
0,0, /* no flip */
sx,sy,
clip, TRANSPARENCY_PEN, 7 );
}
}
}
VIDEO_UPDATE( mnchmobl )
{
draw_background( bitmap );
draw_sprites( bitmap );
draw_status( bitmap );
}

View File

@ -1,186 +0,0 @@
/***************************************************************************
vidhrdw.c
Functions to emulate the video hardware of the machine.
There are only a few differences between the video hardware of Mysterious
Stones and Mat Mania. The tile bank select bit is different and the sprite
selection seems to be different as well. Additionally, the palette is stored
differently. I'm also not sure that the 2nd tile page is really used in
Mysterious Stones.
***************************************************************************/
#include "driver.h"
#include "vidhrdw/generic.h"
UINT8 *mystston_videoram2;
static int mystston_fgcolor, mystston_bgpage;
static struct tilemap *fg_tilemap, *bg_tilemap;
/***************************************************************************
Convert the color PROMs into a more useable format.
Mysterious Stones has both palette RAM and a PROM. The PROM is used for
text.
***************************************************************************/
PALETTE_INIT( mystston )
{
int i;
for (i = 0; i < 32; i++)
{
int bit0, bit1, bit2, r, g, b;
// red component
bit0 = (*color_prom >> 0) & 0x01;
bit1 = (*color_prom >> 1) & 0x01;
bit2 = (*color_prom >> 2) & 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 = 0;
bit1 = (*color_prom >> 6) & 0x01;
bit2 = (*color_prom >> 7) & 0x01;
b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
palette_set_color(i + 24, r, g, b); // first 24 colors are from RAM
color_prom++;
}
}
WRITE_HANDLER( mystston_videoram_w )
{
if (videoram[offset] != data)
{
videoram[offset] = data;
tilemap_mark_tile_dirty(fg_tilemap, offset & 0x3ff);
}
}
WRITE_HANDLER( mystston_videoram2_w )
{
if (videoram[offset] != data)
{
mystston_videoram2[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset & 0x1ff);
}
}
WRITE_HANDLER( mystston_scroll_w )
{
tilemap_set_scrolly(bg_tilemap, 0, data);
}
WRITE_HANDLER( mystston_control_w )
{
// bits 0 and 1 are foreground text color
if (mystston_fgcolor != ((data & 0x01) << 1) + ((data & 0x02) >> 1))
{
mystston_fgcolor = ((data & 0x01) << 1) + ((data & 0x02) >> 1);
tilemap_mark_all_tiles_dirty(fg_tilemap);
}
// bit 2 is background page select
mystston_bgpage = (data & 0x04) ? 1:0;
// bits 4 and 5 are coin counters in flipped order
coin_counter_w(0, data & 0x20);
coin_counter_w(1, data & 0x10);
// bit 7 is screen flip
flip_screen_set((data & 0x80) ^ ((readinputport(3) & 0x20) ? 0x80:0));
}
static void get_bg_tile_info(int tile_index)
{
int code = mystston_videoram2[tile_index] + ((mystston_videoram2[tile_index + 0x200] & 0x01) << 8);
int flags = (tile_index & 0x10) ? TILE_FLIPY : 0;
SET_TILE_INFO(1, code, 0, flags)
}
static void get_fg_tile_info(int tile_index)
{
int code = videoram[tile_index] + ((videoram[tile_index + 0x400] & 0x07) << 8);
int color = mystston_fgcolor;
SET_TILE_INFO(0, code, color, 0)
}
VIDEO_START( mystston )
{
bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_cols_flip_x,
TILEMAP_OPAQUE, 16, 16, 16, 32);
if ( !bg_tilemap )
return 1;
fg_tilemap = tilemap_create(get_fg_tile_info, tilemap_scan_cols_flip_x,
TILEMAP_TRANSPARENT, 8, 8, 32, 32);
if ( !fg_tilemap )
return 1;
tilemap_set_transparent_pen(fg_tilemap, 0);
return 0;
}
static void draw_sprites( struct mame_bitmap *bitmap, const struct rectangle *cliprect )
{
int offs;
for (offs = 0; offs < spriteram_size; offs += 4)
{
int attr = spriteram[offs];
if (attr & 0x01)
{
int code = spriteram[offs + 1] + ((attr & 0x10) << 4);
int color = (attr & 0x08) >> 3;
int flipx = attr & 0x04;
int flipy = attr & 0x02;
int sx = 240 - spriteram[offs + 3];
int sy = (240 - spriteram[offs + 2]) & 0xff;
if (flip_screen)
{
sx = 240 - sx;
sy = 240 - sy;
flipx = !flipx;
flipy = !flipy;
}
drawgfx(bitmap,Machine->gfx[2], code, color, flipx, flipy,
sx, sy, cliprect, TRANSPARENCY_PEN, 0);
}
}
}
VIDEO_UPDATE( mystston )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
draw_sprites(bitmap, cliprect);
tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
}

View File

@ -1,333 +0,0 @@
/***************************************************************************
vidhrdw.c
Functions to emulate the video hardware of the machine.
***************************************************************************/
#include "driver.h"
#include "vidhrdw/generic.h"
unsigned char *route16_sharedram;
unsigned char *route16_videoram1;
unsigned char *route16_videoram2;
size_t route16_videoram_size;
int route16_hardware;
static struct mame_bitmap *tmpbitmap1;
static struct mame_bitmap *tmpbitmap2;
static int video_flip;
static int video_color_select_1;
static int video_color_select_2;
static int video_disable_1 = 0;
static int video_disable_2 = 0;
static int video_remap_1;
static int video_remap_2;
static const unsigned char *route16_color_prom;
/* Local functions */
static void modify_pen(int pen, int colorindex);
static void common_videoram_w(int offset,int data,
int coloroffset, struct mame_bitmap *bitmap);
PALETTE_INIT( route16 )
{
route16_color_prom = color_prom; /* we'll need this later */
}
/***************************************************************************
Start the video hardware emulation.
***************************************************************************/
VIDEO_START( route16 )
{
if ((tmpbitmap1 = auto_bitmap_alloc(Machine->drv->screen_width,Machine->drv->screen_height)) == 0)
return 1;
if ((tmpbitmap2 = auto_bitmap_alloc(Machine->drv->screen_width,Machine->drv->screen_height)) == 0)
return 1;
video_flip = 0;
video_color_select_1 = 0;
video_color_select_2 = 0;
video_disable_1 = 0;
video_disable_2 = 0;
video_remap_1 = 1;
video_remap_2 = 1;
return 0;
}
/***************************************************************************
route16_out0_w
***************************************************************************/
WRITE_HANDLER( route16_out0_w )
{
static int last_write = 0;
if (data == last_write) return;
video_disable_1 = ((data & 0x02) << 6) && route16_hardware;
video_color_select_1 = ((data & 0x1f) << 2);
/* Bit 5 is the coin counter. */
coin_counter_w(0, data & 0x20);
video_remap_1 = 1;
last_write = data;
}
/***************************************************************************
route16_out1_w
***************************************************************************/
WRITE_HANDLER( route16_out1_w )
{
static int last_write = 0;
if (data == last_write) return;
video_disable_2 = ((data & 0x02) << 6 ) && route16_hardware;
video_color_select_2 = ((data & 0x1f) << 2);
if (video_flip != ((data & 0x20) >> 5))
{
video_flip = (data & 0x20) >> 5;
}
video_remap_2 = 1;
last_write = data;
}
/***************************************************************************
Handle Stratovox's extra sound effects.
***************************************************************************/
WRITE_HANDLER( stratvox_sn76477_w )
{
/* get out for Route 16 */
if (route16_hardware) return;
/***************************************************************
* AY8910 output bits are connected to...
* 7 - direct: 5V * 30k/(100+30k) = 1.15V - via DAC??
* 6 - SN76477 mixer a
* 5 - SN76477 mixer b
* 4 - SN76477 mixer c
* 3 - SN76477 envelope 1
* 2 - SN76477 envelope 2
* 1 - SN76477 vco
* 0 - SN76477 enable
***************************************************************/
SN76477_mixer_w(0,(data >> 4) & 7);
SN76477_envelope_w(0,(data >> 2) & 3);
SN76477_vco_w(0,(data >> 1) & 1);
SN76477_enable_w(0,data & 1);
}
/***************************************************************************
route16_sharedram_r
***************************************************************************/
READ_HANDLER( route16_sharedram_r )
{
return route16_sharedram[offset];
}
/***************************************************************************
route16_sharedram_w
***************************************************************************/
WRITE_HANDLER( route16_sharedram_w )
{
route16_sharedram[offset] = data;
// 4313-4319 are used in Route 16 as triggers to wake the other CPU
if (offset >= 0x0313 && offset <= 0x0319 && data == 0xff && route16_hardware)
{
// Let the other CPU run
cpu_yield();
}
}
/***************************************************************************
guessing that the unconnected IN3 and OUT2 on the stratvox schematic
are hooked up for speakres and spacecho to somehow read the variable
resistors (eg a voltage ramp), using a write to OUT2 as a trigger
and then bits 0-2 of IN3 going low when each pot "matches". the VRx
values can be seen when IN0=0x55 and p1b1 is held during power on.
this would then be checking that the sounds are mixed correctly.
***************************************************************************/
static int speakres_vrx;
READ_HANDLER ( speakres_in3_r )
{
int bit2=4, bit1=2, bit0=1;
/* just using a counter, the constants are the number of reads
before going low, each read is 40 cycles apart. the constants
were chosen based on the startup tests and for vr0=vr2 */
speakres_vrx++;
if(speakres_vrx>0x300) bit0=0; /* VR0 100k ohm - speech */
if(speakres_vrx>0x200) bit1=0; /* VR1 50k ohm - main volume */
if(speakres_vrx>0x300) bit2=0; /* VR2 100k ohm - explosion */
return 0xf8|bit2|bit1|bit0;
}
WRITE_HANDLER ( speakres_out2_w )
{
speakres_vrx=0;
}
/***************************************************************************
route16_videoram1_r
***************************************************************************/
READ_HANDLER( route16_videoram1_r )
{
return route16_videoram1[offset];
}
/***************************************************************************
route16_videoram2_r
***************************************************************************/
READ_HANDLER( route16_videoram2_r )
{
return route16_videoram1[offset];
}
/***************************************************************************
route16_videoram1_w
***************************************************************************/
WRITE_HANDLER( route16_videoram1_w )
{
route16_videoram1[offset] = data;
common_videoram_w(offset, data, 0, tmpbitmap1);
}
/***************************************************************************
route16_videoram2_w
***************************************************************************/
WRITE_HANDLER( route16_videoram2_w )
{
route16_videoram2[offset] = data;
common_videoram_w(offset, data, 4, tmpbitmap2);
}
/***************************************************************************
common_videoram_w
***************************************************************************/
static void common_videoram_w(int offset,int data,
int coloroffset, struct mame_bitmap *bitmap)
{
int x, y, color1, color2, color3, color4;
x = ((offset & 0x3f) << 2);
y = (offset & 0xffc0) >> 6;
if (video_flip)
{
x = 255 - x;
y = 255 - y;
}
color4 = ((data & 0x80) >> 6) | ((data & 0x08) >> 3);
color3 = ((data & 0x40) >> 5) | ((data & 0x04) >> 2);
color2 = ((data & 0x20) >> 4) | ((data & 0x02) >> 1);
color1 = ((data & 0x10) >> 3) | ((data & 0x01) );
if (video_flip)
{
plot_pixel(bitmap, x , y, Machine->pens[color1 | coloroffset]);
plot_pixel(bitmap, x-1, y, Machine->pens[color2 | coloroffset]);
plot_pixel(bitmap, x-2, y, Machine->pens[color3 | coloroffset]);
plot_pixel(bitmap, x-3, y, Machine->pens[color4 | coloroffset]);
}
else
{
plot_pixel(bitmap, x , y, Machine->pens[color1 | coloroffset]);
plot_pixel(bitmap, x+1, y, Machine->pens[color2 | coloroffset]);
plot_pixel(bitmap, x+2, y, Machine->pens[color3 | coloroffset]);
plot_pixel(bitmap, x+3, y, Machine->pens[color4 | coloroffset]);
}
}
/***************************************************************************
Draw the game screen in the given mame_bitmap.
Do NOT call osd_update_display() from this function, it will be called by
the main emulation engine.
***************************************************************************/
VIDEO_UPDATE( route16 )
{
if (video_remap_1)
{
modify_pen(0, video_color_select_1 + 0);
modify_pen(1, video_color_select_1 + 1);
modify_pen(2, video_color_select_1 + 2);
modify_pen(3, video_color_select_1 + 3);
}
if (video_remap_2)
{
modify_pen(4, video_color_select_2 + 0);
modify_pen(5, video_color_select_2 + 1);
modify_pen(6, video_color_select_2 + 2);
modify_pen(7, video_color_select_2 + 3);
}
if (get_vh_global_attribute_changed() || video_remap_1 || video_remap_2)
{
int offs;
// redraw bitmaps
for (offs = 0; offs < route16_videoram_size; offs++)
{
route16_videoram1_w(offs, route16_videoram1[offs]);
route16_videoram2_w(offs, route16_videoram2[offs]);
}
}
video_remap_1 = 0;
video_remap_2 = 0;
if (!video_disable_2)
{
copybitmap(bitmap,tmpbitmap2,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
}
if (!video_disable_1)
{
if (video_disable_2)
copybitmap(bitmap,tmpbitmap1,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
else
copybitmap(bitmap,tmpbitmap1,0,0,0,0,&Machine->visible_area,TRANSPARENCY_COLOR,0);
}
}
/***************************************************************************
mofify_pen
***************************************************************************/
static void modify_pen(int pen, int colorindex)
{
int r,g,b,color;
color = route16_color_prom[colorindex];
r = ((color & 1) ? 0xff : 0x00);
g = ((color & 2) ? 0xff : 0x00);
b = ((color & 4) ? 0xff : 0x00);
palette_set_color(pen,r,g,b);
}

View File

@ -143,7 +143,7 @@ VIDEO_START( sega )
/* generate the sine/cosine lookup tables */
for (i = 0; i < 0x400; i++)
{
double angle = ((2. * PI) / (double)0x400) * (double)i;
double angle = ((2. * M_PI) / (double)0x400) * (double)i;
double temp;
temp = sin (angle);