Some pipes lead to weird non-rooms in Super Mario Bros.
Moderator: Moderators
Some pipes lead to weird non-rooms in Super Mario Bros.
Hi! Long time lurker, first time poster. I'm working on an NES Emulator: https://github.com/spieglt/nestur. I just got the square and triangle audio channels working the other day (not merged to master yet) and before I finish audio and implement some mappers I want to take care of a strange bug I noticed a while back. In Super Mario Bros., the pipe in World 1-1 which leads to some coins works fine. The Warp Zone pipes in World 1-2 which take you to worlds 2, 3, or 4 also work fine. But some pipes, like the first in World 1-2 which is supposed to lead to a long shelf of coins with a pipe below, instead take Mario to a strange empty room with no pipe or coins. It doesn't scroll. All you can do is run back and forth until time runs out. Image of the room and the pipe that leads to it are attached. Has anyone seen anything like this before? I'm guessing it's a subtle PPU bug but I have no idea how to go about troubleshooting it. Thanks for any help you can provide!
-
- Posts: 260
- Joined: Mon Jan 23, 2012 11:27 pm
Re: Some pipes lead to weird non-rooms in Super Mario Bros.
Smb has some level data stored in chr iirc. Do you have chr data streaming working? I dont know where in the game that actually happens.
Re: Some pipes lead to weird non-rooms in Super Mario Bros.
As fas as I know, it's not level data in CHR ROM, it's the title screen.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Re: Some pipes lead to weird non-rooms in Super Mario Bros.
Thanks FrankWDoom and Dwedit. I do believe I have CHR-ROM mapped properly for NROM. I'm not sure what you mean by data streaming exactly. So Dwedit, that would mean it's in PRG-ROM? Someone on Reddit sent me the disassembly (https://gist.github.com/1wErt3r/4048722) for SMB, and I've been reading that trying to find where/how WarpZoneControl gets modified. The executed instructions seem to be correct when I go down the pipe compared to a good emulator. HandlePipeEntry reads WarpZoneControl repeatedly. But I'm wondering if, since WZC's value is 0, meaning not a proper "warp zone" that takes you to another World, it determines which room to drop you in another way.
I believe that the L_UndergroundArea3 symbol is the level data for the coin bonus rooms, and those bytes are at 0x2D79 in the ROM, meaning they'd be mapped to 0xAD29 in memory. I'm not sure what that level data means/does exactly, though. Won't hurt to verify that it is where I think it is and is loaded properly, though I don't see how it could be messed up.
I believe that the L_UndergroundArea3 symbol is the level data for the coin bonus rooms, and those bytes are at 0x2D79 in the ROM, meaning they'd be mapped to 0xAD29 in memory. I'm not sure what that level data means/does exactly, though. Won't hurt to verify that it is where I think it is and is loaded properly, though I don't see how it could be messed up.
Re: Some pipes lead to weird non-rooms in Super Mario Bros.
Thought it was just the title screen that was in chr-rom (it's been too long so I can't remember; I emulated SMB on the PCE). But if there is more related data in PPU address space; maybe it has to do something with the "first read from PPU memory after address set needs to be ignored" issue?
Re: Some pipes lead to weird non-rooms in Super Mario Bros.
My hunch is that there's some subtle CPU implementation bug instead of PPU wonkiness. This just doesn't feel like a PPU implementation failure to me .... well, at least as long as the sprite 0 hit is continuing to happen.
Re: Some pipes lead to weird non-rooms in Super Mario Bros.
I've verified that L_UndergroundArea3 is at 0xAD79 in memory and is accessed whenever Mario goes down a pipe to a coin room, and the memory at that location is correct both on my emulator and one that works.
Edit: Also, WarpZoneControl seems to be written to identically in both emulators. It's set to 0 at the start of a level and when entering a coin room, 1 when running above a Warp Zone, 4 when dropping down to the Warp Zone pipes, and back to 0 at the start of the next level. So the WarpZoneControl is correct, the level data for the coin room is correct... I'm not sure what else it can be.
Second edit: I've also verified that the enemy and level data for the underground bonus rooms are not changed when the pipe is taken to the bad room.
Edit: Also, WarpZoneControl seems to be written to identically in both emulators. It's set to 0 at the start of a level and when entering a coin room, 1 when running above a Warp Zone, 4 when dropping down to the Warp Zone pipes, and back to 0 at the start of the next level. So the WarpZoneControl is correct, the level data for the coin room is correct... I'm not sure what else it can be.
Second edit: I've also verified that the enemy and level data for the underground bonus rooms are not changed when the pipe is taken to the bad room.
Re: Some pipes lead to weird non-rooms in Super Mario Bros.
Maybe compare logs against a known good emulator?
Re: Some pipes lead to weird non-rooms in Super Mario Bros.
I second this. Probably forgot some processor flag setting or clearing for 1 or more instruction.
or, maybe incorrectly calculating an indirect address.
nesdoug.com -- blog/tutorial on programming for the NES
Re: Some pipes lead to weird non-rooms in Super Mario Bros.
Start with the basics.
First confirm that you pass CPU tests.
Then confirm that the memory map is correct, and that when you read a byte, the correct byte is read, including page crossing and zeropage wrapping.
First confirm that you pass CPU tests.
Then confirm that the memory map is correct, and that when you read a byte, the correct byte is read, including page crossing and zeropage wrapping.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Re: Some pipes lead to weird non-rooms in Super Mario Bros.
It's passed the popular nestest.nes ROM (which includes zero page but possibly not page cross tests) since before I started on the PPU. What else specifically do you recommend?
Re: Some pipes lead to weird non-rooms in Super Mario Bros.
http://wiki.nesdev.com/w/index.php/Emulator_tests
Try instr_test_v5. http://blargg.8bitalley.com/nes-tests/instr_test-v5.zip
Try instr_test_v5. http://blargg.8bitalley.com/nes-tests/instr_test-v5.zip
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Re: Some pipes lead to weird non-rooms in Super Mario Bros.
Thanks. Looks like I can't run the ones in instr_test-v5.zip as I haven't implemented mapper 1 yet, so maybe I'll take a detour and do that soon.Dwedit wrote: ↑Mon Jan 06, 2020 6:28 pm http://wiki.nesdev.com/w/index.php/Emulator_tests
Try instr_test_v5. http://blargg.8bitalley.com/nes-tests/instr_test-v5.zip
Re: Some pipes lead to weird non-rooms in Super Mario Bros.
I think the ROM Singles are mapper 0, so you can just run those for now.
Note that they test unofficial instructions too, so if you're not trying for those at the moment, you can ignore errors regarding them.
Note that they test unofficial instructions too, so if you're not trying for those at the moment, you can ignore errors regarding them.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Re: Some pipes lead to weird non-rooms in Super Mario Bros.
Wow, thank you so much! Case closed. Test 11 crashed, which led me to find that branching to a value of 0x80 (-128) would cause an overflow because of a bad cast of i8 to usize. This fixed the pipe bug. Tests 15 and 16 also helped fix a bug with my BRK instruction. Now I only fail test 3, because I'm missing some unofficial opcodes (AAC, ASR, ARR, ATX, and AXS), and test 7 which crashes. Not sure why it crashes (tries to execute 0x9C in absolute_x mode), but it goes into an infinite loop on another emulator that seems to work well. Also, thank you again for spotting the problem with my vertical sprite flip a while back!