Update scambled eggs driver
This commit is contained in:
parent
019c674c87
commit
155faf3095
|
@ -1,3 +1,6 @@
|
|||
// FB Alpha Eggs & Dommy driver module
|
||||
// Based on MAME driver by Nicola Salmoria
|
||||
|
||||
#include "tiles_generic.h"
|
||||
#include "m6502_intf.h"
|
||||
#include "bitswap.h"
|
||||
|
@ -6,16 +9,33 @@ extern "C" {
|
|||
#include "ay8910.h"
|
||||
}
|
||||
|
||||
static UINT8 *Mem, *Rom, *Gfx0, *Gfx1, *Prom;
|
||||
static UINT8 DrvJoy1[8], DrvJoy2[8], DrvDips[2], DrvReset;
|
||||
static UINT32 *Palette, *DrvPalette;
|
||||
static UINT8 DrvRecalcPal = 0;
|
||||
static INT16 *pFMBuffer, *pAY8910Buffer[6];
|
||||
static UINT8 *AllMem;
|
||||
static UINT8 *MemEnd;
|
||||
static UINT8 *AllRam;
|
||||
static UINT8 *RamEnd;
|
||||
static UINT8 *Drv6502ROM;
|
||||
static UINT8 *DrvGfxROM0;
|
||||
static UINT8 *DrvGfxROM1;
|
||||
static UINT8 *DrvColPROM;
|
||||
static UINT8 *DrvVidRAM;
|
||||
static UINT8 *Drv6502RAM;
|
||||
static UINT8 *DrvColRAM;
|
||||
|
||||
static INT32 flipscreen = 0;
|
||||
static INT32 VBLK = 0;
|
||||
static INT16 *pAY8910Buffer[6];
|
||||
static INT16 *pFMBuffer = NULL;
|
||||
|
||||
static INT32 scregg = 0, rockduck = 0;
|
||||
static UINT32 *DrvPalette;
|
||||
static UINT8 DrvRecalc;
|
||||
|
||||
static UINT8 *flipscreen;
|
||||
|
||||
static UINT8 DrvJoy1[8];
|
||||
static UINT8 DrvJoy2[8];
|
||||
static UINT8 DrvDips[2];
|
||||
static UINT8 DrvInputs[2];
|
||||
static UINT8 DrvReset;
|
||||
|
||||
static INT32 vblank = 0;
|
||||
|
||||
static struct BurnInputInfo DrvInputList[] = {
|
||||
{"P1 Coin" , BIT_DIGITAL , DrvJoy1 + 6, "p1 coin" },
|
||||
|
@ -43,7 +63,6 @@ STDINPUTINFO(Drv)
|
|||
|
||||
static struct BurnDIPInfo DrvDIPList[]=
|
||||
{
|
||||
// Default Values
|
||||
{0x0f, 0xff, 0xff, 0x7f, NULL },
|
||||
|
||||
{0 , 0xfe, 0 , 4 , "Coin A" },
|
||||
|
@ -62,7 +81,6 @@ static struct BurnDIPInfo DrvDIPList[]=
|
|||
{0x0f, 0x01, 0x40, 0x40, "Cocktail" },
|
||||
{0x0f, 0x01, 0x40, 0x00, "Upright" },
|
||||
|
||||
// Default Values
|
||||
{0x10, 0xff, 0xff, 0xff, NULL },
|
||||
|
||||
{0 , 0xfe, 0 , 2 , "Lives" },
|
||||
|
@ -82,65 +100,75 @@ static struct BurnDIPInfo DrvDIPList[]=
|
|||
|
||||
STDDIPINFO(Drv)
|
||||
|
||||
static inline INT32 calc_mirror_offset(UINT16 address)
|
||||
// Delay allocation of buffer. This allows us to use the proper frames/sec frame rate.
|
||||
static inline void DrvDelayAY8910BufferAllocation()
|
||||
{
|
||||
INT32 x, y, offset;
|
||||
offset = address & 0x3ff;
|
||||
if (pFMBuffer == NULL && pBurnSoundOut)
|
||||
{
|
||||
pFMBuffer = (INT16*)BurnMalloc(nBurnSoundLen * sizeof(INT16) * 6);
|
||||
|
||||
x = offset >> 5;
|
||||
y = offset & 0x1f;
|
||||
|
||||
return ((y << 5) | x);
|
||||
pAY8910Buffer[0] = pFMBuffer + nBurnSoundLen * 0;
|
||||
pAY8910Buffer[1] = pFMBuffer + nBurnSoundLen * 1;
|
||||
pAY8910Buffer[2] = pFMBuffer + nBurnSoundLen * 2;
|
||||
pAY8910Buffer[3] = pFMBuffer + nBurnSoundLen * 3;
|
||||
pAY8910Buffer[4] = pFMBuffer + nBurnSoundLen * 4;
|
||||
pAY8910Buffer[5] = pFMBuffer + nBurnSoundLen * 5;
|
||||
}
|
||||
}
|
||||
|
||||
UINT8 eggs_readmem(UINT16 address)
|
||||
static inline INT32 calc_mirror_offset(UINT16 address)
|
||||
{
|
||||
UINT8 ret = 0xff;
|
||||
return ((address >> 5) & 0x1f) + ((address & 0x1f) << 5);
|
||||
}
|
||||
|
||||
static UINT8 eggs_read(UINT16 address)
|
||||
{
|
||||
if ((address & 0xf800) == 0x1800) {
|
||||
return Rom[0x2000 + (address & 0x400) + calc_mirror_offset(address)];
|
||||
return DrvVidRAM[calc_mirror_offset(address)];
|
||||
}
|
||||
|
||||
if ((address & 0xf800) == 0x1c00) {
|
||||
return DrvColRAM[calc_mirror_offset(address)];
|
||||
}
|
||||
|
||||
switch (address)
|
||||
{
|
||||
case 0x2000:
|
||||
return VBLK | DrvDips[0];
|
||||
return DrvDips[0] | vblank;
|
||||
|
||||
case 0x2001:
|
||||
return DrvDips[1];
|
||||
|
||||
case 0x2002:
|
||||
{
|
||||
for (INT32 i = 0; i < 8; i++) ret ^= DrvJoy1[i] << i;
|
||||
|
||||
return ret;
|
||||
}
|
||||
return DrvInputs[0];
|
||||
|
||||
case 0x2003:
|
||||
{
|
||||
for (INT32 i = 0; i < 8; i++) ret ^= DrvJoy2[i] << i;
|
||||
|
||||
return ret;
|
||||
}
|
||||
return DrvInputs[1];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void eggs_writemem(UINT16 address, UINT8 data)
|
||||
void eggs_write(UINT16 address, UINT8 data)
|
||||
{
|
||||
if ((address & 0xf800) == 0x1800) {
|
||||
Rom[0x2000 + (address & 0x400) + calc_mirror_offset(address)] = data;
|
||||
if ((address & 0xfc00) == 0x1800) {
|
||||
DrvVidRAM[calc_mirror_offset(address)] = data;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((address & 0xfc00) == 0x1c00) {
|
||||
DrvColRAM[calc_mirror_offset(address)] = data;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (address)
|
||||
{
|
||||
case 0x2000:
|
||||
flipscreen = data & 1;
|
||||
*flipscreen = data & 1;
|
||||
break;
|
||||
|
||||
case 0x2001:
|
||||
M6502SetIRQLine(M6502_IRQ_LINE, M6502_IRQSTATUS_NONE);
|
||||
break;
|
||||
|
||||
case 0x2004:
|
||||
|
@ -152,54 +180,45 @@ void eggs_writemem(UINT16 address, UINT8 data)
|
|||
}
|
||||
}
|
||||
|
||||
UINT8 dommy_readmem(UINT16 address)
|
||||
static UINT8 dommy_read(UINT16 address)
|
||||
{
|
||||
UINT8 ret = 0xff;
|
||||
|
||||
if (address >= 0x2800 && address <= 0x2bff) {
|
||||
return Rom[0x2000 + calc_mirror_offset(address)];
|
||||
if ((address & 0xfc00) == 0x2800) {
|
||||
return DrvVidRAM[calc_mirror_offset(address)];
|
||||
}
|
||||
|
||||
switch (address)
|
||||
{
|
||||
case 0x4000:
|
||||
return DrvDips[0] | VBLK;
|
||||
return DrvDips[0] | vblank;
|
||||
|
||||
case 0x4001:
|
||||
return DrvDips[1];
|
||||
|
||||
case 0x4002:
|
||||
{
|
||||
for (INT32 i = 0; i < 8; i++) ret ^= DrvJoy1[i] << i;
|
||||
|
||||
return ret;
|
||||
}
|
||||
return DrvInputs[0];
|
||||
|
||||
case 0x4003:
|
||||
{
|
||||
for (INT32 i = 0; i < 8; i++) ret ^= DrvJoy2[i] << i;
|
||||
|
||||
return ret;
|
||||
}
|
||||
return DrvInputs[1];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dommy_writemem(UINT16 address, UINT8 data)
|
||||
static void dommy_write(UINT16 address, UINT8 data)
|
||||
{
|
||||
if (address >= 0x2800 && address <= 0x2bff) {
|
||||
Rom[0x2000 + calc_mirror_offset(address)] = data;
|
||||
if ((address & 0xfc00) == 0x2800) {
|
||||
DrvVidRAM[calc_mirror_offset(address)] = data;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (address)
|
||||
{
|
||||
case 0x4000:
|
||||
M6502SetIRQLine(M6502_IRQ_LINE, M6502_IRQSTATUS_NONE);
|
||||
break;
|
||||
|
||||
case 0x4001:
|
||||
flipscreen = data & 1;
|
||||
*flipscreen = data & 1;
|
||||
break;
|
||||
|
||||
case 0x4004:
|
||||
|
@ -211,12 +230,9 @@ void dommy_writemem(UINT16 address, UINT8 data)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static INT32 DrvDoReset()
|
||||
{
|
||||
memset (Rom, 0, 0x3000);
|
||||
|
||||
flipscreen = 0;
|
||||
memset(AllRam, 0, RamEnd - AllRam);
|
||||
|
||||
M6502Open(0);
|
||||
M6502Reset();
|
||||
|
@ -228,161 +244,201 @@ static INT32 DrvDoReset()
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static INT32 scregg_gfx_convert()
|
||||
static INT32 DrvGfxDecode()
|
||||
{
|
||||
static INT32 PlaneOffsets[3] = { 0x20000, 0x10000, 0 };
|
||||
static INT32 XOffsets[16] = { 128, 129, 130, 131, 132, 133, 134, 135, 0, 1, 2, 3, 4, 5, 6, 7 };
|
||||
static INT32 YOffsets[16] = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 };
|
||||
static INT32 Planes[3] = { 0x20000, 0x10000, 0 };
|
||||
static INT32 XOffs[16] = { STEP8(128,1), STEP8(0,1) };
|
||||
static INT32 YOffs[16] = { STEP16(0, 8) };
|
||||
|
||||
UINT8 *tmp = (UINT8*)BurnMalloc(0x6000);
|
||||
if (tmp == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
memcpy (tmp, Gfx0, 0x6000);
|
||||
memcpy (tmp, DrvGfxROM0, 0x6000);
|
||||
|
||||
GfxDecode(0x400, 3, 8, 8, PlaneOffsets, XOffsets + 8, YOffsets, 0x040, tmp, Gfx0);
|
||||
GfxDecode(0x100, 3, 16, 16, PlaneOffsets, XOffsets + 0, YOffsets, 0x100, tmp, Gfx1);
|
||||
GfxDecode(0x400, 3, 8, 8, Planes, XOffs + 8, YOffs, 0x040, tmp, DrvGfxROM0);
|
||||
GfxDecode(0x100, 3, 16, 16, Planes, XOffs + 0, YOffs, 0x100, tmp, DrvGfxROM1);
|
||||
|
||||
BurnFree (tmp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT32 scregg_palette_init()
|
||||
static void DrvPaletteInit()
|
||||
{
|
||||
for (INT32 i = 0;i < 8;i++)
|
||||
{
|
||||
INT32 bit0,bit1,bit2,r,g,b;
|
||||
INT32 bit0 = (DrvColPROM[i] >> 0) & 0x01;
|
||||
INT32 bit1 = (DrvColPROM[i] >> 1) & 0x01;
|
||||
INT32 bit2 = (DrvColPROM[i] >> 2) & 0x01;
|
||||
INT32 r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
|
||||
|
||||
bit0 = (Prom[i] >> 0) & 0x01;
|
||||
bit1 = (Prom[i] >> 1) & 0x01;
|
||||
bit2 = (Prom[i] >> 2) & 0x01;
|
||||
r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
|
||||
|
||||
bit0 = (Prom[i] >> 3) & 0x01;
|
||||
bit1 = (Prom[i] >> 4) & 0x01;
|
||||
bit2 = (Prom[i] >> 5) & 0x01;
|
||||
g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
|
||||
bit0 = (DrvColPROM[i] >> 3) & 0x01;
|
||||
bit1 = (DrvColPROM[i] >> 4) & 0x01;
|
||||
bit2 = (DrvColPROM[i] >> 5) & 0x01;
|
||||
INT32 g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
|
||||
|
||||
bit0 = 0;
|
||||
bit1 = (Prom[i] >> 6) & 0x01;
|
||||
bit2 = (Prom[i] >> 7) & 0x01;
|
||||
b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
|
||||
bit1 = (DrvColPROM[i] >> 6) & 0x01;
|
||||
bit2 = (DrvColPROM[i] >> 7) & 0x01;
|
||||
INT32 b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
|
||||
|
||||
Palette[i] = (r << 16) | (g << 8) | b;
|
||||
DrvPalette[i] = BurnHighCol(r, g, b, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void scregg6502Init()
|
||||
{
|
||||
M6502Init(0, TYPE_M6502);
|
||||
M6502Open(0);
|
||||
M6502MapMemory(Drv6502RAM, 0x0000, 0x07ff, M6502_RAM);
|
||||
M6502MapMemory(DrvVidRAM, 0x1000, 0x13ff, M6502_RAM);
|
||||
M6502MapMemory(DrvColRAM, 0x1400, 0x17ff, M6502_RAM);
|
||||
M6502MapMemory(Drv6502ROM + 0x3000, 0x3000, 0x7fff, M6502_ROM);
|
||||
M6502MapMemory(Drv6502ROM + 0x7000, 0xf000, 0xffff, M6502_ROM);
|
||||
M6502SetWriteMemIndexHandler(eggs_write);
|
||||
M6502SetReadMemIndexHandler(eggs_read);
|
||||
M6502SetReadOpArgHandler(eggs_read);
|
||||
M6502SetWriteHandler(eggs_write);
|
||||
M6502SetReadOpHandler(eggs_read);
|
||||
M6502SetReadHandler(eggs_read);
|
||||
M6502Close();
|
||||
}
|
||||
|
||||
static void dommy6502Init()
|
||||
{
|
||||
M6502Init(0, TYPE_M6502);
|
||||
M6502Open(0);
|
||||
M6502MapMemory(Drv6502RAM, 0x0000, 0x07ff, M6502_RAM);
|
||||
M6502MapMemory(DrvVidRAM, 0x2000, 0x23ff, M6502_RAM);
|
||||
M6502MapMemory(DrvColRAM, 0x2400, 0x27ff, M6502_RAM);
|
||||
M6502MapMemory(Drv6502ROM + 0xa000, 0xa000, 0xffff, M6502_ROM);
|
||||
M6502SetWriteMemIndexHandler(dommy_write);
|
||||
M6502SetReadMemIndexHandler(dommy_read);
|
||||
M6502SetReadOpArgHandler(dommy_read);
|
||||
M6502SetWriteHandler(dommy_write);
|
||||
M6502SetReadOpHandler(dommy_read);
|
||||
M6502SetReadHandler(dommy_read);
|
||||
M6502Close();
|
||||
}
|
||||
|
||||
static INT32 rockduckLoadRoms()
|
||||
{
|
||||
if (BurnLoadRom(Drv6502ROM + 0x4000, 0, 1)) return 1;
|
||||
if (BurnLoadRom(Drv6502ROM + 0x6000, 1, 1)) return 1;
|
||||
if (BurnLoadRom(Drv6502ROM + 0x8000, 2, 1)) return 1;
|
||||
memcpy (Drv6502ROM + 0x3000, Drv6502ROM + 0x5000, 0x1000);
|
||||
memcpy (Drv6502ROM + 0x5000, Drv6502ROM + 0x7000, 0x1000);
|
||||
memcpy (Drv6502ROM + 0xe000, Drv6502ROM + 0x8000, 0x2000);
|
||||
memcpy (Drv6502ROM + 0x7000, Drv6502ROM + 0x9000, 0x1000);
|
||||
|
||||
if (BurnLoadRom(DrvGfxROM0 + 0x0000, 3, 1)) return 1;
|
||||
if (BurnLoadRom(DrvGfxROM0 + 0x2000, 4, 1)) return 1;
|
||||
if (BurnLoadRom(DrvGfxROM0 + 0x4000, 5, 1)) return 1;
|
||||
|
||||
if (BurnLoadRom(DrvColPROM + 0x0000, 6, 1)) return 1;
|
||||
|
||||
for (INT32 i = 0x2000; i < 0x6000; i++)
|
||||
DrvGfxROM0[i] = BITSWAP08(DrvGfxROM0[i],2,0,3,6,1,4,7,5);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT32 DrvInit()
|
||||
static INT32 screggLoadRoms()
|
||||
{
|
||||
Mem = (UINT8*)BurnMalloc(0x10000 + 0x10000 + 0x10000 + (0x08 * sizeof(UINT32)) + (0x10 * sizeof(UINT32)));
|
||||
if (Mem == NULL) {
|
||||
return 1;
|
||||
if (BurnLoadRom(Drv6502ROM + 0x3000, 0, 1)) return 1;
|
||||
if (BurnLoadRom(Drv6502ROM + 0x4000, 1, 1)) return 1;
|
||||
if (BurnLoadRom(Drv6502ROM + 0x5000, 2, 1)) return 1;
|
||||
if (BurnLoadRom(Drv6502ROM + 0x6000, 3, 1)) return 1;
|
||||
if (BurnLoadRom(Drv6502ROM + 0x7000, 4, 1)) return 1;
|
||||
|
||||
if (BurnLoadRom(DrvGfxROM0 + 0x0000, 5, 1)) return 1;
|
||||
if (BurnLoadRom(DrvGfxROM0 + 0x1000, 6, 1)) return 1;
|
||||
if (BurnLoadRom(DrvGfxROM0 + 0x2000, 7, 1)) return 1;
|
||||
if (BurnLoadRom(DrvGfxROM0 + 0x3000, 8, 1)) return 1;
|
||||
if (BurnLoadRom(DrvGfxROM0 + 0x4000, 9, 1)) return 1;
|
||||
if (BurnLoadRom(DrvGfxROM0 + 0x5000, 10, 1)) return 1;
|
||||
|
||||
if (BurnLoadRom(DrvColPROM, 11, 1)) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT32 dommyLoadRoms()
|
||||
{
|
||||
if (BurnLoadRom(Drv6502ROM + 0xa000, 0, 1)) return 1;
|
||||
if (BurnLoadRom(Drv6502ROM + 0xc000, 1, 1)) return 1;
|
||||
if (BurnLoadRom(Drv6502ROM + 0xe000, 2, 1)) return 1;
|
||||
|
||||
if (BurnLoadRom(DrvGfxROM0 + 0x0000, 3, 1)) return 1;
|
||||
if (BurnLoadRom(DrvGfxROM0 + 0x2000, 4, 1)) return 1;
|
||||
if (BurnLoadRom(DrvGfxROM0 + 0x4000, 5, 1)) return 1;
|
||||
|
||||
if (BurnLoadRom(DrvColPROM + 0x0000, 6, 1)) return 1;
|
||||
|
||||
memcpy (DrvColPROM, DrvColPROM + 0x08, 8);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT32 MemIndex()
|
||||
{
|
||||
UINT8 *Next; Next = AllMem;
|
||||
|
||||
Drv6502ROM = Next; Next += 0x010000;
|
||||
|
||||
DrvGfxROM0 = Next; Next += 0x010000;
|
||||
DrvGfxROM1 = Next; Next += 0x010000;
|
||||
|
||||
DrvColPROM = Next; Next += 0x000020;
|
||||
|
||||
DrvPalette = (UINT32*)Next; Next += 0x0008 * sizeof(UINT32);
|
||||
|
||||
AllRam = Next;
|
||||
|
||||
Drv6502RAM = Next; Next += 0x000800;
|
||||
DrvVidRAM = Next; Next += 0x000400;
|
||||
DrvColRAM = Next; Next += 0x000400;
|
||||
|
||||
flipscreen = Next; Next += 0x000001;
|
||||
|
||||
RamEnd = Next;
|
||||
|
||||
MemEnd = Next;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT32 DrvInit(void (*m6502Init)(), INT32 (*pLoadCB)())
|
||||
{
|
||||
AllMem = NULL;
|
||||
MemIndex();
|
||||
INT32 nLen = MemEnd - (UINT8 *)0;
|
||||
if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
|
||||
memset(AllMem, 0, nLen);
|
||||
MemIndex();
|
||||
|
||||
if (pLoadCB) {
|
||||
if (pLoadCB()) return 1;
|
||||
|
||||
DrvGfxDecode();
|
||||
DrvPaletteInit();
|
||||
}
|
||||
|
||||
pFMBuffer = (INT16 *)BurnMalloc (nBurnSoundLen * 6 * sizeof(INT16));
|
||||
if (pFMBuffer == NULL) {
|
||||
return 1;
|
||||
if (m6502Init) {
|
||||
m6502Init();
|
||||
}
|
||||
|
||||
Rom = Mem + 0x00000;
|
||||
Gfx0 = Mem + 0x10000;
|
||||
Gfx1 = Mem + 0x20000;
|
||||
Prom = Mem + 0x30000;
|
||||
Palette = (UINT32*)(Mem + 0x30020);
|
||||
DrvPalette = (UINT32*)(Mem + 0x30040);
|
||||
|
||||
if (scregg)
|
||||
{
|
||||
if (rockduck) {
|
||||
if (BurnLoadRom(Rom + 0x4000, 0, 1)) return 1;
|
||||
if (BurnLoadRom(Rom + 0x6000, 1, 1)) return 1;
|
||||
if (BurnLoadRom(Rom + 0x8000, 2, 1)) return 1;
|
||||
memcpy (Rom + 0x3000, Rom + 0x5000, 0x1000);
|
||||
memcpy (Rom + 0x5000, Rom + 0x7000, 0x1000);
|
||||
memcpy (Rom + 0xe000, Rom + 0x8000, 0x2000);
|
||||
memcpy (Rom + 0x7000, Rom + 0x9000, 0x1000);
|
||||
|
||||
if (BurnLoadRom(Gfx0 + 0x0000, 3, 1)) return 1;
|
||||
if (BurnLoadRom(Gfx0 + 0x2000, 4, 1)) return 1;
|
||||
if (BurnLoadRom(Gfx0 + 0x4000, 5, 1)) return 1;
|
||||
|
||||
if (BurnLoadRom(Prom + 0x0000, 6, 1)) return 1;
|
||||
|
||||
for (INT32 i = 0x2000; i < 0x6000; i++)
|
||||
Gfx0[i] = BITSWAP08(Gfx0[i],2,0,3,6,1,4,7,5);
|
||||
|
||||
} else {
|
||||
for (INT32 i = 0; i < 5; i++)
|
||||
if (BurnLoadRom(Rom + 0x3000 + i * 0x1000, i, 1)) return 1;
|
||||
|
||||
memcpy (Rom + 0xf000, Rom + 0x7000, 0x1000);
|
||||
|
||||
for (INT32 i = 0; i < 6; i++)
|
||||
if (BurnLoadRom(Gfx0 + i * 0x1000, i + 5, 1)) return 1;
|
||||
|
||||
if (BurnLoadRom(Prom, 11, 1)) return 1;
|
||||
}
|
||||
|
||||
M6502Init(0, TYPE_M6502);
|
||||
M6502Open(0);
|
||||
M6502SetReadHandler(eggs_readmem);
|
||||
M6502SetWriteHandler(eggs_writemem);
|
||||
M6502SetReadMemIndexHandler(eggs_readmem);
|
||||
M6502SetWriteMemIndexHandler(eggs_writemem);
|
||||
M6502SetReadOpHandler(eggs_readmem);
|
||||
M6502SetReadOpArgHandler(eggs_readmem);
|
||||
M6502MapMemory(Rom + 0x0000, 0x0000, 0x07ff, M6502_RAM);
|
||||
M6502MapMemory(Rom + 0x2000, 0x1000, 0x17ff, M6502_RAM);
|
||||
M6502MapMemory(Rom + 0x3000, 0x3000, 0x7fff, M6502_ROM);
|
||||
M6502MapMemory(Rom + 0xf000, 0xf000, 0xffff, M6502_ROM);
|
||||
M6502Close();
|
||||
} else {
|
||||
for (INT32 i = 0; i < 3; i++) {
|
||||
if (BurnLoadRom(Rom + 0xa000 + i * 0x2000, i, 1)) return 1;
|
||||
if (BurnLoadRom(Gfx0 + 0x0000 + i * 0x2000, 3 + i, 1)) return 1;
|
||||
}
|
||||
|
||||
if (BurnLoadRom(Prom, 6, 1)) return 1;
|
||||
memcpy (Prom, Prom + 0x18, 8);
|
||||
|
||||
M6502Init(0, TYPE_M6502);
|
||||
M6502Open(0);
|
||||
M6502SetReadHandler(dommy_readmem);
|
||||
M6502SetWriteHandler(dommy_writemem);
|
||||
M6502SetReadMemIndexHandler(dommy_readmem);
|
||||
M6502SetWriteMemIndexHandler(dommy_writemem);
|
||||
M6502SetReadOpHandler(dommy_readmem);
|
||||
M6502SetReadOpArgHandler(dommy_readmem);
|
||||
M6502MapMemory(Rom + 0x0000, 0x0000, 0x07ff, M6502_RAM);
|
||||
M6502MapMemory(Rom + 0x2000, 0x2000, 0x27ff, M6502_RAM);
|
||||
M6502MapMemory(Rom + 0xa000, 0xa000, 0xffff, M6502_ROM);
|
||||
M6502Close();
|
||||
}
|
||||
|
||||
scregg_gfx_convert();
|
||||
scregg_palette_init();
|
||||
|
||||
// BurnSetRefreshRate(57); // Proper rate, but the AY8910 can't handle it
|
||||
|
||||
GenericTilesInit();
|
||||
|
||||
pAY8910Buffer[0] = pFMBuffer + nBurnSoundLen * 0;
|
||||
pAY8910Buffer[1] = pFMBuffer + nBurnSoundLen * 1;
|
||||
pAY8910Buffer[2] = pFMBuffer + nBurnSoundLen * 2;
|
||||
pAY8910Buffer[3] = pFMBuffer + nBurnSoundLen * 3;
|
||||
pAY8910Buffer[4] = pFMBuffer + nBurnSoundLen * 4;
|
||||
pAY8910Buffer[5] = pFMBuffer + nBurnSoundLen * 5;
|
||||
BurnSetRefreshRate(57);
|
||||
|
||||
AY8910Init(0, 1500000, nBurnSoundRate, NULL, NULL, NULL, NULL);
|
||||
AY8910Init(1, 1500000, nBurnSoundRate, NULL, NULL, NULL, NULL);
|
||||
AY8910SetAllRoutes(0, 0.23, BURN_SND_ROUTE_BOTH);
|
||||
AY8910SetAllRoutes(1, 0.23, BURN_SND_ROUTE_BOTH);
|
||||
|
||||
GenericTilesInit();
|
||||
|
||||
DrvDoReset();
|
||||
|
||||
return 0;
|
||||
|
@ -390,67 +446,50 @@ static INT32 DrvInit()
|
|||
|
||||
static INT32 DrvExit()
|
||||
{
|
||||
GenericTilesExit();
|
||||
|
||||
M6502Exit();
|
||||
AY8910Exit(0);
|
||||
AY8910Exit(1);
|
||||
GenericTilesExit();
|
||||
|
||||
BurnFree (Mem);
|
||||
BurnFree (AllMem);
|
||||
BurnFree (pFMBuffer);
|
||||
|
||||
DrvRecalcPal = 0;
|
||||
flipscreen = 0;
|
||||
|
||||
scregg = rockduck = 0;
|
||||
VBLK = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void draw_chars()
|
||||
static void draw_layer()
|
||||
{
|
||||
for (INT32 offs = 0; offs < 0x400; offs++)
|
||||
{
|
||||
INT32 sx = (~offs >> 2) & 0xf8;
|
||||
INT32 sy = ( offs & 0x1f) << 3;
|
||||
|
||||
UINT16 code = Rom[0x2000 | offs] | ((Rom[0x2400 | offs] & 3) << 8);
|
||||
UINT16 code = DrvVidRAM[offs] | ((DrvColRAM[offs] & 3) << 8);
|
||||
|
||||
if (flipscreen)
|
||||
{
|
||||
sx ^= 0xf8;
|
||||
sy ^= 0xf8;
|
||||
}
|
||||
|
||||
sy -= 8;
|
||||
if (scregg) sx -= 8;
|
||||
|
||||
if (flipscreen) {
|
||||
Render8x8Tile_FlipXY_Clip(pTransDraw, code, sx, sy, 0, 3, 0, Gfx0);
|
||||
if (*flipscreen) {
|
||||
Render8x8Tile_FlipXY_Clip(pTransDraw, code, (sx ^ 0xf8) - 8, (sy ^ 0xf8) - 8, 0, 3, 0, DrvGfxROM0);
|
||||
} else {
|
||||
Render8x8Tile_Clip(pTransDraw, code, sx, sy, 0, 3, 0, Gfx0);
|
||||
Render8x8Tile_Clip(pTransDraw, code, sx - 8, sy - 8, 0, 3, 0, DrvGfxROM0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_sprites()
|
||||
{
|
||||
for (INT32 i = 0, offs = 0; i < 8; i++, offs += 4*0x20)
|
||||
for (INT32 i = 0, offs = 0; i < 8; i++, offs += 0x80)
|
||||
{
|
||||
INT32 sx, sy, code;
|
||||
UINT8 flipx,flipy;
|
||||
if (~DrvVidRAM[offs] & 0x01) continue;
|
||||
|
||||
if (!(Rom[0x2000 + offs] & 0x01)) continue;
|
||||
INT32 sx = 240 - DrvVidRAM[offs + 0x60];
|
||||
INT32 sy = 240 - DrvVidRAM[offs + 0x40];
|
||||
|
||||
sx = 240 - Rom[0x2000 + offs + 0x60];
|
||||
sy = 240 - Rom[0x2000 + offs + 0x40];
|
||||
INT32 flipx = DrvVidRAM[offs] & 0x04;
|
||||
INT32 flipy = DrvVidRAM[offs] & 0x02;
|
||||
|
||||
flipx = Rom[0x2000 + offs] & 0x04;
|
||||
flipy = Rom[0x2000 + offs] & 0x02;
|
||||
INT32 code = DrvVidRAM[offs + 0x20];
|
||||
|
||||
code = Rom[0x2000 + offs + 0x20];
|
||||
|
||||
if (flipscreen)
|
||||
if (*flipscreen)
|
||||
{
|
||||
sx = 240 - sx;
|
||||
sy = 240 - sy;
|
||||
|
@ -459,20 +498,17 @@ static void draw_sprites()
|
|||
flipy = !flipy;
|
||||
}
|
||||
|
||||
sy -= 8;
|
||||
if (scregg) sx -= 8;
|
||||
|
||||
if (flipy) {
|
||||
if (flipx) {
|
||||
Render16x16Tile_Mask_FlipXY_Clip(pTransDraw, code, sx, sy, 0, 3, 0, 0, Gfx1);
|
||||
Render16x16Tile_Mask_FlipXY_Clip(pTransDraw, code, sx - 8, sy - 8, 0, 3, 0, 0, DrvGfxROM1);
|
||||
} else {
|
||||
Render16x16Tile_Mask_FlipY_Clip(pTransDraw, code, sx, sy, 0, 3, 0, 0, Gfx1);
|
||||
Render16x16Tile_Mask_FlipY_Clip(pTransDraw, code, sx - 8, sy - 8, 0, 3, 0, 0, DrvGfxROM1);
|
||||
}
|
||||
} else {
|
||||
if (flipx) {
|
||||
Render16x16Tile_Mask_FlipX_Clip(pTransDraw, code, sx, sy, 0, 3, 0, 0, Gfx1);
|
||||
Render16x16Tile_Mask_FlipX_Clip(pTransDraw, code, sx - 8, sy - 8, 0, 3, 0, 0, DrvGfxROM1);
|
||||
} else {
|
||||
Render16x16Tile_Mask_Clip(pTransDraw, code, sx, sy, 0, 3, 0, 0, Gfx1);
|
||||
Render16x16Tile_Mask_Clip(pTransDraw, code, sx - 8, sy - 8, 0, 3, 0, 0, DrvGfxROM1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -480,15 +516,12 @@ static void draw_sprites()
|
|||
|
||||
static INT32 DrvDraw()
|
||||
{
|
||||
// check to see if we need to recalculate the palette
|
||||
if (DrvRecalcPal) {
|
||||
for (INT32 i = 0; i < 8; i++) {
|
||||
INT32 col = Palette[i];
|
||||
DrvPalette[i] = BurnHighCol(col >> 16, col >> 8, col, 0);
|
||||
}
|
||||
if (DrvRecalc) {
|
||||
DrvPaletteInit();
|
||||
DrvRecalc = 0;
|
||||
}
|
||||
|
||||
draw_chars();
|
||||
draw_layer();
|
||||
draw_sprites();
|
||||
|
||||
BurnTransferCopy(DrvPalette);
|
||||
|
@ -496,31 +529,36 @@ static INT32 DrvDraw()
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline void scregg_interrupt_handler(INT32 scanline)
|
||||
{
|
||||
if (scanline == 0)
|
||||
VBLK = 0;
|
||||
|
||||
if (scanline == 14)
|
||||
VBLK = 0x80;
|
||||
|
||||
M6502SetIRQLine(M6502_IRQ_LINE, M6502_IRQSTATUS_AUTO);
|
||||
}
|
||||
|
||||
static INT32 DrvFrame()
|
||||
{
|
||||
DrvDelayAY8910BufferAllocation();
|
||||
|
||||
if (DrvReset) {
|
||||
DrvDoReset();
|
||||
}
|
||||
|
||||
INT32 nTotalCycles = (INT32)((double)(1500000 / 57));
|
||||
{
|
||||
memset (DrvInputs, 0xff, 2 * sizeof(UINT8));
|
||||
|
||||
for (INT32 i = 0; i < 8; i++) {
|
||||
DrvInputs[0] ^= (DrvJoy1[i] & 1) << i;
|
||||
DrvInputs[1] ^= (DrvJoy2[i] & 1) << i;
|
||||
}
|
||||
}
|
||||
|
||||
INT32 nInterleave = 32;
|
||||
INT32 nTotalCycles = 1500000 / 57;
|
||||
INT32 nCyclesRun = 0;
|
||||
|
||||
M6502Open(0);
|
||||
|
||||
for (INT32 i = 0; i < 16; i++) {
|
||||
nCyclesRun += M6502Run((nTotalCycles - nCyclesRun) / (16 - i));
|
||||
scregg_interrupt_handler(i);
|
||||
vblank = 0;
|
||||
|
||||
for (INT32 i = 0; i < nInterleave; i++) {
|
||||
nCyclesRun += M6502Run(nTotalCycles / nInterleave);
|
||||
M6502SetIRQLine(M6502_IRQ_LINE, (i & 1) ? M6502_IRQSTATUS_ACK : M6502_IRQSTATUS_NONE);
|
||||
|
||||
if (i == 28) vblank = 0x80;
|
||||
}
|
||||
|
||||
M6502Close();
|
||||
|
@ -536,7 +574,6 @@ static INT32 DrvFrame()
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static INT32 DrvScan(INT32 nAction,INT32 *pnMin)
|
||||
{
|
||||
struct BurnArea ba;
|
||||
|
@ -547,17 +584,13 @@ static INT32 DrvScan(INT32 nAction,INT32 *pnMin)
|
|||
|
||||
if (nAction & ACB_VOLATILE) {
|
||||
memset(&ba, 0, sizeof(ba));
|
||||
|
||||
ba.Data = Rom + 0x0000;
|
||||
ba.nLen = 0x3000;
|
||||
ba.Data = AllRam;
|
||||
ba.nLen = RamEnd - AllRam;
|
||||
ba.szName = "All Ram";
|
||||
BurnAcb(&ba);
|
||||
|
||||
M6502Scan(nAction);
|
||||
AY8910Scan(nAction, pnMin);
|
||||
|
||||
// Scan critical driver variables
|
||||
SCAN_VAR(flipscreen);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -583,13 +616,18 @@ static struct BurnRomInfo dommyRomDesc[] = {
|
|||
STD_ROM_PICK(dommy)
|
||||
STD_ROM_FN(dommy)
|
||||
|
||||
static INT32 dommyInit()
|
||||
{
|
||||
return DrvInit(dommy6502Init, dommyLoadRoms);
|
||||
}
|
||||
|
||||
struct BurnDriver BurnDrvdommy = {
|
||||
"dommy", NULL, NULL, NULL, "198?",
|
||||
"Dommy\0", NULL, "Technos", "Miscellaneous",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_TECHNOS, GBF_MAZE, 0,
|
||||
NULL, dommyRomInfo, dommyRomName, NULL, NULL, DrvInputInfo, DrvDIPInfo,
|
||||
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalcPal, 0x08,
|
||||
dommyInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x08,
|
||||
240, 248, 3, 4
|
||||
};
|
||||
|
||||
|
@ -620,9 +658,7 @@ STD_ROM_FN(scregg)
|
|||
|
||||
static INT32 screggInit()
|
||||
{
|
||||
scregg = 1;
|
||||
|
||||
return DrvInit();
|
||||
return DrvInit(scregg6502Init, screggLoadRoms);
|
||||
}
|
||||
|
||||
struct BurnDriver BurnDrvscregg = {
|
||||
|
@ -631,7 +667,7 @@ struct BurnDriver BurnDrvscregg = {
|
|||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_TECHNOS, GBF_MAZE, 0,
|
||||
NULL, screggRomInfo, screggRomName, NULL, NULL, DrvInputInfo, DrvDIPInfo,
|
||||
screggInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalcPal, 0x08,
|
||||
screggInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x08,
|
||||
240, 240, 3, 4
|
||||
};
|
||||
|
||||
|
@ -666,7 +702,7 @@ struct BurnDriver BurnDrveggs = {
|
|||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_TECHNOS, GBF_MAZE, 0,
|
||||
NULL, eggsRomInfo, eggsRomName, NULL, NULL, DrvInputInfo, DrvDIPInfo,
|
||||
screggInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalcPal, 0x08,
|
||||
screggInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x08,
|
||||
240, 240, 3, 4
|
||||
};
|
||||
|
||||
|
@ -678,12 +714,11 @@ static struct BurnRomInfo rockduckRomDesc[] = {
|
|||
{ "rdc.bin", 0x2000, 0x482d9a0c, 1 | BRF_ESS | BRF_PRG }, // 1
|
||||
{ "rdb.bin", 0x2000, 0x974626f2, 1 | BRF_ESS | BRF_PRG }, // 2
|
||||
|
||||
|
||||
{ "rd3.rdg", 0x2000, 0x8a3f1e53, 2 | BRF_GRA }, // 3 Graphics
|
||||
{ "rd2.rdh", 0x2000, 0xe94e673e, 2 | BRF_GRA }, // 4
|
||||
{ "rd1.rdj", 0x2000, 0x654afff2, 2 | BRF_GRA }, // 5
|
||||
|
||||
{ "eggs.c6", 0x0020, 0xe8408c81, 3 | BRF_GRA }, // 6 Palette
|
||||
{ "eggs.c6", 0x0020, 0xe8408c81, 3 | BRF_GRA }, // 6 Palette
|
||||
};
|
||||
|
||||
STD_ROM_PICK(rockduck)
|
||||
|
@ -691,10 +726,7 @@ STD_ROM_FN(rockduck)
|
|||
|
||||
static INT32 rockduckInit()
|
||||
{
|
||||
scregg = 1;
|
||||
rockduck = 1;
|
||||
|
||||
return DrvInit();
|
||||
return DrvInit(scregg6502Init, rockduckLoadRoms);
|
||||
}
|
||||
|
||||
struct BurnDriver BurnDrvrockduck = {
|
||||
|
@ -703,6 +735,6 @@ struct BurnDriver BurnDrvrockduck = {
|
|||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_TECHNOS, GBF_MAZE, 0,
|
||||
NULL, rockduckRomInfo, rockduckRomName, NULL, NULL, DrvInputInfo, DrvDIPInfo,
|
||||
rockduckInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalcPal, 0x08,
|
||||
rockduckInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x08,
|
||||
240, 240, 3, 4
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue