Previous 15994 Revisions Next

r13407 Monday 28th November, 2011 at 19:16:27 UTC by Fabio Priuli
wswan: fixed bug 2045. this fixes crash in several wswan games (Morita Shougi, Chocobo Dungeon, World Stadium, World Stadium '99 and the two Medarot games) and possibly in some wscolor games too. [Fabio Priuli]

tech comment: according to docs the frequency value is 11 bits long, so I just masked out the value, fixing the crash.
[src/mess/audio]wswan.c

src/mess/audio/wswan.c
r13406r13407
5757
5858static void wswan_ch_set_freq( running_machine &machine, struct CHAN *ch, UINT16 freq )
5959{
60   freq &= 0x7ff;   // docs say freq is 11bits and a few games (Morita Shougi, World Stadium + others) write 0x800 causing a divide by 0 crash
6061   ch->freq = freq;
61   ch->period = machine.sample_rate() / ( 3072000 / ( ( 2048 - freq ) << 5 ) );
62   ch->period = machine.sample_rate() / (3072000 / ((2048 - freq) << 5));
6263}
6364
6465WRITE8_DEVICE_HANDLER( wswan_sound_port_w )
r13406r13407
6970
7071   switch( offset ) {
7172   case 0x80:            /* Audio 1 freq (lo) */
72      wswan_ch_set_freq( device->machine(), &state->audio1, ( state->audio1.freq & 0xFF00 ) | data );
73      wswan_ch_set_freq(device->machine(), &state->audio1, (state->audio1.freq & 0xff00) | data);
7374      break;
7475   case 0x81:            /* Audio 1 freq (hi) */
75      wswan_ch_set_freq( device->machine(), &state->audio1, ( data << 8 ) | ( state->audio1.freq & 0x00FF ) );
76      wswan_ch_set_freq(device->machine(), &state->audio1, (data << 8 ) | (state->audio1.freq & 0x00ff));
7677      break;
7778   case 0x82:            /* Audio 2 freq (lo) */
78      wswan_ch_set_freq( device->machine(), &state->audio2, ( state->audio2.freq & 0xFF00 ) | data );
79      wswan_ch_set_freq(device->machine(), &state->audio2, (state->audio2.freq & 0xff00) | data);
7980      break;
8081   case 0x83:            /* Audio 2 freq (hi) */
81      wswan_ch_set_freq( device->machine(), &state->audio2, ( data << 8 ) | ( state->audio2.freq & 0x00FF ) );
82      wswan_ch_set_freq(device->machine(), &state->audio2, (data << 8 ) | (state->audio2.freq & 0x00ff));
8283      break;
8384   case 0x84:            /* Audio 3 freq (lo) */
84      wswan_ch_set_freq( device->machine(), &state->audio3, ( state->audio3.freq & 0xFF00 ) | data );
85      wswan_ch_set_freq(device->machine(), &state->audio3, (state->audio3.freq & 0xff00) | data);
8586      break;
8687   case 0x85:            /* Audio 3 freq (hi) */
87      wswan_ch_set_freq( device->machine(), &state->audio3, ( data << 8 ) | ( state->audio3.freq & 0x00FF ) );
88      wswan_ch_set_freq(device->machine(), &state->audio3, (data << 8) | (state->audio3.freq & 0x00ff));
8889      break;
8990   case 0x86:            /* Audio 4 freq (lo) */
90      wswan_ch_set_freq( device->machine(), &state->audio4, ( state->audio4.freq & 0xFF00 ) | data );
91      wswan_ch_set_freq(device->machine(), &state->audio4, (state->audio4.freq & 0xff00) | data);
9192      break;
9293   case 0x87:            /* Audio 4 freq (hi) */
93      wswan_ch_set_freq( device->machine(), &state->audio4, ( data << 8 ) | ( state->audio4.freq & 0x00FF ) );
94      wswan_ch_set_freq(device->machine(), &state->audio4, (data << 8) | (state->audio4.freq & 0x00ff));
9495      break;
9596   case 0x88:            /* Audio 1 volume */
9697      state->audio1.vol_left = ( data & 0xF0 ) >> 4;
r13406r13407
199200            if ( state->sweep_count >= state->sweep_time ) {
200201               state->sweep_count = 0;
201202               state->audio3.freq += state->sweep_step;
202               state->audio3.period = device->machine().sample_rate() / ( 3072000  / ( ( 2048 - state->audio3.freq ) << 5 ) );
203               state->audio3.period = device->machine().sample_rate() / (3072000  / ((2048 - (state->audio3.freq & 0x7ff)) << 5));
203204            }
204205         }
205206         left += state->audio3.vol_left * sample;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team