I'm looking for a starting point here as to best methods for creating a simple vram buffer. I understand the reasons to have one; the limited amount of time for graphical updates in the vBlank. So for things like HUD updates, background graphic changes, etc...I get it. I get that the concept would be to do all of the math and logic outside of the vBlank and have it in cue so that when vBlank hits, it does the update.
So I conceptually understand, I just don't know where to start to maximize that NMI time with doing the least amount of compares in it. Part of this is a little proverbial rubber-duck debugging, but I'm definitely genuinely curious as to best methods.
So for instance, simple HUD with a pictorial life meter. Just to muscle it to work, I had a system where in each NMI, I drew out a series of blank hearts, then looped through based on a health variable how many 'full' hearts to draw over the top. This is how I might handle it in a more modern engine, so it's where my mind went. This was fine, except I know that it'll kill me later.
I would figure that the math would be done outside the NMI to determine which would be full and which would be empty. It seems like I could create a little ram buffer table and in it determine the state of each image (full or empty) outside of NMI, and then just draw that whole table. This would cut the writes in half...but it still feels like there would be a more efficient way to change only the tiles that need changing. Make some function that stores the number of tiles that need changing, the address of those tiles, and the tiles they need to be changed to, and then call those values in the NMI? Maybe do different types of updates on even/odd numbered frames or something to ensure there is time for everything?
How do you guys handle this? Any advice?
So I conceptually understand, I just don't know where to start to maximize that NMI time with doing the least amount of compares in it. Part of this is a little proverbial rubber-duck debugging, but I'm definitely genuinely curious as to best methods.
So for instance, simple HUD with a pictorial life meter. Just to muscle it to work, I had a system where in each NMI, I drew out a series of blank hearts, then looped through based on a health variable how many 'full' hearts to draw over the top. This is how I might handle it in a more modern engine, so it's where my mind went. This was fine, except I know that it'll kill me later.
I would figure that the math would be done outside the NMI to determine which would be full and which would be empty. It seems like I could create a little ram buffer table and in it determine the state of each image (full or empty) outside of NMI, and then just draw that whole table. This would cut the writes in half...but it still feels like there would be a more efficient way to change only the tiles that need changing. Make some function that stores the number of tiles that need changing, the address of those tiles, and the tiles they need to be changed to, and then call those values in the NMI? Maybe do different types of updates on even/odd numbered frames or something to ensure there is time for everything?
How do you guys handle this? Any advice?