Voyage Home - A lesson in 32KB and ambition

Hello everyone! I’ve been working on a project and I’ve reached the point that I wanted to share. The reason for sharing is unfortunately that I’m going to have to change what the game is again and strip parts out to get a game that fits in memory.

My game is Voyage Home. A Space Rogue-like where the objective is to find your way home, uphold the values of the Federation by assisting planets in need, fending off those who would harm you and of course upgrading your ship! Ambitious but I thought I could boil the mechanics down to Arduboy style. Simple text choices, re-use art, randomly generated maps and upgrades simply being upping the hit points of a ship system. I believe I still might be able to but it is going to require me to do more work and be more clever.

So! I ran out of ProgMem space! I’ve learned in the last few weeks that 32KB goes very very fast. At first I thought I could do a turn based RPG. But before I even got to the point where I put “AI” in or Text for the diplomacy part of the game, I was going to run out of memory. So I dumped a lot of graphics, menus and decided to go with an Action approach.

My second approach was going to be reminiscent of the ship battle system in Star Trek The Next Generation for SNES and Sega Genesis. During this process I found a lot of “Devil in the details” issues. After putting weapons in, I found that hitting the other ship was hard, so I wrote some code so that torpedos could “track”. The AI was pretty simple but even then, a KB here, 2 KB there and you’re out of space. When I stopped to take the final video to make this post I was at 28,546 KB out of 28,672 KB. My last ditch to make it playable was to just make it so that after defeating all the enemies, you went to a new sector with more enemies and just last as long as you can. Currently, when I try to generate a new “sector”, the game crashes. I’m sure I have a bug but what I find interesting is that if I remove the star simulation (The stars in the background), to free up some space, the crash goes away. I know it’s probably some bad memory handling and I’m looking into it.

I’m not an expert C++ coder but I’ve been coding in higher level languages for years. I probably did something very inefficiently and I’m going to get a friend to review the code and help me out. This project refreshed a lot for me and instilled hope that I knew what I was doing. I learned a bit about optimizing code too. This is only my second Arduboy project and I learned that while I can run at 60 FPS, my ambition was larger than the allowed memory size. I’ve garnered a greater respect for old console devs who did more with less and wrote their games in assembly.

I’ve learned from this and after I invest some time in another project, I’ll be back…

-Wenceslao

Side Note:
I utilized my tool Image2Arduboy to convert images I made in Photoshop into Hex Byte Arrays that I used in the game. (http://www.gamedesignfu.com/#/portfolio/portfolio/20_image2arduboy/)

9 Likes

Post your source on github please. Did you trying using avr-objdump to get an exact idea of where all your space was going? It’s not always helpful to optimize just by looking at the code unless you deeply understand what the compiler is doing behind the scenes.

1 Like

Oh wow no way! Would love to try this out! :smiley: To boldly code where nobody has coded before!

If you post the code I’ll share the highlights from the dump (or you can just run it yourself)

Some useful articles on setting up git and github

https://guides.github.com/activities/hello-world/

https://help.github.com/articles/set-up-git/

Also on a related note the library gets smaller everyday… not be kilobytes and kilobytes, but little be little. Designing a ‘big’ game on a small platform always requires thinking outside the box. Read some of the teamarg technical briefs for some ideas.


Moderator Note:
Links to Team ARG’s website have been removed due to malicious new owners.

1 Like

@Wenceslao_Villanueva Hey man! Bump for getting the code for this we would love to play! Come back from vacation or wherever you are to bring us the trekkie goodness!

Wow. That is a very cool looking game! Can’t wait to see what becomes of it, scaled back or not!

Using the heap has always been a bit iffy on tiny platforms. Is there any way you can statically allocate the things you need ahead of time, and manage their availability in your own code?

Hey guys, sorry, been crunching at work and I was in Portland all weekend so I didn’t get my Ardubooy until this morning. The project is way over in ProgMem now. Dreamer3, I’ve run an avr-objdump on it and I’ve never done it before and it looks super useful. Thanks! What I’ll do is reduce the build tonight at at least put out something that runs when I get home.

3 Likes

Recently avr-nm was recommended to me also, might be even better if you want to give it a try.