experimental/ai_playbook.s

Download file

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

1    .ifndef WITH_FRIENDLY_RECEPTION2    .equ WITH_FRIENDLY_RECEPTION,03    .endif4    .ifndef WITH_FINISH_POSITION5    .equ WITH_FINISH_POSITION,06    .endif7| Hard: one native nearest chaser, open point shots, deliberate one-timer spots.8| No persistent RAM. Native assignments, skating, passes and shots execute actions.9    .ifndef WITH_AI_FREECROSS10    .equ WITH_AI_FREECROSS,011    .endif12    .text13    .globl _start14_start:15    bra.w pressure16    bra.w pointshot17    bra.w reception18    bra.w receive_skate19    bra.w frame20    .if WITH_AI_FREECROSS21    bra.w finish_ready22    bra.w clearlane23    .endif2425guard:26    moveq #0,%d027    cmpi.w #1,0xFFFFF07A28    bne.s guard_done29    btst #3,0x62(%a3)30    bne.s guard_done31    btst #5,0x62(%a3)32    bne.s guard_done33    btst #2,0x63(%a3)34    bne.s guard_done35    tst.w 0x34(%a3)36    ble.s guard_done37    btst #0,0xFFFFC2EA38    bne.s guard_done39    .if WITH_PASS_PLAN40    btst #4,0xFFFFC2EA41    bne.s guard_done42    .endif43    btst #7,0xFFFFC2EC44    bne.s guard_done45    btst #7,0xFFFFC2EE46    bne.s guard_done47    btst #2,0xFFFFC2F248    bne.s guard_done49    move.b 0xFFFFC2FA,%d050    andi.w #5,%d051    bne.s guard_no52    moveq #1,%d053    rts54guard_no:55    moveq #0,%d056guard_done:57    rts5859pressure:60    movem.l %d0/%d2-%d3,-(%sp)61    bsr.w guard62    tst.w %d063    beq.s pressure_native64    .if WITH_PASS_CONTINUITY65    bsr.w flight_owner66    .else67    move.w 0xFFFFB7AA,%d268    .endif69    cmpi.w #11,%d270    bhi.s pressure_native71    move.w 0x52(%a3),%d372    subi.w #6,%d273    subi.w #6,%d374    eor.w %d3,%d275    bpl.s pressure_native76    movem.l (%sp)+,%d0/%d2-%d377    move.w 0xFFFFB74A,%d078    move.w 0xFFFFB75E,%d179    jmp 0xEA0480pressure_native:81    movem.l (%sp)+,%d0/%d2-%d382    btst #2,0x30(%a2)83    beq.s pressure_plain84    jmp 0xE9DE85pressure_plain:86    jmp 0xEA048788| A3's clear shooting lane to goal centre. Exclude goalies, boxed/unavailable.89| D0 boolean; every other register preserved. Conservative 12-unit corridor.90clearlane:91    movem.l %d1-%d7/%a0,-(%sp)92    moveq #0,%d093    move.w 0x14(%a3),%d694    btst #7,0x62(%a3)95    bne.s lane_depth96    neg.w %d697lane_depth:98    move.w #264,%d599    sub.w %d6,%d5                  | positive distance toward attacking goal100    ble.w lane_done101    lea 0xFFFFB04A,%a0102    cmpi.w #6,0x52(%a3)103    bcc.s lane_base104    adda.w #768,%a0105lane_base:106    .if WITH_AI_FREECROSS107    moveq #5,%d7                   | all real actors; keepers may change object slot108    .else109    moveq #4,%d7110    .endif111lane_opponent:112    tst.w 0x34(%a0)113    ble.s lane_next114    btst #2,0x63(%a0)115    bne.s lane_next116    move.w 0x14(%a0),%d2117    btst #7,0x62(%a3)118    bne.s lane_opp_depth119    neg.w %d2120lane_opp_depth:121    sub.w %d6,%d2122    bmi.s lane_next123    cmp.w %d5,%d2124    bge.s lane_next125    move.w (%a0),%d1126    sub.w (%a3),%d1127    muls.w %d5,%d1128    muls.w (%a3),%d2129    add.l %d2,%d1                  | cross with (-actorX, goalDepth-actorDepth)130    bpl.s lane_abs131    neg.l %d1132lane_abs:133    move.w (%a3),%d3134    bpl.s lane_width135    neg.w %d3136lane_width:137    add.w %d5,%d3138    mulu.w #12,%d3139    cmp.l %d3,%d1140    ble.s lane_done141lane_next:142    adda.w #128,%a0143    dbra %d7,lane_opponent144    moveq #1,%d0145lane_done:146    movem.l (%sp)+,%d1-%d7/%a0147    rts148149pointshot:150    movem.l %d1-%d2,-(%sp)151    bsr.w guard152    tst.w %d0153    beq.s point_done154    moveq #0,%d0155    btst #1,0x64(%a3)156    bne.s point_done157    move.w 0x52(%a3),%d1158    cmp.w 0xFFFFB7AA,%d1159    bne.s point_done160    move.w 0x14(%a3),%d1161    btst #7,0x62(%a3)162    bne.s point_depth163    neg.w %d1164point_depth:165    cmpi.w #88,%d1166    blt.s point_done167    cmpi.w #144,%d1168    bgt.s point_done169    move.w (%a3),%d2170    bpl.s point_abs171    neg.w %d2172point_abs:173    cmpi.w #100,%d2174    bgt.s point_done175    bsr.w clearlane176    tst.w %d0177    beq.s point_done178    moveq #4,%d0                   | one in four eligible native decision checks179    jsr 0x11086180    tst.w %d0181    seq %d0182    andi.w #1,%d0183point_done:184    movem.l (%sp)+,%d1-%d2185    rts186187| Native receiver used to wind up from anywhere beyond blue. Let point/wide188| receivers catch and relay; finishers arm a native catch-and-release shot.189reception:190    cmpi.w #1,0xFFFFF07A191    bne.w reception_native192    bsr.w guard193    tst.w %d0194    beq.s reception_native195    move.b #64,0x40(%a3)            | wait for a native catch, then relay/finish196    bsr.w finish_ready197    tst.w %d0198    beq.s reception_return199    move.w #0x5042,0xFFFFF086200    move.w 0x52(%a3),%d0201    addq.w #1,%d0202    move.w %d0,0xFFFFF088203    move.w #64,0xFFFFF08A204reception_return:205    moveq #0,%d0                   | CPU keeps skating until the pass arrives206    rts207reception_native:208    jmp 0xF6C44209210| Free finishing position; D0 boolean, other registers preserved.211finish_ready:212    movem.l %d1-%d2,-(%sp)213    bsr.w guard214    tst.w %d0215    beq.s ready_done216    moveq #0,%d0217    move.w 0x14(%a3),%d1218    btst #7,0x62(%a3)219    bne.s ready_depth220    neg.w %d1221ready_depth:222    cmpi.w #160,%d1223    blt.s ready_done224    cmpi.w #252,%d1225    bgt.s ready_done226    move.w (%a3),%d2227    bpl.s ready_abs228    neg.w %d2229ready_abs:230    cmpi.w #92,%d2231    bgt.s ready_done232    bsr.w clearlane233ready_done:234    movem.l (%sp)+,%d1-%d2235    rts236237| Catch-and-relay receivers track the incoming puck with native steering.238receive_skate:239    movem.l %d0-%d7/%a0-%a3,-(%sp)240    bsr.w guard241    tst.w %d0242    .if WITH_FINISH_HOLD243    beq.w receive_tick244    .else245    beq.s receive_tick246    .endif247    tst.w 0xFFFFB7AA248    .if WITH_FINISH_HOLD249    bpl.w receive_tick250    .else251    bpl.s receive_tick252    .endif253    move.w 0x52(%a3),%d0254    cmp.w 0xFFFFBEE0,%d0255    .if WITH_FINISH_HOLD256    bne.w receive_tick257    .else258    bne.s receive_tick259    .endif260    .if WITH_FINISH_HOLD261    | Keep an armed, free finisher in his slot while the pass approaches.262    | Track point/wide receivers, expired buffers, blocked slots and missed passes.263    cmpi.w #0x5042,0xFFFFF086264    bne.s receive_track265    tst.w 0xFFFFF08A266    ble.s receive_track267    addq.w #1,%d0268    cmp.w 0xFFFFF088,%d0269    bne.s receive_track270    move.w 0xFFFFB74A,%d0271    sub.w (%a3),%d0272    move.w 0xFFFFB75E,%d1273    sub.w 0x14(%a3),%d1274    move.w %d0,%d2275    bpl.s receiver_dx276    neg.w %d2277receiver_dx:278    move.w %d1,%d3279    bpl.s receiver_dy280    neg.w %d3281receiver_dy:282    add.w %d3,%d2283    cmpi.w #64,%d2284    .if WITH_FINISH_POSITION285    bls.w receive_close             | actual near reception uses a fresh native target286    .else287    bls.s receive_track288    .endif289    muls.w 0xFFFFB772,%d0290    muls.w 0xFFFFB774,%d1291    add.l %d1,%d0292    bpl.s receive_track293    bsr.w finish_ready294    tst.w %d0295    .if WITH_FINISH_POSITION296    beq.s receive_track297    jsr 0x225000                  | native steer toward actual pass-course interception298    tst.w %d0299    bne.s receive_tick300    .else301    bne.s receive_tick302    .endif303    .endif304    .if WITH_FINISH_POSITION305    bra.s receive_track306receive_close:307    bsr.w finish_ready308    tst.w %d0309    beq.s receive_track310    jsr 0x225004311    tst.w %d0312    bne.s receive_tick313    .endif314receive_track:315    jsr 0x105A2316receive_tick:317    movem.l (%sp)+,%d0-%d7/%a0-%a3318    sub.b %d7,0x40(%a3)319    bpl.s receive_wait320    jmp 0xEC68321receive_wait:322    jmp 0x15464323324| Once per rendered frame, same native catch-and-release path as human buffer.325| Transient F086 magic, F088 object+1, F08A TTL. Never stored in saves.326frame:327    .if WITH_PASS_PLAN328    jsr 0x2DF804329    .endif330    cmpi.w #0x5042,0xFFFFF086331    bne.w frame_empty332    movem.l %d0-%d7/%a0-%a6,-(%sp)333    subq.w #1,0xFFFFF08A334    bmi.w frame_clear335    move.w 0xFFFFF088,%d0336    subq.w #1,%d0337    cmpi.w #11,%d0338    bhi.w frame_clear339    move.w %d0,%d7340    lsl.w #7,%d0341    lea 0xFFFFB04A,%a3342    adda.w %d0,%a3343    .if WITH_FRIENDLY_RECEPTION344    jsr 0x225800345    .else346    bsr.w guard347    .endif348    tst.w %d0349    beq.w frame_clear350    cmp.w 0xFFFFB7AA,%d7351    beq.s frame_caught352    tst.w 0xFFFFB7AA353    bpl.s frame_clear354    cmp.w 0xFFFFBEE0,%d7355    bne.s frame_clear356    bra.s frame_done357frame_caught:358    .if WITH_FRIENDLY_RECEPTION359    jsr 0x225804360    .else361    bsr.w finish_ready362    .endif363    tst.w %d0364    beq.s frame_clear365    .if WITH_CATCH_OPENING366    jsr 0x2DF004367    tst.w %d0368    beq.s frame_clear369    .endif370    clr.l 0xFFFFF086371    clr.w 0xFFFFF08A372    .if WITH_AI_FREECROSS373| A buffered catch can release before FF5A observes the new native owner.374| Run that same possession bookkeeping first: real scorer/assist chain,375| last-possession coordinates and native zone state, without touching counters.376    movea.l %a3,%a2377    jsr 0x1013E378    .endif379    bset #3,0x64(%a3)380    move.w #0x7FC,%d1381    jsr 0x1073A382    jsr 0xC2F2383    bclr #3,0x64(%a3)384    bra.s frame_done385frame_clear:386    clr.l 0xFFFFF086387    clr.w 0xFFFFF08A388frame_done:389    movem.l (%sp)+,%d0-%d7/%a0-%a6390frame_empty:391    rts392393    .if WITH_PASS_CONTINUITY394flight_owner:395    jsr 0x2DD680396    rts397    .endif398