jaleco/megasys1.cpp, jaleco/cischeat: Encapsulated gate array simulation as a device. (#11650)

* Fixes crashes in tshingen (MT08541).
* Refined memory maps and cleaned up code.
* Reduced reliance on driver init functions.
* Removed placeholder microcontroller ROMs from games using gate arrays.
* Updated notes.
This commit is contained in:
mamehaze 2023-10-26 17:36:44 +01:00 committed by GitHub
parent f0de443968
commit 5217259167
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 718 additions and 730 deletions

View File

@ -186,7 +186,6 @@ Cisco Heat.
#include "cpu/m68000/m68000.h" #include "cpu/m68000/m68000.h"
#include "machine/adc0804.h" #include "machine/adc0804.h"
#include "jalcrpt.h"
#include "machine/nvram.h" #include "machine/nvram.h"
#include "sound/okim6295.h" #include "sound/okim6295.h"
#include "sound/ymopm.h" #include "sound/ymopm.h"
@ -2138,6 +2137,13 @@ void cischeat_state::bigrun(machine_config &config)
m_oki2->add_route(ALL_OUTPUTS, "rspeaker", 0.25); m_oki2->add_route(ALL_OUTPUTS, "rspeaker", 0.25);
} }
void cischeat_state::bigrun_d65006(machine_config &config)
{
bigrun(config);
MEGASYS1_GATEARRAY_D65006(config, m_gatearray, 0);
m_gatearray->set_cpu_tag(m_soundcpu);
m_gatearray->set_cpuregion_tag("soundcpu");
}
void cischeat_state::cischeat(machine_config &config) void cischeat_state::cischeat(machine_config &config)
{ {
@ -2169,6 +2175,14 @@ void cischeat_state::cischeat(machine_config &config)
m_tmap[2]->set_bits_per_color_code(5); m_tmap[2]->set_bits_per_color_code(5);
} }
void cischeat_state::cischeat_gs88000(machine_config &config)
{
cischeat(config);
MEGASYS1_GATEARRAY_GS88000(config, m_gatearray, 0);
m_gatearray->set_cpu_tag(m_soundcpu);
m_gatearray->set_cpuregion_tag("soundcpu");
}
void cischeat_state::f1gpstar(machine_config &config) void cischeat_state::f1gpstar(machine_config &config)
{ {
@ -2678,7 +2692,6 @@ ROM_END
void cischeat_state::init_bigrun() void cischeat_state::init_bigrun()
{ {
cischeat_untangle_sprites("sprites"); // Untangle sprites cischeat_untangle_sprites("sprites"); // Untangle sprites
phantasm_rom_decode(machine(), "soundcpu"); // Decrypt sound cpu code
} }
@ -2797,10 +2810,8 @@ ROM_END
void cischeat_state::init_cischeat() void cischeat_state::init_cischeat()
{ {
cischeat_untangle_sprites("sprites"); // Untangle sprites cischeat_untangle_sprites("sprites"); // Untangle sprites
astyanax_rom_decode(machine(), "soundcpu"); // Decrypt sound cpu code
} }
/*************************************************************************** /***************************************************************************
F1 GrandPrix Star F1 GrandPrix Star
@ -4122,10 +4133,10 @@ void captflag_state::init_vscaptfl()
***************************************************************************/ ***************************************************************************/
GAMEL( 1989, bigrun, 0, bigrun, bigrun, cischeat_state, init_bigrun, ROT0, "Jaleco", "Big Run (11th Rallye version, Europe?)", MACHINE_NODEVICE_LAN, layout_cischeat ) // there's a 13th Rallye version (1991) (only on the SNES? Could just be updated title, 1989 -> 11th Paris-Dakar ...) GAMEL( 1989, bigrun, 0, bigrun_d65006, bigrun, cischeat_state, init_bigrun, ROT0, "Jaleco", "Big Run (11th Rallye version, Europe?)", MACHINE_NODEVICE_LAN, layout_cischeat ) // there's a 13th Rallye version (1991) (only on the SNES? Could just be updated title, 1989 -> 11th Paris-Dakar ...)
GAMEL( 1989, bigrunu, bigrun, bigrun, bigrun, cischeat_state, init_bigrun, ROT0, "Jaleco", "Big Run (11th Rallye version, US?)", MACHINE_NODEVICE_LAN, layout_cischeat ) GAMEL( 1989, bigrunu, bigrun, bigrun_d65006, bigrun, cischeat_state, init_bigrun, ROT0, "Jaleco", "Big Run (11th Rallye version, US?)", MACHINE_NODEVICE_LAN, layout_cischeat )
GAMEL( 1990, cischeat, 0, cischeat, cischeat, cischeat_state, init_cischeat, ROT0, "Jaleco", "Cisco Heat", MACHINE_IMPERFECT_GRAPHICS | MACHINE_NODEVICE_LAN, layout_cischeat ) GAMEL( 1990, cischeat, 0, cischeat_gs88000, cischeat, cischeat_state, init_cischeat, ROT0, "Jaleco", "Cisco Heat", MACHINE_IMPERFECT_GRAPHICS | MACHINE_NODEVICE_LAN, layout_cischeat )
GAMEL( 1992, f1gpstar, 0, f1gpstar, f1gpstar, cischeat_state, init_f1gpstar, ROT0, "Jaleco", "Grand Prix Star (ver 4.0)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_NODEVICE_LAN, layout_f1gpstar ) GAMEL( 1992, f1gpstar, 0, f1gpstar, f1gpstar, cischeat_state, init_f1gpstar, ROT0, "Jaleco", "Grand Prix Star (ver 4.0)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_NODEVICE_LAN, layout_f1gpstar )
GAMEL( 1991, f1gpstar3, f1gpstar, f1gpstar, f1gpstar, cischeat_state, init_f1gpstar, ROT0, "Jaleco", "Grand Prix Star (ver 3.0)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_NODEVICE_LAN, layout_f1gpstar ) GAMEL( 1991, f1gpstar3, f1gpstar, f1gpstar, f1gpstar, cischeat_state, init_f1gpstar, ROT0, "Jaleco", "Grand Prix Star (ver 3.0)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_NODEVICE_LAN, layout_f1gpstar )

View File

@ -12,6 +12,7 @@
#include "machine/ticket.h" #include "machine/ticket.h"
#include "machine/timer.h" #include "machine/timer.h"
#include "machine/watchdog.h" #include "machine/watchdog.h"
#include "ms1_gatearray.h"
#include "ms1_tmap.h" #include "ms1_tmap.h"
#include "emupal.h" #include "emupal.h"
#include "screen.h" #include "screen.h"
@ -39,6 +40,7 @@ public:
, m_palette(*this, "palette") , m_palette(*this, "palette")
, m_soundlatch(*this, "soundlatch") , m_soundlatch(*this, "soundlatch")
, m_soundlatch2(*this, "soundlatch2") , m_soundlatch2(*this, "soundlatch2")
, m_gatearray(*this, "gatearray")
, m_leds(*this, "led%u", 0U) , m_leds(*this, "led%u", 0U)
{} {}
@ -95,6 +97,9 @@ public:
void f1gpstr2(machine_config &config); void f1gpstr2(machine_config &config);
void f1gpstar(machine_config &config); void f1gpstar(machine_config &config);
void bigrun(machine_config &config); void bigrun(machine_config &config);
void bigrun_d65006(machine_config &config);
void cischeat_gs88000(machine_config &config);
void bigrun_map(address_map &map); void bigrun_map(address_map &map);
void bigrun_map2(address_map &map); void bigrun_map2(address_map &map);
void bigrun_map3(address_map &map); void bigrun_map3(address_map &map);
@ -113,7 +118,11 @@ public:
void scudhamm_map(address_map &map); void scudhamm_map(address_map &map);
protected: protected:
virtual void machine_start() override { m_leds.resolve(); m_scudhamm_motor_command = 0; } virtual void machine_start() override
{
m_leds.resolve(); m_scudhamm_motor_command = 0;
}
virtual void video_start() override; virtual void video_start() override;
optional_device_array<megasys1_tilemap_device, 3> m_tmap; optional_device_array<megasys1_tilemap_device, 3> m_tmap;
@ -152,7 +161,7 @@ protected:
required_device<palette_device> m_palette; required_device<palette_device> m_palette;
optional_device<generic_latch_16_device> m_soundlatch; optional_device<generic_latch_16_device> m_soundlatch;
optional_device<generic_latch_16_device> m_soundlatch2; optional_device<generic_latch_16_device> m_soundlatch2;
optional_device<megasys1_gatearray_device> m_gatearray;
output_finder<5> m_leds; output_finder<5> m_leds;
}; };

View File

@ -3,109 +3,6 @@
#include "emu.h" #include "emu.h"
#include "jalcrpt.h" #include "jalcrpt.h"
void phantasm_rom_decode(running_machine &machine, const char *region)
{
uint16_t *RAM = (uint16_t *) machine.root_device().memregion(region)->base();
int i, size = machine.root_device().memregion(region)->bytes();
if (size > 0x40000) size = 0x40000;
for (i = 0 ; i < size/2 ; i++)
{
uint16_t x,y;
x = RAM[i];
// [0] def0 189a bc56 7234
// [1] fdb9 7531 eca8 6420
// [2] 0123 4567 ba98 fedc
#define BITSWAP_0 bitswap<16>(x,0xd,0xe,0xf,0x0,0x1,0x8,0x9,0xa,0xb,0xc,0x5,0x6,0x7,0x2,0x3,0x4)
#define BITSWAP_1 bitswap<16>(x,0xf,0xd,0xb,0x9,0x7,0x5,0x3,0x1,0xe,0xc,0xa,0x8,0x6,0x4,0x2,0x0)
#define BITSWAP_2 bitswap<16>(x,0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0xb,0xa,0x9,0x8,0xf,0xe,0xd,0xc)
if (i < 0x08000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0;} else {y = BITSWAP_1;} }
else if (i < 0x10000/2) { y = BITSWAP_2; }
else if (i < 0x18000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0;} else {y = BITSWAP_1;} }
else if (i < 0x20000/2) { y = BITSWAP_1; }
else { y = BITSWAP_2; }
#undef BITSWAP_0
#undef BITSWAP_1
#undef BITSWAP_2
RAM[i] = y;
}
}
void astyanax_rom_decode(running_machine &machine, const char *region)
{
uint16_t *RAM = (uint16_t *) machine.root_device().memregion(region)->base();
int i, size = machine.root_device().memregion(region)->bytes();
if (size > 0x40000) size = 0x40000;
for (i = 0 ; i < size/2 ; i++)
{
uint16_t x,y;
x = RAM[i];
// [0] def0 a981 65cb 7234
// [1] fdb9 7531 8ace 0246
// [2] 4567 0123 ba98 fedc
#define BITSWAP_0 bitswap<16>(x,0xd,0xe,0xf,0x0,0xa,0x9,0x8,0x1,0x6,0x5,0xc,0xb,0x7,0x2,0x3,0x4)
#define BITSWAP_1 bitswap<16>(x,0xf,0xd,0xb,0x9,0x7,0x5,0x3,0x1,0x8,0xa,0xc,0xe,0x0,0x2,0x4,0x6)
#define BITSWAP_2 bitswap<16>(x,0x4,0x5,0x6,0x7,0x0,0x1,0x2,0x3,0xb,0xa,0x9,0x8,0xf,0xe,0xd,0xc)
if (i < 0x08000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0;} else {y = BITSWAP_1;} }
else if (i < 0x10000/2) { y = BITSWAP_2; }
else if (i < 0x18000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0;} else {y = BITSWAP_1;} }
else if (i < 0x20000/2) { y = BITSWAP_1; }
else { y = BITSWAP_2; }
#undef BITSWAP_0
#undef BITSWAP_1
#undef BITSWAP_2
RAM[i] = y;
}
}
void rodland_rom_decode(running_machine &machine, const char *region)
{
uint16_t *RAM = (uint16_t *) machine.root_device().memregion(region)->base();
int i, size = machine.root_device().memregion(region)->bytes();
if (size > 0x40000) size = 0x40000;
for (i = 0 ; i < size/2 ; i++)
{
uint16_t x,y;
x = RAM[i];
// [0] d0a9 6ebf 5c72 3814 [1] 4567 0123 ba98 fedc
// [2] fdb9 ce07 5318 a246 [3] 4512 ed3b a967 08fc
#define BITSWAP_0 bitswap<16>(x,0xd,0x0,0xa,0x9,0x6,0xe,0xb,0xf,0x5,0xc,0x7,0x2,0x3,0x8,0x1,0x4);
#define BITSWAP_1 bitswap<16>(x,0x4,0x5,0x6,0x7,0x0,0x1,0x2,0x3,0xb,0xa,0x9,0x8,0xf,0xe,0xd,0xc);
#define BITSWAP_2 bitswap<16>(x,0xf,0xd,0xb,0x9,0xc,0xe,0x0,0x7,0x5,0x3,0x1,0x8,0xa,0x2,0x4,0x6);
#define BITSWAP_3 bitswap<16>(x,0x4,0x5,0x1,0x2,0xe,0xd,0x3,0xb,0xa,0x9,0x6,0x7,0x0,0x8,0xf,0xc);
if (i < 0x08000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0;} else {y = BITSWAP_1;} }
else if (i < 0x10000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_2;} else {y = BITSWAP_3;} }
else if (i < 0x18000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0;} else {y = BITSWAP_1;} }
else if (i < 0x20000/2) { y = BITSWAP_1; }
else { y = BITSWAP_3; }
#undef BITSWAP_0
#undef BITSWAP_1
#undef BITSWAP_2
#undef BITSWAP_3
RAM[i] = y;
}
}
/********** DECRYPT **********/ /********** DECRYPT **********/
/* 4 known types */ /* 4 known types */

View File

@ -1,8 +1,5 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Luca Elia, David Haywood // copyright-holders:Luca Elia, David Haywood
void astyanax_rom_decode(running_machine &machine, const char *region);
void phantasm_rom_decode(running_machine &machine, const char *region);
void rodland_rom_decode (running_machine &machine, const char *region);
void decrypt_ms32_tx(running_machine &machine, int addr_xor,int data_xor, const char *region); void decrypt_ms32_tx(running_machine &machine, int addr_xor,int data_xor, const char *region);
void decrypt_ms32_bg(running_machine &machine, int addr_xor,int data_xor, const char *region); void decrypt_ms32_bg(running_machine &machine, int addr_xor,int data_xor, const char *region);

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,7 @@
#include "machine/timer.h" #include "machine/timer.h"
#include "sound/msm5205.h" #include "sound/msm5205.h"
#include "sound/okim6295.h" #include "sound/okim6295.h"
#include "ms1_gatearray.h"
#include "ms1_tmap.h" #include "ms1_tmap.h"
#include "emupal.h" #include "emupal.h"
#include "screen.h" #include "screen.h"
@ -43,43 +44,20 @@ public:
m_io_dsw1(*this, "DSW1"), m_io_dsw1(*this, "DSW1"),
m_io_dsw2(*this, "DSW2"), m_io_dsw2(*this, "DSW2"),
m_scantimer(*this, "scantimer"), m_scantimer(*this, "scantimer"),
m_objectram(*this, "objectram"),
m_ymsnd(*this, "ymsnd"),
m_p47b_adpcm(*this, "msm%u", 1U),
m_rom_maincpu(*this, "maincpu"), m_rom_maincpu(*this, "maincpu"),
m_okibank(*this, "okibank") m_objectram(*this, "objectram"),
m_ymsnd(*this, "ymsnd")
{ {
m_hardware_type_z = 0; m_hardware_type_z = 0;
} }
void system_A_soldam(machine_config &config);
void system_B_monkelf(machine_config &config); void system_B_monkelf(machine_config &config);
void system_A_iganinju(machine_config &config);
void kickoffb(machine_config &config);
void p47b(machine_config &config);
void system_D(machine_config &config);
void system_C(machine_config &config); void system_C(machine_config &config);
void system_Bbl(machine_config &config); void system_Bbl(machine_config &config);
void system_A(machine_config &config); void system_base(machine_config &config);
void system_A_jitsupro(machine_config &config);
void init_peekaboo();
void init_soldam();
void init_astyanax();
void init_stdragon();
void init_soldamj();
void init_phantasm();
void init_jitsupro();
void init_iganinju();
void init_rodlandj();
void init_rittam();
void init_rodlandjb();
void init_monkelf(); void init_monkelf();
void init_edfp();
void init_rodland();
void init_stdragona();
void init_stdragonb();
void init_lordofkbp();
protected: protected:
virtual void machine_reset() override; virtual void machine_reset() override;
@ -101,24 +79,36 @@ protected:
optional_ioport m_io_dsw1; optional_ioport m_io_dsw1;
optional_ioport m_io_dsw2; optional_ioport m_io_dsw2;
optional_device<timer_device> m_scantimer; optional_device<timer_device> m_scantimer;
required_region_ptr<u16> m_rom_maincpu;
void megasys1B_map(address_map &map); void megasys1B_map(address_map &map);
void megasys1C_map(address_map &map); void megasys1C_map(address_map &map);
void megasys1c_handle_scanline_irq(int scanline); void megasys1c_handle_scanline_irq(int scanline);
TIMER_DEVICE_CALLBACK_MEMBER(megasys1A_scanline); TIMER_DEVICE_CALLBACK_MEMBER(megasys_base_scanline);
TIMER_DEVICE_CALLBACK_MEMBER(megasys1B_scanline); TIMER_DEVICE_CALLBACK_MEMBER(megasys1B_scanline);
void megasys_base_map(address_map &map); void megasys_base_map(address_map &map);
void megasys1B_sound_map(address_map &map); void megasys1B_sound_map(address_map &map);
void megasys1_palette(palette_device &palette);
virtual void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect); virtual void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect);
void mix_sprite_bitmap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void mix_sprite_bitmap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void partial_clear_sprite_bitmap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, u8 param); void partial_clear_sprite_bitmap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, u8 param);
inline void draw_16x16_priority_sprite(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect, s32 code, s32 color, s32 sx, s32 sy, s32 flipx, s32 flipy, u8 mosaic, u8 mosaicsol, s32 priority); inline void draw_16x16_priority_sprite(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect, s32 code, s32 color, s32 sx, s32 sy, s32 flipx, s32 flipy, u8 mosaic, u8 mosaicsol, s32 priority);
u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void sound_irq(int state);
void screen_vblank(int state);
void screen_flag_w(offs_t offset, u16 data, u16 mem_mask = ~0); void screen_flag_w(offs_t offset, u16 data, u16 mem_mask = ~0);
void active_layers_w(offs_t offset, u16 data, u16 mem_mask = ~0);
void sprite_bank_w(offs_t offset, u16 data, u16 mem_mask = ~0);
u16 sprite_flag_r();
void sprite_flag_w(offs_t offset, u16 data, u16 mem_mask = ~0);
void soundlatch_w(u16 data);
void soundlatch_c_w(u16 data);
template<int Chip> u8 oki_status_r();
int m_hardware_type_z = 0; // System Z int m_hardware_type_z = 0; // System Z
@ -127,9 +117,6 @@ protected:
// System C // System C
u16 m_sprite_bank = 0; u16 m_sprite_bank = 0;
// soldam
u16 *m_spriteram = nullptr;
u16 m_screen_flag = 0; u16 m_screen_flag = 0;
// all // all
@ -146,79 +133,112 @@ protected:
private: private:
required_shared_ptr<u16> m_objectram; required_shared_ptr<u16> m_objectram;
optional_device<device_t> m_ymsnd; optional_device<device_t> m_ymsnd;
optional_device_array<msm5205_device, 2> m_p47b_adpcm;
required_region_ptr<u16> m_rom_maincpu;
optional_memory_bank m_okibank;
// configuration // configuration
int m_layers_order[16]{}; int m_layers_order[16]{};
// System A only
int m_mcu_hs = 0;
u16 m_mcu_hs_ram[0x10]{};
// peekaboo
u16 m_protection_val = 0;
void sound_irq(int state);
u16 protection_peekaboo_r();
void protection_peekaboo_w(offs_t offset, u16 data, u16 mem_mask = ~0);
u16 megasys1A_mcu_hs_r(offs_t offset, u16 mem_mask = ~0);
void megasys1A_mcu_hs_w(offs_t offset, u16 data, u16 mem_mask = ~0);
u16 iganinju_mcu_hs_r(offs_t offset, u16 mem_mask = ~0);
void iganinju_mcu_hs_w(offs_t offset, u16 data, u16 mem_mask = ~0);
u16 soldamj_spriteram16_r(offs_t offset);
void soldamj_spriteram16_w(offs_t offset, u16 data, u16 mem_mask = ~0);
u16 stdragon_mcu_hs_r(offs_t offset, u16 mem_mask = ~0);
void stdragon_mcu_hs_w(offs_t offset, u16 data, u16 mem_mask = ~0);
void active_layers_w(offs_t offset, u16 data, u16 mem_mask = ~0);
void sprite_bank_w(offs_t offset, u16 data, u16 mem_mask = ~0);
u16 sprite_flag_r();
void sprite_flag_w(offs_t offset, u16 data, u16 mem_mask = ~0);
void soundlatch_w(u16 data);
void soundlatch_c_w(u16 data);
void monkelf_scroll0_w(offs_t offset, u16 data, u16 mem_mask = ~0); void monkelf_scroll0_w(offs_t offset, u16 data, u16 mem_mask = ~0);
void monkelf_scroll1_w(offs_t offset, u16 data, u16 mem_mask = ~0); void monkelf_scroll1_w(offs_t offset, u16 data, u16 mem_mask = ~0);
template<int Chip> u8 oki_status_r();
void ram_w(offs_t offset, u16 data); void ram_w(offs_t offset, u16 data);
void p47b_adpcm_w(offs_t offset, u8 data);
void megasys1_palette(palette_device &palette);
void screen_vblank(int state);
INTERRUPT_GEN_MEMBER(megasys1D_irq);
TIMER_DEVICE_CALLBACK_MEMBER(megasys1A_iganinju_scanline);
TIMER_DEVICE_CALLBACK_MEMBER(megasys1C_scanline); TIMER_DEVICE_CALLBACK_MEMBER(megasys1C_scanline);
void priority_create(); void priority_create();
void rodland_gfx_unmangle(const char *region);
void jitsupro_gfx_unmangle(const char *region); void megasys1B_edfbl_map(address_map &map);
void stdragona_gfx_unmangle(const char *region); void megasys1B_monkelf_map(address_map &map);
};
class megasys1_typea_state : public megasys1_state
{
public:
megasys1_typea_state(const machine_config &mconfig, device_type type, const char *tag) :
megasys1_state(mconfig, type, tag),
m_p47b_adpcm(*this, "msm%u", 1U),
m_gatearray(*this, "gatearray")
{ }
void system_A(machine_config &config);
void system_A_d65006_soldam(machine_config &config);
void system_A_gs88000_soldam(machine_config &config);
void system_A_iganinju(machine_config &config);
void system_A_kickoffb(machine_config &config);
void system_A_p47b(machine_config &config);
void system_A_d65006(machine_config &config);
void system_A_d65006_iganinju(machine_config &config);
void system_A_gs88000(machine_config &config);
void system_A_unkarray(machine_config &config);
void init_jitsupro_gfx();
void init_rodland_gfx();
void init_stdragon_gfx();
void init_lordofkbp();
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
void kickoffb_sound_map(address_map &map); void kickoffb_sound_map(address_map &map);
void p47b_sound_map(address_map &map); void p47b_sound_map(address_map &map);
void p47b_extracpu_prg_map(address_map &map); void p47b_extracpu_prg_map(address_map &map);
void p47b_extracpu_io_map(address_map &map); void p47b_extracpu_io_map(address_map &map);
void megasys1A_map(address_map &map); void megasys1A_map(address_map &map);
void megasys1A_sound_map(address_map &map); void megasys1A_sound_map(address_map &map);
void megasys1A_jitsupro_sound_map(address_map &map);
void megasys1B_edfbl_map(address_map &map); void p47b_adpcm_w(offs_t offset, u8 data);
void megasys1B_monkelf_map(address_map &map);
void megasys1D_map(address_map &map);
void megasys1D_oki_map(address_map &map); private:
optional_device_array<msm5205_device, 2> m_p47b_adpcm;
optional_device<megasys1_gatearray_device> m_gatearray;
TIMER_DEVICE_CALLBACK_MEMBER(megasys1A_iganinju_scanline);
void rodland_gfx_unmangle(const char *region);
void jitsupro_gfx_unmangle(const char *region);
void stdragona_gfx_unmangle(const char *region);
}; };
class megasys1_hachoo_state : public megasys1_state class megasys1_typea_hachoo_state : public megasys1_typea_state
{ {
public: public:
megasys1_hachoo_state(const machine_config &mconfig, device_type type, const char *tag) : megasys1_typea_hachoo_state(const machine_config &mconfig, device_type type, const char *tag) :
megasys1_state(mconfig, type, tag) megasys1_typea_state(mconfig, type, tag)
{ } { }
protected: protected:
virtual void machine_reset() override; virtual void machine_reset() override;
}; };
class megasys1_typed_state : public megasys1_state
{
public:
megasys1_typed_state(const machine_config &mconfig, device_type type, const char *tag) :
megasys1_state(mconfig, type, tag),
m_okibank(*this, "okibank")
{ }
void system_D(machine_config &config);
void init_peekaboo();
private:
required_memory_bank m_okibank;
// peekaboo
u16 m_protection_val = 0;
u16 protection_peekaboo_r();
void protection_peekaboo_w(offs_t offset, u16 data, u16 mem_mask = ~0);
INTERRUPT_GEN_MEMBER(megasys1D_irq);
void megasys1D_map(address_map &map);
void megasys1D_oki_map(address_map &map);
};
class megasys1_typez_state : public megasys1_state class megasys1_typez_state : public megasys1_state
{ {
public: public:
@ -251,7 +271,6 @@ public:
void init_avspirit(); void init_avspirit();
void init_64street(); void init_64street();
void init_chimerab();
void init_chimeraba(); void init_chimeraba();
void init_cybattlr(); void init_cybattlr();
void init_hayaosi1(); void init_hayaosi1();
@ -262,12 +281,20 @@ public:
void system_C_iosim(machine_config &config); void system_C_iosim(machine_config &config);
protected: protected:
virtual void machine_start() override;
virtual void machine_reset() override; virtual void machine_reset() override;
u16 m_ip_select_values[7]{}; // System B and C const u8 *m_ip_select_values = nullptr; // System B and C
u16 m_ip_latched = 0; u16 m_ip_latched = 0;
static constexpr u8 avspirit_seq[7] = { 0x37,0x35,0x36,0x33,0x34, 0xff,0x06 };
static constexpr u8 edf_seq[7] = { 0x20,0x21,0x22,0x23,0x24, 0xf0,0x06 };
static constexpr u8 hayaosi1_seq[7] = { 0x51,0x52,0x53,0x54,0x55, 0xfc,0x06 };
static constexpr u8 street_seq[7] = { 0x57,0x53,0x54,0x55,0x56, 0xfa,0x06 };
static constexpr u8 chimeraba_seq[7] = { 0x56,0x52,0x53,0x55,0x54, 0xfa,0x06 };
static constexpr u8 cybattler_seq[7] = { 0x56,0x52,0x53,0x54,0x55, 0xf2,0x06 };
void megasys1B_iosim_map(address_map &map); void megasys1B_iosim_map(address_map &map);
void megasys1C_iosim_map(address_map &map); void megasys1C_iosim_map(address_map &map);
@ -283,11 +310,10 @@ public:
m_iomcu(*this, "iomcu") m_iomcu(*this, "iomcu")
{ } { }
void init_bigstrik();
void system_C_bigstrik(machine_config &config); void system_C_bigstrik(machine_config &config);
protected: protected:
virtual void machine_start() override;
virtual void machine_reset() override; virtual void machine_reset() override;
private: private:

View File

@ -1,5 +1,5 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Luca Elia // copyright-holders:Luca Elia, David Haywood
/*************************************************************************** /***************************************************************************
-= Jaleco Mega System 1 =- -= Jaleco Mega System 1 =-
@ -201,8 +201,6 @@ actual code sent to the hardware.
void megasys1_state::video_start() void megasys1_state::video_start()
{ {
m_spriteram = &m_ram[0x8000/2];
m_buffer_objectram = std::make_unique<u16[]>(0x2000); m_buffer_objectram = std::make_unique<u16[]>(0x2000);
m_buffer_spriteram16 = std::make_unique<u16[]>(0x2000); m_buffer_spriteram16 = std::make_unique<u16[]>(0x2000);
m_buffer2_objectram = std::make_unique<u16[]>(0x2000); m_buffer2_objectram = std::make_unique<u16[]>(0x2000);
@ -219,6 +217,7 @@ void megasys1_state::video_start()
save_item(NAME(m_screen_flag)); save_item(NAME(m_screen_flag));
save_item(NAME(m_active_layers)); save_item(NAME(m_active_layers));
save_item(NAME(m_sprite_flag)); save_item(NAME(m_sprite_flag));
save_item(NAME(m_sprite_bank)); // only on type C
} }
@ -427,7 +426,7 @@ inline void megasys1_state::draw_16x16_priority_sprite(screen_device &screen, bi
void megasys1_typez_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect) void megasys1_typez_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect)
{ {
int color,code,sx,sy,flipx,flipy,attr,sprite; int color,code,sx,sy,flipx,flipy,attr,sprite;
u16 *spriteram16 = m_spriteram; u16 *spriteram16 = &m_ram[0x8000/2];
/* MS1-Z just draws Sprite Data, and in reverse order */ /* MS1-Z just draws Sprite Data, and in reverse order */
@ -871,7 +870,7 @@ void megasys1_state::screen_vblank(int state)
memcpy(m_buffer_objectram.get(), m_objectram, 0x2000); memcpy(m_buffer_objectram.get(), m_objectram, 0x2000);
//spriteram16 //spriteram16
memcpy(m_buffer2_spriteram16.get(), m_buffer_spriteram16.get(), 0x2000); memcpy(m_buffer2_spriteram16.get(), m_buffer_spriteram16.get(), 0x2000);
memcpy(m_buffer_spriteram16.get(), m_spriteram, 0x2000); memcpy(m_buffer_spriteram16.get(), &m_ram[0x8000/2], 0x2000);
} }
} }

View File

@ -0,0 +1,219 @@
// license:BSD-3-Clause
// copyright-holders:Angelo Salese, David Haywood
#include "emu.h"
#include "ms1_gatearray.h"
//#define VERBOSE 1
#include "logmacro.h"
DEFINE_DEVICE_TYPE(MEGASYS1_GATEARRAY_D65006, megasys1_gatearray_d65006_device, "ms1_d65005", "Mega System 1 Gate Array D65005")
DEFINE_DEVICE_TYPE(MEGASYS1_GATEARRAY_GS88000, megasys1_gatearray_gs88000_device, "ms1_gs88000", "Mega System 1 Gate Array GS-88000")
DEFINE_DEVICE_TYPE(MEGASYS1_GATEARRAY_UNKARRAY, megasys1_gatearray_unkarray_device, "ms1_unkarray", "Mega System 1 Gate Array UNKNOWN")
megasys1_gatearray_device::megasys1_gatearray_device(
machine_config const &mconfig,
device_type type,
char const *tag,
device_t *owner,
u32 clock)
: device_t(mconfig, type, tag, owner, clock)
, m_cpu(*this, finder_base::DUMMY_TAG)
, m_cpuregion(*this, finder_base::DUMMY_TAG)
{
m_has_decoded = false;
}
void megasys1_gatearray_device::device_start()
{
save_item(NAME(m_gatearray_hs));
save_item(NAME(m_gatearray_hs_ram));
rom_decode();
install_gatearray_overlay();
}
void megasys1_gatearray_device::device_reset()
{
m_gatearray_hs = 0;
}
void megasys1_gatearray_d65006_device::rom_decode()
{
u16 *RAM = (u16 *)m_cpuregion->base();
int size = m_cpuregion->bytes();
if (size > 0x40000) size = 0x40000;
for (int i = 0 ; i < size/2 ; i++)
{
u16 y;
u16 x = RAM[i];
auto const BITSWAP_0 = [] (u16 x) { return bitswap<16>(x,0xd,0xe,0xf,0x0,0x1,0x8,0x9,0xa,0xb,0xc,0x5,0x6,0x7,0x2,0x3,0x4); };
auto const BITSWAP_1 = [] (u16 x) { return bitswap<16>(x,0xf,0xd,0xb,0x9,0x7,0x5,0x3,0x1,0xe,0xc,0xa,0x8,0x6,0x4,0x2,0x0); };
auto const BITSWAP_2 = [] (u16 x) { return bitswap<16>(x,0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0xb,0xa,0x9,0x8,0xf,0xe,0xd,0xc); };
if (i < 0x08000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0(x);} else {y = BITSWAP_1(x);} }
else if (i < 0x10000/2) { y = BITSWAP_2(x); }
else if (i < 0x18000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0(x);} else {y = BITSWAP_1(x);} }
else if (i < 0x20000/2) { y = BITSWAP_1(x); }
else { y = BITSWAP_2(x); }
RAM[i] = y;
}
}
void megasys1_gatearray_gs88000_device::rom_decode()
{
u16 *RAM = (u16 *)m_cpuregion->base();
int size = m_cpuregion->bytes();
if (size > 0x40000) size = 0x40000;
for (int i = 0 ; i < size/2 ; i++)
{
u16 y;
u16 x = RAM[i];
auto const BITSWAP_0 = [] (u16 x) { return bitswap<16>(x,0xd,0xe,0xf,0x0,0xa,0x9,0x8,0x1,0x6,0x5,0xc,0xb,0x7,0x2,0x3,0x4); };
auto const BITSWAP_1 = [] (u16 x) { return bitswap<16>(x,0xf,0xd,0xb,0x9,0x7,0x5,0x3,0x1,0x8,0xa,0xc,0xe,0x0,0x2,0x4,0x6); };
auto const BITSWAP_2 = [] (u16 x) { return bitswap<16>(x,0x4,0x5,0x6,0x7,0x0,0x1,0x2,0x3,0xb,0xa,0x9,0x8,0xf,0xe,0xd,0xc); };
if (i < 0x08000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0(x);} else {y = BITSWAP_1(x);} }
else if (i < 0x10000/2) { y = BITSWAP_2(x); }
else if (i < 0x18000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0(x);} else {y = BITSWAP_1(x);} }
else if (i < 0x20000/2) { y = BITSWAP_1(x); }
else { y = BITSWAP_2(x); }
RAM[i] = y;
}
}
void megasys1_gatearray_unkarray_device::rom_decode()
{
u16 *RAM = (u16 *)m_cpuregion->base();
int size = m_cpuregion->bytes();
if (size > 0x40000) size = 0x40000;
for (int i = 0 ; i < size/2 ; i++)
{
u16 y;
u16 x = RAM[i];
auto const BITSWAP_0 = [] (u16 x) { return bitswap<16>(x,0xd,0x0,0xa,0x9,0x6,0xe,0xb,0xf,0x5,0xc,0x7,0x2,0x3,0x8,0x1,0x4); };
auto const BITSWAP_1 = [] (u16 x) { return bitswap<16>(x,0x4,0x5,0x6,0x7,0x0,0x1,0x2,0x3,0xb,0xa,0x9,0x8,0xf,0xe,0xd,0xc); };
auto const BITSWAP_2 = [] (u16 x) { return bitswap<16>(x,0xf,0xd,0xb,0x9,0xc,0xe,0x0,0x7,0x5,0x3,0x1,0x8,0xa,0x2,0x4,0x6); };
auto const BITSWAP_3 = [] (u16 x) { return bitswap<16>(x,0x4,0x5,0x1,0x2,0xe,0xd,0x3,0xb,0xa,0x9,0x6,0x7,0x0,0x8,0xf,0xc); };
if (i < 0x08000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0(x);} else {y = BITSWAP_1(x);} }
else if (i < 0x10000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_2(x);} else {y = BITSWAP_3(x);} }
else if (i < 0x18000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0(x);} else {y = BITSWAP_1(x);} }
else if (i < 0x20000/2) { y = BITSWAP_1(x); }
else { y = BITSWAP_3(x); }
RAM[i] = y;
}
}
/*
Gate array handshake sequence:
the UPD65006 gate array can overlay 0x40 bytes of data inside the ROM space.
The offset where this happens is given by m68k to UPD65006 write [0x8/2] << 6.
For example stdragon writes 0x33e -> maps at 0xcf80-0xcfbf while stdragona writes 0x33f -> maps at 0xcfc0-0xcfff.
Note: stdragona forgets to turn off the overlay before the ROM check in service mode (hence it reports an error).
*/
bool megasys1_gatearray_device::gatearray_hs_seq(u16 g1,u16 g2,u16 g3,u16 g4)
{
return (m_gatearray_hs_ram[0/2] == g1 && m_gatearray_hs_ram[2/2] == g2 && m_gatearray_hs_ram[4/2] == g3 && m_gatearray_hs_ram[6/2] == g4);
}
u16 megasys1_gatearray_device::gatearray_r(offs_t offset, u16 mem_mask)
{
u16 *rom_maincpu = (u16 *)m_cpuregion->base();
if(m_gatearray_hs && ((m_gatearray_hs_ram[8/2] << 6) & 0x3ffc0) == ((offset*2) & 0x3ffc0))
{
LOG("GATEARRAY HS R (%04x) <- [%02x]\n",mem_mask,offset*2);
if (m_gatearray_seq)
return m_gatearray_seq[4];
else
return 0;
}
return rom_maincpu[offset];
}
void megasys1_gatearray_device::gatearray_w(offs_t offset, u16 data, u16 mem_mask)
{
// astyanax writes to 0x2000x
// iganinju writes to 0x2f00x
// stdragon writes to 0x23ffx
// tshingen writes to 0x20c0x
// assume writes mirror across the space
if (!m_gatearray_seq)
{
logerror("Write to ROM area with no gatearray sequence");
return;
}
offset &= 0x7;
COMBINE_DATA(&m_gatearray_hs_ram[offset]);
if (gatearray_hs_seq(m_gatearray_seq[0],m_gatearray_seq[1],m_gatearray_seq[2],m_gatearray_seq[3]) && offset == 0x8/2)
m_gatearray_hs = 1;
else
m_gatearray_hs = 0;
LOG("GATEARRAY HS W %04x (%04x) -> [%02x]\n",data,mem_mask,offset*2);
}
void megasys1_gatearray_device::install_gatearray_overlay()
{
m_cpu->space(AS_PROGRAM).install_read_handler(0x00000, 0x3ffff, read16s_delegate(*this, FUNC(megasys1_gatearray_device::gatearray_r)));
m_cpu->space(AS_PROGRAM).install_write_handler(0x20000, 0x2ffff, write16s_delegate(*this, FUNC(megasys1_gatearray_device::gatearray_w)));
m_gatearray_hs = 0;
memset(m_gatearray_hs_ram, 0, sizeof(m_gatearray_hs_ram));
}
megasys1_gatearray_d65006_device::megasys1_gatearray_d65006_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: megasys1_gatearray_d65006_device(mconfig, MEGASYS1_GATEARRAY_D65006, tag, owner, clock)
{
m_gatearray_seq = jaleco_d65006_unlock_sequence;
}
megasys1_gatearray_d65006_device::megasys1_gatearray_d65006_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
: megasys1_gatearray_device(mconfig, type, tag, owner, clock)
{
}
megasys1_gatearray_gs88000_device::megasys1_gatearray_gs88000_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: megasys1_gatearray_gs88000_device(mconfig, MEGASYS1_GATEARRAY_GS88000, tag, owner, clock)
{
m_gatearray_seq = jaleco_gs88000_unlock_sequence;
}
megasys1_gatearray_gs88000_device::megasys1_gatearray_gs88000_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
: megasys1_gatearray_device(mconfig, type, tag, owner, clock)
{
}
megasys1_gatearray_unkarray_device::megasys1_gatearray_unkarray_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: megasys1_gatearray_unkarray_device(mconfig, MEGASYS1_GATEARRAY_UNKARRAY, tag, owner, clock)
{
m_gatearray_seq = nullptr; // only used by rodland, which doesn't enable an overlay
}
megasys1_gatearray_unkarray_device::megasys1_gatearray_unkarray_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
: megasys1_gatearray_device(mconfig, type, tag, owner, clock)
{
}

View File

@ -0,0 +1,97 @@
// license:BSD-3-Clause
// copyright-holders:Angelo Salese, David Haywood
#ifndef MAME_JALECO_MS1_GATEARRAY_H
#define MAME_JALECO_MS1_GATEARRAY_H
#pragma once
class megasys1_gatearray_device : public device_t
{
public:
template <typename T> void set_cpu_tag(T &&tag) { m_cpu.set_tag(std::forward<T>(tag)); }
template <typename T> void set_cpuregion_tag(T &&tag) { m_cpuregion.set_tag(std::forward<T>(tag)); }
protected:
megasys1_gatearray_device(
machine_config const &mconfig,
device_type type,
char const *tag,
device_t *owner,
u32 clock);
virtual void device_start() override;
virtual void device_reset() override;
void install_gatearray_overlay();
u16 gatearray_r(offs_t offset, u16 mem_mask = ~0);
void gatearray_w(offs_t offset, u16 data, u16 mem_mask = ~0);
bool gatearray_hs_seq(u16 g1,u16 g2,u16 g3,u16 g4);
int m_gatearray_hs = 0;
u16 m_gatearray_hs_ram[0x8]{};
const u16* m_gatearray_seq = nullptr;
required_device<cpu_device> m_cpu;
required_memory_region m_cpuregion;
bool m_has_decoded;
virtual void rom_decode() = 0;
};
class megasys1_gatearray_d65006_device : public megasys1_gatearray_device
{
public:
megasys1_gatearray_d65006_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
protected:
megasys1_gatearray_d65006_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
virtual void rom_decode() override;
private:
// write sequence return value
static constexpr u16 jaleco_d65006_unlock_sequence[5] = { 0x0000,0x0055,0x00aa,0x00ff, 0x835d };
};
class megasys1_gatearray_gs88000_device : public megasys1_gatearray_device
{
public:
megasys1_gatearray_gs88000_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
protected:
megasys1_gatearray_gs88000_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
virtual void rom_decode() override;
// write sequence return value
static constexpr u16 jaleco_gs88000_unlock_sequence[5] = { 0x00ff,0x0055,0x00aa,0x0000, 0x889e };
private:
};
class megasys1_gatearray_unkarray_device : public megasys1_gatearray_device
{
public:
megasys1_gatearray_unkarray_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
protected:
megasys1_gatearray_unkarray_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
virtual void rom_decode() override;
private:
};
// device type definition
//DECLARE_DEVICE_TYPE(MEGASYS1_GATEARRAY, megasys1_gatearray_device)
DECLARE_DEVICE_TYPE(MEGASYS1_GATEARRAY_D65006, megasys1_gatearray_d65006_device)
DECLARE_DEVICE_TYPE(MEGASYS1_GATEARRAY_GS88000, megasys1_gatearray_gs88000_device)
DECLARE_DEVICE_TYPE(MEGASYS1_GATEARRAY_UNKARRAY, megasys1_gatearray_unkarray_device)
#endif // MAME_JALECO_MS1_GATEARRAY_H