Previous 199869 Revisions Next

r33641 Wednesday 3rd December, 2014 at 05:15:57 UTC by Alex W. Jackson
renegade.c: replace custom sound with MSM5205 [Alex Jackson]
[src/mame/drivers]renegade.c
[src/mame/includes]renegade.h
[src/mame/video]renegade.c

trunk/src/mame/drivers/renegade.c
r242152r242153
108108#include "includes/renegade.h"
109109
110110
111/********************************************************************************************/
111/***************************************************************************
112112
113const device_type RENEGADE_ADPCM = &device_creator<renegade_adpcm_device>;
113    ADPCM sound
114114
115renegade_adpcm_device::renegade_adpcm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
116   : device_t(mconfig, RENEGADE_ADPCM, "Renegade ADPCM Custom", tag, owner, clock, "renegade_adpcm", __FILE__),
117      device_sound_interface(mconfig, *this),
118      m_stream(NULL),
119      m_current(0),
120      m_end(0),
121      m_nibble(0),
122      m_playing(0),
123      m_base(NULL)
115***************************************************************************/
116
117WRITE8_MEMBER(renegade_state::adpcm_start_w)
124118{
119   m_msm->reset_w(0);
120   m_adpcm_playing = true;
125121}
126122
127//-------------------------------------------------
128//  device_config_complete - perform any
129//  operations now that the configuration is
130//  complete
131//-------------------------------------------------
132
133void renegade_adpcm_device::device_config_complete()
123WRITE8_MEMBER(renegade_state::adpcm_addr_w)
134124{
125   m_adpcm_pos = (data - 0x2c) * 0x2000 * 2;
126   m_adpcm_end = m_adpcm_pos + 0x2000 * 2;
135127}
136128
137//-------------------------------------------------
138//  device_start - device-specific startup
139//-------------------------------------------------
140
141void renegade_adpcm_device::device_start()
129WRITE8_MEMBER(renegade_state::adpcm_stop_w)
142130{
143   m_playing = 0;
144   m_stream = machine().sound().stream_alloc(*this, 0, 1, clock());
145   m_base = machine().root_device().memregion("adpcm")->base();
146   m_adpcm.reset();
147
148   save_item(NAME(m_current));
149   save_item(NAME(m_end));
150   save_item(NAME(m_nibble));
151   save_item(NAME(m_playing));
131   m_msm->reset_w(1);
132   m_adpcm_playing = false;
152133}
153134
154//-------------------------------------------------
155//  sound_stream_update - handle a stream update
156//-------------------------------------------------
157
158void renegade_adpcm_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
135WRITE_LINE_MEMBER(renegade_state::adpcm_int)
159136{
160   stream_sample_t *dest = outputs[0];
137   if (!m_adpcm_playing) return;
161138
162   while (m_playing && samples > 0)
139   if (m_adpcm_pos >= m_adpcm_end)
163140   {
164      int val = (m_base[m_current] >> m_nibble) & 15;
165
166      m_nibble ^= 4;
167      if (m_nibble == 4)
168      {
169         m_current++;
170         if (m_current >= m_end)
171            m_playing = 0;
172      }
173
174      *dest++ = m_adpcm.clock(val) << 4;
175      samples--;
141      m_msm->reset_w(1);
142      m_adpcm_playing = false;
143      m_audiocpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
176144   }
177   while (samples > 0)
145   else
178146   {
179      *dest++ = 0;
180      samples--;
147      UINT8 const data = m_adpcmrom[m_adpcm_pos / 2];
148      m_msm->data_w(m_adpcm_pos & 1 ? data & 0xf : data >> 4);
149      m_adpcm_pos++;
181150   }
182151}
183152
184
185WRITE8_MEMBER(renegade_adpcm_device::play_w)
186{
187   int offs = (data - 0x2c) * 0x2000;
188   int len = 0x2000 * 2;
189
190   /* kludge to avoid reading past end of ROM */
191   if (offs + len > 0x20000)
192      len = 0x1000;
193
194   if (offs >= 0 && offs+len <= 0x20000)
195   {
196      m_stream->update();
197      m_adpcm.reset();
198
199      m_current = offs;
200      m_end = offs + len/2;
201      m_nibble = 4;
202      m_playing = 1;
203   }
204   else
205      logerror("out of range adpcm command: 0x%02x\n", data);
206}
207
208153WRITE8_MEMBER(renegade_state::sound_w)
209154{
210155   soundlatch_byte_w(space, offset, data);
r242152r242153
230175   0x68, 0x60
231176};
232177
233void renegade_state::setbank()
234{
235   UINT8 *RAM = memregion("maincpu")->base();
236   membank("bank1")->set_base(&RAM[m_bank ? 0x10000 : 0x4000]);
237}
238
239178void renegade_state::machine_start()
240179{
180   m_rombank->configure_entries(0, 2, memregion("maincpu")->base(), 0x4000);
181
182   save_item(NAME(m_adpcm_pos));
183   save_item(NAME(m_adpcm_end));
184   save_item(NAME(m_adpcm_playing));
241185   save_item(NAME(m_mcu_buffer));
242186   save_item(NAME(m_mcu_input_size));
243187   save_item(NAME(m_mcu_output_byte));
244188   save_item(NAME(m_mcu_key));
245
246   save_item(NAME(m_bank));
247   machine().save().register_postload(save_prepost_delegate(FUNC(renegade_state::setbank), this));
248189}
249190
250191DRIVER_INIT_MEMBER(renegade_state,renegade)
r242152r242153
605546
606547WRITE8_MEMBER(renegade_state::bankswitch_w)
607548{
608   if ((data & 1) != m_bank)
609   {
610      m_bank = data & 1;
611      setbank();
612   }
549   m_rombank->set_entry(data & 1);
613550}
614551
615552TIMER_DEVICE_CALLBACK_MEMBER(renegade_state::renegade_interrupt)
r242152r242153
632569
633570static ADDRESS_MAP_START( renegade_map, AS_PROGRAM, 8, renegade_state )
634571   AM_RANGE(0x0000, 0x17ff) AM_RAM
635   AM_RANGE(0x1800, 0x1fff) AM_RAM_WRITE(renegade_videoram2_w) AM_SHARE("videoram2")
572   AM_RANGE(0x1800, 0x1fff) AM_RAM_WRITE(fg_videoram_w) AM_SHARE("fg_videoram")
636573   AM_RANGE(0x2000, 0x27ff) AM_RAM AM_SHARE("spriteram")
637   AM_RANGE(0x2800, 0x2fff) AM_RAM_WRITE(renegade_videoram_w) AM_SHARE("videoram")
574   AM_RANGE(0x2800, 0x2fff) AM_RAM_WRITE(bg_videoram_w) AM_SHARE("bg_videoram")
638575   AM_RANGE(0x3000, 0x30ff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")
639576   AM_RANGE(0x3100, 0x31ff) AM_RAM_DEVWRITE("palette", palette_device, write_ext) AM_SHARE("palette_ext")
640   AM_RANGE(0x3800, 0x3800) AM_READ_PORT("IN0") AM_WRITE(renegade_scroll0_w)       /* Player#1 controls, P1,P2 start */
641   AM_RANGE(0x3801, 0x3801) AM_READ_PORT("IN1") AM_WRITE(renegade_scroll1_w)       /* Player#2 controls, coin triggers */
577   AM_RANGE(0x3800, 0x3800) AM_READ_PORT("IN0") AM_WRITE(scroll_lsb_w)       /* Player#1 controls, P1,P2 start */
578   AM_RANGE(0x3801, 0x3801) AM_READ_PORT("IN1") AM_WRITE(scroll_msb_w)       /* Player#2 controls, coin triggers */
642579   AM_RANGE(0x3802, 0x3802) AM_READ_PORT("DSW2") AM_WRITE(sound_w) /* DIP2  various IO ports */
643580   AM_RANGE(0x3803, 0x3803) AM_READ_PORT("DSW1") AM_WRITE(renegade_flipscreen_w)   /* DIP1 */
644581   AM_RANGE(0x3804, 0x3804) AM_READWRITE(mcu_r, mcu_w)
645582   AM_RANGE(0x3805, 0x3805) AM_READWRITE(mcu_reset_r, bankswitch_w)
646583   AM_RANGE(0x3806, 0x3806) AM_WRITENOP // ?? watchdog
647584   AM_RANGE(0x3807, 0x3807) AM_WRITE(renegade_coin_counter_w)
648   AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1")
585   AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("rombank")
649586   AM_RANGE(0x8000, 0xffff) AM_ROM
650587ADDRESS_MAP_END
651588
652589static ADDRESS_MAP_START( renegade_sound_map, AS_PROGRAM, 8, renegade_state )
653590   AM_RANGE(0x0000, 0x0fff) AM_RAM
654591   AM_RANGE(0x1000, 0x1000) AM_READ(soundlatch_byte_r)
655   AM_RANGE(0x1800, 0x1800) AM_WRITENOP // this gets written the same values as 0x2000
656   AM_RANGE(0x2000, 0x2000) AM_DEVWRITE("adpcm", renegade_adpcm_device, play_w)
592   AM_RANGE(0x1800, 0x1800) AM_WRITE(adpcm_start_w)
593   AM_RANGE(0x2000, 0x2000) AM_WRITE(adpcm_addr_w)
657594   AM_RANGE(0x2800, 0x2801) AM_DEVREADWRITE("ymsnd", ym3526_device, read, write)
658   AM_RANGE(0x3000, 0x3000) AM_WRITENOP /* adpcm related? stereo pan? */
595   AM_RANGE(0x3000, 0x3000) AM_WRITE(adpcm_stop_w)
659596   AM_RANGE(0x8000, 0xffff) AM_ROM
660597ADDRESS_MAP_END
661598
r242152r242153
866803
867804void renegade_state::machine_reset()
868805{
869   m_bank = 0;
870   setbank();
806   m_rombank->set_entry(0);
807   m_msm->reset_w(1);
808   m_adpcm_playing = 0;
871809}
872810
873811
r242152r242153
905843   MCFG_YM3526_IRQ_HANDLER(DEVWRITELINE("audiocpu", m6809_device, firq_line))
906844   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
907845
908   MCFG_SOUND_ADD("adpcm", RENEGADE_ADPCM, 8000)
846   MCFG_SOUND_ADD("msm", MSM5205, 12000000/32)
847   MCFG_MSM5205_VCLK_CB(WRITELINE(renegade_state, adpcm_int))
848   MCFG_MSM5205_PRESCALER_SELECTOR(MSM5205_S48_4B)  /* 8kHz */
909849   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
910850MACHINE_CONFIG_END
911851
r242152r242153
916856
917857
918858ROM_START( renegade )
919   ROM_REGION( 0x14000, "maincpu", 0 ) /* 64k for code + bank switched ROM */
859   ROM_REGION( 0x10000, "maincpu", 0 ) /* 64k for code + bank switched ROM */
860   ROM_LOAD( "na-5.ic52",     0x00000, 0x8000, CRC(de7e7df4) SHA1(7d26ac29e0b5858d9a0c0cdc86c864e464145260) )
920861   ROM_LOAD( "nb-5.ic51",     0x08000, 0x8000, CRC(ba683ddf) SHA1(7516fac1c4fd14cbf43481e94c0c26c662c4cd28) )
921   ROM_LOAD( "na-5.ic52",     0x04000, 0x4000, CRC(de7e7df4) SHA1(7d26ac29e0b5858d9a0c0cdc86c864e464145260) )
922   ROM_CONTINUE(         0x10000, 0x4000 )
923862
924863   ROM_REGION( 0x10000, "audiocpu", 0 )
925864   ROM_LOAD( "n0-5.ic13",     0x8000, 0x8000, CRC(3587de3b) SHA1(f82e758254b21eb0c5a02469c72adb86d9577065) )
r242152r242153
959898ROM_END
960899
961900ROM_START( kuniokun )
962   ROM_REGION( 0x14000, "maincpu", 0 ) /* 64k for code + bank switched ROM */
901   ROM_REGION( 0x10000, "maincpu", 0 ) /* 64k for code + bank switched ROM */
902   ROM_LOAD( "ta18-11.bin",  0x00000, 0x8000, CRC(f240f5cd) SHA1(ed6875e8ad2988e88389d4f63ff448d0823c195f) )
963903   ROM_LOAD( "nb-01.bin",    0x08000, 0x8000, CRC(93fcfdf5) SHA1(51cdb9377544ae17895e427f21d150ce195ab8e7) ) // original
964   ROM_LOAD( "ta18-11.bin",  0x04000, 0x4000, CRC(f240f5cd) SHA1(ed6875e8ad2988e88389d4f63ff448d0823c195f) )
965   ROM_CONTINUE(         0x10000, 0x4000 )
966904
967905   ROM_REGION( 0x10000, "audiocpu", 0 )
968906   ROM_LOAD( "n0-5.bin",     0x8000, 0x8000, CRC(3587de3b) SHA1(f82e758254b21eb0c5a02469c72adb86d9577065) )
r242152r242153
1002940ROM_END
1003941
1004942ROM_START( kuniokunb )
1005   ROM_REGION( 0x14000, "maincpu", 0 ) /* 64k for code + bank switched ROM */
943   ROM_REGION( 0x10000, "maincpu", 0 ) /* 64k for code + bank switched ROM */
944   ROM_LOAD( "ta18-11.bin",  0x00000, 0x8000, CRC(f240f5cd) SHA1(ed6875e8ad2988e88389d4f63ff448d0823c195f) )
1006945   ROM_LOAD( "ta18-10.bin",  0x08000, 0x8000, CRC(a90cf44a) SHA1(6d63d9c29da7b8c5bc391e074b6b8fe6ae3892ae) ) // bootleg
1007   ROM_LOAD( "ta18-11.bin",  0x04000, 0x4000, CRC(f240f5cd) SHA1(ed6875e8ad2988e88389d4f63ff448d0823c195f) )
1008   ROM_CONTINUE(         0x10000, 0x4000 )
1009946
1010947   ROM_REGION( 0x10000, "audiocpu", 0 )
1011948   ROM_LOAD( "n0-5.bin",     0x8000, 0x8000, CRC(3587de3b) SHA1(f82e758254b21eb0c5a02469c72adb86d9577065) )
trunk/src/mame/includes/renegade.h
r242152r242153
1#include "sound/okiadpcm.h"
1#include "sound/msm5205.h"
22
33#define MCU_BUFFER_MAX 6
44
5class renegade_adpcm_device;
6
75class renegade_state : public driver_device
86{
97public:
108   renegade_state(const machine_config &mconfig, device_type type, const char *tag)
119      : driver_device(mconfig, type, tag),
12      m_videoram(*this, "videoram"),
13      m_videoram2(*this, "videoram2"),
14      m_spriteram(*this, "spriteram"),
1510      m_maincpu(*this,"maincpu"),
1611      m_audiocpu(*this, "audiocpu"),
1712      m_mcu(*this, "mcu"),
13      m_msm(*this, "msm"),
1814      m_gfxdecode(*this, "gfxdecode"),
19      m_palette(*this, "palette") { }
15      m_rombank(*this, "rombank"),
16      m_adpcmrom(*this, "adpcm"),
17      m_fg_videoram(*this, "fg_videoram"),
18      m_bg_videoram(*this, "bg_videoram"),
19      m_spriteram(*this, "spriteram") { }
2020
21   UINT8 m_bank;
21   required_device<cpu_device> m_maincpu;
22   required_device<cpu_device> m_audiocpu;
23   optional_device<cpu_device> m_mcu;
24   required_device<msm5205_device> m_msm;
25   required_device<gfxdecode_device> m_gfxdecode;
26   required_memory_bank m_rombank;
27   required_region_ptr<UINT8> m_adpcmrom;
28   required_shared_ptr<UINT8> m_fg_videoram;
29   required_shared_ptr<UINT8> m_bg_videoram;
30   required_shared_ptr<UINT8> m_spriteram;
31
32   UINT32 m_adpcm_pos;
33   UINT32 m_adpcm_end;
34   bool m_adpcm_playing;
35
2236   int m_mcu_sim;
2337   int m_from_main;
2438   int m_from_mcu;
r242152r242153
4054   int m_mcu_checksum;
4155   const UINT8 *m_mcu_encrypt_table;
4256   int m_mcu_encrypt_table_len;
43   int m_coin;
44   required_shared_ptr<UINT8> m_videoram;
45   required_shared_ptr<UINT8> m_videoram2;
4657   INT32 m_scrollx;
4758   tilemap_t *m_bg_tilemap;
4859   tilemap_t *m_fg_tilemap;
49   required_shared_ptr<UINT8> m_spriteram;
5060
51   required_device<cpu_device> m_maincpu;
5261   DECLARE_WRITE8_MEMBER(sound_w);
5362   DECLARE_READ8_MEMBER(mcu_reset_r);
5463   DECLARE_WRITE8_MEMBER(mcu_w);
r242152r242153
6574   DECLARE_READ8_MEMBER(renegade_68705_port_c_r);
6675   DECLARE_WRITE8_MEMBER(renegade_68705_port_c_w);
6776   DECLARE_WRITE8_MEMBER(renegade_68705_ddr_c_w);
68   DECLARE_WRITE8_MEMBER(renegade_videoram_w);
69   DECLARE_WRITE8_MEMBER(renegade_videoram2_w);
77   DECLARE_WRITE8_MEMBER(fg_videoram_w);
78   DECLARE_WRITE8_MEMBER(bg_videoram_w);
7079   DECLARE_WRITE8_MEMBER(renegade_flipscreen_w);
71   DECLARE_WRITE8_MEMBER(renegade_scroll0_w);
72   DECLARE_WRITE8_MEMBER(renegade_scroll1_w);
80   DECLARE_WRITE8_MEMBER(scroll_lsb_w);
81   DECLARE_WRITE8_MEMBER(scroll_msb_w);
7382   DECLARE_CUSTOM_INPUT_MEMBER(mcu_status_r);
74   DECLARE_WRITE8_MEMBER(adpcm_play_w);
83   DECLARE_WRITE8_MEMBER(adpcm_start_w);
84   DECLARE_WRITE8_MEMBER(adpcm_addr_w);
85   DECLARE_WRITE8_MEMBER(adpcm_stop_w);
86   DECLARE_WRITE_LINE_MEMBER(adpcm_int);
87   
7588   DECLARE_DRIVER_INIT(kuniokun);
7689   DECLARE_DRIVER_INIT(kuniokunb);
7790   DECLARE_DRIVER_INIT(renegade);
r242152r242153
8295   virtual void video_start();
8396   UINT32 screen_update_renegade(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8497   TIMER_DEVICE_CALLBACK_MEMBER(renegade_interrupt);
85   void setbank();
8698   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
87   required_device<cpu_device> m_audiocpu;
88   optional_device<cpu_device> m_mcu;
89   required_device<gfxdecode_device> m_gfxdecode;
90   required_device<palette_device> m_palette;
9199};
92
93class renegade_adpcm_device : public device_t,
94                           public device_sound_interface
95{
96public:
97   renegade_adpcm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
98   ~renegade_adpcm_device() {}
99
100   DECLARE_WRITE8_MEMBER(play_w);
101
102protected:
103   // device-level overrides
104   virtual void device_config_complete();
105   virtual void device_start();
106
107   // sound stream update overrides
108   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
109
110private:
111   // internal state
112   oki_adpcm_state m_adpcm;
113   sound_stream *m_stream;
114   UINT32 m_current;
115   UINT32 m_end;
116   UINT8 m_nibble;
117   UINT8 m_playing;
118   UINT8 *m_base;
119};
120
121extern const device_type RENEGADE_ADPCM;
trunk/src/mame/video/renegade.c
r242152r242153
88#include "includes/renegade.h"
99
1010
11WRITE8_MEMBER(renegade_state::renegade_videoram_w)
11WRITE8_MEMBER(renegade_state::bg_videoram_w)
1212{
13   UINT8 *videoram = m_videoram;
14   videoram[offset] = data;
13   m_bg_videoram[offset] = data;
1514   offset = offset % (64 * 16);
1615   m_bg_tilemap->mark_tile_dirty(offset);
1716}
1817
19WRITE8_MEMBER(renegade_state::renegade_videoram2_w)
18WRITE8_MEMBER(renegade_state::fg_videoram_w)
2019{
21   m_videoram2[offset] = data;
20   m_fg_videoram[offset] = data;
2221   offset = offset % (32 * 32);
2322   m_fg_tilemap->mark_tile_dirty(offset);
2423}
r242152r242153
2827   flip_screen_set(~data & 0x01);
2928}
3029
31WRITE8_MEMBER(renegade_state::renegade_scroll0_w)
30WRITE8_MEMBER(renegade_state::scroll_lsb_w)
3231{
3332   m_scrollx = (m_scrollx & 0xff00) | data;
3433}
3534
36WRITE8_MEMBER(renegade_state::renegade_scroll1_w)
35WRITE8_MEMBER(renegade_state::scroll_msb_w)
3736{
3837   m_scrollx = (m_scrollx & 0xff) | (data << 8);
3938}
4039
4140TILE_GET_INFO_MEMBER(renegade_state::get_bg_tilemap_info)
4241{
43   UINT8 *videoram = m_videoram;
44   const UINT8 *source = &videoram[tile_index];
42   const UINT8 *source = &m_bg_videoram[tile_index];
4543   UINT8 attributes = source[0x400]; /* CCC??BBB */
4644   SET_TILE_INFO_MEMBER(1 + (attributes & 0x7),
4745      source[0],
r242152r242153
5149
5250TILE_GET_INFO_MEMBER(renegade_state::get_fg_tilemap_info)
5351{
54   const UINT8 *source = &m_videoram2[tile_index];
52   const UINT8 *source = &m_fg_videoram[tile_index];
5553   UINT8 attributes = source[0x400];
5654   SET_TILE_INFO_MEMBER(0,
5755      (attributes & 3) * 256 + source[0],


Previous 199869 Revisions Next


© 1997-2024 The MAME Team