Adventures in Cross Compilation

Twelve days ago I got Plasmacore running on the Wii.  The problem was that while our current game project (MadStone) looked great in general, there was a slightly noticeable – but noticeable – frame rate drop when a level first starts and dozens of blocks fall from the sky.

I did some profiling.  Turns out that:

  • We were getting 30 frames per second during regular gameplay, dipping to 15 during level start.
  • Frames were taking around 1.5 * 1/60th of a second to generate.  Since games often wait to switch in their newly drawn frame until during the one of the television’s 60 vertical blanks (pauses between screen redraws) per second, if you can draw frames in 0.99 1/60ths of a second then you get 60fps but if it takes you 1.01 1/60ths of a second then you get 30fps.
  • Of the “1.5″ update interval, Slag code was taking about 2/3 of the time and actual Wii graphic drawing was taking up the other third.

I plugged some numbers in and realized that if I could make Slag go 50% faster, that should bring the frame time down to 1.0 or less – a worthy goal.  I then started a project to make an ETC-to-CPP cross compiler that reads in compiled Slag ETC bytecode and spits out C++ source code.

I estimated it would take me 3-4 days.  It ended up taking me 11, which just proves that the old maxim is correct and programmers should always multiply their best guess time estimates by 3 – or by pi, as I understand some do.

It’s been an epic battle.  My epic battle, let me tell you it.

Read the rest of this entry »