Fragments like this are so simple and elegant.

It checks the high bit of $9801 and sets the base address of the stepper table in HL.
So one table at $3289 for one direction, and another at $3293 for the other direction. To save a couple of bytes, they overlapped the tables a little bit.


Then we get the current phase at $C007, and look up the next phase with LDAX (HL+A).
We save a copy in B, write the new phase to $C007.
The we look up another phase, wait a couple of cycles and write that phase and return.

so if we're at phase 1, the next will be 5

if we are at 5 the next will be 4

Starting at 1, this will generate the sequence 1 5 4 6 2 A 8 9 1... and backwards for the other direction which matches the sequence for NOT_A_REEL in steppers.cpp.


No comments:
Post a Comment