Note that the ^ operator performs a modulo operation (modulo is remainder after division). If you keep your direction values as 0,1,2,3 instead of 1,2,3,4, it will be much more optimal. You will want to use rand^64 and rand^96 to get an int on [0,63] and [0,95], respectively (remember, this is not BASIC, so you have that extra row and column). As well, in assembly, ^64 is much more optimised, being only a few bytes and a handful of cycles. This is because 64 is a power of 2, and so 63=%00111111 which is a nice mask for using AND logic. Your code for changing direction is correct, but it might be able to be optimised. If you put the *2 after the pxl-Test(), Axe can optimise that to a 1-byte, 11 cycle instruction, instead of including a general purpose multiplication routine (saving you maybe 20 bytes and a few hundred t-states in all).

Also, by using the direction as 0,1,2,3, you can fix C by just using ^4 instead of checking if C is out of bounds. Finally, you need an End statement for every If in Axe (and there is no need to use 'Then'). Here is my rendition :

```
.LANGTON
rand^64→A
rand^96→B
rand^4→C
Repeat getKey
pxl-Test(A,B)*2+3+C and 3→C ;-1 = +3 modulo 4, so this keeps it an 8-bit number, making ' and 3' more optimised than ^4
Pxl-Change(A,B)
DispGraph
!If C
If A-1→A=-1
95→A
End
End
If C=1
B+1 and 63→B
End
If C=2
If A+1→A=96
0→A
End
End
If C=3
B+63 and 63→B
End
End
```

Also, you control when the LCD gets updated, so you need to include the DispGraph to draw the graph screen to the LCD. This alone makes graphics faster than in TI-BASIC :P