mirror of
https://github.com/libretro/FBNeo.git
synced 2024-11-23 08:59:39 +00:00
Add 20Pacgal, add z180 interface with support for all the bells and whistles. Update ghox.
This commit is contained in:
parent
426d33b556
commit
4ac641e4ad
@ -59,7 +59,7 @@ drvsrc = d_dodonpachi.o d_donpachi.o d_esprade.o d_feversos.o d_gaia.o d_guwang
|
||||
d_tigeroad.o d_timelimt.o d_toki.o d_toypop.o d_travrusa.o d_tsamurai.o d_twincobr.o d_usgames.o d_vastar.o d_vulgus.o d_wallc.o d_warpwarp.o d_wc90.o \
|
||||
d_wc90b.o d_wiping.o d_wiz.o d_wrally.o d_wwfsstar.o d_xain.o d_xxmissio.o d_zodiack.o \
|
||||
\
|
||||
d_1945kiii.o d_aerofgt.o d_airbustr.o d_aquarium.o d_bestleag.o d_bigstrkb.o d_blmbycar.o d_bloodbro.o d_crospang.o d_crshrace.o d_dcon.o \
|
||||
d_1945kiii.o d_20pacgal.o d_aerofgt.o d_airbustr.o d_aquarium.o d_bestleag.o d_bigstrkb.o d_blmbycar.o d_bloodbro.o d_crospang.o d_crshrace.o d_dcon.o \
|
||||
d_ddragon3.o d_deniam.o d_diverboy.o d_dooyong.o d_dreamwld.o d_drgnmst.o d_drtomy.o d_egghunt.o d_esd16.o d_f1gp.o d_funybubl.o d_fuukifg2.o \
|
||||
d_fuukifg3.o d_gaelco.o d_gaelco2.o d_gaiden.o d_galpanic.o d_galspnbl.o d_glass.o d_gotcha.o d_gumbo.o d_hyperpac.o d_jchan.o d_kaneko16.o d_lordgun.o \
|
||||
d_macrossp.o d_mcatadv.o d_metro.o d_midas.o d_mugsmash.o d_mwarr.o d_namcos2.o d_news.o d_nmg5.o d_nmk16.o d_ohmygod.o d_onetwo.o d_pass.o d_patapata.o \
|
||||
@ -101,7 +101,7 @@ depobj = burn.o burn_gun.o burn_led.o burn_shift.o burn_memory.o burn_pal.o bur
|
||||
ymdeltat.o ymf278b.o ymz280b.o \
|
||||
\
|
||||
arm7_intf.o arm_intf.o h6280_intf.o hd6309_intf.o konami_intf.o m6502_intf.o m6800_intf.o m6805_intf.o m6809_intf.o \
|
||||
m68000_intf.o nec_intf.o pic16c5x_intf.o s2650_intf.o tlcs90_intf.o z80_intf.o \
|
||||
m68000_intf.o nec_intf.o pic16c5x_intf.o s2650_intf.o tlcs90_intf.o z80_intf.o z180_intf.o \
|
||||
\
|
||||
arm.o arm7.o h6280.o hd6309.o i8039.o i8x41.o mcs51.o konami.o m6502.o m6800.o m6805.o m6809.o nec.o pic16c5x.o s2650.o sh2.o tms32010.o tlcs90.o \
|
||||
upd7725.o upd7810.o v25.o v60.o z80.o z80daisy.o z180.o \
|
||||
|
856
src/burn/drv/pst90s/d_20pacgal.cpp
Normal file
856
src/burn/drv/pst90s/d_20pacgal.cpp
Normal file
@ -0,0 +1,856 @@
|
||||
// FB Alpha Ms. Pac-Man/Galaga - 20th Anniversary Class of 1981 Reunion / Pac-Man - 25th Anniversary Edition driver module
|
||||
// Based on MAME driver by Nicola Salmoria
|
||||
|
||||
// to do
|
||||
// 20pacgal cannot select Galaga :/
|
||||
// 20pacgal pacman sounds bad...
|
||||
|
||||
#include "tiles_generic.h"
|
||||
#include "z180_intf.h"
|
||||
#include "namco_snd.h"
|
||||
#include "dac.h"
|
||||
#include "eeprom.h"
|
||||
#include "watchdog.h"
|
||||
|
||||
static UINT8 *AllMem;
|
||||
static UINT8 *MemEnd;
|
||||
static UINT8 *AllRam;
|
||||
static UINT8 *RamEnd;
|
||||
static UINT8 *DrvZ180ROM;
|
||||
static UINT8 *DrvColPROM;
|
||||
static UINT8 *DrvZ180RAM;
|
||||
static UINT8 *DrvCharRAM;
|
||||
static UINT8 *DrvVidRAM;
|
||||
static UINT8 *DrvSprRAM;
|
||||
static UINT8 *DrvSprLut;
|
||||
static UINT8 *DrvSprGfx;
|
||||
static UINT8 *Drv48000RAM;
|
||||
|
||||
static UINT32 *DrvPalette;
|
||||
static UINT8 DrvRecalc;
|
||||
|
||||
static UINT8 game_selected;
|
||||
static UINT8 stars_seed[2];
|
||||
static UINT8 stars_ctrl;
|
||||
static UINT8 global_flip;
|
||||
static UINT8 irq_mask;
|
||||
static UINT8 _47100_val;
|
||||
|
||||
static UINT8 DrvJoy1[8];
|
||||
static UINT8 DrvJoy2[8];
|
||||
static UINT8 DrvJoy3[8];
|
||||
static UINT8 DrvInputs[3];
|
||||
static UINT8 DrvDips[1];
|
||||
static UINT8 DrvReset;
|
||||
|
||||
static UINT32 sprite_pal_base = 0;
|
||||
|
||||
static struct BurnInputInfo Pacgal20InputList[] = {
|
||||
{"P1 Coin", BIT_DIGITAL, DrvJoy1 + 5, "p1 coin" },
|
||||
{"P1 Start", BIT_DIGITAL, DrvJoy2 + 5, "p1 start" },
|
||||
{"P1 Up", BIT_DIGITAL, DrvJoy1 + 0, "p1 up" },
|
||||
{"P1 Down", BIT_DIGITAL, DrvJoy1 + 3, "p1 down" },
|
||||
{"P1 Left", BIT_DIGITAL, DrvJoy1 + 1, "p1 left" },
|
||||
{"P1 Right", BIT_DIGITAL, DrvJoy1 + 2, "p1 right" },
|
||||
{"P1 Button 1", BIT_DIGITAL, DrvJoy1 + 7, "p1 fire 1" },
|
||||
|
||||
{"P2 Coin", BIT_DIGITAL, DrvJoy1 + 6, "p2 coin" },
|
||||
{"P2 Start", BIT_DIGITAL, DrvJoy2 + 6, "p2 start" },
|
||||
{"P2 Up", BIT_DIGITAL, DrvJoy2 + 0, "p2 up" },
|
||||
{"P2 Down", BIT_DIGITAL, DrvJoy2 + 3, "p2 down" },
|
||||
{"P2 Left", BIT_DIGITAL, DrvJoy2 + 1, "p2 left" },
|
||||
{"P2 Right", BIT_DIGITAL, DrvJoy2 + 2, "p2 right" },
|
||||
{"P2 Button 1", BIT_DIGITAL, DrvJoy1 + 4, "p2 fire 1" },
|
||||
|
||||
{"Reset", BIT_DIGITAL, &DrvReset, "reset" },
|
||||
{"Dip A", BIT_DIPSWITCH, DrvDips + 0, "dip" },
|
||||
};
|
||||
|
||||
STDINPUTINFO(Pacgal20)
|
||||
|
||||
static struct BurnDIPInfo Pacgal20DIPList[]=
|
||||
{
|
||||
{0x0f, 0xff, 0xff, 0x80, NULL },
|
||||
|
||||
{0 , 0xfe, 0 , 2, "Service Mode" },
|
||||
{0x0f, 0x01, 0x80, 0x80, "Off" },
|
||||
{0x0f, 0x01, 0x80, 0x00, "On" },
|
||||
};
|
||||
|
||||
STDDIPINFO(Pacgal20)
|
||||
|
||||
static void set_bank(INT32 select)
|
||||
{
|
||||
if (select == 0)
|
||||
{
|
||||
Z180MapMemory(DrvZ180ROM + 0x08000, 0x48000, 0x49fff, MAP_ROM);
|
||||
Z180MapMemory(NULL, 0x48000, 0x49fff, MAP_WRITE);
|
||||
}
|
||||
else
|
||||
{
|
||||
Z180MapMemory(DrvVidRAM, 0x48000, 0x487ff, MAP_RAM);
|
||||
Z180MapMemory(Drv48000RAM, 0x48800, 0x49fff, MAP_RAM);
|
||||
}
|
||||
}
|
||||
|
||||
static UINT8 __fastcall pacgal20_read(UINT32 address)
|
||||
{
|
||||
switch (address)
|
||||
{
|
||||
case 0x47100:
|
||||
return _47100_val;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __fastcall pacgal20_write(UINT32 address, UINT8 data)
|
||||
{
|
||||
if (address >= 0x45040 && address <= 0x4505f) {
|
||||
NamcoSoundWrite(address & 0x1f, data);
|
||||
}
|
||||
|
||||
if (address >= 0x45000 && address <= 0x450ff) {
|
||||
DrvZ180RAM[address - 0x44800] = data;
|
||||
return;
|
||||
}
|
||||
|
||||
if (address >= 0x45f00 && address <= 0x45fff) {
|
||||
namcos1_custom30_write(address & 0xff, data);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (address)
|
||||
{
|
||||
case 0x47100:
|
||||
_47100_val = data;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void __fastcall pacgal20_write_port(UINT32 address, UINT8 data)
|
||||
{
|
||||
address &= 0xff;
|
||||
|
||||
if (address <= 0x7f) return; // z180 internal regs
|
||||
|
||||
switch (address)
|
||||
{
|
||||
case 0x80:
|
||||
BurnWatchogWrite();
|
||||
return;
|
||||
|
||||
case 0x81:
|
||||
// timer_pulse_w (unemulated)
|
||||
return;
|
||||
|
||||
case 0x82:
|
||||
irq_mask = data & 1;
|
||||
if (~data & 1) Z180SetIRQLine(0, CPU_IRQSTATUS_NONE);
|
||||
return;
|
||||
|
||||
case 0x85:
|
||||
case 0x86:
|
||||
stars_seed[address - 0x85] = data;
|
||||
return;
|
||||
|
||||
case 0x87:
|
||||
EEPROMWriteBit((data & 0x80) ? 1 : 0);
|
||||
EEPROMSetCSLine((data & 0x20) ? 0 : 1);
|
||||
EEPROMSetClockLine((data & 0x40) ? 1 : 0);
|
||||
return;
|
||||
|
||||
case 0x88:
|
||||
game_selected = data & 1;
|
||||
set_bank(data & 1);
|
||||
return;
|
||||
|
||||
case 0x89:
|
||||
DACWrite(0,data);
|
||||
return;
|
||||
|
||||
case 0x8a:
|
||||
stars_ctrl = data;
|
||||
return;
|
||||
|
||||
case 0x8b:
|
||||
global_flip = data;
|
||||
return;
|
||||
|
||||
case 0x8f:
|
||||
// coin_counter_w
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static UINT8 __fastcall pacgal20_read_port(UINT32 address)
|
||||
{
|
||||
address &= 0xff;
|
||||
|
||||
if (address <= 0x7f) return 0; // z180 internal regs
|
||||
|
||||
switch (address)
|
||||
{
|
||||
case 0x80:
|
||||
case 0x81:
|
||||
case 0x82:
|
||||
return DrvInputs[address & 3];
|
||||
|
||||
case 0x87:
|
||||
return EEPROMRead() ? 0x80 : 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT32 DrvSyncDAC()
|
||||
{
|
||||
return (INT32)(float)(nBurnSoundLen * (Z180TotalCycles() / (18432000 / 60)));
|
||||
}
|
||||
|
||||
static INT32 DrvDoReset(INT32 clear_mem)
|
||||
{
|
||||
if (clear_mem) {
|
||||
memset(AllRam, 0, RamEnd - AllRam);
|
||||
}
|
||||
|
||||
Z180Open(0);
|
||||
Z180Reset();
|
||||
set_bank(0);
|
||||
Z180Close();
|
||||
|
||||
EEPROMReset();
|
||||
|
||||
BurnWatchdogReset();
|
||||
|
||||
NamcoSoundReset();
|
||||
DACReset();
|
||||
|
||||
stars_seed[0] = stars_seed[1] = 0;
|
||||
stars_ctrl = 0;
|
||||
global_flip = 0;
|
||||
irq_mask = 0;
|
||||
_47100_val = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT32 MemIndex()
|
||||
{
|
||||
UINT8 *Next; Next = AllMem;
|
||||
|
||||
DrvZ180ROM = Next; Next += 0x040000;
|
||||
|
||||
DrvColPROM = Next; Next += 0x008000;
|
||||
|
||||
DrvPalette = (UINT32*)Next; Next += 0x1040 * sizeof(UINT32);
|
||||
|
||||
AllRam = Next;
|
||||
|
||||
DrvZ180RAM = Next; Next += 0x001800;
|
||||
DrvCharRAM = Next; Next += 0x001000;
|
||||
DrvVidRAM = Next; Next += 0x000800;
|
||||
DrvSprRAM = Next; Next += 0x001f00;
|
||||
DrvSprLut = Next; Next += 0x000100;
|
||||
DrvSprGfx = Next; Next += 0x002000;
|
||||
Drv48000RAM = Next; Next += 0x002000;
|
||||
|
||||
RamEnd = Next;
|
||||
|
||||
MemEnd = Next;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const eeprom_interface eeprom_interface_20pacgal =
|
||||
{
|
||||
7, // address bits
|
||||
8, // data bits
|
||||
"*110", // read command
|
||||
"*101", // write command
|
||||
0, // erase command
|
||||
"*10000xxxxx", // lock command
|
||||
"*10011xxxxx", // unlock command
|
||||
1, // 1?
|
||||
0
|
||||
};
|
||||
|
||||
static INT32 DrvInit()
|
||||
{
|
||||
AllMem = NULL;
|
||||
MemIndex();
|
||||
INT32 nLen = MemEnd - (UINT8 *)0;
|
||||
if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
|
||||
memset(AllMem, 0, nLen);
|
||||
MemIndex();
|
||||
|
||||
{
|
||||
if (BurnLoadRom(DrvZ180ROM, 0, 1)) return 1;
|
||||
|
||||
if (BurnLoadRom(DrvColPROM, 1, 1)) return 1;
|
||||
}
|
||||
|
||||
Z180Init(18432000);
|
||||
Z180Open(0);
|
||||
Z180MapMemory(DrvZ180ROM, 0x00000, 0x3ffff, MAP_ROM);
|
||||
Z180MapMemory(DrvVidRAM, 0x44000, 0x447ff, MAP_RAM);
|
||||
Z180MapMemory(DrvZ180RAM, 0x44800, 0x44fff, MAP_RAM);
|
||||
Z180MapMemory(DrvZ180RAM + 0x0800, 0x45000, 0x450ff, MAP_ROM);
|
||||
Z180MapMemory(DrvZ180RAM + 0x0900, 0x45100, 0x45eff, MAP_RAM);
|
||||
Z180MapMemory(DrvZ180ROM + 0xa000, 0x4a000, 0x4ffff, MAP_ROM);
|
||||
Z180MapMemory(DrvCharRAM, 0x46000, 0x46fff, MAP_WRITE);
|
||||
Z180MapMemory(DrvSprGfx, 0x4c000, 0x4dfff, MAP_WRITE);
|
||||
Z180MapMemory(DrvSprRAM, 0x4e000, 0x4feff, MAP_WRITE);
|
||||
Z180MapMemory(DrvSprLut, 0x4ff00, 0x4ffff, MAP_WRITE);
|
||||
Z180SetReadHandler(pacgal20_read);
|
||||
Z180SetWriteHandler(pacgal20_write);
|
||||
Z180SetReadPortHandler(pacgal20_read_port);
|
||||
Z180SetWritePortHandler(pacgal20_write_port);
|
||||
Z180Close();
|
||||
|
||||
NamcoSoundInit(18432000 / 4 / 6 / 32, 3, 0);
|
||||
NacmoSoundSetAllRoutes(1.00, BURN_SND_ROUTE_BOTH);
|
||||
|
||||
DACInit(0, 0, 1, DrvSyncDAC);
|
||||
DACSetRoute(0, 0.30, BURN_SND_ROUTE_BOTH);
|
||||
|
||||
BurnWatchdogInit(DrvDoReset, 180);
|
||||
|
||||
EEPROMInit(&eeprom_interface_20pacgal);
|
||||
|
||||
GenericTilesInit();
|
||||
|
||||
DrvDoReset(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT32 DrvExit()
|
||||
{
|
||||
Z180Exit();
|
||||
DACExit();
|
||||
|
||||
EEPROMExit();
|
||||
|
||||
NamcoSoundExit();
|
||||
|
||||
BurnFree (AllMem);
|
||||
|
||||
sprite_pal_base = 0;
|
||||
|
||||
GenericTilesExit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void DrvPaletteInit()
|
||||
{
|
||||
for (INT32 offs = 0; offs < 0x1000 ;offs++)
|
||||
{
|
||||
INT32 bit0 = (DrvColPROM[offs] >> 0) & 0x01;
|
||||
INT32 bit1 = (DrvColPROM[offs] >> 1) & 0x01;
|
||||
INT32 bit2 = (DrvColPROM[offs] >> 2) & 0x01;
|
||||
INT32 r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
|
||||
|
||||
bit0 = (DrvColPROM[offs] >> 3) & 0x01;
|
||||
bit1 = (DrvColPROM[offs] >> 4) & 0x01;
|
||||
bit2 = (DrvColPROM[offs] >> 5) & 0x01;
|
||||
INT32 g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
|
||||
|
||||
bit1 = (DrvColPROM[offs] >> 6) & 0x01;
|
||||
bit2 = (DrvColPROM[offs] >> 7) & 0x01;
|
||||
INT32 b = 0x47 * bit1 + 0x97 * bit2;
|
||||
|
||||
DrvPalette[offs] = BurnHighCol(r, g, b, 0);
|
||||
}
|
||||
|
||||
for (INT32 offs = 0; offs < 64; offs++)
|
||||
{
|
||||
static const INT32 map[4] = { 0x00, 0x47, 0x97 ,0xde };
|
||||
|
||||
INT32 r = map[(offs >> 0) & 0x03];
|
||||
INT32 g = map[(offs >> 2) & 0x03];
|
||||
INT32 b = map[(offs >> 4) & 0x03];
|
||||
|
||||
DrvPalette[0x1000 + offs] = BurnHighCol(r, g, b, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_stars()
|
||||
{
|
||||
if ((stars_ctrl >> 5) & 1 )
|
||||
{
|
||||
UINT16 lfsr = stars_seed[0] + stars_seed[1]*256;
|
||||
UINT8 feedback = (stars_ctrl >> 6) & 1;
|
||||
UINT16 star_seta = 0x3fc0 | (((stars_ctrl >> 3) & 0x01) << 14);
|
||||
UINT16 star_setb = 0x3fc0 | (((stars_ctrl >> 3) & 0x02) << 14);
|
||||
INT32 cnt = 0;
|
||||
|
||||
for (INT32 clock = 0; clock < nScreenWidth*nScreenHeight; clock++)
|
||||
{
|
||||
INT32 x = clock % nScreenWidth;
|
||||
INT32 y = clock / nScreenWidth;
|
||||
|
||||
INT32 carryout = ((lfsr >> 4) ^ feedback ^ 1) & 1;
|
||||
feedback = (lfsr >> 15) & 1;
|
||||
lfsr = (lfsr << 1) | carryout;
|
||||
|
||||
if (((lfsr & 0xffc0) == star_seta) || ((lfsr & 0xffc0) == star_setb))
|
||||
{
|
||||
if (y >= 0 && y < nScreenHeight)
|
||||
pTransDraw[(y * nScreenWidth) + x] = 0x1000 + (lfsr & 0x3f);
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_chars()
|
||||
{
|
||||
INT32 flip = global_flip & 0x01;
|
||||
|
||||
for (INT32 offs = 0; offs < 0x400; offs++)
|
||||
{
|
||||
INT32 y, x;
|
||||
|
||||
UINT8 *gfx = DrvCharRAM + (DrvVidRAM[offs] << 4);
|
||||
UINT32 color_base = (DrvVidRAM[0x0400 | offs] & 0x3f) << 2;
|
||||
|
||||
if ((offs & 0x03c0) == 0)
|
||||
{
|
||||
y = (offs & 0x1f) - 2;
|
||||
x = (offs >> 5) + 34;
|
||||
}
|
||||
else if ((offs & 0x03c0) == 0x3c0)
|
||||
{
|
||||
y = (offs & 0x1f) - 2;
|
||||
x = (offs >> 5) - 30;
|
||||
}
|
||||
else
|
||||
{
|
||||
y = (offs >> 5) - 2;
|
||||
x = (offs & 0x1f) + 2;
|
||||
}
|
||||
|
||||
if ((y < 0) || (y > 27)) continue;
|
||||
|
||||
y = y << 3;
|
||||
x = x << 3;
|
||||
|
||||
if (flip)
|
||||
{
|
||||
y = nScreenHeight - 1 - y;
|
||||
x = nScreenWidth - 1 - x;
|
||||
}
|
||||
|
||||
for (INT32 sy = 0; sy < 8; sy++)
|
||||
{
|
||||
int x_sav = x;
|
||||
|
||||
UINT16 data = (gfx[8] << 8) | gfx[0];
|
||||
|
||||
for (INT32 sx = 0; sx < 8; sx++)
|
||||
{
|
||||
UINT8 col = ((data & 0x8000) >> 14) | ((data & 0x0800) >> 11);
|
||||
|
||||
if (col != 0)
|
||||
pTransDraw[(y * nScreenWidth) + x] = (color_base | col) << 4;
|
||||
|
||||
if (flip)
|
||||
x = x - 1;
|
||||
else
|
||||
x = x + 1;
|
||||
|
||||
if (sx == 0x03)
|
||||
data = data << 5;
|
||||
else
|
||||
data = data << 1;
|
||||
}
|
||||
|
||||
if (flip)
|
||||
y = y - 1;
|
||||
else
|
||||
y = y + 1;
|
||||
|
||||
x = x_sav;
|
||||
|
||||
gfx = gfx + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_sprite(int y, int x, UINT8 code, UINT8 color, int flip_y, int flip_x)
|
||||
{
|
||||
INT32 pen_base = (color & 0x1f) << 2;
|
||||
pen_base += sprite_pal_base;
|
||||
|
||||
if (flip_y) y = y + 0x0f;
|
||||
if (flip_x) x = x + 0x0f;
|
||||
|
||||
for (INT32 sy = 0; sy < 0x10; sy++)
|
||||
{
|
||||
INT32 x_sav = x;
|
||||
|
||||
if ((y >= 0) && (y < nScreenHeight))
|
||||
{
|
||||
UINT32 gfx_offs = ((code & 0x7f) << 6) | (sy << 2);
|
||||
|
||||
gfx_offs = (gfx_offs & 0x1f83) | ((gfx_offs & 0x003c) << 1) | ((gfx_offs & 0x0040) >> 4);
|
||||
|
||||
UINT32 data = (DrvSprGfx[gfx_offs + 0] << 24) | (DrvSprGfx[gfx_offs + 1] << 16) |
|
||||
(DrvSprGfx[gfx_offs + 2] << 8) | (DrvSprGfx[gfx_offs + 3] << 0);
|
||||
|
||||
for (INT32 sx = 0; sx < 0x10; sx++)
|
||||
{
|
||||
if ((x >= 0) && (x < nScreenWidth))
|
||||
{
|
||||
UINT32 pen = (data & 0xc0000000) >> 30;
|
||||
|
||||
UINT8 col = DrvSprLut[pen_base | pen] & 0x0f;
|
||||
|
||||
if (col)
|
||||
pTransDraw[(y * nScreenWidth) + x] = (pTransDraw[(y * nScreenWidth) + x] & 0xff0) | col;
|
||||
}
|
||||
|
||||
if (flip_x)
|
||||
x = x - 1;
|
||||
else
|
||||
x = x + 1;
|
||||
|
||||
data = data << 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (flip_y)
|
||||
y = y - 1;
|
||||
else
|
||||
y = y + 1;
|
||||
|
||||
x = x_sav;
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_sprites()
|
||||
{
|
||||
for (INT32 offs = 0x80 - 2; offs >= 0; offs -= 2)
|
||||
{
|
||||
static const int code_offs[2][2] =
|
||||
{
|
||||
{ 0, 1 },
|
||||
{ 2, 3 }
|
||||
};
|
||||
int x, y;
|
||||
|
||||
uint8_t code = DrvSprRAM[offs + 0x000];
|
||||
uint8_t color = DrvSprRAM[offs + 0x001];
|
||||
|
||||
int sx = DrvSprRAM[offs + 0x081] - 41 + 0x100*(DrvSprRAM[offs + 0x101] & 3);
|
||||
int sy = 256 - DrvSprRAM[offs + 0x080] + 1;
|
||||
|
||||
int flip_x = (DrvSprRAM[offs + 0x100] & 0x01) >> 0;
|
||||
int flip_y = (DrvSprRAM[offs + 0x100] & 0x02) >> 1;
|
||||
int size_x = (DrvSprRAM[offs + 0x100] & 0x04) >> 2;
|
||||
int size_y = (DrvSprRAM[offs + 0x100] & 0x08) >> 3;
|
||||
|
||||
sy = sy - (16 * size_y);
|
||||
sy = (sy & 0xff) - 32;
|
||||
|
||||
if (game_selected && (global_flip & 0x01))
|
||||
{
|
||||
flip_x = !flip_x;
|
||||
flip_y = !flip_y;
|
||||
}
|
||||
|
||||
for (y = 0; y <= size_y; y++)
|
||||
for (x = 0; x <= size_x; x++)
|
||||
draw_sprite(sy + (16 * y), sx + (16 * x),code + code_offs[y ^ (size_y * flip_y)][x ^ (size_x * flip_x)], color, flip_y, flip_x);
|
||||
}
|
||||
}
|
||||
|
||||
static INT32 DrvDraw()
|
||||
{
|
||||
if (DrvRecalc) {
|
||||
DrvPaletteInit();
|
||||
DrvRecalc = 0;
|
||||
}
|
||||
|
||||
BurnTransferClear();
|
||||
|
||||
draw_stars();
|
||||
draw_chars();
|
||||
draw_sprites();
|
||||
|
||||
BurnTransferCopy(DrvPalette);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT32 DrvFrame()
|
||||
{
|
||||
BurnWatchdogUpdate();
|
||||
|
||||
if (DrvReset) {
|
||||
DrvDoReset(0);
|
||||
}
|
||||
|
||||
Z180NewFrame();
|
||||
|
||||
{
|
||||
memset (DrvInputs, 0xff, 3);
|
||||
|
||||
DrvInputs[2] = (DrvDips[0] & 0x80) | (DrvInputs[2] & 0x7f);
|
||||
|
||||
for (INT32 i = 0; i < 8; i++) {
|
||||
DrvInputs[0] ^= (DrvJoy1[i] & 1) << i;
|
||||
DrvInputs[1] ^= (DrvJoy2[i] & 1) << i;
|
||||
DrvInputs[2] ^= (DrvJoy3[i] & 1) << i;
|
||||
}
|
||||
|
||||
if (sprite_pal_base) // 25pacmano
|
||||
DrvInputs[2] ^= 0x7e;
|
||||
}
|
||||
|
||||
INT32 nInterleave = 224; // ?
|
||||
INT32 nCyclesTotal[1] = { 18432000 / 60 };
|
||||
INT32 nCyclesDone[1] = { 0 };
|
||||
|
||||
Z180Open(0);
|
||||
|
||||
for (INT32 i = 0; i < nInterleave; i++)
|
||||
{
|
||||
nCyclesDone[0] += Z180Run(nCyclesTotal[0] / nInterleave);
|
||||
|
||||
if (i == (nInterleave - 1) && irq_mask) Z180SetIRQLine(0, CPU_IRQSTATUS_ACK); // hold?
|
||||
}
|
||||
|
||||
if (pBurnSoundOut) {
|
||||
NamcoSoundUpdate(pBurnSoundOut, nBurnSoundLen);
|
||||
DACUpdate(pBurnSoundOut, nBurnSoundLen);
|
||||
}
|
||||
|
||||
Z180Close();
|
||||
|
||||
if (pBurnDraw) {
|
||||
DrvDraw();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
|
||||
{
|
||||
struct BurnArea ba;
|
||||
|
||||
if (pnMin != NULL) {
|
||||
*pnMin = 0x029737;
|
||||
}
|
||||
|
||||
if (nAction & ACB_MEMORY_RAM) {
|
||||
memset(&ba, 0, sizeof(ba));
|
||||
ba.Data = AllRam;
|
||||
ba.nLen = RamEnd-AllRam;
|
||||
ba.szName = "All Ram";
|
||||
BurnAcb(&ba);
|
||||
}
|
||||
|
||||
if (nAction & ACB_DRIVER_DATA) {
|
||||
Z180Scan();
|
||||
|
||||
NamcoSoundScan(nAction, pnMin);
|
||||
|
||||
EEPROMScan(nAction, pnMin);
|
||||
BurnWatchdogScan(nAction);
|
||||
|
||||
SCAN_VAR(game_selected);
|
||||
SCAN_VAR(stars_seed);
|
||||
SCAN_VAR(stars_ctrl);
|
||||
SCAN_VAR(global_flip);
|
||||
SCAN_VAR(irq_mask);
|
||||
SCAN_VAR(_47100_val);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Pac-Man - 25th Anniversary Edition (Rev 3.00)
|
||||
|
||||
static struct BurnRomInfo Pacman25RomDesc[] = {
|
||||
{ "pacman25ver3.u1", 0x40000, 0x55b0076e, 1 | BRF_PRG | BRF_ESS }, // 0 Z180 Code
|
||||
|
||||
{ "pacman_25th.u14", 0x08000, 0xc19d9ad0, 2 | BRF_GRA }, // 1 Color PROM
|
||||
};
|
||||
|
||||
STD_ROM_PICK(Pacman25)
|
||||
STD_ROM_FN(Pacman25)
|
||||
|
||||
static INT32 Pacman25Init()
|
||||
{
|
||||
sprite_pal_base = 0x80;
|
||||
|
||||
return DrvInit();
|
||||
}
|
||||
|
||||
struct BurnDriver BurnDrvPacman25 = {
|
||||
"25pacman", NULL, NULL, NULL, "2006",
|
||||
"Pac-Man - 25th Anniversary Edition (Rev 3.00)\0", NULL, "Namco / Cosmodog", "Miscellaneous",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_POST90S, GBF_MAZE, 0,
|
||||
NULL, Pacman25RomInfo, Pacman25RomName, NULL, NULL, Pacgal20InputInfo, Pacgal20DIPInfo,//Pacman25InputInfo, Pacman25DIPInfo,
|
||||
Pacman25Init, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x1040,
|
||||
224, 288, 3, 4
|
||||
};
|
||||
|
||||
|
||||
// Pac-Man - 25th Anniversary Edition (Rev 2.00)
|
||||
|
||||
static struct BurnRomInfo Pacman25oRomDesc[] = {
|
||||
{ "pacman_25th_rev2.0.u13", 0x40000, 0x99a52784, 1 | BRF_PRG | BRF_ESS }, // 0 Z180 Code
|
||||
|
||||
{ "pacman_25th.u14", 0x08000, 0xc19d9ad0, 2 | BRF_GRA }, // 1 Color PROM
|
||||
};
|
||||
|
||||
STD_ROM_PICK(Pacman25o)
|
||||
STD_ROM_FN(Pacman25o)
|
||||
|
||||
struct BurnDriver BurnDrvPacman25o = {
|
||||
"25pacmano", "25pacman", NULL, NULL, "2005",
|
||||
"Pac-Man - 25th Anniversary Edition (Rev 2.00)\0", NULL, "Namco / Cosmodog", "Miscellaneous",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_POST90S, GBF_MAZE, 0,
|
||||
NULL, Pacman25oRomInfo, Pacman25oRomName, NULL, NULL, Pacgal20InputInfo, Pacgal20DIPInfo,
|
||||
Pacman25Init, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x1040,
|
||||
224, 288, 3, 4
|
||||
};
|
||||
|
||||
|
||||
// Ms. Pac-Man/Galaga - 20th Anniversary Class of 1981 Reunion (V1.08)
|
||||
|
||||
static struct BurnRomInfo Pacgal20RomDesc[] = {
|
||||
{ "ms_pac-galaga_v1.08.u13", 0x40000, 0x2ea16809, 1 | BRF_PRG | BRF_ESS }, // 0 Z180 Code
|
||||
|
||||
{ "ms_pac-galaga.u14", 0x08000, 0xc19d9ad0, 2 | BRF_GRA }, // 1 Color PROM
|
||||
};
|
||||
|
||||
STD_ROM_PICK(Pacgal20)
|
||||
STD_ROM_FN(Pacgal20)
|
||||
|
||||
struct BurnDriver BurnDrvPacgal20 = {
|
||||
"20pacgal", NULL, NULL, NULL, "2000",
|
||||
"Ms. Pac-Man/Galaga - 20th Anniversary Class of 1981 Reunion (V1.08)\0", NULL, "Namco / Cosmodog", "Miscellaneous",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_POST90S, GBF_MAZE, 0,
|
||||
NULL, Pacgal20RomInfo, Pacgal20RomName, NULL, NULL, Pacgal20InputInfo, Pacgal20DIPInfo,
|
||||
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x1040,
|
||||
224, 288, 3, 4
|
||||
};
|
||||
|
||||
|
||||
// Ms. Pac-Man/Galaga - 20th Anniversary Class of 1981 Reunion (V1.04)
|
||||
|
||||
static struct BurnRomInfo Pacgal20r4RomDesc[] = {
|
||||
{ "ms_pac-galaga_v1.04.u13", 0x40000, 0x6c474d2d, 1 | BRF_PRG | BRF_ESS }, // 0 Z180 Code
|
||||
|
||||
{ "ms_pac-galaga.u14", 0x08000, 0xc19d9ad0, 2 | BRF_GRA }, // 1 Color PROM
|
||||
};
|
||||
|
||||
STD_ROM_PICK(Pacgal20r4)
|
||||
STD_ROM_FN(Pacgal20r4)
|
||||
|
||||
struct BurnDriver BurnDrvPacgal20r4 = {
|
||||
"20pacgalr4", "20pacgal", NULL, NULL, "2000",
|
||||
"Ms. Pac-Man/Galaga - 20th Anniversary Class of 1981 Reunion (V1.04)\0", NULL, "Namco / Cosmodog", "Miscellaneous",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_POST90S, GBF_MAZE, 0,
|
||||
NULL, Pacgal20r4RomInfo, Pacgal20r4RomName, NULL, NULL, Pacgal20InputInfo, Pacgal20DIPInfo,
|
||||
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x1040,
|
||||
224, 288, 3, 4
|
||||
};
|
||||
|
||||
|
||||
// Ms. Pac-Man/Galaga - 20th Anniversary Class of 1981 Reunion (V1.03)
|
||||
|
||||
static struct BurnRomInfo Pacgal20r3RomDesc[] = {
|
||||
{ "ms_pac-galaga_v1.03.u13", 0x40000, 0xe13dce63, 1 | BRF_PRG | BRF_ESS }, // 0 Z180 Code
|
||||
|
||||
{ "ms_pac-galaga.u14", 0x08000, 0xc19d9ad0, 2 | BRF_GRA }, // 1 Color PROM
|
||||
};
|
||||
|
||||
STD_ROM_PICK(Pacgal20r3)
|
||||
STD_ROM_FN(Pacgal20r3)
|
||||
|
||||
struct BurnDriver BurnDrvPacgal20r3 = {
|
||||
"20pacgalr3", "20pacgal", NULL, NULL, "2000",
|
||||
"Ms. Pac-Man/Galaga - 20th Anniversary Class of 1981 Reunion (V1.03)\0", NULL, "Namco / Cosmodog", "Miscellaneous",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_POST90S, GBF_MAZE, 0,
|
||||
NULL, Pacgal20r3RomInfo, Pacgal20r3RomName, NULL, NULL, Pacgal20InputInfo, Pacgal20DIPInfo,
|
||||
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x1040,
|
||||
224, 288, 3, 4
|
||||
};
|
||||
|
||||
|
||||
// Ms. Pac-Man/Galaga - 20th Anniversary Class of 1981 Reunion (V1.02)
|
||||
|
||||
static struct BurnRomInfo Pacgal20r2RomDesc[] = {
|
||||
{ "ms_pac-galaga_v1.02.u13", 0x40000, 0xb939f805, 1 | BRF_PRG | BRF_ESS }, // 0 Z180 Code
|
||||
|
||||
{ "ms_pac-galaga.u14", 0x08000, 0xc19d9ad0, 2 | BRF_GRA }, // 1 Color PROM
|
||||
};
|
||||
|
||||
STD_ROM_PICK(Pacgal20r2)
|
||||
STD_ROM_FN(Pacgal20r2)
|
||||
|
||||
struct BurnDriver BurnDrvPacgal20r2 = {
|
||||
"20pacgalr2", "20pacgal", NULL, NULL, "2000",
|
||||
"Ms. Pac-Man/Galaga - 20th Anniversary Class of 1981 Reunion (V1.02)\0", NULL, "Namco / Cosmodog", "Miscellaneous",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_POST90S, GBF_MAZE, 0,
|
||||
NULL, Pacgal20r2RomInfo, Pacgal20r2RomName, NULL, NULL, Pacgal20InputInfo, Pacgal20DIPInfo,
|
||||
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x1040,
|
||||
224, 288, 3, 4
|
||||
};
|
||||
|
||||
|
||||
// Ms. Pac-Man/Galaga - 20th Anniversary Class of 1981 Reunion (V1.01)
|
||||
|
||||
static struct BurnRomInfo Pacgal20r1RomDesc[] = {
|
||||
{ "ms_pac-galaga_v1.01.u13", 0x40000, 0x77159582, 1 | BRF_PRG | BRF_ESS }, // 0 Z180 Code
|
||||
|
||||
{ "ms_pac-galaga.u14", 0x08000, 0xc19d9ad0, 2 | BRF_GRA }, // 1 Color PROM
|
||||
};
|
||||
|
||||
STD_ROM_PICK(Pacgal20r1)
|
||||
STD_ROM_FN(Pacgal20r1)
|
||||
|
||||
struct BurnDriver BurnDrvPacgal20r1 = {
|
||||
"20pacgalr1", "20pacgal", NULL, NULL, "2000",
|
||||
"Ms. Pac-Man/Galaga - 20th Anniversary Class of 1981 Reunion (V1.01)\0", NULL, "Namco / Cosmodog", "Miscellaneous",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_POST90S, GBF_MAZE, 0,
|
||||
NULL, Pacgal20r1RomInfo, Pacgal20r1RomName, NULL, NULL, Pacgal20InputInfo, Pacgal20DIPInfo,
|
||||
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x1040,
|
||||
224, 288, 3, 4
|
||||
};
|
||||
|
||||
|
||||
// Ms. Pac-Man/Galaga - 20th Anniversary Class of 1981 Reunion (V1.00)
|
||||
|
||||
static struct BurnRomInfo Pacgal20r0RomDesc[] = {
|
||||
{ "ms_pac-galaga_v1.0.u13", 0x40000, 0x3c92a269, 1 | BRF_PRG | BRF_ESS }, // 0 Z180 Code
|
||||
|
||||
{ "ms_pac-galaga.u14", 0x08000, 0xc19d9ad0, 2 | BRF_GRA }, // 1 Color PROM
|
||||
};
|
||||
|
||||
STD_ROM_PICK(Pacgal20r0)
|
||||
STD_ROM_FN(Pacgal20r0)
|
||||
|
||||
struct BurnDriver BurnDrvPacgal20r0 = {
|
||||
"20pacgalr0", "20pacgal", NULL, NULL, "2000",
|
||||
"Ms. Pac-Man/Galaga - 20th Anniversary Class of 1981 Reunion (V1.00)\0", NULL, "Namco / Cosmodog", "Miscellaneous",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_POST90S, GBF_MAZE, 0,
|
||||
NULL, Pacgal20r0RomInfo, Pacgal20r0RomName, NULL, NULL, Pacgal20InputInfo, Pacgal20DIPInfo,
|
||||
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x1040,
|
||||
224, 288, 3, 4
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
// Based on MAME driver by Quench, Yochizo, David Haywood
|
||||
|
||||
#include "toaplan.h"
|
||||
#include "z180.h"
|
||||
#include "z180_intf.h"
|
||||
|
||||
#define REFRESHRATE 60
|
||||
#define VBLANK_LINES (32)
|
||||
@ -182,11 +182,9 @@ static INT32 DrvScan(INT32 nAction,INT32 *pnMin)
|
||||
BurnAcb(&ba);
|
||||
|
||||
SekScan(nAction); // scan 68000 states
|
||||
z180_scan();
|
||||
|
||||
ToaScanGP9001(nAction, pnMin);
|
||||
|
||||
ToaRecalcPalette = 1;
|
||||
bDrawScreen = true; // get background back ?
|
||||
}
|
||||
|
||||
@ -236,10 +234,11 @@ UINT8 __fastcall ghoxReadByte(UINT32 sekAddress)
|
||||
}
|
||||
|
||||
if (sekAddress >= 0x180000 && sekAddress <= 0x180fff) {
|
||||
return ShareRAM[(sekAddress - 0x180000) >> 1];
|
||||
nCyclesDone[1] += Z180Run(SekTotalCycles() - nCyclesDone[1]);
|
||||
return ShareRAM[((sekAddress - 0x180000) >> 1)];
|
||||
}
|
||||
|
||||
//bprintf(PRINT_NORMAL, _T("Read Byte %x\n"), sekAddress);
|
||||
bprintf(PRINT_NORMAL, _T("Read Byte %x\n"), sekAddress);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -261,12 +260,18 @@ UINT16 __fastcall ghoxReadWord(UINT32 sekAddress)
|
||||
case 0x100000:
|
||||
return PaddleRead(0);
|
||||
}
|
||||
|
||||
|
||||
if (sekAddress >= 0x180000 && sekAddress <= 0x180fff) {
|
||||
// bprintf(PRINT_NORMAL, _T("Read Word %x\n"), sekAddress);
|
||||
nCyclesDone[1] += Z180Run(SekTotalCycles() - nCyclesDone[1]);
|
||||
return ShareRAM[((sekAddress - 0x180000) >> 1)] + (ShareRAM[((sekAddress - 0x180000) >> 1)] * 256);
|
||||
}
|
||||
|
||||
/*
|
||||
if (sekAddress >= 0x180000 && sekAddress <= 0x180fff) {
|
||||
SEK_DEF_READ_WORD(0, sekAddress);
|
||||
}
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T("Read Word %x\n"), sekAddress);
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -287,12 +292,15 @@ void __fastcall ghoxWriteByte(UINT32 sekAddress, UINT8 byteValue)
|
||||
|
||||
if (sekAddress >= 0x180000 && sekAddress <= 0x180fff) {
|
||||
if ((sekAddress & 0x01) == 0x01) {
|
||||
ShareRAM[(sekAddress - 0x180000) >> 1] = byteValue;
|
||||
nCyclesDone[1] += Z180Run(SekTotalCycles() - nCyclesDone[1]); // iq_132
|
||||
ShareRAM[((sekAddress - 0x180000) >> 1)] = byteValue;
|
||||
} else {
|
||||
bprintf(0, _T("%X, "), sekAddress);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T("Write Byte %x, %x\n"), sekAddress, byteValue);
|
||||
bprintf(PRINT_NORMAL, _T("Write Byte %x, %x\n"), sekAddress, byteValue);
|
||||
}
|
||||
|
||||
void __fastcall ghoxWriteWord(UINT32 sekAddress, UINT16 wordValue)
|
||||
@ -317,45 +325,22 @@ void __fastcall ghoxWriteWord(UINT32 sekAddress, UINT16 wordValue)
|
||||
ToaGP9001WriteRegister(wordValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sekAddress >= 0x180000 && sekAddress <= 0x180fff) {
|
||||
// bprintf(PRINT_NORMAL, _T("Write Word %x, %x\n"), sekAddress, wordValue);
|
||||
nCyclesDone[1] += Z180Run(SekTotalCycles() - nCyclesDone[1]); // iq_132
|
||||
ShareRAM[(sekAddress - 0x180000) >> 1] = wordValue&0xff;
|
||||
return;
|
||||
}
|
||||
/*
|
||||
if (sekAddress >= 0x180000 && sekAddress <= 0x180fff) {
|
||||
SEK_DEF_WRITE_WORD(0, sekAddress, wordValue)
|
||||
return;
|
||||
}
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T("Write Word %x, %x\n"), sekAddress, wordValue);
|
||||
*/
|
||||
}
|
||||
|
||||
static UINT8 __fastcall GhoxMCUReadOp(UINT32 a)
|
||||
static UINT8 __fastcall GhoxMCURead(UINT32 a)
|
||||
{
|
||||
if (a <= 0x3fff) return Rom02[a];
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T("Read Op %x\n"), a);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static UINT8 __fastcall GhoxMCUReadOpArg(UINT32 a)
|
||||
{
|
||||
if (a <= 0x3fff) return Rom02[a];
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T("Read Op Arg %x\n"), a);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static UINT8 __fastcall GhoxMCUReadProg(UINT32 a)
|
||||
{
|
||||
if (a <= 0x3fff) return Rom02[a];
|
||||
|
||||
if (a >= 0x3fe00 && a <= 0x3ffff) {
|
||||
return Ram02[(a - 0x3fe00) + 0x200];
|
||||
}
|
||||
|
||||
if (a >= 0x40000 && a <= 0x407ff) {
|
||||
return ShareRAM[a - 0x40000];
|
||||
}
|
||||
|
||||
switch (a) {
|
||||
case 0x80002: {
|
||||
return DrvInput[3];
|
||||
@ -386,23 +371,13 @@ static UINT8 __fastcall GhoxMCUReadProg(UINT32 a)
|
||||
}
|
||||
}
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T("Read Prog %x\n"), a);
|
||||
bprintf(PRINT_NORMAL, _T("Read Prog %x\n"), a);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __fastcall GhoxMCUWriteProg(UINT32 a, UINT8 d)
|
||||
static void __fastcall GhoxMCUWrite(UINT32 a, UINT8 d)
|
||||
{
|
||||
if (a >= 0x3fe00 && a <= 0x3ffff) {
|
||||
Ram02[(a - 0x3fe00) + 0x200] = d;
|
||||
return;
|
||||
}
|
||||
|
||||
if (a >= 0x40000 && a <= 0x407ff) {
|
||||
ShareRAM[(a - 0x40000)] = d;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (a) {
|
||||
case 0x8000e: {
|
||||
BurnYM2151SelectRegister(d);
|
||||
@ -415,7 +390,7 @@ static void __fastcall GhoxMCUWriteProg(UINT32 a, UINT8 d)
|
||||
}
|
||||
}
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T("Write Prog %x, %x\n"), a, d);
|
||||
bprintf(PRINT_NORMAL, _T("Write Prog %x, %x\n"), a, d);
|
||||
}
|
||||
|
||||
static INT32 DrvDoReset()
|
||||
@ -423,8 +398,10 @@ static INT32 DrvDoReset()
|
||||
SekOpen(0);
|
||||
SekReset();
|
||||
SekClose();
|
||||
|
||||
z180_reset();
|
||||
|
||||
Z180Open(0);
|
||||
Z180Reset();
|
||||
Z180Close();
|
||||
|
||||
BurnYM2151Reset();
|
||||
|
||||
@ -448,7 +425,7 @@ static INT32 DrvInit()
|
||||
|
||||
BurnSetRefreshRate(REFRESHRATE);
|
||||
|
||||
nGP9001ROMSize[0] = 0x100000;
|
||||
nGP9001ROMSize[0] = 0x800000;
|
||||
|
||||
// Find out how much memory is needed
|
||||
Mem = NULL;
|
||||
@ -492,14 +469,18 @@ static INT32 DrvInit()
|
||||
ToaPalSrc = RamPal;
|
||||
ToaPalInit();
|
||||
|
||||
z180_init(0, 10000000, NULL);
|
||||
Z180SetCPUOpReadHandler(GhoxMCUReadOp);
|
||||
Z180SetCPUOpReadArgHandler(GhoxMCUReadOpArg);
|
||||
Z180SetCPUProgReadHandler(GhoxMCUReadProg);
|
||||
Z180SetCPUProgWriteHandler(GhoxMCUWriteProg);
|
||||
Z180Init(10000000);
|
||||
Z180Open(0);
|
||||
Z180MapMemory(Rom02, 0x00000, 0x03fff, MAP_ROM);
|
||||
Z180MapMemory(Ram02, 0x0fe00, 0x0ffff, MAP_RAM);
|
||||
Z180MapMemory(Ram02 + 0x200, 0x3fe00, 0x3ffff, MAP_RAM);
|
||||
Z180MapMemory(ShareRAM, 0x40000, 0x407ff, MAP_RAM);
|
||||
Z180SetReadHandler(GhoxMCURead);
|
||||
Z180SetWriteHandler(GhoxMCUWrite);
|
||||
Z180Close();
|
||||
|
||||
BurnYM2151Init(27000000 / 8);
|
||||
BurnYM2151SetAllRoutes(0.35, BURN_SND_ROUTE_BOTH);
|
||||
BurnYM2151SetAllRoutes(0.55, BURN_SND_ROUTE_BOTH);
|
||||
|
||||
bDrawScreen = true;
|
||||
|
||||
@ -514,7 +495,7 @@ static INT32 DrvExit()
|
||||
ToaExitGP9001();
|
||||
SekExit(); // Deallocate 68000s
|
||||
|
||||
z180_exit();
|
||||
Z180Exit();
|
||||
|
||||
BurnYM2151Exit();
|
||||
|
||||
@ -537,14 +518,9 @@ static INT32 DrvDraw()
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline static INT32 CheckSleep(INT32)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT32 DrvFrame()
|
||||
{
|
||||
INT32 nInterleave = 100;
|
||||
INT32 nInterleave = 400;
|
||||
INT32 nSoundBufferPos = 0;
|
||||
|
||||
if (DrvReset) {
|
||||
@ -568,11 +544,14 @@ static INT32 DrvFrame()
|
||||
SekNewFrame();
|
||||
|
||||
SekOpen(0);
|
||||
Z180Open(0);
|
||||
|
||||
SekIdle(nCyclesDone[0]);
|
||||
|
||||
nCyclesTotal[0] = (INT32)((INT64)10000000 * nBurnCPUSpeedAdjust / (0x0100 * REFRESHRATE));
|
||||
nCyclesTotal[1] = (INT32)((INT64)10000000 / REFRESHRATE);
|
||||
nCyclesTotal[1] = nCyclesTotal[0];
|
||||
|
||||
nCyclesDone[1] = 0;
|
||||
|
||||
SekSetCyclesScanline(nCyclesTotal[0] / 262);
|
||||
nToaCyclesDisplayStart = nCyclesTotal[0] - ((nCyclesTotal[0] * (TOA_VBLANK_LINES + 240)) / 262);
|
||||
@ -589,7 +568,7 @@ static INT32 DrvFrame()
|
||||
if (nNext > nToaCyclesVBlankStart) {
|
||||
if (SekTotalCycles() < nToaCyclesVBlankStart) {
|
||||
nCyclesSegment = nToaCyclesVBlankStart - SekTotalCycles();
|
||||
SekRun(nCyclesSegment);
|
||||
SekRun(nCyclesSegment); // bring us to vbl
|
||||
}
|
||||
|
||||
if (pBurnDraw) {
|
||||
@ -603,14 +582,11 @@ static INT32 DrvFrame()
|
||||
}
|
||||
|
||||
nCyclesSegment = nNext - SekTotalCycles();
|
||||
if (bVBlank || (!CheckSleep(0))) {
|
||||
SekRun(nCyclesSegment);
|
||||
} else {
|
||||
SekIdle(nCyclesSegment);
|
||||
}
|
||||
|
||||
SekRun(nCyclesSegment);
|
||||
|
||||
// Run MCU
|
||||
nCyclesDone[1] += z180_execute(nCyclesTotal[1] / nInterleave);
|
||||
nCyclesDone[1] += Z180Run(SekTotalCycles() - nCyclesDone[1]);
|
||||
|
||||
// Render sound segment
|
||||
if (pBurnSoundOut) {
|
||||
@ -635,6 +611,7 @@ static INT32 DrvFrame()
|
||||
|
||||
// ToaBufferFCU2Sprites();
|
||||
|
||||
Z180Close();
|
||||
SekClose();
|
||||
|
||||
return 0;
|
||||
@ -656,7 +633,7 @@ STD_ROM_PICK(ghox)
|
||||
STD_ROM_FN(ghox)
|
||||
|
||||
struct BurnDriver BurnDrvGhox = {
|
||||
"ghox", NULL, NULL, NULL, "1991",
|
||||
"ghox", NULL, NULL, "ghox", "1991",
|
||||
"Ghox (spinner)\0", NULL, "Toaplan", "Toaplan GP9001 based",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 2, HARDWARE_TOAPLAN_68K_Zx80, GBF_BREAKOUT, 0,
|
||||
@ -682,7 +659,7 @@ STD_ROM_PICK(ghoxj)
|
||||
STD_ROM_FN(ghoxj)
|
||||
|
||||
struct BurnDriver BurnDrvGhoxj = {
|
||||
"ghoxj", "ghox", NULL, NULL, "1991",
|
||||
"ghoxj", "ghox", NULL, "ghox", "1991",
|
||||
"Ghox (joystick)\0", NULL, "Toaplan", "Toaplan GP9001 based",
|
||||
NULL, NULL, NULL, NULL,
|
||||
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 2, HARDWARE_TOAPLAN_68K_Zx80, GBF_BREAKOUT, 0,
|
||||
|
@ -79,82 +79,23 @@ Hitachi HD647180 series:
|
||||
#include "burnint.h"
|
||||
#define Z180_INLINE static inline
|
||||
|
||||
#include "z180.h"
|
||||
#include "z180_intf.h"
|
||||
|
||||
Z180ReadOpHandler Z180CPUReadOp;
|
||||
Z180ReadOpArgHandler Z180CPUReadOpArg;
|
||||
Z180ReadProgHandler Z180CPUReadProg;
|
||||
Z180WriteProgHandler Z180CPUWriteProg;
|
||||
Z180ReadIOHandler Z180CPUReadIO;
|
||||
Z180WriteIOHandler Z180CPUWriteIO;
|
||||
// in z180_intf.cpp
|
||||
extern void __fastcall z180_cpu_write_handler(UINT32 address, UINT8 data);
|
||||
extern UINT8 __fastcall z180_cpu_fetchop_handler(UINT32 address);
|
||||
extern UINT8 __fastcall z180_cpu_fetcharg_handler(UINT32 address);
|
||||
extern UINT8 __fastcall z180_cpu_read_handler(UINT32 address);
|
||||
extern void __fastcall z180_cpu_write_port_handler(UINT32 address, UINT8 data);
|
||||
extern UINT8 __fastcall z180_cpu_read_port_handler(UINT32 address);
|
||||
|
||||
static UINT8 __fastcall Z180DummyReadOp(UINT32)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#define cpu_readop(a) z180_cpu_fetchop_handler(a)
|
||||
#define cpu_readop_arg(a) z180_cpu_fetcharg_handler(a)
|
||||
#define program_read_byte_8le(a) z180_cpu_read_handler(a)
|
||||
#define program_write_byte_8le(a,d) z180_cpu_write_handler(a,d)
|
||||
#define io_read_byte_8le(a) z180_cpu_read_port_handler(a)
|
||||
#define io_write_byte_8le(a,d) z180_cpu_write_port_handler(a,d)
|
||||
|
||||
static UINT8 __fastcall Z180DummyReadOpArg(UINT32)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static UINT8 __fastcall Z180DummyReadProg(UINT32)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __fastcall Z180DummyWriteProg(UINT32, UINT8)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static UINT8 __fastcall Z180DummyReadIO(UINT32)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __fastcall Z180DummyWriteIO(UINT32, UINT8)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Z180SetCPUOpReadHandler(Z180ReadOpHandler handler)
|
||||
{
|
||||
Z180CPUReadOp = handler;
|
||||
}
|
||||
|
||||
void Z180SetCPUOpReadArgHandler(Z180ReadOpArgHandler handler)
|
||||
{
|
||||
Z180CPUReadOpArg = handler;
|
||||
}
|
||||
|
||||
void Z180SetCPUProgReadHandler(Z180ReadProgHandler handler)
|
||||
{
|
||||
Z180CPUReadProg = handler;
|
||||
}
|
||||
|
||||
void Z180SetCPUProgWriteHandler(Z180WriteProgHandler handler)
|
||||
{
|
||||
Z180CPUWriteProg = handler;
|
||||
}
|
||||
|
||||
void Z180SetCPUIOReadHandler(Z180ReadIOHandler handler)
|
||||
{
|
||||
Z180CPUReadIO = handler;
|
||||
}
|
||||
|
||||
void Z180SetCPUIOWriteHandler(Z180WriteIOHandler handler)
|
||||
{
|
||||
Z180CPUWriteIO = handler;
|
||||
}
|
||||
|
||||
#define cpu_readop(a) Z180CPUReadOp(a)
|
||||
#define cpu_readop_arg(a) Z180CPUReadOpArg(a)
|
||||
#define program_read_byte_8le(a) Z180CPUReadProg(a)
|
||||
#define program_write_byte_8le(a,d) Z180CPUWriteProg(a,d)
|
||||
#define io_read_byte_8le(a) Z180CPUReadIO(a)
|
||||
#define io_write_byte_8le(a,d) Z180CPUWriteIO(a,d)
|
||||
|
||||
#include "z80daisy.h"
|
||||
|
||||
|
||||
@ -849,6 +790,9 @@ static UINT8 *SZHVC_add;
|
||||
static UINT8 *SZHVC_sub;
|
||||
#endif
|
||||
|
||||
static UINT32 total_cycles;
|
||||
static UINT32 current_cycles;
|
||||
|
||||
void z180_scan()
|
||||
{
|
||||
void *daisybk = (void*)Z180.daisy;
|
||||
@ -1849,13 +1793,6 @@ void z180_init(int index, int clock, /*const void *config,*/ int (*irqcallback)(
|
||||
SZHVC_add = (UINT8 *)BurnMalloc(2*256*256*sizeof(UINT8));
|
||||
SZHVC_sub = (UINT8 *)BurnMalloc(2*256*256*sizeof(UINT8));
|
||||
#endif
|
||||
|
||||
Z180CPUReadOp = Z180DummyReadOp;
|
||||
Z180CPUReadOpArg = Z180DummyReadOpArg;
|
||||
Z180CPUReadProg = Z180DummyReadProg;
|
||||
Z180CPUWriteProg = Z180DummyWriteProg;
|
||||
Z180CPUReadIO = Z180DummyReadIO;
|
||||
Z180CPUWriteIO = Z180DummyWriteIO;
|
||||
}
|
||||
|
||||
void z180_exit()
|
||||
@ -2039,6 +1976,9 @@ void z180_reset(void)
|
||||
if (Z180.daisy)
|
||||
z80daisy_reset(Z180.daisy);
|
||||
z180_mmu();
|
||||
|
||||
total_cycles = 0;
|
||||
current_cycles = 0;
|
||||
}
|
||||
|
||||
/* Handle PRT timers, decreasing them after 20 clocks and returning the new icount base that needs to be used for the next check */
|
||||
@ -2126,6 +2066,7 @@ int z180_execute(int cycles)
|
||||
{
|
||||
int old_icount = cycles;
|
||||
z180_icount = cycles;
|
||||
current_cycles = cycles;
|
||||
|
||||
/* check for NMIs on the way in; they can only be set externally */
|
||||
/* via timers, and can't be dynamically enabled, so it is safe */
|
||||
@ -2189,21 +2130,40 @@ again:
|
||||
{
|
||||
check_interrupts();
|
||||
Z180.after_EI = 0;
|
||||
|
||||
_PPC = _PCD;
|
||||
_R++;
|
||||
|
||||
EXEC_Z180_INLINE(op,ROP());
|
||||
|
||||
old_icount = handle_timers(z180_icount, old_icount);
|
||||
|
||||
/* If DMA is started go to check the mode */
|
||||
if ((IO_DSTAT & Z180_DSTAT_DME) == Z180_DSTAT_DME)
|
||||
goto again;
|
||||
|
||||
} while( z180_icount > 0 );
|
||||
}
|
||||
|
||||
total_cycles += cycles - z180_icount;
|
||||
|
||||
return cycles - z180_icount;
|
||||
}
|
||||
|
||||
void z180_run_end()
|
||||
{
|
||||
z180_icount = 0;
|
||||
}
|
||||
|
||||
INT32 z180_total_cycles()
|
||||
{
|
||||
return total_cycles + (current_cycles - z180_icount);
|
||||
}
|
||||
|
||||
void z180_new_frame()
|
||||
{
|
||||
total_cycles = 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Burn 'cycles' T-states. Adjust R register for the lost time
|
||||
****************************************************************************/
|
||||
|
@ -7,6 +7,8 @@
|
||||
#define Z180_ASSERT_LINE 1
|
||||
#define Z180_INPUT_LINE_NMI 32
|
||||
|
||||
#if 0
|
||||
|
||||
typedef UINT8 (__fastcall *Z180ReadOpHandler)(UINT32 a);
|
||||
typedef UINT8 (__fastcall *Z180ReadOpArgHandler)(UINT32 a);
|
||||
typedef UINT8 (__fastcall *Z180ReadProgHandler)(UINT32 a);
|
||||
@ -28,6 +30,8 @@ void Z180SetCPUProgWriteHandler(Z180WriteProgHandler handler);
|
||||
void Z180SetCPUIOReadHandler(Z180ReadIOHandler handler);
|
||||
void Z180SetCPUIOWriteHandler(Z180WriteIOHandler handler);
|
||||
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
Z180_PC=1,
|
||||
@ -162,4 +166,8 @@ void z180_write_iolines(UINT32 data);
|
||||
void z180_write_internal_io(UINT32 port, UINT8 data);
|
||||
void z180_scan();
|
||||
|
||||
INT32 z180_total_cycles();
|
||||
void z180_new_frame();
|
||||
void z180_run_end();
|
||||
|
||||
#endif /* __Z180_H__ */
|
||||
|
423
src/cpu/z180_intf.cpp
Normal file
423
src/cpu/z180_intf.cpp
Normal file
@ -0,0 +1,423 @@
|
||||
#include "burnint.h"
|
||||
#include "z180.h"
|
||||
|
||||
static INT32 DebugCPU_Z180Initted = 0;
|
||||
|
||||
#define NUM_CPUS 1
|
||||
|
||||
#define PROG_ADDRESS_BITS 20
|
||||
#define PROG_PAGE_BITS 8
|
||||
#define PORT_ADDRESS_BITS 16
|
||||
|
||||
#define READ 0
|
||||
#define WRITE 1
|
||||
#define FETCHOP 2
|
||||
#define FETCHARG 3
|
||||
|
||||
#define PROG_RANGE (1 << PROG_ADDRESS_BITS)
|
||||
#define PROG_MASK (PROG_RANGE - 1)
|
||||
#define PROG_PAGE_RANGE (1 << PROG_PAGE_BITS)
|
||||
#define PROG_PAGE_MASK (PROG_PAGE_RANGE - 1)
|
||||
#define PROG_PAGES (PROG_RANGE >> PROG_PAGE_BITS)
|
||||
#define PROG_PAGES_MASK (PROG_PAGES - 1)
|
||||
|
||||
#define PORT_RANGE (1 << PORT_ADDRESS_BITS)
|
||||
#define PORT_MASK (PORT_RANGE - 1)
|
||||
|
||||
static UINT8 *Mem[NUM_CPUS][4][PROG_PAGES];
|
||||
static INT32 nActiveCPU = -1;
|
||||
|
||||
typedef UINT8 __fastcall (*read_cb)(UINT32 address);
|
||||
typedef void __fastcall (*write_cb)(UINT32 address, UINT8 data);
|
||||
|
||||
static write_cb prog_write[NUM_CPUS];
|
||||
static read_cb prog_read[NUM_CPUS];
|
||||
static read_cb prog_fetchop[NUM_CPUS];
|
||||
static read_cb prog_fetcharg[NUM_CPUS];
|
||||
static write_cb port_write[NUM_CPUS];
|
||||
static read_cb port_read[NUM_CPUS];
|
||||
|
||||
void Z180SetWriteHandler(void __fastcall (*write)(UINT32, UINT8))
|
||||
{
|
||||
prog_write[nActiveCPU] = write;
|
||||
}
|
||||
|
||||
void Z180SetReadHandler(UINT8 __fastcall (*read)(UINT32))
|
||||
{
|
||||
prog_read[nActiveCPU] = read;
|
||||
}
|
||||
|
||||
void Z180SetFetchOpHandler(UINT8 __fastcall (*fetch)(UINT32))
|
||||
{
|
||||
prog_fetchop[nActiveCPU] = fetch;
|
||||
}
|
||||
|
||||
void Z180SetFetchArgHandler(UINT8 __fastcall (*fetch)(UINT32))
|
||||
{
|
||||
prog_fetcharg[nActiveCPU] = fetch;
|
||||
}
|
||||
|
||||
void Z180SetWritePortHandler(void __fastcall (*write)(UINT32, UINT8))
|
||||
{
|
||||
port_write[nActiveCPU] = write;
|
||||
}
|
||||
|
||||
void Z180SetReadPortHandler(UINT8 __fastcall (*read)(UINT32))
|
||||
{
|
||||
port_read[nActiveCPU] = read;
|
||||
}
|
||||
|
||||
void Z180MapMemory(UINT8 *ptr, UINT32 start, UINT32 end, UINT32 flags)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_Z180Initted) bprintf(PRINT_ERROR, _T("Z180MapMemory called without init\n"));
|
||||
if (nActiveCPU == -1) bprintf(PRINT_ERROR, _T("Z180MapMemory called when no CPU open\n"));
|
||||
if (end <= start || start >= PROG_RANGE || end >= PROG_RANGE || flags == 0)
|
||||
bprintf(PRINT_ERROR, _T("Z180MapMemory called when invalid parameters ptr, start: %x, end: %x, flags: %x\n"), start, end, flags);
|
||||
#endif
|
||||
|
||||
UINT32 s = (start >> PROG_PAGE_BITS);
|
||||
|
||||
for (UINT32 i = 0; i < ((end >> PROG_PAGE_BITS) - (start >> PROG_PAGE_BITS)) + 1; i++)
|
||||
{
|
||||
if (flags & MAP_READ ) Mem[nActiveCPU][READ ][s + i] = (ptr == NULL) ? NULL : (ptr + (i << PROG_PAGE_BITS));
|
||||
if (flags & MAP_WRITE ) Mem[nActiveCPU][WRITE ][s + i] = (ptr == NULL) ? NULL : (ptr + (i << PROG_PAGE_BITS));
|
||||
if (flags & MAP_FETCHOP ) Mem[nActiveCPU][FETCHOP ][s + i] = (ptr == NULL) ? NULL : (ptr + (i << PROG_PAGE_BITS));
|
||||
if (flags & MAP_FETCHARG) Mem[nActiveCPU][FETCHARG][s + i] = (ptr == NULL) ? NULL : (ptr + (i << PROG_PAGE_BITS));
|
||||
}
|
||||
}
|
||||
|
||||
static INT32 dummy_irq_callback(INT32)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Z180Reset()
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_Z180Initted) bprintf(PRINT_ERROR, _T("Z180Reset called without init\n"));
|
||||
if (nActiveCPU == -1) bprintf(PRINT_ERROR, _T("Z180Reset called when no CPU open\n"));
|
||||
#endif
|
||||
|
||||
z180_reset();
|
||||
}
|
||||
|
||||
void Z180Exit()
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_Z180Initted) bprintf(PRINT_ERROR, _T("Z180Exit called without init\n"));
|
||||
#endif
|
||||
|
||||
z180_exit();
|
||||
nActiveCPU = -1;
|
||||
DebugCPU_Z180Initted = 0;
|
||||
}
|
||||
|
||||
INT32 Z180GetActive()
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_Z180Initted) bprintf(PRINT_ERROR, _T("Z180GetActive called without init\n"));
|
||||
#endif
|
||||
|
||||
return nActiveCPU;
|
||||
}
|
||||
|
||||
void Z180Open(INT32 nCPU)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_Z180Initted) bprintf(PRINT_ERROR, _T("Z180Open called without init\n"));
|
||||
if (nCPU >= NUM_CPUS) bprintf(PRINT_ERROR, _T("Z180Open called with invalid index %x\n"), nCPU);
|
||||
if (nActiveCPU != -1) bprintf(PRINT_ERROR, _T("Z180Open called when CPU already open with index %x\n"), nCPU);
|
||||
#endif
|
||||
|
||||
nActiveCPU = nCPU;
|
||||
}
|
||||
|
||||
void Z180Close()
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_Z180Initted) bprintf(PRINT_ERROR, _T("Z180Close called without init\n"));
|
||||
if (nActiveCPU == -1) bprintf(PRINT_ERROR, _T("Z180Close called when no CPU open\n"));
|
||||
#endif
|
||||
|
||||
nActiveCPU = -1;
|
||||
}
|
||||
|
||||
INT32 Z180Run(INT32 cycles)
|
||||
{
|
||||
if (cycles <= 0) return 0;
|
||||
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_Z180Initted) bprintf(PRINT_ERROR, _T("Z180Run called without init\n"));
|
||||
if (nActiveCPU == -1) bprintf(PRINT_ERROR, _T("Z180Run called when no CPU open\n"));
|
||||
// if (cycles <= 0) bprintf(PRINT_ERROR, _T("Z180Run called with invalid cycles (%d)\n"), cycles);
|
||||
#endif
|
||||
|
||||
return z180_execute(cycles);
|
||||
}
|
||||
|
||||
INT32 Z180TotalCycles()
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_Z180Initted) bprintf(PRINT_ERROR, _T("Z180TotalCycles called without init\n"));
|
||||
if (nActiveCPU == -1) bprintf(PRINT_ERROR, _T("Z180TotalCycles called when no CPU open\n"));
|
||||
#endif
|
||||
|
||||
return z180_total_cycles();
|
||||
}
|
||||
|
||||
void Z180RunEnd()
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_Z180Initted) bprintf(PRINT_ERROR, _T("Z180RunEnd called without init\n"));
|
||||
if (nActiveCPU == -1) bprintf(PRINT_ERROR, _T("Z180RunEnd called when no CPU open\n"));
|
||||
#endif
|
||||
|
||||
z180_run_end();
|
||||
}
|
||||
|
||||
void Z180NewFrame()
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_Z180Initted) bprintf(PRINT_ERROR, _T("Z180NewFrame called without init\n"));
|
||||
#endif
|
||||
z180_new_frame();
|
||||
}
|
||||
|
||||
void Z180BurnCycles(INT32 cycles)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_Z180Initted) bprintf(PRINT_ERROR, _T("Z180BurnCycles called without init\n"));
|
||||
if (nActiveCPU == -1) bprintf(PRINT_ERROR, _T("Z180BurnCycles called when no CPU open\n"));
|
||||
#endif
|
||||
|
||||
z180_burn(cycles);
|
||||
}
|
||||
|
||||
void Z180SetIRQLine(INT32 irqline, INT32 state)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_Z180Initted) bprintf(PRINT_ERROR, _T("Z180SetIRQLine called without init\n"));
|
||||
if (nActiveCPU == -1) bprintf(PRINT_ERROR, _T("Z180SetIRQLine called when no CPU open\n"));
|
||||
if (irqline != 0 && irqline != Z180_INPUT_LINE_NMI) bprintf(PRINT_ERROR, _T("Z180SetIRQLine called with invalid line %d\n"), irqline);
|
||||
if (state != CPU_IRQSTATUS_NONE && state != CPU_IRQSTATUS_ACK && state != CPU_IRQSTATUS_AUTO)
|
||||
bprintf(PRINT_ERROR, _T("Z180SetIRQLine called with invalid state %d\n"), state);
|
||||
#endif
|
||||
|
||||
z180_set_irq_line(irqline, state);
|
||||
}
|
||||
|
||||
void Z180Scan()
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_Z180Initted) bprintf(PRINT_ERROR, _T("Z180Scan called without init\n"));
|
||||
#endif
|
||||
z180_scan();
|
||||
}
|
||||
|
||||
void __fastcall z180_cpu_write_handler(UINT32 address, UINT8 data)
|
||||
{
|
||||
address &= PROG_MASK;
|
||||
|
||||
if (Mem[nActiveCPU][WRITE][(address >> PROG_PAGE_BITS)]) {
|
||||
Mem[nActiveCPU][WRITE][(address >> PROG_PAGE_BITS)][address & PROG_PAGE_MASK] = data;
|
||||
return;
|
||||
}
|
||||
|
||||
if (prog_write[nActiveCPU]) {
|
||||
prog_write[nActiveCPU](address, data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UINT8 __fastcall z180_cpu_fetchop_handler(UINT32 address)
|
||||
{
|
||||
address &= PROG_MASK;
|
||||
|
||||
if (Mem[nActiveCPU][FETCHOP][(address >> PROG_PAGE_BITS)]) {
|
||||
return Mem[nActiveCPU][FETCHOP][(address >> PROG_PAGE_BITS)][address & PROG_PAGE_MASK];
|
||||
}
|
||||
|
||||
if (prog_fetchop[nActiveCPU]) {
|
||||
return prog_fetchop[nActiveCPU](address);
|
||||
}
|
||||
|
||||
// fall back to arg
|
||||
if (Mem[nActiveCPU][FETCHARG][(address >> PROG_PAGE_BITS)]) {
|
||||
return Mem[nActiveCPU][FETCHARG][(address >> PROG_PAGE_BITS)][address & PROG_PAGE_MASK];
|
||||
}
|
||||
|
||||
if (prog_fetcharg[nActiveCPU]) {
|
||||
return prog_fetcharg[nActiveCPU](address);
|
||||
}
|
||||
|
||||
// fall back to read
|
||||
if (Mem[nActiveCPU][READ ][(address >> PROG_PAGE_BITS)]) {
|
||||
return Mem[nActiveCPU][READ ][(address >> PROG_PAGE_BITS)][address & PROG_PAGE_MASK];
|
||||
}
|
||||
|
||||
if (prog_read[nActiveCPU]) {
|
||||
return prog_read[nActiveCPU](address);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT8 __fastcall z180_cpu_fetcharg_handler(UINT32 address)
|
||||
{
|
||||
address &= PROG_MASK;
|
||||
|
||||
if (Mem[nActiveCPU][FETCHARG][(address >> PROG_PAGE_BITS)]) {
|
||||
return Mem[nActiveCPU][FETCHARG][(address >> PROG_PAGE_BITS)][address & PROG_PAGE_MASK];
|
||||
}
|
||||
|
||||
if (prog_fetcharg[nActiveCPU]) {
|
||||
return prog_fetcharg[nActiveCPU](address);
|
||||
}
|
||||
|
||||
// fall back to op
|
||||
if (Mem[nActiveCPU][FETCHOP][(address >> PROG_PAGE_BITS)]) {
|
||||
return Mem[nActiveCPU][FETCHOP][(address >> PROG_PAGE_BITS)][address & PROG_PAGE_MASK];
|
||||
}
|
||||
|
||||
if (prog_fetchop[nActiveCPU]) {
|
||||
return prog_fetchop[nActiveCPU](address);
|
||||
}
|
||||
|
||||
// fall back to read
|
||||
if (Mem[nActiveCPU][READ ][(address >> PROG_PAGE_BITS)]) {
|
||||
return Mem[nActiveCPU][READ ][(address >> PROG_PAGE_BITS)][address & PROG_PAGE_MASK];
|
||||
}
|
||||
|
||||
if (prog_read[nActiveCPU]) {
|
||||
return prog_read[nActiveCPU](address);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT8 __fastcall z180_cpu_read_handler(UINT32 address)
|
||||
{
|
||||
address &= PROG_MASK;
|
||||
|
||||
if (Mem[nActiveCPU][READ ][(address >> PROG_PAGE_BITS)]) {
|
||||
return Mem[nActiveCPU][READ ][(address >> PROG_PAGE_BITS)][address & PROG_PAGE_MASK];
|
||||
}
|
||||
|
||||
if (prog_read[nActiveCPU]) {
|
||||
return prog_read[nActiveCPU](address);
|
||||
}
|
||||
|
||||
if (Mem[nActiveCPU][FETCHOP][(address >> PROG_PAGE_BITS)]) {
|
||||
return Mem[nActiveCPU][FETCHOP][(address >> PROG_PAGE_BITS)][address & PROG_PAGE_MASK];
|
||||
}
|
||||
|
||||
if (prog_fetchop[nActiveCPU]) {
|
||||
return prog_fetchop[nActiveCPU](address);
|
||||
}
|
||||
|
||||
if (Mem[nActiveCPU][FETCHARG][(address >> PROG_PAGE_BITS)]) {
|
||||
return Mem[nActiveCPU][FETCHARG][(address >> PROG_PAGE_BITS)][address & PROG_PAGE_MASK];
|
||||
}
|
||||
|
||||
if (prog_fetcharg[nActiveCPU]) {
|
||||
return prog_fetcharg[nActiveCPU](address);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __fastcall z180_cpu_write_port_handler(UINT32 address, UINT8 data)
|
||||
{
|
||||
address &= PORT_MASK;
|
||||
|
||||
if (port_write[nActiveCPU]) {
|
||||
port_write[nActiveCPU](address,data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UINT8 __fastcall z180_cpu_read_port_handler(UINT32 address)
|
||||
{
|
||||
address &= PORT_MASK;
|
||||
|
||||
if (port_read[nActiveCPU]) {
|
||||
return port_read[nActiveCPU](address);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
UINT8 z180_cheat_read(UINT32 address)
|
||||
{
|
||||
return z180_cpu_read_handler(address);
|
||||
}
|
||||
|
||||
void z180_cheat_write(UINT32 address, UINT8 data)
|
||||
{
|
||||
if (Mem[nActiveCPU][FETCHOP][(address >> PROG_PAGE_BITS)]) {
|
||||
Mem[nActiveCPU][FETCHOP][(address >> PROG_PAGE_BITS)][address & PROG_PAGE_MASK] = data;
|
||||
}
|
||||
|
||||
if (Mem[nActiveCPU][FETCHARG][(address >> PROG_PAGE_BITS)]) {
|
||||
Mem[nActiveCPU][FETCHARG][(address >> PROG_PAGE_BITS)][address & PROG_PAGE_MASK] = data;
|
||||
}
|
||||
|
||||
if (Mem[nActiveCPU][READ ][(address >> PROG_PAGE_BITS)]) {
|
||||
Mem[nActiveCPU][READ ][(address >> PROG_PAGE_BITS)][address & PROG_PAGE_MASK] = data;
|
||||
}
|
||||
|
||||
if (Mem[nActiveCPU][WRITE][(address >> PROG_PAGE_BITS)]) {
|
||||
Mem[nActiveCPU][WRITE][(address >> PROG_PAGE_BITS)][address & PROG_PAGE_MASK] = data;
|
||||
return;
|
||||
}
|
||||
|
||||
if (prog_write[nActiveCPU]) {
|
||||
prog_write[nActiveCPU](address, data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static cpu_core_config Z180CheatCpuConfig =
|
||||
{
|
||||
Z180Open,
|
||||
Z180Close,
|
||||
z180_cheat_read,
|
||||
z180_cheat_write,
|
||||
Z180GetActive,
|
||||
Z180TotalCycles,
|
||||
Z180NewFrame,
|
||||
Z180Run,
|
||||
Z180RunEnd,
|
||||
Z180Reset,
|
||||
PROG_RANGE,
|
||||
0
|
||||
};
|
||||
|
||||
void Z180Init(UINT32 nCPU)
|
||||
{
|
||||
DebugCPU_Z180Initted = 1;
|
||||
|
||||
#if defined FBA_DEBUG
|
||||
if (nCPU >= NUM_CPUS) bprintf(PRINT_ERROR, _T("Z180Init called with invalid nCPU (%d), max is %d\n"), nCPU, NUM_CPUS-1);
|
||||
if (nCPU >= NUM_CPUS) nCPU = 0;
|
||||
#endif
|
||||
|
||||
nActiveCPU = nCPU; // default
|
||||
|
||||
z180_init(nActiveCPU, 0, dummy_irq_callback);
|
||||
|
||||
memset (Mem[nActiveCPU], 0, 4 * PROG_PAGES * sizeof(UINT8*));
|
||||
|
||||
prog_write[nActiveCPU] = NULL;
|
||||
prog_read[nActiveCPU] = NULL;
|
||||
prog_fetchop[nActiveCPU] = NULL;
|
||||
prog_fetcharg[nActiveCPU] = NULL;
|
||||
port_write[nActiveCPU] = NULL;
|
||||
port_read[nActiveCPU] = NULL;
|
||||
|
||||
CpuCheatRegister(nActiveCPU, &Z180CheatCpuConfig);
|
||||
|
||||
nActiveCPU = -1; // default
|
||||
}
|
27
src/cpu/z180_intf.h
Normal file
27
src/cpu/z180_intf.h
Normal file
@ -0,0 +1,27 @@
|
||||
#include "z180.h"
|
||||
|
||||
void Z180SetWriteHandler(void __fastcall (*write)(UINT32, UINT8));
|
||||
void Z180SetReadHandler(UINT8 __fastcall (*read)(UINT32));
|
||||
void Z180SetFetchOpHandler(UINT8 __fastcall (*fetch)(UINT32));
|
||||
void Z180SetFetchArgHandler(UINT8 __fastcall (*fetch)(UINT32));
|
||||
void Z180SetWritePortHandler(void __fastcall (*write)(UINT32, UINT8));
|
||||
void Z180SetReadPortHandler(UINT8 __fastcall (*read)(UINT32));
|
||||
|
||||
// pass NULL for ptr to unmap memory
|
||||
void Z180MapMemory(UINT8 *ptr, UINT32 start, UINT32 end, UINT32 flags);
|
||||
|
||||
void Z180Init(UINT32 nCPU);
|
||||
void Z180Exit();
|
||||
void Z180Reset();
|
||||
INT32 Z180Run(INT32 cycles);
|
||||
void Z180BurnCycles(INT32 cycles);
|
||||
void Z180SetIRQLine(INT32 irqline, INT32 state);
|
||||
void Z180Scan();
|
||||
|
||||
INT32 Z180GetActive();
|
||||
void Z180Open(INT32);
|
||||
void Z180Close();
|
||||
|
||||
INT32 Z180TotalCycles();
|
||||
void Z180NewFrame();
|
||||
void Z180RunEnd();
|
Loading…
Reference in New Issue
Block a user