Previous 199869 Revisions Next

r24638 Thursday 1st August, 2013 at 23:50:39 UTC by Tafoid
Modernized the Seibu ADPCM device and converted the Seibu sound system to be a device.  [Osso]
[src/mame/audio]seibu.c seibu.h
[src/mame/drivers]bloodbro.c cabal.c cshooter.c dcon.c deadang.c dynduke.c goodejan.c legionna.c mustache.c nmk16.c r2dx_v33.c raiden.c raiden2.c sengokmj.c shanghai.c toki.c
[src/mame/includes]cabal.h deadang.h dynduke.h mustache.h nmk16.h raiden.h raiden2.h toki.h
[src/mame/machine]seicop.c

trunk/src/mame/machine/seicop.c
r24637r24638
15921592*/
15931593
15941594#include "emu.h"
1595#include "audio/seibu.h"
15961595#include "includes/legionna.h"
15971596#include "includes/raiden2.h"
15981597#include "machine/seicop.h"
r24637r24638
30793078READ16_HANDLER( heatbrl_mcu_r )
30803079{
30813080   if(offset >= 0x3c0/2 && offset <= 0x3df/2)
3082      return seibu_main_word_r(space,(offset >> 1) & 7,0xffff);
3081         return space.machine().device<seibu_sound_device>("seibu_sound")->main_word_r(space,(offset >> 1) & 7,0xffff);
30833082
30843083   if(offset >= 0x340/2 && offset <= 0x34f/2)
30853084   {
r24637r24638
31143113
31153114   if(offset >= 0x3c0/2 && offset <= 0x3df/2)
31163115   {
3117      seibu_main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff);
3116      space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff);
31183117      return;
31193118   }
31203119
r24637r24638
31303129READ16_HANDLER( cupsoc_mcu_r )
31313130{
31323131   if(offset >= 0x300/2 && offset <= 0x31f/2)
3133      return seibu_main_word_r(space,(offset >> 1) & 7,0xffff);
3132      return space.machine().device<seibu_sound_device>("seibu_sound")->main_word_r(space,(offset >> 1) & 7,0xffff);
31343133
31353134   if(offset >= 0x340/2 && offset <= 0x34f/2)
31363135   {
r24637r24638
31633162
31643163   if(offset >= 0x300/2 && offset <= 0x31f/2)
31653164   {
3166      seibu_main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff);
3165      space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff);
31673166      return;
31683167   }
31693168
r24637r24638
31733172READ16_HANDLER( cupsocs_mcu_r )
31743173{
31753174   if(offset >= 0x340/2 && offset <= 0x35f/2)
3176      return seibu_main_word_r(space,(offset >> 1) & 7,0xffff);
3175      return space.machine().device<seibu_sound_device>("seibu_sound")->main_word_r(space,(offset >> 1) & 7,0xffff);
31773176
31783177   if(offset >= 0x300/2 && offset <= 0x30f/2)
31793178   {
r24637r24638
32123211
32133212   if(offset >= 0x340/2 && offset <= 0x35f/2)
32143213   {
3215      seibu_main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff);
3214      space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff);
32163215      return;
32173216   }
32183217
r24637r24638
32263225READ16_HANDLER( godzilla_mcu_r )
32273226{
32283227   if(offset >= 0x300/2 && offset <= 0x31f/2)
3229      return seibu_main_word_r(space,(offset >> 1) & 7,0xffff);
3228      return space.machine().device<seibu_sound_device>("seibu_sound")->main_word_r(space,(offset >> 1) & 7,0xffff);
32303229
32313230   if(offset >= 0x340/2 && offset <= 0x34f/2)
32323231   {
r24637r24638
32603259
32613260   if(offset >= 0x300/2 && offset <= 0x31f/2)
32623261   {
3263      seibu_main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff);
3262      space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff);
32643263      return;
32653264   }
32663265
r24637r24638
32743273READ16_HANDLER( denjinmk_mcu_r )
32753274{
32763275   if(offset >= 0x300/2 && offset <= 0x31f/2)
3277      return seibu_main_word_r(space,(offset >> 1) & 7,0xffff);
3276      return space.machine().device<seibu_sound_device>("seibu_sound")->main_word_r(space,(offset >> 1) & 7,0xffff);
32783277
32793278   if(offset >= 0x340/2 && offset <= 0x34f/2)
32803279   {
r24637r24638
33133312
33143313   if(offset >= 0x300/2 && offset <= 0x31f/2)
33153314   {
3316      seibu_main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff);
3315      space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff);
33173316      return;
33183317   }
33193318
r24637r24638
33273326READ16_HANDLER( grainbow_mcu_r )
33283327{
33293328   if(offset >= 0x300/2 && offset <= 0x31f/2)
3330      return seibu_main_word_r(space,(offset >> 1) & 7,0xffff);
3329      return space.machine().device<seibu_sound_device>("seibu_sound")->main_word_r(space,(offset >> 1) & 7,0xffff);
33313330
33323331   if(offset >= 0x340/2 && offset <= 0x34f/2)
33333332   {
r24637r24638
33613360
33623361   if(offset >= 0x300/2 && offset <= 0x31f/2)
33633362   {
3364      seibu_main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff);
3363      space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff);
33653364      return;
33663365   }
33673366
r24637r24638
33763375READ16_HANDLER( legionna_mcu_r )
33773376{
33783377   if(offset >= 0x300/2 && offset <= 0x31f/2)
3379      return seibu_main_word_r(space,(offset >> 1) & 7,0xffff);
3378      return space.machine().device<seibu_sound_device>("seibu_sound")->main_word_r(space,(offset >> 1) & 7,0xffff);
33803379
33813380   if(offset >= 0x340/2 && offset <= 0x34f/2)
33823381   {
r24637r24638
34073406
34083407   if(offset >= 0x300/2 && offset <= 0x31f/2)
34093408   {
3410      seibu_main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff);
3409      space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff);
34113410      return;
34123411   }
34133412
trunk/src/mame/includes/raiden.h
r24637r24638
44
55*******************************************************************************/
66
7#include "audio/seibu.h"
78#include "video/bufsprite.h"
89
910class raiden_state : public driver_device
r24637r24638
1213   raiden_state(const machine_config &mconfig, device_type type, const char *tag)
1314      : driver_device(mconfig, type, tag),
1415      m_maincpu(*this, "maincpu"),
16      m_seibu_sound(*this, "seibu_sound"),
1517      m_spriteram(*this, "spriteram"),
1618      m_shared_ram(*this, "shared_ram"),
1719      m_videoram(*this, "videoram"),
r24637r24638
2123   { }
2224
2325   required_device<cpu_device> m_maincpu;
26   required_device<seibu_sound_device> m_seibu_sound;
2427   required_device<buffered_spriteram16_device> m_spriteram;
2528   required_shared_ptr<UINT16> m_shared_ram;
2629   required_shared_ptr<UINT16> m_videoram;
trunk/src/mame/includes/dynduke.h
r24637r24638
1#include "audio/seibu.h"
12#include "video/bufsprite.h"
23
34class dynduke_state : public driver_device
r24637r24638
1011      m_videoram(*this, "videoram"),
1112      m_back_data(*this, "back_data"),
1213      m_fore_data(*this, "fore_data"),
13      m_maincpu(*this, "maincpu") { }
14      m_maincpu(*this, "maincpu"),
15      m_seibu_sound(*this, "seibu_sound") { }
1416
1517   required_device<buffered_spriteram16_device> m_spriteram;
1618   required_shared_ptr<UINT16> m_scroll_ram;
1719   required_shared_ptr<UINT16> m_videoram;
1820   required_shared_ptr<UINT16> m_back_data;
1921   required_shared_ptr<UINT16> m_fore_data;
22   
23   required_device<cpu_device> m_maincpu;
24   required_device<seibu_sound_device> m_seibu_sound;
2025
2126   tilemap_t *m_bg_layer;
2227   tilemap_t *m_fg_layer;
r24637r24638
4550   INTERRUPT_GEN_MEMBER(dynduke_interrupt);
4651   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,int pri);
4752   void draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri );
48   required_device<cpu_device> m_maincpu;
4953};
trunk/src/mame/includes/deadang.h
r24637r24638
1#include "audio/seibu.h"
2
13class deadang_state : public driver_device
24{
35public:
r24637r24638
810      m_scroll_ram(*this, "scroll_ram"),
911      m_video_data(*this, "video_data"),
1012      m_maincpu(*this, "maincpu"),
11      m_subcpu(*this, "sub") { }
13      m_subcpu(*this, "sub"),
14      m_seibu_sound(*this, "seibu_sound"),
15      m_adpcm1(*this, "adpcm1"),
16      m_adpcm2(*this, "adpcm2") { }
1217
1318   required_shared_ptr<UINT16> m_spriteram;
1419   required_shared_ptr<UINT16> m_videoram;
1520   required_shared_ptr<UINT16> m_scroll_ram;
1621   required_shared_ptr<UINT16> m_video_data;
22   
23   required_device<cpu_device> m_maincpu;
24   required_device<cpu_device> m_subcpu;
25   required_device<seibu_sound_device> m_seibu_sound;
26   required_device<seibu_adpcm_device> m_adpcm1;
27   required_device<seibu_adpcm_device> m_adpcm2;
28   
1729   tilemap_t *m_pf3_layer;
1830   tilemap_t *m_pf2_layer;
1931   tilemap_t *m_pf1_layer;
r24637r24638
3850   TIMER_DEVICE_CALLBACK_MEMBER(deadang_main_scanline);
3951   TIMER_DEVICE_CALLBACK_MEMBER(deadang_sub_scanline);
4052   void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
41   required_device<cpu_device> m_maincpu;
42   required_device<cpu_device> m_subcpu;
4353};
trunk/src/mame/includes/toki.h
r24637r24638
1#include "audio/seibu.h"
2#include "sound/msm5205.h"
13#include "video/bufsprite.h"
2#include "sound/msm5205.h"
34
45class toki_state : public driver_device
56{
r24637r24638
1314      m_scrollram16(*this, "scrollram16"),
1415      m_maincpu(*this, "maincpu"),
1516      m_audiocpu(*this, "audiocpu"),
17      m_seibu_sound(*this, "seibu_sound"),
1618      m_msm(*this, "msm") { }
1719
1820   required_device<buffered_spriteram16_device> m_spriteram;
r24637r24638
2022   required_shared_ptr<UINT16> m_background2_videoram16;
2123   required_shared_ptr<UINT16> m_videoram;
2224   required_shared_ptr<UINT16> m_scrollram16;
25   
26   required_device<cpu_device> m_maincpu;
27   required_device<cpu_device> m_audiocpu;
28   optional_device<seibu_sound_device> m_seibu_sound;
29   optional_device<msm5205_device> m_msm;
2330
2431   int m_msm5205next;
2532   int m_toggle;
r24637r24638
4754   void toki_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
4855   void tokib_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
4956   DECLARE_WRITE_LINE_MEMBER(toki_adpcm_int);
50   required_device<cpu_device> m_maincpu;
51   required_device<cpu_device> m_audiocpu;
52   optional_device<msm5205_device> m_msm;
5357};
trunk/src/mame/includes/cabal.h
r24637r24638
1#include "audio/seibu.h"
12#include "sound/msm5205.h"
3
24class cabal_state : public driver_device
35{
46public:
r24637r24638
911      m_videoram(*this, "videoram"),
1012      m_maincpu(*this, "maincpu"),
1113      m_audiocpu(*this, "audiocpu"),
14      m_seibu_sound(*this, "seibu_sound"),
15      m_adpcm1(*this, "adpcm1"),
16      m_adpcm2(*this, "adpcm2"),
1217      m_msm1(*this, "msm1"),
1318      m_msm2(*this, "msm2") { }
1419
1520   required_shared_ptr<UINT16> m_spriteram;
1621   required_shared_ptr<UINT16> m_colorram;
1722   required_shared_ptr<UINT16> m_videoram;
23   
24   required_device<cpu_device> m_maincpu;
25   required_device<cpu_device> m_audiocpu;
26   optional_device<seibu_sound_device> m_seibu_sound;
27   optional_device<seibu_adpcm_device> m_adpcm1;
28   optional_device<seibu_adpcm_device> m_adpcm2;
29   optional_device<msm5205_device> m_msm1;
30   optional_device<msm5205_device> m_msm2;
31     
1832   tilemap_t *m_background_layer;
1933   tilemap_t *m_text_layer;
2034   int m_sound_command1;
r24637r24638
4256   UINT32 screen_update_cabal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4357   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
4458   void seibu_sound_bootleg(const char *cpu,int length);
45   required_device<cpu_device> m_maincpu;
46   required_device<cpu_device> m_audiocpu;
47   optional_device<msm5205_device> m_msm1;
48   optional_device<msm5205_device> m_msm2;
4959};
trunk/src/mame/includes/raiden2.h
r24637r24638
1#include "audio/seibu.h"
2
13class raiden2_state : public driver_device
24{
35public:
r24637r24638
810         mid_data(*this, "mid_data"),
911         text_data(*this, "text_data"),
1012         sprites(*this, "sprites") ,
11      m_maincpu(*this, "maincpu") { }
13      m_maincpu(*this, "maincpu"),
14      m_seibu_sound(*this, "seibu_sound") { }
15     
16   required_shared_ptr<UINT16> back_data,fore_data,mid_data, text_data, sprites;
17   required_device<cpu_device> m_maincpu;
18   required_device<seibu_sound_device> m_seibu_sound;
1219
1320   DECLARE_WRITE16_MEMBER( cop_itoa_low_w );
1421   DECLARE_WRITE16_MEMBER( cop_itoa_high_w );
r24637r24638
7986   void common_reset();
8087
8188   tilemap_t *background_layer,*midground_layer,*foreground_layer,*text_layer;
82   required_shared_ptr<UINT16> back_data,fore_data,mid_data, text_data, sprites;
8389   int bg_bank, fg_bank, mid_bank;
8490   UINT16 raiden2_tilemap_enable;
8591   UINT8 prg_bank,prot_data;
r24637r24638
158164   const UINT8 fade_table(int v);
159165   void combine32(UINT32 *val, int offset, UINT16 data, UINT16 mem_mask);
160166   void sprcpt_init(void);
161   required_device<cpu_device> m_maincpu;
162167};
163168
164169/*----------- defined in machine/r2crypt.c -----------*/
trunk/src/mame/includes/nmk16.h
r24637r24638
136136   TILE_GET_INFO_MEMBER(macross_get_tx_tile_info);
137137   TILE_GET_INFO_MEMBER(bjtwin_get_bg_tile_info);
138138   TILE_GET_INFO_MEMBER(get_tile_info_0_8bit);
139   DECLARE_MACHINE_RESET(mustang_sound);
140139   DECLARE_VIDEO_START(macross);
141140   DECLARE_MACHINE_RESET(NMK004);
142141   DECLARE_VIDEO_START(bioship);
trunk/src/mame/includes/mustache.h
r24637r24638
1#include "audio/seibu.h"    // for seibu_sound_decrypt on the MAIN cpu (not sound)
2
13class mustache_state : public driver_device
24{
35public:
r24637r24638
57      : driver_device(mconfig, type, tag),
68      m_videoram(*this, "videoram"),
79      m_spriteram(*this, "spriteram"),
8      m_maincpu(*this, "maincpu") { }
10      m_maincpu(*this, "maincpu"),
11      m_cpu_decrypt(*this, "seibu_sound") { }
912
1013   required_shared_ptr<UINT8> m_videoram;
14   required_shared_ptr<UINT8> m_spriteram;
15   
16   required_device<cpu_device> m_maincpu;
17   required_device<seibu_sound_device> m_cpu_decrypt;
18   
1119   tilemap_t *m_bg_tilemap;
1220   int m_control_byte;
13   required_shared_ptr<UINT8> m_spriteram;
1421   DECLARE_WRITE8_MEMBER(mustache_videoram_w);
1522   DECLARE_WRITE8_MEMBER(mustache_video_control_w);
1623   DECLARE_WRITE8_MEMBER(mustache_scroll_w);
r24637r24638
2128   UINT32 screen_update_mustache(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
2229   TIMER_DEVICE_CALLBACK_MEMBER(mustache_scanline);
2330   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
24   required_device<cpu_device> m_maincpu;
2531};
trunk/src/mame/drivers/deadang.c
r24637r24638
3838
3939#include "emu.h"
4040#include "cpu/nec/nec.h"
41#include "audio/seibu.h"
4241#include "sound/2203intf.h"
4342#include "sound/msm5205.h"
4443#include "includes/deadang.h"
45#include "drivlgcy.h"
4644
45
4746/* Read/Write Handlers */
4847
4948READ16_MEMBER(deadang_state::ghunter_trackball_low_r)
r24637r24638
6261   AM_RANGE(0x03800, 0x03fff) AM_RAM AM_SHARE("spriteram")
6362   AM_RANGE(0x04000, 0x04fff) AM_RAM AM_SHARE("share1")
6463   AM_RANGE(0x05000, 0x05fff) AM_WRITEONLY
65   AM_RANGE(0x06000, 0x0600f) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w)
64   AM_RANGE(0x06000, 0x0600f) AM_DEVREADWRITE("seibu_sound", seibu_sound_device, main_word_r, main_word_w)
6665   AM_RANGE(0x06010, 0x07fff) AM_WRITEONLY
6766   AM_RANGE(0x08000, 0x087ff) AM_WRITE(deadang_text_w) AM_SHARE("videoram")
6867   AM_RANGE(0x08800, 0x0bfff) AM_WRITEONLY
r24637r24638
246245
247246   MCFG_QUANTUM_TIME(attotime::from_hz(60)) // the game stops working with higher interleave rates..
248247
249   MCFG_MACHINE_RESET(seibu_sound)
250
251248   /* video hardware */
252249   MCFG_SCREEN_ADD("screen", RASTER)
253250   MCFG_SCREEN_REFRESH_RATE(60)
r24637r24638
412409
413410DRIVER_INIT_MEMBER(deadang_state,deadang)
414411{
415   seibu_sound_decrypt(machine(), "audiocpu", 0x2000);
416   seibu_adpcm_decrypt(machine(), "adpcm1");
417   seibu_adpcm_decrypt(machine(), "adpcm2");
412   m_seibu_sound->decrypt("audiocpu", 0x2000);
413   m_adpcm1->decrypt("adpcm1");
414   m_adpcm2->decrypt("adpcm2");
418415}
419416
420417DRIVER_INIT_MEMBER(deadang_state,ghunter)
421418{
422   seibu_sound_decrypt(machine(), "audiocpu", 0x2000);
423   seibu_adpcm_decrypt(machine(), "adpcm1");
424   seibu_adpcm_decrypt(machine(), "adpcm2");
419   m_seibu_sound->decrypt("audiocpu", 0x2000);
420   m_adpcm1->decrypt("adpcm1");
421   m_adpcm2->decrypt("adpcm2");
425422
426423   m_maincpu->space(AS_PROGRAM).install_read_handler(0x80000, 0x80001, read16_delegate(FUNC(deadang_state::ghunter_trackball_low_r),this));
427424   m_maincpu->space(AS_PROGRAM).install_read_handler(0xb0000, 0xb0001, read16_delegate(FUNC(deadang_state::ghunter_trackball_high_r),this));
trunk/src/mame/drivers/goodejan.c
r24637r24638
5555#include "audio/seibu.h"
5656#include "sound/3812intf.h"
5757#include "video/seibu_crtc.h"
58#include "drivlgcy.h"
5958
6059
6160class goodejan_state : public driver_device
r24637r24638
417416   AM_RANGE(0xc000, 0xc001) AM_READ_PORT("DSW1")
418417   AM_RANGE(0xc002, 0xc003) AM_READ(mahjong_panel_r)
419418   AM_RANGE(0xc004, 0xc005) AM_READ_PORT("DSW2") // switches
420   AM_RANGE(0xd000, 0xd00f) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w)
419   AM_RANGE(0xd000, 0xd00f) AM_DEVREADWRITE("seibu_sound", seibu_sound_device, main_word_r, main_word_w)
421420ADDRESS_MAP_END
422421
423422static ADDRESS_MAP_START( totmejan_io_map, AS_IO, 16, goodejan_state )
r24637r24638
656655
657656   SEIBU_SOUND_SYSTEM_CPU(GOODEJAN_MHZ1/2)
658657
659   MCFG_MACHINE_RESET(seibu_sound)
660
661658   /* video hardware */
662659   MCFG_SCREEN_ADD("screen", RASTER)
663660   MCFG_SCREEN_REFRESH_RATE(60)
trunk/src/mame/drivers/cabal.c
r24637r24638
4949#include "cpu/z80/z80.h"
5050#include "sound/2151intf.h"
5151#include "sound/msm5205.h"
52#include "audio/seibu.h"
5352#include "includes/cabal.h"
54#include "drivlgcy.h"
5553
5654MACHINE_RESET_MEMBER(cabal_state,cabalbl)
5755{
r24637r24638
10199
102100WRITE16_MEMBER(cabal_state::cabal_sound_irq_trigger_word_w)
103101{
104   seibu_main_word_w(space,4,data,mem_mask);
102   m_seibu_sound->main_word_w(space,4,data,mem_mask);
105103
106104   /* spin for a while to let the Z80 read the command, otherwise coins "stick" */
107105   space.device().execute().spin_until_time(attotime::from_usec(50));
r24637r24638
130128   AM_RANGE(0xc0080, 0xc0081) AM_WRITE(cabal_flipscreen_w)
131129   AM_RANGE(0xe0000, 0xe07ff) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_word_w) AM_SHARE("paletteram")
132130   AM_RANGE(0xe8008, 0xe8009) AM_WRITE(cabal_sound_irq_trigger_word_w) // fix coin insertion
133   AM_RANGE(0xe8000, 0xe800d) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w)
131   AM_RANGE(0xe8000, 0xe800d) AM_DEVREADWRITE("seibu_sound", seibu_sound_device, main_word_r, main_word_w)
134132ADDRESS_MAP_END
135133
136134static ADDRESS_MAP_START( cabalbl_main_map, AS_PROGRAM, 16, cabal_state )
r24637r24638
176174static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, cabal_state )
177175   AM_RANGE(0x0000, 0x1fff) AM_ROM
178176   AM_RANGE(0x2000, 0x27ff) AM_RAM
179   AM_RANGE(0x4001, 0x4001) AM_WRITE_LEGACY(seibu_irq_clear_w)
180   AM_RANGE(0x4002, 0x4002) AM_WRITE_LEGACY(seibu_rst10_ack_w)
181   AM_RANGE(0x4003, 0x4003) AM_WRITE_LEGACY(seibu_rst18_ack_w)
182   AM_RANGE(0x4005, 0x4006) AM_DEVWRITE_LEGACY("adpcm1", seibu_adpcm_adr_w)
177   AM_RANGE(0x4001, 0x4001) AM_DEVWRITE("seibu_sound", seibu_sound_device, irq_clear_w)
178   AM_RANGE(0x4002, 0x4002) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst10_ack_w)
179   AM_RANGE(0x4003, 0x4003) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst18_ack_w)
180   AM_RANGE(0x4005, 0x4006) AM_DEVWRITE("adpcm1", seibu_adpcm_device, adr_w)
183181   AM_RANGE(0x4008, 0x4009) AM_DEVREADWRITE("ymsnd", ym2151_device, read, write)
184   AM_RANGE(0x4010, 0x4011) AM_READ_LEGACY(seibu_soundlatch_r)
185   AM_RANGE(0x4012, 0x4012) AM_READ_LEGACY(seibu_main_data_pending_r)
182   AM_RANGE(0x4010, 0x4011) AM_DEVREAD("seibu_sound", seibu_sound_device, soundlatch_r)
183   AM_RANGE(0x4012, 0x4012) AM_DEVREAD("seibu_sound", seibu_sound_device, main_data_pending_r)
186184   AM_RANGE(0x4013, 0x4013) AM_READ_PORT("COIN")
187   AM_RANGE(0x4018, 0x4019) AM_WRITE_LEGACY(seibu_main_data_w)
188   AM_RANGE(0x401a, 0x401a) AM_DEVWRITE_LEGACY("adpcm1", seibu_adpcm_ctl_w)
189   AM_RANGE(0x401b, 0x401b) AM_WRITE_LEGACY(seibu_coin_w)
190   AM_RANGE(0x6005, 0x6006) AM_DEVWRITE_LEGACY("adpcm2", seibu_adpcm_adr_w)
191   AM_RANGE(0x601a, 0x601a) AM_DEVWRITE_LEGACY("adpcm2", seibu_adpcm_ctl_w)
185   AM_RANGE(0x4018, 0x4019) AM_DEVWRITE("seibu_sound", seibu_sound_device, main_data_w)
186   AM_RANGE(0x401a, 0x401a) AM_DEVWRITE("adpcm1", seibu_adpcm_device, ctl_w)
187   AM_RANGE(0x401b, 0x401b) AM_DEVWRITE("seibu_sound", seibu_sound_device, coin_w)
188   AM_RANGE(0x6005, 0x6006) AM_DEVWRITE("adpcm2", seibu_adpcm_device, adr_w)
189   AM_RANGE(0x601a, 0x601a) AM_DEVWRITE("adpcm2", seibu_adpcm_device, ctl_w)
192190   AM_RANGE(0x8000, 0xffff) AM_ROM
193191ADDRESS_MAP_END
194192
r24637r24638
482480   MCFG_CPU_ADD("audiocpu", Z80, XTAL_3_579545MHz) /* verified on pcb */
483481   MCFG_CPU_PROGRAM_MAP(sound_map)
484482
485   MCFG_MACHINE_RESET(seibu_sound)
486
487483   /* video hardware */
488484   MCFG_SCREEN_ADD("screen", RASTER)
489485   MCFG_SCREEN_REFRESH_RATE(59.60)   /* verified on pcb */
r24637r24638
497493
498494
499495   /* sound hardware */
496   MCFG_SEIBU_SOUND_ADD("seibu_sound")
497   
500498   MCFG_SPEAKER_STANDARD_MONO("mono")
501499
502500   MCFG_YM2151_ADD("ymsnd", XTAL_3_579545MHz) /* verified on pcb */
503   MCFG_YM2151_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<seibu_ym2151_irqhandler>))
501   MCFG_YM2151_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym2151_irqhandler))
504502   MCFG_SOUND_ROUTE(ALL_OUTPUTS,"mono", 0.80)
505503
506504   MCFG_SOUND_ADD("adpcm1", SEIBU_ADPCM, 8000) /* it should use the msm5205 */
r24637r24638
525523   MCFG_CPU_PROGRAM_MAP(cabalbl_sound_map)
526524
527525   /* there are 2x z80s for the ADPCM */
528   MCFG_CPU_ADD("adpcm1", Z80, XTAL_3_579545MHz) /* verified on pcb */
526   MCFG_CPU_ADD("adpcm_1", Z80, XTAL_3_579545MHz) /* verified on pcb */
529527   MCFG_CPU_PROGRAM_MAP(cabalbl_talk1_map)
530528   MCFG_CPU_IO_MAP(cabalbl_talk1_portmap)
531529   MCFG_CPU_PERIODIC_INT_DRIVER(cabal_state, irq0_line_hold, 8000)
532530
533   MCFG_CPU_ADD("adpcm2", Z80, XTAL_3_579545MHz) /* verified on pcb */
531   MCFG_CPU_ADD("adpcm_2", Z80, XTAL_3_579545MHz) /* verified on pcb */
534532   MCFG_CPU_PROGRAM_MAP(cabalbl_talk2_map)
535533   MCFG_CPU_IO_MAP(cabalbl_talk2_portmap)
536534   MCFG_CPU_PERIODIC_INT_DRIVER(cabal_state, irq0_line_hold, 8000)
r24637r24638
772770   ROM_LOAD16_BYTE( "cabal_01.bin",   0x60000, 0x10000, CRC(55c44764) SHA1(7fad1f2084664b5b4d1384c8081371b0c79c4f5e) )
773771   ROM_LOAD16_BYTE( "cabal_08.bin",   0x60001, 0x10000, CRC(702735c9) SHA1(e4ac799dc85ff5b7c8e578611605989c78f9e8b3) )
774772
775   ROM_REGION( 0x10000, "adpcm1", 0 )
773   ROM_REGION( 0x10000, "adpcm_1", 0 )
776774   ROM_LOAD( "cabal_09.bin",   0x00000, 0x10000, CRC(4ffa7fe3) SHA1(381d8e765a7b94678fb3308965c748bbe9f8e247) ) /* Z80 code/adpcm data */
777775
778   ROM_REGION( 0x10000, "adpcm2", 0 )
776   ROM_REGION( 0x10000, "adpcm_2", 0 )
779777   ROM_LOAD( "cabal_10.bin",   0x00000, 0x10000, CRC(958789b6) SHA1(344c3ee8a1e272b56499e5c0415bb714aec0ddcf) ) /* Z80 code/adpcm data */
780778ROM_END
781779
r24637r24638
849847
850848DRIVER_INIT_MEMBER(cabal_state,cabal)
851849{
852   seibu_sound_decrypt(machine(),"audiocpu",0x2000);
853   seibu_adpcm_decrypt(machine(),"adpcm1");
854   seibu_adpcm_decrypt(machine(),"adpcm2");
850   m_seibu_sound->decrypt("audiocpu",0x2000);
851   m_adpcm1->decrypt("adpcm1");
852   m_adpcm2->decrypt("adpcm2");
855853}
856854
857855DRIVER_INIT_MEMBER(cabal_state,cabalbl2)
858856{
859857   seibu_sound_bootleg("audiocpu",0x2000);
860   seibu_adpcm_decrypt(machine(),"adpcm1");
861   seibu_adpcm_decrypt(machine(),"adpcm2");
858   m_adpcm1->decrypt("adpcm1");
859   m_adpcm2->decrypt("adpcm2");
862860}
863861
864862
trunk/src/mame/drivers/nmk16.c
r24637r24638
195195   NMK004_init(machine());
196196}
197197
198MACHINE_RESET_MEMBER(nmk16_state,mustang_sound)
199{
200   MACHINE_RESET_CALL_LEGACY(seibu_sound);
201}
202
203198WRITE16_MEMBER(nmk16_state::ssmissin_sound_w)
204199{
205200   if (ACCESSING_BITS_0_7)
r24637r24638
425420   AM_RANGE(0x08000e, 0x08000f) AM_NOP
426421   AM_RANGE(0x080014, 0x080015) AM_WRITE(nmk_flipscreen_w)
427422   AM_RANGE(0x080016, 0x080017) AM_WRITENOP    // frame number?
428   AM_RANGE(0x08001e, 0x08001f) AM_WRITE_LEGACY(seibu_main_mustb_w)
423   AM_RANGE(0x08001e, 0x08001f) AM_DEVWRITE("seibu_sound", seibu_sound_device, main_mustb_w)
429424   AM_RANGE(0x088000, 0x0887ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBRGBx_word_w) AM_SHARE("paletteram")
430425   AM_RANGE(0x08c000, 0x08c001) AM_WRITE(mustang_scroll_w)
431426   AM_RANGE(0x08c002, 0x08c087) AM_WRITENOP    // ??
r24637r24638
913908   AM_RANGE(0x0c000a, 0x0c000b) AM_READ_PORT("DSW2")
914909   AM_RANGE(0x0c0014, 0x0c0015) AM_WRITE(nmk_flipscreen_w) /* Maybe */
915910   AM_RANGE(0x0c0018, 0x0c0019) AM_WRITE(nmk_tilebank_w) /* Tile Bank ? */
916   AM_RANGE(0x0c001e, 0x0c001f) AM_WRITE_LEGACY(seibu_main_mustb_w)
911   AM_RANGE(0x0c001e, 0x0c001f) AM_DEVWRITE("seibu_sound", seibu_sound_device, main_mustb_w)
917912   AM_RANGE(0x0c4000, 0x0c4007) AM_RAM_WRITE(nmk_scroll_w)
918913   AM_RANGE(0x0c8000, 0x0c87ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBRGBx_word_w) AM_SHARE("paletteram")
919914   AM_RANGE(0x0cc000, 0x0cffff) AM_RAM_WRITE(nmk_bgvideoram0_w) AM_SHARE("nmk_bgvideoram0")
r24637r24638
35933588   MCFG_CPU_PROGRAM_MAP(tharrier_sound_map)
35943589   MCFG_CPU_IO_MAP(tharrier_sound_io_map)
35953590
3596   MCFG_MACHINE_RESET_OVERRIDE(nmk16_state,mustang_sound)
3597
35983591   /* video hardware */
35993592   MCFG_SCREEN_ADD("screen", RASTER)
36003593   MCFG_SCREEN_REFRESH_RATE(56)
r24637r24638
37233716
37243717   SEIBU_SOUND_SYSTEM_CPU(14318180/4)
37253718
3726   MCFG_MACHINE_RESET_OVERRIDE(nmk16_state,mustang_sound)
3727
37283719   /* video hardware */
37293720   MCFG_SCREEN_ADD("screen", RASTER)
37303721   MCFG_SCREEN_REFRESH_RATE(56)
r24637r24638
39193910
39203911   SEIBU_SOUND_SYSTEM_CPU(14318180/4)
39213912
3922   MCFG_MACHINE_RESET_OVERRIDE(nmk16_state,mustang_sound)
3923
39243913   /* video hardware */
39253914   MCFG_SCREEN_ADD("screen", RASTER)
39263915   MCFG_SCREEN_REFRESH_RATE(56)
trunk/src/mame/drivers/raiden2.c
r24637r24638
147147#include "emu.h"
148148#include "cpu/nec/nec.h"
149149#include "cpu/z80/z80.h"
150#include "audio/seibu.h"
151150#include "machine/eepromser.h"
152151#include "sound/okim6295.h"
153152#include "includes/raiden2.h"
r24637r24638
11761175{
11771176   common_reset();
11781177   sprcpt_init();
1179   MACHINE_RESET_CALL_LEGACY(seibu_sound);
1180
1178   
11811179   membank("mainbank")->set_entry(1);
11821180
11831181   prg_bank = 0;
r24637r24638
11881186{
11891187   common_reset();
11901188   sprcpt_init();
1191   MACHINE_RESET_CALL_LEGACY(seibu_sound);
1192
1189   
11931190   membank("mainbank")->set_entry(8);
11941191
11951192   prg_bank = 0x08;
r24637r24638
12031200   fg_bank = 2;
12041201   mid_bank = 1;
12051202   sprcpt_init();
1206   MACHINE_RESET_CALL_LEGACY(seibu_sound);
1207
1203   
12081204   membank("mainbank")->set_entry(1);
12091205
12101206   prg_bank = 0;
r24637r24638
12171213   fg_bank = 2;
12181214   mid_bank = 1;
12191215   sprcpt_init();
1220   MACHINE_RESET_CALL_LEGACY(seibu_sound);
1221
1216   
12221217   //membank("mainbank")->set_entry(1);
12231218
12241219   //cop_init();
r24637r24638
12261221
12271222READ16_MEMBER(raiden2_state::raiden2_sound_comms_r)
12281223{
1229   return seibu_main_word_r(space,(offset >> 1) & 7,0xffff);
1224   return m_seibu_sound->main_word_r(space,(offset >> 1) & 7,0xffff);
12301225}
12311226
12321227WRITE16_MEMBER(raiden2_state::raiden2_sound_comms_w)
12331228{
1234   seibu_main_word_w(space,(offset >> 1) & 7,data,0x00ff);
1229   m_seibu_sound->main_word_w(space,(offset >> 1) & 7,data,0x00ff);
12351230}
12361231
12371232WRITE16_MEMBER(raiden2_state::raiden2_bank_w)
trunk/src/mame/drivers/raiden.c
r24637r24638
5050#include "emu.h"
5151#include "cpu/nec/nec.h"
5252#include "cpu/z80/z80.h"
53#include "audio/seibu.h"
5453#include "sound/3812intf.h"
5554#include "sound/okim6295.h"
5655#include "includes/raiden.h"
5756#include "video/seibu_crtc.h"
58#include "drivlgcy.h"
5957
6058
6159/******************************************************************************/
r24637r24638
6462   AM_RANGE(0x00000, 0x06fff) AM_RAM
6563   AM_RANGE(0x07000, 0x07fff) AM_RAM AM_SHARE("spriteram")
6664   AM_RANGE(0x08000, 0x08fff) AM_RAM AM_SHARE("shared_ram")
67   AM_RANGE(0x0a000, 0x0a00d) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w)
65   AM_RANGE(0x0a000, 0x0a00d) AM_DEVREADWRITE("seibu_sound", seibu_sound_device, main_word_r, main_word_w)
6866   AM_RANGE(0x0c000, 0x0c7ff) AM_WRITE(raiden_text_w) AM_SHARE("videoram")
6967   AM_RANGE(0x0e000, 0x0e001) AM_READ_PORT("P1_P2")
7068   AM_RANGE(0x0e002, 0x0e003) AM_READ_PORT("DSW")
r24637r24638
9997   AM_RANGE(0x0b004, 0x0b005) AM_WRITENOP // watchdog?
10098   AM_RANGE(0x0b006, 0x0b007) AM_WRITE8(raiden_control_w, 0x00ff)
10199   AM_RANGE(0x0c000, 0x0c7ff) AM_WRITE(raiden_text_w) AM_SHARE("videoram")
102   AM_RANGE(0x0d000, 0x0d00d) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w)
100   AM_RANGE(0x0d000, 0x0d00d) AM_DEVREADWRITE("seibu_sound", seibu_sound_device, main_word_r, main_word_w)
103101   AM_RANGE(0xa0000, 0xfffff) AM_ROM
104102ADDRESS_MAP_END
105103
r24637r24638
126124   AM_RANGE(0x0b004, 0x0b005) AM_WRITENOP // watchdog?
127125   AM_RANGE(0x0b006, 0x0b007) AM_WRITE8(raidenb_control_w, 0x00ff)
128126   AM_RANGE(0x0c000, 0x0c7ff) AM_WRITE(raiden_text_w) AM_SHARE("videoram")
129   AM_RANGE(0x0d000, 0x0d00d) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w)
127   AM_RANGE(0x0d000, 0x0d00d) AM_DEVREADWRITE("seibu_sound", seibu_sound_device, main_word_r, main_word_w)
130128   AM_RANGE(0x0d040, 0x0d08f) AM_DEVREADWRITE("crtc", seibu_crtc_device, read, write)
131129   AM_RANGE(0xa0000, 0xfffff) AM_ROM
132130ADDRESS_MAP_END
r24637r24638
281279
282280   MCFG_QUANTUM_TIME(attotime::from_hz(12000))
283281
284   MCFG_MACHINE_RESET(seibu_sound)
285
286282   /* video hardware */
287283   MCFG_BUFFERED_SPRITERAM16_ADD("spriteram")
288284
r24637r24638
620616DRIVER_INIT_MEMBER(raiden_state,raiden)
621617{
622618   common_decrypt();
623   seibu_sound_decrypt(machine(),"audiocpu",0x20000);
619   m_seibu_sound->decrypt("audiocpu",0x20000);
624620}
625621
626622DRIVER_INIT_MEMBER(raiden_state,raidenk)
r24637r24638
630626
631627DRIVER_INIT_MEMBER(raiden_state,raidenu)
632628{
633   seibu_sound_decrypt(machine(),"audiocpu",0x20000);
629   m_seibu_sound->decrypt("audiocpu",0x20000);
634630}
635631
636632
trunk/src/mame/drivers/dynduke.c
r24637r24638
6565#include "emu.h"
6666#include "cpu/nec/nec.h"
6767#include "cpu/z80/z80.h"
68#include "audio/seibu.h"
6968#include "sound/3812intf.h"
7069#include "sound/okim6295.h"
7170#include "includes/dynduke.h"
72#include "drivlgcy.h"
7371
72
7473/* Memory Maps */
7574
7675static ADDRESS_MAP_START( master_map, AS_PROGRAM, 16, dynduke_state )
r24637r24638
8382   AM_RANGE(0x0b004, 0x0b005) AM_WRITENOP
8483   AM_RANGE(0x0b006, 0x0b007) AM_WRITE(dynduke_control_w)
8584   AM_RANGE(0x0c000, 0x0c7ff) AM_RAM_WRITE(dynduke_text_w) AM_SHARE("videoram")
86   AM_RANGE(0x0d000, 0x0d00d) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w)
85   AM_RANGE(0x0d000, 0x0d00d) AM_DEVREADWRITE("seibu_sound", seibu_sound_device, main_word_r, main_word_w)
8786   AM_RANGE(0xa0000, 0xfffff) AM_ROM
8887ADDRESS_MAP_END
8988
r24637r24638
103102   AM_RANGE(0x00000, 0x06fff) AM_RAM
104103   AM_RANGE(0x07000, 0x07fff) AM_RAM AM_SHARE("spriteram")
105104   AM_RANGE(0x08000, 0x087ff) AM_RAM_WRITE(dynduke_text_w) AM_SHARE("videoram")
106   AM_RANGE(0x09000, 0x0900d) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w)
105   AM_RANGE(0x09000, 0x0900d) AM_DEVREADWRITE("seibu_sound", seibu_sound_device, main_word_r, main_word_w)
107106   AM_RANGE(0x0c000, 0x0c0ff) AM_RAM AM_SHARE("scroll_ram")
108107   AM_RANGE(0x0e000, 0x0efff) AM_RAM AM_SHARE("share1")
109108   AM_RANGE(0x0f000, 0x0f001) AM_READ_PORT("P1_P2")
r24637r24638
285284
286285   MCFG_QUANTUM_TIME(attotime::from_hz(3600))
287286
288   MCFG_MACHINE_RESET(seibu_sound)
289
290287   // video hardware
291288   MCFG_BUFFERED_SPRITERAM16_ADD("spriteram")
292289
r24637r24638
607604
608605DRIVER_INIT_MEMBER(dynduke_state,dynduke)
609606{
610   seibu_sound_decrypt(machine(),"audiocpu",0x20000);
607   m_seibu_sound->decrypt("audiocpu",0x20000);
611608}
612609
613610/* Game Drivers */
trunk/src/mame/drivers/shanghai.c
r24637r24638
2626#include "cpu/nec/nec.h"
2727#include "audio/seibu.h"
2828#include "video/hd63484.h"
29#include "drivlgcy.h"
3029
3130
3231class shanghai_state : public driver_device
r24637r24638
190189   AM_RANGE(0x09014, 0x09015) AM_READ_PORT("SYSTEM")
191190   AM_RANGE(0x09016, 0x0901f) AM_WRITENOP // 0x9016 is set to 0 at the boot
192191   AM_RANGE(0x0a000, 0x0a1ff) AM_WRITE(paletteram_xxxxBBBBGGGGRRRR_word_w) AM_SHARE("paletteram")
193   AM_RANGE(0x0b010, 0x0b01f) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w)
192   AM_RANGE(0x0b010, 0x0b01f) AM_DEVREADWRITE("seibu_sound", seibu_sound_device, main_word_r, main_word_w)
194193   AM_RANGE(0x80000, 0xfffff) AM_ROM
195194ADDRESS_MAP_END
196195
r24637r24638
514513
515514   MCFG_QUANTUM_TIME(attotime::from_hz(12000))
516515
517   MCFG_MACHINE_RESET(seibu_sound)
518
519516   /* video hardware */
520517   MCFG_SCREEN_ADD("screen", RASTER)
521518   MCFG_SCREEN_REFRESH_RATE(30)
r24637r24638
533530
534531   /* same as standard seibu ym2203, but "ym1" also reads "DSW" */
535532   MCFG_SOUND_ADD("ym1", YM2203, 14318180/4)
536   MCFG_YM2203_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<seibu_ym2203_irqhandler>))
533   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym2203_irqhandler))
537534   MCFG_YM2203_AY8910_INTF(&kothello_ay8910_config)
538535   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
539536
trunk/src/mame/drivers/bloodbro.c
r24637r24638
124124#include "sound/3812intf.h"
125125#include "includes/bloodbro.h"
126126#include "video/seibu_crtc.h"
127#include "drivlgcy.h"
128127
129128
130129/* Memory Maps */
r24637r24638
140139   AM_RANGE(0x08e000, 0x08e7ff) AM_RAM
141140   AM_RANGE(0x08e800, 0x08f7ff) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_word_w) AM_SHARE("paletteram")
142141   AM_RANGE(0x08f800, 0x08ffff) AM_RAM
143   AM_RANGE(0x0a0000, 0x0a000d) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w)
142   AM_RANGE(0x0a0000, 0x0a000d) AM_DEVREADWRITE("seibu_sound", seibu_sound_device, main_word_r, main_word_w)
144143//  AM_RANGE(0x0c0000, 0x0c007f) AM_RAM AM_SHARE("scroll")
145144   AM_RANGE(0x0c0080, 0x0c0081) AM_WRITENOP // ??? IRQ Ack VBL?
146145   AM_RANGE(0x0c00c0, 0x0c00c1) AM_WRITENOP // ??? watchdog?
r24637r24638
467466
468467   SEIBU_SOUND_SYSTEM_CPU(XTAL_7_15909MHz/2) /* verified on pcb */
469468
470   MCFG_MACHINE_RESET(seibu_sound)
471
472469   // video hardware
473470
474471   MCFG_SCREEN_ADD("screen", RASTER)
trunk/src/mame/drivers/dcon.c
r24637r24638
1818#include "audio/seibu.h"
1919#include "includes/dcon.h"
2020#include "video/seibu_crtc.h"
21#include "drivlgcy.h"
2221
22
2323/***************************************************************************/
2424
2525static ADDRESS_MAP_START( dcon_map, AS_PROGRAM, 16, dcon_state )
r24637r24638
3434   AM_RANGE(0x8f800, 0x8ffff) AM_RAM AM_SHARE("spriteram")
3535   AM_RANGE(0x9d000, 0x9d7ff) AM_WRITE(dcon_gfxbank_w)
3636
37   AM_RANGE(0xa0000, 0xa000d) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w)
37   AM_RANGE(0xa0000, 0xa000d) AM_DEVREADWRITE("seibu_sound", seibu_sound_device, main_word_r, main_word_w)
3838   AM_RANGE(0xc0000, 0xc004f) AM_DEVREADWRITE("crtc", seibu_crtc_device, read, write)
3939   AM_RANGE(0xc0080, 0xc0081) AM_WRITENOP
4040   AM_RANGE(0xc00c0, 0xc00c1) AM_WRITENOP
r24637r24638
273273
274274   SEIBU_SOUND_SYSTEM_CPU(4000000) /* Perhaps 14318180/4? */
275275
276   MCFG_MACHINE_RESET(seibu_sound)
277
278276   /* video hardware */
279277   MCFG_SCREEN_ADD("screen", RASTER)
280278   MCFG_SCREEN_REFRESH_RATE(60)
r24637r24638
301299
302300   SEIBU2_SOUND_SYSTEM_CPU(14318180/4)
303301
304   MCFG_MACHINE_RESET(seibu_sound)
305
306302   /* video hardware */
307303   MCFG_SCREEN_ADD("screen", RASTER)
308304   MCFG_SCREEN_REFRESH_RATE(60)
trunk/src/mame/drivers/legionna.c
r24637r24638
7575#include "cpu/m68000/m68000.h"
7676#include "machine/seicop.h"
7777#include "includes/legionna.h"
78#include "drivlgcy.h"
7978
8079/*****************************************************************************/
8180
r24637r24638
10661065
10671066   SEIBU_SOUND_SYSTEM_CPU(14318180/4)
10681067
1069   MCFG_MACHINE_RESET(seibu_sound)
1070
10711068   /* video hardware */
10721069   MCFG_SCREEN_ADD("screen", RASTER)
10731070   MCFG_SCREEN_REFRESH_RATE(60)
r24637r24638
10961093
10971094   SEIBU_SOUND_SYSTEM_CPU(14318180/4)
10981095
1099   MCFG_MACHINE_RESET(seibu_sound)
1100
11011096   /* video hardware */
11021097   MCFG_SCREEN_ADD("screen", RASTER)
11031098   MCFG_SCREEN_REFRESH_RATE(60)
r24637r24638
11251120
11261121   SEIBU2_SOUND_SYSTEM_CPU(14318180/4)
11271122
1128   MCFG_MACHINE_RESET(seibu_sound)
1129
11301123   /* video hardware */
11311124   MCFG_SCREEN_ADD("screen", RASTER)
11321125//  MCFG_SCREEN_REFRESH_RATE(61)
r24637r24638
11551148
11561149   SEIBU2_SOUND_SYSTEM_CPU(14318180/4)
11571150
1158   MCFG_MACHINE_RESET(seibu_sound)
1159
11601151   /* video hardware */
11611152   MCFG_SCREEN_ADD("screen", RASTER)
11621153   MCFG_SCREEN_SIZE(42*8, 36*8)
r24637r24638
11841175
11851176   SEIBU2_SOUND_SYSTEM_CPU(14318180/4)
11861177
1187   MCFG_MACHINE_RESET(seibu_sound)
1188
11891178   /* video hardware */
11901179   MCFG_SCREEN_ADD("screen", RASTER)
11911180   MCFG_SCREEN_REFRESH_RATE(60)
r24637r24638
12141203
12151204   SEIBU_SOUND_SYSTEM_CPU(14318180/4)
12161205
1217   MCFG_MACHINE_RESET(seibu_sound)
1218
12191206   /* video hardware */
12201207   MCFG_SCREEN_ADD("screen", RASTER)
12211208   MCFG_SCREEN_REFRESH_RATE(60)
r24637r24638
12521239   MCFG_CPU_PROGRAM_MAP(cupsocbl_sound_mem)
12531240   //MCFG_PERIODIC_INT("screen", nmi_line_pulse)
12541241
1255   //MCFG_MACHINE_INIT(seibu_sound)
1256
12571242   /* video hardware */
12581243   MCFG_SCREEN_ADD("screen", RASTER)
12591244   MCFG_SCREEN_REFRESH_RATE(60)
trunk/src/mame/drivers/r2dx_v33.c
r24637r24638
1616#include "emu.h"
1717#include "cpu/nec/nec.h"
1818#include "cpu/z80/z80.h"
19#include "audio/seibu.h"
2019#include "machine/eepromser.h"
2120#include "sound/okim6295.h"
2221#include "includes/raiden2.h"
23#include "drivlgcy.h"
2422
2523
2624class r2dx_v33_state : public driver_device
r24637r24638
3432      m_fg_vram(*this, "fg_vram"),
3533      m_tx_vram(*this, "tx_vram"),
3634      m_maincpu(*this, "maincpu"),
35      m_seibu_sound(*this, "seibu_sound"),
3736      m_eeprom(*this, "eeprom") { }
3837
3938   required_shared_ptr<UINT16> m_spriteram;
39   required_shared_ptr<UINT16> m_bg_vram;
40   required_shared_ptr<UINT16> m_md_vram;
41   required_shared_ptr<UINT16> m_fg_vram;
42   required_shared_ptr<UINT16> m_tx_vram;
43   
44   required_device<cpu_device> m_maincpu;
45   optional_device<seibu_sound_device> m_seibu_sound;
46   optional_device<eeprom_serial_93cxx_device> m_eeprom;
47   
4048   DECLARE_WRITE16_MEMBER(rdx_bg_vram_w);
4149   DECLARE_WRITE16_MEMBER(rdx_md_vram_w);
4250   DECLARE_WRITE16_MEMBER(rdx_fg_vram_w);
r24637r24638
6068   TILE_GET_INFO_MEMBER(get_fg_tile_info);
6169   TILE_GET_INFO_MEMBER(get_tx_tile_info);
6270
63   required_shared_ptr<UINT16> m_bg_vram;
64   required_shared_ptr<UINT16> m_md_vram;
65   required_shared_ptr<UINT16> m_fg_vram;
66   required_shared_ptr<UINT16> m_tx_vram;
6771   tilemap_t *m_bg_tilemap;
6872   tilemap_t *m_md_tilemap;
6973   tilemap_t *m_fg_tilemap;
r24637r24638
7276   UINT32 screen_update_rdx_v33(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7377   INTERRUPT_GEN_MEMBER(rdx_v33_interrupt);
7478   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,int pri);
75   required_device<cpu_device> m_maincpu;
76   optional_device<eeprom_serial_93cxx_device> m_eeprom;
7779};
7880
7981
r24637r24638
440442{
441443   switch(offset+0x780)
442444   {
443      case (0x788/2): return seibu_main_word_r(space,2,0xffff);
444      case (0x78c/2): return seibu_main_word_r(space,3,0xffff);
445      case (0x794/2): return seibu_main_word_r(space,5,0xffff);
445      case (0x788/2): return m_seibu_sound->main_word_r(space,2,0xffff);
446      case (0x78c/2): return m_seibu_sound->main_word_r(space,3,0xffff);
447      case (0x794/2): return m_seibu_sound->main_word_r(space,5,0xffff);
446448   }
447449
448450   return 0xffff;
r24637r24638
453455{
454456   switch(offset+0x780)
455457   {
456      case (0x780/2): { seibu_main_word_w(space,0,data,0x00ff); break; }
457      case (0x784/2): { seibu_main_word_w(space,1,data,0x00ff); break; }
458      //case (0x790/2): { seibu_main_word_w(space,4,data,0x00ff); break; }
459      case (0x794/2): { seibu_main_word_w(space,4,data,0x00ff); break; }
460      case (0x798/2): { seibu_main_word_w(space,6,data,0x00ff); break; }
458      case (0x780/2): { m_seibu_sound->main_word_w(space,0,data,0x00ff); break; }
459      case (0x784/2): { m_seibu_sound->main_word_w(space,1,data,0x00ff); break; }
460      //case (0x790/2): { m_seibu_sound->main_word_w(space,4,data,0x00ff); break; }
461      case (0x794/2): { m_seibu_sound->main_word_w(space,4,data,0x00ff); break; }
462      case (0x798/2): { m_seibu_sound->main_word_w(space,6,data,0x00ff); break; }
461463   }
462464}
463465
r24637r24638
724726   MCFG_CPU_PROGRAM_MAP(nzerotea_map)
725727   MCFG_CPU_VBLANK_INT_DRIVER("screen", r2dx_v33_state,  rdx_v33_interrupt)
726728
727   MCFG_MACHINE_RESET(seibu_sound)
728
729//  SEIBU2_RAIDEN2_SOUND_SYSTEM_CPU(14318180/4)
729   //  SEIBU2_RAIDEN2_SOUND_SYSTEM_CPU(14318180/4)
730730   SEIBU_NEWZEROTEAM_SOUND_SYSTEM_CPU(14318180/4)
731731
732732   /* video hardware */
trunk/src/mame/drivers/mustache.c
r24637r24638
2929***************************************************************************/
3030#include "emu.h"
3131#include "cpu/z80/z80.h"
32#include "audio/seibu.h"    // for seibu_sound_decrypt on the MAIN cpu (not sound)
3332#include "audio/t5182.h"
3433#include "includes/mustache.h"
3534
r24637r24638
195194
196195
197196   /* sound hardware */
197   MCFG_SEIBU_SOUND_ADD("seibu_sound") // for seibu_sound_decrypt on the MAIN cpu (not sound)
198   
198199   MCFG_SPEAKER_STANDARD_MONO("mono")
199200
200201   MCFG_YM2151_ADD("ymsnd", YM_CLOCK)
r24637r24638
278279      gfx2[i] = buf[BITSWAP24(i,23,22,21,20,19,18,17,16,15,12,11,10,9,8,7,6,5,4,13,14,3,2,1,0)];
279280
280281   auto_free(machine(), buf);
281   seibu_sound_decrypt(machine(),"maincpu",0x8000);
282   m_cpu_decrypt->decrypt("maincpu",0x8000);
282283}
283284
284285
trunk/src/mame/drivers/sengokmj.c
r24637r24638
5757#include "sound/3812intf.h"
5858#include "video/seibu_crtc.h"
5959#include "machine/nvram.h"
60#include "drivlgcy.h"
6160
6261
6362class sengokmj_state : public driver_device
r24637r24638
381380ADDRESS_MAP_END
382381
383382static ADDRESS_MAP_START( sengokmj_io_map, AS_IO, 16, sengokmj_state )
384   AM_RANGE(0x4000, 0x400f) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w)
383   AM_RANGE(0x4000, 0x400f) AM_DEVREADWRITE("seibu_sound", seibu_sound_device, main_word_r, main_word_w)
385384   /*Areas from 8000-804f are for the custom Seibu CRTC.*/
386385   AM_RANGE(0x8000, 0x804f) AM_DEVREADWRITE("crtc", seibu_crtc_device, read, write)
387386
r24637r24638
571570
572571   SEIBU_SOUND_SYSTEM_CPU(14318180/4)
573572
574   MCFG_MACHINE_RESET(seibu_sound)
575573   MCFG_NVRAM_ADD_0FILL("nvram")
576574
577575   /* video hardware */
trunk/src/mame/drivers/toki.c
r24637r24638
3737#include "emu.h"
3838#include "cpu/m68000/m68000.h"
3939#include "cpu/z80/z80.h"
40#include "audio/seibu.h"
4140#include "sound/3812intf.h"
4241#include "sound/msm5205.h"
4342#include "sound/3812intf.h"
4443#include "includes/toki.h"
45#include "drivlgcy.h"
4644
4745WRITE16_MEMBER(toki_state::tokib_soundcommand16_w)
4846{
r24637r24638
9694   AM_RANGE(0x06e800, 0x06efff) AM_RAM_WRITE(toki_background1_videoram16_w) AM_SHARE("bg1_vram16")
9795   AM_RANGE(0x06f000, 0x06f7ff) AM_RAM_WRITE(toki_background2_videoram16_w) AM_SHARE("bg2_vram16")
9896   AM_RANGE(0x06f800, 0x06ffff) AM_RAM_WRITE(toki_foreground_videoram16_w) AM_SHARE("videoram")
99   AM_RANGE(0x080000, 0x08000d) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w)
97   AM_RANGE(0x080000, 0x08000d) AM_DEVREADWRITE("seibu_sound", seibu_sound_device, main_word_r, main_word_w)
10098   AM_RANGE(0x0a0000, 0x0a005f) AM_WRITE(toki_control_w) AM_SHARE("scrollram16")
10199   AM_RANGE(0x0c0000, 0x0c0001) AM_READ_PORT("DSW")
102100   AM_RANGE(0x0c0002, 0x0c0003) AM_READ_PORT("INPUTS")
r24637r24638
420418
421419   SEIBU_SOUND_SYSTEM_CPU(XTAL_14_31818MHz/4)  /* verifed on pcb */
422420
423   MCFG_MACHINE_RESET(seibu_sound)
424
425421   /* video hardware */
426422   MCFG_BUFFERED_SPRITERAM16_ADD("spriteram")
427423
r24637r24638
797793
798794   auto_free(machine(), buffer);
799795
800   seibu_sound_decrypt(machine(),"audiocpu",0x2000);
796   m_seibu_sound->decrypt("audiocpu",0x2000);
801797}
802798
803799
trunk/src/mame/drivers/cshooter.c
r24637r24638
9494   cshooter_state(const machine_config &mconfig, device_type type, const char *tag)
9595      : driver_device(mconfig, type, tag),
9696      m_maincpu(*this, "maincpu"),
97      m_seibu_sound(*this, "seibu_sound"),
9798      m_txram(*this, "txram"),
9899      m_mainram(*this, "mainram"),
99100      m_spriteram(*this, "spriteram")
100101   { }
101102
102103   required_device<cpu_device> m_maincpu;
104   optional_device<seibu_sound_device> m_seibu_sound;
103105   required_shared_ptr<UINT8> m_txram;
104106   optional_shared_ptr<UINT8> m_mainram;
105107   optional_shared_ptr<UINT8> m_spriteram;
r24637r24638
121123   virtual void video_start();
122124   virtual void palette_init();
123125   DECLARE_MACHINE_RESET(cshooter);
124   DECLARE_MACHINE_RESET(airraid);
125126   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
126127   UINT32 screen_update_cshooter(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
127128   UINT32 screen_update_airraid(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
r24637r24638
250251   m_counter = 0;
251252}
252253
253MACHINE_RESET_MEMBER(cshooter_state,airraid)
254{
255   MACHINE_RESET_CALL_LEGACY(seibu_sound);
256}
257
258254READ8_MEMBER(cshooter_state::cshooter_coin_r)
259255{
260256   /* Even reads must return 0xff - Odd reads must return the contents of input port 5.
r24637r24638
279275
280276READ8_MEMBER(cshooter_state::seibu_sound_comms_r)
281277{
282   return seibu_main_word_r(space,offset,0x00ff);
278   return m_seibu_sound->main_word_r(space,offset,0x00ff);
283279}
284280
285281WRITE8_MEMBER(cshooter_state::seibu_sound_comms_w)
286282{
287   seibu_main_word_w(space,offset,data,0x00ff);
283   m_seibu_sound->main_word_w(space,offset,data,0x00ff);
288284}
289285
290286#if 0
r24637r24638
469465   MCFG_QUANTUM_TIME(attotime::from_hz(6000))
470466
471467   MCFG_MACHINE_RESET_OVERRIDE(cshooter_state,cshooter)
472
468   
473469   /* video hardware */
474470   MCFG_SCREEN_ADD("screen", RASTER)
475471   MCFG_SCREEN_REFRESH_RATE(60)
r24637r24638
483479
484480   /* sound hardware */
485481   /* YM2151 and ym3931 seibu custom cpu running at XTAL_14_31818MHz/4 */
482   MCFG_SEIBU_SOUND_ADD("seibu_sound")
483   
486484MACHINE_CONFIG_END
487485#endif
488486
r24637r24638
497495
498496   MCFG_QUANTUM_TIME(attotime::from_hz(6000))
499497
500   MCFG_MACHINE_RESET_OVERRIDE(cshooter_state,airraid)
501
502498   /* video hardware */
503499   MCFG_SCREEN_ADD("screen", RASTER)
504500   MCFG_SCREEN_REFRESH_RATE(60)
r24637r24638
678674   }
679675
680676   membank("bank1")->set_base(&memregion("user1")->base()[0]);
681   seibu_sound_decrypt(machine(),"audiocpu",0x2000);
677   m_seibu_sound->decrypt("audiocpu",0x2000);
682678}
683679
684680
trunk/src/mame/audio/seibu.c
r24637r24638
3939#include "sound/2203intf.h"
4040#include "sound/okiadpcm.h"
4141#include "sound/okim6295.h"
42#include "devlegcy.h"
4342
4443
44
45/***************************************************************************
46   Seibu Sound System
47***************************************************************************/
48
4549/*
4650    Games using encrypted sound cpu:
4751
r24637r24638
6973    00002CA2: 17 37
7074*/
7175
76const device_type SEIBU_SOUND = &device_creator<seibu_sound_device>;
7277
78seibu_sound_device::seibu_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
79   : device_t(mconfig, SEIBU_SOUND, "Seibu Sound System", tag, owner, clock, "seibu_sound", __FILE__),
80      m_main2sub_pending(0),
81      m_sub2main_pending(0)
82{
83}
84
85//-------------------------------------------------
86//  device_config_complete - perform any
87//  operations now that the configuration is
88//  complete
89//-------------------------------------------------
90
91void seibu_sound_device::device_config_complete()
92{
93}
94
95//-------------------------------------------------
96//  device_start - device-specific startup
97//-------------------------------------------------
98
99void seibu_sound_device::device_start()
100{
101   m_main2sub[0] = m_main2sub[1] = 0;
102   m_sub2main[0] = m_sub2main[1] = 0;
103   
104   save_item(NAME(m_main2sub_pending));
105   save_item(NAME(m_sub2main_pending));
106   
107   save_item(NAME(m_main2sub));
108   save_item(NAME(m_sub2main));
109   
110   for (int i = 0; i < 2; i++)
111   {
112      save_item(NAME(m_main2sub[i]), i);
113      save_item(NAME(m_sub2main[i]), i);
114   }
115}
116
117//-------------------------------------------------
118//  device_reset - device-specific reset
119//-------------------------------------------------
120
121void seibu_sound_device::device_reset()
122{
123   int romlength = machine().root_device().memregion("audiocpu")->bytes();
124   UINT8 *rom = machine().root_device().memregion("audiocpu")->base();
125
126   m_sound_cpu = machine().device("audiocpu");
127   update_irq_lines(VECTOR_INIT);
128   if (romlength > 0x10000)
129   {
130      machine().root_device().membank("bank1")->configure_entries(0, (romlength - 0x10000) / 0x8000, rom + 0x10000, 0x8000);
131
132      /* Denjin Makai definitely needs this at start-up, it never writes to the bankswitch */
133      machine().root_device().membank("bank1")->set_entry(0);
134   }
135}
136
73137static UINT8 decrypt_data(int a,int src)
74138{
75139   if ( BIT(a,9)  &  BIT(a,8))             src ^= 0x80;
r24637r24638
103167   return src;
104168}
105169
106void seibu_sound_decrypt(running_machine &machine,const char *cpu,int length)
170void seibu_sound_device::decrypt(const char *cpu,int length)
107171{
108   address_space &space = machine.device(cpu)->memory().space(AS_PROGRAM);
109   UINT8 *decrypt = auto_alloc_array(machine, UINT8, length);
110   UINT8 *rom = machine.root_device().memregion(cpu)->base();
172   address_space &space = machine().device(cpu)->memory().space(AS_PROGRAM);
173   UINT8 *decrypt = auto_alloc_array_clear(machine(), UINT8, length);
174   UINT8 *rom = machine().root_device().memregion(cpu)->base();
111175   int i;
112176
113177   space.set_decrypted_region(0x0000, (length < 0x10000) ? (length - 1) : 0x1fff, decrypt);
r24637r24638
121185   }
122186
123187   if (length > 0x10000)
124      machine.root_device().membank("bank1")->configure_decrypted_entries(0, (length - 0x10000) / 0x8000, decrypt + 0x10000, 0x8000);
188      machine().root_device().membank("bank1")->configure_decrypted_entries(0, (length - 0x10000) / 0x8000, decrypt + 0x10000, 0x8000);
125189}
126190
127
128/***************************************************************************/
129
130/*
131    Handlers for early Seibu/Tad games with dual channel ADPCM
132*/
133
134const seibu_adpcm_interface seibu_adpcm1_intf =
191void seibu_sound_device::update_irq_lines(int param)
135192{
136   "adpcm1"
137};
138
139const seibu_adpcm_interface seibu_adpcm2_intf =
140{
141   "adpcm2"
142};
143
144struct seibu_adpcm_state
145{
146   oki_adpcm_state m_adpcm;
147   sound_stream *m_stream;
148   UINT32 m_current;
149   UINT32 m_end;
150   UINT8 m_nibble;
151   UINT8 m_playing;
152   UINT8 m_allocated;
153   UINT8 *m_base;
154};
155
156static STREAM_UPDATE( seibu_adpcm_callback )
157{
158   seibu_adpcm_state *state = (seibu_adpcm_state *)param;
159   stream_sample_t *dest = outputs[0];
160
161   while (state->m_playing && samples > 0)
162   {
163      int val = (state->m_base[state->m_current] >> state->m_nibble) & 15;
164
165      state->m_nibble ^= 4;
166      if (state->m_nibble == 4)
167      {
168         state->m_current++;
169         if (state->m_current >= state->m_end)
170            state->m_playing = 0;
171      }
172
173      *dest++ = state->m_adpcm.clock(val) << 4;
174      samples--;
175   }
176   while (samples > 0)
177   {
178      *dest++ = 0;
179      samples--;
180   }
181}
182
183static DEVICE_START( seibu_adpcm )
184{
185   running_machine &machine = device->machine();
186   seibu_adpcm_state *state = (seibu_adpcm_state *)downcast<seibu_adpcm_device *>(device)->token();
187   const seibu_adpcm_interface *intf;
188
189   intf = (const seibu_adpcm_interface *)device->static_config();
190
191   state->m_playing = 0;
192   state->m_stream = device->machine().sound().stream_alloc(*device, 0, 1, device->clock(), state, seibu_adpcm_callback);
193   state->m_base = machine.root_device().memregion(intf->rom_region)->base();
194   state->m_adpcm.reset();
195}
196
197// "decrypt" is a bit flowery here, as it's probably just line-swapping to
198// simplify PCB layout/routing rather than intentional protection, but it
199// still fits, especially since the Z80s for all these games are truly encrypted.
200
201void seibu_adpcm_decrypt(running_machine &machine, const char *region)
202{
203   UINT8 *ROM = machine.root_device().memregion(region)->base();
204   int len = machine.root_device().memregion(region)->bytes();
205   int i;
206
207   for (i = 0; i < len; i++)
208   {
209      ROM[i] = BITSWAP8(ROM[i], 7, 5, 3, 1, 6, 4, 2, 0);
210   }
211}
212
213WRITE8_DEVICE_HANDLER( seibu_adpcm_adr_w )
214{
215   seibu_adpcm_state *state = (seibu_adpcm_state *)downcast<seibu_adpcm_device *>(device)->token();
216
217   if (state->m_stream)
218      state->m_stream->update();
219   if (offset)
220   {
221      state->m_end = data<<8;
222   }
223   else
224   {
225      state->m_current = data<<8;
226      state->m_nibble = 4;
227   }
228}
229
230WRITE8_DEVICE_HANDLER( seibu_adpcm_ctl_w )
231{
232   seibu_adpcm_state *state = (seibu_adpcm_state *)downcast<seibu_adpcm_device *>(device)->token();
233
234   // sequence is 00 02 01 each time.
235   if (state->m_stream)
236      state->m_stream->update();
237   switch (data)
238   {
239      case 0:
240         state->m_playing = 0;
241         break;
242      case 2:
243         break;
244      case 1:
245         state->m_playing = 1;
246         break;
247
248   }
249}
250
251/***************************************************************************/
252
253static device_t *sound_cpu;
254
255enum
256{
257   VECTOR_INIT,
258   RST10_ASSERT,
259   RST10_CLEAR,
260   RST18_ASSERT,
261   RST18_CLEAR
262};
263
264static void update_irq_lines(running_machine &machine, int param)
265{
266193   static int irq1,irq2;
267194
268195   switch(param)
r24637r24638
288215         break;
289216   }
290217
291   if ((irq1 & irq2) == 0xff)  /* no IRQs pending */
292      sound_cpu->execute().set_input_line(0,CLEAR_LINE);
293   else    /* IRQ pending */
294      sound_cpu->execute().set_input_line_and_vector(0,ASSERT_LINE,irq1 & irq2);
295}
218   if (m_sound_cpu != NULL)
219         if ((irq1 & irq2) == 0xff)  /* no IRQs pending */
220            m_sound_cpu->execute().set_input_line(0,CLEAR_LINE);
221         else    /* IRQ pending */
222            m_sound_cpu->execute().set_input_line_and_vector(0,ASSERT_LINE,irq1 & irq2);
223   else
224   return;
225   }   
226   
296227
297WRITE8_HANDLER( seibu_irq_clear_w )
228WRITE8_MEMBER( seibu_sound_device::irq_clear_w )
298229{
299230   /* Denjin Makai and SD Gundam doesn't like this, it's tied to the rst18 ack ONLY so it could be related to it. */
300   //update_irq_lines(space.machine(), VECTOR_INIT);
231   //update_irq_lines(VECTOR_INIT);
301232}
302233
303WRITE8_HANDLER( seibu_rst10_ack_w )
234WRITE8_MEMBER( seibu_sound_device::rst10_ack_w )
304235{
305236   /* Unused for now */
306237}
307238
308WRITE8_HANDLER( seibu_rst18_ack_w )
239WRITE8_MEMBER( seibu_sound_device::rst18_ack_w )
309240{
310   update_irq_lines(space.machine(), RST18_CLEAR);
241   update_irq_lines(RST18_CLEAR);
311242}
312243
313void seibu_ym3812_irqhandler(device_t *device, int linestate)
244void seibu_sound_device::ym3812_irqhandler(int linestate)
314245{
315   update_irq_lines(device->machine(), linestate ? RST10_ASSERT : RST10_CLEAR);
246   update_irq_lines(linestate ? RST10_ASSERT : RST10_CLEAR);
316247}
317248
318WRITE_LINE_DEVICE_HANDLER( seibu_ym2151_irqhandler )
249WRITE_LINE_MEMBER( seibu_sound_device::ym2151_irqhandler )
319250{
320   update_irq_lines(device->machine(), state ? RST10_ASSERT : RST10_CLEAR);
251   update_irq_lines(state ? RST10_ASSERT : RST10_CLEAR);
321252}
322253
323void seibu_ym2203_irqhandler(device_t *device, int linestate)
254void seibu_sound_device::ym2203_irqhandler(int linestate)
324255{
325   update_irq_lines(device->machine(), linestate ? RST10_ASSERT : RST10_CLEAR);
256   update_irq_lines(linestate ? RST10_ASSERT : RST10_CLEAR);
326257}
327258
328/***************************************************************************/
329
330MACHINE_RESET( seibu_sound )
259WRITE8_MEMBER( seibu_sound_device::bank_w )
331260{
332   int romlength = machine.root_device().memregion("audiocpu")->bytes();
333   UINT8 *rom = machine.root_device().memregion("audiocpu")->base();
334
335   sound_cpu = machine.device("audiocpu");
336   update_irq_lines(machine, VECTOR_INIT);
337   if (romlength > 0x10000)
338   {
339      machine.root_device().membank("bank1")->configure_entries(0, (romlength - 0x10000) / 0x8000, rom + 0x10000, 0x8000);
340
341      /* Denjin Makai definitely needs this at start-up, it never writes to the bankswitch */
342      machine.root_device().membank("bank1")->set_entry(0);
343   }
344}
345
346/***************************************************************************/
347
348static UINT8 main2sub[2],sub2main[2];
349static int main2sub_pending,sub2main_pending;
350
351WRITE8_HANDLER( seibu_bank_w )
352{
353261   space.machine().root_device().membank("bank1")->set_entry(data & 1);
354262}
355263
356WRITE8_HANDLER( seibu_coin_w )
264WRITE8_MEMBER( seibu_sound_device::coin_w )
357265{
358266   coin_counter_w(space.machine(), 0,data & 1);
359267   coin_counter_w(space.machine(), 1,data & 2);
360268}
361269
362READ8_HANDLER( seibu_soundlatch_r )
270READ8_MEMBER( seibu_sound_device::soundlatch_r )
363271{
364   return main2sub[offset];
272   return m_main2sub[offset];
365273}
366274
367READ8_HANDLER( seibu_main_data_pending_r )
275READ8_MEMBER( seibu_sound_device::main_data_pending_r )
368276{
369   return sub2main_pending ? 1 : 0;
277   return m_sub2main_pending ? 1 : 0;
370278}
371279
372WRITE8_HANDLER( seibu_main_data_w )
280WRITE8_MEMBER( seibu_sound_device::main_data_w )
373281{
374   sub2main[offset] = data;
282   m_sub2main[offset] = data;
375283}
376284
377static WRITE8_HANDLER( seibu_pending_w )
285WRITE8_MEMBER( seibu_sound_device::pending_w )
378286{
379287   /* just a guess */
380   main2sub_pending = 0;
381   sub2main_pending = 1;
288   m_main2sub_pending = 0;
289   m_sub2main_pending = 1;
382290}
383291
384READ16_HANDLER( seibu_main_word_r )
292READ16_MEMBER( seibu_sound_device::main_word_r )
385293{
386294   //logerror("%06x: seibu_main_word_r(%x)\n",space.device().safe_pc(),offset);
387295   switch (offset)
388296   {
389297      case 2:
390298      case 3:
391         return sub2main[offset-2];
299         return m_sub2main[offset-2];
392300      case 5:
393         return main2sub_pending ? 1 : 0;
301         return m_main2sub_pending ? 1 : 0;
394302      default:
395303         //logerror("%06x: seibu_main_word_r(%x)\n",space.device().safe_pc(),offset);
396304         return 0xffff;
397305   }
398306}
399307
400WRITE16_HANDLER( seibu_main_word_w )
308WRITE16_MEMBER( seibu_sound_device::main_word_w )
401309{
402310   //printf("%06x: seibu_main_word_w(%x,%02x)\n",space.device().safe_pc(),offset,data);
403311   if (ACCESSING_BITS_0_7)
r24637r24638
406314      {
407315         case 0:
408316         case 1:
409            main2sub[offset] = data;
317            m_main2sub[offset] = data;
410318            break;
411319         case 4:
412            update_irq_lines(space.machine(), RST18_ASSERT);
320            update_irq_lines(RST18_ASSERT);
413321            break;
414322         case 2: //Sengoku Mahjong writes here
415323         case 6:
416324            /* just a guess */
417            sub2main_pending = 0;
418            main2sub_pending = 1;
325            m_sub2main_pending = 0;
326            m_main2sub_pending = 1;
419327            break;
420328         default:
421329            //logerror("%06x: seibu_main_word_w(%x,%02x)\n",space.device().safe_pc(),offset,data);
r24637r24638
424332   }
425333}
426334
427READ8_HANDLER( seibu_main_v30_r )
335READ8_MEMBER( seibu_sound_device::main_v30_r )
428336{
429   return seibu_main_word_r(space,offset/2,0xffff) >> (8 * (offset & 1));
337   return main_word_r(space,offset/2,0xffff) >> (8 * (offset & 1));
430338}
431339
432WRITE8_HANDLER( seibu_main_v30_w )
340WRITE8_MEMBER( seibu_sound_device::main_v30_w )
433341{
434   seibu_main_word_w(space,offset/2,data << (8 * (offset & 1)),0x00ff << (8 * (offset & 1)));
342   main_word_w(space,offset/2,data << (8 * (offset & 1)),0x00ff << (8 * (offset & 1)));
435343}
436344
437WRITE16_HANDLER( seibu_main_mustb_w )
345WRITE16_MEMBER( seibu_sound_device::main_mustb_w )
438346{
439   main2sub[0] = data&0xff;
440   main2sub[1] = data>>8;
347   m_main2sub[0] = data&0xff;
348   m_main2sub[1] = data>>8;
441349
442350//  logerror("seibu_main_mustb_w: %x -> %x %x\n", data, main2sub[0], main2sub[1]);
443351
444   update_irq_lines(space.machine(), RST18_ASSERT);
352   update_irq_lines(RST18_ASSERT);
445353}
446354
447355/***************************************************************************/
r24637r24638
458366ADDRESS_MAP_START( seibu_sound_map, AS_PROGRAM, 8, driver_device )
459367   AM_RANGE(0x0000, 0x1fff) AM_ROM
460368   AM_RANGE(0x2000, 0x27ff) AM_RAM
461   AM_RANGE(0x4000, 0x4000) AM_WRITE_LEGACY(seibu_pending_w)
462   AM_RANGE(0x4001, 0x4001) AM_WRITE_LEGACY(seibu_irq_clear_w)
463   AM_RANGE(0x4002, 0x4002) AM_WRITE_LEGACY(seibu_rst10_ack_w)
464   AM_RANGE(0x4003, 0x4003) AM_WRITE_LEGACY(seibu_rst18_ack_w)
465   AM_RANGE(0x4007, 0x4007) AM_WRITE_LEGACY(seibu_bank_w)
369   AM_RANGE(0x4000, 0x4000) AM_DEVWRITE("seibu_sound", seibu_sound_device, pending_w)
370   AM_RANGE(0x4001, 0x4001) AM_DEVWRITE("seibu_sound", seibu_sound_device, irq_clear_w)
371   AM_RANGE(0x4002, 0x4002) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst10_ack_w)
372   AM_RANGE(0x4003, 0x4003) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst18_ack_w)
373   AM_RANGE(0x4007, 0x4007) AM_DEVWRITE("seibu_sound", seibu_sound_device, bank_w)
466374   AM_RANGE(0x4008, 0x4009) AM_DEVREADWRITE("ymsnd", ym3812_device, read, write)
467   AM_RANGE(0x4010, 0x4011) AM_READ_LEGACY(seibu_soundlatch_r)
468   AM_RANGE(0x4012, 0x4012) AM_READ_LEGACY(seibu_main_data_pending_r)
375   AM_RANGE(0x4010, 0x4011) AM_DEVREAD("seibu_sound", seibu_sound_device, soundlatch_r)
376   AM_RANGE(0x4012, 0x4012) AM_DEVREAD("seibu_sound", seibu_sound_device, main_data_pending_r)
469377   AM_RANGE(0x4013, 0x4013) AM_READ_PORT("COIN")
470   AM_RANGE(0x4018, 0x4019) AM_WRITE_LEGACY(seibu_main_data_w)
471   AM_RANGE(0x401b, 0x401b) AM_WRITE_LEGACY(seibu_coin_w)
378   AM_RANGE(0x4018, 0x4019) AM_DEVWRITE("seibu_sound", seibu_sound_device, main_data_w)
379   AM_RANGE(0x401b, 0x401b) AM_DEVWRITE("seibu_sound", seibu_sound_device, coin_w)
472380   AM_RANGE(0x6000, 0x6000) AM_DEVREADWRITE("oki", okim6295_device, read, write)
473381   AM_RANGE(0x8000, 0xffff) AM_ROMBANK("bank1")
474382ADDRESS_MAP_END
r24637r24638
476384ADDRESS_MAP_START( seibu2_airraid_sound_map, AS_PROGRAM, 8, driver_device )
477385   AM_RANGE(0x0000, 0x1fff) AM_ROM
478386   AM_RANGE(0x2000, 0x27ff) AM_RAM
479   AM_RANGE(0x4000, 0x4000) AM_WRITE_LEGACY(seibu_pending_w)
480   AM_RANGE(0x4001, 0x4001) AM_WRITE_LEGACY(seibu_irq_clear_w)
481   AM_RANGE(0x4002, 0x4002) AM_WRITE_LEGACY(seibu_rst10_ack_w)
482   AM_RANGE(0x4003, 0x4003) AM_WRITE_LEGACY(seibu_rst18_ack_w)
387   AM_RANGE(0x4000, 0x4000) AM_DEVWRITE("seibu_sound", seibu_sound_device, pending_w)
388   AM_RANGE(0x4001, 0x4001) AM_DEVWRITE("seibu_sound", seibu_sound_device, irq_clear_w)
389   AM_RANGE(0x4002, 0x4002) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst10_ack_w)
390   AM_RANGE(0x4003, 0x4003) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst18_ack_w)
483391   AM_RANGE(0x4007, 0x4007) AM_WRITENOP // bank, always 0
484392   AM_RANGE(0x4008, 0x4009) AM_DEVREADWRITE("ymsnd", ym2151_device, read, write)
485   AM_RANGE(0x4010, 0x4011) AM_READ_LEGACY(seibu_soundlatch_r)
486   AM_RANGE(0x4012, 0x4012) AM_READ_LEGACY(seibu_main_data_pending_r)
393   AM_RANGE(0x4010, 0x4011) AM_DEVREAD("seibu_sound", seibu_sound_device, soundlatch_r)
394   AM_RANGE(0x4012, 0x4012) AM_DEVREAD("seibu_sound", seibu_sound_device, main_data_pending_r)
487395   AM_RANGE(0x4013, 0x4013) AM_READ_PORT("COIN")
488   AM_RANGE(0x4018, 0x4019) AM_WRITE_LEGACY(seibu_main_data_w)
489   AM_RANGE(0x401b, 0x401b) AM_WRITE_LEGACY(seibu_coin_w)
396   AM_RANGE(0x4018, 0x4019) AM_DEVWRITE("seibu_sound", seibu_sound_device, main_data_w)
397   AM_RANGE(0x401b, 0x401b) AM_DEVWRITE("seibu_sound", seibu_sound_device, coin_w)
490398//  AM_RANGE(0x6000, 0x6000) AM_DEVREADWRITE("oki", okim6295_device, read, write)
491399   AM_RANGE(0x8000, 0xffff) AM_ROM
492400ADDRESS_MAP_END
r24637r24638
494402ADDRESS_MAP_START( seibu2_sound_map, AS_PROGRAM, 8, driver_device )
495403   AM_RANGE(0x0000, 0x1fff) AM_ROM
496404   AM_RANGE(0x2000, 0x27ff) AM_RAM
497   AM_RANGE(0x4000, 0x4000) AM_WRITE_LEGACY(seibu_pending_w)
498   AM_RANGE(0x4001, 0x4001) AM_WRITE_LEGACY(seibu_irq_clear_w)
499   AM_RANGE(0x4002, 0x4002) AM_WRITE_LEGACY(seibu_rst10_ack_w)
500   AM_RANGE(0x4003, 0x4003) AM_WRITE_LEGACY(seibu_rst18_ack_w)
501   AM_RANGE(0x4007, 0x4007) AM_WRITE_LEGACY(seibu_bank_w)
405   AM_RANGE(0x4000, 0x4000) AM_DEVWRITE("seibu_sound", seibu_sound_device, pending_w)
406   AM_RANGE(0x4001, 0x4001) AM_DEVWRITE("seibu_sound", seibu_sound_device, irq_clear_w)
407   AM_RANGE(0x4002, 0x4002) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst10_ack_w)
408   AM_RANGE(0x4003, 0x4003) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst18_ack_w)
409   AM_RANGE(0x4007, 0x4007) AM_DEVWRITE("seibu_sound", seibu_sound_device, bank_w)
502410   AM_RANGE(0x4008, 0x4009) AM_DEVREADWRITE("ymsnd", ym2151_device, read, write)
503   AM_RANGE(0x4010, 0x4011) AM_READ_LEGACY(seibu_soundlatch_r)
504   AM_RANGE(0x4012, 0x4012) AM_READ_LEGACY(seibu_main_data_pending_r)
411   AM_RANGE(0x4010, 0x4011) AM_DEVREAD("seibu_sound", seibu_sound_device, soundlatch_r)
412   AM_RANGE(0x4012, 0x4012) AM_DEVREAD("seibu_sound", seibu_sound_device, main_data_pending_r)
505413   AM_RANGE(0x4013, 0x4013) AM_READ_PORT("COIN")
506   AM_RANGE(0x4018, 0x4019) AM_WRITE_LEGACY(seibu_main_data_w)
507   AM_RANGE(0x401b, 0x401b) AM_WRITE_LEGACY(seibu_coin_w)
414   AM_RANGE(0x4018, 0x4019) AM_DEVWRITE("seibu_sound", seibu_sound_device, main_data_w)
415   AM_RANGE(0x401b, 0x401b) AM_DEVWRITE("seibu_sound", seibu_sound_device, coin_w)
508416   AM_RANGE(0x6000, 0x6000) AM_DEVREADWRITE("oki", okim6295_device, read, write)
509417   AM_RANGE(0x8000, 0xffff) AM_ROMBANK("bank1")
510418ADDRESS_MAP_END
r24637r24638
512420ADDRESS_MAP_START( seibu2_raiden2_sound_map, AS_PROGRAM, 8, driver_device )
513421   AM_RANGE(0x0000, 0x1fff) AM_ROM
514422   AM_RANGE(0x2000, 0x27ff) AM_RAM
515   AM_RANGE(0x4000, 0x4000) AM_WRITE_LEGACY(seibu_pending_w)
516   AM_RANGE(0x4001, 0x4001) AM_WRITE_LEGACY(seibu_irq_clear_w)
517   AM_RANGE(0x4002, 0x4002) AM_WRITE_LEGACY(seibu_rst10_ack_w)
518   AM_RANGE(0x4003, 0x4003) AM_WRITE_LEGACY(seibu_rst18_ack_w)
423   AM_RANGE(0x4000, 0x4000) AM_DEVWRITE("seibu_sound", seibu_sound_device, pending_w)
424   AM_RANGE(0x4001, 0x4001) AM_DEVWRITE("seibu_sound", seibu_sound_device, irq_clear_w)
425   AM_RANGE(0x4002, 0x4002) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst10_ack_w)
426   AM_RANGE(0x4003, 0x4003) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst18_ack_w)
519427   AM_RANGE(0x4008, 0x4009) AM_DEVREADWRITE("ymsnd", ym2151_device, read, write)
520   AM_RANGE(0x4010, 0x4011) AM_READ_LEGACY(seibu_soundlatch_r)
521   AM_RANGE(0x4012, 0x4012) AM_READ_LEGACY(seibu_main_data_pending_r)
428   AM_RANGE(0x4010, 0x4011) AM_DEVREAD("seibu_sound", seibu_sound_device, soundlatch_r)
429   AM_RANGE(0x4012, 0x4012) AM_DEVREAD("seibu_sound", seibu_sound_device, main_data_pending_r)
522430   AM_RANGE(0x4013, 0x4013) AM_READ_PORT("COIN")
523   AM_RANGE(0x4018, 0x4019) AM_WRITE_LEGACY(seibu_main_data_w)
524   AM_RANGE(0x401a, 0x401a) AM_WRITE_LEGACY(seibu_bank_w)
525   AM_RANGE(0x401b, 0x401b) AM_WRITE_LEGACY(seibu_coin_w)
431   AM_RANGE(0x4018, 0x4019) AM_DEVWRITE("seibu_sound", seibu_sound_device, main_data_w)
432   AM_RANGE(0x401a, 0x401a) AM_DEVWRITE("seibu_sound", seibu_sound_device, bank_w)
433   AM_RANGE(0x401b, 0x401b) AM_DEVWRITE("seibu_sound", seibu_sound_device, coin_w)
526434   AM_RANGE(0x6000, 0x6000) AM_DEVREADWRITE("oki1", okim6295_device, read, write)
527435   AM_RANGE(0x6002, 0x6002) AM_DEVREADWRITE("oki2", okim6295_device, read, write)
528436   AM_RANGE(0x8000, 0xffff) AM_ROMBANK("bank1")
r24637r24638
533441ADDRESS_MAP_START( seibu_newzeroteam_sound_map, AS_PROGRAM, 8, driver_device )
534442   AM_RANGE(0x0000, 0x1fff) AM_ROM
535443   AM_RANGE(0x2000, 0x27ff) AM_RAM
536   AM_RANGE(0x4000, 0x4000) AM_WRITE_LEGACY(seibu_pending_w)
537   AM_RANGE(0x4001, 0x4001) AM_WRITE_LEGACY(seibu_irq_clear_w)
538   AM_RANGE(0x4002, 0x4002) AM_WRITE_LEGACY(seibu_rst10_ack_w)
539   AM_RANGE(0x4003, 0x4003) AM_WRITE_LEGACY(seibu_rst18_ack_w)
444   AM_RANGE(0x4000, 0x4000) AM_DEVWRITE("seibu_sound", seibu_sound_device, pending_w)
445   AM_RANGE(0x4001, 0x4001) AM_DEVWRITE("seibu_sound", seibu_sound_device, irq_clear_w)
446   AM_RANGE(0x4002, 0x4002) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst10_ack_w)
447   AM_RANGE(0x4003, 0x4003) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst18_ack_w)
540448   AM_RANGE(0x4008, 0x4009) AM_DEVREADWRITE("ymsnd", ym3812_device, read, write)
541   AM_RANGE(0x4010, 0x4011) AM_READ_LEGACY(seibu_soundlatch_r)
542   AM_RANGE(0x4012, 0x4012) AM_READ_LEGACY(seibu_main_data_pending_r)
449   AM_RANGE(0x4010, 0x4011) AM_DEVREAD("seibu_sound", seibu_sound_device, soundlatch_r)
450   AM_RANGE(0x4012, 0x4012) AM_DEVREAD("seibu_sound", seibu_sound_device, main_data_pending_r)
543451   AM_RANGE(0x4013, 0x4013) AM_READ_PORT("COIN")
544   AM_RANGE(0x4018, 0x4019) AM_WRITE_LEGACY(seibu_main_data_w)
545   AM_RANGE(0x401a, 0x401a) AM_WRITE_LEGACY(seibu_bank_w)
546   AM_RANGE(0x401b, 0x401b) AM_WRITE_LEGACY(seibu_coin_w)
452   AM_RANGE(0x4018, 0x4019) AM_DEVWRITE("seibu_sound", seibu_sound_device, main_data_w)
453   AM_RANGE(0x401a, 0x401a) AM_DEVWRITE("seibu_sound", seibu_sound_device, bank_w)
454   AM_RANGE(0x401b, 0x401b) AM_DEVWRITE("seibu_sound", seibu_sound_device, coin_w)
547455   AM_RANGE(0x6000, 0x6000) AM_DEVREADWRITE("oki", okim6295_device, read, write)
548456   AM_RANGE(0x8000, 0xffff) AM_ROMBANK("bank1")
549457ADDRESS_MAP_END
r24637r24638
551459ADDRESS_MAP_START( seibu3_sound_map, AS_PROGRAM, 8, driver_device )
552460   AM_RANGE(0x0000, 0x1fff) AM_ROM
553461   AM_RANGE(0x2000, 0x27ff) AM_RAM
554   AM_RANGE(0x4000, 0x4000) AM_WRITE_LEGACY(seibu_pending_w)
555   AM_RANGE(0x4001, 0x4001) AM_WRITE_LEGACY(seibu_irq_clear_w)
556   AM_RANGE(0x4002, 0x4002) AM_WRITE_LEGACY(seibu_rst10_ack_w)
557   AM_RANGE(0x4003, 0x4003) AM_WRITE_LEGACY(seibu_rst18_ack_w)
558   AM_RANGE(0x4007, 0x4007) AM_WRITE_LEGACY(seibu_bank_w)
462   AM_RANGE(0x4000, 0x4000) AM_DEVWRITE("seibu_sound", seibu_sound_device, pending_w)
463   AM_RANGE(0x4001, 0x4001) AM_DEVWRITE("seibu_sound", seibu_sound_device, irq_clear_w)
464   AM_RANGE(0x4002, 0x4002) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst10_ack_w)
465   AM_RANGE(0x4003, 0x4003) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst18_ack_w)
466   AM_RANGE(0x4007, 0x4007) AM_DEVWRITE("seibu_sound", seibu_sound_device, bank_w)
559467   AM_RANGE(0x4008, 0x4009) AM_DEVREADWRITE("ym1", ym2203_device, read, write)
560   AM_RANGE(0x4010, 0x4011) AM_READ_LEGACY(seibu_soundlatch_r)
561   AM_RANGE(0x4012, 0x4012) AM_READ_LEGACY(seibu_main_data_pending_r)
468   AM_RANGE(0x4010, 0x4011) AM_DEVREAD("seibu_sound", seibu_sound_device, soundlatch_r)
469   AM_RANGE(0x4012, 0x4012) AM_DEVREAD("seibu_sound", seibu_sound_device, main_data_pending_r)
562470   AM_RANGE(0x4013, 0x4013) AM_READ_PORT("COIN")
563   AM_RANGE(0x4018, 0x4019) AM_WRITE_LEGACY(seibu_main_data_w)
564   AM_RANGE(0x401b, 0x401b) AM_WRITE_LEGACY(seibu_coin_w)
471   AM_RANGE(0x4018, 0x4019) AM_DEVWRITE("seibu_sound", seibu_sound_device, main_data_w)
472   AM_RANGE(0x401b, 0x401b) AM_DEVWRITE("seibu_sound", seibu_sound_device, coin_w)
565473   AM_RANGE(0x6008, 0x6009) AM_DEVREADWRITE("ym2", ym2203_device, read, write)
566474   AM_RANGE(0x8000, 0xffff) AM_ROMBANK("bank1")
567475ADDRESS_MAP_END
r24637r24638
569477ADDRESS_MAP_START( seibu3_adpcm_sound_map, AS_PROGRAM, 8, driver_device )
570478   AM_RANGE(0x0000, 0x1fff) AM_ROM
571479   AM_RANGE(0x2000, 0x27ff) AM_RAM
572   AM_RANGE(0x4000, 0x4000) AM_WRITE_LEGACY(seibu_pending_w)
573   AM_RANGE(0x4001, 0x4001) AM_WRITE_LEGACY(seibu_irq_clear_w)
574   AM_RANGE(0x4002, 0x4002) AM_WRITE_LEGACY(seibu_rst10_ack_w)
575   AM_RANGE(0x4003, 0x4003) AM_WRITE_LEGACY(seibu_rst18_ack_w)
576   AM_RANGE(0x4005, 0x4006) AM_DEVWRITE_LEGACY("adpcm1", seibu_adpcm_adr_w)
577   AM_RANGE(0x4007, 0x4007) AM_WRITE_LEGACY(seibu_bank_w)
480   AM_RANGE(0x4000, 0x4000) AM_DEVWRITE("seibu_sound", seibu_sound_device, pending_w)
481   AM_RANGE(0x4001, 0x4001) AM_DEVWRITE("seibu_sound", seibu_sound_device, irq_clear_w)
482   AM_RANGE(0x4002, 0x4002) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst10_ack_w)
483   AM_RANGE(0x4003, 0x4003) AM_DEVWRITE("seibu_sound", seibu_sound_device, rst18_ack_w)
484   AM_RANGE(0x4005, 0x4006) AM_DEVWRITE("adpcm1", seibu_adpcm_device, adr_w)
485   AM_RANGE(0x4007, 0x4007) AM_DEVWRITE("seibu_sound", seibu_sound_device, bank_w)
578486   AM_RANGE(0x4008, 0x4009) AM_DEVREADWRITE("ym1", ym2203_device, read, write)
579   AM_RANGE(0x4010, 0x4011) AM_READ_LEGACY(seibu_soundlatch_r)
580   AM_RANGE(0x4012, 0x4012) AM_READ_LEGACY(seibu_main_data_pending_r)
487   AM_RANGE(0x4010, 0x4011) AM_DEVREAD("seibu_sound", seibu_sound_device, soundlatch_r)
488   AM_RANGE(0x4012, 0x4012) AM_DEVREAD("seibu_sound", seibu_sound_device, main_data_pending_r)
581489   AM_RANGE(0x4013, 0x4013) AM_READ_PORT("COIN")
582   AM_RANGE(0x4018, 0x4019) AM_WRITE_LEGACY(seibu_main_data_w)
583   AM_RANGE(0x401a, 0x401a) AM_DEVWRITE_LEGACY("adpcm1", seibu_adpcm_ctl_w)
584   AM_RANGE(0x401b, 0x401b) AM_WRITE_LEGACY(seibu_coin_w)
585   AM_RANGE(0x6005, 0x6006) AM_DEVWRITE_LEGACY("adpcm2", seibu_adpcm_adr_w)
490   AM_RANGE(0x4018, 0x4019) AM_DEVWRITE("seibu_sound", seibu_sound_device, main_data_w)
491   AM_RANGE(0x401a, 0x401a) AM_DEVWRITE("adpcm1", seibu_adpcm_device, ctl_w)
492   AM_RANGE(0x401b, 0x401b) AM_DEVWRITE("seibu_sound", seibu_sound_device, coin_w)
493   AM_RANGE(0x6005, 0x6006) AM_DEVWRITE("adpcm2", seibu_adpcm_device, adr_w)
586494   AM_RANGE(0x6008, 0x6009) AM_DEVREADWRITE("ym2", ym2203_device, read, write)
587   AM_RANGE(0x601a, 0x601a) AM_DEVWRITE_LEGACY("adpcm2", seibu_adpcm_ctl_w)
495   AM_RANGE(0x601a, 0x601a) AM_DEVWRITE("adpcm2", seibu_adpcm_device, ctl_w)
588496   AM_RANGE(0x8000, 0xffff) AM_ROMBANK("bank1")
589497ADDRESS_MAP_END
590498
499/***************************************************************************
500   Seibu ADPCM device
501***************************************************************************/
591502
592503const device_type SEIBU_ADPCM = &device_creator<seibu_adpcm_device>;
593504
594505seibu_adpcm_device::seibu_adpcm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
595506   : device_t(mconfig, SEIBU_ADPCM, "Seibu ADPCM", tag, owner, clock, "seibu_adpcm", __FILE__),
596      device_sound_interface(mconfig, *this)
507      device_sound_interface(mconfig, *this),
508      m_stream(NULL),
509      m_current(0),
510      m_end(0),
511      m_nibble(0),
512      m_playing(0),
513      m_allocated(0),
514      m_base(NULL)
597515{
598   m_token = global_alloc_clear(seibu_adpcm_state);
599516}
600517
601518//-------------------------------------------------
r24637r24638
606523
607524void seibu_adpcm_device::device_config_complete()
608525{
526   // inherit a copy of the static data
527   const seibu_adpcm_interface *intf = reinterpret_cast<const seibu_adpcm_interface *>(static_config());
528   if (intf != NULL)
529      *static_cast<seibu_adpcm_interface *>(this) = *intf;
530
531   // or initialize to defaults if none provided
532   else
533   {
534      m_rom_region = "";
535   }
609536}
610537
611538//-------------------------------------------------
r24637r24638
614541
615542void seibu_adpcm_device::device_start()
616543{
617   DEVICE_START_NAME( seibu_adpcm )(this);
544   m_playing = 0;
545   m_stream = machine().sound().stream_alloc(*this, 0, 1, clock(), this);
546   m_base = machine().root_device().memregion(m_rom_region)->base();
547   m_adpcm.reset();
618548}
619549
550// "decrypt" is a bit flowery here, as it's probably just line-swapping to
551// simplify PCB layout/routing rather than intentional protection, but it
552// still fits, especially since the Z80s for all these games are truly encrypted.
553
554void seibu_adpcm_device::decrypt(const char *region)
555{
556   UINT8 *ROM = machine().root_device().memregion(region)->base();
557   int len = machine().root_device().memregion(region)->bytes();
558   int i;
559
560   for (i = 0; i < len; i++)
561   {
562      ROM[i] = BITSWAP8(ROM[i], 7, 5, 3, 1, 6, 4, 2, 0);
563   }
564}
565
566WRITE8_MEMBER( seibu_adpcm_device::adr_w )
567{
568   if (m_stream)
569      m_stream->update();
570   if (offset)
571   {
572      m_end = data<<8;
573   }
574   else
575   {
576      m_current = data<<8;
577      m_nibble = 4;
578   }
579}
580
581WRITE8_MEMBER( seibu_adpcm_device::ctl_w )
582{
583   // sequence is 00 02 01 each time.
584   if (m_stream)
585      m_stream->update();
586   switch (data)
587   {
588      case 0:
589         m_playing = 0;
590         break;
591      case 2:
592         break;
593      case 1:
594         m_playing = 1;
595         break;
596
597   }
598}
599
600
620601//-------------------------------------------------
621602//  sound_stream_update - handle a stream update
622603//-------------------------------------------------
623604
624605void seibu_adpcm_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
625606{
626   // should never get here
627   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
607   stream_sample_t *dest = outputs[0];
608
609   while (m_playing && samples > 0)
610   {
611      int val = (m_base[m_current] >> m_nibble) & 15;
612
613      m_nibble ^= 4;
614      if (m_nibble == 4)
615      {
616         m_current++;
617         if (m_current >= m_end)
618            m_playing = 0;
619      }
620
621      *dest++ = m_adpcm.clock(val) << 4;
622      samples--;
623   }
624   while (samples > 0)
625   {
626      *dest++ = 0;
627      samples--;
628   }
628629}
630
631//  Handlers for early Seibu/Tad games with dual channel ADPCM
632
633
634const seibu_adpcm_interface seibu_adpcm1_intf =
635{
636   "adpcm1"
637};
638
639const seibu_adpcm_interface seibu_adpcm2_intf =
640{
641   "adpcm2"
642};
trunk/src/mame/audio/seibu.h
r24637r24638
3737ADDRESS_MAP_EXTERN(seibu3_sound_map, 8);
3838ADDRESS_MAP_EXTERN(seibu3_adpcm_sound_map, 8);
3939
40DECLARE_READ16_HANDLER( seibu_main_word_r );
41DECLARE_READ8_HANDLER( seibu_main_v30_r );
42DECLARE_WRITE16_HANDLER( seibu_main_word_w );
43DECLARE_WRITE8_HANDLER( seibu_main_v30_w );
40class seibu_sound_device : public device_t
41{
42public:
43   seibu_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
44   ~seibu_sound_device() {}
4445
45DECLARE_WRITE16_HANDLER( seibu_main_mustb_w );
46   DECLARE_READ16_MEMBER( main_word_r );
47   DECLARE_READ8_MEMBER( main_v30_r );
48   DECLARE_WRITE16_MEMBER( main_word_w );
49   DECLARE_WRITE8_MEMBER( main_v30_w );
4650
47DECLARE_WRITE8_HANDLER( seibu_irq_clear_w );
48DECLARE_WRITE8_HANDLER( seibu_rst10_ack_w );
49DECLARE_WRITE8_HANDLER( seibu_rst18_ack_w );
50DECLARE_WRITE8_HANDLER( seibu_bank_w );
51DECLARE_WRITE8_HANDLER( seibu_coin_w );
52void seibu_ym3812_irqhandler(device_t *device, int linestate);
53WRITE_LINE_DEVICE_HANDLER(seibu_ym2151_irqhandler);
54void seibu_ym2203_irqhandler(device_t *device, int linestate);
55DECLARE_READ8_HANDLER( seibu_soundlatch_r );
56DECLARE_READ8_HANDLER( seibu_main_data_pending_r );
57DECLARE_WRITE8_HANDLER( seibu_main_data_w );
58MACHINE_RESET( seibu_sound );
59void seibu_sound_decrypt(running_machine &machine,const char *cpu,int length);
51   DECLARE_WRITE16_MEMBER( main_mustb_w );
6052
61void seibu_adpcm_decrypt(running_machine &machine, const char *region);
62DECLARE_WRITE8_DEVICE_HANDLER( seibu_adpcm_adr_w );
63DECLARE_WRITE8_DEVICE_HANDLER( seibu_adpcm_ctl_w );
53   DECLARE_WRITE8_MEMBER( irq_clear_w );
54   DECLARE_WRITE8_MEMBER( rst10_ack_w );
55   DECLARE_WRITE8_MEMBER( rst18_ack_w );
56   DECLARE_WRITE8_MEMBER( bank_w );
57   DECLARE_WRITE8_MEMBER( coin_w );
58   void ym3812_irqhandler(int linestate);
59   WRITE_LINE_MEMBER(ym2151_irqhandler);
60   void ym2203_irqhandler(int linestate);
61   DECLARE_READ8_MEMBER( soundlatch_r );
62   DECLARE_READ8_MEMBER( main_data_pending_r );
63   DECLARE_WRITE8_MEMBER( main_data_w );
64   DECLARE_WRITE8_MEMBER( pending_w );
65   void decrypt(const char *cpu,int length);
66   void update_irq_lines(int param);
67   
68protected:
69   // device-level overrides
70   virtual void device_config_complete();
71   virtual void device_start();
72   virtual void device_reset();
6473
74   private:
75   // internal state
76   device_t *m_sound_cpu;
77   UINT8 m_main2sub[2];
78   UINT8 m_sub2main[2];
79   int m_main2sub_pending;
80   int m_sub2main_pending;   
81   
82   enum
83   {
84      VECTOR_INIT,
85      RST10_ASSERT,
86      RST10_CLEAR,
87      RST18_ASSERT,
88      RST18_CLEAR
89   };
90};
91
92extern const device_type SEIBU_SOUND;
93
94extern const ay8910_interface seibu_ay8910_config;
95
96
97// Seibu ADPCM device
98
99struct seibu_adpcm_interface
100{
101   const char *m_rom_region;
102};
103
65104class seibu_adpcm_device : public device_t,
66                           public device_sound_interface
105                           public device_sound_interface,
106                           public seibu_adpcm_interface
67107{
68108public:
69109   seibu_adpcm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
70   ~seibu_adpcm_device() { global_free(m_token); }
110   ~seibu_adpcm_device() {}
71111
72   // access to legacy token
73   void *token() const { assert(m_token != NULL); return m_token; }
112   void decrypt(const char *region);
113   DECLARE_WRITE8_MEMBER( adr_w );
114   DECLARE_WRITE8_MEMBER( ctl_w );
115   
74116protected:
75117   // device-level overrides
76118   virtual void device_config_complete();
r24637r24638
78120
79121   // sound stream update overrides
80122   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
81private:
123
124   private:
82125   // internal state
83   void *m_token;
126   oki_adpcm_state m_adpcm;
127   sound_stream *m_stream;
128   UINT32 m_current;
129   UINT32 m_end;
130   UINT8 m_nibble;
131   UINT8 m_playing;
132   UINT8 m_allocated;
133   UINT8 *m_base;
84134};
85135
86136extern const device_type SEIBU_ADPCM;
87137
88
89extern const ay8910_interface seibu_ay8910_config;
90
91struct seibu_adpcm_interface
92{
93   const char *rom_region;
94};
95
96138extern const seibu_adpcm_interface seibu_adpcm1_intf;
97139extern const seibu_adpcm_interface seibu_adpcm2_intf;
98140
141
99142/**************************************************************************/
100143
144#define MCFG_SEIBU_SOUND_ADD(_tag) \
145   MCFG_DEVICE_ADD(_tag, SEIBU_SOUND, 0)
146
101147#define SEIBU_COIN_INPUTS                                           \
102148   PORT_START("COIN")                                              \
103149   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(4)     \
r24637r24638
113159
114160#define SEIBU_SOUND_SYSTEM_CPU(freq)                                \
115161   MCFG_CPU_ADD("audiocpu", Z80, freq)                             \
116   MCFG_CPU_PROGRAM_MAP(seibu_sound_map)
162   MCFG_CPU_PROGRAM_MAP(seibu_sound_map)                     \
163   MCFG_SEIBU_SOUND_ADD("seibu_sound")                 
164   
117165#define SEIBU2_SOUND_SYSTEM_CPU(freq)                               \
118166   MCFG_CPU_ADD("audiocpu", Z80, freq)                             \
119   MCFG_CPU_PROGRAM_MAP(seibu2_sound_map)
167   MCFG_CPU_PROGRAM_MAP(seibu2_sound_map)                     \
168   MCFG_SEIBU_SOUND_ADD("seibu_sound")                 
169   
120170#define SEIBU2_AIRRAID_SOUND_SYSTEM_CPU(freq)                       \
121171   MCFG_CPU_ADD("audiocpu", Z80, freq)                             \
122   MCFG_CPU_PROGRAM_MAP(seibu2_airraid_sound_map)
172   MCFG_CPU_PROGRAM_MAP(seibu2_airraid_sound_map)               \
173   MCFG_SEIBU_SOUND_ADD("seibu_sound")                 
123174
124175#define SEIBU2_RAIDEN2_SOUND_SYSTEM_CPU(freq)                       \
125   MCFG_CPU_ADD("audiocpu",  Z80, freq)                                \
126   MCFG_CPU_PROGRAM_MAP(seibu2_raiden2_sound_map)
176   MCFG_CPU_ADD("audiocpu",  Z80, freq)                            \
177   MCFG_CPU_PROGRAM_MAP(seibu2_raiden2_sound_map)               \
178   MCFG_SEIBU_SOUND_ADD("seibu_sound")                 
179   
127180#define SEIBU_NEWZEROTEAM_SOUND_SYSTEM_CPU(freq)                    \
128181   MCFG_CPU_ADD("audiocpu", Z80, freq)                             \
129   MCFG_CPU_PROGRAM_MAP(seibu_newzeroteam_sound_map)
182   MCFG_CPU_PROGRAM_MAP(seibu_newzeroteam_sound_map)            \
183   MCFG_SEIBU_SOUND_ADD("seibu_sound")                 
184   
130185#define SEIBU3_SOUND_SYSTEM_CPU(freq)                               \
131186   MCFG_CPU_ADD("audiocpu", Z80, freq)                             \
132   MCFG_CPU_PROGRAM_MAP(seibu3_sound_map)
187   MCFG_CPU_PROGRAM_MAP(seibu3_sound_map)                     \
188   MCFG_SEIBU_SOUND_ADD("seibu_sound")                 
189   
133190#define SEIBU3A_SOUND_SYSTEM_CPU(freq)                              \
134191   MCFG_CPU_ADD("audiocpu", Z80, freq)                             \
135   MCFG_CPU_PROGRAM_MAP(seibu3_adpcm_sound_map)
192   MCFG_CPU_PROGRAM_MAP(seibu3_adpcm_sound_map)               \
193   MCFG_SEIBU_SOUND_ADD("seibu_sound")                 
194   
136195#define SEIBU_SOUND_SYSTEM_YM3812_INTERFACE(freq1,freq2)            \
137196   MCFG_SPEAKER_STANDARD_MONO("mono")                              \
138197                                                   \
139198   MCFG_SOUND_ADD("ymsnd", YM3812, freq1)                              \
140   MCFG_YM3812_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<seibu_ym3812_irqhandler>)) \
199   MCFG_YM3812_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym3812_irqhandler)) \
141200   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)                      \
142201                                                   \
143202   MCFG_OKIM6295_ADD("oki", freq2, OKIM6295_PIN7_LOW)              \
r24637r24638
146205   MCFG_SPEAKER_STANDARD_MONO("mono")                              \
147206                                                   \
148207   MCFG_SOUND_ADD("ymsnd", YM3812, freq1)                              \
149   MCFG_YM3812_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<seibu_ym3812_irqhandler>)) \
208   MCFG_YM3812_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym3812_irqhandler)) \
150209   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)                      \
151210                                                   \
152211   MCFG_OKIM6295_ADD("oki", freq2, OKIM6295_PIN7_HIGH)             \
r24637r24638
155214   MCFG_SPEAKER_STANDARD_MONO("mono")                              \
156215                                                   \
157216   MCFG_YM2151_ADD("ymsnd", freq1)                             \
158   MCFG_YM2151_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<seibu_ym2151_irqhandler>)) \
217   MCFG_YM2151_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym2151_irqhandler)) \
159218   MCFG_SOUND_ROUTE(0, "mono", 0.50)                               \
160219   MCFG_SOUND_ROUTE(1, "mono", 0.50)                               \
161220                                                   \
r24637r24638
165224   MCFG_SPEAKER_STANDARD_MONO("mono")                              \
166225                                                   \
167226   MCFG_YM2151_ADD("ymsnd", freq1)                             \
168   MCFG_YM2151_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<seibu_ym2151_irqhandler>)) \
227   MCFG_YM2151_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym2151_irqhandler)) \
169228   MCFG_SOUND_ROUTE(0, "mono", 0.50)                               \
170229   MCFG_SOUND_ROUTE(1, "mono", 0.50)
171230
r24637r24638
173232   MCFG_SPEAKER_STANDARD_MONO("mono")                              \
174233                                                   \
175234   MCFG_YM2151_ADD("ymsnd", freq1)                             \
176   MCFG_YM2151_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<seibu_ym2151_irqhandler>)) \
235   MCFG_YM2151_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym2151_irqhandler)) \
177236   MCFG_SOUND_ROUTE(0, "mono", 0.50)                               \
178237   MCFG_SOUND_ROUTE(1, "mono", 0.50)                               \
179238                                                   \
r24637r24638
187246   MCFG_SPEAKER_STANDARD_MONO("mono")                              \
188247                                                   \
189248   MCFG_SOUND_ADD("ym1", YM2203, freq)                             \
190   MCFG_YM2203_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<seibu_ym2203_irqhandler>)) \
249   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym2203_irqhandler)) \
191250   MCFG_YM2203_AY8910_INTF(&seibu_ay8910_config)                   \
192251   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)                     \
193252                                                   \

Previous 199869 Revisions Next


© 1997-2024 The MAME Team