📄 taito.c
字号:
I call the three planes with the conventional names "front", "middle" and
"back", because that's their default order, but they can be arranged,
together with the sprites, in any order. The priority is selected by
register 0xd300, which works as follow:
bits 0-3 go to A4-A7 of a 256x4 PROM
bit 4 selects D0/D1 or D2/D3 of the PROM
bit 5-7 n.c.
A0-A3 of the PROM is fed with a mask of the inactive planes
(i.e. all-zero) in the order sprites-front-middle-back
the 2-bit code which comes out from the PROM selects the plane
to display.
Here is a dump of the PROM; on the right is the resulting order
(s = sprites f = front m = middle b = back)
d300 pri d300 pri
00: 08 09 08 0A 00 05 00 0F 08 09 08 0A 00 05 00 0F | 00 sfmb 10 msfb
10: 08 09 08 0B 00 0D 00 0F 08 09 08 0A 00 05 00 0F | 01 sfbm 11 msbf
20: 08 0A 08 0A 04 05 00 0F 08 0A 08 0A 04 05 00 0F | 02 smfb 12 mfsb
30: 08 0A 08 0A 04 07 0C 0F 08 0A 08 0A 04 05 00 0F | 03 smbf 13 mfbs
40: 08 0B 08 0B 0C 0F 0C 0F 08 09 08 0A 00 05 00 0F | 04 sbfm 14 mbsf
50: 08 0B 08 0B 0C 0F 0C 0F 08 0A 08 0A 04 05 00 0F | 05 sbmf 15 mbfs
60: 0D 0D 0C 0E 0D 0D 0C 0F 01 05 00 0A 01 05 00 0F | 06 fsmb 16 bsfm
70: 0D 0D 0C 0F 0D 0D 0C 0F 01 09 00 0A 01 05 00 0F | 07 fsbm 17 bsmf
80: 0D 0D 0E 0E 0D 0D 0C 0F 05 05 02 0A 05 05 00 0F | 08 fmsb 18 bfsm
90: 0D 0D 0E 0E 0D 0D 0F 0F 05 05 0A 0A 05 05 00 0F | 09 fmbs 19 bfms
A0: 0D 0D 0F 0F 0D 0D 0F 0F 09 09 08 0A 01 05 00 0F | 0A fbsm 1A bmsf
B0: 0D 0D 0F 0F 0D 0D 0F 0F 09 09 0A 0A 05 05 00 0F | 0B fbms 1B bmfs
C0: 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F | 0C - 1C -
D0: 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F | 0D - 1D -
E0: 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F | 0E - 1E -
F0: 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F | 0F - 1F -
***************************************************************************/
static int draworder[32][4] =
{
{ 3,2,1,0 },{ 2,3,1,0 },{ 3,1,2,0 },{ 1,3,2,0 },{ 2,1,3,0 },{ 1,2,3,0 },
{ 3,2,0,1 },{ 2,3,0,1 },{ 3,0,2,1 },{ 0,3,2,1 },{ 2,0,3,1 },{ 0,2,3,1 },
{ 3,3,3,3 },{ 3,3,3,3 },{ 3,3,3,3 },{ 3,3,3,3 },
{ 3,1,0,2 },{ 1,3,0,2 },{ 3,0,1,2 },{ 0,3,1,2 },{ 1,0,3,2 },{ 0,1,3,2 },
{ 2,1,0,3 },{ 1,2,0,3 },{ 2,0,1,3 },{ 0,2,1,3 },{ 1,0,2,3 },{ 0,1,2,3 },
{ 3,3,3,3 },{ 3,3,3,3 },{ 3,3,3,3 },{ 3,3,3,3 },
};
static void drawsprites(struct osd_bitmap *bitmap)
{
/* Draw the sprites. Note that it is important to draw them exactly in this */
/* order, to have the correct priorities. */
if (taito_video_enable & 0x80)
{
int offs;
for (offs = spriteram_size - 4;offs >= 0;offs -= 4)
{
int sx,sy,flipx,flipy;
sx = ((spriteram[offs] + 13) & 0xff) - 14; /* ?? */
sy = 240 - spriteram[offs + 1];
flipx = spriteram[offs + 2] & 1;
flipy = spriteram[offs + 2] & 2;
if (flipscreen[0])
{
sx = 238 - sx;
flipx = !flipx;
}
if (flipscreen[1])
{
sy = 242 - sy;
flipy = !flipy;
}
drawgfx(bitmap,Machine->gfx[(spriteram[offs + 3] & 0x40) ? 3 : 1],
spriteram[offs + 3] & 0x3f,
2 * ((taito_colorbank[1] >> 4) & 0x03) + ((spriteram[offs + 2] >> 2) & 1),
flipx,flipy,
sx,sy,
&Machine->drv->visible_area,TRANSPARENCY_PEN,0);
}
}
}
static void drawplayfield1(struct osd_bitmap *bitmap)
{
if (taito_video_enable & 0x10)
{
int i,scrollx,scrolly[32];
scrollx = *taito_scrollx1;
if (flipscreen[0])
scrollx = (scrollx & 0xf8) + ((scrollx) & 7) + 3;
else
scrollx = -(scrollx & 0xf8) + ((scrollx) & 7) + 3;
if (flipscreen[1])
{
for (i = 0;i < 32;i++)
scrolly[31-i] = taito_colscrolly1[i] + *taito_scrolly1;
}
else
{
for (i = 0;i < 32;i++)
scrolly[i] = -taito_colscrolly1[i] - *taito_scrolly1;
}
copyscrollbitmap(bitmap,tmpbitmap,1,&scrollx,32,scrolly,&Machine->drv->visible_area,TRANSPARENCY_COLOR,0);
}
}
static void drawplayfield2(struct osd_bitmap *bitmap)
{
if (taito_video_enable & 0x20)
{
int i,scrollx,scrolly[32];
scrollx = *taito_scrollx2;
if (flipscreen[0])
scrollx = (scrollx & 0xf8) + ((scrollx+1) & 7) + 10;
else
scrollx = -(scrollx & 0xf8) + ((scrollx+1) & 7) + 10;
if (flipscreen[1])
{
for (i = 0;i < 32;i++)
scrolly[31-i] = taito_colscrolly2[i] + *taito_scrolly2;
}
else
{
for (i = 0;i < 32;i++)
scrolly[i] = -taito_colscrolly2[i] - *taito_scrolly2;
}
copyscrollbitmap(bitmap,tmpbitmap2,1,&scrollx,32,scrolly,&Machine->drv->visible_area,TRANSPARENCY_COLOR,0);
}
}
static void drawplayfield3(struct osd_bitmap *bitmap)
{
if (taito_video_enable & 0x40)
{
int i,scrollx,scrolly[32];
scrollx = *taito_scrollx3;
if (flipscreen[0])
scrollx = (scrollx & 0xf8) + ((scrollx-1) & 7) + 12;
else
scrollx = -(scrollx & 0xf8) + ((scrollx-1) & 7) + 12;
if (flipscreen[1])
{
for (i = 0;i < 32;i++)
scrolly[31-i] = taito_colscrolly3[i] + *taito_scrolly3;
}
else
{
for (i = 0;i < 32;i++)
scrolly[i] = -taito_colscrolly3[i] - *taito_scrolly3;
}
copyscrollbitmap(bitmap,tmpbitmap3,1,&scrollx,32,scrolly,&Machine->drv->visible_area,TRANSPARENCY_COLOR,0);
}
}
static void drawplane(int n,struct osd_bitmap *bitmap)
{
switch (n)
{
case 0:
drawsprites(bitmap);
break;
case 1:
drawplayfield1(bitmap);
break;
case 2:
drawplayfield2(bitmap);
break;
case 3:
drawplayfield3(bitmap);
break;
}
}
void taito_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
int offs,i;
/* decode modified characters */
for (offs = 0;offs < 256;offs++)
{
if (dirtycharacter1[offs] == 1)
{
decodechar(Machine->gfx[0],offs,taito_characterram,Machine->drv->gfxdecodeinfo[0].gfxlayout);
dirtycharacter1[offs] = 0;
}
if (dirtycharacter2[offs] == 1)
{
decodechar(Machine->gfx[2],offs,taito_characterram + 0x1800,Machine->drv->gfxdecodeinfo[2].gfxlayout);
dirtycharacter2[offs] = 0;
}
}
/* decode modified sprites */
for (offs = 0;offs < 64;offs++)
{
if (dirtysprite1[offs] == 1)
{
decodechar(Machine->gfx[1],offs,taito_characterram,Machine->drv->gfxdecodeinfo[1].gfxlayout);
dirtysprite1[offs] = 0;
}
if (dirtysprite2[offs] == 1)
{
decodechar(Machine->gfx[3],offs,taito_characterram + 0x1800,Machine->drv->gfxdecodeinfo[3].gfxlayout);
dirtysprite2[offs] = 0;
}
}
/* for every character in the Video RAM, check if it has been modified */
/* since last time and update it accordingly. */
for (offs = videoram_size - 1;offs >= 0;offs--)
{
if (dirtybuffer[offs])
{
int sx,sy;
dirtybuffer[offs] = 0;
sx = offs % 32;
sy = offs / 32;
if (flipscreen[0]) sx = 31 - sx;
if (flipscreen[1]) sy = 31 - sy;
drawgfx(tmpbitmap,Machine->gfx[taito_colorbank[0] & 0x08 ? 2 : 0],
videoram[offs],
(taito_colorbank[0] & 0x07) + 8, /* use transparent pen 0 */
flipscreen[0],flipscreen[1],
8*sx,8*sy,
0,TRANSPARENCY_NONE,0);
}
if (dirtybuffer2[offs])
{
int sx,sy;
dirtybuffer2[offs] = 0;
sx = offs % 32;
sy = offs / 32;
if (flipscreen[0]) sx = 31 - sx;
if (flipscreen[1]) sy = 31 - sy;
drawgfx(tmpbitmap2,Machine->gfx[taito_colorbank[0] & 0x80 ? 2 : 0],
taito_videoram2[offs],
((taito_colorbank[0] >> 4) & 0x07) + 8, /* use transparent pen 0 */
flipscreen[0],flipscreen[1],
8*sx,8*sy,
0,TRANSPARENCY_NONE,0);
}
if (dirtybuffer3[offs])
{
int sx,sy;
dirtybuffer3[offs] = 0;
sx = offs % 32;
sy = offs / 32;
if (flipscreen[0]) sx = 31 - sx;
if (flipscreen[1]) sy = 31 - sy;
drawgfx(tmpbitmap3,Machine->gfx[taito_colorbank[1] & 0x08 ? 2 : 0],
taito_videoram3[offs],
(taito_colorbank[1] & 0x07) + 8, /* use transparent pen 0 */
flipscreen[0],flipscreen[1],
8*sx,8*sy,
0,TRANSPARENCY_NONE,0);
}
}
/* first of all, fill the screen with the background color */
fillbitmap(bitmap,Machine->gfx[0]->colortable[8 * (taito_colorbank[1] & 0x07)],
&Machine->drv->visible_area);
for (i = 0;i < 4;i++)
drawplane(draworder[*taito_video_priority & 0x1f][i],bitmap);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -