kaneko_toybox_device: cleanups (nw)

This commit is contained in:
Ivan Vangelista 2014-09-01 19:26:53 +00:00
parent cd119b649c
commit d3fbd22c38
7 changed files with 157 additions and 182 deletions

View File

@ -74,36 +74,40 @@ class galpani3_state : public driver_device
public:
galpani3_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_spriteram(*this, "spriteram"),
m_priority_buffer(*this, "priority_buffer"),
m_sprregs(*this, "sprregs"),
m_sprite_bitmap_1(1024, 1024),
m_maincpu(*this,"maincpu"),
m_grap2_0(*this,"grap2_0"),
m_grap2_1(*this,"grap2_1"),
m_grap2_2(*this,"grap2_2"),
m_palette(*this, "palette"),
m_paletteram(*this, "palette")
m_spritegen(*this, "spritegen"),
m_paletteram(*this, "palette"),
m_spriteram(*this, "spriteram"),
m_priority_buffer(*this, "priority_buffer"),
m_sprregs(*this, "sprregs"),
m_sprite_bitmap_1(1024, 1024)
{ }
optional_shared_ptr<UINT16> m_spriteram;
required_shared_ptr<UINT16> m_priority_buffer;
required_shared_ptr<UINT16> m_sprregs;
bitmap_ind16 m_sprite_bitmap_1;
required_device<cpu_device> m_maincpu;
required_device<kaneko_grap2_device> m_grap2_0;
required_device<kaneko_grap2_device> m_grap2_1;
required_device<kaneko_grap2_device> m_grap2_2;
required_device<palette_device> m_palette;
required_device<sknsspr_device> m_spritegen;
required_shared_ptr<UINT16> m_paletteram;
optional_shared_ptr<UINT16> m_spriteram;
required_shared_ptr<UINT16> m_priority_buffer;
required_shared_ptr<UINT16> m_sprregs;
bitmap_ind16 m_sprite_bitmap_1;
UINT16 m_priority_buffer_scrollx;
UINT16 m_priority_buffer_scrolly;
UINT32 m_spriteram32[0x4000/4];
UINT32 m_spc_regs[0x40/4];
sknsspr_device* m_spritegen;
DECLARE_WRITE16_MEMBER(galpani3_suprnova_sprite32_w);
DECLARE_WRITE16_MEMBER(galpani3_suprnova_sprite32regs_w);
@ -147,8 +151,6 @@ TIMER_DEVICE_CALLBACK_MEMBER(galpani3_state::galpani3_vblank)// 2, 3, 5 ?
void galpani3_state::video_start()
{
/* so we can use suprnova.c */
m_spritegen = machine().device<sknsspr_device>("spritegen");
m_spritegen->skns_sprite_kludge(0,0);
}
@ -465,13 +467,13 @@ static ADDRESS_MAP_START( galpani3_map, AS_PROGRAM, 16, galpani3_state )
AM_RANGE(0x300000, 0x303fff) AM_RAM_WRITE(galpani3_suprnova_sprite32_w) AM_SHARE("spriteram")
AM_RANGE(0x380000, 0x38003f) AM_RAM_WRITE(galpani3_suprnova_sprite32regs_w) AM_SHARE("sprregs")
AM_RANGE(0x400000, 0x40ffff) AM_DEVREADWRITE( "toybox", kaneko_toybox_device, toybox_mcu_ram_r, toybox_mcu_ram_w ) // area [C]
AM_RANGE(0x400000, 0x40ffff) AM_RAM AM_SHARE("mcuram") // area [C]
AM_RANGE(0x580000, 0x580001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com0_w)
AM_RANGE(0x600000, 0x600001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com1_w)
AM_RANGE(0x680000, 0x680001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com2_w)
AM_RANGE(0x700000, 0x700001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com3_w)
AM_RANGE(0x780000, 0x780001) AM_DEVREAD( "toybox", kaneko_toybox_device, toybox_mcu_status_r)
AM_RANGE(0x580000, 0x580001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com0_w)
AM_RANGE(0x600000, 0x600001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com1_w)
AM_RANGE(0x680000, 0x680001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com2_w)
AM_RANGE(0x700000, 0x700001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com3_w)
AM_RANGE(0x780000, 0x780001) AM_DEVREAD( "toybox", kaneko_toybox_device, mcu_status_r)
GRAP2_AREA( 0x800000, "grap2_0" )
GRAP2_AREA( 0xa00000, "grap2_1" )

View File

@ -181,26 +181,27 @@ class jchan_state : public driver_device
public:
jchan_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this,"maincpu"),
m_subcpu(*this,"sub"),
m_palette(*this, "palette"),
m_spritegen1(*this, "spritegen1"),
m_spritegen2(*this, "spritegen2"),
m_view2_0(*this, "view2_0"),
m_spriteram_1(*this, "spriteram_1"),
m_sprregs_1(*this, "sprregs_1"),
m_spriteram_2(*this, "spriteram_2"),
m_sprregs_2(*this, "sprregs_2"),
m_mainsub_shared_ram(*this, "mainsub_shared"),
m_ctrl(*this, "ctrl"),
m_maincpu(*this,"maincpu"),
m_subcpu(*this,"sub"),
m_palette(*this, "palette")
m_ctrl(*this, "ctrl")
{ }
optional_device<kaneko_view2_tilemap_device> m_view2_0;
bitmap_ind16 *m_sprite_bitmap_1;
bitmap_ind16 *m_sprite_bitmap_2;
UINT32* m_sprite_ram32_1;
UINT32* m_sprite_ram32_2;
UINT32* m_sprite_regs32_1;
UINT32* m_sprite_regs32_2;
int m_irq_sub_enable;
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_subcpu;
required_device<palette_device> m_palette;
required_device<sknsspr_device> m_spritegen1;
required_device<sknsspr_device> m_spritegen2;
required_device<kaneko_view2_tilemap_device> m_view2_0;
required_shared_ptr<UINT16> m_spriteram_1;
required_shared_ptr<UINT16> m_sprregs_1;
required_shared_ptr<UINT16> m_spriteram_2;
@ -208,12 +209,13 @@ public:
required_shared_ptr<UINT16> m_mainsub_shared_ram;
required_shared_ptr<UINT16> m_ctrl;
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_subcpu;
required_device<palette_device> m_palette;
sknsspr_device* m_spritegen1;
sknsspr_device* m_spritegen2;
bitmap_ind16 *m_sprite_bitmap_1;
bitmap_ind16 *m_sprite_bitmap_2;
UINT32* m_sprite_ram32_1;
UINT32* m_sprite_ram32_2;
UINT32* m_sprite_regs32_1;
UINT32* m_sprite_regs32_2;
int m_irq_sub_enable;
DECLARE_WRITE16_MEMBER(jchan_ctrl_w);
DECLARE_READ16_MEMBER(jchan_ctrl_r);
@ -284,10 +286,6 @@ void jchan_state::video_start()
m_sprite_bitmap_1 = auto_bitmap_ind16_alloc(machine(),1024,1024);
m_sprite_bitmap_2 = auto_bitmap_ind16_alloc(machine(),1024,1024);
m_spritegen1 = machine().device<sknsspr_device>("spritegen1");
m_spritegen2 = machine().device<sknsspr_device>("spritegen2");
m_spritegen1->skns_sprite_kludge(0,0);
m_spritegen2->skns_sprite_kludge(0,0);
}
@ -435,12 +433,12 @@ static ADDRESS_MAP_START( jchan_main, AS_PROGRAM, 16, jchan_state )
AM_RANGE(0x000000, 0x1fffff) AM_ROM
AM_RANGE(0x200000, 0x20ffff) AM_RAM // Work RAM - [A] grid tested, cleared ($9d6-$a54)
AM_RANGE(0x300000, 0x30ffff) AM_DEVREADWRITE( "toybox", kaneko_toybox_device, toybox_mcu_ram_r, toybox_mcu_ram_w )// [G] MCU share
AM_RANGE(0x330000, 0x330001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com0_w)
AM_RANGE(0x340000, 0x340001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com1_w)
AM_RANGE(0x350000, 0x350001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com2_w)
AM_RANGE(0x360000, 0x360001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com3_w)
AM_RANGE(0x370000, 0x370001) AM_DEVREAD( "toybox", kaneko_toybox_device, toybox_mcu_status_r)
AM_RANGE(0x300000, 0x30ffff) AM_RAM AM_SHARE("mcuram") // [G] MCU share
AM_RANGE(0x330000, 0x330001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com0_w)
AM_RANGE(0x340000, 0x340001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com1_w)
AM_RANGE(0x350000, 0x350001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com2_w)
AM_RANGE(0x360000, 0x360001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com3_w)
AM_RANGE(0x370000, 0x370001) AM_DEVREAD( "toybox", kaneko_toybox_device, mcu_status_r)
AM_RANGE(0x400000, 0x403fff) AM_RAM AM_SHARE("mainsub_shared")

View File

@ -421,11 +421,11 @@ WRITE16_MEMBER(kaneko16_gtmr_state::bloodwar_coin_lockout_w)
static ADDRESS_MAP_START( bloodwar, AS_PROGRAM, 16, kaneko16_gtmr_state )
AM_RANGE(0x000000, 0x0fffff) AM_ROM // ROM
AM_RANGE(0x100000, 0x10ffff) AM_RAM // Work RAM
AM_RANGE(0x200000, 0x20ffff) AM_DEVREADWRITE( "toybox", kaneko_toybox_device, toybox_mcu_ram_r, toybox_mcu_ram_w )
AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com0_w) // To MCU ?
AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com1_w)
AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com2_w)
AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com3_w)
AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_SHARE("mcuram")
AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com0_w) // To MCU ?
AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com1_w)
AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com2_w)
AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com3_w)
AM_RANGE(0x300000, 0x30ffff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") // Palette
AM_RANGE(0x400000, 0x401fff) AM_RAM AM_SHARE("spriteram") // Sprites
AM_RANGE(0x500000, 0x503fff) AM_DEVREADWRITE("view2_0", kaneko_view2_tilemap_device, kaneko_tmap_vram_r, kaneko_tmap_vram_w )
@ -443,7 +443,7 @@ static ADDRESS_MAP_START( bloodwar, AS_PROGRAM, 16, kaneko16_gtmr_state )
AM_RANGE(0xb00006, 0xb00007) AM_READ_PORT("EXTRA")
AM_RANGE(0xb80000, 0xb80001) AM_WRITE(bloodwar_coin_lockout_w) // Coin Lockout
AM_RANGE(0xc00000, 0xc00001) AM_WRITE(kaneko16_display_enable)
AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, toybox_mcu_status_r)
AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, mcu_status_r)
AM_RANGE(0xe00000, 0xe00001) AM_WRITE(bloodwar_oki_0_bank_w)
AM_RANGE(0xe80000, 0xe80001) AM_WRITE(bloodwar_oki_1_bank_w)
ADDRESS_MAP_END
@ -475,11 +475,11 @@ WRITE16_MEMBER(kaneko16_gtmr_state::bonkadv_oki_1_bank_w)
static ADDRESS_MAP_START( bonkadv, AS_PROGRAM, 16, kaneko16_gtmr_state )
AM_RANGE(0x000000, 0x0fffff) AM_ROM // ROM
AM_RANGE(0x100000, 0x10ffff) AM_RAM // Work RAM
AM_RANGE(0x200000, 0x20ffff) AM_DEVREADWRITE( "toybox", kaneko_toybox_device, toybox_mcu_ram_r, toybox_mcu_ram_w ) // Shared With MCU
AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com0_w) // To MCU ?
AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com1_w)
AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com2_w)
AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com3_w)
AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_SHARE("mcuram") // Shared With MCU
AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com0_w) // To MCU ?
AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com1_w)
AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com2_w)
AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com3_w)
AM_RANGE(0x300000, 0x30ffff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") // Palette
AM_RANGE(0x400000, 0x401fff) AM_RAM AM_SHARE("spriteram") // Sprites
AM_RANGE(0x500000, 0x503fff) AM_DEVREADWRITE("view2_0", kaneko_view2_tilemap_device, kaneko_tmap_vram_r, kaneko_tmap_vram_w )
@ -497,7 +497,7 @@ static ADDRESS_MAP_START( bonkadv, AS_PROGRAM, 16, kaneko16_gtmr_state )
AM_RANGE(0xb00006, 0xb00007) AM_READ_PORT("UNK")
AM_RANGE(0xb80000, 0xb80001) AM_WRITE(bloodwar_coin_lockout_w) // Coin Lockout
AM_RANGE(0xc00000, 0xc00001) AM_WRITE(kaneko16_display_enable)
AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, toybox_mcu_status_r)
AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, mcu_status_r)
AM_RANGE(0xe00000, 0xe00001) AM_WRITE(bonkadv_oki_0_bank_w)
AM_RANGE(0xe80000, 0xe80001) AM_WRITE(bonkadv_oki_1_bank_w)
ADDRESS_MAP_END
@ -545,12 +545,12 @@ static ADDRESS_MAP_START( gtmr_map, AS_PROGRAM, 16, kaneko16_gtmr_state )
AM_RANGE(0x0ffffe, 0x0fffff) AM_READ(gtmr_wheel_r) // Wheel Value
AM_RANGE(0x100000, 0x10ffff) AM_RAM // Work RAM
AM_RANGE(0x200000, 0x20ffff) AM_DEVREADWRITE( "toybox", kaneko_toybox_device, toybox_mcu_ram_r, toybox_mcu_ram_w ) // Shared With MCU
AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_SHARE("mcuram") // Shared With MCU
AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com0_w) // To MCU ?
AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com1_w)
AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com2_w)
AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com3_w)
AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com0_w) // To MCU ?
AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com1_w)
AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com2_w)
AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com3_w)
AM_RANGE(0x300000, 0x30ffff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") // Palette
AM_RANGE(0x310000, 0x327fff) AM_RAM //
@ -577,7 +577,7 @@ static ADDRESS_MAP_START( gtmr_map, AS_PROGRAM, 16, kaneko16_gtmr_state )
AM_RANGE(0xb80000, 0xb80001) AM_WRITE(kaneko16_coin_lockout_w) // Coin Lockout
AM_RANGE(0xc00000, 0xc00001) AM_WRITE(kaneko16_display_enable) // might do more than that
AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, toybox_mcu_status_r)
AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, mcu_status_r)
AM_RANGE(0xe00000, 0xe00001) AM_WRITE(gtmr_oki_0_bank_w) // Samples Bankswitching
AM_RANGE(0xe80000, 0xe80001) AM_WRITE(gtmr_oki_1_bank_w)
@ -614,12 +614,12 @@ static ADDRESS_MAP_START( gtmr2_map, AS_PROGRAM, 16, kaneko16_gtmr_state )
AM_RANGE(0x0ffffe, 0x0fffff) AM_READ(gtmr2_wheel_r) // Wheel Value
AM_RANGE(0x100000, 0x10ffff) AM_RAM // Work RAM
AM_RANGE(0x200000, 0x20ffff) AM_DEVREADWRITE( "toybox", kaneko_toybox_device, toybox_mcu_ram_r, toybox_mcu_ram_w ) // Shared With MCU
AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_SHARE("mcuram") // Shared With MCU
AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com0_w) // To MCU ?
AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com1_w)
AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com2_w)
AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com3_w)
AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com0_w) // To MCU ?
AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com1_w)
AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com2_w)
AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com3_w)
AM_RANGE(0x300000, 0x30ffff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") // Palette
AM_RANGE(0x310000, 0x327fff) AM_RAM //
@ -645,7 +645,7 @@ static ADDRESS_MAP_START( gtmr2_map, AS_PROGRAM, 16, kaneko16_gtmr_state )
AM_RANGE(0xb80000, 0xb80001) AM_WRITE(kaneko16_coin_lockout_w) // Coin Lockout
AM_RANGE(0xc00000, 0xc00001) AM_WRITE(kaneko16_display_enable) // might do more than that
AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, toybox_mcu_status_r)
AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, mcu_status_r)
AM_RANGE(0xe00000, 0xe00001) AM_WRITE(gtmr_oki_0_bank_w) // Samples Bankswitching
AM_RANGE(0xe80000, 0xe80001) AM_WRITE(gtmr_oki_1_bank_w)
@ -1907,8 +1907,6 @@ static MACHINE_CONFIG_START( gtmr, kaneko16_gtmr_state )
MCFG_KANEKO16_SPRITE_GFXDECODE("gfxdecode")
MCFG_DEVICE_ADD("toybox", KANEKO_TOYBOX, 0)
kaneko_toybox_device::set_toybox_table(*device, TABLE_NORMAL);
kaneko_toybox_device::set_toybox_gametype(*device, GAME_NORMAL);
/* part of the toybox? */
MCFG_DEVICE_ADD("kan_hit", KANEKO_HIT, 0)
kaneko_hit_device::set_type(*device, 1);
@ -1928,7 +1926,7 @@ MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( gtmre, gtmr )
MCFG_DEVICE_MODIFY("toybox")
kaneko_toybox_device::set_toybox_table(*device, TABLE_ALT);
MCFG_TOYBOX_TABLE_TYPE(TABLE_ALT)
MACHINE_CONFIG_END
/***************************************************************************
@ -1980,7 +1978,7 @@ static MACHINE_CONFIG_DERIVED( bonkadv, gtmr )
MCFG_DEVICE_MODIFY("toybox")
kaneko_toybox_device::set_toybox_gametype(*device, GAME_BONK);
MCFG_TOYBOX_GAME_TYPE(GAME_BONK)
MCFG_DEVICE_MODIFY("kan_hit")
kaneko_hit_device::set_type(*device, 0);

View File

@ -24,6 +24,9 @@ public:
skns_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this,"maincpu"),
m_spritegen(*this, "spritegen"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
m_spriteram(*this,"spriteram"),
m_spc_regs(*this, "spc_regs"),
m_v3_regs(*this, "v3_regs"),
@ -34,14 +37,14 @@ public:
m_palette_ram(*this, "palette_ram"),
m_v3t_ram(*this, "v3t_ram"),
m_main_ram(*this, "main_ram"),
m_cache_ram(*this, "cache_ram"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette") { }
m_cache_ram(*this, "cache_ram") { }
required_device<sh2_device> m_maincpu;
required_device<sknsspr_device> m_spritegen;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
required_shared_ptr<UINT32> m_spriteram;
sknsspr_device* m_spritegen;
required_shared_ptr<UINT32> m_spc_regs;
required_shared_ptr<UINT32> m_v3_regs;
required_shared_ptr<UINT32> m_tilemapA_ram;
@ -52,8 +55,7 @@ public:
required_shared_ptr<UINT32> m_v3t_ram;
required_shared_ptr<UINT32> m_main_ram;
required_shared_ptr<UINT32> m_cache_ram;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
hit_t m_hit;
UINT32 m_timer_0_temp[4];
bitmap_ind16 m_sprite_bitmap;

View File

@ -52,85 +52,63 @@ mcu_subcmd = kaneko16_mcu_ram[0x0014/2]; // sub-command parameter, happens o
const device_type KANEKO_TOYBOX = &device_creator<kaneko_toybox_device>;
kaneko_toybox_device::kaneko_toybox_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, KANEKO_TOYBOX, "Kaneko Toybox MCU", tag, owner, clock, "kaneko_toybox", __FILE__)
: device_t(mconfig, KANEKO_TOYBOX, "Kaneko Toybox MCU", tag, owner, clock, "kaneko_toybox", __FILE__),
m_mcuram(*this, ":mcuram"),
m_gametype(GAME_NORMAL),
m_tabletype(TABLE_NORMAL)
{
m_tabletype = TABLE_NORMAL;
m_gametype = GAME_NORMAL;
m_mcu_com[0] = m_mcu_com[1] = m_mcu_com[2] = m_mcu_com[3] = 0;
}
void kaneko_toybox_device::set_toybox_table(device_t &device, int tabletype)
void kaneko_toybox_device::set_table(device_t &device, int tabletype)
{
kaneko_toybox_device &dev = downcast<kaneko_toybox_device &>(device);
dev.m_tabletype = tabletype;
}
void kaneko_toybox_device::set_toybox_gametype(device_t &device, int gametype)
void kaneko_toybox_device::set_game_type(device_t &device, int gametype)
{
kaneko_toybox_device &dev = downcast<kaneko_toybox_device &>(device);
dev.m_gametype = gametype;
}
void kaneko_toybox_device::device_start()
{
m_toybox_mcuram = (UINT16*)auto_alloc_array_clear(this->machine(), UINT16, 0x10000/2);
memset(m_toybox_mcu_com, 0, 4 * sizeof( UINT16) );
toxboy_decrypt_rom(this->machine());
save_pointer(NAME(m_toybox_mcuram), 0x10000/2);
save_item(NAME(m_toybox_mcu_com[0]));
save_item(NAME(m_toybox_mcu_com[1]));
save_item(NAME(m_toybox_mcu_com[2]));
save_item(NAME(m_toybox_mcu_com[3]));
memset(m_mcu_com, 0, 4 * sizeof( UINT16) );
decrypt_rom();
save_item(NAME(m_mcu_com));
}
void kaneko_toybox_device::device_reset()
{
toybox_mcu_init(this->machine());
mcu_init();
}
READ16_MEMBER(kaneko_toybox_device::toybox_mcu_ram_r)
{
return m_toybox_mcuram[offset];
}
WRITE16_MEMBER(kaneko_toybox_device::toybox_mcu_ram_w)
{
COMBINE_DATA(&m_toybox_mcuram[offset]);
}
#define MCU_RESPONSE(d) memcpy(&m_toybox_mcuram[mcu_offset], d, sizeof(d))
#define MCU_RESPONSE(d) memcpy(&m_mcuram[mcu_offset], d, sizeof(d))
// I use a byteswapped MCU data rom to make the transfers to the 68k side easier
// not sure if it's all 100% endian safe
void kaneko_toybox_device::toxboy_decrypt_rom(running_machine& machine)
void kaneko_toybox_device::decrypt_rom()
{
UINT8 *src = (UINT8 *)machine.root_device().memregion(":mcudata" )->base();
UINT8 *src = (UINT8 *)machine().root_device().memregion(":mcudata")->base();
int i;
for (i=0;i<0x020000;i++)
{
if (m_tabletype == TABLE_NORMAL) src[i] = src[i] + toybox_mcu_decryption_table[(i^1)&0xff];
else src[i] = src[i] + toybox_mcu_decryption_table_alt[(i^1)&0xff];
if (m_tabletype == TABLE_NORMAL) src[i] = src[i] + decryption_table[(i^1)&0xff];
else src[i] = src[i] + decryption_table_alt[(i^1)&0xff];
}
}
void kaneko_toybox_device::toxboy_handle_04_subcommand(running_machine& machine,UINT8 mcu_subcmd, UINT16*mcu_ram)
void kaneko_toybox_device::handle_04_subcommand(UINT8 mcu_subcmd, UINT16 *mcu_ram)
{
UINT8 *src = (UINT8 *)machine.root_device().memregion(":mcudata")->base()+0x10000;
UINT8 *src = (UINT8 *)machine().root_device().memregion(":mcudata")->base()+0x10000;
UINT8* dst = (UINT8 *)mcu_ram;
int offs = (mcu_subcmd&0x3f)*8;
@ -151,32 +129,32 @@ void kaneko_toybox_device::toxboy_handle_04_subcommand(running_machine& machine,
}
void kaneko_toybox_device::toybox_mcu_init(running_machine &machine)
void kaneko_toybox_device::mcu_init()
{
memset(m_toybox_mcu_com, 0, 4 * sizeof( UINT16) );
memset(m_mcu_com, 0, 4 * sizeof( UINT16) );
}
void kaneko_toybox_device::toybox_mcu_com_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _n_)
void kaneko_toybox_device::mcu_com_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _n_)
{
COMBINE_DATA(&m_toybox_mcu_com[_n_]);
if (m_toybox_mcu_com[0] != 0xFFFF) return;
if (m_toybox_mcu_com[1] != 0xFFFF) return;
if (m_toybox_mcu_com[2] != 0xFFFF) return;
if (m_toybox_mcu_com[3] != 0xFFFF) return;
COMBINE_DATA(&m_mcu_com[_n_]);
if (m_mcu_com[0] != 0xFFFF) return;
if (m_mcu_com[1] != 0xFFFF) return;
if (m_mcu_com[2] != 0xFFFF) return;
if (m_mcu_com[3] != 0xFFFF) return;
memset(m_toybox_mcu_com, 0, 4 * sizeof( UINT16 ) );
toybox_mcu_run(machine());
memset(m_mcu_com, 0, 4 * sizeof( UINT16 ) );
mcu_run();
}
WRITE16_MEMBER(kaneko_toybox_device::toybox_mcu_com0_w){ toybox_mcu_com_w(offset, data, mem_mask, 0); }
WRITE16_MEMBER(kaneko_toybox_device::toybox_mcu_com1_w){ toybox_mcu_com_w(offset, data, mem_mask, 1); }
WRITE16_MEMBER(kaneko_toybox_device::toybox_mcu_com2_w){ toybox_mcu_com_w(offset, data, mem_mask, 2); }
WRITE16_MEMBER(kaneko_toybox_device::toybox_mcu_com3_w){ toybox_mcu_com_w(offset, data, mem_mask, 3); }
WRITE16_MEMBER(kaneko_toybox_device::mcu_com0_w){ mcu_com_w(offset, data, mem_mask, 0); }
WRITE16_MEMBER(kaneko_toybox_device::mcu_com1_w){ mcu_com_w(offset, data, mem_mask, 1); }
WRITE16_MEMBER(kaneko_toybox_device::mcu_com2_w){ mcu_com_w(offset, data, mem_mask, 2); }
WRITE16_MEMBER(kaneko_toybox_device::mcu_com3_w){ mcu_com_w(offset, data, mem_mask, 3); }
/*
bonkadv and bloodwar test bit 0
*/
READ16_MEMBER(kaneko_toybox_device::toybox_mcu_status_r)
READ16_MEMBER(kaneko_toybox_device::mcu_status_r)
{
logerror("CPU %s (PC=%06X) : read MCU status\n", space.device().tag(), space.device().safe_pcbase());
return 0; // most games test bit 0 for failure
@ -184,12 +162,11 @@ READ16_MEMBER(kaneko_toybox_device::toybox_mcu_status_r)
void kaneko_toybox_device::toybox_mcu_run(running_machine &machine)
void kaneko_toybox_device::mcu_run()
{
UINT16 *kaneko16_mcu_ram = m_toybox_mcuram;
UINT16 mcu_command = kaneko16_mcu_ram[0x0010/2];
UINT16 mcu_offset = kaneko16_mcu_ram[0x0012/2] / 2;
UINT16 mcu_data = kaneko16_mcu_ram[0x0014/2];
UINT16 mcu_command = m_mcuram[0x0010/2];
UINT16 mcu_offset = m_mcuram[0x0012/2] / 2;
UINT16 mcu_data = m_mcuram[0x0014/2];
//printf("command %04x\n",mcu_command);
@ -197,30 +174,30 @@ void kaneko_toybox_device::toybox_mcu_run(running_machine &machine)
{
case 0x02: // Read from NVRAM
{
UINT8* nvdat = (UINT8*)&kaneko16_mcu_ram[mcu_offset];
UINT8* nvdat = (UINT8*)&m_mcuram[mcu_offset];
address_space &eeprom_space = machine.device<eeprom_serial_93cxx_device>(":eeprom")->space();
address_space &eeprom_space = machine().device<eeprom_serial_93cxx_device>(":eeprom")->space();
for (int i=0;i<0x80;i++)
{
nvdat[i] = eeprom_space.read_byte(i);
}
logerror("%s : MCU executed command: %04X %04X (load NVRAM settings)\n", machine.describe_context(), mcu_command, mcu_offset*2);
logerror("%s : MCU executed command: %04X %04X (load NVRAM settings)\n", machine().describe_context(), mcu_command, mcu_offset*2);
}
break;
case 0x42: // Write to NVRAM
{
address_space &eeprom_space = machine.device<eeprom_serial_93cxx_device>(":eeprom")->space();
UINT8* nvdat = (UINT8*)&kaneko16_mcu_ram[mcu_offset];
address_space &eeprom_space = machine().device<eeprom_serial_93cxx_device>(":eeprom")->space();
UINT8* nvdat = (UINT8*)&m_mcuram[mcu_offset];
for (int i=0;i<0x80;i++)
{
eeprom_space.write_byte(i, nvdat[i]);
}
logerror("%s : MCU executed command: %04X %04X (save NVRAM settings)\n", machine.describe_context(), mcu_command, mcu_offset*2);
logerror("%s : MCU executed command: %04X %04X (save NVRAM settings)\n", machine().describe_context(), mcu_command, mcu_offset*2);
}
break;
@ -232,27 +209,27 @@ void kaneko_toybox_device::toybox_mcu_run(running_machine &machine)
//memcpy(m_nvram_save, bonkadv_mcu_43, sizeof(bonkadv_mcu_43));
address_space &eeprom_space = machine.device<eeprom_serial_93cxx_device>(":eeprom")->space();
address_space &eeprom_space = machine().device<eeprom_serial_93cxx_device>(":eeprom")->space();
UINT8* nvdat = (UINT8*)&bonkadv_mcu_43[0];
for (int i=0;i<0x80;i++)
{
eeprom_space.write_byte(i, nvdat[i]);
}
logerror("%s : MCU executed command: %04X %04X (restore default NVRAM settings)\n", machine.describe_context(), mcu_command, mcu_offset*2);
logerror("%s : MCU executed command: %04X %04X (restore default NVRAM settings)\n", machine().describe_context(), mcu_command, mcu_offset*2);
}
}
break;
case 0x03: // DSW
{
kaneko16_mcu_ram[mcu_offset] = machine.root_device().ioport(":DSW1")->read();
logerror("%s : MCU executed command: %04X %04X (read DSW)\n", machine.describe_context(), mcu_command, mcu_offset*2);
m_mcuram[mcu_offset] = machine().root_device().ioport(":DSW1")->read();
logerror("%s : MCU executed command: %04X %04X (read DSW)\n", machine().describe_context(), mcu_command, mcu_offset*2);
}
break;
case 0x04: // Protection
{
logerror("%s : MCU executed command: %04X %04X %04X\n", machine.describe_context(), mcu_command, mcu_offset*2, mcu_data);
logerror("%s : MCU executed command: %04X %04X %04X\n", machine().describe_context(), mcu_command, mcu_offset*2, mcu_data);
if (m_gametype == GAME_BONK)
{
@ -268,21 +245,21 @@ void kaneko_toybox_device::toybox_mcu_run(running_machine &machine)
// dynamic, per-level (29), in level order
default:
toxboy_handle_04_subcommand(machine, mcu_data, kaneko16_mcu_ram);
handle_04_subcommand(mcu_data, m_mcuram);
break;
}
}
else
{
toxboy_handle_04_subcommand(machine, mcu_data, kaneko16_mcu_ram);
handle_04_subcommand(mcu_data, m_mcuram);
}
}
break;
default:
logerror("%s : MCU executed command: %04X %04X %04X (UNKNOWN COMMAND)\n", machine.describe_context(), mcu_command, mcu_offset*2, mcu_data);
logerror("%s : MCU executed command: %04X %04X %04X (UNKNOWN COMMAND)\n", machine().describe_context(), mcu_command, mcu_offset*2, mcu_data);
break;
}
}

View File

@ -290,7 +290,7 @@ static const UINT16 bonkadv_mcu_4_33[] = {
};
/* decryption table */
static const UINT8 toybox_mcu_decryption_table[0x100] = {
static const UINT8 decryption_table[0x100] = {
0x7b,0x82,0xf0,0xbc,0x7f,0x1d,0xa2,0xc5,0x2a,0xfa,0x55,0xee,0x1a,0xd0,0x59,0x76,
0x5e,0x75,0x79,0x16,0xa5,0xf6,0x84,0xed,0x0f,0x2e,0xf2,0x36,0x61,0xac,0xcd,0xab,
0x01,0x3b,0x01,0x87,0x73,0xab,0xce,0x5d,0xd4,0x1d,0x68,0x2a,0x35,0xea,0x13,0x27,
@ -310,7 +310,7 @@ static const UINT8 toybox_mcu_decryption_table[0x100] = {
};
/* alt decryption table (gtmr2) */
static const UINT8 toybox_mcu_decryption_table_alt[0x100] = {
static const UINT8 decryption_table_alt[0x100] = {
0x26,0x17,0xb9,0xcf,0x1a,0xf5,0x14,0x1e,0x0c,0x35,0xb3,0x66,0xa0,0x17,0xe9,0xe4,
0x90,0xf6,0xd5,0x35,0xac,0x95,0x49,0x43,0x64,0x0c,0x03,0x75,0x4d,0xda,0xb6,0xdf,
0x06,0xcf,0x83,0x9e,0x35,0x2c,0x71,0x2a,0xab,0xcc,0x65,0xd4,0x1f,0xb0,0x88,0x3c,
@ -335,37 +335,37 @@ class kaneko_toybox_device : public device_t
public:
kaneko_toybox_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
static void set_toybox_table(device_t &device, int tabletype);
static void set_toybox_gametype(device_t &device, int gametype);
static void set_table(device_t &device, int tabletype);
static void set_game_type(device_t &device, int gametype);
DECLARE_READ16_MEMBER(toybox_mcu_ram_r);
DECLARE_WRITE16_MEMBER(toybox_mcu_ram_w);
DECLARE_WRITE16_MEMBER(toybox_mcu_com0_w);
DECLARE_WRITE16_MEMBER(toybox_mcu_com1_w);
DECLARE_WRITE16_MEMBER(toybox_mcu_com2_w);
DECLARE_WRITE16_MEMBER(toybox_mcu_com3_w);
DECLARE_READ16_MEMBER(toybox_mcu_status_r);
void toybox_mcu_com_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _n_);
void toxboy_decrypt_rom(running_machine& machine);
void toxboy_handle_04_subcommand(running_machine& machine,UINT8 mcu_subcmd, UINT16*mcu_ram);
void toybox_mcu_init(running_machine &machine);
void toybox_mcu_run(running_machine &machine);
UINT16 m_toybox_mcu_com[4];
int m_gametype;
int m_tabletype;
DECLARE_WRITE16_MEMBER(mcu_com0_w);
DECLARE_WRITE16_MEMBER(mcu_com1_w);
DECLARE_WRITE16_MEMBER(mcu_com2_w);
DECLARE_WRITE16_MEMBER(mcu_com3_w);
DECLARE_READ16_MEMBER(mcu_status_r);
protected:
virtual void device_start();
virtual void device_reset();
private:
UINT16* m_toybox_mcuram;
required_shared_ptr<UINT16> m_mcuram;
UINT16 m_mcu_com[4];
int m_gametype;
int m_tabletype;
void mcu_com_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _n_);
void decrypt_rom();
void handle_04_subcommand(UINT8 mcu_subcmd, UINT16 *mcu_ram);
void mcu_init();
void mcu_run();
};
extern const device_type KANEKO_TOYBOX;
#define MCFG_TOYBOX_TABLE_TYPE(_type) \
kaneko_toybox_device::set_table(*device, _type);
#define MCFG_TOYBOX_GAME_TYPE(_type) \
kaneko_toybox_device::set_game_type(*device, _type);

View File

@ -343,8 +343,6 @@ WRITE32_MEMBER(skns_state::skns_v3_regs_w)
void skns_state::video_start()
{
m_spritegen = machine().device<sknsspr_device>("spritegen");
m_tilemap_A = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(skns_state::get_tilemap_A_tile_info),this),TILEMAP_SCAN_ROWS,16,16,64, 64);
m_tilemap_A->set_transparent_pen(0);