Kudos to getting to this point. Adding support for more mappers is a nice incremental thing that can be done at your leisure, and once you get save states implemented, playing games at your own pace is super fun :)
Kudos to getting to this point. Adding support for more mappers is a nice incremental thing that can be done at your leisure, and once you get save states implemented, playing games at your own pace is super fun :)
The APU sends all of its samples to a staging buffer, then between video frames, the Mutex for the SDL buffer is locked and the staging buffer is emptied into it. The SDL callback also locks the Mutex 60 times per second, takes evenly spaced samples from the raw data, and truncates what it consumed if it had more than it needed. Now the audio keeps perfect pace with the emulator, whether it slows to 58 FPS or goes too fast, and there's no popping and clicking. If you're curious, here are the relevant spots in the code now:
https://github.com/spieglt/nestur/blob/master/src/audio.rs https://github.com/spieglt/nestur/blob/e49921541d493b3616352...
I just beat the first Zelda dungeon last night, saving the file afterwards, and it was indeed really satisfying.
SBC = A - V - (1 - C)
SBC = A + (-1 * (V - (1 - C)))
SBC = A + (-V + (1 - C))
SBC = A + -V + 1 + C
I am not able to follow the mathemagic behind the third line. Is it normal algebra or its in 1's complement?
ADC = A + V + C
SBC = A - V - (1 - C)
SBC = A + (-1 * (V - (C - 1)))
SBC = A + (-V + (C - 1))
SBC = A + -(V + 1) + C
"The SBC instruction subtracts a value from the accumulator register, with an extra 1 subtracted from the result if the carry flag is NOT set."The explanation fits though. If the carry flag is not set (C == 0) then you subtract an extra 1. If C == 1 then it's A-V.
SBC = A - V - 1 + C
Thanks. I'll fix this up :)
Also, this line is bothersome, they do opposite things but that's why you have already done (1 - C).
Maybe the fact that -V is actually (!V + 1) (in 2's complement) that eats up the extra -1 is the correct explanation?
So,
SBC = A - V - 1 + C
SBC = A + !V + 1 - 1 + C
SBC = A + !V + CAt the time of writing I was sure I had it right too!
I’ll fix that up. Thanks :)