I'm working on a game and had been using sprites for certain objects, but because they don't move very often and because I can have far more than 8 per line, I wanted to store them in the background while they're not active. I wrote the code to do so, which does write the correct sprite to the correct background tile, however, every time I do, the screen will briefly scroll for what seems to be a frame before it will reset back to where it should be a ~frame later (haven't actually confirmed its exactly one frame, but I think scroll gets reset every frame with the code I'm working off of). I tried resetting the scroll in the same cycle manually, but it didn't fix the issue. It seems to mostly scroll vertically, but occasionally it's been diagonally.
I'm assuming there's something quirky about writing to the PPU_ADDRESS that I'm missing OR I'm writing to it at the wrong time? Its being written during NMI. I'm using nesdoug's tutorials/example code as a baseline, so part of it is extracted here.
Code snippet below (for all the code and this exact snippet, its here):
Any help or info would be greatly appreciated Thanks in advance!
I'm assuming there's something quirky about writing to the PPU_ADDRESS that I'm missing OR I'm writing to it at the wrong time? Its being written during NMI. I'm using nesdoug's tutorials/example code as a baseline, so part of it is extracted here.
Code snippet below (for all the code and this exact snippet, its here):
Code:
void remove_from_background(int x, int y) {
index = y/8;
//Nametable 0
PPU_ADDRESS = 0x20 + (index/8);
PPU_ADDRESS = 32*(index % 4) + (x/8);
PPU_DATA = 0x01;
Reset_Scroll();
}
index = y/8;
//Nametable 0
PPU_ADDRESS = 0x20 + (index/8);
PPU_ADDRESS = 32*(index % 4) + (x/8);
PPU_DATA = 0x01;
Reset_Scroll();
}
Any help or info would be greatly appreciated Thanks in advance!