I've recently written my Nes emulator's ppu and almost every game(donkey kong, smb, ice climbers, balloon fight) runs fine except Kung Fu. Here's what happens to him:
https://imgur.com/a/G4Chx8D
Does anyone have any idea as to what is causing this? I'm stuck and i can't find anything. Anything is appreciated.
My Nes emulator causes the main character's body in Kung Fu to split in half?
Moderator: Moderators
Re: My Nes emulator causes the main character's body in Kung Fu to split in half?
The main character in this game is drawn with background tiles, not sprites, so the game need to change the scroll mid-frame in order to control the positions of the background and the player. The scroll split is supposed to happen much closer to the top of the screen, so maybe this is a timing issue?
Re: My Nes emulator causes the main character's body in Kung Fu to split in half?
Where exactly would be the first play i should start looking in my emulator for errors with the timing?tokumaru wrote: ↑Mon Jan 18, 2021 1:46 am The main character in this game is drawn with background tiles, not sprites, so the game need to change the scroll mid-frame in order to control the positions of the background and the player. The scroll split is supposed to happen much closer to the top of the screen, so maybe this is a timing issue?
Re: My Nes emulator causes the main character's body in Kung Fu to split in half?
It could be a sprite 0 hit issue, or the execution time of the instructions. Are you keeping track of the CPU cycles relative to the PPU cycles? Many games will use timed code while the PPU is rendering in order to wait for specific moments and apply some sort of PPU effect, such as a scroll change, and for that to work you must make sure that the PPU and the CPU run in parallel, with each instruction taking the correct number of cycles to execute.
Re: My Nes emulator causes the main character's body in Kung Fu to split in half?
0x3000-0x3eff is a mirror of 0x2000-0x2efftokumaru wrote: ↑Mon Jan 18, 2021 2:50 am It could be a sprite 0 hit issue, or the execution time of the instructions. Are you keeping track of the CPU cycles relative to the PPU cycles? Many games will use timed code while the PPU is rendering in order to wait for specific moments and apply some sort of PPU effect, such as a scroll change, and for that to work you must make sure that the PPU and the CPU run in parallel, with each instruction taking the correct number of cycles to execute.
does that mean data written to 0x3000 - 0x3eff is also written to 0x2000-0x2eff?
Re: My Nes emulator causes the main character's body in Kung Fu to split in half?
Yes and I didn't know about this mirror, thanks. My NES emulator doesn't support it. Data at this range isn't "also" written to the other range, mirrors work by masking part of the address during access.
As for the scrolling split, the one between HUD and play field is done with sprite 0. The next 2 are timed by the CPU relative to where sprite 0 hit. It's hard to tell exactly what's wrong in this screenshot.
How many CPU cycles do you emulate per scan line?
How do you count CPU cycles?
Re: My Nes emulator causes the main character's body in Kung Fu to split in half?
For each CPU access (read/write), the NTSC PPU runs for 3 cycles, or 341 PPU cycles per scanline, or 113.6 CPU cycles.How many CPU cycles do you emulate per scan line?
How do you count CPU cycles?
Zepper
RockNES author
RockNES author
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
Re: My Nes emulator causes the main character's body in Kung Fu to split in half?
nesemu101, next time, if your response has nothing to do with a quoted post, please don’t quote the post. I was utterly confused as why you thought tokumaru’s post meant data written to 0x3000 - 0x3eff is also written to 0x2000-0x2eff.nesemu101 wrote: ↑Tue Jan 19, 2021 1:43 am0x3000-0x3eff is a mirror of 0x2000-0x2efftokumaru wrote: ↑Mon Jan 18, 2021 2:50 am It could be a sprite 0 hit issue, or the execution time of the instructions. Are you keeping track of the CPU cycles relative to the PPU cycles? Many games will use timed code while the PPU is rendering in order to wait for specific moments and apply some sort of PPU effect, such as a scroll change, and for that to work you must make sure that the PPU and the CPU run in parallel, with each instruction taking the correct number of cycles to execute.
does that mean data written to 0x3000 - 0x3eff is also written to 0x2000-0x2eff?
If you want tokumaru to respond to a new question, you might try thanking him for his crucial help and THEN ask your new question.