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: Select all
...
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
...
Code: Select all
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
The used nametable is determined in my program every scanline with a statement like this:
Code: Select all
int NAMETABLE = 0x2000;
switch (readCPURAM(0x2000) & 3) {
case 3:
NAMETABLE = 0x2c00;
break;
case 2:
NAMETABLE = 0x2800;
break;
case 1:
NAMETABLE = 0x2400;
}
Greetings,
mrhyde