| ST shifted compiled-sprite walker (NATIVE-PERF Phase 1).
|
| One shared routine serves all 14 sub-byte sprite phases: the emitted
| per-phase thunk (spriteEmitInterleaved68k.c) loads groupBase into a0,
| points a1 at its pre-shifted data table, loads the row / group loop
| counts into d0/d1, and jmp's here. The data table holds, per 16-px
| group per row, three big-endian longs:
|   notMask  = ~M16 : ~M16    (same mask for all four plane words)
|   bits01   = bp0  : bp1     (pre-shifted OR bits, planes 0..1)
|   bits23   = bp2  : bp3     (planes 2..3)
| The walker RMWs each group's four interleaved plane words with two
| movem.l transfers -- addressing is linear (stride 8) at group
| granularity, which is what lets one routine serve every phase where
| byte-granular displacement patterns could not.
|
| Register ABI (private -- reached only from emitted thunks):
|   a0 = groupBase (base + y*160 + (x>>4)*8; even -- movem-safe)
|   a1 = data table
|   d0.w = rows - 1
|   d1.w = groupsPerRow - 1
| The thunk jmp's (not jsr's), so sp still holds the dispatcher's
| return address and the final rts returns straight to C. d0/d1/a0/a1
| are cdecl scratch; d3-d6/a2 are callee-save and preserved here.
|
| GAS m68k syntax, assembled by m68k-atari-mint-as. ST-only: this file
| must stay in src/atarist/ (src/m68k/*.s is wildcarded into the Amiga
| build too).

                .text

                .globl  _stSpriteDrawShiftWalker

_stSpriteDrawShiftWalker:
                movem.l %d3-%d6/%a2,-(%sp)
.LswRow:
                movea.l %a0,%a2                | a2 = this row's first group
                move.w  %d1,%d3                | d3 = groupsPerRow - 1
.LswGrp:
                movem.l (%a2),%d4-%d5          | d4 = p0w:p1w, d5 = p2w:p3w
                move.l  (%a1)+,%d6             | notMask long
                and.l   %d6,%d4
                and.l   %d6,%d5
                or.l    (%a1)+,%d4             | bits01
                or.l    (%a1)+,%d5             | bits23
                movem.l %d4-%d5,(%a2)
                addq.l  #8,%a2                 | next group
                dbra    %d3,.LswGrp
                lea     160(%a0),%a0           | ST_BYTES_PER_ROW
                dbra    %d0,.LswRow
                movem.l (%sp)+,%d3-%d6/%a2
                rts
