Hi,
I didn't know if I should open a new topic for this or reuse my old one here. But because of the fact that this problem is "standalone" I opend a new topic. I hope this is okay for you.
For those who didn't read the other topic: I'm developing an nes emulator. Currently I'm working on the background. I think it looks really good; scrolling in x direction also works pretty nice. The colors arn't so hard - there is no problem. Oh wait:
While I'm developing I test my result with Super Mario Bros (1). Only to see if everything works. So you know, that the "general information" (time left, world etc.) is displayed in the top area of the screen. As you can see here only the first nametable displays this data. I figured out, that if the "camera" scrolls into the second nametable (0x2400) it "switches" for the first 31 scanlines the nametable to the first one (0x2000) containing this information bar; the rest of the screen is then rendered from the second nametable. Here some debug output from my program:
So now the problem: if my emulator runs normal everytime Mario is in the second nametable the information bar is flickering. Because sometimes the nametable is not set to 0x2000 for the first 31 scanlines:
So have you any idea where I made a mistake?
The used nametable is determined in my program every scanline with a statement like this:
int NAMETABLE = 0x2000;
switch (readCPURAM(0x2000) & 3) {
case 3:
NAMETABLE = 0x2c00;
break;
case 2:
NAMETABLE = 0x2800;
break;
case 1:
NAMETABLE = 0x2400;
}
I think that this precludes a mistake in my emulator, because the program is responsible for maintaining the contents in register 0x2000. But this bug isn't present in other emulators - that is a hint for a bug in my emulator ...
Greetings,
mrhyde
I didn't know if I should open a new topic for this or reuse my old one here. But because of the fact that this problem is "standalone" I opend a new topic. I hope this is okay for you.
For those who didn't read the other topic: I'm developing an nes emulator. Currently I'm working on the background. I think it looks really good; scrolling in x direction also works pretty nice. The colors arn't so hard - there is no problem. Oh wait:
While I'm developing I test my result with Super Mario Bros (1). Only to see if everything works. So you know, that the "general information" (time left, world etc.) is displayed in the top area of the screen. As you can see here only the first nametable displays this data. I figured out, that if the "camera" scrolls into the second nametable (0x2400) it "switches" for the first 31 scanlines the nametable to the first one (0x2000) containing this information bar; the rest of the screen is then rendered from the second nametable. Here some debug output from my program:
Code:
...
Nametable used: 0x2400 for scanline 238
Nametable used: 0x2400 for scanline 239
Nametable used: 0x2000 for scanline 0
Nametable used: 0x2000 for scanline 1
...
Nametable used: 0x2000 for scanline 31
Nametable used: 0x2400 for scanline 32
...
Nametable used: 0x2400 for scanline 238
Nametable used: 0x2400 for scanline 239
Nametable used: 0x2000 for scanline 0
Nametable used: 0x2000 for scanline 1
...
Nametable used: 0x2000 for scanline 31
Nametable used: 0x2400 for scanline 32
...
So now the problem: if my emulator runs normal everytime Mario is in the second nametable the information bar is flickering. Because sometimes the nametable is not set to 0x2000 for the first 31 scanlines:
Code:
Nametable used: 0x2400 for scanline 238
Nametable used: 0x2400 for scanline 239
Nametable used: 0x2400 for scanline 0
...
Nametable used: 0x2400 for scanline 29
Nametable used: 0x2400 for scanline 30
Nametable used: 0x2400 for scanline 31
Nametable used: 0x2400 for scanline 239
Nametable used: 0x2400 for scanline 0
...
Nametable used: 0x2400 for scanline 29
Nametable used: 0x2400 for scanline 30
Nametable used: 0x2400 for scanline 31
So have you any idea where I made a mistake?
The used nametable is determined in my program every scanline with a statement like this:
Code:
int NAMETABLE = 0x2000;
switch (readCPURAM(0x2000) & 3) {
case 3:
NAMETABLE = 0x2c00;
break;
case 2:
NAMETABLE = 0x2800;
break;
case 1:
NAMETABLE = 0x2400;
}
I think that this precludes a mistake in my emulator, because the program is responsible for maintaining the contents in register 0x2000. But this bug isn't present in other emulators - that is a hint for a bug in my emulator ...
Greetings,
mrhyde