| A critical release makes only the puck alternate red/normal, four frames each.
| Native sprite geometry, flips, priority, physics and shadow remain unchanged.
    .equ ACTIVE,0xFFF060             | visible-render lifetime, at most 127 frames
    .equ RED,0xFFF062                | last rendered phase; cache invalidation on changes
    .equ RED_TILES,0x2FFE00
    .text
    .globl _start
_start:
    bra.w begin_shot
    bra.w critical
    bra.w pickup
    bra.w frame
    bra.w tiles
    bra.w sprite

begin_shot:
    clr.w ACTIVE
    moveq #0,%d1                    | displaced critical.s instructions
    move.b 0x66(%a3),%d1
    rts
critical:
    move.w #127,ACTIVE              | first four visible frames are red
    move.w 0xFFBEDE,%d0             | displaced critical.s instruction
    rts
pickup:
    clr.w ACTIVE                    | called only after the blue-line pickup gate accepts
    bclr #0,0x62(%a2)               | displaced instruction, preserves its Z result
    rts

frame:
    move.w 6(%a3),%d0
    andi.w #0x7FF,%d0
    cmpa.w #0xB74A,%a3
    bne.s cached
    move.l %d1,-(%sp)
    btst #0,0xFFC2FA                | shootout: the clock-stop flag is always set there, so only
    bne.s 1f                        | possession ends it (2026-10-26b: crits had no red/flames)
    btst #0,0xFFC2EA                | native dead-puck/clock-stop flag (C3F4 is a penalty report)
    bne.s stop
1:
    tst.w 0xFFB7AA                  | owner < 0 means loose; any possession ends the effect
    bpl.s stop
    move.w ACTIVE,%d1
    beq.s normal
    subq.w #1,ACTIVE
    btst #2,%d1
    beq.s normal
    moveq #1,%d1
    bra.s phase
stop:
    clr.w ACTIVE
normal:
    moveq #0,%d1
phase:
    cmp.w RED,%d1
    beq.s same
    move.w %d1,RED
    move.w #-1,8(%a3)               | reload pixels when changing colour, even for the same frame
same:
    move.l (%sp)+,%d1
cached:
    jmp 0x16800                     | original native frame-cache comparison

tiles:
    addi.l #0x5DE84,%d2             | displaced native DMA source computation
    cmpa.w #0xB74A,%a3
    bne.s original_tiles
    tst.w RED
    beq.s original_tiles
    cmpi.l #0x7C324,%d2             | eight contiguous native puck tiles, $F25..$F2C
    bcs.s original_tiles
    cmpi.l #0x7C424,%d2
    bcc.s original_tiles
    addi.l #RED_TILES-0x7C324,%d2    | same geometry and transfer size, red pixel-index copies
original_tiles:
    rts

sprite:
    or.b 0xA(%a3,%d5.w),%d2        | displaced native tile-slot and priority computation
    add.w 0x12(%a3),%d2
    cmpa.w #0xB74A,%a3
    bne.s original_sprite
    tst.w RED
    beq.s original_sprite
    andi.w #0x9FFF,%d2              | keep flips/priority/tile index
    ori.w #0x2000,%d2               | fixed rink palette 1: index A is pure red since r11
original_sprite:
    rts
