Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Friday, June 14, 2013

ZX81 numeric printing

I'd read that the ZX81 print routine for floating-point numbers (ie all numbers) was slow, but I didn't realise how slow till I used the very good VB81 emulator to compare a 1-to-100 FOR loop which (a) uses PRINT to print each number, (b) uses a subroutine to calculate the digits and print them as characters, or (c) calls the ROM routine at 0A98 to print numbers between 0 and 9999.

Timings per iteration:
(a) 460 ms
(b) 280 ms
(c) 100 ms

That includes the loop mechanism and various extra BASIC code, but it's interesting to see that the standard number routine is considerably slower than a BASIC subroutine with a lot of division and multiplication, and far slower than the dedicated ROM routine.

Separate handling for integers would have speeded ZX BASIC up no end.

I wish I'd known about the routine at 0A98 at the time, it would have been dead useful for showing scores in machine code games. I only found out about it this week after re-reading Understanding Your ZX81 ROM which I found up in my loft.

Update: The 0A98 routine explains why Electric Pencil's Asteroids game crashed when your score got to 99990. Pity, because otherwise it was the best ZX81 Asteroids implementation by miles.

Followers

Blog Archive