; > MouseTable

        GET     Hdr.Macros8051
        GET     Hdr.SFRs
        GET     Hdr.Hardware

        GBLA    index
        GBLA    refo
        GBLA    diro
        GBLA    refn
        GBLA    dirn
        GBLA    val

        MACRO
        MouseTable      $oref, $odir, $nref, $ndir, $val0, $val1, $val2, $val3
index   SETA    0
        LCLA    ooref
        LCLA    oodir
        LCLA    nnref
        LCLA    nndir
        [ MouseHiNibble
ooref   SETA    $nref
oodir   SETA    $ndir
nnref   SETA    $oref
nndir   SETA    $odir
        |
ooref   SETA    $oref
oodir   SETA    $odir
nnref   SETA    $nref
nndir   SETA    $ndir
        ]

        WHILE   index < &100
refo    SETA    (index :SHR: $ooref) :AND: 1
diro    SETA    ((index :SHR: $oodir) :AND: 1) :EOR: refo
refn    SETA    (index :SHR: $nnref) :AND: 1
dirn    SETA    ((index :SHR: $nndir) :AND: 1) :EOR: refn

val     SETA    ((dirn+refn*2)-(diro+refo*2)):AND:3
        [ val=0
val     SETA    $val0
        |
        [ val=1
val     SETA    $val1
        |
        [ val=2
val     SETA    $val2
        |
        ASSERT  val=3
val     SETA    $val3
        ]
        ]
        ]
        [ (index :AND: 3)=0
        =       10, "        =       &"
        |
        =       ", &"
        ]
        =       :STR:((val*2):AND:&FF)
index   SETA    index +1
        WEND
        =       10, 10
        MEND

        =       "; > adfs::NorthWeald.Asm8051.Obj.MouseTable", 10, 10
        =       "; This 'source' file is generated by assembling", 10
        =       "; 'adfs::NorthWeald.Asm8051.MouseTable'", 10, 10

        [ MouseHiNibble
        =       " [ :LNOT: MouseHiNibble", 10
        |
        =       " [ MouseHiNibble", 10
        ]
        =       " ! 1, ""Please re-assemble file 'MouseTable'""", 10
        =       " ]", 10, 10

        =       "XTablesBase", 10

; X table when previous direction was 0

        MouseTable      4, 6, 0, 2, 0, 1, 0, -1

; X table when previous direction was -ve

        MouseTable      4, 6, 0, 2, 0, 1, -2, -1

; X table when previous direction was +ve

        MouseTable      4, 6, 0, 2, 0, 1, 2, -1

        =        "YTablesBase", 10

; Y table when previous direction was 0

        MouseTable      5, 7, 1, 3, 0, 1, 0, -1

; Y table when previous direction was -ve

        MouseTable      5, 7, 1, 3, 0, 1, -2, -1

; Y table when previous direction was +ve

        MouseTable      5, 7, 1, 3, 0, 1, 2, -1

        =       "        END", 10

        END
