experimental/shot_plan.s

Download file

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

1    .ifndef WITH_REFINEMENTS2    .equ WITH_REFINEMENTS,03    .endif4    .ifndef WITH_PLAN_AIM_HINTS5    .equ WITH_PLAN_AIM_HINTS,16    .endif7    .equ PLAN_AIM_CLEAR,168    .equ PLAN_AIM_IMPROVE,89| Optional Hard CPU shot plan. Native pass/carry/assignment/physics remain active.10| Only own option F810 and bounded transient F840..F847 are written.11    .equ VALUE,0xFFFFF81012    .equ MAGIC,0xFFFFF84013    .equ ACTOR,0xFFFFF84214    .equ AGE,0xFFFFF84415    .equ SIDE,0xFFFFF84616    .equ LIMIT,9617    .text18    .globl _start19_start:20    bra.w commit21    bra.w target22    bra.w decide23    bra.w geometry24    bra.w load25    bra.w put26    bra.w reset27    bra.w clear2829| D0 boolean. Internal scratch D1/D2/A0; callers preserve their full contracts.30guard:31    moveq #0,%d032    cmpi.w #1,VALUE33    bne.w guard_done34    cmpi.w #1,0xFFFFF07A35    bne.w guard_done36    btst #3,0x62(%a3)37    bne.w guard_done38    btst #5,0x62(%a3)39    bne.w guard_done40    move.b 0x63(%a3),%d141    andi.b #5,%d142    bne.w guard_done43    tst.w 0x34(%a3)44    ble.w guard_done45    cmpi.w #5,0x34(%a3)46    bhi.w guard_done47    move.b 0xFFFFC2EA,%d148    andi.b #0x51,%d149    bne.w guard_done50    move.b 0xFFFFC2EC,%d151    andi.b #0x81,%d152    bne.w guard_done53    btst #7,0xFFFFC2EE54    bne.w guard_done55    btst #2,0xFFFFC2F256    bne.w guard_done57    move.b 0xFFFFC2FA,%d158    andi.b #5,%d159    bne.w guard_done60    tst.w 0xFFFFD41261    bne.w guard_done62    move.w 0xFFFFF738,%d163    subi.w #0xA502,%d164    cmpi.w #5,%d165    bcs.w guard_done66    move.w 0x52(%a3),%d167    cmpi.w #11,%d168    bhi.w guard_done69    cmp.w 0xFFFFB7AA,%d170    bne.w guard_done71    lea 0xFFFFC328,%a072    moveq #3,%d273human_pad:74    tst.w (%a0)75    beq.s next_pad76    cmp.w -8(%a0),%d177    beq.s guard_done78next_pad:79    addq.w #2,%a080    dbra %d2,human_pad81    moveq #1,%d082guard_done:83    rts8485| D0=1 only for a covered ordinary attacking shot in the weak middle distance.86| All other GPR/SP, incoming X/IRQ and native BEDC are preserved; no RNG/writes.87geometry:88    move.w %sr,-(%sp)89    movem.l %d1-%d7/%a0-%a6,-(%sp)90    move.w 0xFFFFBEDC,-(%sp)91    bsr.w guard92    tst.w %d093    beq.w geometry_no94    btst #1,0x64(%a3)95    bne.w geometry_no96    btst #3,0x64(%a3)97    bne.w geometry_no             | existing native one-timer/buffered paths remain responsible98    move.w 0xFFFFB75E,%d599    btst #7,0x62(%a3)100    bne.s normalized101    neg.w %d5102normalized:103    cmpi.w #88,%d5104    blt.w geometry_no             | native defensive/neutral clearances remain available105    cmpi.w #264,%d5106    bge.w geometry_no107    move.w 0xFFFFB74A,%d4108    cmpi.w #-160,%d4109    blt.w geometry_no110    cmpi.w #160,%d4111    bgt.w geometry_no112    jsr 0xC566                    | actual native aim; restored before returning113    bsr.w plan_oracle_policy      | local exact native-target geometry, available in legacy ablations114    tst.w %d0115    beq.w geometry_no116    cmpi.w #8,%d1117    bhi.w geometry_no118    cmpi.w #16,%d2119    bcc.w geometry_no             | genuine keeper openings/empty nets retain native shots120    move.w 0xFFFFB75E,%d5        | recompute after native C566; do not assume its scratch ABI121    btst #7,0x62(%a3)122    bne.s selected_depth123    neg.w %d5124selected_depth:125    lsl.w #2,%d1126    lea 0xC542,%a0127    move.w (%a0,%d1.w),%d0       | actual selected native target post X128    sub.w 0xFFFFB74A,%d0129    move.w #264,%d1130    sub.w %d5,%d1131    muls.w %d0,%d0132    muls.w %d1,%d1133    add.l %d1,%d0134    jsr 0x110BE                   | same native distance square-root as actual C3FC release135    cmpi.w #160,%d0136    bcc.s geometry_no137    cmpi.w #40,%d0138    bls.s geometry_no139    moveq #1,%d0140    bra.s geometry_restore141geometry_no:142    moveq #0,%d0143geometry_restore:144    move.w (%sp)+,0xFFFFBEDC145    movem.l (%sp)+,%d1-%d7/%a0-%a6146    move.w (%sp)+,%sr147    tst.w %d0148    rts149150| Pure decision. Bounded observations are counted only by actual target calls.151decide:152    move.w %sr,-(%sp)153    move.l %d1,-(%sp)154    bsr.w geometry155    tst.w %d0156    beq.s decided157    cmpi.w #0x4150,MAGIC158    bne.s decided159    move.w 0x52(%a3),%d1160    cmp.w ACTOR,%d1161    bne.s decided162    cmpi.w #1,SIDE163    beq.s age_check164    cmpi.w #-1,SIDE165    bne.s decided166age_check:167    cmpi.w #LIMIT,AGE168    bne.s decided169    moveq #0,%d0                 | native fallback remains latched for this observed owner170 decided:171    move.l (%sp)+,%d1172    move.w (%sp)+,%sr173    tst.w %d0174    rts175176| Actual native shot commitment, before its original caller-return discard.177commit:178    move.w %sr,-(%sp)179    cmpi.w #1,VALUE180    bne.s commit_fast181    movem.l %d0-%d7/%a0-%a6,-(%sp)182    bsr.w decide183    tst.w %d0184    bne.s decline185    movem.l (%sp)+,%d0-%d7/%a0-%a6186    move.w (%sp)+,%sr187    bra.s commit_native188decline:189    movem.l (%sp)+,%d0-%d7/%a0-%a6190    move.w (%sp)+,%sr191    rts                           | genuine original caller continues native pass/carry192commit_fast:193    move.w (%sp)+,%sr194commit_native:195    addq.w #4,%sp                 | displaced original E412196    move.w 0xFFFFB75E,%d0197    jmp 0xE418198199| D0=1 only if an actual available opposing SKATER is within24 of the carrier.200| Keeper role0 is excluded; native E12C still does movement/evasion itself.201pressure:202    lea 0xFFFFB04A,%a0203    cmpi.w #6,0x52(%a3)204    bcc.s pressure_base205    adda.w #768,%a0206pressure_base:207    moveq #5,%d7208pressure_next:209    tst.w 0x34(%a0)210    ble.s pressure_skip211    cmpi.w #5,0x34(%a0)212    bhi.s pressure_skip213    btst #2,0x63(%a0)214    bne.s pressure_skip215    move.w (%a0),%d3216    sub.w (%a3),%d3217    cmpi.w #-24,%d3218    blt.s pressure_skip219    cmpi.w #24,%d3220    bgt.s pressure_skip221    move.w 0x14(%a0),%d4222    sub.w 0x14(%a3),%d4223    cmpi.w #-24,%d4224    blt.s pressure_skip225    cmpi.w #24,%d4226    bgt.s pressure_skip227    muls.w %d3,%d3228    muls.w %d4,%d4229    add.l %d4,%d3230    cmpi.l #576,%d3231    bls.s pressured232pressure_skip:233    adda.w #128,%a0234    dbra %d7,pressure_next235    moveq #0,%d0236    rts237pressured:238    moveq #1,%d0239    rts240241| Actual carrier target boundary. Only D0/D1 lowwords may be overridden.242target:243    move.w %sr,-(%sp)244    cmpi.w #1,VALUE245    bne.w target_fast246    movem.l %d0-%d7/%a0-%a6,-(%sp)247    bsr.w guard248    tst.w %d0249    beq.w target_restore250    bsr.w geometry251    tst.w %d0252    bne.s plan_wanted253    bsr.w clear254    bra.w target_restore255plan_wanted:256    move.w 0x52(%a3),%d1257    cmpi.w #0x4150,MAGIC258    bne.s initialize259    cmp.w ACTOR,%d1260    bne.s initialize261    cmpi.w #LIMIT,AGE262    bhi.s initialize263    cmpi.w #1,SIDE264    beq.s observed265    cmpi.w #-1,SIDE266    beq.s observed267initialize:268    move.w #0x4150,MAGIC269    move.w %d1,ACTOR270    clr.w AGE271    move.w #1,SIDE272    tst.w (%a3)273    bpl.s observed274    move.w #-1,SIDE275observed:276    cmpi.w #LIMIT,AGE277    bcc.s target_restore278    addq.w #1,AGE279    cmpi.w #LIMIT,AGE280    bcc.s target_restore281    bsr.w pressure282    tst.w %d0283    bne.s target_restore284    move.w 0x14(%a3),%d2285    btst #7,0x62(%a3)286    bne.s carrier_depth287    neg.w %d2288carrier_depth:289    move.w #56,%d3290    move.w #220,%d4291    cmpi.w #216,%d2292    blt.s route_ready293    move.w #28,%d3294    move.w #248,%d4295route_ready:296    muls.w SIDE,%d3297    btst #7,0x62(%a3)298    bne.s route_world299    neg.w %d4300route_world:301    move.w %d3,2(%sp)             | D0 lowword in saved full-register frame302    move.w %d4,6(%sp)             | D1 lowword; native upperwords remain exact303target_restore:304    movem.l (%sp)+,%d0-%d7/%a0-%a6305target_fast:306    move.w (%sp)+,%sr307    lea 0xE12C,%a0                | displaced original PC-relative LEA, same callback308    btst #2,0xFFFFC2F2309    jmp 0xE116310311clear:312    move.w %sr,-(%sp)313    clr.l MAGIC314    clr.l MAGIC+4315    move.w (%sp)+,%sr316    rts317318record:319    lea 0x209A85,%a0              | native/Full/Light/Mini logical4D42..49320    tst.w 0xFFFFF06C321    beq.s record_done322    move.w 0xFFFFF06A,%d0323    subq.w #1,%d0324    cmpi.w #2,%d0325    bhi.s record_done326    addq.w #1,%d0327    lsl.w #2,%d0328    adda.w %d0,%a0329record_done:330    rts331load:332    move.w %sr,-(%sp)333    movem.l %d0-%d1/%a0,-(%sp)334    .if WITH_REFINEMENTS335    move.w #1,VALUE336    .else337    clr.w VALUE338    .endif339    bsr.w clear340    bsr.s record341    moveq #0,%d0342    move.b (%a0),%d0343    move.w %d0,%d1344    andi.w #0xFE,%d1345    cmpi.w #0x76,%d1346    bne.s loaded347    not.b %d0348    cmp.b 2(%a0),%d0349    bne.s loaded350    not.b %d0351    andi.w #1,%d0352    move.w %d0,VALUE353loaded:354    movem.l (%sp)+,%d0-%d1/%a0355    move.w (%sp)+,%sr356    rts357put:358    move.w %sr,-(%sp)359    movem.l %d0-%d1/%a0,-(%sp)360    bsr.w record361    moveq #0x76,%d0362    cmpi.w #1,VALUE363    bne.s write364    addq.w #1,%d0365write:366    move.b %d0,(%a0)367    not.b %d0368    move.b %d0,2(%a0)369    lea 0x208001,%a0370    moveq #0,%d0371    move.w #0x1FFD,%d1372sum:373    add.b (%a0),%d0374    addq.l #2,%a0375    dbra %d1,sum376    not.b %d0377    move.b %d0,(%a0)378    not.b %d0379    move.b %d0,2(%a0)380    movem.l (%sp)+,%d0-%d1/%a0381    move.w (%sp)+,%sr382    rts383reset:384    move.w %sr,-(%sp)385    move.w 0xFFFFF06C,-(%sp)386    move.w #1,0xFFFFF06C387    .if WITH_REFINEMENTS388    move.w #1,VALUE389    .else390    clr.w VALUE391    .endif392    bsr.w clear393    bsr.w put394    move.w (%sp)+,0xFFFFF06C395    move.w (%sp)+,%sr396    rts397398| Geometry copied from the accepted native-target policy, with every label local.399| When native smart aiming is explicitly ablated, keep its actual native post400| instead of evaluating a post that the release would never choose. This helper401| never depends on an optional module being present, and never writes its target.402plan_oracle_guard:403 moveq #0,%d0404 cmpi.w #1,0xFFFFF07A405 bne.w plan_oracle_guard_done406 btst #3,0x62(%a3)407 bne.w plan_oracle_guard_done408 btst #2,0x63(%a3)409 bne.w plan_oracle_guard_done410 tst.w 0x34(%a3)411 ble.w plan_oracle_guard_done412 btst #5,0x62(%a3)413 beq.s plan_oracle_guard_context414 cmpi.w #0x7FC,0x58(%a3)415 beq.s plan_oracle_guard_context416 cmpi.w #0x92E,0x58(%a3)417 bne.w plan_oracle_guard_done418plan_oracle_guard_context:419 btst #0,0xFFFFC2EA420 bne.w plan_oracle_guard_done421 btst #4,0xFFFFC2EA422 bne.w plan_oracle_guard_done423 btst #7,0xFFFFC2EC424 bne.w plan_oracle_guard_done425 btst #7,0xFFFFC2EE426 bne.w plan_oracle_guard_done427 btst #2,0xFFFFC2F2428 bne.w plan_oracle_guard_done429 move.b 0xFFFFC2FA,%d0430 andi.w #5,%d0431 bne.s plan_oracle_guard_no432 move.w 0xFFFFF738,%d0433 subi.w #0xA502,%d0434 cmpi.w #5,%d0435 bcs.s plan_oracle_guard_no                    | native automatic replay can have C2EC bit7 clear436 move.w 0xFFFFB7AA,%d0437 cmpi.w #11,%d0438 bhi.s plan_oracle_guard_no439 cmp.w 0x52(%a3),%d0440 bne.s plan_oracle_guard_no441 moveq #1,%d0442 rts443plan_oracle_guard_no:444 moveq #0,%d0445plan_oracle_guard_done:446 rts447448| Native BEDC input; D0 eligible, D1 selected index, D2 selected ray separation.449| D3-D7/A0-A6 preserved. 7FFF means no keeper between puck and goal line.450plan_oracle_policy:451 link.w %a6,#-24452 movem.l %d3-%d7/%a0-%a5,-(%sp)453 moveq #0,%d1454 move.w 0xFFFFBEDC,%d1455 move.w #0x7FFF,%d2456 cmpi.w #8,%d1457 bhi.w plan_oracle_policy_no458 bsr.w plan_oracle_guard459 tst.w %d0460 beq.w plan_oracle_policy_no461 move.w 0xFFFFB74A,-2(%a6)462 move.w 0xFFFFB75E,%d3463 btst #7,0x62(%a3)464 bne.s plan_oracle_puck_depth465 neg.w %d3466plan_oracle_puck_depth:467 move.w %d3,-4(%a6)468 cmpi.w #264,%d3469 bge.w plan_oracle_behind_goal470 cmpi.w #88,%d3471 blt.w plan_oracle_policy_yes                 | retain native clears outside attacking plan_oracle_policy472 move.w #264,%d4473 sub.w %d3,%d4474 move.w %d4,-6(%a6)475 move.w %d1,%d3476 lsl.w #2,%d3477 lea 0xC542,%a0478 move.w 2(%a0,%d3.w),-16(%a6)      | keep the actual native chosen shot height479 lea 0xFFFFB04A,%a0480 cmpi.w #6,0x52(%a3)481 bcc.s plan_oracle_keeper_base482 adda.w #768,%a0483plan_oracle_keeper_base:484 moveq #5,%d7485plan_oracle_keeper_scan:486 tst.w 0x34(%a0)487 bne.s plan_oracle_keeper_next488 btst #2,0x63(%a0)489 bne.s plan_oracle_keeper_next490 moveq #0,%d3491 move.b 0x28(%a0),%d3492 ext.w %d3493 asr.w #1,%d3494 add.w (%a0),%d3495 move.w %d3,-8(%a6)496 moveq #0,%d4497 move.b 0x2A(%a0),%d4498 ext.w %d4499 asr.w #1,%d4500 add.w 0x14(%a0),%d4501 btst #7,0x62(%a3)502 bne.s plan_oracle_keeper_depth503 neg.w %d4504plan_oracle_keeper_depth:505 sub.w -4(%a6),%d4506 ble.w plan_oracle_policy_yes507 cmp.w -6(%a6),%d4508 bhi.w plan_oracle_policy_yes509 move.w %d4,-10(%a6)510 bra.s plan_oracle_evaluate511plan_oracle_keeper_next:512 adda.w #128,%a0513 dbra %d7,plan_oracle_keeper_scan514 bra.w plan_oracle_policy_yes515plan_oracle_evaluate:516 move.w %d1,%d3517 lsl.w #2,%d3518 lea 0xC542,%a0519 move.w (%a0,%d3.w),%d3520 bsr.w plan_oracle_ray_gap521 move.w %d3,%d2                  | actual native target's current opening522 move.w %d2,%d6                  | best target, retaining native on ties523 move.w %d1,%d7524    .if WITH_PLAN_AIM_HINTS525 moveq #-16,%d5526 moveq #1,%d4527plan_oracle_post:528 move.w %d5,%d3529 bsr.w plan_oracle_ray_gap530 cmpi.w #PLAN_AIM_CLEAR,%d3531 blt.s plan_oracle_post_next532 cmp.w %d6,%d3533 ble.s plan_oracle_post_next534 move.w %d3,%d6535 moveq #3,%d7                    | right low native target536 tst.w %d5537 bpl.s plan_oracle_post_height538 moveq #5,%d7                    | left low native target539plan_oracle_post_height:540 cmpi.w #6,-16(%a6)541 bne.s plan_oracle_post_high542 moveq #2,%d7543 tst.w %d5544 bpl.s plan_oracle_post_next545 moveq #6,%d7546 bra.s plan_oracle_post_next547plan_oracle_post_high:548 cmpi.w #12,-16(%a6)549 bne.s plan_oracle_post_next550 moveq #1,%d7551 tst.w %d5552 bpl.s plan_oracle_post_next553 moveq #7,%d7554plan_oracle_post_next:555 neg.w %d5556 dbra %d4,plan_oracle_post557 move.w %d2,%d3558 addi.w #PLAN_AIM_IMPROVE,%d3559 cmp.w %d3,%d6560 blt.s plan_oracle_policy_yes561 move.w %d7,%d1562 move.w %d6,%d2563    .endif564plan_oracle_policy_yes:565 moveq #1,%d0566 bra.s plan_oracle_policy_return567plan_oracle_behind_goal:568 moveq #0,%d2569 bra.s plan_oracle_policy_yes570plan_oracle_policy_no:571 moveq #0,%d0572plan_oracle_policy_return:573 movem.l (%sp)+,%d3-%d7/%a0-%a5574 unlk %a6575 rts576577plan_oracle_ray_gap:578 sub.w -2(%a6),%d3579 muls.w -10(%a6),%d3580 divs.w -6(%a6),%d3581 add.w -2(%a6),%d3582 sub.w -8(%a6),%d3583 bpl.s plan_oracle_gap_return584 neg.w %d3585plan_oracle_gap_return:586 rts587