From 17f7b701315e63ade2e91f12e2e767f352abe9d6 Mon Sep 17 00:00:00 2001 From: Scott Stone Date: Thu, 11 Jul 2013 17:11:27 +0000 Subject: [PATCH] Split up in their own files the remaining modernized devices contained in konicdev.c. [Osso] --- .gitattributes | 15 + src/mame/drivers/aliens.c | 1 - src/mame/drivers/blockhl.c | 1 - src/mame/drivers/chqflag.c | 1 - src/mame/drivers/crimfght.c | 2 +- src/mame/drivers/crshrace.c | 2 +- src/mame/drivers/f1gp.c | 2 +- src/mame/drivers/gbusters.c | 2 +- src/mame/drivers/gradius3.c | 2 +- src/mame/drivers/hornet.c | 2 +- src/mame/drivers/labyrunr.c | 2 +- src/mame/drivers/metro.c | 2 +- src/mame/drivers/parodius.c | 2 +- src/mame/drivers/plygonet.c | 2 +- src/mame/drivers/rungun.c | 2 +- src/mame/drivers/simpsons.c | 2 +- src/mame/drivers/spy.c | 2 +- src/mame/drivers/suprslam.c | 2 +- src/mame/drivers/surpratk.c | 2 +- src/mame/drivers/tasman.c | 2 +- src/mame/drivers/thunderx.c | 2 +- src/mame/drivers/vendetta.c | 2 +- src/mame/drivers/xmen.c | 2 +- src/mame/includes/88games.h | 5 +- src/mame/includes/ajax.h | 5 +- src/mame/includes/aliens.h | 3 + src/mame/includes/asterix.h | 3 +- src/mame/includes/battlnts.h | 3 +- src/mame/includes/bishi.h | 3 +- src/mame/includes/bladestl.h | 4 +- src/mame/includes/blockhl.h | 4 + src/mame/includes/bottom9.h | 5 +- src/mame/includes/chqflag.h | 5 +- src/mame/includes/combatsc.h | 2 +- src/mame/includes/contra.h | 2 +- src/mame/includes/crimfght.h | 3 + src/mame/includes/dbz.h | 4 +- src/mame/includes/djmain.h | 2 +- src/mame/includes/fastlane.h | 3 +- src/mame/includes/flkatck.h | 2 +- src/mame/includes/gbusters.h | 3 + src/mame/includes/gijoe.h | 3 +- src/mame/includes/gradius3.h | 3 + src/mame/includes/hcastle.h | 2 +- src/mame/includes/labyrunr.h | 3 + src/mame/includes/lethal.h | 2 +- src/mame/includes/mainevt.h | 5 +- src/mame/includes/moo.h | 4 +- src/mame/includes/overdriv.h | 4 +- src/mame/includes/parodius.h | 3 + src/mame/includes/qdrmfgp.h | 2 +- src/mame/includes/rockrage.h | 3 +- src/mame/includes/rollerg.h | 3 +- src/mame/includes/rungun.h | 2 +- src/mame/includes/simpsons.h | 3 + src/mame/includes/spy.h | 3 + src/mame/includes/surpratk.h | 3 + src/mame/includes/tail2nos.h | 2 +- src/mame/includes/thunderx.h | 3 + src/mame/includes/tmnt.h | 5 +- src/mame/includes/ultraman.h | 4 +- src/mame/includes/vendetta.h | 4 +- src/mame/includes/wecleman.h | 2 +- src/mame/includes/xexex.h | 4 +- src/mame/includes/xmen.h | 3 + src/mame/machine/ajax.c | 2 +- src/mame/machine/simpsons.c | 2 +- src/mame/mame.mak | 9 + src/mame/video/aliens.c | 2 +- src/mame/video/blockhl.c | 2 +- src/mame/video/combatsc.c | 2 +- src/mame/video/crimfght.c | 2 +- src/mame/video/crshrace.c | 2 +- src/mame/video/f1gp.c | 2 +- src/mame/video/gbusters.c | 2 +- src/mame/video/gradius3.c | 2 +- src/mame/video/k007121.h | 35 + src/mame/video/k007342.c | 307 +++ src/mame/video/k007342.h | 62 + src/mame/video/k007420.c | 261 +++ src/mame/video/k007420.h | 43 + src/mame/video/k037122.c | 227 ++ src/mame/video/k037122.h | 52 + src/mame/video/k051316.c | 317 +++ src/mame/video/k051316.h | 63 + src/mame/video/k051733.c | 205 ++ src/mame/video/k051733.h | 30 + src/mame/video/k051960.h | 80 + src/mame/video/k052109.c | 751 +++++++ src/mame/video/k052109.h | 104 + src/mame/video/k05324x.h | 18 + src/mame/video/k053251.c | 277 +++ src/mame/video/konami_helper.c | 59 + src/mame/video/konami_helper.h | 12 + src/mame/video/konicdev.c | 3693 ++------------------------------ src/mame/video/konicdev.h | 566 +---- src/mame/video/labyrunr.c | 2 +- src/mame/video/mainevt.c | 2 +- src/mame/video/parodius.c | 2 +- src/mame/video/plygonet.c | 2 +- src/mame/video/rungun.c | 2 +- src/mame/video/simpsons.c | 2 +- src/mame/video/spy.c | 2 +- src/mame/video/suprslam.c | 2 +- src/mame/video/surpratk.c | 2 +- src/mame/video/thunderx.c | 2 +- src/mame/video/tmnt.c | 2 +- src/mame/video/vendetta.c | 2 +- src/mame/video/xmen.c | 2 +- 109 files changed, 3212 insertions(+), 4197 deletions(-) create mode 100644 src/mame/video/k007121.h create mode 100644 src/mame/video/k007342.c create mode 100644 src/mame/video/k007342.h create mode 100644 src/mame/video/k007420.c create mode 100644 src/mame/video/k007420.h create mode 100644 src/mame/video/k037122.c create mode 100644 src/mame/video/k037122.h create mode 100644 src/mame/video/k051316.c create mode 100644 src/mame/video/k051316.h create mode 100644 src/mame/video/k051733.c create mode 100644 src/mame/video/k051733.h create mode 100644 src/mame/video/k051960.h create mode 100644 src/mame/video/k052109.c create mode 100644 src/mame/video/k052109.h create mode 100644 src/mame/video/k053251.c diff --git a/.gitattributes b/.gitattributes index b1ea27ee23c..b5c3b85efa1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5525,8 +5525,23 @@ src/mame/video/jalblend.c svneol=native#text/plain src/mame/video/jalblend.h svneol=native#text/plain src/mame/video/jedi.c svneol=native#text/plain src/mame/video/jpmimpct.c svneol=native#text/plain +src/mame/video/k007121.h svneol=native#text/plain +src/mame/video/k007342.c svneol=native#text/plain +src/mame/video/k007342.h svneol=native#text/plain +src/mame/video/k007420.c svneol=native#text/plain +src/mame/video/k007420.h svneol=native#text/plain +src/mame/video/k037122.c svneol=native#text/plain +src/mame/video/k037122.h svneol=native#text/plain +src/mame/video/k051316.c svneol=native#text/plain +src/mame/video/k051316.h svneol=native#text/plain +src/mame/video/k051733.c svneol=native#text/plain +src/mame/video/k051733.h svneol=native#text/plain +src/mame/video/k051960.h svneol=native#text/plain +src/mame/video/k052109.c svneol=native#text/plain +src/mame/video/k052109.h svneol=native#text/plain src/mame/video/k05324x.c svneol=native#text/plain src/mame/video/k05324x.h svneol=native#text/plain +src/mame/video/k053251.c svneol=native#text/plain src/mame/video/k053936.c svneol=native#text/plain src/mame/video/k053936.h svneol=native#text/plain src/mame/video/k054000.c svneol=native#text/plain diff --git a/src/mame/drivers/aliens.c b/src/mame/drivers/aliens.c index 42686cb19d1..4173e9820bd 100644 --- a/src/mame/drivers/aliens.c +++ b/src/mame/drivers/aliens.c @@ -11,7 +11,6 @@ Preliminary driver by: #include "cpu/z80/z80.h" #include "cpu/m6809/konami.h" /* for the callback and the firq irq definition */ #include "sound/2151intf.h" -#include "video/konicdev.h" #include "includes/konamipt.h" #include "includes/aliens.h" diff --git a/src/mame/drivers/blockhl.c b/src/mame/drivers/blockhl.c index dfb3ebaafa4..1fac0b2f637 100644 --- a/src/mame/drivers/blockhl.c +++ b/src/mame/drivers/blockhl.c @@ -22,7 +22,6 @@ #include "emu.h" #include "cpu/z80/z80.h" #include "cpu/m6809/konami.h" /* for the callback and the firq irq definition */ -#include "video/konicdev.h" #include "sound/2151intf.h" #include "includes/konamipt.h" #include "includes/blockhl.h" diff --git a/src/mame/drivers/chqflag.c b/src/mame/drivers/chqflag.c index f335781fd19..c144e364083 100644 --- a/src/mame/drivers/chqflag.c +++ b/src/mame/drivers/chqflag.c @@ -18,7 +18,6 @@ #include "sound/2151intf.h" #include "includes/chqflag.h" #include "includes/konamipt.h" - #include "chqflag.lh" diff --git a/src/mame/drivers/crimfght.c b/src/mame/drivers/crimfght.c index 5169e75ee23..5a2f1992159 100644 --- a/src/mame/drivers/crimfght.c +++ b/src/mame/drivers/crimfght.c @@ -14,7 +14,7 @@ #include "emu.h" #include "cpu/z80/z80.h" #include "cpu/m6809/konami.h" /* for the callback and the firq irq definition */ -#include "video/konicdev.h" + #include "sound/2151intf.h" #include "includes/konamipt.h" #include "includes/crimfght.h" diff --git a/src/mame/drivers/crshrace.c b/src/mame/drivers/crshrace.c index 83d1c588c0e..a92dd5aa73c 100644 --- a/src/mame/drivers/crshrace.c +++ b/src/mame/drivers/crshrace.c @@ -129,7 +129,7 @@ Dip locations verified with Service Mode. #include "emu.h" #include "cpu/m68000/m68000.h" #include "sound/2610intf.h" -#include "video/konicdev.h" + #include "includes/crshrace.h" diff --git a/src/mame/drivers/f1gp.c b/src/mame/drivers/f1gp.c index be954de4aa2..5f76dc38488 100644 --- a/src/mame/drivers/f1gp.c +++ b/src/mame/drivers/f1gp.c @@ -25,7 +25,7 @@ #include "emu.h" #include "cpu/z80/z80.h" #include "cpu/m68000/m68000.h" -#include "video/konicdev.h" + #include "sound/2610intf.h" #include "sound/okim6295.h" #include "includes/f1gp.h" diff --git a/src/mame/drivers/gbusters.c b/src/mame/drivers/gbusters.c index 5b7a08a8e48..cf1800184bf 100644 --- a/src/mame/drivers/gbusters.c +++ b/src/mame/drivers/gbusters.c @@ -10,7 +10,7 @@ #include "emu.h" #include "cpu/z80/z80.h" #include "cpu/m6809/konami.h" /* for the callback and the firq irq definition */ -#include "video/konicdev.h" + #include "sound/2151intf.h" #include "includes/konamipt.h" #include "includes/gbusters.h" diff --git a/src/mame/drivers/gradius3.c b/src/mame/drivers/gradius3.c index a9fc86350c0..ca1cece3262 100644 --- a/src/mame/drivers/gradius3.c +++ b/src/mame/drivers/gradius3.c @@ -19,7 +19,7 @@ ***************************************************************************/ #include "emu.h" -#include "video/konicdev.h" + #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" #include "sound/2151intf.h" diff --git a/src/mame/drivers/hornet.c b/src/mame/drivers/hornet.c index cb7fe4daec0..bcf3d24ef22 100644 --- a/src/mame/drivers/hornet.c +++ b/src/mame/drivers/hornet.c @@ -320,7 +320,7 @@ #include "sound/rf5c400.h" #include "sound/k056800.h" #include "video/voodoo.h" -#include "video/konicdev.h" +#include "video/k037122.h" #include "rendlay.h" diff --git a/src/mame/drivers/labyrunr.c b/src/mame/drivers/labyrunr.c index 66bc4fd99c5..aabad958504 100644 --- a/src/mame/drivers/labyrunr.c +++ b/src/mame/drivers/labyrunr.c @@ -11,7 +11,7 @@ #include "emu.h" #include "cpu/m6809/hd6309.h" #include "sound/2203intf.h" -#include "video/konicdev.h" + #include "includes/konamipt.h" #include "includes/labyrunr.h" diff --git a/src/mame/drivers/metro.c b/src/mame/drivers/metro.c index 5df8fecd973..0068d17e222 100644 --- a/src/mame/drivers/metro.c +++ b/src/mame/drivers/metro.c @@ -105,7 +105,7 @@ driver modified by Eisuke Watanabe #include "sound/es8712.h" #include "sound/okim6295.h" #include "sound/ymf278b.h" -#include "video/konicdev.h" + /*************************************************************************** diff --git a/src/mame/drivers/parodius.c b/src/mame/drivers/parodius.c index 1193a8dd8c2..d057a927d5f 100644 --- a/src/mame/drivers/parodius.c +++ b/src/mame/drivers/parodius.c @@ -9,7 +9,7 @@ #include "emu.h" #include "cpu/z80/z80.h" #include "cpu/m6809/konami.h" /* for the callback and the firq irq definition */ -#include "video/konicdev.h" + #include "sound/2151intf.h" #include "sound/k053260.h" #include "includes/konamipt.h" diff --git a/src/mame/drivers/plygonet.c b/src/mame/drivers/plygonet.c index 715c34b2c68..1e815d3ef8e 100644 --- a/src/mame/drivers/plygonet.c +++ b/src/mame/drivers/plygonet.c @@ -62,7 +62,7 @@ */ #include "emu.h" -#include "video/konicdev.h" + #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" #include "cpu/dsp56k/dsp56k.h" diff --git a/src/mame/drivers/rungun.c b/src/mame/drivers/rungun.c index 8e3badb6ee6..080261b7037 100644 --- a/src/mame/drivers/rungun.c +++ b/src/mame/drivers/rungun.c @@ -42,7 +42,7 @@ #include "emu.h" -#include "video/konicdev.h" + #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" #include "machine/eeprom.h" diff --git a/src/mame/drivers/simpsons.c b/src/mame/drivers/simpsons.c index afc2321ded2..c37029ce3ec 100644 --- a/src/mame/drivers/simpsons.c +++ b/src/mame/drivers/simpsons.c @@ -69,7 +69,7 @@ Custom ICs - 053260 - sound chip (QFP80) #include "emu.h" #include "cpu/m6809/konami.h" /* for the callback and the firq irq definition */ #include "cpu/z80/z80.h" -#include "video/konicdev.h" + #include "machine/eeprom.h" #include "sound/2151intf.h" #include "sound/k053260.h" diff --git a/src/mame/drivers/spy.c b/src/mame/drivers/spy.c index 71bac6a4ae7..e37a16fe41f 100644 --- a/src/mame/drivers/spy.c +++ b/src/mame/drivers/spy.c @@ -20,7 +20,7 @@ #include "emu.h" #include "cpu/z80/z80.h" #include "cpu/m6809/m6809.h" -#include "video/konicdev.h" + #include "sound/3812intf.h" #include "includes/konamipt.h" #include "includes/spy.h" diff --git a/src/mame/drivers/suprslam.c b/src/mame/drivers/suprslam.c index 146365866d1..7bd767efb18 100644 --- a/src/mame/drivers/suprslam.c +++ b/src/mame/drivers/suprslam.c @@ -83,7 +83,7 @@ EB26IC73.BIN 27C240 / Main Program #include "emu.h" #include "cpu/z80/z80.h" #include "cpu/m68000/m68000.h" -#include "video/konicdev.h" + #include "sound/2610intf.h" #include "video/vsystem_spr.h" #include "includes/suprslam.h" diff --git a/src/mame/drivers/surpratk.c b/src/mame/drivers/surpratk.c index 197596e2fa3..22b77fa0bd3 100644 --- a/src/mame/drivers/surpratk.c +++ b/src/mame/drivers/surpratk.c @@ -10,7 +10,7 @@ #include "emu.h" #include "cpu/m6809/konami.h" /* for the callback and the firq irq definition */ -#include "video/konicdev.h" + #include "sound/2151intf.h" #include "includes/konamipt.h" #include "includes/surpratk.h" diff --git a/src/mame/drivers/tasman.c b/src/mame/drivers/tasman.c index 8db3382d60f..205d40a8fa5 100644 --- a/src/mame/drivers/tasman.c +++ b/src/mame/drivers/tasman.c @@ -15,7 +15,7 @@ */ #include "emu.h" -#include "video/konicdev.h" +#include "video/konami_helper.h" #include "includes/konamigx.h" #include "cpu/m68000/m68000.h" #include "machine/eeprom.h" diff --git a/src/mame/drivers/thunderx.c b/src/mame/drivers/thunderx.c index b0092a0918e..bd5209ff1e1 100644 --- a/src/mame/drivers/thunderx.c +++ b/src/mame/drivers/thunderx.c @@ -15,7 +15,7 @@ #include "emu.h" #include "cpu/z80/z80.h" #include "cpu/m6809/konami.h" /* for the callback and the firq irq definition */ -#include "video/konicdev.h" + #include "sound/2151intf.h" #include "includes/konamipt.h" #include "includes/thunderx.h" diff --git a/src/mame/drivers/vendetta.c b/src/mame/drivers/vendetta.c index 2515d96b0d3..957da1400d9 100644 --- a/src/mame/drivers/vendetta.c +++ b/src/mame/drivers/vendetta.c @@ -88,7 +88,7 @@ #include "emu.h" #include "cpu/z80/z80.h" -#include "video/konicdev.h" + #include "cpu/m6809/konami.h" /* for the callback and the firq irq definition */ #include "machine/eeprom.h" #include "sound/2151intf.h" diff --git a/src/mame/drivers/xmen.c b/src/mame/drivers/xmen.c index d3d13a18a77..f5850bc795e 100644 --- a/src/mame/drivers/xmen.c +++ b/src/mame/drivers/xmen.c @@ -15,7 +15,7 @@ likewise be a 2 screen game ***************************************************************************/ #include "emu.h" #include "cpu/m68000/m68000.h" -#include "video/konicdev.h" + #include "machine/eeprom.h" #include "cpu/z80/z80.h" #include "sound/2151intf.h" diff --git a/src/mame/includes/88games.h b/src/mame/includes/88games.h index eee17cba7c0..94cc62c60ac 100644 --- a/src/mame/includes/88games.h +++ b/src/mame/includes/88games.h @@ -4,7 +4,10 @@ *************************************************************************/ #include "sound/upd7759.h" -#include "video/konicdev.h" +#include "video/k052109.h" +#include "video/k051960.h" +#include "video/k051316.h" +#include "video/konami_helper.h" class _88games_state : public driver_device { diff --git a/src/mame/includes/ajax.h b/src/mame/includes/ajax.h index 07e85591417..811b1038020 100644 --- a/src/mame/includes/ajax.h +++ b/src/mame/includes/ajax.h @@ -1,5 +1,8 @@ #include "sound/k007232.h" -#include "video/konicdev.h" +#include "video/k052109.h" +#include "video/k051960.h" +#include "video/k051316.h" +#include "video/konami_helper.h" class ajax_state : public driver_device { diff --git a/src/mame/includes/aliens.h b/src/mame/includes/aliens.h index 2db869e48c8..c64b007046e 100644 --- a/src/mame/includes/aliens.h +++ b/src/mame/includes/aliens.h @@ -4,6 +4,9 @@ *************************************************************************/ #include "sound/k007232.h" +#include "video/k052109.h" +#include "video/k051960.h" +#include "video/konami_helper.h" class aliens_state : public driver_device { diff --git a/src/mame/includes/asterix.h b/src/mame/includes/asterix.h index 265ab7b9c70..9f0934ededa 100644 --- a/src/mame/includes/asterix.h +++ b/src/mame/includes/asterix.h @@ -4,9 +4,10 @@ *************************************************************************/ #include "sound/k053260.h" -#include "video/konicdev.h" +#include "video/k053251.h" #include "video/k054156_k054157_k056832.h" #include "video/k05324x.h" +#include "video/konami_helper.h" class asterix_state : public driver_device { diff --git a/src/mame/includes/battlnts.h b/src/mame/includes/battlnts.h index 365e5d3e42f..64d1fc35776 100644 --- a/src/mame/includes/battlnts.h +++ b/src/mame/includes/battlnts.h @@ -4,7 +4,8 @@ *************************************************************************/ -#include "video/konicdev.h" +#include "video/k007342.h" +#include "video/k007420.h" class battlnts_state : public driver_device { diff --git a/src/mame/includes/bishi.h b/src/mame/includes/bishi.h index ccb080f845b..2c03652bc0a 100644 --- a/src/mame/includes/bishi.h +++ b/src/mame/includes/bishi.h @@ -4,10 +4,11 @@ *************************************************************************/ -#include "video/konicdev.h" + #include "video/k054156_k054157_k056832.h" #include "video/k055555.h" #include "video/k054338.h" +#include "video/konami_helper.h" #define CPU_CLOCK (XTAL_24MHz / 2) /* 68000 clock */ #define SOUND_CLOCK XTAL_16_9344MHz /* YMZ280 clock */ diff --git a/src/mame/includes/bladestl.h b/src/mame/includes/bladestl.h index dafcd57fce9..0997e6705db 100644 --- a/src/mame/includes/bladestl.h +++ b/src/mame/includes/bladestl.h @@ -4,7 +4,9 @@ *************************************************************************/ #include "sound/upd7759.h" -#include "video/konicdev.h" +#include "video/k007342.h" +#include "video/k007420.h" +#include "video/k051733.h" class bladestl_state : public driver_device { diff --git a/src/mame/includes/blockhl.h b/src/mame/includes/blockhl.h index 55f970ed64a..04391bdd0b4 100644 --- a/src/mame/includes/blockhl.h +++ b/src/mame/includes/blockhl.h @@ -4,6 +4,10 @@ *************************************************************************/ +#include "video/k052109.h" +#include "video/k051960.h" +#include "video/konami_helper.h" + class blockhl_state : public driver_device { public: diff --git a/src/mame/includes/bottom9.h b/src/mame/includes/bottom9.h index 35ec4cb8e02..e793cc2eba7 100644 --- a/src/mame/includes/bottom9.h +++ b/src/mame/includes/bottom9.h @@ -4,7 +4,10 @@ *************************************************************************/ #include "sound/k007232.h" -#include "video/konicdev.h" +#include "video/k052109.h" +#include "video/k051960.h" +#include "video/k051316.h" +#include "video/konami_helper.h" class bottom9_state : public driver_device { diff --git a/src/mame/includes/chqflag.h b/src/mame/includes/chqflag.h index 920c97fcd8d..47fdf6eee1f 100644 --- a/src/mame/includes/chqflag.h +++ b/src/mame/includes/chqflag.h @@ -4,7 +4,10 @@ *************************************************************************/ #include "sound/k007232.h" -#include "video/konicdev.h" +#include "video/k051960.h" +#include "video/k051316.h" +#include "video/k051733.h" +#include "video/konami_helper.h" class chqflag_state : public driver_device { diff --git a/src/mame/includes/combatsc.h b/src/mame/includes/combatsc.h index f848a63e4b0..20ff48338a2 100644 --- a/src/mame/includes/combatsc.h +++ b/src/mame/includes/combatsc.h @@ -5,7 +5,7 @@ *************************************************************************/ #include "sound/upd7759.h" #include "sound/msm5205.h" -#include "video/konicdev.h" +#include "video/k007121.h" class combatsc_state : public driver_device { diff --git a/src/mame/includes/contra.h b/src/mame/includes/contra.h index eee0b221b2e..c1648a39eab 100644 --- a/src/mame/includes/contra.h +++ b/src/mame/includes/contra.h @@ -4,7 +4,7 @@ *************************************************************************/ -#include "video/konicdev.h" +#include "video/k007121.h" class contra_state : public driver_device { diff --git a/src/mame/includes/crimfght.h b/src/mame/includes/crimfght.h index dd78103d0c1..98197b72f41 100644 --- a/src/mame/includes/crimfght.h +++ b/src/mame/includes/crimfght.h @@ -4,6 +4,9 @@ *************************************************************************/ #include "sound/k007232.h" +#include "video/k052109.h" +#include "video/k051960.h" +#include "video/konami_helper.h" class crimfght_state : public driver_device { diff --git a/src/mame/includes/dbz.h b/src/mame/includes/dbz.h index 43c2aecc1b4..e50ad3b76a3 100644 --- a/src/mame/includes/dbz.h +++ b/src/mame/includes/dbz.h @@ -3,11 +3,13 @@ Dragonball Z *************************************************************************/ -#include "video/konicdev.h" + #include "machine/k053252.h" #include "video/k054156_k054157_k056832.h" #include "video/k05324x.h" #include "video/k053936.h" +#include "video/k053251.h" +#include "video/konami_helper.h" class dbz_state : public driver_device { diff --git a/src/mame/includes/djmain.h b/src/mame/includes/djmain.h index e924e14007e..38edcedb72f 100644 --- a/src/mame/includes/djmain.h +++ b/src/mame/includes/djmain.h @@ -1,5 +1,5 @@ #include "machine/ataintf.h" -#include "video/konicdev.h" +#include "video/konami_helper.h" #include "video/k054156_k054157_k056832.h" #include "video/k055555.h" diff --git a/src/mame/includes/fastlane.h b/src/mame/includes/fastlane.h index 9e4ff8ef7fd..dc7e4ab7911 100644 --- a/src/mame/includes/fastlane.h +++ b/src/mame/includes/fastlane.h @@ -4,7 +4,8 @@ *************************************************************************/ #include "sound/k007232.h" -#include "video/konicdev.h" +#include "video/k007121.h" +#include "video/k051733.h" class fastlane_state : public driver_device { diff --git a/src/mame/includes/flkatck.h b/src/mame/includes/flkatck.h index 9f12abe14d7..8c05323f4d7 100644 --- a/src/mame/includes/flkatck.h +++ b/src/mame/includes/flkatck.h @@ -4,7 +4,7 @@ *************************************************************************/ #include "sound/k007232.h" -#include "video/konicdev.h" +#include "video/k007121.h" class flkatck_state : public driver_device { diff --git a/src/mame/includes/gbusters.h b/src/mame/includes/gbusters.h index 8e861955713..d33a1904d01 100644 --- a/src/mame/includes/gbusters.h +++ b/src/mame/includes/gbusters.h @@ -5,6 +5,9 @@ *************************************************************************/ #include "sound/k007232.h" +#include "video/k052109.h" +#include "video/k051960.h" +#include "video/konami_helper.h" class gbusters_state : public driver_device { diff --git a/src/mame/includes/gijoe.h b/src/mame/includes/gijoe.h index 4915f8259a8..9b0973dcce7 100644 --- a/src/mame/includes/gijoe.h +++ b/src/mame/includes/gijoe.h @@ -4,9 +4,10 @@ *************************************************************************/ #include "sound/k054539.h" -#include "video/konicdev.h" +#include "video/k053251.h" #include "video/k054156_k054157_k056832.h" #include "video/k05324x.h" +#include "video/konami_helper.h" class gijoe_state : public driver_device { diff --git a/src/mame/includes/gradius3.h b/src/mame/includes/gradius3.h index c0f1ea04ade..91634808ae8 100644 --- a/src/mame/includes/gradius3.h +++ b/src/mame/includes/gradius3.h @@ -4,6 +4,9 @@ *************************************************************************/ #include "sound/k007232.h" +#include "video/k052109.h" +#include "video/k051960.h" +#include "video/konami_helper.h" class gradius3_state : public driver_device { diff --git a/src/mame/includes/hcastle.h b/src/mame/includes/hcastle.h index bc8c8873108..5ed82c31b75 100644 --- a/src/mame/includes/hcastle.h +++ b/src/mame/includes/hcastle.h @@ -6,7 +6,7 @@ #include "video/bufsprite.h" #include "sound/k007232.h" -#include "video/konicdev.h" +#include "video/k007121.h" class hcastle_state : public driver_device { diff --git a/src/mame/includes/labyrunr.h b/src/mame/includes/labyrunr.h index 835f127f17b..df4b1983860 100644 --- a/src/mame/includes/labyrunr.h +++ b/src/mame/includes/labyrunr.h @@ -4,6 +4,9 @@ *************************************************************************/ +#include "video/k007121.h" +#include "video/k051733.h" + class labyrunr_state : public driver_device { public: diff --git a/src/mame/includes/lethal.h b/src/mame/includes/lethal.h index 3606c09bc28..9143207c503 100644 --- a/src/mame/includes/lethal.h +++ b/src/mame/includes/lethal.h @@ -4,7 +4,7 @@ *************************************************************************/ #include "sound/k054539.h" -#include "video/konicdev.h" +#include "video/konami_helper.h" #include "video/k054156_k054157_k056832.h" #include "video/k05324x.h" #include "video/k054000.h" diff --git a/src/mame/includes/mainevt.h b/src/mame/includes/mainevt.h index 92c33b6d551..fad402eb442 100644 --- a/src/mame/includes/mainevt.h +++ b/src/mame/includes/mainevt.h @@ -5,7 +5,10 @@ *************************************************************************/ #include "sound/upd7759.h" #include "sound/k007232.h" -#include "video/konicdev.h" +#include "video/k052109.h" +#include "video/k051960.h" +#include "video/k051733.h" +#include "video/konami_helper.h" class mainevt_state : public driver_device { diff --git a/src/mame/includes/moo.h b/src/mame/includes/moo.h index 143379d5a66..98914009e53 100644 --- a/src/mame/includes/moo.h +++ b/src/mame/includes/moo.h @@ -6,12 +6,12 @@ #include "sound/okim6295.h" #include "sound/k054539.h" #include "machine/k053252.h" -#include "video/konicdev.h" +#include "video/k053251.h" #include "video/k054156_k054157_k056832.h" #include "video/k05324x.h" #include "video/k054000.h" #include "video/k054338.h" - +#include "video/konami_helper.h" class moo_state : public driver_device { diff --git a/src/mame/includes/overdriv.h b/src/mame/includes/overdriv.h index 7f3c20201a8..7f5688f493e 100644 --- a/src/mame/includes/overdriv.h +++ b/src/mame/includes/overdriv.h @@ -5,8 +5,10 @@ *************************************************************************/ #include "sound/k053260.h" #include "machine/k053252.h" -#include "video/konicdev.h" +#include "video/k051316.h" #include "video/k05324x.h" +#include "video/k053251.h" +#include "video/konami_helper.h" class overdriv_state : public driver_device { diff --git a/src/mame/includes/parodius.h b/src/mame/includes/parodius.h index 4ba02c17326..7f4af698395 100644 --- a/src/mame/includes/parodius.h +++ b/src/mame/includes/parodius.h @@ -5,6 +5,9 @@ *************************************************************************/ #include "sound/k053260.h" #include "video/k05324x.h" +#include "video/k052109.h" +#include "video/k053251.h" +#include "video/konami_helper.h" class parodius_state : public driver_device { diff --git a/src/mame/includes/qdrmfgp.h b/src/mame/includes/qdrmfgp.h index e302bf816c8..08d0c9f989b 100644 --- a/src/mame/includes/qdrmfgp.h +++ b/src/mame/includes/qdrmfgp.h @@ -1,7 +1,7 @@ #include "machine/ataintf.h" #include "sound/k054539.h" #include "machine/k053252.h" -#include "video/konicdev.h" +#include "video/konami_helper.h" #include "video/k054156_k054157_k056832.h" class qdrmfgp_state : public driver_device diff --git a/src/mame/includes/rockrage.h b/src/mame/includes/rockrage.h index 19166e3c2cf..5844999cf28 100644 --- a/src/mame/includes/rockrage.h +++ b/src/mame/includes/rockrage.h @@ -4,7 +4,8 @@ *************************************************************************/ -#include "video/konicdev.h" +#include "video/k007342.h" +#include "video/k007420.h" class rockrage_state : public driver_device { diff --git a/src/mame/includes/rollerg.h b/src/mame/includes/rollerg.h index 4b0ef722c36..8c6e98343c1 100644 --- a/src/mame/includes/rollerg.h +++ b/src/mame/includes/rollerg.h @@ -5,7 +5,8 @@ *************************************************************************/ #include "sound/k053260.h" #include "machine/k053252.h" -#include "video/konicdev.h" +#include "video/k051316.h" +#include "video/konami_helper.h" #include "video/k05324x.h" class rollerg_state : public driver_device diff --git a/src/mame/includes/rungun.h b/src/mame/includes/rungun.h index 50b7a45b77e..34ba05298ba 100644 --- a/src/mame/includes/rungun.h +++ b/src/mame/includes/rungun.h @@ -7,7 +7,7 @@ #include "machine/k053252.h" #include "video/k05324x.h" #include "video/k053936.h" - +#include "video/konami_helper.h" class rungun_state : public driver_device { diff --git a/src/mame/includes/simpsons.h b/src/mame/includes/simpsons.h index b9678c6a584..a306d6230a3 100644 --- a/src/mame/includes/simpsons.h +++ b/src/mame/includes/simpsons.h @@ -1,5 +1,8 @@ #include "sound/k053260.h" #include "video/k05324x.h" +#include "video/k052109.h" +#include "video/k053251.h" +#include "video/konami_helper.h" class simpsons_state : public driver_device { diff --git a/src/mame/includes/spy.h b/src/mame/includes/spy.h index 6515060b4a6..ac4d8706462 100644 --- a/src/mame/includes/spy.h +++ b/src/mame/includes/spy.h @@ -4,6 +4,9 @@ *************************************************************************/ #include "sound/k007232.h" +#include "video/k052109.h" +#include "video/k051960.h" +#include "video/konami_helper.h" class spy_state : public driver_device { diff --git a/src/mame/includes/surpratk.h b/src/mame/includes/surpratk.h index 63ef61f17ec..88cd49a2617 100644 --- a/src/mame/includes/surpratk.h +++ b/src/mame/includes/surpratk.h @@ -5,6 +5,9 @@ *************************************************************************/ #include "video/k05324x.h" +#include "video/k052109.h" +#include "video/k053251.h" +#include "video/konami_helper.h" class surpratk_state : public driver_device { diff --git a/src/mame/includes/tail2nos.h b/src/mame/includes/tail2nos.h index 4d499b35275..2891f6a9024 100644 --- a/src/mame/includes/tail2nos.h +++ b/src/mame/includes/tail2nos.h @@ -4,7 +4,7 @@ *************************************************************************/ -#include "video/konicdev.h" +#include "video/k051316.h" class tail2nos_state : public driver_device { diff --git a/src/mame/includes/thunderx.h b/src/mame/includes/thunderx.h index e99e60a0dda..e607dcfa39a 100644 --- a/src/mame/includes/thunderx.h +++ b/src/mame/includes/thunderx.h @@ -4,6 +4,9 @@ *************************************************************************/ #include "sound/k007232.h" +#include "video/k052109.h" +#include "video/k051960.h" +#include "video/konami_helper.h" class thunderx_state : public driver_device { diff --git a/src/mame/includes/tmnt.h b/src/mame/includes/tmnt.h index ff4ace1f7d4..8bea61763ac 100644 --- a/src/mame/includes/tmnt.h +++ b/src/mame/includes/tmnt.h @@ -4,9 +4,12 @@ #include "sound/k053260.h" #include "sound/k054539.h" #include "video/k05324x.h" -#include "video/konicdev.h" +#include "video/k052109.h" +#include "video/k051960.h" +#include "video/k053251.h" #include "video/k053936.h" #include "video/k054000.h" +#include "video/konami_helper.h" class tmnt_state : public driver_device { diff --git a/src/mame/includes/ultraman.h b/src/mame/includes/ultraman.h index 005624a2f62..2c22aaa65e4 100644 --- a/src/mame/includes/ultraman.h +++ b/src/mame/includes/ultraman.h @@ -4,7 +4,9 @@ *************************************************************************/ -#include "video/konicdev.h" +#include "video/k051960.h" +#include "video/k051316.h" +#include "video/konami_helper.h" class ultraman_state : public driver_device { diff --git a/src/mame/includes/vendetta.h b/src/mame/includes/vendetta.h index 4b3fe20afce..3a5ea4d9a8a 100644 --- a/src/mame/includes/vendetta.h +++ b/src/mame/includes/vendetta.h @@ -7,7 +7,9 @@ #include "machine/k053252.h" #include "video/k05324x.h" #include "video/k054000.h" - +#include "video/k052109.h" +#include "video/k053251.h" +#include "video/konami_helper.h" class vendetta_state : public driver_device { diff --git a/src/mame/includes/wecleman.h b/src/mame/includes/wecleman.h index 93bad99bffe..d28aef9934b 100644 --- a/src/mame/includes/wecleman.h +++ b/src/mame/includes/wecleman.h @@ -1,5 +1,5 @@ #include "sound/k007232.h" -#include "video/konicdev.h" +#include "video/k051316.h" class wecleman_state : public driver_device { diff --git a/src/mame/includes/xexex.h b/src/mame/includes/xexex.h index 11151efdd22..b66b3c0ba8f 100644 --- a/src/mame/includes/xexex.h +++ b/src/mame/includes/xexex.h @@ -8,11 +8,11 @@ #include "sound/flt_vol.h" #include "sound/k054539.h" #include "machine/k053252.h" -#include "video/konicdev.h" #include "video/k054156_k054157_k056832.h" #include "video/k05324x.h" #include "video/k054338.h" - +#include "video/k053251.h" +#include "video/konami_helper.h" class xexex_state : public driver_device { diff --git a/src/mame/includes/xmen.h b/src/mame/includes/xmen.h index 5e090ae59fa..1914fccea75 100644 --- a/src/mame/includes/xmen.h +++ b/src/mame/includes/xmen.h @@ -1,5 +1,8 @@ #include "sound/k054539.h" #include "video/k05324x.h" +#include "video/k053251.h" +#include "video/k052109.h" +#include "video/konami_helper.h" class xmen_state : public driver_device { diff --git a/src/mame/machine/ajax.c b/src/mame/machine/ajax.c index c4ca9b070e9..35a42c0b387 100644 --- a/src/mame/machine/ajax.c +++ b/src/mame/machine/ajax.c @@ -11,7 +11,7 @@ #include "cpu/m6809/m6809.h" #include "cpu/z80/z80.h" #include "cpu/m6809/konami.h" -#include "video/konicdev.h" + #include "includes/ajax.h" /* ajax_bankswitch_w: diff --git a/src/mame/machine/simpsons.c b/src/mame/machine/simpsons.c index 642be992a31..b9c5e6d7140 100644 --- a/src/mame/machine/simpsons.c +++ b/src/mame/machine/simpsons.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "cpu/m6809/konami.h" #include "machine/eeprom.h" #include "sound/k053260.h" diff --git a/src/mame/mame.mak b/src/mame/mame.mak index 3fe5ed22612..0a05bd898af 100644 --- a/src/mame/mame.mak +++ b/src/mame/mame.mak @@ -1222,6 +1222,15 @@ $(MAMEOBJ)/konami.a: \ $(DRIVERS)/yiear.o $(VIDEO)/yiear.o \ $(DRIVERS)/zr107.o \ $(VIDEO)/konami_helper.o \ + $(VIDEO)/k007121.o \ + $(VIDEO)/k007342.o \ + $(VIDEO)/k007420.o \ + $(VIDEO)/k037122.o \ + $(VIDEO)/k051316.o \ + $(VIDEO)/k051733.o \ + $(VIDEO)/k051960.o \ + $(VIDEO)/k052109.o \ + $(VIDEO)/k053251.o \ $(VIDEO)/k054156_k054157_k056832.o \ $(VIDEO)/k05324x.o \ $(VIDEO)/k055555.o \ diff --git a/src/mame/video/aliens.c b/src/mame/video/aliens.c index f81b428548e..6f481a1d7fd 100644 --- a/src/mame/video/aliens.c +++ b/src/mame/video/aliens.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/aliens.h" /*************************************************************************** diff --git a/src/mame/video/blockhl.c b/src/mame/video/blockhl.c index eeed2e63626..657b22b718e 100644 --- a/src/mame/video/blockhl.c +++ b/src/mame/video/blockhl.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/blockhl.h" diff --git a/src/mame/video/combatsc.c b/src/mame/video/combatsc.c index 5c02e881572..f132d71233f 100644 --- a/src/mame/video/combatsc.c +++ b/src/mame/video/combatsc.c @@ -7,7 +7,7 @@ ***************************************************************************/ #include "emu.h" -#include "video/konicdev.h" + #include "includes/combatsc.h" PALETTE_INIT_MEMBER(combatsc_state,combatsc) diff --git a/src/mame/video/crimfght.c b/src/mame/video/crimfght.c index 8c5779bc1f4..ae77c138d7c 100644 --- a/src/mame/video/crimfght.c +++ b/src/mame/video/crimfght.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/crimfght.h" diff --git a/src/mame/video/crshrace.c b/src/mame/video/crshrace.c index 115acad29ec..4d1d6080a1f 100644 --- a/src/mame/video/crshrace.c +++ b/src/mame/video/crshrace.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/crshrace.h" diff --git a/src/mame/video/f1gp.c b/src/mame/video/f1gp.c index 11ca65a3d36..6ffec4ed1ae 100644 --- a/src/mame/video/f1gp.c +++ b/src/mame/video/f1gp.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/f1gp.h" diff --git a/src/mame/video/gbusters.c b/src/mame/video/gbusters.c index 88337a0ed29..0d155ca08b8 100644 --- a/src/mame/video/gbusters.c +++ b/src/mame/video/gbusters.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/gbusters.h" diff --git a/src/mame/video/gradius3.c b/src/mame/video/gradius3.c index 68d94c2f020..24625e09c1b 100644 --- a/src/mame/video/gradius3.c +++ b/src/mame/video/gradius3.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/gradius3.h" diff --git a/src/mame/video/k007121.h b/src/mame/video/k007121.h new file mode 100644 index 00000000000..7f84ea7114d --- /dev/null +++ b/src/mame/video/k007121.h @@ -0,0 +1,35 @@ +#pragma once +#ifndef __K007121_H__ +#define __K007121_H__ + +class k007121_device : public device_t +{ +public: + k007121_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + ~k007121_device() {} + + DECLARE_READ8_MEMBER( ctrlram_r ); + DECLARE_WRITE8_MEMBER( ctrl_w ); + + /* shall we move source in the interface? */ + /* also notice that now we directly pass *gfx[chip] instead of **gfx !! */ + void sprites_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx, colortable_t *ctable, const UINT8 *source, int base_color, int global_x_offset, int bank_base, UINT32 pri_mask ); + +protected: + // device-level overrides + virtual void device_config_complete(); + virtual void device_start(); + virtual void device_reset(); + +private: + // internal state + UINT8 m_ctrlram[8]; + int m_flipscreen; +}; + +extern const device_type K007121; + +#define MCFG_K007121_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, K007121, 0) + +#endif diff --git a/src/mame/video/k007342.c b/src/mame/video/k007342.c new file mode 100644 index 00000000000..bc5cb8c4fe7 --- /dev/null +++ b/src/mame/video/k007342.c @@ -0,0 +1,307 @@ +/* +Konami 007342 +------ +The 007342 manages 2 64x32 scrolling tilemaps with 8x8 characters, and +optionally generates timing clocks and interrupt signals. It uses 0x2000 +bytes of RAM, plus 0x0200 bytes for scrolling, and a variable amount of ROM. +It cannot read the ROMs. + +control registers +000: ------x- INT control + ---x---- flip screen (TODO: doesn't work with thehustl) +001: Used for banking in Rock'n'Rage +002: -------x MSB of x scroll 1 + ------x- MSB of x scroll 2 + ---xxx-- layer 1 row/column scroll control + 000 = disabled + 010 = unknown (bladestl shootout between periods) + 011 = 32 columns (Blades of Steel) + 101 = 256 rows (Battlantis, Rock 'n Rage) + x------- enable sprite wraparound from bottom to top (see Blades of Steel + high score table) +003: x scroll 1 +004: y scroll 1 +005: x scroll 2 +006: y scroll 2 +007: not used +*/ + +#include "emu.h" +#include "k007342.h" +#include "konami_helper.h" + +#define VERBOSE 0 +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) + +const device_type K007342 = &device_creator; + +k007342_device::k007342_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, K007342, "Konami 007342", tag, owner, clock, "k007342", __FILE__), + m_ram(NULL), + m_scroll_ram(NULL), + m_videoram_0(NULL), + m_videoram_1(NULL), + m_colorram_0(NULL), + m_colorram_1(NULL), + //m_tilemap[2]; + m_flipscreen(0), + m_int_enabled(0) + //m_regs[8], + //m_scrollx[2], + //m_scrolly[2] +{ +} + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void k007342_device::device_config_complete() +{ + // inherit a copy of the static data + const k007342_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + m_gfxnum = 0; + m_callback = NULL; + } +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void k007342_device::device_start() +{ + m_tilemap[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k007342_device::get_tile_info0),this), tilemap_mapper_delegate(FUNC(k007342_device::scan),this), 8, 8, 64, 32); + m_tilemap[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k007342_device::get_tile_info1),this), tilemap_mapper_delegate(FUNC(k007342_device::scan),this), 8, 8, 64, 32); + + m_ram = auto_alloc_array_clear(machine(), UINT8, 0x2000); + m_scroll_ram = auto_alloc_array_clear(machine(), UINT8, 0x0200); + + m_colorram_0 = &m_ram[0x0000]; + m_colorram_1 = &m_ram[0x1000]; + m_videoram_0 = &m_ram[0x0800]; + m_videoram_1 = &m_ram[0x1800]; + + m_tilemap[0]->set_transparent_pen(0); + m_tilemap[1]->set_transparent_pen(0); + + save_pointer(NAME(m_ram), 0x2000); + save_pointer(NAME(m_scroll_ram), 0x0200); + save_item(NAME(m_int_enabled)); + save_item(NAME(m_flipscreen)); + save_item(NAME(m_scrollx)); + save_item(NAME(m_scrolly)); + save_item(NAME(m_regs)); +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void k007342_device::device_reset() +{ + int i; + + m_int_enabled = 0; + m_flipscreen = 0; + m_scrollx[0] = 0; + m_scrollx[1] = 0; + m_scrolly[0] = 0; + m_scrolly[1] = 0; + + for (i = 0; i < 8; i++) + m_regs[i] = 0; +} + +/***************************************************************************** + DEVICE HANDLERS +*****************************************************************************/ + +READ8_MEMBER( k007342_device::read ) +{ + return m_ram[offset]; +} + +WRITE8_MEMBER( k007342_device::write ) +{ + m_ram[offset] = data; + + if (offset < 0x1000) /* layer 0 */ + m_tilemap[0]->mark_tile_dirty(offset & 0x7ff); + else /* layer 1 */ + m_tilemap[1]->mark_tile_dirty(offset & 0x7ff); +} + +READ8_MEMBER( k007342_device::scroll_r ) +{ + return m_scroll_ram[offset]; +} + +WRITE8_MEMBER( k007342_device::scroll_w ) +{ + m_scroll_ram[offset] = data; +} + +WRITE8_MEMBER( k007342_device::vreg_w ) +{ + switch(offset) + { + case 0x00: + /* bit 1: INT control */ + m_int_enabled = data & 0x02; + m_flipscreen = data & 0x10; + m_tilemap[0]->set_flip(m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + m_tilemap[1]->set_flip(m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + break; + case 0x01: /* used for banking in Rock'n'Rage */ + if (data != m_regs[1]) + space.machine().tilemap().mark_all_dirty(); + case 0x02: + m_scrollx[0] = (m_scrollx[0] & 0xff) | ((data & 0x01) << 8); + m_scrollx[1] = (m_scrollx[1] & 0xff) | ((data & 0x02) << 7); + break; + case 0x03: /* scroll x (register 0) */ + m_scrollx[0] = (m_scrollx[0] & 0x100) | data; + break; + case 0x04: /* scroll y (register 0) */ + m_scrolly[0] = data; + break; + case 0x05: /* scroll x (register 1) */ + m_scrollx[1] = (m_scrollx[1] & 0x100) | data; + break; + case 0x06: /* scroll y (register 1) */ + m_scrolly[1] = data; + case 0x07: /* unused */ + break; + } + m_regs[offset] = data; +} + +void k007342_device::tilemap_update( ) +{ + int offs; + + /* update scroll */ + switch (m_regs[2] & 0x1c) + { + case 0x00: + case 0x08: /* unknown, blades of steel shootout between periods */ + m_tilemap[0]->set_scroll_rows(1); + m_tilemap[0]->set_scroll_cols(1); + m_tilemap[0]->set_scrollx(0, m_scrollx[0]); + m_tilemap[0]->set_scrolly(0, m_scrolly[0]); + break; + + case 0x0c: /* 32 columns */ + m_tilemap[0]->set_scroll_rows(1); + m_tilemap[0]->set_scroll_cols(512); + m_tilemap[0]->set_scrollx(0, m_scrollx[0]); + for (offs = 0; offs < 256; offs++) + m_tilemap[0]->set_scrolly((offs + m_scrollx[0]) & 0x1ff, + m_scroll_ram[2 * (offs / 8)] + 256 * m_scroll_ram[2 * (offs / 8) + 1]); + break; + + case 0x14: /* 256 rows */ + m_tilemap[0]->set_scroll_rows(256); + m_tilemap[0]->set_scroll_cols(1); + m_tilemap[0]->set_scrolly(0, m_scrolly[0]); + for (offs = 0; offs < 256; offs++) + m_tilemap[0]->set_scrollx((offs + m_scrolly[0]) & 0xff, + m_scroll_ram[2 * offs] + 256 * m_scroll_ram[2 * offs + 1]); + break; + + default: +// popmessage("unknown scroll ctrl %02x", m_regs[2] & 0x1c); + break; + } + + m_tilemap[1]->set_scrollx(0, m_scrollx[1]); + m_tilemap[1]->set_scrolly(0, m_scrolly[1]); + +#if 0 + { + static int current_layer = 0; + + if (machine.input().code_pressed_once(KEYCODE_Z)) current_layer = !current_layer; + m_tilemap[current_layer]->enable(1); + m_tilemap[!current_layer]->enable(0); + + popmessage("regs:%02x %02x %02x %02x-%02x %02x %02x %02x:%02x", + m_regs[0], m_regs[1], m_regs[2], m_regs[3], + m_regs[4], m_regs[5], m_regs[6], m_regs[7], + current_layer); + } +#endif +} + +void k007342_device::tilemap_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, int num, int flags, UINT32 priority ) +{ + m_tilemap[num]->draw(bitmap, cliprect, flags, priority); +} + +int k007342_device::is_int_enabled( ) +{ + return m_int_enabled; +} + + +/*************************************************************************** + + Callbacks for the TileMap code + +***************************************************************************/ + +/* + data format: + video RAM xxxxxxxx tile number (bits 0-7) + color RAM x------- tiles with priority over the sprites + color RAM -x------ depends on external conections + color RAM --x----- flip Y + color RAM ---x---- flip X + color RAM ----xxxx depends on external connections (usually color and banking) +*/ + +TILEMAP_MAPPER_MEMBER(k007342_device::scan) +{ + /* logical (col,row) -> memory offset */ + return (col & 0x1f) + ((row & 0x1f) << 5) + ((col & 0x20) << 5); +} + +void k007342_device::get_tile_info( tile_data &tileinfo, int tile_index, int layer, UINT8 *cram, UINT8 *vram ) +{ + int color, code, flags; + + color = cram[tile_index]; + code = vram[tile_index]; + flags = TILE_FLIPYX((color & 0x30) >> 4); + + tileinfo.category = (color & 0x80) >> 7; + + m_callback(machine(), layer, m_regs[1], &code, &color, &flags); + + SET_TILE_INFO_MEMBER( + m_gfxnum, + code, + color, + flags); +} + +TILE_GET_INFO_MEMBER(k007342_device::get_tile_info0) +{ + get_tile_info(tileinfo, tile_index, 0, m_colorram_0, m_videoram_0); +} + +TILE_GET_INFO_MEMBER(k007342_device::get_tile_info1) +{ + get_tile_info(tileinfo, tile_index, 1, m_colorram_1, m_videoram_1); +} + + diff --git a/src/mame/video/k007342.h b/src/mame/video/k007342.h new file mode 100644 index 00000000000..45f6f22b4d7 --- /dev/null +++ b/src/mame/video/k007342.h @@ -0,0 +1,62 @@ +#pragma once +#ifndef __K007342_H__ +#define __K007342_H__ + +typedef void (*k007342_callback)(running_machine &machine, int tmap, int bank, int *code, int *color, int *flags); + +struct k007342_interface +{ + int m_gfxnum; + k007342_callback m_callback; +}; + +class k007342_device : public device_t, + public k007342_interface +{ +public: + k007342_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + ~k007342_device() {} + + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); + DECLARE_READ8_MEMBER( scroll_r ); + DECLARE_WRITE8_MEMBER( scroll_w ); + DECLARE_WRITE8_MEMBER( vreg_w ); + + void tilemap_update(); + void tilemap_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int num, int flags, UINT32 priority); + int is_int_enabled(); + +protected: + // device-level overrides + virtual void device_config_complete(); + virtual void device_start(); + virtual void device_reset(); +private: + // internal state + UINT8 *m_ram; + UINT8 *m_scroll_ram; + UINT8 *m_videoram_0; + UINT8 *m_videoram_1; + UINT8 *m_colorram_0; + UINT8 *m_colorram_1; + + tilemap_t *m_tilemap[2]; + int m_flipscreen, m_int_enabled; + UINT8 m_regs[8]; + UINT16 m_scrollx[2]; + UINT8 m_scrolly[2]; + + TILEMAP_MAPPER_MEMBER(scan); + TILE_GET_INFO_MEMBER(get_tile_info0); + TILE_GET_INFO_MEMBER(get_tile_info1); + void get_tile_info( tile_data &tileinfo, int tile_index, int layer, UINT8 *cram, UINT8 *vram ); +}; + +extern const device_type K007342; + +#define MCFG_K007342_ADD(_tag, _interface) \ + MCFG_DEVICE_ADD(_tag, K007342, 0) \ + MCFG_DEVICE_CONFIG(_interface) + +#endif diff --git a/src/mame/video/k007420.c b/src/mame/video/k007420.c new file mode 100644 index 00000000000..67aed36c9e9 --- /dev/null +++ b/src/mame/video/k007420.c @@ -0,0 +1,261 @@ +/* +Konami 007420 +------ +Sprite generator. 8 bytes per sprite with zoom. It uses 0x200 bytes of RAM, +and a variable amount of ROM. Nothing is known about its external interface. +*/ + +#include "emu.h" +#include "k007420.h" +#include "konami_helper.h" + +#define VERBOSE 0 +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) + +#define K007420_SPRITERAM_SIZE 0x200 + +const device_type K007420 = &device_creator; + +k007420_device::k007420_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, K007420, "Konami 007420", tag, owner, clock, "k007420", __FILE__), + m_ram(NULL), + m_flipscreen(0) + //m_regs[8], +{ +} + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void k007420_device::device_config_complete() +{ + // inherit a copy of the static data + const k007420_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + m_banklimit = 0; + m_callback = NULL; + } +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void k007420_device::device_start() +{ + m_ram = auto_alloc_array_clear(machine(), UINT8, 0x200); + + save_pointer(NAME(m_ram), 0x200); + save_item(NAME(m_flipscreen)); // current one uses 7342 one + save_item(NAME(m_regs)); // current one uses 7342 ones +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void k007420_device::device_reset() +{ + int i; + + m_flipscreen = 0; + for (i = 0; i < 8; i++) + m_regs[i] = 0; +} + +/***************************************************************************** + DEVICE HANDLERS +*****************************************************************************/ + +READ8_MEMBER( k007420_device::read ) +{ + return m_ram[offset]; +} + +WRITE8_MEMBER( k007420_device::write ) +{ + m_ram[offset] = data; +} + +/* + * Sprite Format + * ------------------ + * + * Byte | Bit(s) | Use + * -----+-76543210-+---------------- + * 0 | xxxxxxxx | y position + * 1 | xxxxxxxx | sprite code (low 8 bits) + * 2 | xxxxxxxx | depends on external conections. Usually banking + * 3 | xxxxxxxx | x position (low 8 bits) + * 4 | x------- | x position (high bit) + * 4 | -xxx---- | sprite size 000=16x16 001=8x16 010=16x8 011=8x8 100=32x32 + * 4 | ----x--- | flip y + * 4 | -----x-- | flip x + * 4 | ------xx | zoom (bits 8 & 9) + * 5 | xxxxxxxx | zoom (low 8 bits) 0x080 = normal, < 0x80 enlarge, > 0x80 reduce + * 6 | xxxxxxxx | unused + * 7 | xxxxxxxx | unused + */ + +void k007420_device::sprites_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx ) +{ + int offs; + int codemask = m_banklimit; + int bankmask = ~m_banklimit; + + for (offs = K007420_SPRITERAM_SIZE - 8; offs >= 0; offs -= 8) + { + int ox, oy, code, color, flipx, flipy, zoom, w, h, x, y, bank; + static const int xoffset[4] = { 0, 1, 4, 5 }; + static const int yoffset[4] = { 0, 2, 8, 10 }; + + code = m_ram[offs + 1]; + color = m_ram[offs + 2]; + ox = m_ram[offs + 3] - ((m_ram[offs + 4] & 0x80) << 1); + oy = 256 - m_ram[offs + 0]; + flipx = m_ram[offs + 4] & 0x04; + flipy = m_ram[offs + 4] & 0x08; + + m_callback(machine(), &code, &color); + + bank = code & bankmask; + code &= codemask; + + /* 0x080 = normal scale, 0x040 = double size, 0x100 half size */ + zoom = m_ram[offs + 5] | ((m_ram[offs + 4] & 0x03) << 8); + if (!zoom) + continue; + zoom = 0x10000 * 128 / zoom; + + switch (m_ram[offs + 4] & 0x70) + { + case 0x30: w = h = 1; break; + case 0x20: w = 2; h = 1; code &= (~1); break; + case 0x10: w = 1; h = 2; code &= (~2); break; + case 0x00: w = h = 2; code &= (~3); break; + case 0x40: w = h = 4; code &= (~3); break; + default: w = 1; h = 1; +//logerror("Unknown sprite size %02x\n",(m_ram[offs + 4] & 0x70) >> 4); + } + + if (m_flipscreen) + { + ox = 256 - ox - ((zoom * w + (1 << 12)) >> 13); + oy = 256 - oy - ((zoom * h + (1 << 12)) >> 13); + flipx = !flipx; + flipy = !flipy; + } + + if (zoom == 0x10000) + { + int sx, sy; + + for (y = 0; y < h; y++) + { + sy = oy + 8 * y; + + for (x = 0; x < w; x++) + { + int c = code; + + sx = ox + 8 * x; + if (flipx) + c += xoffset[(w - 1 - x)]; + else + c += xoffset[x]; + + if (flipy) + c += yoffset[(h - 1 - y)]; + else + c += yoffset[y]; + + if (c & bankmask) + continue; + else + c += bank; + + drawgfx_transpen(bitmap,cliprect,gfx, + c, + color, + flipx,flipy, + sx,sy,0); + + if (m_regs[2] & 0x80) + drawgfx_transpen(bitmap,cliprect,gfx, + c, + color, + flipx,flipy, + sx,sy-256,0); + } + } + } + else + { + int sx, sy, zw, zh; + for (y = 0; y < h; y++) + { + sy = oy + ((zoom * y + (1 << 12)) >> 13); + zh = (oy + ((zoom * (y + 1) + (1 << 12)) >> 13)) - sy; + + for (x = 0; x < w; x++) + { + int c = code; + + sx = ox + ((zoom * x + (1<<12)) >> 13); + zw = (ox + ((zoom * (x + 1) + (1 << 12)) >> 13)) - sx; + if (flipx) + c += xoffset[(w - 1 - x)]; + else + c += xoffset[x]; + + if (flipy) + c += yoffset[(h - 1 - y)]; + else + c += yoffset[y]; + + if (c & bankmask) + continue; + else + c += bank; + + drawgfxzoom_transpen(bitmap,cliprect,gfx, + c, + color, + flipx,flipy, + sx,sy, + (zw << 16) / 8,(zh << 16) / 8,0); + + if (m_regs[2] & 0x80) + drawgfxzoom_transpen(bitmap,cliprect,gfx, + c, + color, + flipx,flipy, + sx,sy-256, + (zw << 16) / 8,(zh << 16) / 8,0); + } + } + } + } +#if 0 + { + static int current_sprite = 0; + + if (machine().input().code_pressed_once(KEYCODE_Z)) current_sprite = (current_sprite+1) & ((K007420_SPRITERAM_SIZE/8)-1); + if (machine().input().code_pressed_once(KEYCODE_X)) current_sprite = (current_sprite-1) & ((K007420_SPRITERAM_SIZE/8)-1); + + popmessage("%02x:%02x %02x %02x %02x %02x %02x %02x %02x", current_sprite, + m_ram[(current_sprite*8)+0], m_ram[(current_sprite*8)+1], + m_ram[(current_sprite*8)+2], m_ram[(current_sprite*8)+3], + m_ram[(current_sprite*8)+4], m_ram[(current_sprite*8)+5], + m_ram[(current_sprite*8)+6], m_ram[(current_sprite*8)+7]); + } +#endif +} diff --git a/src/mame/video/k007420.h b/src/mame/video/k007420.h new file mode 100644 index 00000000000..c2dffbf9bd6 --- /dev/null +++ b/src/mame/video/k007420.h @@ -0,0 +1,43 @@ +#pragma once +#ifndef __K007420_H__ +#define __K007420_H__ + +typedef void (*k007420_callback)(running_machine &machine, int *code, int *color); + +struct k007420_interface +{ + int m_banklimit; + k007420_callback m_callback; +}; + +class k007420_device : public device_t, + public k007420_interface +{ +public: + k007420_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + ~k007420_device() {} + + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); + void sprites_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx); + +protected: + // device-level overrides + virtual void device_config_complete(); + virtual void device_start(); + virtual void device_reset(); +private: + // internal state + UINT8 *m_ram; + + int m_flipscreen; // current code uses the 7342 flipscreen!! + UINT8 m_regs[8]; // current code uses the 7342 regs!! (only [2]) +}; + +extern const device_type K007420; + +#define MCFG_K007420_ADD(_tag, _interface) \ + MCFG_DEVICE_ADD(_tag, K007420, 0) \ + MCFG_DEVICE_CONFIG(_interface) + +#endif diff --git a/src/mame/video/k037122.c b/src/mame/video/k037122.c new file mode 100644 index 00000000000..6b53821a28f --- /dev/null +++ b/src/mame/video/k037122.c @@ -0,0 +1,227 @@ +/* +Konami 037122 +*/ + +#include "emu.h" +#include "k037122.h" +#include "konami_helper.h" + +#define VERBOSE 0 +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) + +#define K037122_NUM_TILES 16384 + +const device_type K037122 = &device_creator; + +k037122_device::k037122_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, K037122, "Konami 0371222", tag, owner, clock, "k037122", __FILE__), + m_screen(NULL), + m_tile_ram(NULL), + m_char_ram(NULL), + m_reg(NULL) +{ +} + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void k037122_device::device_config_complete() +{ + // inherit a copy of the static data + const k037122_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + m_screen_tag = ""; + m_gfx_index = 0; + } +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void k037122_device::device_start() +{ + static const gfx_layout k037122_char_layout = + { + 8, 8, + K037122_NUM_TILES, + 8, + { 0,1,2,3,4,5,6,7 }, + { 1*16, 0*16, 3*16, 2*16, 5*16, 4*16, 7*16, 6*16 }, + { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128 }, + 8*128 + }; + + m_screen = machine().device(m_screen_tag); + + m_char_ram = auto_alloc_array_clear(machine(), UINT32, 0x200000 / 4); + m_tile_ram = auto_alloc_array_clear(machine(), UINT32, 0x20000 / 4); + m_reg = auto_alloc_array_clear(machine(), UINT32, 0x400 / 4); + + m_layer[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k037122_device::tile_info_layer0),this), TILEMAP_SCAN_ROWS, 8, 8, 256, 64); + m_layer[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k037122_device::tile_info_layer1),this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); + + m_layer[0]->set_transparent_pen(0); + m_layer[1]->set_transparent_pen(0); + + machine().gfx[m_gfx_index] = auto_alloc_clear(machine(), gfx_element(machine(), k037122_char_layout, (UINT8*)m_char_ram, machine().total_colors() / 16, 0)); + + save_pointer(NAME(m_reg), 0x400 / 4); + save_pointer(NAME(m_char_ram), 0x200000 / 4); + save_pointer(NAME(m_tile_ram), 0x20000 / 4); + +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void k037122_device::device_reset() +{ + memset(m_char_ram, 0, 0x200000); + memset(m_tile_ram, 0, 0x20000); + memset(m_reg, 0, 0x400); +} + +/***************************************************************************** + DEVICE HANDLERS +*****************************************************************************/ + +TILE_GET_INFO_MEMBER(k037122_device::tile_info_layer0) +{ + UINT32 val = m_tile_ram[tile_index + (0x8000/4)]; + int color = (val >> 17) & 0x1f; + int tile = val & 0x3fff; + int flags = 0; + + if (val & 0x400000) + flags |= TILE_FLIPX; + if (val & 0x800000) + flags |= TILE_FLIPY; + + SET_TILE_INFO_MEMBER(m_gfx_index, tile, color, flags); +} + +TILE_GET_INFO_MEMBER(k037122_device::tile_info_layer1) +{ + UINT32 val = m_tile_ram[tile_index]; + int color = (val >> 17) & 0x1f; + int tile = val & 0x3fff; + int flags = 0; + + if (val & 0x400000) + flags |= TILE_FLIPX; + if (val & 0x800000) + flags |= TILE_FLIPY; + + SET_TILE_INFO_MEMBER(m_gfx_index, tile, color, flags); +} + + +void k037122_device::tile_draw( bitmap_rgb32 &bitmap, const rectangle &cliprect ) +{ + const rectangle &visarea = m_screen->visible_area(); + + if (m_reg[0xc] & 0x10000) + { + m_layer[1]->set_scrolldx(visarea.min_x, visarea.min_x); + m_layer[1]->set_scrolldy(visarea.min_y, visarea.min_y); + m_layer[1]->draw(bitmap, cliprect, 0, 0); + } + else + { + m_layer[0]->set_scrolldx(visarea.min_x, visarea.min_x); + m_layer[0]->set_scrolldy(visarea.min_y, visarea.min_y); + m_layer[0]->draw(bitmap, cliprect, 0, 0); + } +} + +void k037122_device::update_palette_color( UINT32 palette_base, int color ) +{ + UINT32 data = m_tile_ram[(palette_base / 4) + color]; + + palette_set_color_rgb(machine(), color, pal5bit(data >> 6), pal6bit(data >> 0), pal5bit(data >> 11)); +} + +READ32_MEMBER( k037122_device::sram_r ) +{ + return m_tile_ram[offset]; +} + +WRITE32_MEMBER( k037122_device::sram_w ) +{ + COMBINE_DATA(m_tile_ram + offset); + + if (m_reg[0xc] & 0x10000) + { + if (offset < 0x8000 / 4) + { + m_layer[1]->mark_tile_dirty(offset); + } + else if (offset >= 0x8000 / 4 && offset < 0x18000 / 4) + { + m_layer[0]->mark_tile_dirty(offset - (0x8000 / 4)); + } + else if (offset >= 0x18000 / 4) + { + update_palette_color(0x18000, offset - (0x18000 / 4)); + } + } + else + { + if (offset < 0x8000 / 4) + { + update_palette_color(0, offset); + } + else if (offset >= 0x8000 / 4 && offset < 0x18000 / 4) + { + m_layer[0]->mark_tile_dirty(offset - (0x8000 / 4)); + } + else if (offset >= 0x18000 / 4) + { + m_layer[1]->mark_tile_dirty(offset - (0x18000 / 4)); + } + } +} + + +READ32_MEMBER( k037122_device::char_r ) +{ + int bank = m_reg[0x30 / 4] & 0x7; + + return m_char_ram[offset + (bank * (0x40000 / 4))]; +} + +WRITE32_MEMBER( k037122_device::char_w ) +{ + int bank = m_reg[0x30 / 4] & 0x7; + UINT32 addr = offset + (bank * (0x40000/4)); + + COMBINE_DATA(m_char_ram + addr); + space.machine().gfx[m_gfx_index]->mark_dirty(addr / 32); +} + +READ32_MEMBER( k037122_device::reg_r ) +{ + switch (offset) + { + case 0x14/4: + { + return 0x000003fa; + } + } + return m_reg[offset]; +} + +WRITE32_MEMBER( k037122_device::reg_w ) +{ + COMBINE_DATA(m_reg + offset); +} diff --git a/src/mame/video/k037122.h b/src/mame/video/k037122.h new file mode 100644 index 00000000000..902db3b3343 --- /dev/null +++ b/src/mame/video/k037122.h @@ -0,0 +1,52 @@ +#pragma once +#ifndef __K037122_H__ +#define __K037122_H__ + +struct k037122_interface +{ + const char *m_screen_tag; + int m_gfx_index; +}; + +class k037122_device : public device_t, + public k037122_interface +{ +public: + k037122_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + ~k037122_device() {} + + void tile_draw( bitmap_rgb32 &bitmap, const rectangle &cliprect ); + DECLARE_READ32_MEMBER( sram_r ); + DECLARE_WRITE32_MEMBER( sram_w ); + DECLARE_READ32_MEMBER( char_r ); + DECLARE_WRITE32_MEMBER( char_w ); + DECLARE_READ32_MEMBER( reg_r ); + DECLARE_WRITE32_MEMBER( reg_w ); + +protected: + // device-level overrides + virtual void device_config_complete(); + virtual void device_start(); + virtual void device_reset(); + +private: + // internal state + screen_device *m_screen; + tilemap_t *m_layer[2]; + + UINT32 * m_tile_ram; + UINT32 * m_char_ram; + UINT32 * m_reg; + + TILE_GET_INFO_MEMBER(tile_info_layer0); + TILE_GET_INFO_MEMBER(tile_info_layer1); + void update_palette_color( UINT32 palette_base, int color ); +}; + +extern const device_type K037122; + +#define MCFG_K037122_ADD(_tag, _interface) \ + MCFG_DEVICE_ADD(_tag, K037122, 0) \ + MCFG_DEVICE_CONFIG(_interface) + +#endif diff --git a/src/mame/video/k051316.c b/src/mame/video/k051316.c new file mode 100644 index 00000000000..498b3cb7350 --- /dev/null +++ b/src/mame/video/k051316.c @@ -0,0 +1,317 @@ +/* +Konami 051316 +------ +Manages a 32x32 tilemap (16x16 tiles, 512x512 pixels) which can be zoomed, +distorted and rotated. +It uses two internal 24 bit counters which are incremented while scanning the +picture. The coordinates of the pixel in the tilemap that has to be drawn to +the current beam position are the counters / (2^11). +The chip doesn't directly generate the color information for the pixel, it +just generates a 24 bit address (whose top 16 bits are the contents of the +tilemap RAM), and a "visible" signal. It's up to external circuitry to convert +the address into a pixel color. Most games seem to use 4bpp graphics, but Ajax +uses 7bpp. +If the value in the internal counters is out of the visible range (0..511), it +is truncated and the corresponding address is still generated, but the "visible" +signal is not asserted. The external circuitry might ignore that signal and +still generate the pixel, therefore making the tilemap a continuous playfield +that wraps around instead of a large sprite. + +control registers +000-001 X counter starting value / 256 +002-003 amount to add to the X counter after each horizontal pixel +004-005 amount to add to the X counter after each line (0 = no rotation) +006-007 Y counter starting value / 256 +008-009 amount to add to the Y counter after each horizontal pixel (0 = no rotation) +00a-00b amount to add to the Y counter after each line +00c-00d ROM bank to read, used during ROM testing +00e bit 0 = enable ROM reading (active low). This only makes the chip output the + requested address: the ROM is actually read externally, not through + the chip's data bus. + bit 1 = unknown + bit 2 = unknown +00f unused + +*/ + +#include "emu.h" +#include "k051316.h" +#include "konami_helper.h" + +#define VERBOSE 0 +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) + +#define XOR(a) WORD_XOR_BE(a) + +const device_type K051316 = &device_creator; + +k051316_device::k051316_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, K051316, "Konami 051316", tag, owner, clock, "k051316", __FILE__), + m_ram(NULL) + //m_tmap, + //m_ctrlram[16] +{ +} + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void k051316_device::device_config_complete() +{ + // inherit a copy of the static data + const k051316_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + m_gfx_memory_region_tag = ""; + m_gfx_num = 0; + m_bpp = 0; + m_pen_is_mask = 0; + m_transparent_pen = 0; + m_wrap = 0; + m_xoffs = 0; + m_yoffs = 0; + m_callback = NULL; + } +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void k051316_device::device_start() +{ + int is_tail2nos = 0; + UINT32 total; + + static const gfx_layout charlayout4 = + { + 16,16, + 0, + 4, + { 0, 1, 2, 3 }, + { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4, + 8*4, 9*4, 10*4, 11*4, 12*4, 13*4, 14*4, 15*4 }, + { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64, + 8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 }, + 128*8 + }; + + static const gfx_layout charlayout7 = + { + 16,16, + 0, + 7, + { 1,2,3,4,5,6,7 }, + { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, + 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, + { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128, + 8*128, 9*128, 10*128, 11*128, 12*128, 13*128, 14*128, 15*128 }, + 256*8 + }; + + static const gfx_layout charlayout8 = + { + 16,16, + 0, + 8, + { 0,1,2,3,4,5,6,7 }, + { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, + 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, + { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128, + 8*128, 9*128, 10*128, 11*128, 12*128, 13*128, 14*128, 15*128 }, + 256*8 + }; + + static const gfx_layout charlayout_tail2nos = + { + 16,16, + 0, + 4, + { 0, 1, 2, 3 }, + { XOR(0)*4, XOR(1)*4, XOR(2)*4, XOR(3)*4, XOR(4)*4, XOR(5)*4, XOR(6)*4, XOR(7)*4, + XOR(8)*4, XOR(9)*4, XOR(10)*4, XOR(11)*4, XOR(12)*4, XOR(13)*4, XOR(14)*4, XOR(15)*4 }, + { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64, + 8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 }, + 128*8 + }; + + /* decode the graphics */ + switch (m_bpp) + { + case -4: + total = 0x400; + is_tail2nos = 1; + konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region_tag)->base(), total, &charlayout_tail2nos, 4); + break; + + case 4: + total = machine().root_device().memregion(m_gfx_memory_region_tag)->bytes() / 128; + konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region_tag)->base(), total, &charlayout4, 4); + break; + + case 7: + total = machine().root_device().memregion(m_gfx_memory_region_tag)->bytes() / 256; + konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region_tag)->base(), total, &charlayout7, 7); + break; + + case 8: + total = machine().root_device().memregion(m_gfx_memory_region_tag)->bytes() / 256; + konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region_tag)->base(), total, &charlayout8, 8); + break; + + default: + fatalerror("Unsupported bpp\n"); + } + + m_bpp = is_tail2nos ? 4 : m_bpp; // tail2nos is passed with bpp = -4 to setup the custom charlayout! + + m_tmap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k051316_device::get_tile_info0),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); + + m_ram = auto_alloc_array_clear(machine(), UINT8, 0x800); + + if (!m_pen_is_mask) + m_tmap->set_transparent_pen(m_transparent_pen); + else + { + m_tmap->map_pens_to_layer(0, 0, 0, TILEMAP_PIXEL_LAYER1); + m_tmap->map_pens_to_layer(0, m_transparent_pen, m_transparent_pen, TILEMAP_PIXEL_LAYER0); + } + + save_pointer(NAME(m_ram), 0x800); + save_item(NAME(m_ctrlram)); + save_item(NAME(m_wrap)); + +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void k051316_device::device_reset() +{ + memset(m_ctrlram, 0, 0x10); +} + +/***************************************************************************** + DEVICE HANDLERS +*****************************************************************************/ + +READ8_MEMBER( k051316_device::read ) +{ + return m_ram[offset]; +} + +WRITE8_MEMBER( k051316_device::write ) +{ + m_ram[offset] = data; + m_tmap->mark_tile_dirty(offset & 0x3ff); +} + + +READ8_MEMBER( k051316_device::rom_r ) +{ + if ((m_ctrlram[0x0e] & 0x01) == 0) + { + int addr = offset + (m_ctrlram[0x0c] << 11) + (m_ctrlram[0x0d] << 19); + if (m_bpp <= 4) + addr /= 2; + addr &= space.machine().root_device().memregion(m_gfx_memory_region_tag)->bytes() - 1; + + // popmessage("%s: offset %04x addr %04x", space.machine().describe_context(), offset, addr); + + return space.machine().root_device().memregion(m_gfx_memory_region_tag)->base()[addr]; + } + else + { + //logerror("%s: read 051316 ROM offset %04x but reg 0x0c bit 0 not clear\n", space.machine().describe_context(), offset); + return 0; + } +} + +WRITE8_MEMBER( k051316_device::ctrl_w ) +{ + m_ctrlram[offset] = data; + //if (offset >= 0x0c) logerror("%s: write %02x to 051316 reg %x\n", space.machine().describe_context(), data, offset); +} + +// a few games (ajax, rollerg, ultraman, etc.) can enable and disable wraparound after start +void k051316_device::wraparound_enable( int status ) +{ + m_wrap = status; +} + +/*************************************************************************** + + Callbacks for the TileMap code + +***************************************************************************/ + +void k051316_device::get_tile_info( tile_data &tileinfo, int tile_index ) +{ + int code = m_ram[tile_index]; + int color = m_ram[tile_index + 0x400]; + int flags = 0; + + m_callback(machine(), &code, &color, &flags); + + SET_TILE_INFO_MEMBER( + m_gfx_num, + code, + color, + flags); +} + + +TILE_GET_INFO_MEMBER(k051316_device::get_tile_info0) { get_tile_info(tileinfo, tile_index); } + + +void k051316_device::zoom_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, int flags, UINT32 priority ) +{ + UINT32 startx, starty; + int incxx, incxy, incyx, incyy; + + startx = 256 * ((INT16)(256 * m_ctrlram[0x00] + m_ctrlram[0x01])); + incxx = (INT16)(256 * m_ctrlram[0x02] + m_ctrlram[0x03]); + incyx = (INT16)(256 * m_ctrlram[0x04] + m_ctrlram[0x05]); + starty = 256 * ((INT16)(256 * m_ctrlram[0x06] + m_ctrlram[0x07])); + incxy = (INT16)(256 * m_ctrlram[0x08] + m_ctrlram[0x09]); + incyy = (INT16)(256 * m_ctrlram[0x0a] + m_ctrlram[0x0b]); + + startx -= (16 + m_yoffs) * incyx; + starty -= (16 + m_yoffs) * incyy; + + startx -= (89 + m_xoffs) * incxx; + starty -= (89 + m_xoffs) * incxy; + + m_tmap->draw_roz(bitmap, cliprect, startx << 5,starty << 5, + incxx << 5,incxy << 5,incyx << 5,incyy << 5, + m_wrap, + flags,priority); + +#if 0 + popmessage("%02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x", + m_ctrlram[0x00], + m_ctrlram[0x01], + m_ctrlram[0x02], + m_ctrlram[0x03], + m_ctrlram[0x04], + m_ctrlram[0x05], + m_ctrlram[0x06], + m_ctrlram[0x07], + m_ctrlram[0x08], + m_ctrlram[0x09], + m_ctrlram[0x0a], + m_ctrlram[0x0b], + m_ctrlram[0x0c], /* bank for ROM testing */ + m_ctrlram[0x0d], + m_ctrlram[0x0e], /* 0 = test ROMs */ + m_ctrlram[0x0f]); +#endif +} diff --git a/src/mame/video/k051316.h b/src/mame/video/k051316.h new file mode 100644 index 00000000000..1c516458106 --- /dev/null +++ b/src/mame/video/k051316.h @@ -0,0 +1,63 @@ +#pragma once +#ifndef __K051316_H__ +#define __K051316_H__ + +typedef void (*k051316_callback)(running_machine &machine, int *code, int *color, int *flags); + +struct k051316_interface +{ + const char *m_gfx_memory_region_tag; + int m_gfx_num; + int m_bpp, m_pen_is_mask, m_transparent_pen; + int m_wrap, m_xoffs, m_yoffs; + k051316_callback m_callback; +}; + +class k051316_device : public device_t, + public k051316_interface +{ +public: + k051316_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + ~k051316_device() {} + + /* + The callback is passed: + - code (range 00-FF, contents of the first tilemap RAM byte) + - color (range 00-FF, contents of the first tilemap RAM byte). Note that bit 6 + seems to be hardcoded as flip X. + The callback must put: + - in code the resulting tile number + - in color the resulting color index + - if necessary, put flags for the TileMap code in the tile_info + structure (e.g. TILE_FLIPX) + */ + + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); + DECLARE_READ8_MEMBER( rom_r ); + DECLARE_WRITE8_MEMBER( ctrl_w ); + void zoom_draw(bitmap_ind16 &bitmap,const rectangle &cliprect,int flags,UINT32 priority); + void wraparound_enable(int status); + +protected: + // device-level overrides + virtual void device_config_complete(); + virtual void device_start(); + virtual void device_reset(); +private: + // internal state + UINT8 *m_ram; + tilemap_t *m_tmap; + UINT8 m_ctrlram[16]; + + TILE_GET_INFO_MEMBER(get_tile_info0); + void get_tile_info( tile_data &tileinfo, int tile_index ); +}; + +extern const device_type K051316; + +#define MCFG_K051316_ADD(_tag, _interface) \ + MCFG_DEVICE_ADD(_tag, K051316, 0) \ + MCFG_DEVICE_CONFIG(_interface) + +#endif diff --git a/src/mame/video/k051733.c b/src/mame/video/k051733.c new file mode 100644 index 00000000000..98ab93dcbdc --- /dev/null +++ b/src/mame/video/k051733.c @@ -0,0 +1,205 @@ +/* +Konami 051733 +------ +Sort of a protection device, used for collision detection, and for +arithmetical operations. +It is passed a few parameters, and returns the result. + +Memory map(preliminary): +------------------------ +00-01 W operand 1 +02-03 W operand 2 +04-05 W operand 3 + +00-01 R operand 1 / operand 2 +02-03 R operand 1 % operand 2? +04-05 R sqrt(operand 3<<16) +06 R unknown - return value written to 13? + +06-07 W distance for collision check +08-09 W Y pos of obj1 +0a-0b W X pos of obj1 +0c-0d W Y pos of obj2 +0e-0f W X pos of obj2 +13 W unknown + +07 R collision (0x80 = no, 0x00 = yes) +0a-0b R unknown (chequered flag), might just read back X pos +0e-0f R unknown (chequered flag), might just read back X pos + +Other addresses are unknown or unused. + +Fast Lane: +---------- +$9def: +This routine is called only after a collision. +(R) 0x0006: unknown. Only bits 0-3 are used. + +Blades of Steel: +---------------- +$ac2f: +(R) 0x2f86: unknown. Only uses bit 0. + +$a5de: +writes to 0x2f84-0x2f85, waits a little, and then reads from 0x2f84. + +$7af3: +(R) 0x2f86: unknown. Only uses bit 0. + + +Devastators: +------------ +$6ce8: +reads from 0x0006, and only uses bit 1. +*/ + +#include "emu.h" +#include "k051733.h" +#include "konami_helper.h" + +#define VERBOSE 0 +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) + +const device_type K051733 = &device_creator; + +k051733_device::k051733_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, K051733, "Konami 051733", tag, owner, clock, "k051733", __FILE__), + //m_ram[0x20], + m_rng(0) +{ +} + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void k051733_device::device_config_complete() +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void k051733_device::device_start() +{ + save_item(NAME(m_ram)); + save_item(NAME(m_rng)); +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void k051733_device::device_reset() +{ + int i; + + for (i = 0; i < 0x20; i++) + m_ram[i] = 0; + + m_rng = 0; +} + +/***************************************************************************** + DEVICE HANDLERS +*****************************************************************************/ + +WRITE8_MEMBER( k051733_device::write ) +{ + //logerror("%04x: write %02x to 051733 address %02x\n", space.device().safe_pc(), data, offset); + + m_ram[offset] = data; +} + + +static int k051733_int_sqrt( UINT32 op ) +{ + UINT32 i = 0x8000; + UINT32 step = 0x4000; + + while (step) + { + if (i * i == op) + return i; + else if (i * i > op) + i -= step; + else + i += step; + step >>= 1; + } + return i; +} + +READ8_MEMBER( k051733_device::read ) +{ + int op1 = (m_ram[0x00] << 8) | m_ram[0x01]; + int op2 = (m_ram[0x02] << 8) | m_ram[0x03]; + int op3 = (m_ram[0x04] << 8) | m_ram[0x05]; + + int rad = (m_ram[0x06] << 8) | m_ram[0x07]; + int yobj1c = (m_ram[0x08] << 8) | m_ram[0x09]; + int xobj1c = (m_ram[0x0a] << 8) | m_ram[0x0b]; + int yobj2c = (m_ram[0x0c] << 8) | m_ram[0x0d]; + int xobj2c = (m_ram[0x0e] << 8) | m_ram[0x0f]; + + switch (offset) + { + case 0x00: + if (op2) + return (op1 / op2) >> 8; + else + return 0xff; + case 0x01: + if (op2) + return (op1 / op2) & 0xff; + else + return 0xff; + + /* this is completely unverified */ + case 0x02: + if (op2) + return (op1 % op2) >> 8; + else + return 0xff; + case 0x03: + if (op2) + return (op1 % op2) & 0xff; + else + return 0xff; + + case 0x04: + return k051733_int_sqrt(op3 << 16) >> 8; + + case 0x05: + return k051733_int_sqrt(op3 << 16) & 0xff; + + case 0x06: + m_rng += m_ram[0x13]; + return m_rng; //RNG read, used by Chequered Flag for differentiate cars, implementation is a raw guess + + case 0x07:{ /* note: Chequered Flag definitely wants all these bits to be enabled */ + if (xobj1c + rad < xobj2c) + return 0xff; + + if (xobj2c + rad < xobj1c) + return 0xff; + + if (yobj1c + rad < yobj2c) + return 0xff; + + if (yobj2c + rad < yobj1c) + return 0xff; + + return 0; + } + case 0x0e: /* best guess */ + return (xobj2c - xobj1c) >> 8; + case 0x0f: + return (xobj2c - xobj1c) & 0xff; + default: + return m_ram[offset]; + } +} diff --git a/src/mame/video/k051733.h b/src/mame/video/k051733.h new file mode 100644 index 00000000000..218edd3980a --- /dev/null +++ b/src/mame/video/k051733.h @@ -0,0 +1,30 @@ +#pragma once +#ifndef __K051733_H__ +#define __K051733_H__ + +class k051733_device : public device_t +{ +public: + k051733_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + ~k051733_device() {} + + DECLARE_WRITE8_MEMBER( write ); + DECLARE_READ8_MEMBER( read ); + +protected: + // device-level overrides + virtual void device_config_complete(); + virtual void device_start(); + virtual void device_reset(); +private: + // internal state + UINT8 m_ram[0x20]; + UINT8 m_rng; +}; + +extern const device_type K051733; + +#define MCFG_K051733_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, K051733, 0) + +#endif diff --git a/src/mame/video/k051960.h b/src/mame/video/k051960.h new file mode 100644 index 00000000000..a5e96f7c71d --- /dev/null +++ b/src/mame/video/k051960.h @@ -0,0 +1,80 @@ +#pragma once +#ifndef __K051960_H__ +#define __K051960_H__ + +typedef void (*k051960_callback)(running_machine &machine, int *code, int *color, int *priority, int *shadow); + +struct k051960_interface +{ + const char *m_gfx_memory_region; + int m_gfx_num; + int m_plane_order; + int m_deinterleave; + k051960_callback m_callback; +}; + +class k051960_device : public device_t, + public k051960_interface +{ +public: + k051960_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + ~k051960_device() {} + + /* + The callback is passed: + - code (range 00-1FFF, output of the pins CA5-CA17) + - color (range 00-FF, output of the pins OC0-OC7). Note that most of the + time COL7 seems to be "shadow", but not always (e.g. Aliens). + The callback must put: + - in code the resulting sprite number + - in color the resulting color index + - if necessary, in priority the priority of the sprite wrt tilemaps + - if necessary, alter shadow to indicate whether the sprite has shadows enabled. + shadow is preloaded with color & 0x80 so it doesn't need to be changed unless + the game has special treatment (Aliens) + */ + + DECLARE_READ8_MEMBER( k051960_r ); + DECLARE_WRITE8_MEMBER( k051960_w ); + DECLARE_READ16_MEMBER( k051960_word_r ); + DECLARE_WRITE16_MEMBER( k051960_word_w ); + + DECLARE_READ8_MEMBER( k051937_r ); + DECLARE_WRITE8_MEMBER( k051937_w ); + DECLARE_READ16_MEMBER( k051937_word_r ); + DECLARE_WRITE16_MEMBER( k051937_word_w ); + + void k051960_sprites_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int min_priority, int max_priority); + int k051960_is_irq_enabled(); + int k051960_is_nmi_enabled(); + void k051960_set_sprite_offsets(int dx, int dy); + +protected: + // device-level overrides + virtual void device_config_complete(); + virtual void device_start(); + virtual void device_reset(); +private: + // internal state + UINT8 *m_ram; + + gfx_element *m_gfx; + + UINT8 m_spriterombank[3]; + int m_dx, m_dy; + int m_romoffset; + int m_spriteflip, m_readroms; + int m_irq_enabled, m_nmi_enabled; + + int m_k051937_counter; + + int k051960_fetchromdata( int byte ); +}; + +extern const device_type K051960; + +#define MCFG_K051960_ADD(_tag, _interface) \ + MCFG_DEVICE_ADD(_tag, K051960, 0) \ + MCFG_DEVICE_CONFIG(_interface) + +#endif diff --git a/src/mame/video/k052109.c b/src/mame/video/k052109.c new file mode 100644 index 00000000000..3e1ab35e161 --- /dev/null +++ b/src/mame/video/k052109.c @@ -0,0 +1,751 @@ +/* +Konami 052109/051962 +------------- +These work in pair. +The 052109 manages 3 64x32 scrolling tilemaps with 8x8 characters, and +optionally generates timing clocks and interrupt signals. It uses 0x4000 +bytes of RAM, and a variable amount of ROM. It cannot read the ROMs: +instead, it exports 21 bits (16 from the tilemap RAM + 3 for the character +raster line + 2 additional ones for ROM banking) and these are externally +used to generate the address of the required data on the ROM; the output of +the ROMs is sent to the 051962, along with a color code. In theory you could +have any combination of bits in the tilemap RAM, as long as they add to 16. +In practice, all the games supported so far standardize on the same format +which uses 3 bits for the color code and 13 bits for the character code. +The 051962 multiplexes the data of the three layers and converts it into +palette indexes and transparency bits which will be mixed later in the video +chain. +Priority is handled externally: these chips only generate the tilemaps, they +don't mix them. +Both chips are interfaced with the main CPU. When the RMRD pin is asserted, +the CPU can read the gfx ROM data. This is done by telling the 052109 which +dword to read (this is a combination of some banking registers, and the CPU +address lines), and then reading it from the 051962. + +052109 inputs: +- address lines (AB0-AB15, AB13-AB15 seem to have a different function) +- data lines (DB0-DB7) +- misc interface stuff + +052109 outputs: +- address lines for the private RAM (RA0-RA12) +- data lines for the private RAM (VD0-VD15) +- NMI, IRQ, FIRQ for the main CPU +- misc interface stuff +- ROM bank selector (CAB1-CAB2) +- character "code" (VC0-VC10) +- character "color" (COL0-COL7); used foc color but also bank switching and tile + flipping. Exact meaning depends on externl connections. All evidence indicates + that COL2 and COL3 select the tile bank, and are replaced with the low 2 bits + from the bank register. The top 2 bits of the register go to CAB1-CAB2. + However, this DOES NOT WORK with Gradius III. "color" seems to pass through + unaltered. +- layer A horizontal scroll (ZA1H-ZA4H) +- layer B horizontal scroll (ZB1H-ZB4H) +- ????? (BEN) + +051962 inputs: +- gfx data from the ROMs (VC0-VC31) +- color code (COL0-COL7); only COL4-COL7 seem to really be used for color; COL0 + is tile flip X. +- layer A horizontal scroll (ZA1H-ZA4H) +- layer B horizontal scroll (ZB1H-ZB4H) +- let main CPU read the gfx ROMs (RMRD) +- address lines to be used with RMRD (AB0-AB1) +- data lines to be used with RMRD (DB0-DB7) +- ????? (BEN) +- misc interface stuff + +051962 outputs: +- FIX layer palette index (DFI0-DFI7) +- FIX layer transparency (NFIC) +- A layer palette index (DSA0-DSAD); DSAA-DSAD seem to be unused +- A layer transparency (NSAC) +- B layer palette index (DSB0-DSBD); DSBA-DSBD seem to be unused +- B layer transparency (NSBC) +- misc interface stuff + + +052109 memory layout: +0000-07ff: layer FIX tilemap (attributes) +0800-0fff: layer A tilemap (attributes) +1000-1fff: layer B tilemap (attributes) +180c-1833: A y scroll +1a00-1bff: A x scroll +1c00 : ? +1c80 : row/column scroll control + ------xx layer A row scroll + 00 = disabled + 01 = disabled? (gradius3, vendetta) + 10 = 32 lines + 11 = 256 lines + -----x-- layer A column scroll + 0 = disabled + 1 = 64 (actually 40) columns + ---xx--- layer B row scroll + --x----- layer B column scroll + surpratk sets this register to 70 during the second boss. There is + nothing obviously wrong so it's not clear what should happen. + glfgreat sets it to 30 when showing the leader board +1d00 : bits 0 & 1 might enable NMI and FIRQ, not sure + : bit 2 = IRQ enable +1d80 : ROM bank selector bits 0-3 = bank 0 bits 4-7 = bank 1 +1e00 : ROM membank selector for ROM testing +1e80 : bit 0 = flip screen (applies to tilemaps only, not sprites) + : bit 1 = set by crimfght, mainevt, surpratk, xmen, mia, punkshot, thndrx2, spy + : it seems to enable tile flip X, however flip X is handled by the + : 051962 and it is not hardwired to a specific tile attribute. + : Note that xmen, punkshot and thndrx2 set the bit but the current + : drivers don't use flip X and seem to work fine. + : bit 2 = enables tile flip Y when bit 1 of the tile attribute is set +1f00 : ROM bank selector bits 0-3 = bank 2 bits 4-7 = bank 3 +2000-27ff: layer FIX tilemap (code) +2800-2fff: layer A tilemap (code) +3000-37ff: layer B tilemap (code) +3800-3807: nothing here, so the chip can share address space with a 051937 +380c-3833: B y scroll +3a00-3bff: B x scroll +3c00-3fff: nothing here, so the chip can share address space with a 051960 +3d80 : mirror of 1d80, but ONLY during ROM test (surpratk) +3e00 : mirror of 1e00, but ONLY during ROM test (surpratk) +3f00 : mirror of 1f00, but ONLY during ROM test (surpratk) +EXTRA ADDRESSING SPACE USED BY X-MEN: +4000-47ff: layer FIX tilemap (code high bits) +4800-4fff: layer A tilemap (code high bits) +5000-57ff: layer B tilemap (code high bits) + +The main CPU doesn't have direct acces to the RAM used by the 052109, it has +to through the chip. +*/ + +#include "emu.h" +#include "k052109.h" +#include "konami_helper.h" + +#define VERBOSE 0 +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) + +#define XOR(a) WORD_XOR_BE(a) + +const device_type K052109 = &device_creator; + +k052109_device::k052109_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, K052109, "Konami 052109", tag, owner, clock, "k052109", __FILE__), + m_ram(NULL), + m_videoram_F(NULL), + m_videoram_A(NULL), + m_videoram_B(NULL), + m_videoram2_F(NULL), + m_videoram2_A(NULL), + m_videoram2_B(NULL), + m_colorram_F(NULL), + m_colorram_A(NULL), + m_colorram_B(NULL), + + //m_tilemap[3], + m_tileflip_enable(0), + //m_charrombank[4], + //m_charrombank_2[4], + m_has_extra_video_ram(0), + m_rmrd_line(0), + m_irq_enabled(0), + //m_dx[3], m_dy[3], + m_romsubbank(0), + m_scrollctrl(0) +{ +} + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void k052109_device::device_config_complete() +{ + // inherit a copy of the static data + const k052109_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + m_gfx_memory_region = ""; + m_gfx_num = 0; + m_plane_order = 0; + m_deinterleave = 0; + m_callback = NULL; + } +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void k052109_device::device_start() +{ + UINT32 total; + static const gfx_layout charlayout = + { + 8,8, + 0, + 4, + { 24, 16, 8, 0 }, + { 0, 1, 2, 3, 4, 5, 6, 7 }, + { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 }, + 32*8 + }; + static const gfx_layout charlayout_gradius3 = + { + 8,8, + 0, + 4, + { 0, 1, 2, 3 }, + { XOR(0)*4, XOR(1)*4, XOR(2)*4, XOR(3)*4, XOR(4)*4, XOR(5)*4, XOR(6)*4, XOR(7)*4 }, + { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 }, + 32*8 + }; + + + /* decode the graphics */ + switch (m_plane_order) + { + case NORMAL_PLANE_ORDER: + total = machine().root_device().memregion(m_gfx_memory_region)->bytes() / 32; + konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region)->base(), total, &charlayout, 4); + break; + + case GRADIUS3_PLANE_ORDER: + total = 0x1000; + konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region)->base(), total, &charlayout_gradius3, 4); + break; + + default: + fatalerror("Unsupported plane_order\n"); + } + + /* deinterleave the graphics, if needed */ + konami_deinterleave_gfx(machine(), m_gfx_memory_region, m_deinterleave); + + m_tilemap[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k052109_device::get_tile_info0),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); + m_tilemap[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k052109_device::get_tile_info1),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); + m_tilemap[2] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k052109_device::get_tile_info2),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); + + m_ram = auto_alloc_array_clear(machine(), UINT8, 0x6000); + + m_colorram_F = &m_ram[0x0000]; + m_colorram_A = &m_ram[0x0800]; + m_colorram_B = &m_ram[0x1000]; + m_videoram_F = &m_ram[0x2000]; + m_videoram_A = &m_ram[0x2800]; + m_videoram_B = &m_ram[0x3000]; + m_videoram2_F = &m_ram[0x4000]; + m_videoram2_A = &m_ram[0x4800]; + m_videoram2_B = &m_ram[0x5000]; + + m_tilemap[0]->set_transparent_pen(0); + m_tilemap[1]->set_transparent_pen(0); + m_tilemap[2]->set_transparent_pen(0); + + save_pointer(NAME(m_ram), 0x6000); + save_item(NAME(m_rmrd_line)); + save_item(NAME(m_romsubbank)); + save_item(NAME(m_scrollctrl)); + save_item(NAME(m_irq_enabled)); + save_item(NAME(m_charrombank)); + save_item(NAME(m_charrombank_2)); + save_item(NAME(m_dx)); + save_item(NAME(m_dy)); + save_item(NAME(m_has_extra_video_ram)); + machine().save().register_postload(save_prepost_delegate(FUNC(k052109_device::tileflip_reset), this)); +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void k052109_device::device_reset() +{ + int i; + + m_rmrd_line = CLEAR_LINE; + m_irq_enabled = 0; + m_romsubbank = 0; + m_scrollctrl = 0; + + m_has_extra_video_ram = 0; + + for (i = 0; i < 3; i++) + m_dx[i] = m_dy[i] = 0; + + for (i = 0; i < 4; i++) + { + m_charrombank[i] = 0; + m_charrombank_2[i] = 0; + } +} + +/***************************************************************************** + DEVICE HANDLERS +*****************************************************************************/ + +READ8_MEMBER( k052109_device::read ) +{ + if (m_rmrd_line == CLEAR_LINE) + { + if ((offset & 0x1fff) >= 0x1800) + { + if (offset >= 0x180c && offset < 0x1834) + { /* A y scroll */ } + else if (offset >= 0x1a00 && offset < 0x1c00) + { /* A x scroll */ } + else if (offset == 0x1d00) + { /* read for bitwise operations before writing */ } + else if (offset >= 0x380c && offset < 0x3834) + { /* B y scroll */ } + else if (offset >= 0x3a00 && offset < 0x3c00) + { /* B x scroll */ } +// else +//logerror("%04x: read from unknown 052109 address %04x\n",space.device().safe_pc(),offset); + } + + return m_ram[offset]; + } + else /* Punk Shot and TMNT read from 0000-1fff, Aliens from 2000-3fff */ + { + int code = (offset & 0x1fff) >> 5; + int color = m_romsubbank; + int flags = 0; + int priority = 0; + int bank = m_charrombank[(color & 0x0c) >> 2] >> 2; /* discard low bits (TMNT) */ + int addr; + + bank |= (m_charrombank_2[(color & 0x0c) >> 2] >> 2); // Surprise Attack uses this 2nd bank in the rom test + + if (m_has_extra_video_ram) + code |= color << 8; /* kludge for X-Men */ + else + m_callback(space.machine(), 0, bank, &code, &color, &flags, &priority); + + addr = (code << 5) + (offset & 0x1f); + addr &= space.machine().root_device().memregion(m_gfx_memory_region)->bytes() - 1; + +// logerror("%04x: off = %04x sub = %02x (bnk = %x) adr = %06x\n", space.device().safe_pc(), offset, m_romsubbank, bank, addr); + + return space.machine().root_device().memregion(m_gfx_memory_region)->base()[addr]; + } +} + +WRITE8_MEMBER( k052109_device::write ) +{ + if ((offset & 0x1fff) < 0x1800) /* tilemap RAM */ + { + if (offset >= 0x4000) + m_has_extra_video_ram = 1; /* kludge for X-Men */ + + m_ram[offset] = data; + m_tilemap[(offset & 0x1800) >> 11]->mark_tile_dirty(offset & 0x7ff); + } + else /* control registers */ + { + m_ram[offset] = data; + + if (offset >= 0x180c && offset < 0x1834) + { /* A y scroll */ } + else if (offset >= 0x1a00 && offset < 0x1c00) + { /* A x scroll */ } + else if (offset == 0x1c80) + { + if (m_scrollctrl != data) + { +//popmessage("scrollcontrol = %02x", data); +//logerror("%04x: rowscrollcontrol = %02x\n", space.device().safe_pc(), data); + m_scrollctrl = data; + } + } + else if (offset == 0x1d00) + { +//logerror("%04x: 052109 register 1d00 = %02x\n", space.device().safe_pc(), data); + /* bit 2 = irq enable */ + /* the custom chip can also generate NMI and FIRQ, for use with a 6809 */ + m_irq_enabled = data & 0x04; + } + else if (offset == 0x1d80) + { + int dirty = 0; + + if (m_charrombank[0] != (data & 0x0f)) + dirty |= 1; + if (m_charrombank[1] != ((data >> 4) & 0x0f)) + dirty |= 2; + + if (dirty) + { + int i; + + m_charrombank[0] = data & 0x0f; + m_charrombank[1] = (data >> 4) & 0x0f; + + for (i = 0; i < 0x1800; i++) + { + int bank = (m_ram[i]&0x0c) >> 2; + if ((bank == 0 && (dirty & 1)) || (bank == 1 && (dirty & 2))) + { + m_tilemap[(i & 0x1800) >> 11]->mark_tile_dirty(i & 0x7ff); + } + } + } + } + else if (offset == 0x1e00 || offset == 0x3e00) // Surprise Attack uses offset 0x3e00 + { +//logerror("%04x: 052109 register 1e00 = %02x\n",space.device().safe_pc(),data); + m_romsubbank = data; + } + else if (offset == 0x1e80) + { +//if ((data & 0xfe)) logerror("%04x: 052109 register 1e80 = %02x\n",space.device().safe_pc(),data); + m_tilemap[0]->set_flip((data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + m_tilemap[1]->set_flip((data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + m_tilemap[2]->set_flip((data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + if (m_tileflip_enable != ((data & 0x06) >> 1)) + { + m_tileflip_enable = ((data & 0x06) >> 1); + + m_tilemap[0]->mark_all_dirty(); + m_tilemap[1]->mark_all_dirty(); + m_tilemap[2]->mark_all_dirty(); + } + } + else if (offset == 0x1f00) + { + int dirty = 0; + + if (m_charrombank[2] != (data & 0x0f)) + dirty |= 1; + + if (m_charrombank[3] != ((data >> 4) & 0x0f)) + dirty |= 2; + + if (dirty) + { + int i; + + m_charrombank[2] = data & 0x0f; + m_charrombank[3] = (data >> 4) & 0x0f; + + for (i = 0; i < 0x1800; i++) + { + int bank = (m_ram[i] & 0x0c) >> 2; + if ((bank == 2 && (dirty & 1)) || (bank == 3 && (dirty & 2))) + m_tilemap[(i & 0x1800) >> 11]->mark_tile_dirty(i & 0x7ff); + } + } + } + else if (offset >= 0x380c && offset < 0x3834) + { /* B y scroll */ } + else if (offset >= 0x3a00 && offset < 0x3c00) + { /* B x scroll */ } + else if (offset == 0x3d80) // Surprise Attack uses offset 0x3d80 in rom test + { + // mirroring this write, breaks Surprise Attack in game tilemaps + m_charrombank_2[0] = data & 0x0f; + m_charrombank_2[1] = (data >> 4) & 0x0f; + } + else if (offset == 0x3f00) // Surprise Attack uses offset 0x3f00 in rom test + { + // mirroring this write, breaks Surprise Attack in game tilemaps + m_charrombank_2[2] = data & 0x0f; + m_charrombank_2[3] = (data >> 4) & 0x0f; + } +// else +// logerror("%04x: write %02x to unknown 052109 address %04x\n",space.device().safe_pc(),data,offset); + } +} + +READ16_MEMBER( k052109_device::word_r ) +{ + return read(space, offset + 0x2000) | (read(space, offset) << 8); +} + +WRITE16_MEMBER( k052109_device::word_w ) +{ + if (ACCESSING_BITS_8_15) + write(space, offset, (data >> 8) & 0xff); + if (ACCESSING_BITS_0_7) + write(space, offset + 0x2000, data & 0xff); +} + +READ16_MEMBER( k052109_device::lsb_r ) +{ + return read(space, offset); +} + +WRITE16_MEMBER( k052109_device::lsb_w ) +{ + if(ACCESSING_BITS_0_7) + write(space, offset, data & 0xff); +} + +void k052109_device::set_rmrd_line( int state ) +{ + m_rmrd_line = state; +} + +int k052109_device::get_rmrd_line( ) +{ + return m_rmrd_line; +} + + +void k052109_device::tilemap_mark_dirty( int tmap_num ) +{ + m_tilemap[tmap_num]->mark_all_dirty(); +} + + +void k052109_device::tilemap_update( ) +{ + int xscroll, yscroll, offs; + +#if 0 +{ +popmessage("%x %x %x %x", + m_charrombank[0], + m_charrombank[1], + m_charrombank[2], + m_charrombank[3]); +} +#endif + + if ((m_scrollctrl & 0x03) == 0x02) + { + UINT8 *scrollram = &m_ram[0x1a00]; + + m_tilemap[1]->set_scroll_rows(256); + m_tilemap[1]->set_scroll_cols(1); + yscroll = m_ram[0x180c]; + m_tilemap[1]->set_scrolly(0, yscroll + m_dy[1]); + for (offs = 0; offs < 256; offs++) + { + xscroll = scrollram[2 * (offs & 0xfff8) + 0] + 256 * scrollram[2 * (offs & 0xfff8) + 1]; + xscroll -= 6; + m_tilemap[1]->set_scrollx((offs + yscroll) & 0xff, xscroll + m_dx[1]); + } + } + else if ((m_scrollctrl & 0x03) == 0x03) + { + UINT8 *scrollram = &m_ram[0x1a00]; + + m_tilemap[1]->set_scroll_rows(256); + m_tilemap[1]->set_scroll_cols(1); + yscroll = m_ram[0x180c]; + m_tilemap[1]->set_scrolly(0, yscroll + m_dy[1]); + for (offs = 0; offs < 256; offs++) + { + xscroll = scrollram[2 * offs + 0] + 256 * scrollram[2 * offs + 1]; + xscroll -= 6; + m_tilemap[1]->set_scrollx((offs + yscroll) & 0xff, xscroll + m_dx[1]); + } + } + else if ((m_scrollctrl & 0x04) == 0x04) + { + UINT8 *scrollram = &m_ram[0x1800]; + + m_tilemap[1]->set_scroll_rows(1); + m_tilemap[1]->set_scroll_cols(512); + xscroll = m_ram[0x1a00] + 256 * m_ram[0x1a01]; + xscroll -= 6; + m_tilemap[1]->set_scrollx(0, xscroll + m_dx[1]); + for (offs = 0; offs < 512; offs++) + { + yscroll = scrollram[offs / 8]; + m_tilemap[1]->set_scrolly((offs + xscroll) & 0x1ff, yscroll + m_dy[1]); + } + } + else + { + UINT8 *scrollram = &m_ram[0x1a00]; + + m_tilemap[1]->set_scroll_rows(1); + m_tilemap[1]->set_scroll_cols(1); + xscroll = scrollram[0] + 256 * scrollram[1]; + xscroll -= 6; + yscroll = m_ram[0x180c]; + m_tilemap[1]->set_scrollx(0, xscroll + m_dx[1]); + m_tilemap[1]->set_scrolly(0, yscroll + m_dy[1]); + } + + if ((m_scrollctrl & 0x18) == 0x10) + { + UINT8 *scrollram = &m_ram[0x3a00]; + + m_tilemap[2]->set_scroll_rows(256); + m_tilemap[2]->set_scroll_cols(1); + yscroll = m_ram[0x380c]; + m_tilemap[2]->set_scrolly(0, yscroll + m_dy[2]); + for (offs = 0; offs < 256; offs++) + { + xscroll = scrollram[2 * (offs & 0xfff8) + 0] + 256 * scrollram[2 * (offs & 0xfff8) + 1]; + xscroll -= 6; + m_tilemap[2]->set_scrollx((offs + yscroll) & 0xff, xscroll + m_dx[2]); + } + } + else if ((m_scrollctrl & 0x18) == 0x18) + { + UINT8 *scrollram = &m_ram[0x3a00]; + + m_tilemap[2]->set_scroll_rows(256); + m_tilemap[2]->set_scroll_cols(1); + yscroll = m_ram[0x380c]; + m_tilemap[2]->set_scrolly(0, yscroll + m_dy[2]); + for (offs = 0; offs < 256; offs++) + { + xscroll = scrollram[2 * offs + 0] + 256 * scrollram[2 * offs + 1]; + xscroll -= 6; + m_tilemap[2]->set_scrollx((offs + yscroll) & 0xff, xscroll + m_dx[2]); + } + } + else if ((m_scrollctrl & 0x20) == 0x20) + { + UINT8 *scrollram = &m_ram[0x3800]; + + m_tilemap[2]->set_scroll_rows(1); + m_tilemap[2]->set_scroll_cols(512); + xscroll = m_ram[0x3a00] + 256 * m_ram[0x3a01]; + xscroll -= 6; + m_tilemap[2]->set_scrollx(0, xscroll + m_dx[2]); + for (offs = 0; offs < 512; offs++) + { + yscroll = scrollram[offs / 8]; + m_tilemap[2]->set_scrolly((offs + xscroll) & 0x1ff, yscroll + m_dy[2]); + } + } + else + { + UINT8 *scrollram = &m_ram[0x3a00]; + + m_tilemap[2]->set_scroll_rows(1); + m_tilemap[2]->set_scroll_cols(1); + xscroll = scrollram[0] + 256 * scrollram[1]; + xscroll -= 6; + yscroll = m_ram[0x380c]; + m_tilemap[2]->set_scrollx(0, xscroll + m_dx[2]); + m_tilemap[2]->set_scrolly(0, yscroll + m_dy[2]); + } + +#if 0 +if ((m_scrollctrl & 0x03) == 0x01 || + (m_scrollctrl & 0x18) == 0x08 || + ((m_scrollctrl & 0x04) && (m_scrollctrl & 0x03)) || + ((m_scrollctrl & 0x20) && (m_scrollctrl & 0x18)) || + (m_scrollctrl & 0xc0) != 0) + popmessage("scrollcontrol = %02x", m_scrollctrl); + +if (machine().input().code_pressed(KEYCODE_F)) +{ + FILE *fp; + fp=fopen("TILE.DMP", "w+b"); + if (fp) + { + fwrite(m_ram, 0x6000, 1, fp); + popmessage("saved"); + fclose(fp); + } +} +#endif +} + +void k052109_device::tilemap_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, int tmap_num, UINT32 flags, UINT8 priority ) +{ + m_tilemap[tmap_num]->draw(bitmap, cliprect, flags, priority); +} + +int k052109_device::is_irq_enabled( ) +{ + return m_irq_enabled; +} + +void k052109_device::set_layer_offsets( int layer, int dx, int dy ) +{ + m_dx[layer] = dx; + m_dy[layer] = dy; +} + + +/*************************************************************************** + + Callbacks for the TileMap code + +***************************************************************************/ + +/* + data format: + video RAM xxxxxxxx tile number (low 8 bits) + color RAM xxxx---- depends on external connections (usually color and banking) + color RAM ----xx-- bank select (0-3): these bits are replaced with the 2 + bottom bits of the bank register before being placed on + the output pins. The other two bits of the bank register are + placed on the CAB1 and CAB2 output pins. + color RAM ------xx depends on external connections (usually banking, flip) +*/ + +void k052109_device::get_tile_info( tile_data &tileinfo, int tile_index, int layer, UINT8 *cram, UINT8 *vram1, UINT8 *vram2 ) +{ + int flipy = 0; + int code = vram1[tile_index] + 256 * vram2[tile_index]; + int color = cram[tile_index]; + int flags = 0; + int priority = 0; + int bank = m_charrombank[(color & 0x0c) >> 2]; + if (m_has_extra_video_ram) + bank = (color & 0x0c) >> 2; /* kludge for X-Men */ + + color = (color & 0xf3) | ((bank & 0x03) << 2); + bank >>= 2; + + flipy = color & 0x02; + + m_callback(machine(), layer, bank, &code, &color, &flags, &priority); + + /* if the callback set flip X but it is not enabled, turn it off */ + if (!(m_tileflip_enable & 1)) + flags &= ~TILE_FLIPX; + + /* if flip Y is enabled and the attribute but is set, turn it on */ + if (flipy && (m_tileflip_enable & 2)) + flags |= TILE_FLIPY; + + SET_TILE_INFO_MEMBER( + m_gfx_num, + code, + color, + flags); + + tileinfo.category = priority; +} + +TILE_GET_INFO_MEMBER(k052109_device::get_tile_info0) +{ + get_tile_info(tileinfo, tile_index, 0, m_colorram_F, m_videoram_F, m_videoram2_F); +} + +TILE_GET_INFO_MEMBER(k052109_device::get_tile_info1) +{ + get_tile_info(tileinfo, tile_index, 1, m_colorram_A, m_videoram_A, m_videoram2_A); +} + +TILE_GET_INFO_MEMBER(k052109_device::get_tile_info2) +{ + get_tile_info(tileinfo, tile_index, 2, m_colorram_B, m_videoram_B, m_videoram2_B); +} + + +void k052109_device::tileflip_reset() +{ + int data = m_ram[0x1e80]; + m_tilemap[0]->set_flip((data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + m_tilemap[1]->set_flip((data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + m_tilemap[2]->set_flip((data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + m_tileflip_enable = ((data & 0x06) >> 1); +} diff --git a/src/mame/video/k052109.h b/src/mame/video/k052109.h new file mode 100644 index 00000000000..33d2cdf59ad --- /dev/null +++ b/src/mame/video/k052109.h @@ -0,0 +1,104 @@ +#pragma once +#ifndef __K052109_H__ +#define __K052109_H__ + + +typedef void (*k052109_callback)(running_machine &machine, int layer, int bank, int *code, int *color, int *flags, int *priority); + +struct k052109_interface +{ + const char *m_gfx_memory_region; + int m_gfx_num; + int m_plane_order; + int m_deinterleave; + k052109_callback m_callback; +}; + +class k052109_device : public device_t, + public k052109_interface +{ +public: + k052109_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + ~k052109_device() {} + + /* + You don't have to decode the graphics: the vh_start() routines will do that + for you, using the plane order passed. + Of course the ROM data must be in the correct order. This is a way to ensure + that the ROM test will pass. + The konami_rom_deinterleave() function in konami_helper.h will do the reorganization for + you in most cases (but see tmnt.c for additional bit rotations or byte + permutations which may be required). + + The callback is passed: + - layer number (0 = FIX, 1 = A, 2 = B) + - bank (range 0-3, output of the pins CAB1 and CAB2) + - code (range 00-FF, output of the pins VC3-VC10) + NOTE: code is in the range 0000-FFFF for X-Men, which uses extra RAM + - color (range 00-FF, output of the pins COL0-COL7) + The callback must put: + - in code the resulting tile number + - in color the resulting color index + - if necessary, put flags and/or priority for the TileMap code in the tile_info + structure (e.g. TILE_FLIPX). Note that TILE_FLIPY is handled internally by the + chip so it must not be set by the callback. + */ + + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); + DECLARE_READ16_MEMBER( word_r ); + DECLARE_WRITE16_MEMBER( word_w ); + DECLARE_READ16_MEMBER( lsb_r ); + DECLARE_WRITE16_MEMBER( lsb_w ); + + void set_rmrd_line(int state); + int get_rmrd_line(); + void tilemap_update(); + int is_irq_enabled(); + void set_layer_offsets(int layer, int dx, int dy); + void tilemap_mark_dirty(int tmap_num); + void tilemap_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int tmap_num, UINT32 flags, UINT8 priority); + +protected: + // device-level overrides + virtual void device_config_complete(); + virtual void device_start(); + virtual void device_reset(); +private: + // internal state + UINT8 *m_ram; + UINT8 *m_videoram_F; + UINT8 *m_videoram_A; + UINT8 *m_videoram_B; + UINT8 *m_videoram2_F; + UINT8 *m_videoram2_A; + UINT8 *m_videoram2_B; + UINT8 *m_colorram_F; + UINT8 *m_colorram_A; + UINT8 *m_colorram_B; + + tilemap_t *m_tilemap[3]; + int m_tileflip_enable; + UINT8 m_charrombank[4]; + UINT8 m_charrombank_2[4]; + UINT8 m_has_extra_video_ram; + INT32 m_rmrd_line; + UINT8 m_irq_enabled; + INT32 m_dx[3], m_dy[3]; + UINT8 m_romsubbank, m_scrollctrl; + + TILE_GET_INFO_MEMBER(get_tile_info0); + TILE_GET_INFO_MEMBER(get_tile_info1); + TILE_GET_INFO_MEMBER(get_tile_info2); + + void get_tile_info( tile_data &tileinfo, int tile_index, int layer, UINT8 *cram, UINT8 *vram1, UINT8 *vram2 ); + void tileflip_reset(); +}; + +extern const device_type K052109; + +#define MCFG_K052109_ADD(_tag, _interface) \ + MCFG_DEVICE_ADD(_tag, K052109, 0) \ + MCFG_DEVICE_CONFIG(_interface) + +#endif diff --git a/src/mame/video/k05324x.h b/src/mame/video/k05324x.h index 291888029c9..38d3b4d88d5 100644 --- a/src/mame/video/k05324x.h +++ b/src/mame/video/k05324x.h @@ -218,7 +218,25 @@ int K053246_read_register(int regnum); +#define MCFG_K053244_ADD(_tag, _interface) \ + MCFG_DEVICE_ADD(_tag, K053244, 0) \ + MCFG_DEVICE_CONFIG(_interface) +#define MCFG_K053245_ADD(_tag, _interface) \ + MCFG_DEVICE_ADD(_tag, K053245, 0) \ + MCFG_DEVICE_CONFIG(_interface) + +#define MCFG_K053246_ADD(_tag, _interface) \ + MCFG_DEVICE_ADD(_tag, K053246, 0) \ + MCFG_DEVICE_CONFIG(_interface) + +#define MCFG_K053247_ADD(_tag, _interface) \ + MCFG_DEVICE_ADD(_tag, K053247, 0) \ + MCFG_DEVICE_CONFIG(_interface) + +#define MCFG_K055673_ADD(_tag, _interface) \ + MCFG_DEVICE_ADD(_tag, K055673, 0) \ + MCFG_DEVICE_CONFIG(_interface) #endif diff --git a/src/mame/video/k053251.c b/src/mame/video/k053251.c new file mode 100644 index 00000000000..0021a658d72 --- /dev/null +++ b/src/mame/video/k053251.c @@ -0,0 +1,277 @@ +/* +Konami 053251 +------ +Priority encoder. + +The chip has inputs for 5 layers (CI0-CI4); only 4 are used (CI1-CI4) +CI0-CI2 are 9(=5+4) bits inputs, CI3-CI4 8(=4+4) bits + +The input connctions change from game to game. E.g. in Simpsons, +CI0 = grounded (background color) +CI1 = sprites +CI2 = FIX +CI3 = A +CI4 = B + +in lgtnfght: +CI0 = grounded +CI1 = sprites +CI2 = FIX +CI3 = B +CI4 = A + +there are three 6 bit priority inputs, PR0-PR2 + +simpsons: +PR0 = 111111 +PR1 = xxxxx0 x bits coming from the sprite attributes +PR2 = 111111 + +lgtnfght: +PR0 = 111111 +PR1 = 1xx000 x bits coming from the sprite attributes +PR2 = 111111 + +also two shadow inputs, SDI0 and SDI1 (from the sprite attributes) + +the chip outputs the 11 bit palette index, CO0-CO10, and two shadow bits. + +16 internal registers; registers are 6 bits wide (input is D0-D5) +For the most part, their meaning is unknown +All registers are write only. +There must be a way to enable/disable the three external PR inputs. +Some games initialize the priorities of the sprite & background layers, +others don't. It isn't clear whether the data written to those registers is +actually used, since the priority is taken from the external ports. + + 0 priority of CI0 (higher = lower priority) + punkshot: unused? + lgtnfght: unused? + simpsons: 3f = 111111 + xmen: 05 = 000101 default value + xmen: 09 = 001001 used to swap CI0 and CI2 + 1 priority of CI1 (higher = lower priority) + punkshot: 28 = 101000 + lgtnfght: unused? + simpsons: unused? + xmen: 02 = 000010 + 2 priority of CI2 (higher = lower priority) + punkshot: 24 = 100100 + lgtnfght: 24 = 100100 + simpsons: 04 = 000100 + xmen: 09 = 001001 default value + xmen: 05 = 000101 used to swap CI0 and CI2 + 3 priority of CI3 (higher = lower priority) + punkshot: 34 = 110100 + lgtnfght: 34 = 110100 + simpsons: 28 = 101000 + xmen: 00 = 000000 + 4 priority of CI4 (higher = lower priority) + punkshot: 2c = 101100 default value + punkshot: 3c = 111100 used to swap CI3 and CI4 + punkshot: 26 = 100110 used to swap CI1 and CI4 + lgtnfght: 2c = 101100 + simpsons: 18 = 011000 + xmen: fe = 111110 + 5 unknown + punkshot: unused? + lgtnfght: 2a = 101010 + simpsons: unused? + xmen: unused? + 6 unknown + punkshot: 26 = 100110 + lgtnfght: 30 = 110000 + simpsons: 17 = 010111 + xmen: 03 = 000011 (written after initial tests) + 7 unknown + punkshot: unused? + lgtnfght: unused? + simpsons: 27 = 100111 + xmen: 07 = 000111 (written after initial tests) + 8 unknown + punkshot: unused? + lgtnfght: unused? + simpsons: 37 = 110111 + xmen: ff = 111111 (written after initial tests) + 9 ----xx CI0 palette index base (CO9-CO10) + --xx-- CI1 palette index base (CO9-CO10) + xx---- CI2 palette index base (CO9-CO10) +10 ---xxx CI3 palette index base (CO8-CO10) + xxx--- CI4 palette index base (CO8-CO10) +11 unknown + punkshot: 00 = 000000 + lgtnfght: 00 = 000000 + simpsons: 00 = 000000 + xmen: 00 = 000000 (written after initial tests) +12 unknown + punkshot: 04 = 000100 + lgtnfght: 04 = 000100 + simpsons: 05 = 000101 + xmen: 05 = 000101 +13 unused +14 unused +15 unused + + +*/ + +#include "emu.h" +#include "k053251.h" +#include "konami_helper.h" + +#define VERBOSE 0 +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) + +const device_type K053251 = &device_creator; + +k053251_device::k053251_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, K053251, "Konami 053251", tag, owner, clock, "k053251", __FILE__), + //m_dirty_tmap[5], + //m_ram[16], + m_tilemaps_set(0) + //m_palette_index[5] +{ +} + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void k053251_device::device_config_complete() +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void k053251_device::device_start() +{ + save_item(NAME(m_ram)); + save_item(NAME(m_tilemaps_set)); + save_item(NAME(m_dirty_tmap)); + + machine().save().register_postload(save_prepost_delegate(FUNC(k053251_device::reset_indexes), this)); +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void k053251_device::device_reset() +{ + int i; + + m_tilemaps_set = 0; + + for (i = 0; i < 0x10; i++) + m_ram[i] = 0; + + for (i = 0; i < 5; i++) + m_dirty_tmap[i] = 0; +} + +/***************************************************************************** + DEVICE HANDLERS +*****************************************************************************/ + +WRITE8_MEMBER( k053251_device::write ) +{ + int i, newind; + + data &= 0x3f; + + if (m_ram[offset] != data) + { + m_ram[offset] = data; + if (offset == 9) + { + /* palette base index */ + for (i = 0; i < 3; i++) + { + newind = 32 * ((data >> 2 * i) & 0x03); + if (m_palette_index[i] != newind) + { + m_palette_index[i] = newind; + m_dirty_tmap[i] = 1; + } + } + + if (!m_tilemaps_set) + space.machine().tilemap().mark_all_dirty(); + } + else if (offset == 10) + { + /* palette base index */ + for (i = 0; i < 2; i++) + { + newind = 16 * ((data >> 3 * i) & 0x07); + if (m_palette_index[3 + i] != newind) + { + m_palette_index[3 + i] = newind; + m_dirty_tmap[3 + i] = 1; + } + } + + if (!m_tilemaps_set) + space.machine().tilemap().mark_all_dirty(); + } + } +} + +WRITE16_MEMBER( k053251_device::lsb_w ) +{ + if (ACCESSING_BITS_0_7) + write(space, offset, data & 0xff); +} + +WRITE16_MEMBER( k053251_device::msb_w ) +{ + if (ACCESSING_BITS_8_15) + write(space, offset, (data >> 8) & 0xff); +} + +int k053251_device::get_priority( int ci ) +{ + return m_ram[ci]; +} + +int k053251_device::get_palette_index( int ci ) +{ + return m_palette_index[ci]; +} + +int k053251_device::get_tmap_dirty( int tmap_num ) +{ + assert(tmap_num < 5); + return m_dirty_tmap[tmap_num]; +} + +void k053251_device::set_tmap_dirty( int tmap_num, int data ) +{ + assert(tmap_num < 5); + m_dirty_tmap[tmap_num] = data ? 1 : 0; +} + +void k053251_device::reset_indexes() +{ + m_palette_index[0] = 32 * ((m_ram[9] >> 0) & 0x03); + m_palette_index[1] = 32 * ((m_ram[9] >> 2) & 0x03); + m_palette_index[2] = 32 * ((m_ram[9] >> 4) & 0x03); + m_palette_index[3] = 16 * ((m_ram[10] >> 0) & 0x07); + m_palette_index[4] = 16 * ((m_ram[10] >> 3) & 0x07); +} + +// debug handlers + +READ16_MEMBER( k053251_device::lsb_r ) +{ + return(m_ram[offset]); +} // PCU1 + +READ16_MEMBER( k053251_device::msb_r ) +{ + return(m_ram[offset] << 8); +} // PCU1 diff --git a/src/mame/video/konami_helper.c b/src/mame/video/konami_helper.c index b537cef8209..75bed1e4ccd 100644 --- a/src/mame/video/konami_helper.c +++ b/src/mame/video/konami_helper.c @@ -107,5 +107,64 @@ void konami_deinterleave_gfx(running_machine &machine, const char *gfx_memory_re } } +/* useful function to sort three tile layers by priority order */ +void konami_sortlayers3( int *layer, int *pri ) +{ +#define SWAP(a,b) \ + if (pri[a] < pri[b]) \ + { \ + int t; \ + t = pri[a]; pri[a] = pri[b]; pri[b] = t; \ + t = layer[a]; layer[a] = layer[b]; layer[b] = t; \ + } + SWAP(0,1) + SWAP(0,2) + SWAP(1,2) +#undef SWAP +} + +/* useful function to sort four tile layers by priority order */ +void konami_sortlayers4( int *layer, int *pri ) +{ +#define SWAP(a,b) \ + if (pri[a] <= pri[b]) \ + { \ + int t; \ + t = pri[a]; pri[a] = pri[b]; pri[b] = t; \ + t = layer[a]; layer[a] = layer[b]; layer[b] = t; \ + } + + SWAP(0, 1) + SWAP(0, 2) + SWAP(0, 3) + SWAP(1, 2) + SWAP(1, 3) + SWAP(2, 3) +#undef SWAP +} + +/* useful function to sort five tile layers by priority order */ +void konami_sortlayers5( int *layer, int *pri ) +{ +#define SWAP(a,b) \ + if (pri[a] <= pri[b]) \ + { \ + int t; \ + t = pri[a]; pri[a] = pri[b]; pri[b] = t; \ + t = layer[a]; layer[a] = layer[b]; layer[b] = t; \ + } + + SWAP(0, 1) + SWAP(0, 2) + SWAP(0, 3) + SWAP(0, 4) + SWAP(1, 2) + SWAP(1, 3) + SWAP(1, 4) + SWAP(2, 3) + SWAP(2, 4) + SWAP(3, 4) +#undef SWAP +} diff --git a/src/mame/video/konami_helper.h b/src/mame/video/konami_helper.h index c3f569a6b38..3b599be339b 100644 --- a/src/mame/video/konami_helper.h +++ b/src/mame/video/konami_helper.h @@ -4,6 +4,11 @@ #ifndef __KONAMI_HELPER_H__ #define __KONAMI_HELPER_H__ +#define NORMAL_PLANE_ORDER 0x0123 +#define REVERSE_PLANE_ORDER 0x3210 +#define GRADIUS3_PLANE_ORDER 0x1111 +#define TASMAN_PLANE_ORDER 0x1616 + enum { KONAMI_ROM_DEINTERLEAVE_NONE = 0, @@ -23,4 +28,11 @@ void konamid_rom_deinterleave_4(running_machine &machine, const char *mem_region void konami_decode_gfx(running_machine &machine, int gfx_index, UINT8 *data, UINT32 total, const gfx_layout *layout, int bpp); void konami_deinterleave_gfx(running_machine &machine, const char *gfx_memory_region, int deinterleave); +/* helper function to sort three tile layers by priority order */ +void konami_sortlayers3(int *layer, int *pri); +/* helper function to sort four tile layers by priority order */ +void konami_sortlayers4(int *layer, int *pri); +/* helper function to sort five tile layers by priority order */ +void konami_sortlayers5(int *layer, int *pri); + #endif diff --git a/src/mame/video/konicdev.c b/src/mame/video/konicdev.c index 22660f048e3..06447876c06 100644 --- a/src/mame/video/konicdev.c +++ b/src/mame/video/konicdev.c @@ -268,578 +268,6 @@ control registers ----x--- flip screen - -007121 ------- -This is an interesting beast. It is an evolution of the 005885, with more -features. Many games use two of these in pair. -It manages sprites and two 32x32 tilemaps. The tilemaps can be joined to form -a single 64x32 one, or one of them can be moved to the side of screen, giving -a high score display suitable for vertical games. -The chip also generates clock and interrupt signals suitable for a 6809. -It uses 0x2000 bytes of RAM for the tilemaps and sprites, and an additional -0x100 bytes, maybe for scroll RAM and line buffers. The maximum addressable -ROM is 0x80000 bytes (addressed 16 bits at a time). Tile and sprite data both -come from the same ROM space. -Two 256x4 lookup PROMs are also used to increase the color combinations. -All tilemap / sprite priority handling is done internally and the chip exports -7 bits of color code, composed of 2 bits of palette bank, 1 bit indicating tile -or sprite, and 4 bits of ROM data remapped through the PROM. - -inputs: -- address lines (A0-A13) -- data lines (DB0-DB7) -- misc interface stuff -- data from the gfx ROMs (RDL0-RDL7, RDU0-RDU7) -- data from the tile lookup PROMs (VCD0-VCD3) -- data from the sprite lookup PROMs (OCD0-OCD3) - -outputs: -- address lines for tilemap RAM (AX0-AX12) -- data lines for tilemap RAM (VO0-VO7) -- address lines for the small RAM (FA0-FA7) -- data lines for the small RAM (FD0-FD7) -- address lines for the gfx ROMs (R0-R17) -- address lines for the tile lookup PROMs (VCF0-VCF3, VCB0-VCB3) -- address lines for the sprite lookup PROMs (OCB0-OCB3, OCF0-OCF3) -- NNMI, NIRQ, NFIR, NE, NQ for the main CPU -- misc interface stuff -- color code to be output on screen (COA0-COA6) - - -control registers -000: scroll x (low 8 bits) -001: -------x scroll x (high bit) - ------x- enable rowscroll? (combatsc) - ----x--- this probably selects an alternate screen layout used in combat - school where tilemap #2 is overlayed on front and doesn't scroll. - The 32 lines of the front layer can be individually turned on or - off using the second 32 bytes of scroll RAM. -002: scroll y -003: -------x bit 13 of the tile code - ------x- unknown (contra) - -----x-- might be sprite / tilemap priority (0 = sprites have priority) - (combat school, contra, haunted castle(0/1), labyrunr) - ----x--- selects sprite buffer (and makes a copy to a private buffer?) - ---x---- screen layout selector: - when this is set, 5 columns are added on the left of the screen - (that means 5 rows at the top for vertical games), and the - rightmost 2 columns are chopped away. - Tilemap #2 is used to display the 5 additional columns on the - left. The rest of tilemap #2 is not used and can be used as work - RAM by the program. - The visible area becomes 280x224. - Note that labyrunr changes this at runtime, setting it during - gameplay and resetting it on the title screen and crosshatch. - --x----- might be sprite / tilemap priority (0 = sprites have priority) - (combat school, contra, haunted castle(0/1), labyrunr) - -x------ Chops away the leftmost and rightmost columns, switching the - visible area from 256 to 240 pixels. This is used by combatsc on - the scrolling stages, and by labyrunr on the title screen. - At first I thought that this enabled an extra bank of 0x40 - sprites, needed by combatsc, but labyrunr proves that this is not - the case - x------- unknown (contra) -004: ----xxxx bits 9-12 of the tile code. Only the bits enabled by the following - mask are actually used, and replace the ones selected by register - 005. - xxxx---- mask enabling the above bits -005: selects where in the attribute byte to pick bits 9-12 of the tile code, - output to pins R12-R15. The bit of the attribute byte to use is the - specified bit (0-3) + 3, that is one of bits 3-6. Bit 7 is hardcoded as - bit 8 of the code. Bits 0-2 are used for the color, however note that - some games use bit 3 as well (see below). - ------xx attribute bit to use for tile code bit 9 - ----xx-- attribute bit to use for tile code bit 10 - --xx---- attribute bit to use for tile code bit 11 - xx------ attribute bit to use for tile code bit 12 -006: ----xxxx select additional effect for bits 3-6 of the tile attribute (the - same ones indexed by register 005). Note that an attribute bit - can therefore be used at the same time to be BOTH a tile code bit - and an additional effect. - -------x bit 3 of attribute is bit 3 of color (combatsc, fastlane, flkatck) - ------x- bit 4 of attribute is tile flip X (assumption - no game uses this) - -----x-- bit 5 of attribute is tile flip Y (flkatck) - ----x--- bit 6 of attribute is tile priority over sprites (combatsc, hcastle, - labyrunr) - Note that hcastle sets this bit for layer 0, and bit 6 of the - attribute is also used as bit 12 of the tile code, however that - bit is ALWAYS set throughout the game. - combatsc uses the bit in the "graduation" scene during attract mode, - to place soldiers behind the stand. - Use in labyrunr has not been investigated yet. - --xx---- palette bank (both tiles and sprites, see contra) -007: -------x nmi enable - ------x- irq enable - -----x-- firq enable - ----x--- flip screen - ---x---- unknown (contra, labyrunr) - - - -007342 ------- -The 007342 manages 2 64x32 scrolling tilemaps with 8x8 characters, and -optionally generates timing clocks and interrupt signals. It uses 0x2000 -bytes of RAM, plus 0x0200 bytes for scrolling, and a variable amount of ROM. -It cannot read the ROMs. - -control registers -000: ------x- INT control - ---x---- flip screen (TODO: doesn't work with thehustl) -001: Used for banking in Rock'n'Rage -002: -------x MSB of x scroll 1 - ------x- MSB of x scroll 2 - ---xxx-- layer 1 row/column scroll control - 000 = disabled - 010 = unknown (bladestl shootout between periods) - 011 = 32 columns (Blades of Steel) - 101 = 256 rows (Battlantis, Rock 'n Rage) - x------- enable sprite wraparound from bottom to top (see Blades of Steel - high score table) -003: x scroll 1 -004: y scroll 1 -005: x scroll 2 -006: y scroll 2 -007: not used - - -007420 ------- -Sprite generator. 8 bytes per sprite with zoom. It uses 0x200 bytes of RAM, -and a variable amount of ROM. Nothing is known about its external interface. - - - -052109/051962 -------------- -These work in pair. -The 052109 manages 3 64x32 scrolling tilemaps with 8x8 characters, and -optionally generates timing clocks and interrupt signals. It uses 0x4000 -bytes of RAM, and a variable amount of ROM. It cannot read the ROMs: -instead, it exports 21 bits (16 from the tilemap RAM + 3 for the character -raster line + 2 additional ones for ROM banking) and these are externally -used to generate the address of the required data on the ROM; the output of -the ROMs is sent to the 051962, along with a color code. In theory you could -have any combination of bits in the tilemap RAM, as long as they add to 16. -In practice, all the games supported so far standardize on the same format -which uses 3 bits for the color code and 13 bits for the character code. -The 051962 multiplexes the data of the three layers and converts it into -palette indexes and transparency bits which will be mixed later in the video -chain. -Priority is handled externally: these chips only generate the tilemaps, they -don't mix them. -Both chips are interfaced with the main CPU. When the RMRD pin is asserted, -the CPU can read the gfx ROM data. This is done by telling the 052109 which -dword to read (this is a combination of some banking registers, and the CPU -address lines), and then reading it from the 051962. - -052109 inputs: -- address lines (AB0-AB15, AB13-AB15 seem to have a different function) -- data lines (DB0-DB7) -- misc interface stuff - -052109 outputs: -- address lines for the private RAM (RA0-RA12) -- data lines for the private RAM (VD0-VD15) -- NMI, IRQ, FIRQ for the main CPU -- misc interface stuff -- ROM bank selector (CAB1-CAB2) -- character "code" (VC0-VC10) -- character "color" (COL0-COL7); used foc color but also bank switching and tile - flipping. Exact meaning depends on externl connections. All evidence indicates - that COL2 and COL3 select the tile bank, and are replaced with the low 2 bits - from the bank register. The top 2 bits of the register go to CAB1-CAB2. - However, this DOES NOT WORK with Gradius III. "color" seems to pass through - unaltered. -- layer A horizontal scroll (ZA1H-ZA4H) -- layer B horizontal scroll (ZB1H-ZB4H) -- ????? (BEN) - -051962 inputs: -- gfx data from the ROMs (VC0-VC31) -- color code (COL0-COL7); only COL4-COL7 seem to really be used for color; COL0 - is tile flip X. -- layer A horizontal scroll (ZA1H-ZA4H) -- layer B horizontal scroll (ZB1H-ZB4H) -- let main CPU read the gfx ROMs (RMRD) -- address lines to be used with RMRD (AB0-AB1) -- data lines to be used with RMRD (DB0-DB7) -- ????? (BEN) -- misc interface stuff - -051962 outputs: -- FIX layer palette index (DFI0-DFI7) -- FIX layer transparency (NFIC) -- A layer palette index (DSA0-DSAD); DSAA-DSAD seem to be unused -- A layer transparency (NSAC) -- B layer palette index (DSB0-DSBD); DSBA-DSBD seem to be unused -- B layer transparency (NSBC) -- misc interface stuff - - -052109 memory layout: -0000-07ff: layer FIX tilemap (attributes) -0800-0fff: layer A tilemap (attributes) -1000-1fff: layer B tilemap (attributes) -180c-1833: A y scroll -1a00-1bff: A x scroll -1c00 : ? -1c80 : row/column scroll control - ------xx layer A row scroll - 00 = disabled - 01 = disabled? (gradius3, vendetta) - 10 = 32 lines - 11 = 256 lines - -----x-- layer A column scroll - 0 = disabled - 1 = 64 (actually 40) columns - ---xx--- layer B row scroll - --x----- layer B column scroll - surpratk sets this register to 70 during the second boss. There is - nothing obviously wrong so it's not clear what should happen. - glfgreat sets it to 30 when showing the leader board -1d00 : bits 0 & 1 might enable NMI and FIRQ, not sure - : bit 2 = IRQ enable -1d80 : ROM bank selector bits 0-3 = bank 0 bits 4-7 = bank 1 -1e00 : ROM membank selector for ROM testing -1e80 : bit 0 = flip screen (applies to tilemaps only, not sprites) - : bit 1 = set by crimfght, mainevt, surpratk, xmen, mia, punkshot, thndrx2, spy - : it seems to enable tile flip X, however flip X is handled by the - : 051962 and it is not hardwired to a specific tile attribute. - : Note that xmen, punkshot and thndrx2 set the bit but the current - : drivers don't use flip X and seem to work fine. - : bit 2 = enables tile flip Y when bit 1 of the tile attribute is set -1f00 : ROM bank selector bits 0-3 = bank 2 bits 4-7 = bank 3 -2000-27ff: layer FIX tilemap (code) -2800-2fff: layer A tilemap (code) -3000-37ff: layer B tilemap (code) -3800-3807: nothing here, so the chip can share address space with a 051937 -380c-3833: B y scroll -3a00-3bff: B x scroll -3c00-3fff: nothing here, so the chip can share address space with a 051960 -3d80 : mirror of 1d80, but ONLY during ROM test (surpratk) -3e00 : mirror of 1e00, but ONLY during ROM test (surpratk) -3f00 : mirror of 1f00, but ONLY during ROM test (surpratk) -EXTRA ADDRESSING SPACE USED BY X-MEN: -4000-47ff: layer FIX tilemap (code high bits) -4800-4fff: layer A tilemap (code high bits) -5000-57ff: layer B tilemap (code high bits) - -The main CPU doesn't have direct acces to the RAM used by the 052109, it has -to through the chip. - - - - - - -051960/051937 -------------- -Sprite generators. Designed to work in pair. The 051960 manages the sprite -list and produces and address that is fed to the gfx ROMs. The data from the -ROMs is sent to the 051937, along with color code and other stuff from the -051960. The 051937 outputs up to 12 bits of palette index, plus "shadow" and -transparency information. -Both chips are interfaced to the main CPU, through 8-bit data buses and 11 -bits of address space. The 051937 sits in the range 000-007, while the 051960 -in the range 400-7ff (all RAM). The main CPU can read the gfx ROM data though -the 051937 data bus, while the 051960 provides the address lines. -The 051960 is designed to directly address 1MB of ROM space, since it produces -18 address lines that go to two 16-bit wide ROMs (the 051937 has a 32-bit data -bus to the ROMs). However, the addressing space can be increased by using one -or more of the "color attribute" bits of the sprites as bank selectors. -Moreover a few games store the gfx data in the ROMs in a format different from -the one expected by the 051960, and use external logic to reorder the address -lines. -The 051960 can also genenrate IRQ, FIRQ and NMI signals. - -memory map: -000-007 is for the 051937, but also seen by the 051960 -400-7ff is 051960 only -000 R bit 0 = unknown, looks like a status flag or something - aliens waits for it to be 0 before starting to copy sprite data - thndrx2 needs it to pulse for the startup checks to succeed -000 W bit 0 = irq enable/acknowledge? - bit 2 = nmi enable? - bit 3 = flip screen (applies to sprites only, not tilemaps) - bit 4 = unknown, used by Devastators, TMNT, Aliens, Chequered Flag, maybe others - aliens sets it just after checking bit 0, and before copying - the sprite data - bit 5 = enable gfx ROM reading -001 W Devastators sets bit 1, function unknown. - Ultraman sets the register to 0x0f. - None of the other games I tested seem to set this register to other than 0. -002-003 W selects the portion of the gfx ROMs to be read. -004 W Aliens uses this to select the ROM bank to be read, but Punk Shot - and TMNT don't, they use another bit of the registers above. Many - other games write to this register before testing. - It is possible that bits 2-7 of 003 go to OC0-OC5, and bits 0-1 of - 004 go to OC6-OC7. -004-007 R reads data from the gfx ROMs (32 bits in total). The address of the - data is determined by the register above and by the last address - accessed on the 051960; plus bank switch bits for larger ROMs. - It seems that the data can also be read directly from the 051960 - address space: 88 Games does this. First it reads 004 and discards - the result, then it reads from the 051960 the data at the address - it wants. The normal order is the opposite, read from the 051960 at - the address you want, discard the result, and fetch the data from - 004-007. -400-7ff RW sprite RAM, 8 bytes per sprite - - - -053245/053244 -------------- -Sprite generators. The 053245 has a 16-bit data bus to the main CPU. -The sprites are buffered, a write to 006 activates to copy between the -main ram and the buffer. - -053244 memory map (but the 053245 sees and processes them too): -000-001 W global X offset -002-003 W global Y offset -004 W unknown -005 W bit 0 = flip screen X - bit 1 = flip screen Y - bit 2 = unknown, used by Parodius - bit 4 = enable gfx ROM reading - bit 5 = unknown, used by Rollergames -006 RW accessing this register copies the sprite ram to the internal buffer -007 W unknown -008-009 W low 16 bits of the ROM address to read -00a-00b W high bits of the ROM address to read. 3 bits for most games, 1 for asterix -00c-00f R reads data from the gfx ROMs (32 bits in total). The address of the - data is determined by the registers above; plus bank switch bits for - larger ROMs. - - - -053247/053246 -------------- -Sprite generators. Nothing is known about their external interface. -The sprite RAM format is very similar to the 053245. - -053246 memory map (but the 053247 sees and processes them too): -000-001 W global X offset -002-003 W global Y offset -004 W low 8 bits of the ROM address to read -005 W bit 0 = flip screen X - bit 1 = flip screen Y - bit 2 = unknown - bit 4 = interrupt enable - bit 5 = unknown -006-007 W high 16 bits of the ROM address to read - -???-??? R reads data from the gfx ROMs (16 bits in total). The address of the - data is determined by the registers above - - - -051316 ------- -Manages a 32x32 tilemap (16x16 tiles, 512x512 pixels) which can be zoomed, -distorted and rotated. -It uses two internal 24 bit counters which are incremented while scanning the -picture. The coordinates of the pixel in the tilemap that has to be drawn to -the current beam position are the counters / (2^11). -The chip doesn't directly generate the color information for the pixel, it -just generates a 24 bit address (whose top 16 bits are the contents of the -tilemap RAM), and a "visible" signal. It's up to external circuitry to convert -the address into a pixel color. Most games seem to use 4bpp graphics, but Ajax -uses 7bpp. -If the value in the internal counters is out of the visible range (0..511), it -is truncated and the corresponding address is still generated, but the "visible" -signal is not asserted. The external circuitry might ignore that signal and -still generate the pixel, therefore making the tilemap a continuous playfield -that wraps around instead of a large sprite. - -control registers -000-001 X counter starting value / 256 -002-003 amount to add to the X counter after each horizontal pixel -004-005 amount to add to the X counter after each line (0 = no rotation) -006-007 Y counter starting value / 256 -008-009 amount to add to the Y counter after each horizontal pixel (0 = no rotation) -00a-00b amount to add to the Y counter after each line -00c-00d ROM bank to read, used during ROM testing -00e bit 0 = enable ROM reading (active low). This only makes the chip output the - requested address: the ROM is actually read externally, not through - the chip's data bus. - bit 1 = unknown - bit 2 = unknown -00f unused - - - -053251 ------- -Priority encoder. - -The chip has inputs for 5 layers (CI0-CI4); only 4 are used (CI1-CI4) -CI0-CI2 are 9(=5+4) bits inputs, CI3-CI4 8(=4+4) bits - -The input connctions change from game to game. E.g. in Simpsons, -CI0 = grounded (background color) -CI1 = sprites -CI2 = FIX -CI3 = A -CI4 = B - -in lgtnfght: -CI0 = grounded -CI1 = sprites -CI2 = FIX -CI3 = B -CI4 = A - -there are three 6 bit priority inputs, PR0-PR2 - -simpsons: -PR0 = 111111 -PR1 = xxxxx0 x bits coming from the sprite attributes -PR2 = 111111 - -lgtnfght: -PR0 = 111111 -PR1 = 1xx000 x bits coming from the sprite attributes -PR2 = 111111 - -also two shadow inputs, SDI0 and SDI1 (from the sprite attributes) - -the chip outputs the 11 bit palette index, CO0-CO10, and two shadow bits. - -16 internal registers; registers are 6 bits wide (input is D0-D5) -For the most part, their meaning is unknown -All registers are write only. -There must be a way to enable/disable the three external PR inputs. -Some games initialize the priorities of the sprite & background layers, -others don't. It isn't clear whether the data written to those registers is -actually used, since the priority is taken from the external ports. - - 0 priority of CI0 (higher = lower priority) - punkshot: unused? - lgtnfght: unused? - simpsons: 3f = 111111 - xmen: 05 = 000101 default value - xmen: 09 = 001001 used to swap CI0 and CI2 - 1 priority of CI1 (higher = lower priority) - punkshot: 28 = 101000 - lgtnfght: unused? - simpsons: unused? - xmen: 02 = 000010 - 2 priority of CI2 (higher = lower priority) - punkshot: 24 = 100100 - lgtnfght: 24 = 100100 - simpsons: 04 = 000100 - xmen: 09 = 001001 default value - xmen: 05 = 000101 used to swap CI0 and CI2 - 3 priority of CI3 (higher = lower priority) - punkshot: 34 = 110100 - lgtnfght: 34 = 110100 - simpsons: 28 = 101000 - xmen: 00 = 000000 - 4 priority of CI4 (higher = lower priority) - punkshot: 2c = 101100 default value - punkshot: 3c = 111100 used to swap CI3 and CI4 - punkshot: 26 = 100110 used to swap CI1 and CI4 - lgtnfght: 2c = 101100 - simpsons: 18 = 011000 - xmen: fe = 111110 - 5 unknown - punkshot: unused? - lgtnfght: 2a = 101010 - simpsons: unused? - xmen: unused? - 6 unknown - punkshot: 26 = 100110 - lgtnfght: 30 = 110000 - simpsons: 17 = 010111 - xmen: 03 = 000011 (written after initial tests) - 7 unknown - punkshot: unused? - lgtnfght: unused? - simpsons: 27 = 100111 - xmen: 07 = 000111 (written after initial tests) - 8 unknown - punkshot: unused? - lgtnfght: unused? - simpsons: 37 = 110111 - xmen: ff = 111111 (written after initial tests) - 9 ----xx CI0 palette index base (CO9-CO10) - --xx-- CI1 palette index base (CO9-CO10) - xx---- CI2 palette index base (CO9-CO10) -10 ---xxx CI3 palette index base (CO8-CO10) - xxx--- CI4 palette index base (CO8-CO10) -11 unknown - punkshot: 00 = 000000 - lgtnfght: 00 = 000000 - simpsons: 00 = 000000 - xmen: 00 = 000000 (written after initial tests) -12 unknown - punkshot: 04 = 000100 - lgtnfght: 04 = 000100 - simpsons: 05 = 000101 - xmen: 05 = 000101 -13 unused -14 unused -15 unused - - - - -051733 ------- -Sort of a protection device, used for collision detection, and for -arithmetical operations. -It is passed a few parameters, and returns the result. - -Memory map(preliminary): ------------------------- -00-01 W operand 1 -02-03 W operand 2 -04-05 W operand 3 - -00-01 R operand 1 / operand 2 -02-03 R operand 1 % operand 2? -04-05 R sqrt(operand 3<<16) -06 R unknown - return value written to 13? - -06-07 W distance for collision check -08-09 W Y pos of obj1 -0a-0b W X pos of obj1 -0c-0d W Y pos of obj2 -0e-0f W X pos of obj2 -13 W unknown - -07 R collision (0x80 = no, 0x00 = yes) -0a-0b R unknown (chequered flag), might just read back X pos -0e-0f R unknown (chequered flag), might just read back X pos - -Other addresses are unknown or unused. - -Fast Lane: ----------- -$9def: -This routine is called only after a collision. -(R) 0x0006: unknown. Only bits 0-3 are used. - -Blades of Steel: ----------------- -$ac2f: -(R) 0x2f86: unknown. Only uses bit 0. - -$a5de: -writes to 0x2f84-0x2f85, waits a little, and then reads from 0x2f84. - -$7af3: -(R) 0x2f86: unknown. Only uses bit 0. - - -Devastators: ------------- -$6ce8: -reads from 0x0006, and only uses bit 1. - - K055550 ------- @@ -864,27 +292,6 @@ Has word-wide registers as follows: -k054338 -------- -Color combiner engine. Designed for use with the 55555, but also found in games -without one. - -Registers (word-wise): - -0: first 8 bits unknown, second 8 bits are the R component of the background color -1: G and B components (8 bits each) of the background color -2-4: shadow 1 R/G/B (16 bits per component. In shadow mode, determines a blend - value between total blackness and the original color. In highlight mode, - determines a blend value between total whiteness and the original color. - The hardware clamps at black or white as necessary: see the Graphics Test - in many System GX games). -5-7: shadow 2 R/G/B -8-10: shadow 3 R/G/B -11-12: brightness R/G/B (external circuit such as the 55555 decides which layers - this applies to) -13-14: alpha blend R/G/B (external circuit such as the 55555 decides which layers - this applies to) - ***************************************************************************/ #include "emu.h" @@ -899,2596 +306,6 @@ Registers (word-wise): #define XOR(a) WORD_XOR_BE(a) -/* useful function to sort three tile layers by priority order */ -void konami_sortlayers3( int *layer, int *pri ) -{ -#define SWAP(a,b) \ - if (pri[a] < pri[b]) \ - { \ - int t; \ - t = pri[a]; pri[a] = pri[b]; pri[b] = t; \ - t = layer[a]; layer[a] = layer[b]; layer[b] = t; \ - } - - SWAP(0,1) - SWAP(0,2) - SWAP(1,2) -#undef SWAP -} - -/* useful function to sort four tile layers by priority order */ -void konami_sortlayers4( int *layer, int *pri ) -{ -#define SWAP(a,b) \ - if (pri[a] <= pri[b]) \ - { \ - int t; \ - t = pri[a]; pri[a] = pri[b]; pri[b] = t; \ - t = layer[a]; layer[a] = layer[b]; layer[b] = t; \ - } - - SWAP(0, 1) - SWAP(0, 2) - SWAP(0, 3) - SWAP(1, 2) - SWAP(1, 3) - SWAP(2, 3) -#undef SWAP -} - -/* useful function to sort five tile layers by priority order */ -void konami_sortlayers5( int *layer, int *pri ) -{ -#define SWAP(a,b) \ - if (pri[a] <= pri[b]) \ - { \ - int t; \ - t = pri[a]; pri[a] = pri[b]; pri[b] = t; \ - t = layer[a]; layer[a] = layer[b]; layer[b] = t; \ - } - - SWAP(0, 1) - SWAP(0, 2) - SWAP(0, 3) - SWAP(0, 4) - SWAP(1, 2) - SWAP(1, 3) - SWAP(1, 4) - SWAP(2, 3) - SWAP(2, 4) - SWAP(3, 4) -#undef SWAP -} - - -/***************************************************************************/ -/* */ -/* 007121 */ -/* */ -/***************************************************************************/ - - -const device_type K007121 = &device_creator; - -k007121_device::k007121_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, K007121, "Konami 007121", tag, owner, clock, "k007121", __FILE__), - m_flipscreen(0) -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void k007121_device::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void k007121_device::device_start() -{ - save_item(NAME(m_ctrlram)); - save_item(NAME(m_flipscreen)); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void k007121_device::device_reset() -{ - int i; - - m_flipscreen = 0; - - for (i = 0; i < 8; i++) - m_ctrlram[i] = 0; -} - - -/***************************************************************************** - DEVICE HANDLERS -*****************************************************************************/ - -READ8_MEMBER( k007121_device::ctrlram_r ) -{ - assert(offset < 8); - - return m_ctrlram[offset]; -} - - -WRITE8_MEMBER( k007121_device::ctrl_w ) -{ - assert(offset < 8); - - switch (offset) - { - case 6: - /* palette bank change */ - if ((m_ctrlram[offset] & 0x30) != (data & 0x30)) - space.machine().tilemap().mark_all_dirty(); - break; - case 7: - m_flipscreen = data & 0x08; - break; - } - - m_ctrlram[offset] = data; -} - -/* - * Sprite Format - * ------------------ - * - * There are 0x40 sprites, each one using 5 bytes. However the number of - * sprites can be increased to 0x80 with a control register (Combat School - * sets it on and off during the game). - * - * Byte | Bit(s) | Use - * -----+-76543210-+---------------- - * 0 | xxxxxxxx | sprite code - * 1 | xxxx---- | color - * 1 | ----xx-- | sprite code low 2 bits for 16x8/8x8 sprites - * 1 | ------xx | sprite code bank bits 1/0 - * 2 | xxxxxxxx | y position - * 3 | xxxxxxxx | x position (low 8 bits) - * 4 | xx------ | sprite code bank bits 3/2 - * 4 | --x----- | flip y - * 4 | ---x---- | flip x - * 4 | ----xxx- | sprite size 000=16x16 001=16x8 010=8x16 011=8x8 100=32x32 - * 4 | -------x | x position (high bit) - * - * Flack Attack uses a different, "wider" layout with 32 bytes per sprite, - * mapped as follows, and the priority order is reversed. Maybe it is a - * compatibility mode with an older custom IC. It is not known how this - * alternate layout is selected. - * - * 0 -> e - * 1 -> f - * 2 -> 6 - * 3 -> 4 - * 4 -> 8 - * - */ - -void k007121_device::sprites_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx, colortable_t *ctable, - const UINT8 *source, int base_color, int global_x_offset, int bank_base, UINT32 pri_mask ) -{ - // gfx_element *gfx = gfxs[chip]; - bitmap_ind8 &priority_bitmap = gfx->machine().priority_bitmap; - int flipscreen = m_flipscreen; - int i, num, inc, offs[5]; - int is_flakatck = (ctable == NULL); - - if (is_flakatck) - { - num = 0x40; - inc = -0x20; - source += 0x3f * 0x20; - offs[0] = 0x0e; - offs[1] = 0x0f; - offs[2] = 0x06; - offs[3] = 0x04; - offs[4] = 0x08; - } - else /* all others */ - { - /* TODO: sprite limit is supposed to be per-line! (check MT #00185) */ - num = 0x40; - //num = (k007121->ctrlram[0x03] & 0x40) ? 0x80 : 0x40; /* WRONG!!! (needed by combatsc) */ - - inc = 5; - offs[0] = 0x00; - offs[1] = 0x01; - offs[2] = 0x02; - offs[3] = 0x03; - offs[4] = 0x04; - /* when using priority buffer, draw front to back */ - if (pri_mask != -1) - { - source += (num - 1)*inc; - inc = -inc; - } - } - - for (i = 0; i < num; i++) - { - int number = source[offs[0]]; /* sprite number */ - int sprite_bank = source[offs[1]] & 0x0f; /* sprite bank */ - int sx = source[offs[3]]; /* vertical position */ - int sy = source[offs[2]]; /* horizontal position */ - int attr = source[offs[4]]; /* attributes */ - int xflip = source[offs[4]] & 0x10; /* flip x */ - int yflip = source[offs[4]] & 0x20; /* flip y */ - int color = base_color + ((source[offs[1]] & 0xf0) >> 4); - int width, height; - int transparent_mask; - static const int x_offset[4] = {0x0,0x1,0x4,0x5}; - static const int y_offset[4] = {0x0,0x2,0x8,0xa}; - int x,y, ex, ey, flipx, flipy, destx, desty; - - if (attr & 0x01) sx -= 256; - if (sy >= 240) sy -= 256; - - number += ((sprite_bank & 0x3) << 8) + ((attr & 0xc0) << 4); - number = number << 2; - number += (sprite_bank >> 2) & 3; - - /* Flak Attack doesn't use a lookup PROM, it maps the color code directly */ - /* to a palette entry */ - if (is_flakatck) - transparent_mask = 1 << 0; - else - transparent_mask = colortable_get_transpen_mask(ctable, gfx, color, 0); - - if (!is_flakatck || source[0x00]) /* Flak Attack needs this */ - { - number += bank_base; - - switch (attr & 0xe) - { - case 0x06: width = height = 1; break; - case 0x04: width = 1; height = 2; number &= (~2); break; - case 0x02: width = 2; height = 1; number &= (~1); break; - case 0x00: width = height = 2; number &= (~3); break; - case 0x08: width = height = 4; number &= (~3); break; - default: width = 1; height = 1; -// logerror("Unknown sprite size %02x\n", attr & 0xe); -// popmessage("Unknown sprite size %02x\n", attr & 0xe); - } - - for (y = 0; y < height; y++) - { - for (x = 0; x < width; x++) - { - ex = xflip ? (width - 1 - x) : x; - ey = yflip ? (height - 1 - y) : y; - - if (flipscreen) - { - flipx = !xflip; - flipy = !yflip; - destx = 248 - (sx + x * 8); - desty = 248 - (sy + y * 8); - } - else - { - flipx = xflip; - flipy = yflip; - destx = global_x_offset + sx + x * 8; - desty = sy + y * 8; - } - - if (pri_mask != -1) - pdrawgfx_transmask(bitmap,cliprect,gfx, - number + x_offset[ex] + y_offset[ey], - color, - flipx,flipy, - destx,desty, - priority_bitmap,pri_mask, - transparent_mask); - else - drawgfx_transmask(bitmap,cliprect,gfx, - number + x_offset[ex] + y_offset[ey], - color, - flipx,flipy, - destx,desty, - transparent_mask); - } - } - } - - source += inc; - } -} - -/***************************************************************************/ -/* */ -/* 007342 */ -/* */ -/***************************************************************************/ - -const device_type K007342 = &device_creator; - -k007342_device::k007342_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, K007342, "Konami 007342", tag, owner, clock, "k007342", __FILE__), - m_ram(NULL), - m_scroll_ram(NULL), - m_videoram_0(NULL), - m_videoram_1(NULL), - m_colorram_0(NULL), - m_colorram_1(NULL), - //m_tilemap[2]; - m_flipscreen(0), - m_int_enabled(0) - //m_regs[8], - //m_scrollx[2], - //m_scrolly[2] -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void k007342_device::device_config_complete() -{ - // inherit a copy of the static data - const k007342_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - *static_cast(this) = *intf; - - // or initialize to defaults if none provided - else - { - m_gfxnum = 0; - m_callback = NULL; - } -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void k007342_device::device_start() -{ - m_tilemap[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k007342_device::get_tile_info0),this), tilemap_mapper_delegate(FUNC(k007342_device::scan),this), 8, 8, 64, 32); - m_tilemap[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k007342_device::get_tile_info1),this), tilemap_mapper_delegate(FUNC(k007342_device::scan),this), 8, 8, 64, 32); - - m_ram = auto_alloc_array_clear(machine(), UINT8, 0x2000); - m_scroll_ram = auto_alloc_array_clear(machine(), UINT8, 0x0200); - - m_colorram_0 = &m_ram[0x0000]; - m_colorram_1 = &m_ram[0x1000]; - m_videoram_0 = &m_ram[0x0800]; - m_videoram_1 = &m_ram[0x1800]; - - m_tilemap[0]->set_transparent_pen(0); - m_tilemap[1]->set_transparent_pen(0); - - save_pointer(NAME(m_ram), 0x2000); - save_pointer(NAME(m_scroll_ram), 0x0200); - save_item(NAME(m_int_enabled)); - save_item(NAME(m_flipscreen)); - save_item(NAME(m_scrollx)); - save_item(NAME(m_scrolly)); - save_item(NAME(m_regs)); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void k007342_device::device_reset() -{ - int i; - - m_int_enabled = 0; - m_flipscreen = 0; - m_scrollx[0] = 0; - m_scrollx[1] = 0; - m_scrolly[0] = 0; - m_scrolly[1] = 0; - - for (i = 0; i < 8; i++) - m_regs[i] = 0; -} - -/***************************************************************************** - DEVICE HANDLERS -*****************************************************************************/ - -READ8_MEMBER( k007342_device::read ) -{ - return m_ram[offset]; -} - -WRITE8_MEMBER( k007342_device::write ) -{ - m_ram[offset] = data; - - if (offset < 0x1000) /* layer 0 */ - m_tilemap[0]->mark_tile_dirty(offset & 0x7ff); - else /* layer 1 */ - m_tilemap[1]->mark_tile_dirty(offset & 0x7ff); -} - -READ8_MEMBER( k007342_device::scroll_r ) -{ - return m_scroll_ram[offset]; -} - -WRITE8_MEMBER( k007342_device::scroll_w ) -{ - m_scroll_ram[offset] = data; -} - -WRITE8_MEMBER( k007342_device::vreg_w ) -{ - switch(offset) - { - case 0x00: - /* bit 1: INT control */ - m_int_enabled = data & 0x02; - m_flipscreen = data & 0x10; - m_tilemap[0]->set_flip(m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - m_tilemap[1]->set_flip(m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - break; - case 0x01: /* used for banking in Rock'n'Rage */ - if (data != m_regs[1]) - space.machine().tilemap().mark_all_dirty(); - case 0x02: - m_scrollx[0] = (m_scrollx[0] & 0xff) | ((data & 0x01) << 8); - m_scrollx[1] = (m_scrollx[1] & 0xff) | ((data & 0x02) << 7); - break; - case 0x03: /* scroll x (register 0) */ - m_scrollx[0] = (m_scrollx[0] & 0x100) | data; - break; - case 0x04: /* scroll y (register 0) */ - m_scrolly[0] = data; - break; - case 0x05: /* scroll x (register 1) */ - m_scrollx[1] = (m_scrollx[1] & 0x100) | data; - break; - case 0x06: /* scroll y (register 1) */ - m_scrolly[1] = data; - case 0x07: /* unused */ - break; - } - m_regs[offset] = data; -} - -void k007342_device::tilemap_update( ) -{ - int offs; - - /* update scroll */ - switch (m_regs[2] & 0x1c) - { - case 0x00: - case 0x08: /* unknown, blades of steel shootout between periods */ - m_tilemap[0]->set_scroll_rows(1); - m_tilemap[0]->set_scroll_cols(1); - m_tilemap[0]->set_scrollx(0, m_scrollx[0]); - m_tilemap[0]->set_scrolly(0, m_scrolly[0]); - break; - - case 0x0c: /* 32 columns */ - m_tilemap[0]->set_scroll_rows(1); - m_tilemap[0]->set_scroll_cols(512); - m_tilemap[0]->set_scrollx(0, m_scrollx[0]); - for (offs = 0; offs < 256; offs++) - m_tilemap[0]->set_scrolly((offs + m_scrollx[0]) & 0x1ff, - m_scroll_ram[2 * (offs / 8)] + 256 * m_scroll_ram[2 * (offs / 8) + 1]); - break; - - case 0x14: /* 256 rows */ - m_tilemap[0]->set_scroll_rows(256); - m_tilemap[0]->set_scroll_cols(1); - m_tilemap[0]->set_scrolly(0, m_scrolly[0]); - for (offs = 0; offs < 256; offs++) - m_tilemap[0]->set_scrollx((offs + m_scrolly[0]) & 0xff, - m_scroll_ram[2 * offs] + 256 * m_scroll_ram[2 * offs + 1]); - break; - - default: -// popmessage("unknown scroll ctrl %02x", m_regs[2] & 0x1c); - break; - } - - m_tilemap[1]->set_scrollx(0, m_scrollx[1]); - m_tilemap[1]->set_scrolly(0, m_scrolly[1]); - -#if 0 - { - static int current_layer = 0; - - if (machine.input().code_pressed_once(KEYCODE_Z)) current_layer = !current_layer; - m_tilemap[current_layer]->enable(1); - m_tilemap[!current_layer]->enable(0); - - popmessage("regs:%02x %02x %02x %02x-%02x %02x %02x %02x:%02x", - m_regs[0], m_regs[1], m_regs[2], m_regs[3], - m_regs[4], m_regs[5], m_regs[6], m_regs[7], - current_layer); - } -#endif -} - -void k007342_device::tilemap_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, int num, int flags, UINT32 priority ) -{ - m_tilemap[num]->draw(bitmap, cliprect, flags, priority); -} - -int k007342_device::is_int_enabled( ) -{ - return m_int_enabled; -} - - -/*************************************************************************** - - Callbacks for the TileMap code - -***************************************************************************/ - -/* - data format: - video RAM xxxxxxxx tile number (bits 0-7) - color RAM x------- tiles with priority over the sprites - color RAM -x------ depends on external conections - color RAM --x----- flip Y - color RAM ---x---- flip X - color RAM ----xxxx depends on external connections (usually color and banking) -*/ - -TILEMAP_MAPPER_MEMBER(k007342_device::scan) -{ - /* logical (col,row) -> memory offset */ - return (col & 0x1f) + ((row & 0x1f) << 5) + ((col & 0x20) << 5); -} - -void k007342_device::get_tile_info( tile_data &tileinfo, int tile_index, int layer, UINT8 *cram, UINT8 *vram ) -{ - int color, code, flags; - - color = cram[tile_index]; - code = vram[tile_index]; - flags = TILE_FLIPYX((color & 0x30) >> 4); - - tileinfo.category = (color & 0x80) >> 7; - - m_callback(machine(), layer, m_regs[1], &code, &color, &flags); - - SET_TILE_INFO_MEMBER( - m_gfxnum, - code, - color, - flags); -} - -TILE_GET_INFO_MEMBER(k007342_device::get_tile_info0) -{ - get_tile_info(tileinfo, tile_index, 0, m_colorram_0, m_videoram_0); -} - -TILE_GET_INFO_MEMBER(k007342_device::get_tile_info1) -{ - get_tile_info(tileinfo, tile_index, 1, m_colorram_1, m_videoram_1); -} - -/***************************************************************************/ -/* */ -/* 007420 */ -/* */ -/***************************************************************************/ - -#define K007420_SPRITERAM_SIZE 0x200 - -const device_type K007420 = &device_creator; - -k007420_device::k007420_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, K007420, "Konami 007420", tag, owner, clock, "k007420", __FILE__), - m_ram(NULL), - m_flipscreen(0) - //m_regs[8], -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void k007420_device::device_config_complete() -{ - // inherit a copy of the static data - const k007420_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - *static_cast(this) = *intf; - - // or initialize to defaults if none provided - else - { - m_banklimit = 0; - m_callback = NULL; - } -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void k007420_device::device_start() -{ - m_ram = auto_alloc_array_clear(machine(), UINT8, 0x200); - - save_pointer(NAME(m_ram), 0x200); - save_item(NAME(m_flipscreen)); // current one uses 7342 one - save_item(NAME(m_regs)); // current one uses 7342 ones -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void k007420_device::device_reset() -{ - int i; - - m_flipscreen = 0; - for (i = 0; i < 8; i++) - m_regs[i] = 0; -} - -/***************************************************************************** - DEVICE HANDLERS -*****************************************************************************/ - -READ8_MEMBER( k007420_device::read ) -{ - return m_ram[offset]; -} - -WRITE8_MEMBER( k007420_device::write ) -{ - m_ram[offset] = data; -} - -/* - * Sprite Format - * ------------------ - * - * Byte | Bit(s) | Use - * -----+-76543210-+---------------- - * 0 | xxxxxxxx | y position - * 1 | xxxxxxxx | sprite code (low 8 bits) - * 2 | xxxxxxxx | depends on external conections. Usually banking - * 3 | xxxxxxxx | x position (low 8 bits) - * 4 | x------- | x position (high bit) - * 4 | -xxx---- | sprite size 000=16x16 001=8x16 010=16x8 011=8x8 100=32x32 - * 4 | ----x--- | flip y - * 4 | -----x-- | flip x - * 4 | ------xx | zoom (bits 8 & 9) - * 5 | xxxxxxxx | zoom (low 8 bits) 0x080 = normal, < 0x80 enlarge, > 0x80 reduce - * 6 | xxxxxxxx | unused - * 7 | xxxxxxxx | unused - */ - -void k007420_device::sprites_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx ) -{ - int offs; - int codemask = m_banklimit; - int bankmask = ~m_banklimit; - - for (offs = K007420_SPRITERAM_SIZE - 8; offs >= 0; offs -= 8) - { - int ox, oy, code, color, flipx, flipy, zoom, w, h, x, y, bank; - static const int xoffset[4] = { 0, 1, 4, 5 }; - static const int yoffset[4] = { 0, 2, 8, 10 }; - - code = m_ram[offs + 1]; - color = m_ram[offs + 2]; - ox = m_ram[offs + 3] - ((m_ram[offs + 4] & 0x80) << 1); - oy = 256 - m_ram[offs + 0]; - flipx = m_ram[offs + 4] & 0x04; - flipy = m_ram[offs + 4] & 0x08; - - m_callback(machine(), &code, &color); - - bank = code & bankmask; - code &= codemask; - - /* 0x080 = normal scale, 0x040 = double size, 0x100 half size */ - zoom = m_ram[offs + 5] | ((m_ram[offs + 4] & 0x03) << 8); - if (!zoom) - continue; - zoom = 0x10000 * 128 / zoom; - - switch (m_ram[offs + 4] & 0x70) - { - case 0x30: w = h = 1; break; - case 0x20: w = 2; h = 1; code &= (~1); break; - case 0x10: w = 1; h = 2; code &= (~2); break; - case 0x00: w = h = 2; code &= (~3); break; - case 0x40: w = h = 4; code &= (~3); break; - default: w = 1; h = 1; -//logerror("Unknown sprite size %02x\n",(m_ram[offs + 4] & 0x70) >> 4); - } - - if (m_flipscreen) - { - ox = 256 - ox - ((zoom * w + (1 << 12)) >> 13); - oy = 256 - oy - ((zoom * h + (1 << 12)) >> 13); - flipx = !flipx; - flipy = !flipy; - } - - if (zoom == 0x10000) - { - int sx, sy; - - for (y = 0; y < h; y++) - { - sy = oy + 8 * y; - - for (x = 0; x < w; x++) - { - int c = code; - - sx = ox + 8 * x; - if (flipx) - c += xoffset[(w - 1 - x)]; - else - c += xoffset[x]; - - if (flipy) - c += yoffset[(h - 1 - y)]; - else - c += yoffset[y]; - - if (c & bankmask) - continue; - else - c += bank; - - drawgfx_transpen(bitmap,cliprect,gfx, - c, - color, - flipx,flipy, - sx,sy,0); - - if (m_regs[2] & 0x80) - drawgfx_transpen(bitmap,cliprect,gfx, - c, - color, - flipx,flipy, - sx,sy-256,0); - } - } - } - else - { - int sx, sy, zw, zh; - for (y = 0; y < h; y++) - { - sy = oy + ((zoom * y + (1 << 12)) >> 13); - zh = (oy + ((zoom * (y + 1) + (1 << 12)) >> 13)) - sy; - - for (x = 0; x < w; x++) - { - int c = code; - - sx = ox + ((zoom * x + (1<<12)) >> 13); - zw = (ox + ((zoom * (x + 1) + (1 << 12)) >> 13)) - sx; - if (flipx) - c += xoffset[(w - 1 - x)]; - else - c += xoffset[x]; - - if (flipy) - c += yoffset[(h - 1 - y)]; - else - c += yoffset[y]; - - if (c & bankmask) - continue; - else - c += bank; - - drawgfxzoom_transpen(bitmap,cliprect,gfx, - c, - color, - flipx,flipy, - sx,sy, - (zw << 16) / 8,(zh << 16) / 8,0); - - if (m_regs[2] & 0x80) - drawgfxzoom_transpen(bitmap,cliprect,gfx, - c, - color, - flipx,flipy, - sx,sy-256, - (zw << 16) / 8,(zh << 16) / 8,0); - } - } - } - } -#if 0 - { - static int current_sprite = 0; - - if (machine().input().code_pressed_once(KEYCODE_Z)) current_sprite = (current_sprite+1) & ((K007420_SPRITERAM_SIZE/8)-1); - if (machine().input().code_pressed_once(KEYCODE_X)) current_sprite = (current_sprite-1) & ((K007420_SPRITERAM_SIZE/8)-1); - - popmessage("%02x:%02x %02x %02x %02x %02x %02x %02x %02x", current_sprite, - m_ram[(current_sprite*8)+0], m_ram[(current_sprite*8)+1], - m_ram[(current_sprite*8)+2], m_ram[(current_sprite*8)+3], - m_ram[(current_sprite*8)+4], m_ram[(current_sprite*8)+5], - m_ram[(current_sprite*8)+6], m_ram[(current_sprite*8)+7]); - } -#endif -} - - -/***************************************************************************/ -/* */ -/* 052109 */ -/* */ -/***************************************************************************/ - -const device_type K052109 = &device_creator; - -k052109_device::k052109_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, K052109, "Konami 052109", tag, owner, clock, "k052109", __FILE__), - m_ram(NULL), - m_videoram_F(NULL), - m_videoram_A(NULL), - m_videoram_B(NULL), - m_videoram2_F(NULL), - m_videoram2_A(NULL), - m_videoram2_B(NULL), - m_colorram_F(NULL), - m_colorram_A(NULL), - m_colorram_B(NULL), - - //m_tilemap[3], - m_tileflip_enable(0), - //m_charrombank[4], - //m_charrombank_2[4], - m_has_extra_video_ram(0), - m_rmrd_line(0), - m_irq_enabled(0), - //m_dx[3], m_dy[3], - m_romsubbank(0), - m_scrollctrl(0) -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void k052109_device::device_config_complete() -{ - // inherit a copy of the static data - const k052109_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - *static_cast(this) = *intf; - - // or initialize to defaults if none provided - else - { - m_gfx_memory_region = ""; - m_gfx_num = 0; - m_plane_order = 0; - m_deinterleave = 0; - m_callback = NULL; - } -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void k052109_device::device_start() -{ - UINT32 total; - static const gfx_layout charlayout = - { - 8,8, - 0, - 4, - { 24, 16, 8, 0 }, - { 0, 1, 2, 3, 4, 5, 6, 7 }, - { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 }, - 32*8 - }; - static const gfx_layout charlayout_gradius3 = - { - 8,8, - 0, - 4, - { 0, 1, 2, 3 }, - { XOR(0)*4, XOR(1)*4, XOR(2)*4, XOR(3)*4, XOR(4)*4, XOR(5)*4, XOR(6)*4, XOR(7)*4 }, - { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 }, - 32*8 - }; - - - /* decode the graphics */ - switch (m_plane_order) - { - case NORMAL_PLANE_ORDER: - total = machine().root_device().memregion(m_gfx_memory_region)->bytes() / 32; - konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region)->base(), total, &charlayout, 4); - break; - - case GRADIUS3_PLANE_ORDER: - total = 0x1000; - konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region)->base(), total, &charlayout_gradius3, 4); - break; - - default: - fatalerror("Unsupported plane_order\n"); - } - - /* deinterleave the graphics, if needed */ - konami_deinterleave_gfx(machine(), m_gfx_memory_region, m_deinterleave); - - m_tilemap[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k052109_device::get_tile_info0),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); - m_tilemap[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k052109_device::get_tile_info1),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); - m_tilemap[2] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k052109_device::get_tile_info2),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); - - m_ram = auto_alloc_array_clear(machine(), UINT8, 0x6000); - - m_colorram_F = &m_ram[0x0000]; - m_colorram_A = &m_ram[0x0800]; - m_colorram_B = &m_ram[0x1000]; - m_videoram_F = &m_ram[0x2000]; - m_videoram_A = &m_ram[0x2800]; - m_videoram_B = &m_ram[0x3000]; - m_videoram2_F = &m_ram[0x4000]; - m_videoram2_A = &m_ram[0x4800]; - m_videoram2_B = &m_ram[0x5000]; - - m_tilemap[0]->set_transparent_pen(0); - m_tilemap[1]->set_transparent_pen(0); - m_tilemap[2]->set_transparent_pen(0); - - save_pointer(NAME(m_ram), 0x6000); - save_item(NAME(m_rmrd_line)); - save_item(NAME(m_romsubbank)); - save_item(NAME(m_scrollctrl)); - save_item(NAME(m_irq_enabled)); - save_item(NAME(m_charrombank)); - save_item(NAME(m_charrombank_2)); - save_item(NAME(m_dx)); - save_item(NAME(m_dy)); - save_item(NAME(m_has_extra_video_ram)); - machine().save().register_postload(save_prepost_delegate(FUNC(k052109_device::tileflip_reset), this)); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void k052109_device::device_reset() -{ - int i; - - m_rmrd_line = CLEAR_LINE; - m_irq_enabled = 0; - m_romsubbank = 0; - m_scrollctrl = 0; - - m_has_extra_video_ram = 0; - - for (i = 0; i < 3; i++) - m_dx[i] = m_dy[i] = 0; - - for (i = 0; i < 4; i++) - { - m_charrombank[i] = 0; - m_charrombank_2[i] = 0; - } -} - -/***************************************************************************** - DEVICE HANDLERS -*****************************************************************************/ - -READ8_MEMBER( k052109_device::read ) -{ - if (m_rmrd_line == CLEAR_LINE) - { - if ((offset & 0x1fff) >= 0x1800) - { - if (offset >= 0x180c && offset < 0x1834) - { /* A y scroll */ } - else if (offset >= 0x1a00 && offset < 0x1c00) - { /* A x scroll */ } - else if (offset == 0x1d00) - { /* read for bitwise operations before writing */ } - else if (offset >= 0x380c && offset < 0x3834) - { /* B y scroll */ } - else if (offset >= 0x3a00 && offset < 0x3c00) - { /* B x scroll */ } -// else -//logerror("%04x: read from unknown 052109 address %04x\n",space.device().safe_pc(),offset); - } - - return m_ram[offset]; - } - else /* Punk Shot and TMNT read from 0000-1fff, Aliens from 2000-3fff */ - { - int code = (offset & 0x1fff) >> 5; - int color = m_romsubbank; - int flags = 0; - int priority = 0; - int bank = m_charrombank[(color & 0x0c) >> 2] >> 2; /* discard low bits (TMNT) */ - int addr; - - bank |= (m_charrombank_2[(color & 0x0c) >> 2] >> 2); // Surprise Attack uses this 2nd bank in the rom test - - if (m_has_extra_video_ram) - code |= color << 8; /* kludge for X-Men */ - else - m_callback(space.machine(), 0, bank, &code, &color, &flags, &priority); - - addr = (code << 5) + (offset & 0x1f); - addr &= space.machine().root_device().memregion(m_gfx_memory_region)->bytes() - 1; - -// logerror("%04x: off = %04x sub = %02x (bnk = %x) adr = %06x\n", space.device().safe_pc(), offset, m_romsubbank, bank, addr); - - return space.machine().root_device().memregion(m_gfx_memory_region)->base()[addr]; - } -} - -WRITE8_MEMBER( k052109_device::write ) -{ - if ((offset & 0x1fff) < 0x1800) /* tilemap RAM */ - { - if (offset >= 0x4000) - m_has_extra_video_ram = 1; /* kludge for X-Men */ - - m_ram[offset] = data; - m_tilemap[(offset & 0x1800) >> 11]->mark_tile_dirty(offset & 0x7ff); - } - else /* control registers */ - { - m_ram[offset] = data; - - if (offset >= 0x180c && offset < 0x1834) - { /* A y scroll */ } - else if (offset >= 0x1a00 && offset < 0x1c00) - { /* A x scroll */ } - else if (offset == 0x1c80) - { - if (m_scrollctrl != data) - { -//popmessage("scrollcontrol = %02x", data); -//logerror("%04x: rowscrollcontrol = %02x\n", space.device().safe_pc(), data); - m_scrollctrl = data; - } - } - else if (offset == 0x1d00) - { -//logerror("%04x: 052109 register 1d00 = %02x\n", space.device().safe_pc(), data); - /* bit 2 = irq enable */ - /* the custom chip can also generate NMI and FIRQ, for use with a 6809 */ - m_irq_enabled = data & 0x04; - } - else if (offset == 0x1d80) - { - int dirty = 0; - - if (m_charrombank[0] != (data & 0x0f)) - dirty |= 1; - if (m_charrombank[1] != ((data >> 4) & 0x0f)) - dirty |= 2; - - if (dirty) - { - int i; - - m_charrombank[0] = data & 0x0f; - m_charrombank[1] = (data >> 4) & 0x0f; - - for (i = 0; i < 0x1800; i++) - { - int bank = (m_ram[i]&0x0c) >> 2; - if ((bank == 0 && (dirty & 1)) || (bank == 1 && (dirty & 2))) - { - m_tilemap[(i & 0x1800) >> 11]->mark_tile_dirty(i & 0x7ff); - } - } - } - } - else if (offset == 0x1e00 || offset == 0x3e00) // Surprise Attack uses offset 0x3e00 - { -//logerror("%04x: 052109 register 1e00 = %02x\n",space.device().safe_pc(),data); - m_romsubbank = data; - } - else if (offset == 0x1e80) - { -//if ((data & 0xfe)) logerror("%04x: 052109 register 1e80 = %02x\n",space.device().safe_pc(),data); - m_tilemap[0]->set_flip((data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - m_tilemap[1]->set_flip((data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - m_tilemap[2]->set_flip((data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - if (m_tileflip_enable != ((data & 0x06) >> 1)) - { - m_tileflip_enable = ((data & 0x06) >> 1); - - m_tilemap[0]->mark_all_dirty(); - m_tilemap[1]->mark_all_dirty(); - m_tilemap[2]->mark_all_dirty(); - } - } - else if (offset == 0x1f00) - { - int dirty = 0; - - if (m_charrombank[2] != (data & 0x0f)) - dirty |= 1; - - if (m_charrombank[3] != ((data >> 4) & 0x0f)) - dirty |= 2; - - if (dirty) - { - int i; - - m_charrombank[2] = data & 0x0f; - m_charrombank[3] = (data >> 4) & 0x0f; - - for (i = 0; i < 0x1800; i++) - { - int bank = (m_ram[i] & 0x0c) >> 2; - if ((bank == 2 && (dirty & 1)) || (bank == 3 && (dirty & 2))) - m_tilemap[(i & 0x1800) >> 11]->mark_tile_dirty(i & 0x7ff); - } - } - } - else if (offset >= 0x380c && offset < 0x3834) - { /* B y scroll */ } - else if (offset >= 0x3a00 && offset < 0x3c00) - { /* B x scroll */ } - else if (offset == 0x3d80) // Surprise Attack uses offset 0x3d80 in rom test - { - // mirroring this write, breaks Surprise Attack in game tilemaps - m_charrombank_2[0] = data & 0x0f; - m_charrombank_2[1] = (data >> 4) & 0x0f; - } - else if (offset == 0x3f00) // Surprise Attack uses offset 0x3f00 in rom test - { - // mirroring this write, breaks Surprise Attack in game tilemaps - m_charrombank_2[2] = data & 0x0f; - m_charrombank_2[3] = (data >> 4) & 0x0f; - } -// else -// logerror("%04x: write %02x to unknown 052109 address %04x\n",space.device().safe_pc(),data,offset); - } -} - -READ16_MEMBER( k052109_device::word_r ) -{ - return read(space, offset + 0x2000) | (read(space, offset) << 8); -} - -WRITE16_MEMBER( k052109_device::word_w ) -{ - if (ACCESSING_BITS_8_15) - write(space, offset, (data >> 8) & 0xff); - if (ACCESSING_BITS_0_7) - write(space, offset + 0x2000, data & 0xff); -} - -READ16_MEMBER( k052109_device::lsb_r ) -{ - return read(space, offset); -} - -WRITE16_MEMBER( k052109_device::lsb_w ) -{ - if(ACCESSING_BITS_0_7) - write(space, offset, data & 0xff); -} - -void k052109_device::set_rmrd_line( int state ) -{ - m_rmrd_line = state; -} - -int k052109_device::get_rmrd_line( ) -{ - return m_rmrd_line; -} - - -void k052109_device::tilemap_mark_dirty( int tmap_num ) -{ - m_tilemap[tmap_num]->mark_all_dirty(); -} - - -void k052109_device::tilemap_update( ) -{ - int xscroll, yscroll, offs; - -#if 0 -{ -popmessage("%x %x %x %x", - m_charrombank[0], - m_charrombank[1], - m_charrombank[2], - m_charrombank[3]); -} -#endif - - if ((m_scrollctrl & 0x03) == 0x02) - { - UINT8 *scrollram = &m_ram[0x1a00]; - - m_tilemap[1]->set_scroll_rows(256); - m_tilemap[1]->set_scroll_cols(1); - yscroll = m_ram[0x180c]; - m_tilemap[1]->set_scrolly(0, yscroll + m_dy[1]); - for (offs = 0; offs < 256; offs++) - { - xscroll = scrollram[2 * (offs & 0xfff8) + 0] + 256 * scrollram[2 * (offs & 0xfff8) + 1]; - xscroll -= 6; - m_tilemap[1]->set_scrollx((offs + yscroll) & 0xff, xscroll + m_dx[1]); - } - } - else if ((m_scrollctrl & 0x03) == 0x03) - { - UINT8 *scrollram = &m_ram[0x1a00]; - - m_tilemap[1]->set_scroll_rows(256); - m_tilemap[1]->set_scroll_cols(1); - yscroll = m_ram[0x180c]; - m_tilemap[1]->set_scrolly(0, yscroll + m_dy[1]); - for (offs = 0; offs < 256; offs++) - { - xscroll = scrollram[2 * offs + 0] + 256 * scrollram[2 * offs + 1]; - xscroll -= 6; - m_tilemap[1]->set_scrollx((offs + yscroll) & 0xff, xscroll + m_dx[1]); - } - } - else if ((m_scrollctrl & 0x04) == 0x04) - { - UINT8 *scrollram = &m_ram[0x1800]; - - m_tilemap[1]->set_scroll_rows(1); - m_tilemap[1]->set_scroll_cols(512); - xscroll = m_ram[0x1a00] + 256 * m_ram[0x1a01]; - xscroll -= 6; - m_tilemap[1]->set_scrollx(0, xscroll + m_dx[1]); - for (offs = 0; offs < 512; offs++) - { - yscroll = scrollram[offs / 8]; - m_tilemap[1]->set_scrolly((offs + xscroll) & 0x1ff, yscroll + m_dy[1]); - } - } - else - { - UINT8 *scrollram = &m_ram[0x1a00]; - - m_tilemap[1]->set_scroll_rows(1); - m_tilemap[1]->set_scroll_cols(1); - xscroll = scrollram[0] + 256 * scrollram[1]; - xscroll -= 6; - yscroll = m_ram[0x180c]; - m_tilemap[1]->set_scrollx(0, xscroll + m_dx[1]); - m_tilemap[1]->set_scrolly(0, yscroll + m_dy[1]); - } - - if ((m_scrollctrl & 0x18) == 0x10) - { - UINT8 *scrollram = &m_ram[0x3a00]; - - m_tilemap[2]->set_scroll_rows(256); - m_tilemap[2]->set_scroll_cols(1); - yscroll = m_ram[0x380c]; - m_tilemap[2]->set_scrolly(0, yscroll + m_dy[2]); - for (offs = 0; offs < 256; offs++) - { - xscroll = scrollram[2 * (offs & 0xfff8) + 0] + 256 * scrollram[2 * (offs & 0xfff8) + 1]; - xscroll -= 6; - m_tilemap[2]->set_scrollx((offs + yscroll) & 0xff, xscroll + m_dx[2]); - } - } - else if ((m_scrollctrl & 0x18) == 0x18) - { - UINT8 *scrollram = &m_ram[0x3a00]; - - m_tilemap[2]->set_scroll_rows(256); - m_tilemap[2]->set_scroll_cols(1); - yscroll = m_ram[0x380c]; - m_tilemap[2]->set_scrolly(0, yscroll + m_dy[2]); - for (offs = 0; offs < 256; offs++) - { - xscroll = scrollram[2 * offs + 0] + 256 * scrollram[2 * offs + 1]; - xscroll -= 6; - m_tilemap[2]->set_scrollx((offs + yscroll) & 0xff, xscroll + m_dx[2]); - } - } - else if ((m_scrollctrl & 0x20) == 0x20) - { - UINT8 *scrollram = &m_ram[0x3800]; - - m_tilemap[2]->set_scroll_rows(1); - m_tilemap[2]->set_scroll_cols(512); - xscroll = m_ram[0x3a00] + 256 * m_ram[0x3a01]; - xscroll -= 6; - m_tilemap[2]->set_scrollx(0, xscroll + m_dx[2]); - for (offs = 0; offs < 512; offs++) - { - yscroll = scrollram[offs / 8]; - m_tilemap[2]->set_scrolly((offs + xscroll) & 0x1ff, yscroll + m_dy[2]); - } - } - else - { - UINT8 *scrollram = &m_ram[0x3a00]; - - m_tilemap[2]->set_scroll_rows(1); - m_tilemap[2]->set_scroll_cols(1); - xscroll = scrollram[0] + 256 * scrollram[1]; - xscroll -= 6; - yscroll = m_ram[0x380c]; - m_tilemap[2]->set_scrollx(0, xscroll + m_dx[2]); - m_tilemap[2]->set_scrolly(0, yscroll + m_dy[2]); - } - -#if 0 -if ((m_scrollctrl & 0x03) == 0x01 || - (m_scrollctrl & 0x18) == 0x08 || - ((m_scrollctrl & 0x04) && (m_scrollctrl & 0x03)) || - ((m_scrollctrl & 0x20) && (m_scrollctrl & 0x18)) || - (m_scrollctrl & 0xc0) != 0) - popmessage("scrollcontrol = %02x", m_scrollctrl); - -if (machine().input().code_pressed(KEYCODE_F)) -{ - FILE *fp; - fp=fopen("TILE.DMP", "w+b"); - if (fp) - { - fwrite(m_ram, 0x6000, 1, fp); - popmessage("saved"); - fclose(fp); - } -} -#endif -} - -void k052109_device::tilemap_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, int tmap_num, UINT32 flags, UINT8 priority ) -{ - m_tilemap[tmap_num]->draw(bitmap, cliprect, flags, priority); -} - -int k052109_device::is_irq_enabled( ) -{ - return m_irq_enabled; -} - -void k052109_device::set_layer_offsets( int layer, int dx, int dy ) -{ - m_dx[layer] = dx; - m_dy[layer] = dy; -} - - -/*************************************************************************** - - Callbacks for the TileMap code - -***************************************************************************/ - -/* - data format: - video RAM xxxxxxxx tile number (low 8 bits) - color RAM xxxx---- depends on external connections (usually color and banking) - color RAM ----xx-- bank select (0-3): these bits are replaced with the 2 - bottom bits of the bank register before being placed on - the output pins. The other two bits of the bank register are - placed on the CAB1 and CAB2 output pins. - color RAM ------xx depends on external connections (usually banking, flip) -*/ - -void k052109_device::get_tile_info( tile_data &tileinfo, int tile_index, int layer, UINT8 *cram, UINT8 *vram1, UINT8 *vram2 ) -{ - int flipy = 0; - int code = vram1[tile_index] + 256 * vram2[tile_index]; - int color = cram[tile_index]; - int flags = 0; - int priority = 0; - int bank = m_charrombank[(color & 0x0c) >> 2]; - if (m_has_extra_video_ram) - bank = (color & 0x0c) >> 2; /* kludge for X-Men */ - - color = (color & 0xf3) | ((bank & 0x03) << 2); - bank >>= 2; - - flipy = color & 0x02; - - m_callback(machine(), layer, bank, &code, &color, &flags, &priority); - - /* if the callback set flip X but it is not enabled, turn it off */ - if (!(m_tileflip_enable & 1)) - flags &= ~TILE_FLIPX; - - /* if flip Y is enabled and the attribute but is set, turn it on */ - if (flipy && (m_tileflip_enable & 2)) - flags |= TILE_FLIPY; - - SET_TILE_INFO_MEMBER( - m_gfx_num, - code, - color, - flags); - - tileinfo.category = priority; -} - -TILE_GET_INFO_MEMBER(k052109_device::get_tile_info0) -{ - get_tile_info(tileinfo, tile_index, 0, m_colorram_F, m_videoram_F, m_videoram2_F); -} - -TILE_GET_INFO_MEMBER(k052109_device::get_tile_info1) -{ - get_tile_info(tileinfo, tile_index, 1, m_colorram_A, m_videoram_A, m_videoram2_A); -} - -TILE_GET_INFO_MEMBER(k052109_device::get_tile_info2) -{ - get_tile_info(tileinfo, tile_index, 2, m_colorram_B, m_videoram_B, m_videoram2_B); -} - - -void k052109_device::tileflip_reset() -{ - int data = m_ram[0x1e80]; - m_tilemap[0]->set_flip((data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - m_tilemap[1]->set_flip((data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - m_tilemap[2]->set_flip((data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - m_tileflip_enable = ((data & 0x06) >> 1); -} - - -/***************************************************************************/ -/* */ -/* 051960 */ -/* */ -/***************************************************************************/ - -const device_type K051960 = &device_creator; - -k051960_device::k051960_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, K051960, "Konami 051960", tag, owner, clock, "k051960", __FILE__), - m_ram(NULL), - m_gfx(NULL), - //m_spriterombank[3], - m_dx(0), - m_dy(0), - m_romoffset(0), - m_spriteflip(0), - m_readroms(0), - m_irq_enabled(0), - m_nmi_enabled(0), - m_k051937_counter(0) -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void k051960_device::device_config_complete() -{ - // inherit a copy of the static data - const k051960_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - *static_cast(this) = *intf; - - // or initialize to defaults if none provided - else - { - m_gfx_memory_region = ""; - m_gfx_num = 0; - m_plane_order = 0; - m_deinterleave = 0; - m_callback = NULL; - } -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void k051960_device::device_start() -{ - UINT32 total; - static const gfx_layout spritelayout = - { - 16,16, - 0, - 4, - { 0, 8, 16, 24 }, - { 0, 1, 2, 3, 4, 5, 6, 7, - 8*32+0, 8*32+1, 8*32+2, 8*32+3, 8*32+4, 8*32+5, 8*32+6, 8*32+7 }, - { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, - 16*32, 17*32, 18*32, 19*32, 20*32, 21*32, 22*32, 23*32 }, - 128*8 - }; - static const gfx_layout spritelayout_reverse = - { - 16,16, - 0, - 4, - { 24, 16, 8, 0 }, - { 0, 1, 2, 3, 4, 5, 6, 7, - 8*32+0, 8*32+1, 8*32+2, 8*32+3, 8*32+4, 8*32+5, 8*32+6, 8*32+7 }, - { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, - 16*32, 17*32, 18*32, 19*32, 20*32, 21*32, 22*32, 23*32 }, - 128*8 - }; - static const gfx_layout spritelayout_gradius3 = - { - 16,16, - 0, - 4, - { 0, 1, 2, 3 }, - { 2*4, 3*4, 0*4, 1*4, 6*4, 7*4, 4*4, 5*4, - 32*8+2*4, 32*8+3*4, 32*8+0*4, 32*8+1*4, 32*8+6*4, 32*8+7*4, 32*8+4*4, 32*8+5*4 }, - { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, - 64*8+0*32, 64*8+1*32, 64*8+2*32, 64*8+3*32, 64*8+4*32, 64*8+5*32, 64*8+6*32, 64*8+7*32 }, - 128*8 - }; - - /* decode the graphics */ - switch (m_plane_order) - { - case NORMAL_PLANE_ORDER: - total = machine().root_device().memregion(m_gfx_memory_region)->bytes() / 128; - konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region)->base(), total, &spritelayout, 4); - break; - - case REVERSE_PLANE_ORDER: - total = machine().root_device().memregion(m_gfx_memory_region)->bytes() / 128; - konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region)->base(), total, &spritelayout_reverse, 4); - break; - - case GRADIUS3_PLANE_ORDER: - total = 0x4000; - konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region)->base(), total, &spritelayout_gradius3, 4); - break; - - default: - fatalerror("Unknown plane_order\n"); - } - - if (VERBOSE && !(machine().config().m_video_attributes & VIDEO_HAS_SHADOWS)) - popmessage("driver should use VIDEO_HAS_SHADOWS"); - - /* deinterleave the graphics, if needed */ - konami_deinterleave_gfx(machine(), m_gfx_memory_region, m_deinterleave); - - m_gfx = machine().gfx[m_gfx_num]; - m_ram = auto_alloc_array_clear(machine(), UINT8, 0x400); - - save_item(NAME(m_romoffset)); - save_item(NAME(m_spriteflip)); - save_item(NAME(m_readroms)); - save_item(NAME(m_spriterombank)); - save_pointer(NAME(m_ram), 0x400); - save_item(NAME(m_irq_enabled)); - save_item(NAME(m_nmi_enabled)); - save_item(NAME(m_dx)); - save_item(NAME(m_dy)); - - save_item(NAME(m_k051937_counter)); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void k051960_device::device_reset() -{ - - m_dx = m_dy = 0; - m_k051937_counter = 0; - - m_romoffset = 0; - m_spriteflip = 0; - m_readroms = 0; - m_irq_enabled = 0; - m_nmi_enabled = 0; - - m_spriterombank[0] = 0; - m_spriterombank[1] = 0; - m_spriterombank[2] = 0; -} - - -/***************************************************************************** - DEVICE HANDLERS -*****************************************************************************/ - -int k051960_device::k051960_fetchromdata( int byte ) -{ - int code, color, pri, shadow, off1, addr; - - addr = m_romoffset + (m_spriterombank[0] << 8) + ((m_spriterombank[1] & 0x03) << 16); - code = (addr & 0x3ffe0) >> 5; - off1 = addr & 0x1f; - color = ((m_spriterombank[1] & 0xfc) >> 2) + ((m_spriterombank[2] & 0x03) << 6); - pri = 0; - shadow = color & 0x80; - m_callback(machine(), &code, &color, &pri, &shadow); - - addr = (code << 7) | (off1 << 2) | byte; - addr &= machine().root_device().memregion(m_gfx_memory_region)->bytes() - 1; - -// popmessage("%s: addr %06x", machine().describe_context(), addr); - - return machine().root_device().memregion(m_gfx_memory_region)->base()[addr]; -} - -READ8_MEMBER( k051960_device::k051960_r ) -{ - if (m_readroms) - { - /* the 051960 remembers the last address read and uses it when reading the sprite ROMs */ - m_romoffset = (offset & 0x3fc) >> 2; - return k051960_fetchromdata(offset & 3); /* only 88 Games reads the ROMs from here */ - } - else - return m_ram[offset]; -} - -WRITE8_MEMBER( k051960_device::k051960_w ) -{ - m_ram[offset] = data; -} - -READ16_MEMBER( k051960_device::k051960_word_r ) -{ - return k051960_r(space, offset * 2 + 1) | (k051960_r(space, offset * 2) << 8); -} - -WRITE16_MEMBER( k051960_device::k051960_word_w ) -{ - if (ACCESSING_BITS_8_15) - k051960_w(space, offset * 2, (data >> 8) & 0xff); - if (ACCESSING_BITS_0_7) - k051960_w(space, offset * 2 + 1, data & 0xff); -} - - -/* should this be split by k051960? */ -READ8_MEMBER( k051960_device::k051937_r ) -{ - if (m_readroms && offset >= 4 && offset < 8) - return k051960_fetchromdata(offset & 3); - else - { - if (offset == 0) - { - /* some games need bit 0 to pulse */ - return (m_k051937_counter++) & 1; - } - //logerror("%04x: read unknown 051937 address %x\n", device->cpu->safe_pc(), offset); - return 0; - } - - return 0; -} - -WRITE8_MEMBER( k051960_device::k051937_w ) -{ - if (offset == 0) - { - //if (data & 0xc2) popmessage("051937 reg 00 = %02x",data); - - /* bit 0 is IRQ enable */ - m_irq_enabled = data & 0x01; - - /* bit 1: probably FIRQ enable */ - - /* bit 2 is NMI enable */ - m_nmi_enabled = data & 0x04; - - /* bit 3 = flip screen */ - m_spriteflip = data & 0x08; - - /* bit 4 used by Devastators and TMNT, unknown */ - - /* bit 5 = enable gfx ROM reading */ - m_readroms = data & 0x20; - //logerror("%04x: write %02x to 051937 address %x\n", machine().cpu->safe_pc(), data, offset); - } - else if (offset == 1) - { -// popmessage("%04x: write %02x to 051937 address %x", machine().cpu->safe_pc(), data, offset); -//logerror("%04x: write %02x to unknown 051937 address %x\n", machine().cpu->safe_pc(), data, offset); - } - else if (offset >= 2 && offset < 5) - { - m_spriterombank[offset - 2] = data; - } - else - { - // popmessage("%04x: write %02x to 051937 address %x", machine().cpu->safe_pc(), data, offset); - //logerror("%04x: write %02x to unknown 051937 address %x\n", machine().cpu->safe_pc(), data, offset); - } -} - -int k051960_device::k051960_is_irq_enabled( ) -{ - return m_irq_enabled; -} - -int k051960_device::k051960_is_nmi_enabled( ) -{ - return m_nmi_enabled; -} - -void k051960_device::k051960_set_sprite_offsets( int dx, int dy ) -{ - m_dx = dx; - m_dy = dy; -} - - -READ16_MEMBER( k051960_device::k051937_word_r ) -{ - return k051937_r(space, offset * 2 + 1) | (k051937_r(space, offset * 2) << 8); -} - -WRITE16_MEMBER( k051960_device::k051937_word_w ) -{ - if (ACCESSING_BITS_8_15) - k051937_w(space, offset * 2,(data >> 8) & 0xff); - if (ACCESSING_BITS_0_7) - k051937_w(space, offset * 2 + 1,data & 0xff); -} - -/* - * Sprite Format - * ------------------ - * - * Byte | Bit(s) | Use - * -----+-76543210-+---------------- - * 0 | x------- | active (show this sprite) - * 0 | -xxxxxxx | priority order - * 1 | xxx----- | sprite size (see below) - * 1 | ---xxxxx | sprite code (high 5 bits) - * 2 | xxxxxxxx | sprite code (low 8 bits) - * 3 | xxxxxxxx | "color", but depends on external connections (see below) - * 4 | xxxxxx-- | zoom y (0 = normal, >0 = shrink) - * 4 | ------x- | flip y - * 4 | -------x | y position (high bit) - * 5 | xxxxxxxx | y position (low 8 bits) - * 6 | xxxxxx-- | zoom x (0 = normal, >0 = shrink) - * 6 | ------x- | flip x - * 6 | -------x | x position (high bit) - * 7 | xxxxxxxx | x position (low 8 bits) - * - * Example of "color" field for Punk Shot: - * 3 | x------- | shadow - * 3 | -xx----- | priority - * 3 | ---x---- | use second gfx ROM bank - * 3 | ----xxxx | color code - * - * shadow enables transparent shadows. Note that it applies to pen 0x0f ONLY. - * The rest of the sprite remains normal. - * Note that Aliens also uses the shadow bit to select the second sprite bank. - */ - -void k051960_device::k051960_sprites_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, int min_priority, int max_priority ) -{ -#define NUM_SPRITES 128 - int offs, pri_code; - int sortedlist[NUM_SPRITES]; - UINT8 drawmode_table[256]; - - memset(drawmode_table, DRAWMODE_SOURCE, sizeof(drawmode_table)); - drawmode_table[0] = DRAWMODE_NONE; - - for (offs = 0; offs < NUM_SPRITES; offs++) - sortedlist[offs] = -1; - - /* prebuild a sorted table */ - for (offs = 0; offs < 0x400; offs += 8) - { - if (m_ram[offs] & 0x80) - { - if (max_priority == -1) /* draw front to back when using priority buffer */ - sortedlist[(m_ram[offs] & 0x7f) ^ 0x7f] = offs; - else - sortedlist[m_ram[offs] & 0x7f] = offs; - } - } - - for (pri_code = 0; pri_code < NUM_SPRITES; pri_code++) - { - int ox, oy, code, color, pri, shadow, size, w, h, x, y, flipx, flipy, zoomx, zoomy; - /* sprites can be grouped up to 8x8. The draw order is - 0 1 4 5 16 17 20 21 - 2 3 6 7 18 19 22 23 - 8 9 12 13 24 25 28 29 - 10 11 14 15 26 27 30 31 - 32 33 36 37 48 49 52 53 - 34 35 38 39 50 51 54 55 - 40 41 44 45 56 57 60 61 - 42 43 46 47 58 59 62 63 - */ - static const int xoffset[8] = { 0, 1, 4, 5, 16, 17, 20, 21 }; - static const int yoffset[8] = { 0, 2, 8, 10, 32, 34, 40, 42 }; - static const int width[8] = { 1, 2, 1, 2, 4, 2, 4, 8 }; - static const int height[8] = { 1, 1, 2, 2, 2, 4, 4, 8 }; - - offs = sortedlist[pri_code]; - if (offs == -1) - continue; - - code = m_ram[offs + 2] + ((m_ram[offs + 1] & 0x1f) << 8); - color = m_ram[offs + 3] & 0xff; - pri = 0; - shadow = color & 0x80; - m_callback(machine(), &code, &color, &pri, &shadow); - - if (max_priority != -1) - if (pri < min_priority || pri > max_priority) - continue; - - size = (m_ram[offs + 1] & 0xe0) >> 5; - w = width[size]; - h = height[size]; - - if (w >= 2) code &= ~0x01; - if (h >= 2) code &= ~0x02; - if (w >= 4) code &= ~0x04; - if (h >= 4) code &= ~0x08; - if (w >= 8) code &= ~0x10; - if (h >= 8) code &= ~0x20; - - ox = (256 * m_ram[offs + 6] + m_ram[offs + 7]) & 0x01ff; - oy = 256 - ((256 * m_ram[offs + 4] + m_ram[offs + 5]) & 0x01ff); - ox += m_dx; - oy += m_dy; - flipx = m_ram[offs + 6] & 0x02; - flipy = m_ram[offs + 4] & 0x02; - zoomx = (m_ram[offs + 6] & 0xfc) >> 2; - zoomy = (m_ram[offs + 4] & 0xfc) >> 2; - zoomx = 0x10000 / 128 * (128 - zoomx); - zoomy = 0x10000 / 128 * (128 - zoomy); - - if (m_spriteflip) - { - ox = 512 - (zoomx * w >> 12) - ox; - oy = 256 - (zoomy * h >> 12) - oy; - flipx = !flipx; - flipy = !flipy; - } - - drawmode_table[m_gfx->granularity() - 1] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE; - - if (zoomx == 0x10000 && zoomy == 0x10000) - { - int sx, sy; - - for (y = 0; y < h; y++) - { - sy = oy + 16 * y; - - for (x = 0; x < w; x++) - { - int c = code; - - sx = ox + 16 * x; - if (flipx) - c += xoffset[(w - 1 - x)]; - else - c += xoffset[x]; - - if (flipy) - c += yoffset[(h - 1 - y)]; - else - c += yoffset[y]; - - if (max_priority == -1) - pdrawgfx_transtable(bitmap,cliprect,m_gfx, - c, - color, - flipx,flipy, - sx & 0x1ff,sy, - machine().priority_bitmap,pri, - drawmode_table,machine().shadow_table); - else - drawgfx_transtable(bitmap,cliprect,m_gfx, - c, - color, - flipx,flipy, - sx & 0x1ff,sy, - drawmode_table,machine().shadow_table); - } - } - } - else - { - int sx, sy, zw, zh; - - for (y = 0; y < h; y++) - { - sy = oy + ((zoomy * y + (1 << 11)) >> 12); - zh = (oy + ((zoomy * (y + 1) + (1 << 11)) >> 12)) - sy; - - for (x = 0; x < w; x++) - { - int c = code; - - sx = ox + ((zoomx * x + (1 << 11)) >> 12); - zw = (ox + ((zoomx * (x+1) + (1 << 11)) >> 12)) - sx; - if (flipx) - c += xoffset[(w - 1 - x)]; - else - c += xoffset[x]; - - if (flipy) - c += yoffset[(h - 1 - y)]; - else - c += yoffset[y]; - - if (max_priority == -1) - pdrawgfxzoom_transtable(bitmap,cliprect,m_gfx, - c, - color, - flipx,flipy, - sx & 0x1ff,sy, - (zw << 16) / 16,(zh << 16) / 16, - machine().priority_bitmap,pri, - drawmode_table,machine().shadow_table); - else - drawgfxzoom_transtable(bitmap,cliprect,m_gfx, - c, - color, - flipx,flipy, - sx & 0x1ff,sy, - (zw << 16) / 16,(zh << 16) / 16, - drawmode_table,machine().shadow_table); - } - } - } - } -#if 0 -if (machine().input().code_pressed(KEYCODE_D)) -{ - FILE *fp; - fp=fopen("SPRITE.DMP", "w+b"); - if (fp) - { - fwrite(k051960_ram, 0x400, 1, fp); - popmessage("saved"); - fclose(fp); - } -} -#endif -#undef NUM_SPRITES -} - - -/***************************************************************************/ -/* */ -/* 051316 */ -/* */ -/***************************************************************************/ - -const device_type K051316 = &device_creator; - -k051316_device::k051316_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, K051316, "Konami 051316", tag, owner, clock, "k051316", __FILE__), - m_ram(NULL) - //m_tmap, - //m_ctrlram[16] -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void k051316_device::device_config_complete() -{ - // inherit a copy of the static data - const k051316_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - *static_cast(this) = *intf; - - // or initialize to defaults if none provided - else - { - m_gfx_memory_region_tag = ""; - m_gfx_num = 0; - m_bpp = 0; - m_pen_is_mask = 0; - m_transparent_pen = 0; - m_wrap = 0; - m_xoffs = 0; - m_yoffs = 0; - m_callback = NULL; - } -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void k051316_device::device_start() -{ - int is_tail2nos = 0; - UINT32 total; - - static const gfx_layout charlayout4 = - { - 16,16, - 0, - 4, - { 0, 1, 2, 3 }, - { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4, - 8*4, 9*4, 10*4, 11*4, 12*4, 13*4, 14*4, 15*4 }, - { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64, - 8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 }, - 128*8 - }; - - static const gfx_layout charlayout7 = - { - 16,16, - 0, - 7, - { 1,2,3,4,5,6,7 }, - { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, - 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, - { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128, - 8*128, 9*128, 10*128, 11*128, 12*128, 13*128, 14*128, 15*128 }, - 256*8 - }; - - static const gfx_layout charlayout8 = - { - 16,16, - 0, - 8, - { 0,1,2,3,4,5,6,7 }, - { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, - 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, - { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128, - 8*128, 9*128, 10*128, 11*128, 12*128, 13*128, 14*128, 15*128 }, - 256*8 - }; - - static const gfx_layout charlayout_tail2nos = - { - 16,16, - 0, - 4, - { 0, 1, 2, 3 }, - { XOR(0)*4, XOR(1)*4, XOR(2)*4, XOR(3)*4, XOR(4)*4, XOR(5)*4, XOR(6)*4, XOR(7)*4, - XOR(8)*4, XOR(9)*4, XOR(10)*4, XOR(11)*4, XOR(12)*4, XOR(13)*4, XOR(14)*4, XOR(15)*4 }, - { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64, - 8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 }, - 128*8 - }; - - /* decode the graphics */ - switch (m_bpp) - { - case -4: - total = 0x400; - is_tail2nos = 1; - konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region_tag)->base(), total, &charlayout_tail2nos, 4); - break; - - case 4: - total = machine().root_device().memregion(m_gfx_memory_region_tag)->bytes() / 128; - konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region_tag)->base(), total, &charlayout4, 4); - break; - - case 7: - total = machine().root_device().memregion(m_gfx_memory_region_tag)->bytes() / 256; - konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region_tag)->base(), total, &charlayout7, 7); - break; - - case 8: - total = machine().root_device().memregion(m_gfx_memory_region_tag)->bytes() / 256; - konami_decode_gfx(machine(), m_gfx_num, machine().root_device().memregion(m_gfx_memory_region_tag)->base(), total, &charlayout8, 8); - break; - - default: - fatalerror("Unsupported bpp\n"); - } - - m_bpp = is_tail2nos ? 4 : m_bpp; // tail2nos is passed with bpp = -4 to setup the custom charlayout! - - m_tmap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k051316_device::get_tile_info0),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); - - m_ram = auto_alloc_array_clear(machine(), UINT8, 0x800); - - if (!m_pen_is_mask) - m_tmap->set_transparent_pen(m_transparent_pen); - else - { - m_tmap->map_pens_to_layer(0, 0, 0, TILEMAP_PIXEL_LAYER1); - m_tmap->map_pens_to_layer(0, m_transparent_pen, m_transparent_pen, TILEMAP_PIXEL_LAYER0); - } - - save_pointer(NAME(m_ram), 0x800); - save_item(NAME(m_ctrlram)); - save_item(NAME(m_wrap)); - -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void k051316_device::device_reset() -{ - memset(m_ctrlram, 0, 0x10); -} - -/***************************************************************************** - DEVICE HANDLERS -*****************************************************************************/ - -READ8_MEMBER( k051316_device::read ) -{ - return m_ram[offset]; -} - -WRITE8_MEMBER( k051316_device::write ) -{ - m_ram[offset] = data; - m_tmap->mark_tile_dirty(offset & 0x3ff); -} - - -READ8_MEMBER( k051316_device::rom_r ) -{ - if ((m_ctrlram[0x0e] & 0x01) == 0) - { - int addr = offset + (m_ctrlram[0x0c] << 11) + (m_ctrlram[0x0d] << 19); - if (m_bpp <= 4) - addr /= 2; - addr &= space.machine().root_device().memregion(m_gfx_memory_region_tag)->bytes() - 1; - - // popmessage("%s: offset %04x addr %04x", space.machine().describe_context(), offset, addr); - - return space.machine().root_device().memregion(m_gfx_memory_region_tag)->base()[addr]; - } - else - { - //logerror("%s: read 051316 ROM offset %04x but reg 0x0c bit 0 not clear\n", space.machine().describe_context(), offset); - return 0; - } -} - -WRITE8_MEMBER( k051316_device::ctrl_w ) -{ - m_ctrlram[offset] = data; - //if (offset >= 0x0c) logerror("%s: write %02x to 051316 reg %x\n", space.machine().describe_context(), data, offset); -} - -// a few games (ajax, rollerg, ultraman, etc.) can enable and disable wraparound after start -void k051316_device::wraparound_enable( int status ) -{ - m_wrap = status; -} - -/*************************************************************************** - - Callbacks for the TileMap code - -***************************************************************************/ - -void k051316_device::get_tile_info( tile_data &tileinfo, int tile_index ) -{ - int code = m_ram[tile_index]; - int color = m_ram[tile_index + 0x400]; - int flags = 0; - - m_callback(machine(), &code, &color, &flags); - - SET_TILE_INFO_MEMBER( - m_gfx_num, - code, - color, - flags); -} - - -TILE_GET_INFO_MEMBER(k051316_device::get_tile_info0) { get_tile_info(tileinfo, tile_index); } - - -void k051316_device::zoom_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, int flags, UINT32 priority ) -{ - UINT32 startx, starty; - int incxx, incxy, incyx, incyy; - - startx = 256 * ((INT16)(256 * m_ctrlram[0x00] + m_ctrlram[0x01])); - incxx = (INT16)(256 * m_ctrlram[0x02] + m_ctrlram[0x03]); - incyx = (INT16)(256 * m_ctrlram[0x04] + m_ctrlram[0x05]); - starty = 256 * ((INT16)(256 * m_ctrlram[0x06] + m_ctrlram[0x07])); - incxy = (INT16)(256 * m_ctrlram[0x08] + m_ctrlram[0x09]); - incyy = (INT16)(256 * m_ctrlram[0x0a] + m_ctrlram[0x0b]); - - startx -= (16 + m_yoffs) * incyx; - starty -= (16 + m_yoffs) * incyy; - - startx -= (89 + m_xoffs) * incxx; - starty -= (89 + m_xoffs) * incxy; - - m_tmap->draw_roz(bitmap, cliprect, startx << 5,starty << 5, - incxx << 5,incxy << 5,incyx << 5,incyy << 5, - m_wrap, - flags,priority); - -#if 0 - popmessage("%02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x", - m_ctrlram[0x00], - m_ctrlram[0x01], - m_ctrlram[0x02], - m_ctrlram[0x03], - m_ctrlram[0x04], - m_ctrlram[0x05], - m_ctrlram[0x06], - m_ctrlram[0x07], - m_ctrlram[0x08], - m_ctrlram[0x09], - m_ctrlram[0x0a], - m_ctrlram[0x0b], - m_ctrlram[0x0c], /* bank for ROM testing */ - m_ctrlram[0x0d], - m_ctrlram[0x0e], /* 0 = test ROMs */ - m_ctrlram[0x0f]); -#endif -} - - -/***************************************************************************/ -/* */ -/* 053251 */ -/* */ -/***************************************************************************/ - -const device_type K053251 = &device_creator; - -k053251_device::k053251_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, K053251, "Konami 053251", tag, owner, clock, "k053251", __FILE__), - //m_dirty_tmap[5], - //m_ram[16], - m_tilemaps_set(0) - //m_palette_index[5] -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void k053251_device::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void k053251_device::device_start() -{ - save_item(NAME(m_ram)); - save_item(NAME(m_tilemaps_set)); - save_item(NAME(m_dirty_tmap)); - - machine().save().register_postload(save_prepost_delegate(FUNC(k053251_device::reset_indexes), this)); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void k053251_device::device_reset() -{ - int i; - - m_tilemaps_set = 0; - - for (i = 0; i < 0x10; i++) - m_ram[i] = 0; - - for (i = 0; i < 5; i++) - m_dirty_tmap[i] = 0; -} - -/***************************************************************************** - DEVICE HANDLERS -*****************************************************************************/ - -WRITE8_MEMBER( k053251_device::write ) -{ - int i, newind; - - data &= 0x3f; - - if (m_ram[offset] != data) - { - m_ram[offset] = data; - if (offset == 9) - { - /* palette base index */ - for (i = 0; i < 3; i++) - { - newind = 32 * ((data >> 2 * i) & 0x03); - if (m_palette_index[i] != newind) - { - m_palette_index[i] = newind; - m_dirty_tmap[i] = 1; - } - } - - if (!m_tilemaps_set) - space.machine().tilemap().mark_all_dirty(); - } - else if (offset == 10) - { - /* palette base index */ - for (i = 0; i < 2; i++) - { - newind = 16 * ((data >> 3 * i) & 0x07); - if (m_palette_index[3 + i] != newind) - { - m_palette_index[3 + i] = newind; - m_dirty_tmap[3 + i] = 1; - } - } - - if (!m_tilemaps_set) - space.machine().tilemap().mark_all_dirty(); - } - } -} - -WRITE16_MEMBER( k053251_device::lsb_w ) -{ - if (ACCESSING_BITS_0_7) - write(space, offset, data & 0xff); -} - -WRITE16_MEMBER( k053251_device::msb_w ) -{ - if (ACCESSING_BITS_8_15) - write(space, offset, (data >> 8) & 0xff); -} - -int k053251_device::get_priority( int ci ) -{ - return m_ram[ci]; -} - -int k053251_device::get_palette_index( int ci ) -{ - return m_palette_index[ci]; -} - -int k053251_device::get_tmap_dirty( int tmap_num ) -{ - assert(tmap_num < 5); - return m_dirty_tmap[tmap_num]; -} - -void k053251_device::set_tmap_dirty( int tmap_num, int data ) -{ - assert(tmap_num < 5); - m_dirty_tmap[tmap_num] = data ? 1 : 0; -} - -void k053251_device::reset_indexes() -{ - m_palette_index[0] = 32 * ((m_ram[9] >> 0) & 0x03); - m_palette_index[1] = 32 * ((m_ram[9] >> 2) & 0x03); - m_palette_index[2] = 32 * ((m_ram[9] >> 4) & 0x03); - m_palette_index[3] = 16 * ((m_ram[10] >> 0) & 0x07); - m_palette_index[4] = 16 * ((m_ram[10] >> 3) & 0x07); -} - -// debug handlers - -READ16_MEMBER( k053251_device::lsb_r ) -{ - return(m_ram[offset]); -} // PCU1 - -READ16_MEMBER( k053251_device::msb_r ) -{ - return(m_ram[offset] << 8); -} // PCU1 - - -/***************************************************************************/ -/* */ -/* 051733 */ -/* */ -/***************************************************************************/ - -const device_type K051733 = &device_creator; - -k051733_device::k051733_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, K051733, "Konami 051733", tag, owner, clock, "k051733", __FILE__), - //m_ram[0x20], - m_rng(0) -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void k051733_device::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void k051733_device::device_start() -{ - save_item(NAME(m_ram)); - save_item(NAME(m_rng)); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void k051733_device::device_reset() -{ - int i; - - for (i = 0; i < 0x20; i++) - m_ram[i] = 0; - - m_rng = 0; -} - -/***************************************************************************** - DEVICE HANDLERS -*****************************************************************************/ - -WRITE8_MEMBER( k051733_device::write ) -{ - //logerror("%04x: write %02x to 051733 address %02x\n", space.device().safe_pc(), data, offset); - - m_ram[offset] = data; -} - - -static int k051733_int_sqrt( UINT32 op ) -{ - UINT32 i = 0x8000; - UINT32 step = 0x4000; - - while (step) - { - if (i * i == op) - return i; - else if (i * i > op) - i -= step; - else - i += step; - step >>= 1; - } - return i; -} - -READ8_MEMBER( k051733_device::read ) -{ - int op1 = (m_ram[0x00] << 8) | m_ram[0x01]; - int op2 = (m_ram[0x02] << 8) | m_ram[0x03]; - int op3 = (m_ram[0x04] << 8) | m_ram[0x05]; - - int rad = (m_ram[0x06] << 8) | m_ram[0x07]; - int yobj1c = (m_ram[0x08] << 8) | m_ram[0x09]; - int xobj1c = (m_ram[0x0a] << 8) | m_ram[0x0b]; - int yobj2c = (m_ram[0x0c] << 8) | m_ram[0x0d]; - int xobj2c = (m_ram[0x0e] << 8) | m_ram[0x0f]; - - switch (offset) - { - case 0x00: - if (op2) - return (op1 / op2) >> 8; - else - return 0xff; - case 0x01: - if (op2) - return (op1 / op2) & 0xff; - else - return 0xff; - - /* this is completely unverified */ - case 0x02: - if (op2) - return (op1 % op2) >> 8; - else - return 0xff; - case 0x03: - if (op2) - return (op1 % op2) & 0xff; - else - return 0xff; - - case 0x04: - return k051733_int_sqrt(op3 << 16) >> 8; - - case 0x05: - return k051733_int_sqrt(op3 << 16) & 0xff; - - case 0x06: - m_rng += m_ram[0x13]; - return m_rng; //RNG read, used by Chequered Flag for differentiate cars, implementation is a raw guess - - case 0x07:{ /* note: Chequered Flag definitely wants all these bits to be enabled */ - if (xobj1c + rad < xobj2c) - return 0xff; - - if (xobj2c + rad < xobj1c) - return 0xff; - - if (yobj1c + rad < yobj2c) - return 0xff; - - if (yobj2c + rad < yobj1c) - return 0xff; - - return 0; - } - case 0x0e: /* best guess */ - return (xobj2c - xobj1c) >> 8; - case 0x0f: - return (xobj2c - xobj1c) & 0xff; - default: - return m_ram[offset]; - } -} - - - // Newer Konami devices // from video/gticlub.c @@ -3504,171 +321,17 @@ READ8_MEMBER( k051733_device::read ) /* */ /***************************************************************************/ -struct k001006_state -{ - screen_device *screen; - - UINT16 * pal_ram; - UINT16 * unknown_ram; - UINT32 addr; - int device_sel; - - UINT32 * palette; - - const char *gfx_region; -}; - -/***************************************************************************** - INLINE FUNCTIONS -*****************************************************************************/ - -INLINE k001006_state *k001006_get_safe_token( device_t *device ) -{ - assert(device != NULL); - assert(device->type() == K001006); - - return (k001006_state *)downcast(device)->token(); -} - -INLINE const k001006_interface *k001006_get_interface( device_t *device ) -{ - assert(device != NULL); - assert((device->type() == K001006)); - return (const k001006_interface *) device->static_config(); -} - -/***************************************************************************** - DEVICE HANDLERS -*****************************************************************************/ - -READ32_DEVICE_HANDLER( k001006_r ) -{ - k001006_state *k001006 = k001006_get_safe_token(device); - - if (offset == 1) - { - switch (k001006->device_sel) - { - case 0x0b: // CG Board ROM read - { - UINT16 *rom = (UINT16*)space.machine().root_device().memregion(k001006->gfx_region)->base(); - return rom[k001006->addr / 2] << 16; - } - case 0x0d: // Palette RAM read - { - UINT32 addr = k001006->addr; - - k001006->addr += 2; - return k001006->pal_ram[addr >> 1]; - } - case 0x0f: // Unknown RAM read - { - return k001006->unknown_ram[k001006->addr++]; - } - default: - { - fatalerror("k001006_r, unknown device %02X\n", k001006->device_sel); - } - } - } - return 0; -} - -WRITE32_DEVICE_HANDLER( k001006_w ) -{ - k001006_state *k001006 = k001006_get_safe_token(device); - - if (offset == 0) - { - COMBINE_DATA(&k001006->addr); - } - else if (offset == 1) - { - switch (k001006->device_sel) - { - case 0xd: // Palette RAM write - { - int r, g, b, a; - UINT32 index = k001006->addr; - - k001006->pal_ram[index >> 1] = data & 0xffff; - - a = (data & 0x8000) ? 0x00 : 0xff; - b = ((data >> 10) & 0x1f) << 3; - g = ((data >> 5) & 0x1f) << 3; - r = ((data >> 0) & 0x1f) << 3; - b |= (b >> 5); - g |= (g >> 5); - r |= (r >> 5); - k001006->palette[index >> 1] = MAKE_ARGB(a, r, g, b); - - k001006->addr += 2; - break; - } - case 0xf: // Unknown RAM write - { - // mame_printf_debug("Unknown RAM %08X = %04X\n", k001006->addr, data & 0xffff); - k001006->unknown_ram[k001006->addr++] = data & 0xffff; - break; - } - default: - { - mame_printf_debug("k001006_w: device %02X, write %04X to %08X\n", k001006->device_sel, data & 0xffff, k001006->addr++); - } - } - } - else if (offset == 2) - { - if (ACCESSING_BITS_16_31) - { - k001006->device_sel = (data >> 16) & 0xf; - } - } -} - -UINT32 k001006_get_palette( device_t *device, int index ) -{ - k001006_state *k001006 = k001006_get_safe_token(device); - return k001006->palette[index]; -} - -/***************************************************************************** - DEVICE INTERFACE -*****************************************************************************/ - -static DEVICE_START( k001006 ) -{ - k001006_state *k001006 = k001006_get_safe_token(device); - const k001006_interface *intf = k001006_get_interface(device); - - k001006->pal_ram = auto_alloc_array_clear(device->machine(), UINT16, 0x800); - k001006->unknown_ram = auto_alloc_array_clear(device->machine(), UINT16, 0x1000); - k001006->palette = auto_alloc_array(device->machine(), UINT32, 0x800); - - k001006->gfx_region = intf->gfx_region; - - device->save_pointer(NAME(k001006->pal_ram), 0x800*sizeof(UINT16)); - device->save_pointer(NAME(k001006->unknown_ram), 0x1000*sizeof(UINT16)); - device->save_pointer(NAME(k001006->palette), 0x800*sizeof(UINT32)); - device->save_item(NAME(k001006->device_sel)); - device->save_item(NAME(k001006->addr)); -} - -static DEVICE_RESET( k001006 ) -{ - k001006_state *k001006 = k001006_get_safe_token(device); - - k001006->addr = 0; - k001006->device_sel = 0; - memset(k001006->palette, 0, 0x800*sizeof(UINT32)); -} - const device_type K001006 = &device_creator; k001006_device::k001006_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, K001006, "Konami 001006", tag, owner, clock, "k001006", __FILE__) + : device_t(mconfig, K001006, "Konami 001006", tag, owner, clock, "k001006", __FILE__), + m_screen(NULL), + m_pal_ram(NULL), + m_unknown_ram(NULL), + m_addr(0), + m_device_sel(0), + m_palette(NULL) { - m_token = global_alloc_clear(k001006_state); } //------------------------------------------------- @@ -3679,6 +342,16 @@ k001006_device::k001006_device(const machine_config &mconfig, const char *tag, d void k001006_device::device_config_complete() { + // inherit a copy of the static data + const k001006_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + m_gfx_region = ""; + } } //------------------------------------------------- @@ -3687,7 +360,15 @@ void k001006_device::device_config_complete() void k001006_device::device_start() { - DEVICE_START_NAME( k001006 )(this); + m_pal_ram = auto_alloc_array_clear(machine(), UINT16, 0x800); + m_unknown_ram = auto_alloc_array_clear(machine(), UINT16, 0x1000); + m_palette = auto_alloc_array_clear(machine(), UINT32, 0x800); + + save_pointer(NAME(m_pal_ram), 0x800*sizeof(UINT16)); + save_pointer(NAME(m_unknown_ram), 0x1000*sizeof(UINT16)); + save_pointer(NAME(m_palette), 0x800*sizeof(UINT32)); + save_item(NAME(m_device_sel)); + save_item(NAME(m_addr)); } //------------------------------------------------- @@ -3696,9 +377,102 @@ void k001006_device::device_start() void k001006_device::device_reset() { - DEVICE_RESET_NAME( k001006 )(this); + m_addr = 0; + m_device_sel = 0; + memset(m_palette, 0, 0x800*sizeof(UINT32)); } +/***************************************************************************** + DEVICE HANDLERS +*****************************************************************************/ + +READ32_MEMBER( k001006_device::read ) +{ + if (offset == 1) + { + switch (m_device_sel) + { + case 0x0b: // CG Board ROM read + { + UINT16 *rom = (UINT16*)space.machine().root_device().memregion(m_gfx_region)->base(); + return rom[m_addr / 2] << 16; + } + case 0x0d: // Palette RAM read + { + UINT32 addr = m_addr; + + m_addr += 2; + return m_pal_ram[addr >> 1]; + } + case 0x0f: // Unknown RAM read + { + return m_unknown_ram[m_addr++]; + } + default: + { + fatalerror("k001006_r, unknown device %02X\n", m_device_sel); + } + } + } + return 0; +} + +WRITE32_MEMBER( k001006_device::write ) +{ + if (offset == 0) + { + COMBINE_DATA(&m_addr); + } + else if (offset == 1) + { + switch (m_device_sel) + { + case 0xd: // Palette RAM write + { + int r, g, b, a; + UINT32 index = m_addr; + + m_pal_ram[index >> 1] = data & 0xffff; + + a = (data & 0x8000) ? 0x00 : 0xff; + b = ((data >> 10) & 0x1f) << 3; + g = ((data >> 5) & 0x1f) << 3; + r = ((data >> 0) & 0x1f) << 3; + b |= (b >> 5); + g |= (g >> 5); + r |= (r >> 5); + m_palette[index >> 1] = MAKE_ARGB(a, r, g, b); + + m_addr += 2; + break; + } + case 0xf: // Unknown RAM write + { + // mame_printf_debug("Unknown RAM %08X = %04X\n", m_addr, data & 0xffff); + m_unknown_ram[m_addr++] = data & 0xffff; + break; + } + default: + { + mame_printf_debug("k001006_w: device %02X, write %04X to %08X\n", m_device_sel, data & 0xffff, m_addr++); + } + } + } + else if (offset == 2) + { + if (ACCESSING_BITS_16_31) + { + m_device_sel = (data >> 16) & 0xf; + } + } +} + +UINT32 k001006_device::get_palette( int index ) +{ + return m_palette[index]; +} + + /*****************************************************************************/ /* Konami K001005 Custom 3D Pixel Renderer chip (KS10071) */ @@ -5145,230 +1919,3 @@ void k001604_device::device_reset() memset(k001604->tile_ram, 0, 0x10000); memset(k001604->reg, 0, 0x400); } - - -// from drivers/hornet.c - -/***************************************************************************/ -/* */ -/* 037122 */ -/* */ -/***************************************************************************/ - -#define K037122_NUM_TILES 16384 - -const device_type K037122 = &device_creator; - -k037122_device::k037122_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, K037122, "Konami 0371222", tag, owner, clock, "k037122", __FILE__), - m_screen(NULL), - m_tile_ram(NULL), - m_char_ram(NULL), - m_reg(NULL) -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void k037122_device::device_config_complete() -{ - // inherit a copy of the static data - const k037122_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - *static_cast(this) = *intf; - - // or initialize to defaults if none provided - else - { - m_screen_tag = ""; - m_gfx_index = 0; - } -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void k037122_device::device_start() -{ - static const gfx_layout k037122_char_layout = - { - 8, 8, - K037122_NUM_TILES, - 8, - { 0,1,2,3,4,5,6,7 }, - { 1*16, 0*16, 3*16, 2*16, 5*16, 4*16, 7*16, 6*16 }, - { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128 }, - 8*128 - }; - - m_screen = machine().device(m_screen_tag); - - m_char_ram = auto_alloc_array_clear(machine(), UINT32, 0x200000 / 4); - m_tile_ram = auto_alloc_array_clear(machine(), UINT32, 0x20000 / 4); - m_reg = auto_alloc_array_clear(machine(), UINT32, 0x400 / 4); - - m_layer[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k037122_device::tile_info_layer0),this), TILEMAP_SCAN_ROWS, 8, 8, 256, 64); - m_layer[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(k037122_device::tile_info_layer1),this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); - - m_layer[0]->set_transparent_pen(0); - m_layer[1]->set_transparent_pen(0); - - machine().gfx[m_gfx_index] = auto_alloc_clear(machine(), gfx_element(machine(), k037122_char_layout, (UINT8*)m_char_ram, machine().total_colors() / 16, 0)); - - save_pointer(NAME(m_reg), 0x400 / 4); - save_pointer(NAME(m_char_ram), 0x200000 / 4); - save_pointer(NAME(m_tile_ram), 0x20000 / 4); - -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void k037122_device::device_reset() -{ - memset(m_char_ram, 0, 0x200000); - memset(m_tile_ram, 0, 0x20000); - memset(m_reg, 0, 0x400); -} - -/***************************************************************************** - DEVICE HANDLERS -*****************************************************************************/ - -TILE_GET_INFO_MEMBER(k037122_device::tile_info_layer0) -{ - UINT32 val = m_tile_ram[tile_index + (0x8000/4)]; - int color = (val >> 17) & 0x1f; - int tile = val & 0x3fff; - int flags = 0; - - if (val & 0x400000) - flags |= TILE_FLIPX; - if (val & 0x800000) - flags |= TILE_FLIPY; - - SET_TILE_INFO_MEMBER(m_gfx_index, tile, color, flags); -} - -TILE_GET_INFO_MEMBER(k037122_device::tile_info_layer1) -{ - UINT32 val = m_tile_ram[tile_index]; - int color = (val >> 17) & 0x1f; - int tile = val & 0x3fff; - int flags = 0; - - if (val & 0x400000) - flags |= TILE_FLIPX; - if (val & 0x800000) - flags |= TILE_FLIPY; - - SET_TILE_INFO_MEMBER(m_gfx_index, tile, color, flags); -} - - -void k037122_device::tile_draw( bitmap_rgb32 &bitmap, const rectangle &cliprect ) -{ - const rectangle &visarea = m_screen->visible_area(); - - if (m_reg[0xc] & 0x10000) - { - m_layer[1]->set_scrolldx(visarea.min_x, visarea.min_x); - m_layer[1]->set_scrolldy(visarea.min_y, visarea.min_y); - m_layer[1]->draw(bitmap, cliprect, 0, 0); - } - else - { - m_layer[0]->set_scrolldx(visarea.min_x, visarea.min_x); - m_layer[0]->set_scrolldy(visarea.min_y, visarea.min_y); - m_layer[0]->draw(bitmap, cliprect, 0, 0); - } -} - -void k037122_device::update_palette_color( UINT32 palette_base, int color ) -{ - UINT32 data = m_tile_ram[(palette_base / 4) + color]; - - palette_set_color_rgb(machine(), color, pal5bit(data >> 6), pal6bit(data >> 0), pal5bit(data >> 11)); -} - -READ32_MEMBER( k037122_device::sram_r ) -{ - return m_tile_ram[offset]; -} - -WRITE32_MEMBER( k037122_device::sram_w ) -{ - COMBINE_DATA(m_tile_ram + offset); - - if (m_reg[0xc] & 0x10000) - { - if (offset < 0x8000 / 4) - { - m_layer[1]->mark_tile_dirty(offset); - } - else if (offset >= 0x8000 / 4 && offset < 0x18000 / 4) - { - m_layer[0]->mark_tile_dirty(offset - (0x8000 / 4)); - } - else if (offset >= 0x18000 / 4) - { - update_palette_color(0x18000, offset - (0x18000 / 4)); - } - } - else - { - if (offset < 0x8000 / 4) - { - update_palette_color(0, offset); - } - else if (offset >= 0x8000 / 4 && offset < 0x18000 / 4) - { - m_layer[0]->mark_tile_dirty(offset - (0x8000 / 4)); - } - else if (offset >= 0x18000 / 4) - { - m_layer[1]->mark_tile_dirty(offset - (0x18000 / 4)); - } - } -} - - -READ32_MEMBER( k037122_device::char_r ) -{ - int bank = m_reg[0x30 / 4] & 0x7; - - return m_char_ram[offset + (bank * (0x40000 / 4))]; -} - -WRITE32_MEMBER( k037122_device::char_w ) -{ - int bank = m_reg[0x30 / 4] & 0x7; - UINT32 addr = offset + (bank * (0x40000/4)); - - COMBINE_DATA(m_char_ram + addr); - space.machine().gfx[m_gfx_index]->mark_dirty(addr / 32); -} - -READ32_MEMBER( k037122_device::reg_r ) -{ - switch (offset) - { - case 0x14/4: - { - return 0x000003fa; - } - } - return m_reg[offset]; -} - -WRITE32_MEMBER( k037122_device::reg_w ) -{ - COMBINE_DATA(m_reg + offset); -} - diff --git a/src/mame/video/konicdev.h b/src/mame/video/konicdev.h index d15229881ee..327f7cc2f81 100644 --- a/src/mame/video/konicdev.h +++ b/src/mame/video/konicdev.h @@ -16,59 +16,9 @@ TYPE DEFINITIONS ***************************************************************************/ -typedef void (*k007342_callback)(running_machine &machine, int tmap, int bank, int *code, int *color, int *flags); -typedef void (*k007420_callback)(running_machine &machine, int *code, int *color); -typedef void (*k052109_callback)(running_machine &machine, int layer, int bank, int *code, int *color, int *flags, int *priority); -typedef void (*k051960_callback)(running_machine &machine, int *code, int *color, int *priority, int *shadow); -typedef void (*k051316_callback)(running_machine &machine, int *code, int *color, int *flags); - - -struct k007342_interface -{ - int m_gfxnum; - k007342_callback m_callback; -}; - -struct k007420_interface -{ - int m_banklimit; - k007420_callback m_callback; -}; - -struct k052109_interface -{ - const char *m_gfx_memory_region; - int m_gfx_num; - int m_plane_order; - int m_deinterleave; - k052109_callback m_callback; -}; - -struct k051960_interface -{ - const char *m_gfx_memory_region; - int m_gfx_num; - int m_plane_order; - int m_deinterleave; - k051960_callback m_callback; -}; - - -struct k051316_interface -{ - const char *m_gfx_memory_region_tag; - int m_gfx_num; - int m_bpp, m_pen_is_mask, m_transparent_pen; - int m_wrap, m_xoffs, m_yoffs; - k051316_callback m_callback; -}; - - - - struct k001006_interface { - const char *gfx_region; + const char *m_gfx_region; }; struct k001005_interface @@ -93,400 +43,34 @@ struct k001604_interface int roz_mem_offset; }; -struct k037122_interface -{ - const char *m_screen_tag; - int m_gfx_index; -}; - -class k007121_device : public device_t -{ -public: - k007121_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~k007121_device() {} - - DECLARE_READ8_MEMBER( ctrlram_r ); - DECLARE_WRITE8_MEMBER( ctrl_w ); - - /* shall we move source in the interface? */ - /* also notice that now we directly pass *gfx[chip] instead of **gfx !! */ - void sprites_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx, colortable_t *ctable, const UINT8 *source, int base_color, int global_x_offset, int bank_base, UINT32 pri_mask ); - -protected: - // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - virtual void device_reset(); - -private: - // internal state - UINT8 m_ctrlram[8]; - int m_flipscreen; -}; - -extern const device_type K007121; - -class k007342_device : public device_t, - public k007342_interface -{ -public: - k007342_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~k007342_device() {} - - DECLARE_READ8_MEMBER( read ); - DECLARE_WRITE8_MEMBER( write ); - DECLARE_READ8_MEMBER( scroll_r ); - DECLARE_WRITE8_MEMBER( scroll_w ); - DECLARE_WRITE8_MEMBER( vreg_w ); - - void tilemap_update(); - void tilemap_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int num, int flags, UINT32 priority); - int is_int_enabled(); - -protected: - // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - virtual void device_reset(); -private: - // internal state - UINT8 *m_ram; - UINT8 *m_scroll_ram; - UINT8 *m_videoram_0; - UINT8 *m_videoram_1; - UINT8 *m_colorram_0; - UINT8 *m_colorram_1; - - tilemap_t *m_tilemap[2]; - int m_flipscreen, m_int_enabled; - UINT8 m_regs[8]; - UINT16 m_scrollx[2]; - UINT8 m_scrolly[2]; - - TILEMAP_MAPPER_MEMBER(scan); - TILE_GET_INFO_MEMBER(get_tile_info0); - TILE_GET_INFO_MEMBER(get_tile_info1); - void get_tile_info( tile_data &tileinfo, int tile_index, int layer, UINT8 *cram, UINT8 *vram ); -}; - -extern const device_type K007342; - -class k007420_device : public device_t, - public k007420_interface -{ -public: - k007420_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~k007420_device() {} - - DECLARE_READ8_MEMBER( read ); - DECLARE_WRITE8_MEMBER( write ); - void sprites_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx); - -protected: - // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - virtual void device_reset(); -private: - // internal state - UINT8 *m_ram; - - int m_flipscreen; // current code uses the 7342 flipscreen!! - UINT8 m_regs[8]; // current code uses the 7342 regs!! (only [2]) -}; - -extern const device_type K007420; - -class k052109_device : public device_t, - public k052109_interface -{ -public: - k052109_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~k052109_device() {} - - /* - You don't have to decode the graphics: the vh_start() routines will do that - for you, using the plane order passed. - Of course the ROM data must be in the correct order. This is a way to ensure - that the ROM test will pass. - The konami_rom_deinterleave() function above will do the reorganization for - you in most cases (but see tmnt.c for additional bit rotations or byte - permutations which may be required). - */ - #define NORMAL_PLANE_ORDER 0x0123 - #define REVERSE_PLANE_ORDER 0x3210 - #define GRADIUS3_PLANE_ORDER 0x1111 - #define TASMAN_PLANE_ORDER 0x1616 - - /* - The callback is passed: - - layer number (0 = FIX, 1 = A, 2 = B) - - bank (range 0-3, output of the pins CAB1 and CAB2) - - code (range 00-FF, output of the pins VC3-VC10) - NOTE: code is in the range 0000-FFFF for X-Men, which uses extra RAM - - color (range 00-FF, output of the pins COL0-COL7) - The callback must put: - - in code the resulting tile number - - in color the resulting color index - - if necessary, put flags and/or priority for the TileMap code in the tile_info - structure (e.g. TILE_FLIPX). Note that TILE_FLIPY is handled internally by the - chip so it must not be set by the callback. - */ - - DECLARE_READ8_MEMBER( read ); - DECLARE_WRITE8_MEMBER( write ); - DECLARE_READ16_MEMBER( word_r ); - DECLARE_WRITE16_MEMBER( word_w ); - DECLARE_READ16_MEMBER( lsb_r ); - DECLARE_WRITE16_MEMBER( lsb_w ); - - void set_rmrd_line(int state); - int get_rmrd_line(); - void tilemap_update(); - int is_irq_enabled(); - void set_layer_offsets(int layer, int dx, int dy); - void tilemap_mark_dirty(int tmap_num); - void tilemap_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int tmap_num, UINT32 flags, UINT8 priority); - -protected: - // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - virtual void device_reset(); -private: - // internal state - UINT8 *m_ram; - UINT8 *m_videoram_F; - UINT8 *m_videoram_A; - UINT8 *m_videoram_B; - UINT8 *m_videoram2_F; - UINT8 *m_videoram2_A; - UINT8 *m_videoram2_B; - UINT8 *m_colorram_F; - UINT8 *m_colorram_A; - UINT8 *m_colorram_B; - - tilemap_t *m_tilemap[3]; - int m_tileflip_enable; - UINT8 m_charrombank[4]; - UINT8 m_charrombank_2[4]; - UINT8 m_has_extra_video_ram; - INT32 m_rmrd_line; - UINT8 m_irq_enabled; - INT32 m_dx[3], m_dy[3]; - UINT8 m_romsubbank, m_scrollctrl; - - TILE_GET_INFO_MEMBER(get_tile_info0); - TILE_GET_INFO_MEMBER(get_tile_info1); - TILE_GET_INFO_MEMBER(get_tile_info2); - - void get_tile_info( tile_data &tileinfo, int tile_index, int layer, UINT8 *cram, UINT8 *vram1, UINT8 *vram2 ); - void tileflip_reset(); -}; - -extern const device_type K052109; - -class k051960_device : public device_t, - public k051960_interface -{ -public: - k051960_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~k051960_device() {} - - /* - The callback is passed: - - code (range 00-1FFF, output of the pins CA5-CA17) - - color (range 00-FF, output of the pins OC0-OC7). Note that most of the - time COL7 seems to be "shadow", but not always (e.g. Aliens). - The callback must put: - - in code the resulting sprite number - - in color the resulting color index - - if necessary, in priority the priority of the sprite wrt tilemaps - - if necessary, alter shadow to indicate whether the sprite has shadows enabled. - shadow is preloaded with color & 0x80 so it doesn't need to be changed unless - the game has special treatment (Aliens) - */ - - DECLARE_READ8_MEMBER( k051960_r ); - DECLARE_WRITE8_MEMBER( k051960_w ); - DECLARE_READ16_MEMBER( k051960_word_r ); - DECLARE_WRITE16_MEMBER( k051960_word_w ); - - DECLARE_READ8_MEMBER( k051937_r ); - DECLARE_WRITE8_MEMBER( k051937_w ); - DECLARE_READ16_MEMBER( k051937_word_r ); - DECLARE_WRITE16_MEMBER( k051937_word_w ); - - void k051960_sprites_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int min_priority, int max_priority); - int k051960_is_irq_enabled(); - int k051960_is_nmi_enabled(); - void k051960_set_sprite_offsets(int dx, int dy); - - #if 0 // to be moved in the specific drivers! - /* special handling for the chips sharing address space */ - DECLARE_READ8_HANDLER( k052109_051960_r ); - DECLARE_WRITE8_HANDLER( k052109_051960_w ); - #endif - -protected: - // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - virtual void device_reset(); -private: - // internal state - UINT8 *m_ram; - - gfx_element *m_gfx; - - UINT8 m_spriterombank[3]; - int m_dx, m_dy; - int m_romoffset; - int m_spriteflip, m_readroms; - int m_irq_enabled, m_nmi_enabled; - - int m_k051937_counter; - - int k051960_fetchromdata( int byte ); -}; - -extern const device_type K051960; - - - -class k051316_device : public device_t, - public k051316_interface -{ -public: - k051316_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~k051316_device() {} - - /* - The callback is passed: - - code (range 00-FF, contents of the first tilemap RAM byte) - - color (range 00-FF, contents of the first tilemap RAM byte). Note that bit 6 - seems to be hardcoded as flip X. - The callback must put: - - in code the resulting tile number - - in color the resulting color index - - if necessary, put flags for the TileMap code in the tile_info - structure (e.g. TILE_FLIPX) - */ - - DECLARE_READ8_MEMBER( read ); - DECLARE_WRITE8_MEMBER( write ); - DECLARE_READ8_MEMBER( rom_r ); - DECLARE_WRITE8_MEMBER( ctrl_w ); - void zoom_draw(bitmap_ind16 &bitmap,const rectangle &cliprect,int flags,UINT32 priority); - void wraparound_enable(int status); - -protected: - // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - virtual void device_reset(); -private: - // internal state - UINT8 *m_ram; - tilemap_t *m_tmap; - UINT8 m_ctrlram[16]; - - TILE_GET_INFO_MEMBER(get_tile_info0); - void get_tile_info( tile_data &tileinfo, int tile_index ); -}; - -extern const device_type K051316; - - enum - { - K053251_CI0 = 0, - K053251_CI1, - K053251_CI2, - K053251_CI3, - K053251_CI4 - }; - -class k053251_device : public device_t -{ -public: - k053251_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~k053251_device() {} - - /* - Note: k053251_w() automatically does a ALL_TILEMAPS->mark_all_dirty() - when some palette index changes. If ALL_TILEMAPS is too expensive, use - k053251_set_tilemaps() to indicate which tilemap is associated with each index. - */ - - DECLARE_WRITE8_MEMBER( write ); - DECLARE_WRITE16_MEMBER( lsb_w ); - DECLARE_WRITE16_MEMBER( msb_w ); - int get_priority(int ci); - int get_palette_index(int ci); - int get_tmap_dirty(int tmap_num); - void set_tmap_dirty(int tmap_num, int data); - - DECLARE_READ16_MEMBER( lsb_r ); // PCU1 - DECLARE_READ16_MEMBER( msb_r ); // PCU1 - -protected: - // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - virtual void device_reset(); -private: - // internal state - int m_dirty_tmap[5]; - - UINT8 m_ram[16]; - int m_tilemaps_set; - int m_palette_index[5]; - - void reset_indexes(); -}; - -extern const device_type K053251; - -class k051733_device : public device_t -{ -public: - k051733_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~k051733_device() {} - - DECLARE_WRITE8_MEMBER( write ); - DECLARE_READ8_MEMBER( read ); - -protected: - // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - virtual void device_reset(); -private: - // internal state - UINT8 m_ram[0x20]; - UINT8 m_rng; -}; - -extern const device_type K051733; - - - -class k001006_device : public device_t +class k001006_device : public device_t, + public k001006_interface { public: k001006_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~k001006_device() { global_free(m_token); } + ~k001006_device() {} - // access to legacy token - void *token() const { assert(m_token != NULL); return m_token; } + UINT32 get_palette(int index); + + DECLARE_READ32_MEMBER( read ); + DECLARE_WRITE32_MEMBER( write ); + protected: // device-level overrides virtual void device_config_complete(); virtual void device_start(); virtual void device_reset(); + private: // internal state - void *m_token; + screen_device *m_screen; + + UINT16 * m_pal_ram; + UINT16 * m_unknown_ram; + UINT32 m_addr; + int m_device_sel; + + UINT32 * m_palette; }; extern const device_type K001006; @@ -541,148 +125,36 @@ private: extern const device_type K001604; -class k037122_device : public device_t, - public k037122_interface -{ -public: - k037122_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~k037122_device() {} - - void tile_draw( bitmap_rgb32 &bitmap, const rectangle &cliprect ); - DECLARE_READ32_MEMBER( sram_r ); - DECLARE_WRITE32_MEMBER( sram_w ); - DECLARE_READ32_MEMBER( char_r ); - DECLARE_WRITE32_MEMBER( char_w ); - DECLARE_READ32_MEMBER( reg_r ); - DECLARE_WRITE32_MEMBER( reg_w ); - -protected: - // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - virtual void device_reset(); - -private: - // internal state - screen_device *m_screen; - tilemap_t *m_layer[2]; - - UINT32 * m_tile_ram; - UINT32 * m_char_ram; - UINT32 * m_reg; - - TILE_GET_INFO_MEMBER(tile_info_layer0); - TILE_GET_INFO_MEMBER(tile_info_layer1); - void update_palette_color( UINT32 palette_base, int color ); -}; - -extern const device_type K037122; - - /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define MCFG_K007121_ADD(_tag) \ - MCFG_DEVICE_ADD(_tag, K007121, 0) - -#define MCFG_K007342_ADD(_tag, _interface) \ - MCFG_DEVICE_ADD(_tag, K007342, 0) \ - MCFG_DEVICE_CONFIG(_interface) - -#define MCFG_K007420_ADD(_tag, _interface) \ - MCFG_DEVICE_ADD(_tag, K007420, 0) \ - MCFG_DEVICE_CONFIG(_interface) - -#define MCFG_K052109_ADD(_tag, _interface) \ - MCFG_DEVICE_ADD(_tag, K052109, 0) \ - MCFG_DEVICE_CONFIG(_interface) - -#define MCFG_K051960_ADD(_tag, _interface) \ - MCFG_DEVICE_ADD(_tag, K051960, 0) \ - MCFG_DEVICE_CONFIG(_interface) - -#define MCFG_K053244_ADD(_tag, _interface) \ - MCFG_DEVICE_ADD(_tag, K053244, 0) \ - MCFG_DEVICE_CONFIG(_interface) - -#define MCFG_K053245_ADD(_tag, _interface) \ - MCFG_DEVICE_ADD(_tag, K053245, 0) \ - MCFG_DEVICE_CONFIG(_interface) - -#define MCFG_K053246_ADD(_tag, _interface) \ - MCFG_DEVICE_ADD(_tag, K053246, 0) \ - MCFG_DEVICE_CONFIG(_interface) - -#define MCFG_K053247_ADD(_tag, _interface) \ - MCFG_DEVICE_ADD(_tag, K053247, 0) \ - MCFG_DEVICE_CONFIG(_interface) - -#define MCFG_K055673_ADD(_tag, _interface) \ - MCFG_DEVICE_ADD(_tag, K055673, 0) \ - MCFG_DEVICE_CONFIG(_interface) - -#define MCFG_K051316_ADD(_tag, _interface) \ - MCFG_DEVICE_ADD(_tag, K051316, 0) \ - MCFG_DEVICE_CONFIG(_interface) - - - -#define MCFG_K053251_ADD(_tag) \ - MCFG_DEVICE_ADD(_tag, K053251, 0) - - - -#define MCFG_K051733_ADD(_tag) \ - MCFG_DEVICE_ADD(_tag, K051733, 0) - - - #define MCFG_K001006_ADD(_tag, _interface) \ MCFG_DEVICE_ADD(_tag, K001006, 0) \ MCFG_DEVICE_CONFIG(_interface) - #define MCFG_K001005_ADD(_tag, _interface) \ MCFG_DEVICE_ADD(_tag, K001005, 0) \ MCFG_DEVICE_CONFIG(_interface) - #define MCFG_K001604_ADD(_tag, _interface) \ MCFG_DEVICE_ADD(_tag, K001604, 0) \ MCFG_DEVICE_CONFIG(_interface) -#define MCFG_K037122_ADD(_tag, _interface) \ - MCFG_DEVICE_ADD(_tag, K037122, 0) \ - MCFG_DEVICE_CONFIG(_interface) - - /*************************************************************************** HELPERS FOR DRIVERS ***************************************************************************/ -/* helper function to sort three tile layers by priority order */ -void konami_sortlayers3(int *layer, int *pri); -/* helper function to sort four tile layers by priority order */ -void konami_sortlayers4(int *layer, int *pri); -/* helper function to sort five tile layers by priority order */ -void konami_sortlayers5(int *layer, int *pri); + /*************************************************************************** DEVICE I/O FUNCTIONS ***************************************************************************/ -/** Konami 001006 **/ -UINT32 k001006_get_palette(device_t *device, int index); - -DECLARE_READ32_DEVICE_HANDLER( k001006_r ); -DECLARE_WRITE32_DEVICE_HANDLER( k001006_w ); - - /** Konami 001005 **/ void k001005_draw(device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect); void k001005_swap_buffers(device_t *device); diff --git a/src/mame/video/labyrunr.c b/src/mame/video/labyrunr.c index d9f3b0262c3..f60845328eb 100644 --- a/src/mame/video/labyrunr.c +++ b/src/mame/video/labyrunr.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/labyrunr.h" void labyrunr_state::palette_init() diff --git a/src/mame/video/mainevt.c b/src/mame/video/mainevt.c index ed7f0886ea0..21f092f2f25 100644 --- a/src/mame/video/mainevt.c +++ b/src/mame/video/mainevt.c @@ -7,7 +7,7 @@ ***************************************************************************/ #include "emu.h" -#include "video/konicdev.h" + #include "includes/mainevt.h" diff --git a/src/mame/video/parodius.c b/src/mame/video/parodius.c index 37e0c66e22e..58a4d82e38f 100644 --- a/src/mame/video/parodius.c +++ b/src/mame/video/parodius.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/parodius.h" diff --git a/src/mame/video/plygonet.c b/src/mame/video/plygonet.c index 244d07f5e40..b0a13c47c53 100644 --- a/src/mame/video/plygonet.c +++ b/src/mame/video/plygonet.c @@ -8,7 +8,7 @@ */ #include "emu.h" -#include "video/konicdev.h" + #include "includes/plygonet.h" /* TTL text plane */ diff --git a/src/mame/video/rungun.c b/src/mame/video/rungun.c index cb9361c4f58..6b154fef8a8 100644 --- a/src/mame/video/rungun.c +++ b/src/mame/video/rungun.c @@ -10,7 +10,7 @@ *************************************************************************/ #include "emu.h" -#include "video/konicdev.h" + #include "includes/rungun.h" /* TTL text plane stuff */ diff --git a/src/mame/video/simpsons.c b/src/mame/video/simpsons.c index e26c81db9fe..1278ef426cd 100644 --- a/src/mame/video/simpsons.c +++ b/src/mame/video/simpsons.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/simpsons.h" /*************************************************************************** diff --git a/src/mame/video/spy.c b/src/mame/video/spy.c index 32cfb43a552..012e0d239e5 100644 --- a/src/mame/video/spy.c +++ b/src/mame/video/spy.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/spy.h" diff --git a/src/mame/video/suprslam.c b/src/mame/video/suprslam.c index 48dd9f20c4f..79bd060c697 100644 --- a/src/mame/video/suprslam.c +++ b/src/mame/video/suprslam.c @@ -1,7 +1,7 @@ /* Super Slams - video, see notes in driver file */ #include "emu.h" -#include "video/konicdev.h" + #include "vsystem_spr.h" #include "includes/suprslam.h" diff --git a/src/mame/video/surpratk.c b/src/mame/video/surpratk.c index 681c6655c95..085b09ec979 100644 --- a/src/mame/video/surpratk.c +++ b/src/mame/video/surpratk.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/surpratk.h" diff --git a/src/mame/video/thunderx.c b/src/mame/video/thunderx.c index d4bbf5f670f..cd3da62b4b8 100644 --- a/src/mame/video/thunderx.c +++ b/src/mame/video/thunderx.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/thunderx.h" /*************************************************************************** diff --git a/src/mame/video/tmnt.c b/src/mame/video/tmnt.c index bfb468543de..3e6620032d1 100644 --- a/src/mame/video/tmnt.c +++ b/src/mame/video/tmnt.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/tmnt.h" TILE_GET_INFO_MEMBER(tmnt_state::glfgreat_get_roz_tile_info) diff --git a/src/mame/video/vendetta.c b/src/mame/video/vendetta.c index ca987b209ce..ac5015b996c 100644 --- a/src/mame/video/vendetta.c +++ b/src/mame/video/vendetta.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/vendetta.h" /*************************************************************************** diff --git a/src/mame/video/xmen.c b/src/mame/video/xmen.c index e231d237932..d4df24bc984 100644 --- a/src/mame/video/xmen.c +++ b/src/mame/video/xmen.c @@ -1,5 +1,5 @@ #include "emu.h" -#include "video/konicdev.h" + #include "includes/xmen.h"