Donkey Kong Land shakes horizontally [solved]
Donkey Kong Land shakes horizontally [solved]
I noticed this issue in several GB emulators, including one that I am attempting to code. The player select screen shakes horizontally and the same thing happens during game play. It seems like every other frame it out of alignment. If anyone has seen this issue before, perhaps you can provide me with a few hints to track this down? Thanks.
Last edited by zeroone on Mon Nov 27, 2017 12:12 pm, edited 1 time in total.
Re: Donkey Kong Land shakes horizontally
Can you give an example of an emulator (other than yours) which exhibits this behavior?
Looking at the code, from 5AF2 and forward there's some code that seems to be related to camera panning. It later writes to FFAB which in turn is I'm going to go out on a limb and say that your bug is related to how flags are affected by the rr, sra, add or adc instructions.
Looking at the code, from 5AF2 and forward there's some code that seems to be related to camera panning. It later writes to FFAB which in turn is I'm going to go out on a limb and say that your bug is related to how flags are affected by the rr, sra, add or adc instructions.
Re: Donkey Kong Land shakes horizontally
I saw a similar effect in JavaBoy. It's an old emulator, but it used to be hosted on many web pages. Whatever it is doing wrong, I'm doing the same thing incorrectly.nitro2k01 wrote:Can you give an example of an emulator (other than yours) which exhibits this behavior?
Looking at the code, from 5AF2 and forward there's some code that seems to be related to camera panning. It later writes to FFAB which in turn is I'm going to go out on a limb and say that your bug is related to how flags are affected by the rr, sra, add or adc instructions.
I reviewed the flags in those instructions and I can't visually see an issue. However, I did notice what appears to be a repeated typo in the Gameboy CPU (LR35902) instruction set table; the carry flag is marked as reset in all the SRA instructions. My emulator is setting the carry flag to the LSB.
If there is a particular test ROM that could vet the instruction flags, I'll gladly run it.
I noticed a similar issue with Street Fighter 2. Both of those are SGB roms. I'm not sure if there is a connection.
-
- Posts: 33
- Joined: Sat May 13, 2017 7:54 pm
Re: Donkey Kong Land shakes horizontally
What do you mean? There's no player select...zeroone wrote:I noticed this issue in several GB emulators, including one that I am attempting to code. The player select screen shakes horizontally and the same thing happens during game play. It seems like every other frame it out of alignment. If anyone has seen this issue before, perhaps you can provide me with a few hints to track this down? Thanks.
Re: Donkey Kong Land shakes horizontally
After the title screen, there is a screen where you can select your player (your save game slot). That selection screen shakes horizontally.SuperWill24 wrote:What do you mean? There's no player select...
In fact, the whole games seems like it is running at half speed. It's almost like it renders the frame correctly and then it re-renders it a second time with the wrong scroll offset.
Re: Donkey Kong Land shakes horizontally [solved]
[solved]
The problem was related to LYC. The wiki says that LYC and related registers "can be accessed even during Mode 3, but they have no effect until the end of the current scanline." To postpone the effect of LYC updates, I introduced a cached LYC variable and my buggy code was using the cached value instead of the latest during VBLANK.
On a side note, I suspect that updating LYC actually takes effect immediately since writing to LYC can trigger an LCD STAT interrupt. And, as such, I got rid of the cached version entirely.
The problem was related to LYC. The wiki says that LYC and related registers "can be accessed even during Mode 3, but they have no effect until the end of the current scanline." To postpone the effect of LYC updates, I introduced a cached LYC variable and my buggy code was using the cached value instead of the latest during VBLANK.
On a side note, I suspect that updating LYC actually takes effect immediately since writing to LYC can trigger an LCD STAT interrupt. And, as such, I got rid of the cached version entirely.