Jump to content

OLD CS1

+AtariAge Subscriber
  • Content Count

    8,693
  • Joined

  • Days Won

    5

Blog Comments posted by OLD CS1


  1. Putting some thought into the conversions of X and Y from {-4,0,4} in each to {0..4}, the original formula was developed a long time ago and I just left it since it works. Nonetheless, the duplicate calls to SGN() in each conversion has nagged me. I have been sick the past couple of days and last night, in a bout of physical exhaustion and boredom, I had a go at it.

    ABS(((SGN(X)+3)/2)*SGN(X))+(ABS(((SGN(Y)+3)/2)*SGN(Y))-2*(Y<>0))

    can be optimized as

    (ABS(X)/2+(X<0))+(ABS(Y)+(Y<0))

    Each conversion is 6 seconds faster per 500 iterations in TI BASIC, and 12 seconds for both together over the same period, roughly a considerable 2.4 seconds faster per 100 iterations.  This winds up being noticeable and makes the joystick feel almost as responsive as the keyboard.

     

    Breaking down each direction, the original X conversion calls three functions, two of which are duplicate, three maths, in three priorities.  The new conversion calls one function, two maths, one comparison in two priorities.  The original Y conversion calls one additional math over X, while the new conversion calls one less math than the new X.  I do not have a list on-hand of the speed of each function or mathematical operation in TI BASIC so I have no literals to provide, just the anecdotal execution results.

    • Like 1
×
×
  • Create New...