Jump to content
  • entries
    4,948
  • comments
    2,718
  • views
    1,808,809

Game Boy programming limits


atari2600land

562 views

So I learned apparently that the GBDK I'm using allowing C is only capable of making 32k games. Which I guess is OK for the Oranges game, but I guess I can't make a really big and good adventure game using only C. I also learned the limit of an "int", what I'm using for the score: 32,767. So I decided that in the unlikely occasion that a player would reach 32,767, I will program an ending for the game. So I guess the object of Oranges would be to get to 32,766 and then the Orange-O-Matic will break and I'll put in a THE END message. Kind of like how the object of Pac-Man (unbeknownst to the programmers) is to get a perfect game. But in Oranges's case, something special will happen if you actually do that. Also, I guess having a 32k limit does not necessarily allow for poor games. Super Mario Land is only 32k, for example. And so is Tetris. Plus, I doubt I could even break the 32k limit if I tried. The game would have to be thousands of lines long. It took me about 8 years to get 3,000 lines' worth of code for Insecticide. But who knows. "Oranges" is right now 700 lines of code. But I doubt the end result will be 3,000 lines, though. And even if it was, I bet I still wouldn't break a 32k barrier. Another thing is I would really like to have the game get a limited release, but I don't know anyone capable of mass reproducing Game Boy games. (By "mass" I mean about 25 or 50.) Last night I put the Game Boy Everdrive in the Super Game Boy. The point-getting sound wasn't all scratchy like it is on a real Game Boy, which is odd. Another thing was that the default color for the game was an orange palette. The orange on the title screen was actually colored orange. And I didn't even have to change the palette. How odd. I also learned that the bottom plug-in of my plug-in strip wasn't working for my SNES. Which is also strange because it was working earlier.

1 Comment


Recommended Comments

So score is an easy one... you have a couple of options. The first option, is if you have a minimum score, you can drop the least significant digits. For instance, if the smallest increment is 100 points, just add it as '1' and display the zeros fixed. That takes your (apparent) maximum from 32,767 to 3,276,700. The second thing you can do is use unsigned int instead of regular int - that will double your range and make the maximum 65535. These tips can be combined, of course.

 

Finally, if you need a truly larger range, then you can use 32-bits instead of 16-bits. If the compiler doesn't support "long" then just define two unsigned ints: "score_high" and "score_low" for instance. The easiest way to deal with this is a function that adds to the score for you (rather than adding inline). Then it can work transparently.

 

unsigned int score_low, score_high;

void addscore(int add) {

unsigned int oldlow = score_low;

score_low+=add;

if (score_low < oldlow) ++score_high;

}

[/core]

 

Most compilers will optimize out the 'oldlow' variable, which is just used to check if the score wrapped around. This works as-is only with unsigned ints - for signed ints it will wrap around to negative, so you would also need to fix up score_low.

 

That gives you the maximum 32-bit range (4,294,967,296), but it's a bit of a pain to display because you need to do a 32-bit division. So I like to cheat myself and make 'score_low' wrap at 10,000 instead. That way you can use your existing score display code - just display all 5 digits from score_high and the last 4 digits from score_low. In that case add_score looks like this:

 

[code]

unsigned int score_low, score_high;

void addscore(int add) {

score_low+=add;

if (score_low > 9999) {

score_low -= 10000;

++score_high;

}

}

[/core]

 

The bank-switching for larger games can be done manually too, but I haven't done it on Gameboy so I can't help much there.

 

Anyway, just rambling. Hope that's interesting. ;)

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...