d_ladybug: fix sraider animated background and music/sfx - sn* sounds needed to be interlaced. few cleanups

This commit is contained in:
dinkc64 2017-04-29 03:30:07 +00:00
parent f733f2625d
commit c425639c91
1 changed files with 90 additions and 55 deletions

View File

@ -757,20 +757,12 @@ static INT32 DrvInit(INT32 game_select)
ZetInit(0); ZetInit(0);
ZetOpen(0); ZetOpen(0);
ZetMapArea(0x0000, 0x5fff, 0, DrvZ80ROM0); ZetMapMemory(DrvZ80ROM0, 0x0000, 0x5fff, MAP_ROM);
ZetMapArea(0x0000, 0x5fff, 2, DrvZ80Ops0, DrvZ80ROM0); ZetMapMemory(DrvZ80Ops0, 0x0000, 0x5fff, MAP_FETCHOP); // dorodon encrypted opcodes
ZetMapArea(0x6000, 0x6fff, 0, DrvZ80RAM0); ZetMapMemory(DrvZ80RAM0, 0x6000, 0x6fff, MAP_RAM);
ZetMapArea(0x6000, 0x6fff, 1, DrvZ80RAM0); ZetMapMemory(DrvSprRAM, 0x7000, 0x73ff, MAP_RAM);
ZetMapArea(0x6000, 0x6fff, 2, DrvZ80RAM0); ZetMapMemory(DrvVidRAM, 0xd000, 0xd3ff, MAP_RAM);
ZetMapArea(0x7000, 0x73ff, 0, DrvSprRAM); ZetMapMemory(DrvColRAM, 0xd400, 0xd7ff, MAP_RAM);
ZetMapArea(0x7000, 0x73ff, 1, DrvSprRAM);
ZetMapArea(0x7000, 0x73ff, 2, DrvSprRAM);
ZetMapArea(0xd000, 0xd3ff, 0, DrvVidRAM);
ZetMapArea(0xd000, 0xd3ff, 1, DrvVidRAM);
ZetMapArea(0xd000, 0xd3ff, 2, DrvVidRAM);
ZetMapArea(0xd400, 0xd7ff, 0, DrvColRAM);
ZetMapArea(0xd400, 0xd7ff, 1, DrvColRAM);
ZetMapArea(0xd400, 0xd7ff, 2, DrvColRAM);
ZetSetWriteHandler(ladybug_write); ZetSetWriteHandler(ladybug_write);
ZetSetReadHandler(ladybug_read); ZetSetReadHandler(ladybug_read);
ZetClose(); ZetClose();
@ -824,34 +816,20 @@ static INT32 SraiderInit()
ZetInit(0); ZetInit(0);
ZetOpen(0); ZetOpen(0);
ZetMapArea(0x0000, 0x5fff, 0, DrvZ80ROM0); ZetMapMemory(DrvZ80ROM0, 0x0000, 0x5fff, MAP_ROM);
ZetMapArea(0x0000, 0x5fff, 2, DrvZ80ROM0); ZetMapMemory(DrvZ80RAM0, 0x6000, 0x6fff, MAP_RAM);
ZetMapArea(0x6000, 0x6fff, 0, DrvZ80RAM0); ZetMapMemory(DrvSprRAM, 0x7000, 0x73ff, MAP_RAM);
ZetMapArea(0x6000, 0x6fff, 1, DrvZ80RAM0); ZetMapMemory(DrvVidRAM, 0xd000, 0xd3ff, MAP_RAM);
ZetMapArea(0x6000, 0x6fff, 2, DrvZ80RAM0); ZetMapMemory(DrvColRAM, 0xd400, 0xd7ff, MAP_RAM);
ZetMapArea(0x7000, 0x73ff, 0, DrvSprRAM);
ZetMapArea(0x7000, 0x73ff, 1, DrvSprRAM);
ZetMapArea(0x7000, 0x73ff, 2, DrvSprRAM);
ZetMapArea(0xd000, 0xd3ff, 0, DrvVidRAM);
ZetMapArea(0xd000, 0xd3ff, 1, DrvVidRAM);
ZetMapArea(0xd000, 0xd3ff, 2, DrvVidRAM);
ZetMapArea(0xd400, 0xd7ff, 0, DrvColRAM);
ZetMapArea(0xd400, 0xd7ff, 1, DrvColRAM);
ZetMapArea(0xd400, 0xd7ff, 2, DrvColRAM);
ZetSetWriteHandler(sraider_main_write); ZetSetWriteHandler(sraider_main_write);
ZetSetReadHandler(ladybug_read); ZetSetReadHandler(ladybug_read);
ZetClose(); ZetClose();
ZetInit(1); ZetInit(1);
ZetOpen(1); ZetOpen(1);
ZetMapArea(0x0000, 0x5fff, 0, DrvZ80ROM1); ZetMapMemory(DrvZ80ROM1, 0x0000, 0x5fff, MAP_ROM);
ZetMapArea(0x0000, 0x5fff, 2, DrvZ80ROM1); ZetMapMemory(DrvZ80RAM1, 0x6000, 0x63ff, MAP_RAM);
ZetMapArea(0x6000, 0x63ff, 0, DrvZ80RAM1); ZetMapMemory(DrvGridRAM, 0xe000, 0xe0ff, MAP_RAM);
ZetMapArea(0x6000, 0x63ff, 1, DrvZ80RAM1);
ZetMapArea(0x6000, 0x63ff, 2, DrvZ80RAM1);
ZetMapArea(0xe000, 0xe0ff, 0, DrvGridRAM);
ZetMapArea(0xe000, 0xe0ff, 1, DrvGridRAM);
ZetMapArea(0xe000, 0xe0ff, 2, DrvGridRAM);
ZetSetWriteHandler(sraider_sub_write); ZetSetWriteHandler(sraider_sub_write);
ZetSetReadHandler(sraider_sub_read); ZetSetReadHandler(sraider_sub_read);
ZetSetOutHandler(sraider_sub_out); ZetSetOutHandler(sraider_sub_out);
@ -862,11 +840,11 @@ static INT32 SraiderInit()
SN76489Init(2, 4000000, 1); SN76489Init(2, 4000000, 1);
SN76489Init(3, 4000000, 1); SN76489Init(3, 4000000, 1);
SN76489Init(4, 4000000, 1); SN76489Init(4, 4000000, 1);
SN76496SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH); SN76496SetRoute(0, 0.70, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(1, 1.00, BURN_SND_ROUTE_BOTH); SN76496SetRoute(1, 0.70, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(2, 1.00, BURN_SND_ROUTE_BOTH); SN76496SetRoute(2, 0.70, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(3, 1.00, BURN_SND_ROUTE_BOTH); SN76496SetRoute(3, 0.70, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(4, 1.00, BURN_SND_ROUTE_BOTH); SN76496SetRoute(4, 0.70, BURN_SND_ROUTE_BOTH);
GenericTilesInit(); GenericTilesInit();
@ -916,6 +894,19 @@ static void draw_layer()
} }
} }
static void boxizer(INT32 x, INT32 y, INT32 w, INT32 h, INT32 pxl) {
INT32 t = x;
while(h-- > 0) {
INT32 c = w; x = t;
while(c-- > 0) {
if (x < nScreenWidth && y < nScreenHeight)
pTransDraw[(y*nScreenWidth) + x] = pxl;
x++;
}
y++;
}
}
static void draw_grid() static void draw_grid()
{ {
for (INT32 offs = 4 * 32; offs < 32 * 28; offs++) for (INT32 offs = 4 * 32; offs < 32 * 28; offs++)
@ -940,6 +931,20 @@ static void draw_grid()
} }
} }
} }
for (INT32 i = 0; i < 0x100; i++)
{
if (DrvGridRAM[i] != 0)
{
UINT8 x = i;
int height = nScreenHeight;
if (*flipscreen)
x = ~x;
boxizer(x, 0, 1, height, 0x81);
}
}
} }
static void draw_sprites() static void draw_sprites()
@ -958,7 +963,14 @@ static void draw_sprites()
if (DrvSprRAM[offs + i + 0] & 0x80) if (DrvSprRAM[offs + i + 0] & 0x80)
{ {
INT32 size = (DrvSprRAM[offs + i + 0] >> 6) & 0x01; INT32 size = (DrvSprRAM[offs + i + 0] >> 6) & 0x01;
INT32 code = (DrvSprRAM[offs + i + 1] >> 2) + ((DrvSprRAM[offs + i + 2] & 0x10) << (4 >> size));
INT32 code;
if (size) // 16
code = ((DrvSprRAM[offs + i + 1] >> 2) + 4 * (DrvSprRAM[offs + i + 2] & 0x10)) & 0x7f;
else // 8
code = (DrvSprRAM[offs + i + 1] + 16 * (DrvSprRAM[offs + i + 2] & 0x10)) & 0x1ff;
//INT32 code = (DrvSprRAM[offs + i + 1] >> 2) + ((DrvSprRAM[offs + i + 2] & 0x10) << (4 >> size));
INT32 color = (DrvSprRAM[offs + i + 2] & 0x0f) + 8; INT32 color = (DrvSprRAM[offs + i + 2] & 0x0f) + 8;
INT32 flipx = DrvSprRAM[offs + i + 0] & 0x20; INT32 flipx = DrvSprRAM[offs + i + 0] & 0x20;
INT32 flipy = DrvSprRAM[offs + i + 0] & 0x10; INT32 flipy = DrvSprRAM[offs + i + 0] & 0x10;
@ -1174,8 +1186,10 @@ static INT32 DrvFrame()
ZetClose(); ZetClose();
if (pBurnSoundOut) {
SN76496Update(0, pBurnSoundOut, nBurnSoundLen); SN76496Update(0, pBurnSoundOut, nBurnSoundLen);
SN76496Update(1, pBurnSoundOut, nBurnSoundLen); SN76496Update(1, pBurnSoundOut, nBurnSoundLen);
}
if (pBurnDraw) { if (pBurnDraw) {
DrvDraw(); DrvDraw();
@ -1200,24 +1214,45 @@ static INT32 SraiderFrame()
INT32 nInterleave = 100; INT32 nInterleave = 100;
INT32 nTotalCycles[2] = { 4000000 / 60, 4000000 / 60 }; INT32 nTotalCycles[2] = { 4000000 / 60, 4000000 / 60 };
INT32 nSoundBufferPos = 0;
for (INT32 i = 0; i < nInterleave; i++) { for (INT32 i = 0; i < nInterleave; i++) {
ZetOpen(0); ZetOpen(0);
ZetRun(nTotalCycles[0] / nInterleave); ZetRun(nTotalCycles[0] / nInterleave);
if (i == (nInterleave - 1)) ZetSetIRQLine(0, CPU_IRQSTATUS_AUTO); if (i == (nInterleave - 1)) ZetSetIRQLine(0, CPU_IRQSTATUS_HOLD);
ZetClose(); ZetClose();
ZetOpen(1); ZetOpen(1);
ZetRun(nTotalCycles[1] / nInterleave); ZetRun(nTotalCycles[1] / nInterleave);
if (i == (nInterleave - 1)) ZetSetIRQLine(0, CPU_IRQSTATUS_AUTO); if (i == (nInterleave - 1)) ZetSetIRQLine(0, CPU_IRQSTATUS_HOLD);
ZetClose(); ZetClose();
if (pBurnSoundOut) {
INT32 nSegmentLength = nBurnSoundLen / nInterleave;
INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
SN76496Update(0, pSoundBuf, nSegmentLength);
SN76496Update(1, pSoundBuf, nSegmentLength);
SN76496Update(2, pSoundBuf, nSegmentLength);
SN76496Update(3, pSoundBuf, nSegmentLength);
SN76496Update(4, pSoundBuf, nSegmentLength);
nSoundBufferPos += nSegmentLength;
}
}
if (pBurnSoundOut) {
INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos;
INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
if (nSegmentLength) {
SN76496Update(0, pSoundBuf, nSegmentLength);
SN76496Update(1, pSoundBuf, nSegmentLength);
SN76496Update(2, pSoundBuf, nSegmentLength);
SN76496Update(3, pSoundBuf, nSegmentLength);
SN76496Update(4, pSoundBuf, nSegmentLength);
}
} }
SN76496Update(0, pBurnSoundOut, nBurnSoundLen);
SN76496Update(1, pBurnSoundOut, nBurnSoundLen);
SN76496Update(2, pBurnSoundOut, nBurnSoundLen);
SN76496Update(3, pBurnSoundOut, nBurnSoundLen);
SN76496Update(4, pBurnSoundOut, nBurnSoundLen);
if (pBurnDraw) { if (pBurnDraw) {
SraiderDraw(); SraiderDraw();
@ -1558,5 +1593,5 @@ struct BurnDriver BurnDrvSraider = {
BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_PRE90S, GBF_SHOOT, 0, BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_PRE90S, GBF_SHOOT, 0,
NULL, sraiderRomInfo, sraiderRomName, NULL, NULL, SraiderInputInfo, SraiderDIPInfo, NULL, sraiderRomInfo, sraiderRomName, NULL, NULL, SraiderInputInfo, SraiderDIPInfo,
SraiderInit, DrvExit, SraiderFrame, SraiderDraw, DrvScan, &DrvRecalc, 0x82, SraiderInit, DrvExit, SraiderFrame, SraiderDraw, DrvScan, &DrvRecalc, 0x82,
196, 240, 3, 4 192, 240, 3, 4
}; };