Results 1 to 12 of 12

Thread: Linear Feedback Shift Register

Threaded View

  1. #5

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Linear Feedback Shift Register

    In the site http://wiki.nesdev.com/w/index.php/APU_Noise, it clearly states "Feedback is calculated as the exclusive-OR of bit 0 and one other bit: bit 6 if Mode flag is set, otherwise bit 1. " It all starts at Bit 14. To get to Bit 6 you have to right shift 8 bits:
    ------------------------>
    14-13-12-11-10-9-8-7-6-5-4-3-2-1-0

    And I technically already small stepped it. Take a look at this C# code from another emulator that was commented inside the function:
    Code:
            'if (Noise.datatype)
            '    Noise.CurD = (Noise.CurD << 1) | (((Noise.CurD >> 14) ^ (Noise.CurD >> 8)) & 0x1);
            'else    Noise.CurD = (Noise.CurD << 1) | (((Noise.CurD >> 14) ^ (Noise.CurD >> 13)) & 0x1);
    Although ugly, if you break it down, its actually

    Code:
            'if (Noise.datatype){
            '    Bit_0 = (Noise.CurD >> 14);
            '    Bit_6 = (Noise.CurD >> 8);
            '    Feedback = (Bit_0 ^ Bit_6);
            '    Noise.CurD = (Noise.CurD << 1) | (Feedback & 0x1);
            '}
            'else {   
            '    Bit_0 = (Noise.CurD >> 14);
            '    Bit_1 = (Noise.CurD >> 13);
            '    Feedback = (Bit_0 ^ Bit_1);
            '    Noise.CurD = (Noise.CurD << 1) | (Feedback & 0x1);
            '}
    And even though I did it a tad different, the results were the same either way. Removing &H1 in any of those places resulted in a much higher pitched Noise.

    [EDIT] I was playing around with my emulators noise code and, not sure if you have or not but download my NES Emulator, and remove the ".Length_Counter > 0" if statement in the beginning of the function. Play Super Mario Bros, ignor the Noise sound for a minute (youll see why), grab a mushroom, and break a brick block. Youll hear something that was missing. The sound of bricks breaking with a nice bass thump. Although the length counter code is correct, I may have to do what the C++ emulator did, and actually use a lookup table that I can XOR tap.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width