by Waterluvian · 3y ago · 0 comments
When I wrote mine, something I ran into was realizing that often the CPU and PPU are just doing the same thing over and over and over. If only I could cache all that work.
For example, you don’t modify the previous frame. You have to draw the entire frame every time, writing sprites from OAM memory every time. Sometimes games do clever stuff here for effects, but a lot of the time you’re just drawing the same stuff. Like Tetris is almost completely a routine of drawing almost entirely the same graphics every time. Most of the cycles and OAM writes are just juggling sprites to draw the same layout every time.
I documented the heck out of the PPU because it gave me the second most grief (sound being the worst by far) if you are curious: https://github.com/ablakey/gameboy/blob/master/src/guest/sys... (goodness I’m proud of this project. Don’t tell my boss. He’ll want this level of documentation at work ;) )
I wonder if you googled for this? Googling for “original gameboy battery life” gives nearly this exact quote, but then reading the wikipedia article that it came from reveals that this is talking about the Gameboy Light (1998 - arguably “the original hardware with modern technology to reduce energy consumption”). I went and fact-checked because I remembered that the original original gameboy (1989) had 4 AA batteries and no light ;)
edit. also Nintendo's figures show a lower battery time for the Pocket and Color, so they probably just decided to trade for space/weight.
https://www.nintendo.co.uk/Support/Game-Boy-Pocket-Color/Pro...
9 year old me was particularly proud of the self made spring that fit between the batteries.
Adult me would probably put the batteries side by side though.
Everyone had either the GB and many more people had the GB Pocket because of Pokémon.
FYI, I contacted the group to express interest over 2 years ago and never got a response. They are working on a new project with more advanced graphics https://www.techradar.com/features/the-quest-for-the-solar-p...
Here's a sample from the file:
// For sprites, color 0 is transparency so don't draw anything.
if color == 0 {
continue;
}
This comment is probably not necessary: it would be equally clear if it were written as something like the following: if color == SPRITE_COLOR_TRANSPARENT {
continue;
}
A few lines up is another comment: // Is this specific pixel not on the screen? We already check that x_pos is not off
// the left side earlier, so only need to check that it's not off the right side.
if x_pos + p >= 160 {
continue;
}
If the code were written with a constant, then it would only need to clarify why we don't check the left side here (the only non-obvious thing about the code), so: // Note: bounds testing on the left side is handled earlier
if x_pos + p >= SCREEN_WIDTH {
continue;
}
One last example: // We want to iterate through 160 pixels to draw one scanline.
for col in 0..160u8 {
No comment, similar level of readability: for col in ppu.iterscanlines() {