Previous 199869 Revisions Next

r31860 Monday 1st September, 2014 at 19:26:53 UTC by Osso
kaneko_toybox_device: cleanups (nw)
[src/mame/drivers]galpani3.c jchan.c kaneko16.c
[src/mame/includes]suprnova.h
[src/mame/machine]kaneko_toybox.c kaneko_toybox.h
[src/mame/video]suprnova.c

trunk/src/mame/drivers/galpani3.c
r31859r31860
7474public:
7575   galpani3_state(const machine_config &mconfig, device_type type, const char *tag)
7676      : driver_device(mconfig, type, tag),
77      m_spriteram(*this, "spriteram"),
78      m_priority_buffer(*this, "priority_buffer"),
79      m_sprregs(*this, "sprregs"),
80      m_sprite_bitmap_1(1024, 1024),
8177      m_maincpu(*this,"maincpu"),
8278      m_grap2_0(*this,"grap2_0"),
8379      m_grap2_1(*this,"grap2_1"),
8480      m_grap2_2(*this,"grap2_2"),
8581      m_palette(*this, "palette"),
86      m_paletteram(*this, "palette")
82      m_spritegen(*this, "spritegen"),
83      m_paletteram(*this, "palette"),
84      m_spriteram(*this, "spriteram"),
85      m_priority_buffer(*this, "priority_buffer"),
86      m_sprregs(*this, "sprregs"),
87      m_sprite_bitmap_1(1024, 1024)
88     
8789   { }
8890
89   optional_shared_ptr<UINT16> m_spriteram;
90   required_shared_ptr<UINT16> m_priority_buffer;
91   required_shared_ptr<UINT16> m_sprregs;
92   bitmap_ind16 m_sprite_bitmap_1;
9391   required_device<cpu_device> m_maincpu;
9492   required_device<kaneko_grap2_device> m_grap2_0;
9593   required_device<kaneko_grap2_device> m_grap2_1;
9694   required_device<kaneko_grap2_device> m_grap2_2;
9795   required_device<palette_device> m_palette;
96   required_device<sknsspr_device> m_spritegen;
97   
9898   required_shared_ptr<UINT16> m_paletteram;
99   optional_shared_ptr<UINT16> m_spriteram;
100   required_shared_ptr<UINT16> m_priority_buffer;
101   required_shared_ptr<UINT16> m_sprregs;
99102
103   bitmap_ind16 m_sprite_bitmap_1;
104   
100105   UINT16 m_priority_buffer_scrollx;
101106   UINT16 m_priority_buffer_scrolly;
102107
103108   UINT32 m_spriteram32[0x4000/4];
104109   UINT32 m_spc_regs[0x40/4];
105110
106   sknsspr_device* m_spritegen;
107111   DECLARE_WRITE16_MEMBER(galpani3_suprnova_sprite32_w);
108112   DECLARE_WRITE16_MEMBER(galpani3_suprnova_sprite32regs_w);
109113
r31859r31860
147151void galpani3_state::video_start()
148152{
149153   /* so we can use suprnova.c */
150
151   m_spritegen = machine().device<sknsspr_device>("spritegen");
152154   m_spritegen->skns_sprite_kludge(0,0);
153155}
154156
r31859r31860
465467   AM_RANGE(0x300000, 0x303fff) AM_RAM_WRITE(galpani3_suprnova_sprite32_w) AM_SHARE("spriteram")
466468   AM_RANGE(0x380000, 0x38003f) AM_RAM_WRITE(galpani3_suprnova_sprite32regs_w) AM_SHARE("sprregs")
467469
468   AM_RANGE(0x400000, 0x40ffff) AM_DEVREADWRITE( "toybox", kaneko_toybox_device, toybox_mcu_ram_r, toybox_mcu_ram_w ) // area [C]
470   AM_RANGE(0x400000, 0x40ffff) AM_RAM AM_SHARE("mcuram") // area [C]
469471
470   AM_RANGE(0x580000, 0x580001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com0_w)
471   AM_RANGE(0x600000, 0x600001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com1_w)
472   AM_RANGE(0x680000, 0x680001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com2_w)
473   AM_RANGE(0x700000, 0x700001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com3_w)
474   AM_RANGE(0x780000, 0x780001) AM_DEVREAD( "toybox", kaneko_toybox_device, toybox_mcu_status_r)
472   AM_RANGE(0x580000, 0x580001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com0_w)
473   AM_RANGE(0x600000, 0x600001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com1_w)
474   AM_RANGE(0x680000, 0x680001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com2_w)
475   AM_RANGE(0x700000, 0x700001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com3_w)
476   AM_RANGE(0x780000, 0x780001) AM_DEVREAD( "toybox", kaneko_toybox_device, mcu_status_r)
475477
476478   GRAP2_AREA( 0x800000, "grap2_0" )
477479   GRAP2_AREA( 0xa00000, "grap2_1" )
trunk/src/mame/drivers/kaneko16.c
r31859r31860
421421static ADDRESS_MAP_START( bloodwar, AS_PROGRAM, 16, kaneko16_gtmr_state )
422422   AM_RANGE(0x000000, 0x0fffff) AM_ROM     // ROM
423423   AM_RANGE(0x100000, 0x10ffff) AM_RAM     // Work RAM
424   AM_RANGE(0x200000, 0x20ffff) AM_DEVREADWRITE( "toybox", kaneko_toybox_device, toybox_mcu_ram_r, toybox_mcu_ram_w )
425   AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com0_w)    // To MCU ?
426   AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com1_w)
427   AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com2_w)
428   AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com3_w)
424   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_SHARE("mcuram")
425   AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com0_w)    // To MCU ?
426   AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com1_w)
427   AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com2_w)
428   AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com3_w)
429429   AM_RANGE(0x300000, 0x30ffff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")    // Palette
430430   AM_RANGE(0x400000, 0x401fff) AM_RAM AM_SHARE("spriteram")                   // Sprites
431431   AM_RANGE(0x500000, 0x503fff) AM_DEVREADWRITE("view2_0", kaneko_view2_tilemap_device,  kaneko_tmap_vram_r, kaneko_tmap_vram_w )
r31859r31860
443443   AM_RANGE(0xb00006, 0xb00007) AM_READ_PORT("EXTRA")
444444   AM_RANGE(0xb80000, 0xb80001) AM_WRITE(bloodwar_coin_lockout_w)  // Coin Lockout
445445   AM_RANGE(0xc00000, 0xc00001) AM_WRITE(kaneko16_display_enable)
446   AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, toybox_mcu_status_r)
446   AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, mcu_status_r)
447447   AM_RANGE(0xe00000, 0xe00001) AM_WRITE(bloodwar_oki_0_bank_w)
448448   AM_RANGE(0xe80000, 0xe80001) AM_WRITE(bloodwar_oki_1_bank_w)
449449ADDRESS_MAP_END
r31859r31860
475475static ADDRESS_MAP_START( bonkadv, AS_PROGRAM, 16, kaneko16_gtmr_state )
476476   AM_RANGE(0x000000, 0x0fffff) AM_ROM     // ROM
477477   AM_RANGE(0x100000, 0x10ffff) AM_RAM     // Work RAM
478   AM_RANGE(0x200000, 0x20ffff) AM_DEVREADWRITE( "toybox", kaneko_toybox_device, toybox_mcu_ram_r, toybox_mcu_ram_w )      // Shared With MCU
479   AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com0_w)    // To MCU ?
480   AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com1_w)
481   AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com2_w)
482   AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com3_w)
478   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_SHARE("mcuram")      // Shared With MCU
479   AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com0_w)    // To MCU ?
480   AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com1_w)
481   AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com2_w)
482   AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com3_w)
483483   AM_RANGE(0x300000, 0x30ffff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")    // Palette
484484   AM_RANGE(0x400000, 0x401fff) AM_RAM AM_SHARE("spriteram")                   // Sprites
485485   AM_RANGE(0x500000, 0x503fff) AM_DEVREADWRITE("view2_0", kaneko_view2_tilemap_device,  kaneko_tmap_vram_r, kaneko_tmap_vram_w )
r31859r31860
497497   AM_RANGE(0xb00006, 0xb00007) AM_READ_PORT("UNK")
498498   AM_RANGE(0xb80000, 0xb80001) AM_WRITE(bloodwar_coin_lockout_w)  // Coin Lockout
499499   AM_RANGE(0xc00000, 0xc00001) AM_WRITE(kaneko16_display_enable)
500   AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, toybox_mcu_status_r)
500   AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, mcu_status_r)
501501   AM_RANGE(0xe00000, 0xe00001) AM_WRITE(bonkadv_oki_0_bank_w)
502502   AM_RANGE(0xe80000, 0xe80001) AM_WRITE(bonkadv_oki_1_bank_w)
503503ADDRESS_MAP_END
r31859r31860
545545   AM_RANGE(0x0ffffe, 0x0fffff) AM_READ(gtmr_wheel_r)                                                      // Wheel Value
546546
547547   AM_RANGE(0x100000, 0x10ffff) AM_RAM                                                                     // Work RAM
548   AM_RANGE(0x200000, 0x20ffff) AM_DEVREADWRITE( "toybox", kaneko_toybox_device, toybox_mcu_ram_r, toybox_mcu_ram_w )                                          // Shared With MCU
548   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_SHARE("mcuram")                                          // Shared With MCU
549549
550   AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com0_w)                                                // To MCU ?
551   AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com1_w)
552   AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com2_w)
553   AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com3_w)
550   AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com0_w)                                                // To MCU ?
551   AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com1_w)
552   AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com2_w)
553   AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com3_w)
554554
555555   AM_RANGE(0x300000, 0x30ffff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")    // Palette
556556   AM_RANGE(0x310000, 0x327fff) AM_RAM                                                                     //
r31859r31860
577577   AM_RANGE(0xb80000, 0xb80001) AM_WRITE(kaneko16_coin_lockout_w)                                          // Coin Lockout
578578   AM_RANGE(0xc00000, 0xc00001) AM_WRITE(kaneko16_display_enable)                                          // might do more than that
579579
580   AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, toybox_mcu_status_r)
580   AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, mcu_status_r)
581581
582582   AM_RANGE(0xe00000, 0xe00001) AM_WRITE(gtmr_oki_0_bank_w)                                        // Samples Bankswitching
583583   AM_RANGE(0xe80000, 0xe80001) AM_WRITE(gtmr_oki_1_bank_w)
r31859r31860
614614   AM_RANGE(0x0ffffe, 0x0fffff) AM_READ(gtmr2_wheel_r) // Wheel Value
615615
616616   AM_RANGE(0x100000, 0x10ffff) AM_RAM // Work RAM
617   AM_RANGE(0x200000, 0x20ffff) AM_DEVREADWRITE( "toybox", kaneko_toybox_device, toybox_mcu_ram_r, toybox_mcu_ram_w ) // Shared With MCU
617   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_SHARE("mcuram") // Shared With MCU
618618
619   AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com0_w)    // To MCU ?
620   AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com1_w)
621   AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com2_w)
622   AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com3_w)
619   AM_RANGE(0x2a0000, 0x2a0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com0_w)    // To MCU ?
620   AM_RANGE(0x2b0000, 0x2b0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com1_w)
621   AM_RANGE(0x2c0000, 0x2c0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com2_w)
622   AM_RANGE(0x2d0000, 0x2d0001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com3_w)
623623
624624   AM_RANGE(0x300000, 0x30ffff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")    // Palette
625625   AM_RANGE(0x310000, 0x327fff) AM_RAM //
r31859r31860
645645   AM_RANGE(0xb80000, 0xb80001) AM_WRITE(kaneko16_coin_lockout_w)  // Coin Lockout
646646   AM_RANGE(0xc00000, 0xc00001) AM_WRITE(kaneko16_display_enable)  // might do more than that
647647
648   AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, toybox_mcu_status_r)
648   AM_RANGE(0xd00000, 0xd00001) AM_DEVREAD( "toybox", kaneko_toybox_device, mcu_status_r)
649649
650650   AM_RANGE(0xe00000, 0xe00001) AM_WRITE(gtmr_oki_0_bank_w)    // Samples Bankswitching
651651   AM_RANGE(0xe80000, 0xe80001) AM_WRITE(gtmr_oki_1_bank_w)
r31859r31860
19071907   MCFG_KANEKO16_SPRITE_GFXDECODE("gfxdecode")
19081908
19091909   MCFG_DEVICE_ADD("toybox", KANEKO_TOYBOX, 0)
1910   kaneko_toybox_device::set_toybox_table(*device, TABLE_NORMAL);
1911   kaneko_toybox_device::set_toybox_gametype(*device, GAME_NORMAL);
19121910   /* part of the toybox? */
19131911   MCFG_DEVICE_ADD("kan_hit", KANEKO_HIT, 0)
19141912   kaneko_hit_device::set_type(*device, 1);
r31859r31860
19281926
19291927static MACHINE_CONFIG_DERIVED( gtmre, gtmr )
19301928   MCFG_DEVICE_MODIFY("toybox")
1931   kaneko_toybox_device::set_toybox_table(*device, TABLE_ALT);
1929   MCFG_TOYBOX_TABLE_TYPE(TABLE_ALT)
19321930MACHINE_CONFIG_END
19331931
19341932/***************************************************************************
r31859r31860
19801978
19811979
19821980   MCFG_DEVICE_MODIFY("toybox")
1983   kaneko_toybox_device::set_toybox_gametype(*device, GAME_BONK);
1981   MCFG_TOYBOX_GAME_TYPE(GAME_BONK)
19841982   MCFG_DEVICE_MODIFY("kan_hit")
19851983   kaneko_hit_device::set_type(*device, 0);
19861984
trunk/src/mame/drivers/jchan.c
r31859r31860
181181public:
182182   jchan_state(const machine_config &mconfig, device_type type, const char *tag)
183183      : driver_device(mconfig, type, tag),
184      m_maincpu(*this,"maincpu"),
185      m_subcpu(*this,"sub"),
186      m_palette(*this, "palette"),
187      m_spritegen1(*this, "spritegen1"),
188      m_spritegen2(*this, "spritegen2"),
184189      m_view2_0(*this, "view2_0"),
185190      m_spriteram_1(*this, "spriteram_1"),
186191      m_sprregs_1(*this, "sprregs_1"),
187192      m_spriteram_2(*this, "spriteram_2"),
188193      m_sprregs_2(*this, "sprregs_2"),
189194      m_mainsub_shared_ram(*this, "mainsub_shared"),
190      m_ctrl(*this, "ctrl"),
191      m_maincpu(*this,"maincpu"),
192      m_subcpu(*this,"sub"),
193      m_palette(*this, "palette")
195      m_ctrl(*this, "ctrl")
194196      { }
195197
196   optional_device<kaneko_view2_tilemap_device> m_view2_0;
198   required_device<cpu_device> m_maincpu;
199   required_device<cpu_device> m_subcpu;
200   required_device<palette_device> m_palette;
201   required_device<sknsspr_device> m_spritegen1;
202   required_device<sknsspr_device> m_spritegen2;
203   required_device<kaneko_view2_tilemap_device> m_view2_0;
204   
205   required_shared_ptr<UINT16> m_spriteram_1;
206   required_shared_ptr<UINT16> m_sprregs_1;
207   required_shared_ptr<UINT16> m_spriteram_2;
208   required_shared_ptr<UINT16> m_sprregs_2;
209   required_shared_ptr<UINT16> m_mainsub_shared_ram;
210   required_shared_ptr<UINT16> m_ctrl;
211
197212   bitmap_ind16 *m_sprite_bitmap_1;
198213   bitmap_ind16 *m_sprite_bitmap_2;
199214   UINT32* m_sprite_ram32_1;
r31859r31860
201216   UINT32* m_sprite_regs32_1;
202217   UINT32* m_sprite_regs32_2;
203218   int m_irq_sub_enable;
204   required_shared_ptr<UINT16> m_spriteram_1;
205   required_shared_ptr<UINT16> m_sprregs_1;
206   required_shared_ptr<UINT16> m_spriteram_2;
207   required_shared_ptr<UINT16> m_sprregs_2;
208   required_shared_ptr<UINT16> m_mainsub_shared_ram;
209   required_shared_ptr<UINT16> m_ctrl;
210219
211   required_device<cpu_device> m_maincpu;
212   required_device<cpu_device> m_subcpu;
213   required_device<palette_device> m_palette;
214   sknsspr_device* m_spritegen1;
215   sknsspr_device* m_spritegen2;
216
217
218220   DECLARE_WRITE16_MEMBER(jchan_ctrl_w);
219221   DECLARE_READ16_MEMBER(jchan_ctrl_r);
220222   DECLARE_WRITE16_MEMBER(main2sub_cmd_w);
r31859r31860
284286   m_sprite_bitmap_1 = auto_bitmap_ind16_alloc(machine(),1024,1024);
285287   m_sprite_bitmap_2 = auto_bitmap_ind16_alloc(machine(),1024,1024);
286288
287   m_spritegen1 = machine().device<sknsspr_device>("spritegen1");
288   m_spritegen2 = machine().device<sknsspr_device>("spritegen2");
289
290
291289   m_spritegen1->skns_sprite_kludge(0,0);
292290   m_spritegen2->skns_sprite_kludge(0,0);
293291}
r31859r31860
435433   AM_RANGE(0x000000, 0x1fffff) AM_ROM
436434   AM_RANGE(0x200000, 0x20ffff) AM_RAM // Work RAM - [A] grid tested, cleared ($9d6-$a54)
437435
438   AM_RANGE(0x300000, 0x30ffff) AM_DEVREADWRITE( "toybox", kaneko_toybox_device, toybox_mcu_ram_r, toybox_mcu_ram_w )//    [G] MCU share
439   AM_RANGE(0x330000, 0x330001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com0_w)
440   AM_RANGE(0x340000, 0x340001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com1_w)
441   AM_RANGE(0x350000, 0x350001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com2_w)
442   AM_RANGE(0x360000, 0x360001) AM_DEVWRITE( "toybox", kaneko_toybox_device, toybox_mcu_com3_w)
443   AM_RANGE(0x370000, 0x370001) AM_DEVREAD( "toybox", kaneko_toybox_device, toybox_mcu_status_r)
436   AM_RANGE(0x300000, 0x30ffff) AM_RAM AM_SHARE("mcuram") //    [G] MCU share
437   AM_RANGE(0x330000, 0x330001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com0_w)
438   AM_RANGE(0x340000, 0x340001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com1_w)
439   AM_RANGE(0x350000, 0x350001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com2_w)
440   AM_RANGE(0x360000, 0x360001) AM_DEVWRITE( "toybox", kaneko_toybox_device, mcu_com3_w)
441   AM_RANGE(0x370000, 0x370001) AM_DEVREAD( "toybox", kaneko_toybox_device, mcu_status_r)
444442
445443   AM_RANGE(0x400000, 0x403fff) AM_RAM AM_SHARE("mainsub_shared")
446444
trunk/src/mame/machine/kaneko_toybox.c
r31859r31860
5252const device_type KANEKO_TOYBOX = &device_creator<kaneko_toybox_device>;
5353
5454kaneko_toybox_device::kaneko_toybox_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
55   : device_t(mconfig, KANEKO_TOYBOX, "Kaneko Toybox MCU", tag, owner, clock, "kaneko_toybox", __FILE__)
55   : device_t(mconfig, KANEKO_TOYBOX, "Kaneko Toybox MCU", tag, owner, clock, "kaneko_toybox", __FILE__),
56      m_mcuram(*this, ":mcuram"),
57      m_gametype(GAME_NORMAL),
58      m_tabletype(TABLE_NORMAL)
5659{
57   m_tabletype = TABLE_NORMAL;
58   m_gametype = GAME_NORMAL;
60   m_mcu_com[0] = m_mcu_com[1] = m_mcu_com[2] = m_mcu_com[3] = 0;
5961}
6062
61void kaneko_toybox_device::set_toybox_table(device_t &device, int tabletype)
63void kaneko_toybox_device::set_table(device_t &device, int tabletype)
6264{
6365   kaneko_toybox_device &dev = downcast<kaneko_toybox_device &>(device);
6466   dev.m_tabletype = tabletype;
6567}
6668
67void kaneko_toybox_device::set_toybox_gametype(device_t &device, int gametype)
69void kaneko_toybox_device::set_game_type(device_t &device, int gametype)
6870{
6971   kaneko_toybox_device &dev = downcast<kaneko_toybox_device &>(device);
7072   dev.m_gametype = gametype;
7173}
7274
73
7475void kaneko_toybox_device::device_start()
7576{
76   m_toybox_mcuram = (UINT16*)auto_alloc_array_clear(this->machine(), UINT16, 0x10000/2);
77   memset(m_toybox_mcu_com, 0, 4 * sizeof( UINT16) );
78   toxboy_decrypt_rom(this->machine());
77   memset(m_mcu_com, 0, 4 * sizeof( UINT16) );
78   decrypt_rom();
7979
80
81   save_pointer(NAME(m_toybox_mcuram), 0x10000/2);
82   save_item(NAME(m_toybox_mcu_com[0]));
83   save_item(NAME(m_toybox_mcu_com[1]));
84   save_item(NAME(m_toybox_mcu_com[2]));
85   save_item(NAME(m_toybox_mcu_com[3]));
86
80   save_item(NAME(m_mcu_com));
8781}
8882
8983void kaneko_toybox_device::device_reset()
9084{
91   toybox_mcu_init(this->machine());
85   mcu_init();
9286}
9387
9488
95READ16_MEMBER(kaneko_toybox_device::toybox_mcu_ram_r)
96{
97   return m_toybox_mcuram[offset];
98}
89#define MCU_RESPONSE(d) memcpy(&m_mcuram[mcu_offset], d, sizeof(d))
9990
10091
101WRITE16_MEMBER(kaneko_toybox_device::toybox_mcu_ram_w)
102{
103   COMBINE_DATA(&m_toybox_mcuram[offset]);
104}
105
106
107
108#define MCU_RESPONSE(d) memcpy(&m_toybox_mcuram[mcu_offset], d, sizeof(d))
109
110
111
11292// I use a byteswapped MCU data rom to make the transfers to the 68k side easier
11393//  not sure if it's all 100% endian safe
114void kaneko_toybox_device::toxboy_decrypt_rom(running_machine& machine)
94void kaneko_toybox_device::decrypt_rom()
11595{
116   UINT8 *src = (UINT8 *)machine.root_device().memregion(":mcudata" )->base();
96   UINT8 *src = (UINT8 *)machine().root_device().memregion(":mcudata")->base();
11797
11898   int i;
11999
120100   for (i=0;i<0x020000;i++)
121101   {
122      if (m_tabletype == TABLE_NORMAL) src[i] = src[i] + toybox_mcu_decryption_table[(i^1)&0xff];
123      else src[i] = src[i] + toybox_mcu_decryption_table_alt[(i^1)&0xff];
102      if (m_tabletype == TABLE_NORMAL) src[i] = src[i] + decryption_table[(i^1)&0xff];
103      else src[i] = src[i] + decryption_table_alt[(i^1)&0xff];
124104   }
125
126
127105}
128106
129107
130108
131void kaneko_toybox_device::toxboy_handle_04_subcommand(running_machine& machine,UINT8 mcu_subcmd, UINT16*mcu_ram)
109void kaneko_toybox_device::handle_04_subcommand(UINT8 mcu_subcmd, UINT16 *mcu_ram)
132110{
133   UINT8 *src = (UINT8 *)machine.root_device().memregion(":mcudata")->base()+0x10000;
111   UINT8 *src = (UINT8 *)machine().root_device().memregion(":mcudata")->base()+0x10000;
134112   UINT8* dst = (UINT8 *)mcu_ram;
135113
136114   int offs = (mcu_subcmd&0x3f)*8;
r31859r31860
151129}
152130
153131
154void kaneko_toybox_device::toybox_mcu_init(running_machine &machine)
132void kaneko_toybox_device::mcu_init()
155133{
156   memset(m_toybox_mcu_com, 0, 4 * sizeof( UINT16) );
134   memset(m_mcu_com, 0, 4 * sizeof( UINT16) );
157135}
158136
159void kaneko_toybox_device::toybox_mcu_com_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _n_)
137void kaneko_toybox_device::mcu_com_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _n_)
160138{
161   COMBINE_DATA(&m_toybox_mcu_com[_n_]);
162   if (m_toybox_mcu_com[0] != 0xFFFF)  return;
163   if (m_toybox_mcu_com[1] != 0xFFFF)  return;
164   if (m_toybox_mcu_com[2] != 0xFFFF)  return;
165   if (m_toybox_mcu_com[3] != 0xFFFF)  return;
139   COMBINE_DATA(&m_mcu_com[_n_]);
140   if (m_mcu_com[0] != 0xFFFF)  return;
141   if (m_mcu_com[1] != 0xFFFF)  return;
142   if (m_mcu_com[2] != 0xFFFF)  return;
143   if (m_mcu_com[3] != 0xFFFF)  return;
166144
167   memset(m_toybox_mcu_com, 0, 4 * sizeof( UINT16 ) );
168   toybox_mcu_run(machine());
145   memset(m_mcu_com, 0, 4 * sizeof( UINT16 ) );
146   mcu_run();
169147}
170148
171WRITE16_MEMBER(kaneko_toybox_device::toybox_mcu_com0_w){ toybox_mcu_com_w(offset, data, mem_mask, 0); }
172WRITE16_MEMBER(kaneko_toybox_device::toybox_mcu_com1_w){ toybox_mcu_com_w(offset, data, mem_mask, 1); }
173WRITE16_MEMBER(kaneko_toybox_device::toybox_mcu_com2_w){ toybox_mcu_com_w(offset, data, mem_mask, 2); }
174WRITE16_MEMBER(kaneko_toybox_device::toybox_mcu_com3_w){ toybox_mcu_com_w(offset, data, mem_mask, 3); }
149WRITE16_MEMBER(kaneko_toybox_device::mcu_com0_w){ mcu_com_w(offset, data, mem_mask, 0); }
150WRITE16_MEMBER(kaneko_toybox_device::mcu_com1_w){ mcu_com_w(offset, data, mem_mask, 1); }
151WRITE16_MEMBER(kaneko_toybox_device::mcu_com2_w){ mcu_com_w(offset, data, mem_mask, 2); }
152WRITE16_MEMBER(kaneko_toybox_device::mcu_com3_w){ mcu_com_w(offset, data, mem_mask, 3); }
175153
176154/*
177155    bonkadv and bloodwar test bit 0
178156*/
179READ16_MEMBER(kaneko_toybox_device::toybox_mcu_status_r)
157READ16_MEMBER(kaneko_toybox_device::mcu_status_r)
180158{
181159   logerror("CPU %s (PC=%06X) : read MCU status\n", space.device().tag(), space.device().safe_pcbase());
182160   return 0; // most games test bit 0 for failure
r31859r31860
184162
185163
186164
187void kaneko_toybox_device::toybox_mcu_run(running_machine &machine)
165void kaneko_toybox_device::mcu_run()
188166{
189   UINT16 *kaneko16_mcu_ram = m_toybox_mcuram;
190   UINT16 mcu_command  =   kaneko16_mcu_ram[0x0010/2];
191   UINT16 mcu_offset   =   kaneko16_mcu_ram[0x0012/2] / 2;
192   UINT16 mcu_data     =   kaneko16_mcu_ram[0x0014/2];
167   UINT16 mcu_command  =   m_mcuram[0x0010/2];
168   UINT16 mcu_offset   =   m_mcuram[0x0012/2] / 2;
169   UINT16 mcu_data     =   m_mcuram[0x0014/2];
193170
194171   //printf("command %04x\n",mcu_command);
195172
r31859r31860
197174   {
198175      case 0x02:  // Read from NVRAM
199176      {
200         UINT8* nvdat = (UINT8*)&kaneko16_mcu_ram[mcu_offset];
177         UINT8* nvdat = (UINT8*)&m_mcuram[mcu_offset];
201178
202         address_space &eeprom_space = machine.device<eeprom_serial_93cxx_device>(":eeprom")->space();
179         address_space &eeprom_space = machine().device<eeprom_serial_93cxx_device>(":eeprom")->space();
203180
204181         for (int i=0;i<0x80;i++)
205182         {
206183            nvdat[i] = eeprom_space.read_byte(i);
207184         }
208185
209         logerror("%s : MCU executed command: %04X %04X (load NVRAM settings)\n", machine.describe_context(), mcu_command, mcu_offset*2);
186         logerror("%s : MCU executed command: %04X %04X (load NVRAM settings)\n", machine().describe_context(), mcu_command, mcu_offset*2);
210187
211188      }
212189      break;
213190
214191      case 0x42:  // Write to NVRAM
215192      {
216         address_space &eeprom_space = machine.device<eeprom_serial_93cxx_device>(":eeprom")->space();
217         UINT8* nvdat = (UINT8*)&kaneko16_mcu_ram[mcu_offset];
193         address_space &eeprom_space = machine().device<eeprom_serial_93cxx_device>(":eeprom")->space();
194         UINT8* nvdat = (UINT8*)&m_mcuram[mcu_offset];
218195         for (int i=0;i<0x80;i++)
219196         {
220197            eeprom_space.write_byte(i, nvdat[i]);
221198         }
222199
223         logerror("%s : MCU executed command: %04X %04X (save NVRAM settings)\n", machine.describe_context(), mcu_command, mcu_offset*2);
200         logerror("%s : MCU executed command: %04X %04X (save NVRAM settings)\n", machine().describe_context(), mcu_command, mcu_offset*2);
224201      }
225202      break;
226203
r31859r31860
232209            //memcpy(m_nvram_save, bonkadv_mcu_43, sizeof(bonkadv_mcu_43));
233210
234211
235            address_space &eeprom_space = machine.device<eeprom_serial_93cxx_device>(":eeprom")->space();
212            address_space &eeprom_space = machine().device<eeprom_serial_93cxx_device>(":eeprom")->space();
236213            UINT8* nvdat = (UINT8*)&bonkadv_mcu_43[0];
237214            for (int i=0;i<0x80;i++)
238215            {
239216               eeprom_space.write_byte(i, nvdat[i]);
240217            }
241            logerror("%s : MCU executed command: %04X %04X (restore default NVRAM settings)\n", machine.describe_context(), mcu_command, mcu_offset*2);
218            logerror("%s : MCU executed command: %04X %04X (restore default NVRAM settings)\n", machine().describe_context(), mcu_command, mcu_offset*2);
242219         }
243220      }
244221      break;
245222
246223      case 0x03:  // DSW
247224      {
248         kaneko16_mcu_ram[mcu_offset] = machine.root_device().ioport(":DSW1")->read();
249         logerror("%s : MCU executed command: %04X %04X (read DSW)\n", machine.describe_context(), mcu_command, mcu_offset*2);
225         m_mcuram[mcu_offset] = machine().root_device().ioport(":DSW1")->read();
226         logerror("%s : MCU executed command: %04X %04X (read DSW)\n", machine().describe_context(), mcu_command, mcu_offset*2);
250227      }
251228      break;
252229
253230      case 0x04:  // Protection
254231      {
255         logerror("%s : MCU executed command: %04X %04X %04X\n", machine.describe_context(), mcu_command, mcu_offset*2, mcu_data);
232         logerror("%s : MCU executed command: %04X %04X %04X\n", machine().describe_context(), mcu_command, mcu_offset*2, mcu_data);
256233
257234         if (m_gametype == GAME_BONK)
258235         {
r31859r31860
268245
269246               // dynamic, per-level (29), in level order
270247               default:
271                  toxboy_handle_04_subcommand(machine, mcu_data, kaneko16_mcu_ram);
248                  handle_04_subcommand(mcu_data, m_mcuram);
272249                  break;
273250
274251            }
275252         }
276253         else
277254         {
278            toxboy_handle_04_subcommand(machine, mcu_data, kaneko16_mcu_ram);
255            handle_04_subcommand(mcu_data, m_mcuram);
279256         }
280257
281258      }
282259      break;
283260
284261      default:
285         logerror("%s : MCU executed command: %04X %04X %04X (UNKNOWN COMMAND)\n", machine.describe_context(), mcu_command, mcu_offset*2, mcu_data);
262         logerror("%s : MCU executed command: %04X %04X %04X (UNKNOWN COMMAND)\n", machine().describe_context(), mcu_command, mcu_offset*2, mcu_data);
286263      break;
287264   }
288265}
trunk/src/mame/machine/kaneko_toybox.h
r31859r31860
290290};
291291
292292/* decryption table */
293static const UINT8 toybox_mcu_decryption_table[0x100] = {
293static const UINT8 decryption_table[0x100] = {
2942940x7b,0x82,0xf0,0xbc,0x7f,0x1d,0xa2,0xc5,0x2a,0xfa,0x55,0xee,0x1a,0xd0,0x59,0x76,
2952950x5e,0x75,0x79,0x16,0xa5,0xf6,0x84,0xed,0x0f,0x2e,0xf2,0x36,0x61,0xac,0xcd,0xab,
2962960x01,0x3b,0x01,0x87,0x73,0xab,0xce,0x5d,0xd4,0x1d,0x68,0x2a,0x35,0xea,0x13,0x27,
r31859r31860
310310};
311311
312312/* alt decryption table (gtmr2) */
313static const UINT8 toybox_mcu_decryption_table_alt[0x100] = {
313static const UINT8 decryption_table_alt[0x100] = {
3143140x26,0x17,0xb9,0xcf,0x1a,0xf5,0x14,0x1e,0x0c,0x35,0xb3,0x66,0xa0,0x17,0xe9,0xe4,
3153150x90,0xf6,0xd5,0x35,0xac,0x95,0x49,0x43,0x64,0x0c,0x03,0x75,0x4d,0xda,0xb6,0xdf,
3163160x06,0xcf,0x83,0x9e,0x35,0x2c,0x71,0x2a,0xab,0xcc,0x65,0xd4,0x1f,0xb0,0x88,0x3c,
r31859r31860
335335public:
336336   kaneko_toybox_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
337337
338   static void set_toybox_table(device_t &device, int tabletype);
339   static void set_toybox_gametype(device_t &device, int gametype);
338   static void set_table(device_t &device, int tabletype);
339   static void set_game_type(device_t &device, int gametype);
340340
341   DECLARE_READ16_MEMBER(toybox_mcu_ram_r);
342   DECLARE_WRITE16_MEMBER(toybox_mcu_ram_w);
341   DECLARE_WRITE16_MEMBER(mcu_com0_w);
342   DECLARE_WRITE16_MEMBER(mcu_com1_w);
343   DECLARE_WRITE16_MEMBER(mcu_com2_w);
344   DECLARE_WRITE16_MEMBER(mcu_com3_w);
345   DECLARE_READ16_MEMBER(mcu_status_r);
343346
344   DECLARE_WRITE16_MEMBER(toybox_mcu_com0_w);
345   DECLARE_WRITE16_MEMBER(toybox_mcu_com1_w);
346   DECLARE_WRITE16_MEMBER(toybox_mcu_com2_w);
347   DECLARE_WRITE16_MEMBER(toybox_mcu_com3_w);
348   DECLARE_READ16_MEMBER(toybox_mcu_status_r);
349
350   void toybox_mcu_com_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _n_);
351
352   void toxboy_decrypt_rom(running_machine& machine);
353   void toxboy_handle_04_subcommand(running_machine& machine,UINT8 mcu_subcmd, UINT16*mcu_ram);
354   void toybox_mcu_init(running_machine &machine);
355   void toybox_mcu_run(running_machine &machine);
356
357   UINT16 m_toybox_mcu_com[4];
358
359   int m_gametype;
360   int m_tabletype;
361
362347protected:
363348   virtual void device_start();
364349   virtual void device_reset();
365350
366351private:
367   UINT16* m_toybox_mcuram;
352   required_shared_ptr<UINT16> m_mcuram;
353   UINT16 m_mcu_com[4];
354   int m_gametype;
355   int m_tabletype;
356   
357   void mcu_com_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _n_);
358   void decrypt_rom();
359   void handle_04_subcommand(UINT8 mcu_subcmd, UINT16 *mcu_ram);
360   void mcu_init();
361   void mcu_run();
368362};
369363
370364
371365extern const device_type KANEKO_TOYBOX;
366
367#define MCFG_TOYBOX_TABLE_TYPE(_type) \
368   kaneko_toybox_device::set_table(*device, _type);
369   
370#define MCFG_TOYBOX_GAME_TYPE(_type) \
371   kaneko_toybox_device::set_game_type(*device, _type);
trunk/src/mame/includes/suprnova.h
r31859r31860
2424   skns_state(const machine_config &mconfig, device_type type, const char *tag)
2525      : driver_device(mconfig, type, tag),
2626      m_maincpu(*this,"maincpu"),
27      m_spritegen(*this, "spritegen"),
28      m_gfxdecode(*this, "gfxdecode"),
29      m_palette(*this, "palette"),
2730      m_spriteram(*this,"spriteram"),
2831      m_spc_regs(*this, "spc_regs"),
2932      m_v3_regs(*this, "v3_regs"),
r31859r31860
3437      m_palette_ram(*this, "palette_ram"),
3538      m_v3t_ram(*this, "v3t_ram"),
3639      m_main_ram(*this, "main_ram"),
37      m_cache_ram(*this, "cache_ram"),
38      m_gfxdecode(*this, "gfxdecode"),
39      m_palette(*this, "palette") { }
40      m_cache_ram(*this, "cache_ram") { }
4041
4142   required_device<sh2_device> m_maincpu;
43   required_device<sknsspr_device> m_spritegen;
44   required_device<gfxdecode_device> m_gfxdecode;
45   required_device<palette_device> m_palette;
46   
4247   required_shared_ptr<UINT32> m_spriteram;
43
44   sknsspr_device* m_spritegen;
4548   required_shared_ptr<UINT32> m_spc_regs;
4649   required_shared_ptr<UINT32> m_v3_regs;
4750   required_shared_ptr<UINT32> m_tilemapA_ram;
r31859r31860
5255   required_shared_ptr<UINT32> m_v3t_ram;
5356   required_shared_ptr<UINT32> m_main_ram;
5457   required_shared_ptr<UINT32> m_cache_ram;
55   required_device<gfxdecode_device> m_gfxdecode;
56   required_device<palette_device> m_palette;
58   
5759   hit_t m_hit;
5860   UINT32 m_timer_0_temp[4];
5961   bitmap_ind16 m_sprite_bitmap;
trunk/src/mame/video/suprnova.c
r31859r31860
343343
344344void skns_state::video_start()
345345{
346   m_spritegen = machine().device<sknsspr_device>("spritegen");
347
348346   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);
349347      m_tilemap_A->set_transparent_pen(0);
350348

Previous 199869 Revisions Next


© 1997-2024 The MAME Team