From 936b9f616f617ae44ffd00a1fef8e434fa68caff Mon Sep 17 00:00:00 2001 From: Marcos Medeiros <1381933+zxmarcos@users.noreply.github.com> Date: Sun, 15 Mar 2015 21:29:44 +0000 Subject: [PATCH] d_kinst: Add kinst2 --- src/burn/drv/midway/d_kinst.cpp | 195 +++++++++++++++++++++++++++----- src/cpu/adsp2100_intf.cpp | 3 +- 2 files changed, 168 insertions(+), 30 deletions(-) diff --git a/src/burn/drv/midway/d_kinst.cpp b/src/burn/drv/midway/d_kinst.cpp index a5c6440a8..a871f3aa1 100644 --- a/src/burn/drv/midway/d_kinst.cpp +++ b/src/burn/drv/midway/d_kinst.cpp @@ -9,6 +9,9 @@ #define IDE_IRQ 1 #define VBLANK_IRQ 0 +#define KINST 0x100000 +#define KINST2 0x200000 + static UINT8 *AllMem; static UINT8 *MemEnd; static UINT8 *AllRam; @@ -134,7 +137,6 @@ static void ideWrite(UINT32 address, UINT32 value) } } -static UINT32 xReg = 0, soundData = 0; static UINT32 kinstRead(UINT32 address) { UINT32 tmp; @@ -167,6 +169,37 @@ static UINT32 kinstRead(UINT32 address) return ~0; } +static UINT32 kinst2Read(UINT32 address) +{ + UINT32 tmp; + if (address >= 0x10000080 && address <= 0x100000ff) { + switch (address & 0xFF) { + case 0x80: + tmp = ~2; + if (Dcs2kDataRead() & 0x800) + tmp |= 2; + return tmp; + case 0xA0: + return nSoundData; + + case 0x98: + return ~DrvInputs[0]; + case 0x90: + return ~DrvInputs[1]; + case 0x88: + return ~DrvInputs[2] & ~0x00003e00; + } + return ~0; + } + + if (address >= 0x10000100 && address <= 0x10000173) { + return ideRead(address); + } + + + printf("Invalid read %08X\n", address); + return ~0; +} static void kinstWrite(UINT32 address, UINT64 value) @@ -201,6 +234,39 @@ static void kinstWrite(UINT32 address, UINT64 value) } + +static void kinst2Write(UINT32 address, UINT64 value) +{ + if (address >= 0x10000080 && address <= 0x100000ff) { + switch (address & 0xFF) { + case 0x98: + DrvVRAMBase = (value & 4) ? 0x58000 : 0x30000; + break; + case 0x90: + Dcs2kResetWrite(~value & 1); + break; + case 0x80: { + UINT32 old = nSoundCtrl; + nSoundCtrl = value; + if (!(old & 2) && (nSoundCtrl & 2)) { + Dcs2kDataWrite(nSoundData); + } + break; + } + case 0xA0: + nSoundData = value; + break; + } + return; + } + + if (address >= 0x10000100 && address <= 0x10000173) { + ideWrite(address, value); + return; + } + +} + static void kinstWriteByte(UINT32 address, UINT8 value) { kinstWrite(address, value); } static void kinstWriteHalf(UINT32 address, UINT16 value) { kinstWrite(address, value); } static void kinstWriteWord(UINT32 address, UINT32 value) { kinstWrite(address, value); } @@ -211,6 +277,15 @@ static UINT16 kinstReadHalf(UINT32 address) { return kinstRead(address); } static UINT32 kinstReadWord(UINT32 address) { return kinstRead(address); } static UINT64 kinstReadDouble(UINT32 address) { return kinstRead(address); } +static void kinst2WriteByte(UINT32 address, UINT8 value) { kinst2Write(address, value); } +static void kinst2WriteHalf(UINT32 address, UINT16 value) { kinst2Write(address, value); } +static void kinst2WriteWord(UINT32 address, UINT32 value) { kinst2Write(address, value); } +static void kinst2WriteDouble(UINT32 address, UINT64 value) { kinst2Write(address, value); } + +static UINT8 kinst2ReadByte(UINT32 address) { return kinst2Read(address); } +static UINT16 kinst2ReadHalf(UINT32 address) { return kinst2Read(address); } +static UINT32 kinst2ReadWord(UINT32 address) { return kinst2Read(address); } +static UINT64 kinst2ReadDouble(UINT32 address) { return kinst2Read(address); } static void MakeInputs() { @@ -239,17 +314,58 @@ static INT32 LoadSoundBanks() if (BurnLoadRom(DrvSoundROM + 0xA00000, 6, 2)) return 1; if (BurnLoadRom(DrvSoundROM + 0xC00000, 7, 2)) return 1; if (BurnLoadRom(DrvSoundROM + 0xE00000, 8, 2)) return 1; - - { - FILE *fp = fopen("sound.bin", "w"); - fwrite(DrvSoundROM, 1, 0x1000000, fp); - fclose(fp); - } return 0; - } -static INT32 DrvInit() +static INT32 kinstSetup() +{ + printf("kinst: loading image at kinst.img\n"); + // FIXME: + if (!DrvDisk->load_disk_image("hdd/kinst.img")) { + printf("kinst: harddisk image not found!"); + return 1; + } + + Mips3SetReadByteHandler(1, kinstReadByte); + Mips3SetReadHalfHandler(1, kinstReadHalf); + Mips3SetReadWordHandler(1, kinstReadWord); + Mips3SetReadDoubleHandler(1, kinstReadDouble); + + Mips3SetWriteByteHandler(1, kinstWriteByte); + Mips3SetWriteHalfHandler(1, kinstWriteHalf); + Mips3SetWriteWordHandler(1, kinstWriteWord); + Mips3SetWriteDoubleHandler(1, kinstWriteDouble); + + Mips3MapHandler(1, 0x10000000, 0x100001FF, MAP_READ | MAP_WRITE); + + return 0; +} + +static INT32 kinst2Setup() +{ + printf("kinst: loading image at kinst2.img\n"); + // FIXME: + if (!DrvDisk->load_disk_image("hdd/kinst2.img")) { + printf("kinst: harddisk image not found!"); + return 1; + } + + Mips3SetReadByteHandler(1, kinst2ReadByte); + Mips3SetReadHalfHandler(1, kinst2ReadHalf); + Mips3SetReadWordHandler(1, kinst2ReadWord); + Mips3SetReadDoubleHandler(1, kinst2ReadDouble); + + Mips3SetWriteByteHandler(1, kinst2WriteByte); + Mips3SetWriteHalfHandler(1, kinst2WriteHalf); + Mips3SetWriteWordHandler(1, kinst2WriteWord); + Mips3SetWriteDoubleHandler(1, kinst2WriteDouble); + + Mips3MapHandler(1, 0x10000000, 0x100001FF, MAP_READ | MAP_WRITE); + + return 0; +} + +static INT32 DrvInit(int version) { printf("kinst: DrvInit\n"); MemIndex(); @@ -261,13 +377,6 @@ static INT32 DrvInit() DrvDisk = new ide::ide_disk(); DrvDisk->set_irq_callback(IDESetIRQState); - printf("kinst: loading image at kinst.img\n"); - // FIXME: - if (!DrvDisk->load_disk_image("kinst.img")) { - printf("kinst: harddisk image not found!"); - return 1; - } - MemIndex(); GenerateColorLUT(); @@ -294,17 +403,15 @@ static INT32 DrvInit() Mips3MapMemory(DrvRAM0, 0x00000000, 0x0007FFFF, MAP_RAM); Mips3MapMemory(DrvRAM1, 0x08000000, 0x087FFFFF, MAP_RAM); - Mips3SetReadByteHandler(1, kinstReadByte); - Mips3SetReadHalfHandler(1, kinstReadHalf); - Mips3SetReadWordHandler(1, kinstReadWord); - Mips3SetReadDoubleHandler(1, kinstReadDouble); + switch (version) { + case KINST: + kinstSetup(); + break; + case KINST2: + kinst2Setup(); + break; + } - Mips3SetWriteByteHandler(1, kinstWriteByte); - Mips3SetWriteHalfHandler(1, kinstWriteHalf); - Mips3SetWriteWordHandler(1, kinstWriteWord); - Mips3SetWriteDoubleHandler(1, kinstWriteDouble); - - Mips3MapHandler(1, 0x10000000, 0x100001FF, MAP_READ | MAP_WRITE); Dcs2kMapSoundROM(DrvSoundROM, 0x1000000); Dcs2kBoot(); @@ -317,6 +424,9 @@ static INT32 DrvInit() return 0; } +static INT32 kinstDrvInit() { return DrvInit(KINST); } +static INT32 kinst2DrvInit() { return DrvInit(KINST2); } + static INT32 DrvExit() { Dcs2kExit(); @@ -366,10 +476,11 @@ static INT32 DrvFrame() DrvDraw(); } + + Dcs2kRun(MHz(10) / 60); if (pBurnSoundOut) { - Dcs2kRun(MHz(10) / 60); + Dcs2kRender(pBurnSoundOut, nBurnSoundLen); } - Dcs2kRender(pBurnSoundOut, nBurnSoundLen); Mips3SetIRQLine(VBLANK_IRQ, 1); Mips3Run(kHz(20)); @@ -404,6 +515,32 @@ struct BurnDriver BurnDrvKinst = { NULL, NULL, NULL, NULL, BDF_GAME_WORKING, 2, HARDWARE_PREFIX_MIDWAY, GBF_VSFIGHT, 0, NULL, kinstRomInfo, kinstRomName, NULL, NULL, kinstInputInfo, kinstDIPInfo, - DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x8000, + kinstDrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x8000, 320, 240, 4, 3 }; + +static struct BurnRomInfo kinst2RomDesc[] = { + { "ki2-l14.u98", 0x80000, 0x27d0285e, 1 | BRF_PRG | BRF_ESS }, // 0 MIPS R4600 Code + { "ki2_l1.u10", 0x80000, 0xfdf6ed51, 2 | BRF_SND | BRF_ESS }, // 1 DCS sound banks + { "ki2_l1.u11", 0x80000, 0xf9e70024, 2 | BRF_SND | BRF_ESS }, // 2 + { "ki2_l1.u12", 0x80000, 0x2994c199, 2 | BRF_SND | BRF_ESS }, // 3 + { "ki2_l1.u13", 0x80000, 0x3fe6327b, 2 | BRF_SND | BRF_ESS }, // 4 + { "ki2_l1.u33", 0x80000, 0x6f4dcdcf, 2 | BRF_SND | BRF_ESS }, // 5 + { "ki2_l1.u34", 0x80000, 0x5db48206, 2 | BRF_SND | BRF_ESS }, // 6 + { "ki2_l1.u35", 0x80000, 0x7245ce69, 2 | BRF_SND | BRF_ESS }, // 7 + { "ki2_l1.u36", 0x80000, 0x8920acbb, 2 | BRF_SND | BRF_ESS }, // 8 +}; + +STD_ROM_PICK(kinst2) +STD_ROM_FN(kinst2) + +struct BurnDriver BurnDrvKinst2 = { + "kinst2", "kinst2", NULL, NULL, "1994/1995", + "Killer Instinct II (ver. 1.4)\0", NULL, "Rare/Nintendo", "MIDWAY", + NULL, NULL, NULL, NULL, + BDF_GAME_WORKING, 2, HARDWARE_PREFIX_MIDWAY, GBF_VSFIGHT, 0, + NULL, kinst2RomInfo, kinst2RomName, NULL, NULL, kinstInputInfo, kinstDIPInfo, + kinst2DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x8000, + 320, 240, 4, 3 +}; + diff --git a/src/cpu/adsp2100_intf.cpp b/src/cpu/adsp2100_intf.cpp index 672d276fa..bb0f96dce 100644 --- a/src/cpu/adsp2100_intf.cpp +++ b/src/cpu/adsp2100_intf.cpp @@ -4,7 +4,8 @@ //#include #include -#define xlog(...) fprintf(stdout, "dcs: " __VA_ARGS__); fflush(stdout) +//#define xlog(...) fprintf(stdout, "dcs: " __VA_ARGS__); fflush(stdout) +#define xlog(...) #define ENABLE_TRACE 0