STOS Scramble Port #1: STOS CODE Optimizations

By Jeff D. Fulton

Yesterday I posted this video to youtube. It’s a progress report on my Atari ST port of the Arcade game Scramble to the ST using STOS.

In the video I list a two optimizations I found to speed up code and rendering, especially in the interpreter, I didn’t give details on them. In this post I will explain details of what learned doing progress report #1.

STOS Scramble Port Progress #1

Static Pointer to varptr variables in the many bob command.
The many bob commands in the Tutorial #3 looked something like this:

many bob logic,start(6),varptr(IMAGE(0)),varptr(XBOB(0)),varptr(YBOB(0)),varptr(STATUS(0)),0,0,21,0

A better way to do this is to replace3 thise dynamic varptr look ups with a static variable like this:

VIMAGE=varptr(IMAGE(0))
VXBOB=varptr(XBOB(0))
VYBOB=varptr(YBOB(0))
VSTATUS=varptr(STATUS(0))
many bob logic,s6,VIMAGE,VXBOB,VYBOB,VSTATUS,0,0,21,0

This especially helps by increasing out throughput by adding 6 FPS in the interpreter and also does help for at least 1 FPS in the compiled version. We must ensure to have the absolute tightest code possible in the interpreted version to have any hope of making and arcade game that will fun at 25FPS in the compiled version.

Use “many add” to remove costly loops
Aside from Many bob and many joey, there are other “many” commands in missing link.
I was able to replace the entire set of loops that update and calculate new positions of tiles like this:

for CTR=0 to 20
dec XBOB(CTR):dec XBOB(CTR):dec XBOB(CTR):dec XBOB(CTR)
if XBOB(CTR) <-16 then XBOB(CTR)=315: rem 319 minus the speed
dec XJOE(CTR):dec XJOE(CTR):dec XJOE(CTR):dec XJOE(CTR)
if XJOE(CTR) <-16 then XJOE(CTR)=315: rem 319 minus the speed

next CTR 

With these simple lines:

VXBOB=varptr(XBOB(0))
many add VXBOB,-4,21,-16,315

VXJOE=varptr(XJOE(0))
many add VXJOE,-4,21,-16,315

This helped bring the interpreter up to 17FPS


Until next time…Into the Vertical Blank!

Find us here:

Youtube

Into the Vertical Blank: Generation Atari | Facebook

Into The Vertical Blank Pod Cast – Twitter

Leave a Reply