| Atari ST audio ISR -- MFP Timer A drives per-sample PWM output via
| the YM2149 channel-A volume register.
|
| Each interrupt:
|   1. Reads one byte from the libxmp-lite mix buffer.
|   2. Writes its high 4 bits to YM register 8 (channel A volume) so
|      the analog filter on the YM output emits a 4-bit-resolution
|      sample for that tick.
|   3. Advances the play pointer; raises a refill flag when crossing
|      the midpoint or end of the buffer; wraps at the end.
|   4. Acks the MFP Timer-A bit in ISRA and RTEs.
|
| Communication with the C HAL is via four globals defined in audio.c:
|   _gMixBuf       -- start of the mix buffer (uint8_t array)
|   _gMixPos       -- volatile pointer to the next sample to play
|   _gMixMid       -- end of first half (used to detect mid-cross)
|   _gMixEnd       -- end of buffer (used to detect wrap)
|   _gNeedRefill   -- two-byte array; ISR writes 1 to mark a half stale
|
| GAS-syntax (binutils m68k); assembled by m68k-atari-mint-as via the
| gcc driver.

                .text
                .globl  _mfpTimerAIsr

                .equ    YM_SELECT, 0xFFFF8800
                .equ    YM_DATA,   0xFFFF8802
                .equ    MFP_ISRA,  0xFFFFFA0F

_mfpTimerAIsr:
                movem.l %d0/%a0,-(%sp)

                move.l  _gMixPos,%a0
                move.b  (%a0)+,%d0
                lsr.b   #4,%d0
                and.w   #0x0F,%d0

                move.b  #8,YM_SELECT
                move.b  %d0,YM_DATA

                cmp.l   _gMixMid,%a0
                bne.s   1f
                move.b  #1,_gNeedRefill+0
1:
                cmp.l   _gMixEnd,%a0
                blt.s   2f
                move.b  #1,_gNeedRefill+1
                lea     _gMixBuf,%a0
2:
                move.l  %a0,_gMixPos

                move.b  #0xDF,MFP_ISRA

                movem.l (%sp)+,%d0/%a0
                rte
