Hey it's been a while. School started again, had to start applying for colleges and all that, so this had to kinda get pushed to the side. But I've decided I want to finally try and make a working camera system and scrolling engine, now that I'm a bit more comfortable with a bunch of different concepts (which I've so far been unable to integrate as a whole, but progress is progress.)
What I have so far:
-2x2 tile metatiles
-A simple RLE routine that can encode up to 16 bytes (All I'll need is 15 though, since I'll be drawing columns)
-A simple column buffer (2 actually, I explain why below)
I made this from BunnyBoy's scrolling engine on NA, which was designed to scroll automatically and only to the right. I feel comfortable with metatiles and buffers, but what I've been trying to do now is make it so that the screen can scroll left or right, and via the input of the controller.
Right now, whenever the shadow $2005 variable is at 0, the nametables swap, so at startup, if the d-pad isn't pressed, the screen flickers rapidly as the nametables switch every frame. I don't really understand how to fix this (All I've done is avoid it by making $2005 increment for the first 3 frames, to make it scroll slightly to the right.) I've also noticed that when you only tap the d-pad, rather than holding it down, it'll generate graphical errors every once and a while. I think this has to do with once the shadow $2005 variable wraps around to 0, the nametables flip back and forth rapidly, and if it goes to the wrong one, it produces the glitches; but I could be wrong. The buffer I have right now only draws the right tiles when scrolling to the right, and I don't know how I'd go about modifying it to handle both directions.
I'm sure the engine skeleton I have right now could probably be better, I'd love to hear ways it could be improved. The thing I'm the most "unsure" about is that I have 2 buffers - one for when the first half of a new metatile column is drawn, and the other for when the second one is. I also haven't implemented attribute columns yet, as all I'm really worrying about right now is getting the tiles to work.
Some other things I'm still not too sure on, but aren't really concerned with right now, are:
-How to make objects move in relation to the camera. (I think I heard somewhere that you have 1-byte variables for an object's actual position on the screen, and then a larger variable for their global position in the room. Whenever an object moves, its global position moves freely, but its local x position stays at 128 until its at the end of the room.)
-How to keep track of other objects (For instance, enemies), and make sure there are only enough objects on the screen at a time that the NES can handle. For example, if there are enemies that follow the player, what would happen when a spot was reached where new enemies spawn? Do some enemies just get erased?
Anyway, here's my source which I tried to comment thoroughly to remove any potential ambiguity.
Thanks for all the help you guys have been, and I'm sure will continue to be.
What I have so far:
-2x2 tile metatiles
-A simple RLE routine that can encode up to 16 bytes (All I'll need is 15 though, since I'll be drawing columns)
-A simple column buffer (2 actually, I explain why below)
I made this from BunnyBoy's scrolling engine on NA, which was designed to scroll automatically and only to the right. I feel comfortable with metatiles and buffers, but what I've been trying to do now is make it so that the screen can scroll left or right, and via the input of the controller.
Right now, whenever the shadow $2005 variable is at 0, the nametables swap, so at startup, if the d-pad isn't pressed, the screen flickers rapidly as the nametables switch every frame. I don't really understand how to fix this (All I've done is avoid it by making $2005 increment for the first 3 frames, to make it scroll slightly to the right.) I've also noticed that when you only tap the d-pad, rather than holding it down, it'll generate graphical errors every once and a while. I think this has to do with once the shadow $2005 variable wraps around to 0, the nametables flip back and forth rapidly, and if it goes to the wrong one, it produces the glitches; but I could be wrong. The buffer I have right now only draws the right tiles when scrolling to the right, and I don't know how I'd go about modifying it to handle both directions.
I'm sure the engine skeleton I have right now could probably be better, I'd love to hear ways it could be improved. The thing I'm the most "unsure" about is that I have 2 buffers - one for when the first half of a new metatile column is drawn, and the other for when the second one is. I also haven't implemented attribute columns yet, as all I'm really worrying about right now is getting the tiles to work.
Some other things I'm still not too sure on, but aren't really concerned with right now, are:
-How to make objects move in relation to the camera. (I think I heard somewhere that you have 1-byte variables for an object's actual position on the screen, and then a larger variable for their global position in the room. Whenever an object moves, its global position moves freely, but its local x position stays at 128 until its at the end of the room.)
-How to keep track of other objects (For instance, enemies), and make sure there are only enough objects on the screen at a time that the NES can handle. For example, if there are enemies that follow the player, what would happen when a spot was reached where new enemies spawn? Do some enemies just get erased?
Anyway, here's my source which I tried to comment thoroughly to remove any potential ambiguity.
Attachment:
Thanks for all the help you guys have been, and I'm sure will continue to be.