| AI weak-side winger covers the low slot / a far-side receiver on deep rushes.
| Hook D086 replaces LEA CF98(pc),A0 / MOVE.W puckx,D2. Inputs D0/D1 are the
| native wing target; A3 is the skater. All guards fall back to the native target.
| No new RAM, ratings, RNG, speed/shot/goalkeeper changes or player-control writes.
    .text
    .globl _start
_start:
    lea 0xCF98,%a0
    movem.l %d2-%d7/%a1-%a2,-(%sp)
    cmpi.w #1,0xFFFFF07A               | Hard only; Normal/Easy keep native positioning
    bne.w done
    btst #3,0x62(%a3)                 | never steer a human-controlled skater
    bne.w done
    btst #5,0x62(%a3)
    bne.w done
    btst #2,0x63(%a3)
    bne.w done
    btst #0,0xFFFFC2EA                | no decisions through whistles
    bne.w done
    btst #7,0xFFFFC2EC                | no replay/menu view intervention
    bne.w done
    btst #2,0xFFFFC2FA                | no penalty-shot/shootout intervention
    bne.w done
    cmpi.w #3,0x34(%a3)
    beq.s winger
    cmpi.w #5,0x34(%a3)
    bne.w done
winger:
    .if WITH_PASS_CONTINUITY
    bsr.w flight_owner
    .else
    move.w 0xFFFFB7AA,%d2
    .endif
    cmpi.w #11,%d2
    bhi.w done                        | loose/invalid puck
    move.w 0x52(%a3),%d3
    cmpi.w #6,%d3
    bcc.s visitor
    cmpi.w #6,%d2
    bcs.w done                        | teammate carries
    lea 0xFFFFB34A,%a1
    bra.s opponent
visitor:
    cmpi.w #6,%d2
    bcc.w done
    lea 0xFFFFB04A,%a1
opponent:
    move.w %d0,%d6                    | native wing-side sign in world coordinates
    move.w 0xFFFFB74A,%d3
    move.w %d3,%d4
    bpl.s positive_x
    neg.w %d4
positive_x:
    cmpi.w #56,%d4
    bcs.w done                        | puck near middle: keep native shape
    cmpi.w #144,%d4
    bhi.w done                        | out-of-rink puck
    eor.w %d6,%d3
    bpl.w done                        | puck-side winger keeps the native job
    move.w 0xFFFFB75E,%d3
    btst #7,0x62(%a3)
    bne.s depth
    neg.w %d3
 depth:
    cmpi.w #-160,%d3
    bgt.w done
    cmpi.w #-296,%d3
    blt.w done
    moveq #32,%d0                     | no marked threat: compact weak-post support
    tst.w %d6
    bpl.s side_ready
    neg.w %d0
side_ready:
    move.w #-216,%d1
    move.w #0x7FFF,%d5
    .if WITH_REAL_ACTORS
    moveq #5,%d7
    .else
    moveq #4,%d7
    .endif
scan:
    tst.w 0x34(%a1)
    ble.w next                        | boxed/empty players and goalies are not threats
    btst #2,0x63(%a1)
    bne.w next
    move.w 0x52(%a1),%d2
    cmp.w 0xFFFFB7AA,%d2
    beq.w next                        | never duplicate pressure on the carrier
    move.w (%a1),%d2
    move.w %d2,%d4
    bpl.s abs_x
    neg.w %d4
abs_x:
    cmpi.w #16,%d4
    bcs.w next
    cmpi.w #88,%d4
    bhi.w next
    move.w %d2,%d4
    eor.w %d6,%d4
    bmi.w next                        | only far-side receivers
    move.w 0x14(%a1),%d3
    btst #7,0x62(%a3)
    bne.s threat_depth
    neg.w %d3
threat_depth:
    cmpi.w #-150,%d3
    bgt.w next
    cmpi.w #-260,%d3
    blt.w next
    move.w 0x28(%a1),%d4
    asr.w #8,%d4
    asr.w #1,%d4                      | short look-ahead from actual skater velocity
    add.w %d4,%d2
    move.w 0x2A(%a1),%d4
    asr.w #8,%d4
    asr.w #1,%d4
    btst #7,0x62(%a3)
    bne.s velocity_depth
    neg.w %d4
velocity_depth:
    add.w %d4,%d3
    move.w %d3,%d4
    addi.w #224,%d4
    bpl.s abs_depth
    neg.w %d4
abs_depth:
    add.w %d4,%d4
    tst.w %d2
    bpl.s cost_x
    neg.w %d2
    add.w %d2,%d4
    neg.w %d2
    bra.s compare
cost_x:
    add.w %d2,%d4
compare:
    cmp.w %d5,%d4
    bcc.s next
    move.w %d4,%d5
    move.w %d2,%d0
    move.w %d2,%d4
    asr.w #2,%d4
    sub.w %d4,%d0                     | stand inside the receiver's passing lane
    tst.w %d6
    bmi.s clamp_left
    cmpi.w #16,%d0
    bge.s right_max
    moveq #16,%d0
right_max:
    cmpi.w #64,%d0
    ble.s target_y
    moveq #64,%d0
    bra.s target_y
clamp_left:
    cmpi.w #-16,%d0
    ble.s left_min
    moveq #-16,%d0
left_min:
    cmpi.w #-64,%d0
    bge.s target_y
    moveq #-64,%d0
 target_y:
    move.w %d3,%d1
    subi.w #12,%d1                    | goal-side of the predicted receiver
    cmpi.w #-180,%d1
    ble.s y_min
    move.w #-180,%d1
 y_min:
    cmpi.w #-236,%d1
    bge.s next
    move.w #-236,%d1
next:
    adda.w #128,%a1
    dbra %d7,scan
    btst #7,0x62(%a3)
    bne.s done
    neg.w %d1                        | native world direction at the other end
 done:
    movem.l (%sp)+,%d2-%d7/%a1-%a2
    move.w 0xFFFFB74A,%d2             | displaced native instruction
    rts

    .if WITH_PASS_CONTINUITY
flight_owner:
    jsr 0x2DD680
    rts
    .endif
