d_armedf.cpp - hook up nb1414m4 & patch timer over bug. Kozure Ookami is now working.

This commit is contained in:
dinkc64 2015-07-09 03:35:18 +00:00
parent 05fdcc4f80
commit 99a669a8ef
4 changed files with 369 additions and 36 deletions

View File

@ -45,7 +45,7 @@ drvobj = d_dodonpachi.o d_donpachi.o d_esprade.o d_feversos.o d_gaia.o d_guwang
d_kbash.o d_kbash2.o d_mahoudai.o d_outzone.o d_pipibibs.o d_rallybik.o d_samesame.o d_shippumd.o d_slapfght.o \
d_snowbro2.o d_tekipaki.o d_truxton.o d_truxton2.o d_vfive.o d_vimana.o d_zerowing.o \
\
d_4enraya.o d_1942.o d_1943.o d_alinvade.o d_alpha68k.o d_ambush.o d_arabian.o d_armedf.o d_atetris.o d_aztarac.o d_baraduke.o \
d_4enraya.o d_1942.o d_1943.o d_alinvade.o d_alpha68k.o d_ambush.o d_arabian.o d_armedf.o nb1414m4.o d_atetris.o d_aztarac.o d_baraduke.o \
d_bionicc.o d_blktiger.o d_blockout.o d_blueprnt.o d_bombjack.o d_capbowl.o d_commando.o d_cybertnk.o d_ddragon.o d_djboy.o d_dkong.o \
d_dynduke.o d_epos.o d_exedexes.o d_funkybee.o d_galaga.o d_gauntlet.o d_ginganin.o d_gng.o d_gunsmoke.o d_higemaru.o \
d_ikki.o d_invaders.o d_jack.o d_kangaroo.o d_kncljoe.o d_kyugo.o d_ladybug.o d_lwings.o d_lastduel.o d_mario.o d_markham.o \

View File

@ -1,11 +1,17 @@
// FB Alpha Armed Formation driver module
// Based on MAME driver by Carlos A. Lozano, Phil Stroffolino, and Takahiro Nogi
//
// nb1414m4 hooked up to Kozure Ookami July 8 2015 -dink
// todo:
// fix foreground scrolling registers in terraf
// hook nb1414m4 up to other games that need it
#include "tiles_generic.h"
#include "m68000_intf.h"
#include "z80_intf.h"
#include "burn_ym3812.h"
#include "dac.h"
#include "nb1414m4.h"
static UINT8 *AllMem;
static UINT8 *MemEnd;
@ -52,6 +58,7 @@ static INT32 xoffset;
static INT32 irqline;
static INT32 Terrafjb = 0;
static INT32 Kozuremode = 0;
static struct BurnInputInfo ArmedfInputList[] = {
{"P1 Coin", BIT_DIGITAL, DrvJoy1 + 10, "p1 coin" },
@ -443,38 +450,32 @@ void __fastcall cclimbr2_write_word(UINT32 address, UINT16 data)
switch (address)
{
case 0x7c000:
{
/* if (Terrafjb) {
// We should be using the extra Z80 - but it doesn't seem to work - the normal simulation does though
static UINT32 OldData = 0;
if ((data & 0x4000) && (OldData & 0x4000) == 0) {
ZetClose();
ZetOpen(1);
ZetSetIRQLine(0, CPU_IRQSTATUS_AUTO);
ZetClose();
ZetOpen(0);
}
OldData = data;
} else {*/
if (scroll_type == 2) {
if (~data & 0x0080) {
memset (DrvTxRAM, 0xff, 0x2000);
}
}
if (scroll_type == 0 || scroll_type == 3 || scroll_type == 5 || scroll_type == 6) { // scroll6 - hack
if (((data & 0x4100) == 0x4000 && scroll_type != 6) ||
((data & 0x4100) == 0x0000 && scroll_type == 6)) {
{
if (Kozuremode) {
if(data & 0x4000 && ((*DrvVidRegs & 0x40) == 0)) { //0 -> 1 transition
UINT16 *ram = (UINT16*)DrvTxRAM;
for (INT32 i = 0x10; i < 0x1000; i++) {
ram[i] = 0x0020;
nb_1414m4_exec((ram[0] << 8) | (ram[1] & 0xff),(UINT16*)DrvTxRAM,&DrvScroll[2],&DrvScroll[2]);
}
} else {
if (scroll_type == 2) {
if (~data & 0x0080) {
memset (DrvTxRAM, 0xff, 0x2000);
}
}
if (scroll_type == 0 || scroll_type == 3 || scroll_type == 5 || scroll_type == 6) { // scroll6 - hack
if (((data & 0x4100) == 0x4000 && scroll_type != 6) ||
((data & 0x4100) == 0x0000 && scroll_type == 6)) {
UINT16 *ram = (UINT16*)DrvTxRAM;
for (INT32 i = 0x10; i < 0x1000; i++) {
ram[i] = 0x0020;
}
}
}
}
// }
*DrvVidRegs = data >> 8;
*flipscreen = (data >> 12) & 1;
*flipscreen = (data >> 12) & 1;
}
return;
@ -496,6 +497,7 @@ void __fastcall cclimbr2_write_word(UINT32 address, UINT16 data)
}
return;
}
//bprintf(0, _T("a[%X:%X],"), address, data);
}
void __fastcall cclimbr2_write_byte(UINT32 address, UINT8 data)
@ -526,6 +528,9 @@ void __fastcall cclimbr2_write_byte(UINT32 address, UINT8 data)
UINT16 __fastcall cclimbr2_read_word(UINT32 address)
{
/*if (address >= 0x068000 && address <= 0x069fff) {
return DrvTxRAM[address - 0x68000];// = data & 0x00ff;
} */
switch (address)
{
case 0x78000:
@ -714,14 +719,16 @@ static INT32 MemIndex()
}
DrvPalette = (UINT32*)Next; Next += 0x0800 * sizeof(UINT32);
blit_data = Next; Next += 0x004000; // nb1414m4
AllRam = Next;
DrvSprRAM = Next; Next += 0x001000;
DrvSprBuf = Next; Next += 0x001000;
DrvBgRAM = Next; Next += 0x001000;
DrvFgRAM = Next; Next += 0x001000;
DrvTxRAM = Next; Next += 0x002000;
DrvTxRAM = Next; Next += 0x004000;
DrvPalRAM = Next; Next += 0x001000;
Drv68KRAM0 = Next; Next += 0x005000;
Drv68KRAM1 = Next; Next += 0x001000;
@ -900,6 +907,7 @@ static INT32 DrvExit()
BurnFree (AllMem);
Terrafjb = 0;
Kozuremode = 0;
return 0;
}
@ -1092,7 +1100,7 @@ static INT32 DrvDraw()
if (*DrvVidRegs & 0x04) draw_layer(DrvFgRAM, DrvGfxROM1, DrvScroll[2], DrvScroll[3], 0x400, 0x7ff);
if ((*DrvMcuCmd & 0x30) == 0x10 && *DrvVidRegs & 0x01) draw_txt_layer(txt_transp);
if (*DrvVidRegs & 0x02) draw_sprites(1);
if ((*DrvMcuCmd & 0x30) == 0x00 && *DrvVidRegs & 0x01) draw_txt_layer(txt_transp);
if ((*DrvMcuCmd & 0x30) == 0x00 && *DrvVidRegs & 0x01) draw_txt_layer(txt_transp);
if (*DrvVidRegs & 0x02) draw_sprites(0);
BurnTransferCopy(DrvPalette);
@ -1125,7 +1133,8 @@ static INT32 DrvFrame()
SekOpen(0);
ZetOpen(0);
nb1414_frame++;
for (INT32 i = 0; i < nInterleave; i++)
{
INT32 nNext;
@ -1136,7 +1145,7 @@ static INT32 DrvFrame()
nCyclesDone[0] += nSegment;
BurnTimerUpdateYM3812(i * (nTotalCycles[1] / nInterleave));
for (INT32 j = 0; j < 9; j++) {
if (i == Z80IRQSlice[j]) {
ZetSetIRQLine(0, CPU_IRQSTATUS_ACK);
@ -1464,7 +1473,7 @@ static struct BurnRomInfo kozureRomDesc[] = {
{ "kozure12.8d", 0x20000, 0x15f4021d, 6 | BRF_GRA }, // 11 Sprites
{ "kozure13.9d", 0x20000, 0xb3b6c753, 6 | BRF_GRA }, // 12
{ "kozure10.11c", 0x04000, 0xf48be21d, 7 | BRF_GRA | BRF_OPT }, // 13 MCU data
{ "kozure10.11c", 0x04000, 0xf48be21d, 7 | BRF_GRA }, // 13 MCU data
{ "n82s129an.11j", 0x00100, 0x81244757, 8 | BRF_OPT }, // 14 Proms
};
@ -1481,6 +1490,12 @@ static INT32 KozureLoadRoms()
if (BurnLoadRom(Drv68KROM + 0x040001, 4, 2)) return 1;
if (BurnLoadRom(Drv68KROM + 0x040000, 5, 2)) return 1;
UINT16 *ROM = (UINT16*)Drv68KROM;
/* patch "time over" bug. */
ROM[0x1016c/2] = 0x4e71;
/* ROM check at POST. */
ROM[0x04fc6/2] = 0x4e71;
if (BurnLoadRom(DrvZ80ROM, 6, 1)) return 1;
if (BurnLoadRom(DrvGfxROM0, 7, 1)) return 1;
@ -1492,6 +1507,7 @@ static INT32 KozureLoadRoms()
if (BurnLoadRom(DrvGfxROM3 + 0x000000, 11, 1)) return 1;
if (BurnLoadRom(DrvGfxROM3 + 0x020000, 12, 1)) return 1;
if (BurnLoadRom(blit_data, 13, 1)) return 1;
return 0;
}
@ -1501,13 +1517,19 @@ static INT32 KozureInit()
scroll_type = 2;
sprite_offy = 128;
irqline = 1;
Kozuremode = 1;
return DrvInit(KozureLoadRoms, Cclimbr268KInit, 0xf800);
INT32 nRet = DrvInit(KozureLoadRoms, Cclimbr268KInit, 0xf800);
DACSetRoute(0, 0.20, BURN_SND_ROUTE_BOTH);
DACSetRoute(1, 0.20, BURN_SND_ROUTE_BOTH);
return nRet;
}
struct BurnDriver BurnDrvKozure = {
"kozure", NULL, NULL, NULL, "1987",
"Kozure Ookami (Japan)\0", "Imperfect Graphics", "Nichibutsu", "Miscellaneous",
"Kozure Ookami (Japan)\0", NULL, "Nichibutsu", "Miscellaneous",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_PRE90S, GBF_SCRFIGHT, 0,
NULL, kozureRomInfo, kozureRomName, NULL, NULL, ArmedfInputInfo, KozureDIPInfo,

View File

@ -0,0 +1,306 @@
// license:MAME
// copyright-holders:Angelo Salese
/*******************************************************************************************************************
Nichibutsu 1414M4 device emulation
Written by Angelo Salese, based on researches by Tomasz Slanina with Legion
This is some fancy MCU / blitter that copies text strings in various Nihon Bussan games;
TODO:
- where is the condition that makes "insert coin" text to properly blink?
- first byte meaning is completely unknown;
- Ninja Emaki triggers unknown commands 0x8000 & 0xff20;
- Ninja Emaki continue screen is corrupt;
- How to NOT draw the params?
- Device-ify this;
Notes:
- Just before any string in the "MCU" rom, there's a control byte, this meaning is as follows:
0?-- ---- ---- ---- interpret as data?
10-- ---- ---- ---- single string transfer
11-- ---- ---- ---- src -> dst copy, if destination != 0 fixed src, otherwise do a src -> dst
--xx xxxx xxxx xxxx destination offset in the VRAM tilemap
- I'm sure that this is a shared device, that shares everything. All of the known differences are due of not
understood features of the chip (some bytes in the ROM etc.)
********************************************************************************************************************/
#include "tiles_generic.h" // for UINT* etc
#include "nb1414m4.h"
UINT8 *blit_data = NULL;
UINT32 nb1414_frame = 0;
static void nichibutsu_1414m4_dma(UINT16 src,UINT16 dst,UINT16 size, UINT8 condition,UINT16 *vram)
{
UINT8 * data = blit_data;
int i;
for(i=0;i<size;i++)
{
if(i+dst+0x000 < 18) //avoid param overwrite
continue;
vram[i+dst+0x000] = (condition) ? (data[i+(0)+src] & 0xff) : 0x20;
vram[i+dst+0x400] = data[i+(size)+src] & 0xff;
}
}
static void nichibutsu_1414m4_fill(UINT16 dst,UINT8 tile,UINT8 pal,UINT16 *vram)
{
int i;
for(i=0;i<0x400;i++)
{
if(i+dst+0x000 < 18) //avoid param overwrite
continue;
vram[i+dst+0x000] = tile;
vram[i+dst+0x400] = pal;
}
}
static void insert_coin_msg(UINT16 *vram)
{
UINT8 * data = blit_data;
int credit_count = (vram[0xf] & 0xff);
UINT8 fl_cond = nb1414_frame & 0x10; /* for insert coin "flickering" */
UINT16 dst;
if(credit_count == 0)
{
dst = (data[0x01]<<8|data[0x02]) & 0x3fff;
nichibutsu_1414m4_dma(0x0003,dst,0x10,fl_cond,vram);
}
else
{
dst = (data[0x49]<<8|data[0x4a]) & 0x3fff;
nichibutsu_1414m4_dma(0x004b,dst,0x18,1,vram);
}
}
static void credit_msg(UINT16 *vram)
{
UINT8 * data = blit_data;
int credit_count = (vram[0xf] & 0xff);
UINT8 fl_cond = nb1414_frame & 0x10; /* for insert coin "flickering" */
UINT16 dst;
dst = ((data[0x023]<<8)|(data[0x024]&0xff)) & 0x3fff;
nichibutsu_1414m4_dma(0x0025,dst,0x10,1,vram); /* credit */
dst = ((data[0x045]<<8)|(data[0x046]&0xff)) & 0x3fff;
dst++; // data is 0x5e, needs to be 0x5f ...
vram[dst+0x000] = (credit_count + 0x30); /* credit num */
vram[dst+0x400] = (data[0x48]);
if(credit_count == 1) /* ONE PLAYER ONLY */
{
dst = ((data[0x07b]<<8)|(data[0x07c]&0xff)) & 0x3fff;
nichibutsu_1414m4_dma(0x007d,dst,0x18,fl_cond,vram);
}
else if(credit_count > 1) /* ONE OR TWO PLAYERS */
{
dst = ((data[0x0ad]<<8)|(data[0x0ae]&0xff)) & 0x3fff;
nichibutsu_1414m4_dma(0x00af,dst,0x18,fl_cond,vram);
}
}
static void kozure_score_msg(UINT16 dst,UINT8 src_base,UINT16 *vram)
{
int i;
UINT8 first_digit;
UINT8 res;
UINT8 * data = blit_data;
first_digit = 0;
for(i=0;i<6;i++)
{
res = ((vram[(i/2)+5+src_base*3] >> (!(i & 1) * 4)) & 0xf);
if(first_digit || res)
{
vram[i+dst+0x0000] = res + 0x30;
first_digit = 1;
}
else
vram[i+dst+0x0000] = 0x20;
vram[i+dst+0x0400] = data[0x10f+(src_base*0x1c)+i];
}
vram[6+dst+0x0000] = 0x30;
vram[6+dst+0x0400] = data[0x10f+(src_base*0x1c)+6];
vram[7+dst+0x0000] = 0x30;
vram[7+dst+0x0400] = data[0x10f+(src_base*0x1c)+7];
}
static void nichibutsu_1414m4_0200( UINT16 mcu_cmd,UINT16 *vram)
{
UINT8 * data = blit_data;
UINT16 dst;
dst = (data[0x330+((mcu_cmd & 0xf)*2)]<<8)|(data[0x331+((mcu_cmd & 0xf)*2)]&0xff);
dst &= 0x3fff;
if(dst & 0x7ff) // fill
nichibutsu_1414m4_fill(0x0000,data[dst & 0x3fff],data[dst+1],vram);
else // src -> dst
nichibutsu_1414m4_dma(dst & 0x3fff,0x0000,0x400,1,vram);
}
/*
[0x02] & 0x01 p1 up
[0x02] & 0x02 p1 down
[0x02] & 0x04 p1 left
[0x02] & 0x08 p1 right
[0x02] & 0x10 p1 button 1
[0x02] & 0x20 p1 button 2
[0x02] & 0x40 p1 button 3
[0x03] & 0x01 p2 up
[0x03] & 0x02 p2 down
[0x03] & 0x04 p2 left
[0x03] & 0x08 p2 right
[0x03] & 0x10 p2 button 1
[0x03] & 0x20 p2 button 2
[0x03] & 0x40 p2 button 3
[0x04] & 0x10 service
[0x04] & 0x04 coin A
[0x04] & 0x08 coin B
[0x04] & 0x01 start 1
[0x04] & 0x02 start 2
[0x05] DSW1
[0x06] DSW2
[0x07] & 0x40 demo sounds ON / OFF
[0x07] & 0x7 lives setting
[0x07] & 0x80 cabinet (upright / table)
[0x07] & 0x30 difficulty (easy / normal / hard / hardest)
[0x0f] coinage A
[0x10] coinage B
[0x11] sound test num
*/
static void nichibutsu_1414m4_0600( UINT8 is2p,UINT16 *vram)
{
UINT8 * data = blit_data;
UINT16 dst;
int i;
dst = ((data[0x1f5]<<8)|(data[0x1f6]&0xff)) & 0x3fff;
vram[dst] = (vram[7] & 0x7) + 0x30;//data[0x1f7];
dst = ((data[0x1f8]<<8)|(data[0x1f9]&0xff)) & 0x3fff;
nichibutsu_1414m4_dma(0x1fa + (((vram[7] & 0x30) >> 4) * 0x18),dst,12,1,vram);
// 0x25a - 0x261 unknown meaning
dst = ((data[0x262]<<8)|(data[0x263]&0xff)) & 0x3fff;
nichibutsu_1414m4_dma(0x264 + (((vram[7] & 0x80) >> 7) * 0x18),dst,12,1,vram);
dst = ((data[0x294]<<8)|(data[0x295]&0xff)) & 0x3fff;
nichibutsu_1414m4_dma(0x296 + (((vram[7] & 0x40) >> 6) * 0x18),dst,12,1,vram);
dst = ((data[0x2c6]<<8)|(data[0x2c7]&0xff)) & 0x3fff;
vram[dst] = ((vram[0xf] & 0xf0) >> 4) + 0x30;//data[0x2c8];
dst = ((data[0x2c9]<<8)|(data[0x2ca]&0xff)) & 0x3fff;
vram[dst] = ((vram[0xf] & 0x0f) >> 0) + 0x30;//data[0x2cb];
dst = ((data[0x2cc]<<8)|(data[0x2cd]&0xff)) & 0x3fff;
vram[dst] = ((vram[0x10] & 0xf0) >> 4) + 0x30;//data[0x2ce];
dst = ((data[0x2cf]<<8)|(data[0x2d0]&0xff)) & 0x3fff;
vram[dst] = ((vram[0x10] & 0x0f) >> 0) + 0x30;//data[0x2d1];
dst = ((data[0x2d2]<<8)|(data[0x2d3]&0xff)) & 0x3fff;
vram[dst+0] = ((vram[0x11] & 0xf0) >> 4) + 0x30;//data[0x2d4];
vram[dst+1] = (vram[0x11] & 0x0f) + 0x30;//data[0x2d5];
dst = ((data[0x2d6]<<8)|(data[0x2d7]&0xff)) & 0x3fff;
nichibutsu_1414m4_dma(0x2d8 + (is2p * 0x18),dst,12,1,vram); // 1p / 2p string
dst = ((data[0x308]<<8)|(data[0x309]&0xff)) & 0x3fff;
for(i=0;i<5;i++) /* system inputs */
nichibutsu_1414m4_dma(0x310 + (((vram[0x04] >> (4-i)) & 1) * 6),dst + (i * 0x20),0x3,1,vram);
dst = ((data[0x30a]<<8)|(data[0x30b]&0xff)) & 0x3fff;
for(i=0;i<7;i++) /* 1p / 2p inputs */
nichibutsu_1414m4_dma(0x310 + (((vram[0x02 + is2p] >> (6-i)) & 1) * 6),dst + (i * 0x20),0x3,1,vram);
dst = ((data[0x30c]<<8)|(data[0x30d]&0xff)) & 0x3fff;
for(i=0;i<8;i++) /* dips */
nichibutsu_1414m4_dma(0x310 + (((vram[0x05] >> (7-i)) & 1) * 6),dst + (i * 0x20),0x3,1,vram);
dst = ((data[0x30e]<<8)|(data[0x30f]&0xff)) & 0x3fff;
for(i=0;i<8;i++) /* dips */
nichibutsu_1414m4_dma(0x310 + (((vram[0x06] >> (7-i)) & 1) * 6),dst + (i * 0x20),0x3,1,vram);
}
static void nichibutsu_1414m4_0e00(UINT16 mcu_cmd,UINT16 *vram)
{
UINT8 * data = blit_data;
UINT16 dst;
dst = ((data[0xdf]<<8)|(data[0xe0]&0xff)) & 0x3fff;
nichibutsu_1414m4_dma(0x00e1,dst,8,1,vram); /* hi-score */
if(mcu_cmd & 0x04)
{
dst = ((data[0xfb]<<8)|(data[0xfc]&0xff)) & 0x3fff;
nichibutsu_1414m4_dma(0x00fd,dst,8,!(mcu_cmd & 1),vram); /* 1p-msg */
dst = ((data[0x10d]<<8)|(data[0x10e]&0xff)) & 0x3fff;
kozure_score_msg(dst,0,vram); /* 1p score */
if(mcu_cmd & 0x80)
{
dst = ((data[0x117]<<8)|(data[0x118]&0xff)) & 0x3fff;
nichibutsu_1414m4_dma(0x0119,dst,8,!(mcu_cmd & 2),vram); /* 2p-msg */
dst = ((data[0x129]<<8)|(data[0x12a]&0xff)) & 0x3fff;
kozure_score_msg(dst,1,vram); /* 2p score */
}
}
else
{
dst = ((data[0x133]<<8)|(data[0x134]&0xff)) & 0x3fff;
nichibutsu_1414m4_dma(0x0135,dst,0x10,!(mcu_cmd & 1),vram); /* game over */
insert_coin_msg(vram);
if((mcu_cmd & 0x18) == 0) // TODO: either one of these two disables credit display
credit_msg(vram);
}
}
void nb_1414m4_exec(UINT16 mcu_cmd,UINT16 *vram,UINT16 *scrollx,UINT16 *scrolly)
{
/* latch fg scroll values */
*scrollx = (vram[0x0d] & 0xff) | ((vram[0x0e] & 0xff) << 8);
*scrolly = (vram[0x0b] & 0xff) | ((vram[0x0c] & 0xff) << 8);
/* process the command */
switch(mcu_cmd & 0xff00)
{
/* title screen / continue screens */
case 0x0000: insert_coin_msg(vram); credit_msg(vram); break;
/* direct DMA'ing / fill */
case 0x0200: nichibutsu_1414m4_0200(mcu_cmd & 0x87,vram); break;
/* service mode */
case 0x0600: nichibutsu_1414m4_0600(mcu_cmd & 1,vram); break;
/* gameplay */
case 0x0e00: nichibutsu_1414m4_0e00(mcu_cmd & 0xff,vram); break;
case 0x8000: break; //Ninja Emaki, attract mode
case 0xff00: break; //Ninja Emaki POST, presumably invalid
default:
//popmessage("NB 1414M4 executes %04x command, contact MAMEdev\n",mcu_cmd);
break;
}
}

View File

@ -0,0 +1,5 @@
void nb_1414m4_exec(UINT16 mcu_cmd,UINT16 *vram,UINT16 *scrollx,UINT16 *scrolly);
extern UINT8 *blit_data;
extern UINT32 nb1414_frame;