T-Unit Driver WIP

This commit is contained in:
Barry Harris 2018-12-07 19:33:30 +00:00
parent ee60a7f9f3
commit 5c28b721c0
4 changed files with 778 additions and 2 deletions

View File

@ -31,7 +31,7 @@ drvsrc = d_arcadecl.cpp d_atarig1.cpp d_badlands.cpp d_batman.cpp d_blstroid.cp
d_rollerg.o d_sbasketb.o d_scotrsht.o d_shaolins.o d_simpsons.o d_spy.o d_surpratk.o d_thunderx.o d_timeplt.o d_tmnt.o d_tp84.o d_trackfld.o \
d_tutankhm.o d_twin16.o d_ultraman.o d_vendetta.o d_xexex.o d_xmen.o d_yiear.o \
\
d_wunit.o \
d_tunit.o d_wunit.o \
\
d_neogeo.o \
\
@ -134,7 +134,7 @@ depobj = burn.o burn_bitmap.o burn_gun.o burn_led.o burn_shift.o burn_memory.o
k007121.o k007342_k007420.o k051316.o k051733.o k051960.o k052109.o k053245.o k053247.o k053250.o k053251.o k053936.o k054000.o k054338.o \
k055555.o k056832.o konamigx.o konamiic.o timeplt_snd.o \
\
dcs2k.o midwayic.o midwunit.o \
dcs2k.o midwayic.o midtunit.o midwunit.o \
\
neo_decrypt.o neo_palette.o neo_run.o neo_sprite.o neo_text.o neo_upd4990a.o neogeo.o \
\

View File

@ -0,0 +1,146 @@
#include "driver.h"
#include "burnint.h"
#include "midtunit.h"
static struct BurnInputInfo MkInputList[] = {
{ "Coin 1", BIT_DIGITAL, nTUnitJoy2 + 0, "p1 coin" },
{ "Coin 2", BIT_DIGITAL, nTUnitJoy2 + 1, "p2 coin" },
{ "Coin 3", BIT_DIGITAL, nTUnitJoy2 + 7, "p1 coin" },
{ "Coin 4", BIT_DIGITAL, nTUnitJoy2 + 8, "p2 coin" },
{ "P1 Start", BIT_DIGITAL, nTUnitJoy2 + 2, "p1 start" },
{ "P1 Up", BIT_DIGITAL, nTUnitJoy1 + 0, "p1 up" },
{ "P1 Down", BIT_DIGITAL, nTUnitJoy1 + 1, "p1 down" },
{ "P1 Left", BIT_DIGITAL, nTUnitJoy1 + 2, "p1 left" },
{ "P1 Right", BIT_DIGITAL, nTUnitJoy1 + 3, "p1 right" },
{ "P1 Button 1", BIT_DIGITAL, nTUnitJoy1 + 4, "p1 fire 1" },
{ "P1 Button 2", BIT_DIGITAL, nTUnitJoy1 + 5, "p1 fire 2" },
{ "P1 Button 3", BIT_DIGITAL, nTUnitJoy1 + 6, "p1 fire 3" },
{ "P1 Button 4", BIT_DIGITAL, nTUnitJoy2 + 12, "p1 fire 4" },
{ "P1 Button 5", BIT_DIGITAL, nTUnitJoy2 + 13, "p1 fire 5" },
{ "P1 Button 6", BIT_DIGITAL, nTUnitJoy2 + 15, "p1 fire 6" },
{ "P2 Start", BIT_DIGITAL, nTUnitJoy2 + 5, "p2 start" },
{ "P2 Up", BIT_DIGITAL, nTUnitJoy1 + 8, "p2 up" },
{ "P2 Down", BIT_DIGITAL, nTUnitJoy1 + 9, "p2 down" },
{ "P2 Left", BIT_DIGITAL, nTUnitJoy1 + 10, "p2 left" },
{ "P2 Right", BIT_DIGITAL, nTUnitJoy1 + 11, "p2 right" },
{ "P2 Button 1", BIT_DIGITAL, nTUnitJoy1 + 12, "p2 fire 1" },
{ "P2 Button 2", BIT_DIGITAL, nTUnitJoy1 + 13, "p2 fire 2" },
{ "P2 Button 3", BIT_DIGITAL, nTUnitJoy1 + 14, "p2 fire 3" },
{ "P2 Button 4", BIT_DIGITAL, nTUnitJoy2 + 9, "p2 fire 4" },
{ "P2 Button 5", BIT_DIGITAL, nTUnitJoy2 + 10, "p2 fire 5" },
{ "P2 Button 6", BIT_DIGITAL, nTUnitJoy2 + 11, "p2 fire 6" },
{ "Reset", BIT_DIGITAL, &nTUnitReset, "reset" },
{ "Service", BIT_DIGITAL, nTUnitJoy2 + 6, "service" },
{ "Service Mode", BIT_DIGITAL, nTUnitJoy2 + 4, "diag" },
{ "Tilt", BIT_DIGITAL, nTUnitJoy2 + 3, "tilt" },
{ "Dip A", BIT_DIPSWITCH, nTUnitDSW + 0, "dip" },
{ "Dip B", BIT_DIPSWITCH, nTUnitDSW + 1, "dip" },
};
STDINPUTINFO(Mk)
static struct BurnDIPInfo MkDIPList[]=
{
{0x1e, 0xff, 0xff, 0x7d, NULL },
{0x1f, 0xff, 0xff, 0xf0, NULL },
{0 , 0xfe, 0 , 2, "Test Switch" },
{0x1e, 0x01, 0x01, 0x01, "Off" },
{0x1e, 0x01, 0x01, 0x00, "On" },
{0 , 0xfe, 0 , 2, "Counters" },
{0x1e, 0x01, 0x02, 0x02, "One" },
{0x1e, 0x01, 0x02, 0x00, "Two" },
{0 , 0xfe, 0 , 19, "Coinage" },
{0x1e, 0x01, 0x7c, 0x7c, "USA-1" },
{0x1e, 0x01, 0x7c, 0x3c, "USA-2" },
{0x1e, 0x01, 0x7c, 0x5c, "USA-3" },
{0x1e, 0x01, 0x7c, 0x1c, "USA-4" },
{0x1e, 0x01, 0x7c, 0x6c, "USA-ECA" },
{0x1e, 0x01, 0x7c, 0x0c, "USA-Free Play" },
{0x1e, 0x01, 0x7c, 0x74, "German-1" },
{0x1e, 0x01, 0x7c, 0x34, "German-2" },
{0x1e, 0x01, 0x7c, 0x54, "German-3" },
{0x1e, 0x01, 0x7c, 0x14, "German-4" },
{0x1e, 0x01, 0x7c, 0x64, "German-5" },
{0x1e, 0x01, 0x7c, 0x24, "German-ECA" },
{0x1e, 0x01, 0x7c, 0x04, "German-Free Play" },
{0x1e, 0x01, 0x7c, 0x78, "French-1" },
{0x1e, 0x01, 0x7c, 0x38, "French-2" },
{0x1e, 0x01, 0x7c, 0x58, "French-3" },
{0x1e, 0x01, 0x7c, 0x18, "French-4" },
{0x1e, 0x01, 0x7c, 0x68, "French-ECA" },
{0x1e, 0x01, 0x7c, 0x08, "French-Free Play" },
{0 , 0xfe, 0 , 2, "Coinage Source" },
{0x1e, 0x01, 0x80, 0x80, "Dipswitch" },
{0x1e, 0x01, 0x80, 0x00, "CMOS" },
{0 , 0xfe, 0 , 2, "Skip Powerup Test" },
{0x1f, 0x01, 0x01, 0x01, "Off" },
{0x1f, 0x01, 0x01, 0x00, "On" },
{0 , 0xfe, 0 , 2, "Comic Book Offer" },
{0x1f, 0x01, 0x08, 0x00, "Off" },
{0x1f, 0x01, 0x08, 0x08, "On" },
{0 , 0xfe, 0 , 2, "Attract Sound" },
{0x1f, 0x01, 0x10, 0x00, "Off" },
{0x1f, 0x01, 0x10, 0x10, "On" },
{0 , 0xfe, 0 , 2, "Low Blows" },
{0x1f, 0x01, 0x20, 0x00, "Off" },
{0x1f, 0x01, 0x20, 0x20, "On" },
{0 , 0xfe, 0 , 2, "Blood" },
{0x1f, 0x01, 0x40, 0x00, "Off" },
{0x1f, 0x01, 0x40, 0x40, "On" },
{0 , 0xfe, 0 , 2, "Violence" },
{0x1f, 0x01, 0x80, 0x00, "Off" },
{0x1f, 0x01, 0x80, 0x80, "On" },
};
STDDIPINFO(Mk)
static struct BurnRomInfo mkRomDesc[] = {
{ "mkt-uj12.bin", 0x080000, 0xf4990bf2, 1 | BRF_PRG | BRF_ESS }, // 0 TMS34010
{ "mkt-ug12.bin", 0x080000, 0xb06aeac1, 1 | BRF_PRG | BRF_ESS }, // 1
{ "sl1_mortal_kombat_u12_sound_rom.u12", 0x040000, 0x258bd7f9, 2 | BRF_PRG | BRF_ESS }, // 2 ADPCM sound banks
{ "sl1_mortal_kombat_u13_sound_rom.u13", 0x040000, 0x7b7ec3b6, 2 | BRF_PRG | BRF_ESS }, // 3
{ "mkt-ug14.bin", 0x080000, 0x9e00834e, 3 | BRF_GRA | BRF_ESS | TUNIT_GFX(0x00, 0) }, // 4 GFX
{ "mkt-uj14.bin", 0x080000, 0xf4b0aaa7, 3 | BRF_GRA | BRF_ESS | TUNIT_GFX(0x00, 1) }, // 5
{ "mkt-ug19.bin", 0x080000, 0x2d8c7ba1, 3 | BRF_GRA | BRF_ESS | TUNIT_GFX(0x00, 2) }, // 6
{ "mkt-uj19.bin", 0x080000, 0x33b9b7a4, 3 | BRF_GRA | BRF_ESS | TUNIT_GFX(0x00, 3) }, // 7
{ "mkt-ug16.bin", 0x080000, 0x52c9d1e5, 3 | BRF_GRA | BRF_ESS | TUNIT_GFX(0x02, 0) }, // 8
{ "mkt-uj16.bin", 0x080000, 0xc94c58cf, 3 | BRF_GRA | BRF_ESS | TUNIT_GFX(0x02, 1) }, // 9
{ "mkt-ug20.bin", 0x080000, 0x2f7e55d3, 3 | BRF_GRA | BRF_ESS | TUNIT_GFX(0x02, 2) }, // 10
{ "mkt-uj20.bin", 0x080000, 0xeae96df0, 3 | BRF_GRA | BRF_ESS | TUNIT_GFX(0x02, 3) }, // 11
{ "mkt-ug17.bin", 0x080000, 0xe34fe253, 3 | BRF_GRA | BRF_ESS | TUNIT_GFX(0x04, 0) }, // 12
{ "mkt-uj17.bin", 0x080000, 0xa56e12f5, 3 | BRF_GRA | BRF_ESS | TUNIT_GFX(0x04, 1) }, // 13
{ "mkt-ug22.bin", 0x080000, 0xb537bb4e, 3 | BRF_GRA | BRF_ESS | TUNIT_GFX(0x04, 2) }, // 14
{ "mkt-uj22.bin", 0x080000, 0x5e12523b, 3 | BRF_GRA | BRF_ESS | TUNIT_GFX(0x04, 3) }, // 15
{ "sl1_mortal_kombat_u3_sound_rom.u3", 0x040000, 0xc615844c, 4 | BRF_PRG | BRF_ESS }, // 16 Sound CPU
};
STD_ROM_PICK(mk)
STD_ROM_FN(mk)
struct BurnDriverD BurnDrvMk = {
"mk", NULL, NULL, NULL, "1992",
"Mortal Kombat (rev 5.0 T-Unit 03/19/93)\0", NULL, "Midway", "MIDWAY T-Unit",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_16BIT_ONLY, 2, HARDWARE_MIDWAY_TUNIT, GBF_MISC, 0,
NULL, mkRomInfo, mkRomName, NULL, NULL, MkInputInfo, MkDIPInfo,
TUnitInit, TUnitExit, TUnitFrame, TUnitDraw, TUnitScan, &nTUnitRecalc, 0x8000,
400, 254, 4, 3
};

View File

@ -0,0 +1,611 @@
#include "tiles_generic.h"
#include "midtunit.h"
#include "tms34010_intf.h"
#include "m6809_intf.h"
#include "burn_ym2151.h"
static UINT8 *AllMem;
static UINT8 *RamEnd;
static UINT8 *AllRam;
static UINT8 *MemEnd;
static UINT8 *DrvBootROM;
static UINT8 *DrvSoundROM;
static UINT8 *DrvGfxROM;
static UINT8 *DrvRAM;
static UINT8 *DrvNVRAM;
static UINT8 *DrvPalette;
static UINT32 *DrvPaletteB;
static UINT8 *DrvVRAM;
static UINT16 *DrvVRAM16;
static UINT8 *DrvSoundProgROM;
static UINT8 *DrvSoundProgRAM;
UINT8 nTUnitRecalc;
UINT8 nTUnitJoy1[32];
UINT8 nTUnitJoy2[32];
UINT8 nTUnitJoy3[32];
UINT8 nTUnitDSW[8];
UINT8 nTUnitReset = 0;
static UINT32 DrvInputs[4];
static bool bGfxRomLarge = false;
static UINT32 nGfxBankOffset[2] = { 0x000000, 0x400000 };
static bool bCMOSWriteEnable = false;
static UINT32 nVideoBank = 1;
static UINT16 nDMA[32];
static UINT16 nTUnitCtrl = 0;
static UINT8 DrvFakeSound = 0;
static UINT8 MKProtIndex = 0;
#define RGB888(r,g,b) ((r) | ((g) << 8) | ((b) << 16))
#define RGB888_r(x) ((x) & 0xFF)
#define RGB888_g(x) (((x) >> 8) & 0xFF)
#define RGB888_b(x) (((x) >> 16) & 0xFF)
#define RGB555_2_888(x) \
RGB888((x >> 7) & 0xF8, \
(x >> 2) & 0xF8, \
(x << 3) & 0xF8)
#define RGB888_2_565(x) ( \
((RGB888_r(x) << 8) & 0xF800) | \
((RGB888_g(x) << 3) & 0x07E0) | \
((RGB888_b(x) >> 3)))
#include "midtunit_dma.h"
static INT32 MemIndex()
{
UINT8 *Next; Next = AllMem;
DrvBootROM = Next; Next += 0x800000 * sizeof(UINT8);
DrvSoundROM = Next; Next += 0x1000000 * sizeof(UINT8);
DrvGfxROM = Next; Next += 0x2000000 * sizeof(UINT8);
DrvSoundProgROM = Next; Next +- 0x0040000 * sizeof(UINT8);
AllRam = Next;
DrvSoundProgRAM = Next; Next += 0x002000 * sizeof(UINT8);
DrvRAM = Next; Next += 0x400000 * sizeof(UINT16);
DrvNVRAM = Next; Next += 0x60000 * sizeof(UINT16);
DrvPalette = Next; Next += 0x20000 * sizeof(UINT8);
DrvPaletteB = (UINT32*)Next; Next += 0x8000 * sizeof(UINT32);
DrvVRAM = Next; Next += 0x400000 * sizeof(UINT16);
DrvVRAM16 = (UINT16*)DrvVRAM;
RamEnd = Next;
MemEnd = Next;
return 0;
}
static INT32 LoadGfxBanks()
{
char *pRomName;
struct BurnRomInfo pri;
for (INT32 i = 0; !BurnDrvGetRomName(&pRomName, i, 0); i++) {
BurnDrvGetRomInfo(&pri, i);
if ((pri.nType & 7) == 3) {
UINT32 addr = TUNIT_GFX_ADR(pri.nType) << 20;
UINT32 offs = TUNIT_GFX_OFF(pri.nType);
if (BurnLoadRom(DrvGfxROM + addr + offs, i, 4) != 0) {
return 1;
}
}
}
return 0;
}
static INT32 LoadSoundProgRom()
{
char *pRomName;
struct BurnRomInfo pri;
for (INT32 i = 0; !BurnDrvGetRomName(&pRomName, i, 0); i++) {
BurnDrvGetRomInfo(&pri, i);
if ((pri.nType & 7) == 4) {
if (BurnLoadRom(DrvSoundProgROM, i, 1) != 0) {
return 1;
}
}
}
return 0;
}
static void TUnitToShift(UINT32 address, void *dst)
{
memcpy(dst, &DrvVRAM16[(address >> 3)], 4096/2);
}
static void TUnitFromShift(UINT32 address, void *src)
{
memcpy(&DrvVRAM16[(address >> 3)], src, 4096/2);
}
static void TUnitDoReset()
{
TMS34010Reset();
M6809Open(0);
M6809Reset();
M6809Close();
BurnYM2151Reset();
MKProtIndex = 0;
DrvFakeSound = 0;
}
static UINT16 TUnitVramRead(UINT32 address)
{
UINT32 offset = TOBYTE(address & 0x3fffff);
if (nVideoBank)
return (DrvVRAM16[offset] & 0x00ff) | (DrvVRAM16[offset + 1] << 8);
else
return (DrvVRAM16[offset] >> 8) | (DrvVRAM16[offset + 1] & 0xff00);
}
static void TUnitVramWrite(UINT32 address, UINT16 data)
{
UINT32 offset = TOBYTE(address & 0x3fffff);
if (nVideoBank)
{
DrvVRAM16[offset] = (data & 0xff) | ((nDMA[DMA_PALETTE] & 0xff) << 8);
DrvVRAM16[offset + 1] = ((data >> 8) & 0xff) | (nDMA[DMA_PALETTE] & 0xff00);
}
else
{
DrvVRAM16[offset] = (DrvVRAM16[offset] & 0xff) | ((data & 0xff) << 8);
DrvVRAM16[offset + 1] = (DrvVRAM16[offset + 1] & 0xff) | (data & 0xff00);
}
}
static UINT16 TUnitPalRead(UINT32 address)
{
address &= 0x7FFFF;
return *(UINT16*)(&DrvPalette[TOBYTE(address)]);
}
static void TUnitPalWrite(UINT32 address, UINT16 value)
{
address &= 0x7FFFF;
*(UINT16*)(&DrvPalette[TOBYTE(address)]) = value;
UINT32 col = RGB555_2_888(BURN_ENDIAN_SWAP_INT16(value));
DrvPaletteB[address>>4] = BurnHighCol(RGB888_r(col),RGB888_g(col),RGB888_b(col),0);
}
static void TUnitPalRecalc()
{
for (INT32 i = 0; i < 0x10000; i += 2) {
UINT16 value = *(UINT16*)(&DrvPalette[i]);
UINT32 col = RGB555_2_888(BURN_ENDIAN_SWAP_INT16(value));
DrvPaletteB[i>>1] = BurnHighCol(RGB888_r(col),RGB888_g(col),RGB888_b(col),0);
}
}
static INT32 ScanlineRender(INT32 line, TMS34010Display *info)
{
if (!pBurnDraw) return 0;
UINT16 *src = &DrvVRAM16[(info->rowaddr << 9) & 0x3FE00];
if (info->rowaddr >= nScreenHeight) return 0;
INT32 col = info->coladdr << 1;
UINT16 *dest = (UINT16*) pTransDraw + (info->rowaddr * nScreenWidth);
const INT32 heblnk = info->heblnk;
const INT32 hsblnk = info->hsblnk * 2; // T-Unit is 2 pixels per clock
for (INT32 x = heblnk; x < hsblnk; x++) {
dest[x - heblnk] = src[col++ & 0x1FF] & 0x7FFF;
}
return 0;
}
static UINT16 TUnitRead(UINT32 address)
{
if (address == 0x01600040) return 0xff; // ???
if (address == 0x01d81070) return 0xff; // watchdog
bprintf(PRINT_NORMAL, _T("Read %x\n"), address);
return ~0;
}
static void TUnitWrite(UINT32 address, UINT16 value)
{
if (address == 0x01d81070) return; // watchdog
bprintf(PRINT_NORMAL, _T("Write %x, %x\n"), address, value);
}
static UINT16 TUnitInputRead(UINT32 address)
{
INT32 offset = (address & 0xff) >> 4;
switch (offset) {
case 0x00: return ~DrvInputs[0];
case 0x01: return ~DrvInputs[1];
case 0x02: return ~DrvInputs[2];
case 0x03: return nTUnitDSW[0] | (nTUnitDSW[1] << 8);
}
return ~0;
}
static UINT16 TUnitGfxRead(UINT32 address)
{
//uint8_t *base = m_gfxrom->base() + gfxbank_offset[(offset >> 21) & 1];
UINT8 *base = DrvGfxROM + nGfxBankOffset[0];
UINT32 offset = TOBYTE(address - 0x02000000);
return base[offset] | (base[offset + 1] << 8);
}
static UINT16 TUnitSoundStateRead(UINT32 address)
{
//bprintf(PRINT_NORMAL, _T("Sound State Read %x\n"), address);
if (DrvFakeSound) {
DrvFakeSound--;
return 0;
}
return ~0;
}
static UINT16 TUnitSoundRead(UINT32 address)
{
bprintf(PRINT_NORMAL, _T("Sound Read %x\n"), address);
return ~0;
}
static void TUnitSoundWrite(UINT32 address, UINT16 value)
{
bprintf(PRINT_NORMAL, _T("Sound Write %x, %x\n"), address, value);
}
static void TUnitCtrlWrite(UINT32 address, UINT16 value)
{
nTUnitCtrl = value;
if (!(nTUnitCtrl & 0x0080) || !bGfxRomLarge) {
nGfxBankOffset[0] = 0x000000;
} else {
nGfxBankOffset[0] = 0x800000;
}
nVideoBank = (nTUnitCtrl >> 5) & 1;
}
static void TUnitCMOSWriteEnable(UINT32 address, UINT16 value)
{
bCMOSWriteEnable = true;
}
static UINT16 TUnitCMOSRead(UINT32 address)
{
UINT16 *wn = (UINT16*)DrvNVRAM;
UINT32 offset = (address & 0x01ffff) >> 1;
return wn[offset];
}
static void TUnitCMOSWrite(UINT32 address, UINT16 value)
{
UINT16 *wn = (UINT16*)DrvNVRAM;
UINT32 offset = (address & 0x01ffff) >> 1;
wn[offset] = value;
}
static const uint8_t mk_prot_values[] =
{
0x13, 0x27, 0x0f, 0x1f, 0x3e, 0x3d, 0x3b, 0x37,
0x2e, 0x1c, 0x38, 0x31, 0x22, 0x05, 0x0a, 0x15,
0x2b, 0x16, 0x2d, 0x1a, 0x34, 0x28, 0x10, 0x21,
0x03, 0x06, 0x0c, 0x19, 0x32, 0x24, 0x09, 0x13,
0x27, 0x0f, 0x1f, 0x3e, 0x3d, 0x3b, 0x37, 0x2e,
0x1c, 0x38, 0x31, 0x22, 0x05, 0x0a, 0x15, 0x2b,
0x16, 0x2d, 0x1a, 0x34, 0x28, 0x10, 0x21, 0x03,
0xff
};
static UINT16 MKProtRead(UINT32 /*address*/)
{
if (MKProtIndex >= sizeof(mk_prot_values)) {
MKProtIndex = 0;
}
return mk_prot_values[MKProtIndex++] << 9;
}
static void MKProtWrite(UINT32 /*address*/, UINT16 value)
{
INT32 first_val = (value >> 9) & 0x3f;
INT32 i;
for (i = 0; i < sizeof(mk_prot_values); i++) {
if (mk_prot_values[i] == first_val) {
MKProtIndex = i;
break;
}
}
if (i == sizeof(mk_prot_values)) {
MKProtIndex = 0;
}
}
static void MKYM2151IrqHandler(INT32 Irq)
{
M6809SetIRQLine(M6809_FIRQ_LINE, (Irq) ? CPU_IRQSTATUS_ACK : CPU_IRQSTATUS_NONE);
}
static UINT8 MKSoundRead(UINT16 address)
{
switch (address) {
}
bprintf(PRINT_NORMAL, _T("M6809 Read Byte -> %04X\n"), address);
return 0;
}
static void MKSoundWrite(UINT16 address, UINT8 value)
{
if (address >= 0x4000) return; // ROM
switch (address) {
case 0x2400: {
BurnYM2151SelectRegister(value);
return;
}
case 0x2401: {
BurnYM2151WriteRegister(value);
return;
}
}
bprintf(PRINT_NORMAL, _T("M6809 Write Byte -> %04X, %02X\n"), address, value);
}
INT32 TUnitInit()
{
MemIndex();
INT32 nLen = MemEnd - (UINT8 *)0;
if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL)
return 1;
MemIndex();
UINT32 nRet;
nRet = BurnLoadRom(DrvBootROM + 0, 0, 2);
if (nRet != 0) return 1;
nRet = BurnLoadRom(DrvBootROM + 1, 1, 2);
if (nRet != 0) return 1;
nRet = LoadSoundProgRom();
if (nRet != 0) return 1;
/* nRet = LoadSoundBanks();
if (nRet != 0)
return 1;*/
nRet = LoadGfxBanks();
if (nRet != 0) return 1;
BurnSetRefreshRate(54.71);
TMS34010MapReset();
TMS34010Init();
TMS34010SetScanlineRender(ScanlineRender);
TMS34010SetToShift(TUnitToShift);
TMS34010SetFromShift(TUnitFromShift);
#if 0
// barry - for reference - unmapped memory
map(0x01b00000, 0x01b0001f).w(FUNC(midtunit_state::midtunit_control_w));
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1b00000, 0x1b6ffff, read16_delegate(FUNC(midtunit_state::mk_prot_r),this), write16_delegate(FUNC(midtunit_state::mk_prot_w),this));
map(0x02000000, 0x07ffffff).r(FUNC(midtunit_state::midtunit_gfxrom_r)).share("gfxrom");
#endif
// this will be removed - but putting all unmapped memory through generic handlers to enable logging unmapped reads/writes
TMS34010SetHandlers(1, TUnitRead, TUnitWrite);
TMS34010MapHandler(1, 0x00000000, 0x1FFFFFFF, MAP_READ | MAP_WRITE);
TMS34010MapMemory(DrvBootROM, 0xFF800000, 0xFFFFFFFF, MAP_READ);
TMS34010MapMemory(DrvBootROM, 0x1F800000, 0x1FFFFFFF, MAP_READ); // mirror
TMS34010MapMemory(DrvRAM, 0x01000000, 0x013FFFFF, MAP_READ | MAP_WRITE);
TMS34010SetHandlers(2, TUnitVramRead, TUnitVramWrite);
TMS34010MapHandler(2, 0x00000000, 0x003fffff, MAP_READ | MAP_WRITE);
TMS34010SetHandlers(3, TUnitCMOSRead, TUnitCMOSWrite);
TMS34010MapHandler(3, 0x01400000, 0x0141ffff, MAP_READ | MAP_WRITE);
TMS34010SetWriteHandler(4, TUnitCMOSWriteEnable);
TMS34010MapHandler(4, 0x01480000, 0x014fffff, MAP_READ | MAP_WRITE);
TMS34010SetReadHandler(5, TUnitInputRead);
TMS34010MapHandler(5, 0x01600000, 0x0160003f, MAP_READ);
TMS34010SetHandlers(6, TUnitPalRead, TUnitPalWrite);
TMS34010MapHandler(6, 0x01800000, 0x0187ffff, MAP_READ | MAP_WRITE);
TMS34010SetHandlers(7, TUnitDmaRead, TUnitDmaWrite);
TMS34010MapHandler(7, 0x01a80000, 0x01a800ff, MAP_READ | MAP_WRITE);
TMS34010SetHandlers(8, MKProtRead, MKProtWrite);
TMS34010MapHandler(8, 0x01b00000, 0x1b6ffff, MAP_READ | MAP_WRITE);
TMS34010SetReadHandler(9, TUnitSoundStateRead);
TMS34010MapHandler(9, 0x01d00000, 0x01d0001f, MAP_READ);
TMS34010SetHandlers(10, TUnitSoundRead, TUnitSoundWrite);
TMS34010MapHandler(10, 0x01d01020, 0x01d0103f, MAP_READ | MAP_WRITE);
TMS34010SetWriteHandler(11, TUnitCtrlWrite);
TMS34010MapHandler(11, 0x01f00000, 0x01f0001f, MAP_WRITE);
TMS34010SetReadHandler(12, TUnitGfxRead);
TMS34010MapHandler(12, 0x02000000, 0x07ffffff, MAP_READ);
memset(DrvVRAM, 0, 0x400000);
M6809Init(0);
M6809Open(0);
M6809MapMemory(DrvSoundProgRAM , 0x0000, 0x1fff, MAP_RAM);
M6809MapMemory(DrvSoundProgROM , 0x4000, 0xbfff, MAP_ROM);
M6809MapMemory(DrvSoundProgROM + 0x8000, 0xc000, 0xffff, MAP_ROM);
M6809SetReadHandler(MKSoundRead);
M6809SetWriteHandler(MKSoundWrite);
M6809Close();
BurnYM2151Init(3579545);
BurnYM2151SetIrqHandler(&MKYM2151IrqHandler);
BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT);
BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT);
GenericTilesInit();
TUnitDoReset();
return 0;
}
static void MakeInputs()
{
DrvInputs[0] = 0;
DrvInputs[1] = 0;
DrvInputs[2] = 0;
DrvInputs[3] = 0;
for (INT32 i = 0; i < 16; i++) {
if (nTUnitJoy1[i] & 1) DrvInputs[0] |= (1 << i);
if (nTUnitJoy2[i] & 1) DrvInputs[1] |= (1 << i);
if (nTUnitJoy3[i] & 1) DrvInputs[2] |= (1 << i);
}
}
INT32 TUnitExit()
{
BurnFree(AllMem);
M6809Exit();
BurnYM2151Exit();
GenericTilesExit();
return 0;
}
INT32 TUnitDraw()
{
if (nTUnitRecalc) {
bprintf(0, _T("\nRecalculating the palette!!!!\n"));
TUnitPalRecalc();
nTUnitRecalc = 0;
}
// TMS34010 renders scanlines direct to pTransDraw
BurnTransferCopy(DrvPaletteB);
return 0;
}
INT32 TUnitFrame()
{
if (nTUnitReset) TUnitDoReset();
MakeInputs();
TMS34010NewFrame();
M6809NewFrame();
INT32 nInterleave = 288;
INT32 nCyclesTotal[2] = { (INT32)(50000000/8/54.71), (INT32)(2000000 / 54.71) };
INT32 nCyclesDone[2] = { 0, 0 };
INT32 nSoundBufferPos = 0;
M6809Open(0);
for (INT32 i = 0; i < nInterleave; i++) {
nCyclesDone[0] += TMS34010Run((nCyclesTotal[0] * (i + 1) / nInterleave) - nCyclesDone[0]);
nCyclesDone[1] += M6809Run((nCyclesTotal[1] * (i + 1) / nInterleave) - nCyclesDone[1]);
TMS34010GenerateScanline(i);
if (pBurnSoundOut) {
INT32 nSegmentLength = nBurnSoundLen / nInterleave;
INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
BurnYM2151Render(pSoundBuf, nSegmentLength);
nSoundBufferPos += nSegmentLength;
}
}
// Make sure the buffer is entirely filled.
if (pBurnSoundOut) {
INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos;
INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
if (nSegmentLength) {
BurnYM2151Render(pSoundBuf, nSegmentLength);
}
}
M6809Close();
if (pBurnDraw) {
TUnitDraw();
}
return 0;
}
INT32 TUnitScan(INT32 nAction, INT32 *pnMin)
{
struct BurnArea ba;
if (pnMin) {
*pnMin = 0x029704;
}
if (nAction & ACB_VOLATILE) {
memset(&ba, 0, sizeof(ba));
ba.Data = AllRam;
ba.nLen = RamEnd - AllRam;
ba.szName = "All RAM";
BurnAcb(&ba);
}
if (nAction & ACB_DRIVER_DATA) {
TMS34010Scan(nAction);
SCAN_VAR(nVideoBank);
SCAN_VAR(nDMA);
SCAN_VAR(nTUnitCtrl);
SCAN_VAR(bCMOSWriteEnable);
// Might need to scan the dma_state struct in midtunit_dma.h
}
if (nAction & ACB_WRITE) {
//
}
return 0;
}

View File

@ -0,0 +1,19 @@
#pragma once
extern UINT8 nTUnitJoy1[32];
extern UINT8 nTUnitJoy2[32];
extern UINT8 nTUnitJoy3[32];
extern UINT8 nTUnitDSW[8];
extern UINT8 nTUnitReset;
extern UINT8 nTUnitRecalc;
#define TUNIT_GFX(msb,s) ((msb & 0xFF) << 12) | ((s & 7) << 8)
#define TUNIT_GFX_ADR(value) ((value & (0xFF << 12)) >> 12)
#define TUNIT_GFX_OFF(value) ((value & (7 << 8)) >> 8)
INT32 TUnitInit();
INT32 TUnitFrame();
INT32 TUnitExit();
INT32 TUnitDraw();
INT32 TUnitScan(INT32 nAction, INT32 *pnMin);