How I write Uzebox Games

From Uzebox Wiki
Jump to navigation Jump to search

The crux of UZEbox programming is that:

1. It has very little RAM (~500 bytes in Mode3) - which makes it more like the Atari7800 rather than all the other 8-bit micros.

2. It has very little 'ROM' (~64K without palleted graphics = equivalent of 8K-16K on a micro with)

3. There's not many CPU cycles in a 60th of a second.

4. There's only about 3 sprites in Mode3.


1. Write it on the PC first - I recompile the source for the PC and intercept the calls at a high level i.e. ReadJoy(), DrawSprite(), MakeSound() - it has lot's more ram than the UZE and therefore easier to prototype the game on - easy!

2. Never use int. use s8,u8,s16,u16 - in that order - you automatically save ram and the PC version will then work just like the UZE version then.

3. Minimize 'local' variables - they use stack space and thus RAM - reducing your usable RAM even further - they game will randomly crash otherwise - you could actually just use globals and have no local variables but that can be tricky if you have a lot of nested subroutines.

4. You can't use 256 tiles in sprite Mode3 - the kernel uses the higher indexes for the sprite/background overlaps so stuff will look corrupted before you reach 256.

5. Put static in front of all your subroutines - this will give you a warning when you compile the game and thus you can remove them and save 'ROM' space.

6. Use shifts instead of multiplies: e.g. x/8 == x>>3 and 4*y == y<<2.

7. Avoid divides and binary to decimal conversions - use dirty flags to only do BTD occasionally - like when a score is updated.

8. Use background tiles instead of sprites.