Add Bac06 tilemap device. Hook it up to Mad Motor and Act Fancer

This commit is contained in:
iq_132 2018-01-27 16:08:09 +00:00
parent d43334f533
commit 996b7a082c
5 changed files with 160 additions and 299 deletions

View File

@ -113,7 +113,7 @@ depobj = burn.o burn_gun.o burn_led.o burn_shift.o burn_memory.o burn_pal.o bur
\
cps3run.o cps3snd.o \
\
deco16ic.o deco146.o \
deco16ic.o deco146.o decobac06.o \
\
gal_gfx.o gal_run.o gal_sound.o gal_stars.o \
\

View File

@ -7,6 +7,7 @@
#include "burn_ym2203.h"
#include "burn_ym3812.h"
#include "msm6295.h"
#include "decobac06.h"
static UINT8 *AllMem = NULL;
static UINT8 *AllRam = NULL;
@ -218,6 +219,7 @@ static inline void palette_update(INT32 offset)
void actfan_main_write(UINT32 address, UINT8 data)
{
if ((address & 0xffffe0) == 0x060000) {
DrvPfCtrl[0][address & 0x1f] = data;
return;
}
@ -432,7 +434,7 @@ static INT32 MemIndex()
Drv6502ROM = Next; Next += 0x010000;
DrvGfxROM0 = Next; Next += 0x040000;
DrvGfxROM1 = Next; Next += 0x0c0000;
DrvGfxROM1 = Next; Next += 0x100000;
DrvGfxROM2 = Next; Next += 0x080000;
MSM6295ROM = Next; Next += 0x040000;
@ -669,109 +671,6 @@ static INT32 DrvExit()
return 0;
}
static void draw_pf1_layer()
{
const INT32 config[4][4][2] = {
{ { 64, 16 }, { 32, 32 }, { 16, 64 }, { 32, 32 } }, // type 0
{ { 128, 16 }, { 64, 32 }, { 32, 64 }, { 64, 32 } }, // type 1
{ { 256, 16 }, { 128, 32 }, { 64, 64 }, { 128, 32 } }, // type 2
};
INT32 type = gfx_config[3];
INT32 wide = DrvPfCtrl[0][6] & 3;
INT32 width = config[type][wide][0];
INT32 height = config[type][wide][1];
INT32 scrollx = (DrvPfCtrl[0][0x10] + (DrvPfCtrl[0][0x11] << 8)) & ((width * 16) - 1);
INT32 scrolly = (DrvPfCtrl[0][0x12] + (DrvPfCtrl[0][0x13] << 8)) & ((height * 16) - 1);
INT32 enable_rowscroll = DrvPfCtrl[0][0] & 0x04;
if (enable_rowscroll == 0)
{
for (INT32 offs = 0; offs < width * height; offs++)
{
INT32 sx = (offs % width);
INT32 sy = (offs / width) % height;
INT32 ofst = (sx & 0x0f) + (sy * 16) + ((sx & 0x1f0) << (4+wide));
sx = (sx * 16) - scrollx;
if (sx < -15) sx += width*16;
sy = (sy * 16) - (scrolly + 8);
if (sy < -15) sy += height*16;
if (sy >= nScreenHeight || sx >= nScreenWidth) continue;
INT32 code = DrvPf1RAM[ofst * 2 + 0] | (DrvPf1RAM[ofst * 2 + 1] << 8);
if (sx >= 0 && sx <= (nScreenWidth - 16) && sy >= 0 && sy <= (nScreenHeight - 16)) {
Render16x16Tile(pTransDraw, code & 0xfff, sx, sy, code >> 12, 4, gfx_config[2], DrvGfxROM2);
} else {
Render16x16Tile_Clip(pTransDraw, code & 0xfff, sx, sy, code >> 12, 4, gfx_config[2], DrvGfxROM2);
}
}
} else {
for (INT32 y = 0; y < nScreenHeight; y++)
{
UINT16 *dst = pTransDraw + y * nScreenWidth;
INT32 sy = (y + scrolly + 8) & ((height * 16) - 1);
INT32 scrx = ((sy & 0x1ff) >> (DrvPfCtrl[0][0x17] & 0x0f)) + (0x400/2);
scrx = (scrollx + (DrvPf1Scr[(scrx * 2)+0] << 0) + (DrvPf1Scr[(scrx * 2)+1] << 8)) & ((width * 16) - 1);
for (INT32 x = 0; x < nScreenWidth + 16; x+=16)
{
INT32 sx = (scrx + x) & ((width * 16) - 1);
INT32 ofst = ((sx / 16) & 0x0f) + (sy & 0x3f0) + (((sx / 16) & 0x1f0) << (4 + wide));
UINT16 code = DrvPf1RAM[ofst * 2 + 0] | (DrvPf1RAM[ofst * 2 + 1] << 8);
{
UINT8 *gfx = DrvGfxROM2 + ((code & 0x0fff) * 0x100) + ((sy & 0x0f) * 16);
INT32 color = ((code >> 12) * 16) + gfx_config[2];
INT32 xxx = x - (scrx & 0x0f);
if (xxx >= 0 && xxx <= (nScreenWidth - 16)) {
for (INT32 xx = 0; xx < 16; xx++, xxx++) {
dst[xxx] = gfx[xx] + color;
}
} else {
for (INT32 xx = 0; xx < 16; xx++, xxx++) {
if (xxx >= 0 && xxx < nScreenWidth) {
dst[xxx] = gfx[xx] + color;
}
}
}
}
}
}
}
}
static void draw_pf2_layer()
{
for (INT32 offs = 32; offs < 32 * 31; offs++)
{
INT32 sx = (offs & 0x1f) << 3;
INT32 sy = (offs >> 5) << 3;
INT32 code = DrvPf2RAM[offs * 2 + 0] | (DrvPf2RAM[offs * 2 + 1] << 8);
if (code == 0) continue; // skip transparent tile
Render8x8Tile_Mask(pTransDraw, code & 0xfff, sx, sy - 8, code >> 12, 4, 0, 0, DrvGfxROM0);
}
}
static void draw_sprites()
{
INT32 offs = 0;
@ -859,13 +758,35 @@ static INT32 DrvDraw()
DrvRecalc = 0;
}
UINT16 control[2][2][4];
UINT16 *pf_control0 = (UINT16*)DrvPfCtrl[0];
UINT16 *pf_control1 = (UINT16*)DrvPfCtrl[1];
control[0][0][0] = pf_control0[0];
control[0][0][2] = pf_control0[2];
control[0][0][3] = pf_control0[3];
control[0][1][0] = pf_control0[8];
control[0][1][1] = pf_control0[9];
control[1][0][0] = pf_control1[0];
control[1][0][2] = pf_control1[2];
control[1][0][3] = pf_control1[3];
control[1][1][0] = pf_control1[8];
control[1][1][1] = pf_control1[9];
bac06_depth = 4;
bac06_yadjust = 8;
if ((nBurnLayer & 1) == 0) {
BurnTransferClear();
} else {
draw_pf1_layer();
bac06_draw_layer(DrvPf1RAM, control[0], DrvPf1Scr, NULL, DrvGfxROM2, gfx_config[2], 0x7ff, DrvGfxROM2, gfx_config[2], 0x7ff, 2, 1);
}
if (nBurnLayer & 2) draw_sprites();
if (nBurnLayer & 4) draw_pf2_layer();
if (nBurnLayer & 4) {
bac06_draw_layer(DrvPf2RAM, control[1], NULL, NULL, DrvGfxROM0, gfx_config[0], 0xfff, DrvGfxROM0, gfx_config[0], 0xfff, 0, 0);
}
BurnTransferCopy(DrvPalette);

View File

@ -0,0 +1,119 @@
#include "tiles_generic.h"
int bac06_depth = 4;
int bac06_yadjust = 0;
void bac06_draw_layer(UINT8 *vram, UINT16 control[2][4], UINT8 *rsram, UINT8 *csram, UINT8 *gfx8, INT32 col8, INT32 mask8, UINT8 *gfx16, INT32 col16, INT32 mask16, INT32 widetype, INT32 opaque)
{
const INT32 dims[4][3][2] = {
{ { 128, 32 }, { 64, 64 }, { 32, 128 } },
{ { 64, 16 }, { 32, 32 }, { 16, 64 } },
{ { 128, 16 }, { 64, 32 }, { 32, 64 } },
{ { 256, 16 }, { 128, 32 }, { 64, 64 } }
};
INT32 bank = ( control[0][2] & 1) * 0x1000;
INT32 size = (~control[0][0] & 1);
INT32 shape = control[0][3] & 3;
if (shape == 3) shape = 1;
INT32 tsize = (8 << size);
INT32 wide = dims[(size) ? (widetype + 1) : 0][shape][0];
INT32 high = dims[(size) ? (widetype + 1) : 0][shape][1];
INT32 bsize = dims[(size) ? (widetype + 1) : 0][0][1];
UINT16 *ram = (UINT16*)vram;
INT32 scrollx = (control[1][0]) & ((wide * tsize) - 1);
INT32 scrolly = (control[1][1] + bac06_yadjust) & ((high * tsize) - 1);
INT32 rsenable = (control[0][0] & 0x04) && (rsram != NULL);
INT32 csenable = (control[0][0] & 0x08) && (csram != NULL);
if (rsenable || csenable)
{
UINT16 *scrx = (UINT16*)rsram;
UINT16 *scry = (UINT16*)csram;
INT32 mwidth = (wide * tsize)-1;
INT32 mheight = (high * tsize)-1;
INT32 colbase = size ? col16 : col8;
INT32 gfxmask = size ? mask16 : mask8;
UINT16 *dst = pTransDraw;
UINT8 *gfxbase = size ? gfx16 : gfx8;
for (INT32 sy = 0; sy < nScreenHeight; sy++)
{
INT32 syy = (sy + scrolly) & mheight;
if (csenable) syy = (syy + scry[syy]) & mheight;
INT32 row = syy / tsize;
INT32 zy = syy & (tsize - 1);
for (INT32 sx = 0; sx < nScreenWidth; sx++)
{
INT32 sxx = (sx + scrollx) & mwidth;
if (rsenable) sxx = (sxx + scrx[syy]) & mwidth;
INT32 col = sxx / tsize;
INT32 zx = sxx & (tsize - 1);
INT32 offs = (col & (bsize - 1)) + (row * bsize) + ((col & ~(bsize - 1)) * high);
INT32 code = ram[offs];
INT32 color = ((code >> 12) << bac06_depth) | colbase;
code = (((code & 0xfff) + bank) & gfxmask) * (tsize * tsize);
INT32 pxl = gfxbase[code + (zy * tsize) + zx];
if (pxl | opaque)
dst[sx] = pxl + color;
}
dst += nScreenWidth;
}
} else {
for (INT32 row = 0; row < high; row++)
{
INT32 sy = (row * tsize) - scrolly;
if (sy <= -tsize) sy += high * tsize;
if (sy >= nScreenHeight) continue;
for (INT32 col = 0; col < wide; col++)
{
INT32 sx = (col * tsize) - scrollx;
if (sx <= -tsize) sx += wide * tsize;
if (sx >= nScreenWidth) continue;
INT32 offs = (col & (bsize - 1)) + (row * bsize) + ((col & ~(bsize - 1)) * high);
INT32 code = ram[offs];
INT32 color = (code >> 12);
code = (code & 0xfff) + bank;
if (opaque)
{
if (size)
{
Render16x16Tile_Clip(pTransDraw, code & mask16, sx, sy, color, bac06_depth, col16, gfx16);
}
else
{
Render8x8Tile_Clip(pTransDraw, code & mask8, sx, sy, color, bac06_depth, col8, gfx8);
}
}
else
{
if (size)
{
Render16x16Tile_Mask_Clip(pTransDraw, code & mask16, sx, sy, color, bac06_depth, 0, col16, gfx16);
}
else
{
Render8x8Tile_Mask_Clip(pTransDraw, code & mask8, sx, sy, color, bac06_depth, 0, col8, gfx8);
}
}
}
}
}
}

View File

@ -0,0 +1,4 @@
extern int bac06_depth;
extern int bac06_yadjust;
void bac06_draw_layer(UINT8 *vram, UINT16 control[2][4], UINT8 *rsram, UINT8 *csram, UINT8 *gfx8, INT32 col8, INT32 mask8, UINT8 *gfx16, INT32 col16, INT32 mask16, INT32 widetype, INT32 opaque);

View File

@ -8,6 +8,7 @@
#include "burn_ym2151.h"
#include "msm6295.h"
#include "deco16ic.h"
#include "decobac06.h"
#include "bitswap.h"
static UINT8 *AllMem;
@ -190,6 +191,8 @@ static UINT8 __fastcall madmotor_main_read_byte(UINT32 address)
return DrvDips[0];
case 0x3f8006:
return 0xff;
case 0x3f8007:
return (DrvInputs[1] & ~8) + (vblank ? 0 : 1);
}
@ -451,195 +454,6 @@ static void draw_sprites()
}
}
static void draw_layer(UINT8 *vram, UINT16 control[2][4], UINT8 *rsram, UINT8 *csram, UINT8 *gfx8, INT32 col8, INT32 mask8, UINT8 *gfx16, INT32 col16, INT32 mask16, INT32 widetype, INT32 opaque)
{
int bank = ( control[0][2] & 1) * 0x1000;
int size = (~control[0][0] & 1);
INT32 dims[4][3][2] = {
{ { 128, 32 }, { 64, 64 }, { 32, 128 } },
{ { 64, 16 }, { 32, 32 }, { 16, 64 } },
{ { 128, 16 }, { 64, 32 }, { 32, 64 } },
{ { 256, 16 }, { 128, 32 }, { 64, 64 } }
};
INT32 shape = control[0][3] & 0x3;
if (shape == 3) shape = 1; // 3 is invalid / the same as 1?
INT32 wide = dims[(size) ? (widetype + 1) : 0][shape][0];
INT32 high = dims[(size) ? (widetype + 1) : 0][shape][1];
UINT16 *ram = (UINT16*)vram;
INT32 scrollx = control[1][0] & ((wide << (3+size)) - 1);
INT32 scrolly = (control[1][1] + 8) & ((high << (3+size)) - 1);
INT32 tsize = (8 << size);
INT32 rsenable = (control[0][0] & 0x04) && (rsram != NULL);
INT32 csenable = (control[0][0] & 0x08) && (csram != NULL);
if (rsenable || csenable)
{
UINT16 *scrx = (UINT16*)rsram;
UINT16 *scry = (UINT16*)csram;
INT32 mwidth = (wide * tsize)-1;
INT32 mheight = (high * tsize)-1;
INT32 colbase = size ? col16 : col8;
INT32 gfxmask = size ? mask16 : mask8;
UINT16 *dst = pTransDraw;
UINT8 *gfxbase = size ? gfx16 : gfx8;
for (INT32 sy = 0; sy < nScreenHeight; sy++)
{
for (INT32 sx = 0; sx < nScreenWidth; sx++)
{
INT32 syy = (sy + scrolly) & mheight;
INT32 sxx = (sx + scrollx) & mwidth;
if (csenable) syy = (syy + scry[syy]) & mheight;
if (rsenable) sxx = (sxx + scrx[syy]) & mwidth;
INT32 row = syy / tsize;
INT32 col = sxx / tsize;
INT32 zy = syy & (tsize - 1);
INT32 zx = sxx & (tsize - 1);
INT32 offs = 0;
if (size)
{
switch (shape)
{
case 0:
offs = (col & 0xf) + ((row & 0xf) << 4) + ((col & 0x1f0) << 4);
break;
case 1:
offs = (col & 0xf) + ((row & 0x1f) << 4) + ((col & 0xf0) << 5);
break;
case 2:
offs = (col & 0xf) + ((row & 0x3f) << 4) + ((col & 0x70) << 6);
break;
}
}
else
{
switch (shape)
{
case 0:
offs = (col & 0x1f) + ((row & 0x1f) << 5) + ((col & 0x60) << 5);
break;
case 1:
offs = (col & 0x1f) + ((row & 0x3f) << 5) + ((col & 0x20) << 6);
break;
case 2:
offs = (col & 0x1f) + ((row & 0x7f) << 5);
break;
}
}
INT32 code = ram[offs];
INT32 color = ((code >> 12) << 4) | colbase;
code = (((code & 0xfff) + bank) & gfxmask) * (tsize * tsize);
INT32 pxl = gfxbase[code + (zy * tsize) + zx];
if (pxl | opaque)
dst[sx] = pxl + color;
}
dst += nScreenWidth;
}
} else {
for (INT32 row = 0; row < high; row++)
{
for (INT32 col = 0; col < wide; col++)
{
INT32 sy = (row * tsize) - scrolly;
INT32 sx = (col * tsize) - scrollx;
if (sy <= -tsize) sy += high * tsize;
if (sx <= -tsize) sx += wide * tsize;
if (sx >= nScreenWidth || sy >= nScreenHeight) continue;
INT32 offs = 0;
if (size)
{
switch (shape)
{
case 0:
offs = (col & 0xf) + ((row & 0xf) << 4) + ((col & 0x1f0) << 4);
break;
case 1:
offs = (col & 0xf) + ((row & 0x1f) << 4) + ((col & 0xf0) << 5);
break;
case 2:
offs = (col & 0xf) + ((row & 0x3f) << 4) + ((col & 0x70) << 6);
break;
}
}
else
{
switch (shape)
{
case 0:
offs = (col & 0x1f) + ((row & 0x1f) << 5) + ((col & 0x60) << 5);
break;
case 1:
offs = (col & 0x1f) + ((row & 0x3f) << 5) + ((col & 0x20) << 6);
break;
case 2:
offs = (col & 0x1f) + ((row & 0x7f) << 5);
break;
}
}
INT32 code = ram[offs];
INT32 color = (code >> 12);
code = (code & 0xfff) + bank;
if (opaque)
{
if (size)
{
Render16x16Tile_Clip(pTransDraw, code & mask16, sx, sy, color, 4, col16, gfx16);
}
else
{
Render8x8Tile_Clip(pTransDraw, code & mask8, sx, sy, color, 4, col8, gfx8);
}
}
else
{
if (size)
{
Render16x16Tile_Mask_Clip(pTransDraw, code & mask16, sx, sy, color, 4, 0, col16, gfx16);
}
else
{
Render8x8Tile_Mask_Clip(pTransDraw, code & mask8, sx, sy, color, 4, 0, col8, gfx8);
}
}
}
}
}
}
static INT32 DrvDraw()
{
if (DrvRecalc) {
@ -649,12 +463,15 @@ static INT32 DrvDraw()
BurnTransferClear();
if (nBurnLayer & 4) draw_layer(DrvPfRAM2, pf_control[2], NULL, NULL, DrvGfxROM0, 0x000, 0xfff, DrvGfxROM2, 0x300, 0xfff, 1, 1);
if (nBurnLayer & 2) draw_layer(DrvPfRAM1, pf_control[1], NULL, NULL, DrvGfxROM0, 0x000, 0xfff, DrvGfxROM1, 0x200, 0x7ff, 0, 0);
bac06_depth = 4;
bac06_yadjust = 8;
if (nBurnLayer & 4) bac06_draw_layer(DrvPfRAM2, pf_control[2], NULL, NULL, DrvGfxROM0, 0x000, 0xfff, DrvGfxROM2, 0x300, 0xfff, 1, 1);
if (nBurnLayer & 2) bac06_draw_layer(DrvPfRAM1, pf_control[1], NULL, NULL, DrvGfxROM0, 0x000, 0xfff, DrvGfxROM1, 0x200, 0x7ff, 0, 0);
draw_sprites();
if (nBurnLayer & 1) draw_layer(DrvPfRAM0, pf_control[0], DrvRowScroll, DrvColScroll, DrvGfxROM0, 0x000, 0xfff, DrvGfxROM0, 0x000, 0x000, 0, 0);
if (nBurnLayer & 1) bac06_draw_layer(DrvPfRAM0, pf_control[0], DrvRowScroll, DrvColScroll, DrvGfxROM0, 0x000, 0xfff, DrvGfxROM0, 0x000, 0x000, 0, 0);
BurnTransferCopy(DrvPalette);