experimental/ai_attack.s

Download file

Release 2026-11-04-r2 · SHA256 23acc7598baad4e3adfee95b5fc49b96050d372a3d06fd6f031899b78e0bd61e · Click a line number for a direct link.

1| Hard attack: puck-relative forward support, select a free improved receiver,2| and defer bad-angle shots when such a receiver exists. Native pass/shot physics.3    .ifndef WITH_AI_PLAYBOOK4    .equ WITH_AI_PLAYBOOK,15    .endif6    .text7    .globl _start8_start:9    bra.w support10    bra.w passpick11    bra.w shotgate1213| Common live CPU skater guard. Returns D0=1 eligible, 0 otherwise.14| No persistent RAM; inputs/registers besides D0 preserved.15guard:16    moveq #0,%d017    cmpi.w #1,0xFFFFF07A18    bne.s guard_done19    btst #3,0x62(%a3)20    bne.s guard_done21    btst #5,0x62(%a3)22    bne.s guard_done23    btst #2,0x63(%a3)24    bne.s guard_done25    btst #0,0xFFFFC2EA26    bne.s guard_done27    btst #7,0xFFFFC2EC28    bne.s guard_done29    btst #2,0xFFFFC2F230    bne.s guard_done31    btst #0,0xFFFFC2FA32    bne.s guard_done33    btst #7,0xFFFFC2EE            | native offside signal34    bne.s guard_done35    tst.w 0x34(%a3)36    ble.s guard_done37    moveq #1,%d038guard_done:39    rts4041support:42    lea 0xE594,%a0               | displaced EvadePC callback43    movem.l %d0/%d2-%d7/%a1-%a2,-(%sp)44    bsr.w guard45    tst.w %d046    beq.w support_native47    .if WITH_PASS_CONTINUITY48    bsr.w flight_owner49    .else50    move.w 0xFFFFB7AA,%d251    .endif52    cmpi.w #11,%d253    bhi.w support_native54    cmp.w 0x52(%a3),%d255    beq.w support_native56    move.w 0x52(%a3),%d357    subi.w #6,%d258    subi.w #6,%d359    eor.w %d3,%d260    bmi.w support_native61    cmpi.w #3,0x34(%a3)62    blt.w support_native63    cmpi.w #5,0x34(%a3)64    bgt.w support_native65    move.w 0xFFFFB75E,%d366    btst #7,0x62(%a3)67    bne.s support_depth68    neg.w %d369support_depth:70    cmpi.w #112,%d371    blt.w support_native72    cmpi.w #292,%d373    bgt.w support_native74    move.w 0xFFFFB74A,%d475    cmpi.w #4,0x34(%a3)76    beq.s center77    moveq #1,%d5                 | wing side in world X, from native target78    move.l (%sp),%d279    tst.w %d280    bpl.s wing_side81    moveq #-1,%d582wing_side:83    move.w %d4,%d284    muls.w %d5,%d285    cmpi.w #32,%d286    bgt.s strong_wing87    moveq #44,%d6                | far-side finisher88    addi.w #24,%d389    move.w #184,%d290    move.w #236,%d791    bra.s wing_xy92strong_wing:93    moveq #90,%d6                | same-side return outlet, behind the carrier94    subi.w #40,%d395    move.w #128,%d296    move.w #198,%d797wing_xy:98    muls.w %d5,%d699    bra.s clamp_depth100center:101    moveq #16,%d6102    tst.w %d4103    bmi.s center_depth104    neg.w %d6105center_depth:106    subi.w #12,%d3107    move.w #172,%d2108    move.w #218,%d7109clamp_depth:110    cmp.w %d2,%d3111    bge.s max_depth112    move.w %d2,%d3113max_depth:114    cmp.w %d7,%d3115    ble.s occupancy116    move.w %d7,%d3117occupancy:118    lea 0xFFFFB04A,%a1119    cmpi.w #6,0x52(%a3)120    bcc.s opp_ready121    adda.w #768,%a1122opp_ready:123    .if WITH_REAL_ACTORS124    moveq #5,%d7125    .else126    moveq #4,%d7127    .endif128occupant:129    tst.w 0x34(%a1)130    ble.s next_occupant131    btst #2,0x63(%a1)132    bne.s next_occupant133    move.w (%a1),%d2134    sub.w %d6,%d2135    cmpi.w #-28,%d2136    blt.s next_occupant137    cmpi.w #28,%d2138    bgt.s next_occupant139    move.w 0x14(%a1),%d2140    btst #7,0x62(%a3)141    bne.s occupant_depth142    neg.w %d2143occupant_depth:144    sub.w %d3,%d2145    cmpi.w #-28,%d2146    blt.s next_occupant147    cmpi.w #28,%d2148    bgt.s next_occupant149    subi.w #28,%d3                | drop into a return lane rather than stand marked150    cmpi.w #4,0x34(%a3)151    beq.s support_apply152    moveq #24,%d2153    muls.w %d5,%d2154    add.w %d2,%d6155    bra.s support_apply156next_occupant:157    adda.w #128,%a1158    dbra %d7,occupant159support_apply:160    move.w %d6,%d0161    move.w %d3,%d1162    btst #7,0x62(%a3)163    bne.s support_store164    neg.w %d1165support_store:166    move.l %d0,(%sp)              | return adjusted D0 through saved slot167support_native:168    movem.l (%sp)+,%d0/%d2-%d7/%a1-%a2169    jmp 0x103C8170171| Returns relative teammate slot in D0 or -1. Other registers preserved.172| Local stack contains geometry, score and best index; scan only five skaters.173findreceiver:174    link.w %a6,#-32175    movem.l %d1-%d7/%a0-%a5,-(%sp)176    move.w #-1,-8(%a6)177    bsr.w guard178    tst.w %d0179    beq.w find_done180    btst #1,0x64(%a3)              | keep native breakaway decisions181    bne.w find_done182    move.w 0x52(%a3),%d0183    cmp.w 0xFFFFB7AA,%d0184    bne.w find_done185    move.w 0xFFFFB75E,%d1186    btst #7,0x62(%a3)187    bne.s find_depth188    neg.w %d1189find_depth:190    .if WITH_AI_PLAYBOOK191    cmpi.w #88,%d1192    .else193    cmpi.w #112,%d1194    .endif195    blt.w find_done196    cmpi.w #292,%d1197    bgt.w find_done198    move.w %d1,-2(%a6)199    move.w 0xFFFFB74A,%d2200    bpl.s carrier_abs201    neg.w %d2202carrier_abs:203    add.w %d2,%d2204    subi.w #224,%d1205    bpl.s carrier_cost206    neg.w %d1207carrier_cost:208    add.w %d1,%d2209    move.w %d2,-4(%a6)210    move.w #0x7FFF,-6(%a6)211    lea 0xFFFFB04A,%a4212    lea 0xFFFFB34A,%a5213    cmpi.w #6,0x52(%a3)214    bcs.s own_ready215    exg %a4,%a5216own_ready:217    movea.l %a4,%a0218    .if WITH_REAL_ACTORS219    moveq #5,%d6220    .else221    moveq #4,%d6222    .endif223candidate:224    cmpa.l %a3,%a0225    beq.w next_candidate226    tst.w 0x34(%a0)227    ble.w next_candidate228    btst #2,0x63(%a0)229    bne.w next_candidate230    btst #5,0x62(%a0)231    bne.w next_candidate232    move.w 0x14(%a0),%d1233    btst #7,0x62(%a3)234    bne.s receiver_depth235    neg.w %d1236receiver_depth:237    cmpi.w #112,%d1238    blt.w next_candidate239    cmpi.w #252,%d1240    bgt.w next_candidate241    move.w (%a0),%d2242    bpl.s receiver_abs243    neg.w %d2244receiver_abs:245    cmpi.w #140,%d2246    bgt.w next_candidate247    add.w %d2,%d2248    subi.w #224,%d1249    bpl.s receiver_cost250    neg.w %d1251receiver_cost:252    add.w %d1,%d2253    move.w %d2,-20(%a6)254    addi.w #24,%d2255    cmp.w -4(%a6),%d2256    bgt.w next_candidate257    move.w (%a0),%d1258    sub.w 0xFFFFB74A,%d1259    move.w %d1,-10(%a6)260    bpl.s abs_dx261    neg.w %d1262abs_dx:263    move.w 0x14(%a0),%d2264    sub.w 0xFFFFB75E,%d2265    move.w %d2,-12(%a6)266    bpl.s abs_dy267    neg.w %d2268abs_dy:269    add.w %d1,%d2270    cmpi.w #32,%d2271    blt.w next_candidate272    cmpi.w #200,%d2273    bgt.w next_candidate274    move.w %d2,%d3275    lsr.w #2,%d3276    add.w %d3,-20(%a6)277    move.w -20(%a6),%d3278    cmp.w -6(%a6),%d3279    bge.w next_candidate280    mulu.w #12,%d2281    move.w %d2,-18(%a6)282    move.w -10(%a6),%d1283    muls.w %d1,%d1284    move.w -12(%a6),%d2285    muls.w %d2,%d2286    add.l %d1,%d2287    move.l %d2,-16(%a6)288    movea.l %a5,%a1289    moveq #5,%d7290opponent:291    tst.w 0x34(%a1)292    bmi.w next_opponent293    btst #2,0x63(%a1)294    bne.w next_opponent295    move.w (%a1),%d1296    sub.w (%a0),%d1297    muls.w %d1,%d1298    move.w 0x14(%a1),%d2299    sub.w 0x14(%a0),%d2300    muls.w %d2,%d2301    add.l %d1,%d2302    cmpi.l #676,%d2303    blt.w next_candidate           | marked receiver304    move.w (%a1),%d1305    sub.w 0xFFFFB74A,%d1306    move.w 0x14(%a1),%d2307    sub.w 0xFFFFB75E,%d2308    move.w %d1,%d3309    muls.w -10(%a6),%d3310    move.w %d2,%d4311    muls.w -12(%a6),%d4312    add.l %d4,%d3                 | projection along the pass segment313    ble.s next_opponent314    cmp.l -16(%a6),%d3315    bge.s next_opponent316    muls.w -12(%a6),%d1317    muls.w -10(%a6),%d2318    sub.l %d2,%d1319    bpl.s cross_abs320    neg.l %d1321cross_abs:322    moveq #0,%d2323    move.w -18(%a6),%d2324    cmp.l %d2,%d1325    ble.w next_candidate         | opponent in a conservative pass corridor326next_opponent:327    adda.w #128,%a1328    dbra %d7,opponent329    move.w -20(%a6),-6(%a6)330    move.w 0x52(%a0),%d1331    cmpi.w #6,%d1332    bcs.s store_receiver333    subq.w #6,%d1334store_receiver:335    move.w %d1,-8(%a6)336next_candidate:337    adda.w #128,%a0338    dbra %d6,candidate339find_done:340    moveq #-1,%d0341    move.w -8(%a6),%d0342    movem.l (%sp)+,%d1-%d7/%a0-%a5343    unlk %a6344    rts345346passpick:347    bsr.w findreceiver348    tst.w %d0349    bpl.s pass_return350    moveq #6,%d0351    jmp 0x11086                  | displaced native random teammate choice352pass_return:353    rts354355shotgate:356    movem.l %d0-%d2,-(%sp)357    .if WITH_AI_PLAYBOOK358    jsr 0x2DD004359    tst.w %d0360    beq.s regular_shotgate361    movem.l (%sp)+,%d0-%d2362    jmp 0xE412                   | native shot assignment and stack unwind363regular_shotgate:364    .endif365    move.w 0xFFFFB74A,%d0366    bpl.s shot_abs367    neg.w %d0368shot_abs:369    cmpi.w #88,%d0370    ble.s native_shot371    move.w 0xFFFFB75E,%d1372    btst #7,0x62(%a3)373    bne.s shot_depth374    neg.w %d1375shot_depth:376    cmpi.w #152,%d1377    blt.s native_shot378    cmpi.w #264,%d1379    bge.s native_shot380    bsr.w findreceiver381    tst.w %d0382    bmi.s native_shot383    movem.l (%sp)+,%d0-%d2384    rts                          | bad-angle shot deferred: caller considers pass/skates385native_shot:386    movem.l (%sp)+,%d0-%d2387    jsr 0xE264                   | displaced chkpk / BNE .pkill388    bne.s native_pk389    jmp 0xE298390native_pk:391    jmp 0xE2E4392393    .if WITH_PASS_CONTINUITY394flight_owner:395    jsr 0x2DD680396    rts397    .endif398