Menu

#5 Speedway! sound is wrong

v1.0_(example)
open
nobody
None
5
2018-09-21
2002-10-20
Justin Kerk
No

In O2em v1.00, Speedway! makes a constant white-noise
sound instead of the rising tones according to speed
that it should.

Discussion

  • Nobody/Anonymous

    I confirm the problem. I own a real o2 a few years ago and the first thing i notice is the sound in speedway that was wrong.

    seems the problem is in audio.c/audio_process() which is not handling sound correctly, or maybe speedway use particular hardware tricks that are not fully interpreted by the emulator

     
  • Tigrou Ind

    Tigrou Ind - 2015-08-24

    Here is the reason :
    O2EM generate pseudo-random 1-bit noise using C rand()%2 calls, while real hardware use linear input feed back from it's 24 bit shift register (LFSR) .

    Additionally, O2EM only output sound to audio buffer, but forget to rewrite shifted values to odyssey 24 bit shift register.

    While noise works in most games, the ones that rely on this to generate more complex sounds (eg : motor) just fail.

    If you are looking for accurate odyssey emulation use MESS/MAME which emulate sound properly.

    Here is the file where it is implemented :
    https://github.com/mamedev/mame/blob/master/src/emu/video/i8244.c in sound_stream_update()

     
  • bataas

    bataas - 2016-06-03

    Here's a quick rewrite of audio_process() in audio.c, it should work now as in MESS/MAME:

    void audio_process(unsigned char *buffer){

    unsigned long old_aud_data, aud_data;
    int pos, pnt, cnt, period, noise, enabled, volume;
    //int intena;
    pnt = cnt = 0;
    
    noise = VDCwrite[AUD_CTRL] & 0x10;
    enabled = VDCwrite[AUD_CTRL] & 0x80;
    
    /* Generate the aud_data */
    old_aud_data = aud_data = VDCwrite[AUD_D2] | (VDCwrite[AUD_D1] << 8) | (VDCwrite[AUD_D0] << 16);
    
    if(enabled)  /* Sound is enabled */
    {
        for( pnt = 0; pnt < SOUND_BUFFER_LEN; pnt++)
        {
            pos = (tweakedaudio) ? (pnt/3) : (MAXLINES-1);
            volume = AudioVector[pos] & 0x0F;
            buffer[pnt] = (aud_data & 0x01) * (0x10 * volume);
            period = (AudioVector[pos] & 0x20) ? PERIOD1 : PERIOD2;
            enabled = AudioVector[pos] & 0x80;
            if( ++cnt >= period )
            {
                cnt = 0;
                aud_data = ((aud_data >> 1) | ((aud_data & 1) << 23));
                /* Check if noise should be applied */
                if (noise)
                {
                    /* Noise tap is on bits 0 and 5 and fed back to bits 15 (and 23!) */
                    unsigned long new_bit = ( ( old_aud_data ) ^ ( old_aud_data >> 5 ) ) & 0x01;
                    aud_data = ( old_aud_data & 0xFF0000 ) | ( ( old_aud_data & 0xFFFF ) >> 1 ) | ( new_bit << 15 ) | ( new_bit << 23 );
                }
                VDCwrite[AUD_D2] = aud_data & 0xFF;
                VDCwrite[AUD_D1] = ( aud_data >> 8 ) & 0xFF;
                VDCwrite[AUD_D0] = ( aud_data >> 16 ) & 0xFF;
                old_aud_data = aud_data;
    
            }
    
        }
    }
    else
    {
        /* Sound disabled, so clear the buffer */
        for( pnt = 0; pnt < SOUND_BUFFER_LEN; pnt++)
        {
            buffer[pnt] = 0;
        }
    }
    if (app_data.filter) filter(buffer, SOUND_BUFFER_LEN);
    

    }

     
    • clobber

      clobber - 2018-09-20

      This patch appears to break the intro tune in "Frogger" - a game which relies on the tweakedaudio hack. Any ideas?

       
  • Tigrou Ind

    Tigrou Ind - 2018-09-21

    Maybe to check in MAME if bug also exists and if it works, how it's done.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.