Previous 15994 Revisions Next

r2105 Tuesday 25th March, 2008 at 18:43:28 UTC by Miodrag Milanović
[SPECIAL] Sound added
[src/mess]mess.mak
[src/mess/audio]special.c*
[src/mess/drivers]special.c
[src/mess/includes]special.h
[src/mess/machine]special.c

src/mess/audio/special.c
r0r2105
1/***************************************************************************
2 
3  audio/special.c
4 
5  Functions to emulate sound hardware of Specialist MX
6  ( based on code of DAI interface )
7 
8****************************************************************************/
9 
10#include "driver.h"
11#include "sound/custom.h"
12#include "machine/pit8253.h"
13#include "includes/dai.h"
14#include "streams.h"
15#include "deprecat.h"
16 
17static void *specimx_sh_start(int clock, const struct CustomSound_interface *config);
18static void specimx_sh_update(void *param,stream_sample_t **inputs, stream_sample_t **_buffer,int length);
19 
20static sound_stream *mixer_channel;
21 
22const struct CustomSound_interface specimx_sound_interface =
23{
24   specimx_sh_start,
25   NULL,
26   NULL
27};
28 
29static void *specimx_sh_start(int clock, const struct CustomSound_interface *config)
30{
31   mixer_channel = stream_create(0, 2, Machine->sample_rate, 0, specimx_sh_update);
32   return (void *) ~0;
33}
34 
35static void specimx_sh_update(void *param,stream_sample_t **inputs, stream_sample_t **buffer,int length)
36{
37   INT16 channel_0_signal;
38   INT16 channel_1_signal;
39   INT16 channel_2_signal;
40   static int channel_0_incr = 0;
41   static int channel_1_incr = 0;
42   static int channel_2_incr = 0;
43   int channel_0_baseclock;
44   int channel_1_baseclock;
45   int channel_2_baseclock;
46 
47   int rate = Machine->sample_rate / 2;
48 
49   stream_sample_t *sample_left = buffer[0];
50   stream_sample_t *sample_right = buffer[1];
51 
52   channel_0_baseclock = pit8253_get_frequency(0, 0);
53   channel_1_baseclock = pit8253_get_frequency(0, 1);
54   channel_2_baseclock = pit8253_get_frequency(0, 2);
55 
56   channel_0_signal = pit8253_get_output (0,0) ? 3000 : -3000;
57   channel_1_signal = pit8253_get_output (0,1) ? 3000 : -3000;
58   channel_2_signal = pit8253_get_output (0,2) ? 3000 : -3000;
59 
60 
61   while (length--)
62   {
63      *sample_left = 0;
64      *sample_right = 0;
65 
66      /* music channel 0 */
67 
68      *sample_left += channel_0_signal;
69      channel_0_incr -= channel_0_baseclock;
70      while( channel_0_incr < 0 )
71      {
72         channel_0_incr += rate;
73         channel_0_signal = -channel_0_signal;
74      }
75 
76 
77      /* music channel 1 */
78 
79      *sample_left += channel_1_signal;
80      channel_1_incr -= channel_1_baseclock;
81      while( channel_1_incr < 0 )
82      {
83         channel_1_incr += rate;
84         channel_1_signal = -channel_1_signal;
85      }
86 
87      /* music channel 2 */
88 
89      *sample_left += channel_2_signal;
90      channel_2_incr -= channel_2_baseclock;
91      while( channel_2_incr < 0 )
92      {
93         channel_2_incr += rate;
94         channel_2_signal = -channel_2_signal;
95      }
96       
97      sample_left++;
98      sample_right++;
99   }
100}
101 
102void specimx_sh_change_clock(double clock)
103{
104   stream_update(mixer_channel);
105}
src/mess/includes/special.h
r2104r2105
3131extern READ8_HANDLER ( specimx_disk_ctrl_r );
3232extern WRITE8_HANDLER( specimx_disk_ctrl_w );
3333
34extern WRITE8_HANDLER( specimx_sound_w );
35
3436/*----------- defined in video/special.c -----------*/
3537
3638extern UINT8 *specialist_video_ram;
r2104r2105
4547extern PALETTE_INIT( specimx );
4648extern rgb_t specimx_palette;
4749
50/*----------- defined in audio/special.c -----------*/
51
52extern const struct CustomSound_interface specimx_sound_interface;
53extern void specimx_sh_change_clock(double);
54
4855#endif /* SPECIAL_H_ */
src/mess/machine/special.c
r2104r2105
251251   specimx_color = 0x70;   
252252   wd17xx_reset();
253253   wd17xx_set_side(0);
254   pit8253_reset(0);
255   pit8253_0_gate_w(machine, 0, 0);
256   pit8253_0_gate_w(machine, 1, 0);
257   pit8253_0_gate_w(machine, 2, 0);
254258}
255259
256260READ8_HANDLER ( specimx_disk_data_r )
r2104r2105
334338   basicdsk_set_calcoffset(image, specimx_calcoffset);
335339   return INIT_PASS;
336340}
341
342WRITE8_HANDLER( specimx_sound_w)
343{
344   
345      pit8253_0_w(machine,offset,data);     
346}
src/mess/mess.mak
r2104r2105
11941194   $(MESS_VIDEO)/mikro80.o \
11951195
11961196$(MESSOBJ)/special.a:      \
1197   $(MESS_AUDIO)/special.o \
11971198   $(MESS_DRIVERS)/special.o \
11981199   $(MESS_MACHINE)/special.o \
11991200   $(MESS_VIDEO)/special.o \
src/mess/drivers/special.c
r2104r2105
3838    AM_RANGE( 0xffe0, 0xffe3 ) AM_READWRITE(specialist_keyboard_r,specialist_keyboard_w) // 8255 for keyboard   
3939    AM_RANGE( 0xffe4, 0xffe7 ) AM_RAM //external 8255
4040    AM_RANGE( 0xffe8, 0xffeb ) AM_READWRITE(specimx_disk_data_r,specimx_disk_data_w)
41    AM_RANGE( 0xffec, 0xffef ) AM_READWRITE(pit8253_0_r, pit8253_0_w)
41    AM_RANGE( 0xffec, 0xffef ) AM_READWRITE(pit8253_0_r, specimx_sound_w)
4242    AM_RANGE( 0xfff0, 0xfff3 ) AM_READWRITE(specimx_disk_ctrl_r, specimx_disk_ctrl_w)
4343    AM_RANGE( 0xfff8, 0xfff8 ) AM_READWRITE(specimx_video_color_r,specimx_video_color_w)
4444    AM_RANGE( 0xfffc, 0xfffe ) AM_WRITE(specimx_select_bank)     
r2104r2105
335335      MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)           
336336      MDRV_SOUND_ADD(WAVE, 0)
337337      MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)       
338      MDRV_SOUND_ADD(CUSTOM, 0)
339      MDRV_SOUND_CONFIG(specimx_sound_interface)
340      MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)             
338341MACHINE_DRIVER_END
339342 
340343/* ROM definition */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team