Look up table takes about 3-8 cycles to grab. Since multiply by 5 and dividing by 9 isn't power of 2s, it has to add the variable 5 times, and then subtract it 9 times to get the percentage, which takes a lot more CPU cycles. I'm not sure if it can do the math in 1 frame without interrupting or slowing down the game play, it's possible to process upon demand instead of being called every frame. Making and typing in a look up table would take time without tools to automate it.

It's closer to 16 cycles for a table lookup, if the index is already in a register.

Multiplying by 5 is around 20 cycles (again if the index is in a register). Dividing by 9 generates a loop in IntyBASIC, and that cost is proportional to the number being divided, so it can be rather expensive. Still, for the range 0 - 900, it would iterate no more than 100 times, so the cost would be around 1500 - 1600 cycles (about 1/9th of a frame time). There's more than enough time to do it.

I would personally use a lookup table here, especially since the number is now known to be 162 rather than 180. For anything but the shortest lookup tables, I nearly always write a script or program in some other language to generate the lookup table. You could use Perl, Python, shell-script, Lua, C, C++, or whatever other language you know that can compute the values and print them out.

Or, if you really want to stay in IntyBASIC, it can compute the values for you.

.

PctCvt:
DATA 0 * 50 / 81
DATA 1 * 50 / 81
DATA 2 * 50 / 81
' ... a bunch more lines
DATA 161 * 50 / 81
DATA 162 * 50 / 81

.

Or, if you don't mind a slight approximation, this should be pretty fast:

.

pct = (squares * 5) / 8

.

That actually computes the percent relative to 160 rather than 162. But, you'd probably never notice, since it's impossible to capture all 162 squares, correct?