experimental/ai_smart_aim.s

Download file

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

1    .ifndef WITH_FRIENDLY_RECEPTION2    .equ WITH_FRIENDLY_RECEPTION,03    .endif4 .equ FINISH_GAP,165 .equ AIM_CLEAR,166 .equ AIM_IMPROVE,87| Hard CPU chooses among existing native targets; height and physics stay native.8| +0 actual C30C hook, +4 catch opening, +8 pure target policy (D0/D1/D2).9| No persistent RAM, arbitrary RNG calls, physical or player-attribute writes.10 .text11 .globl _start12_start:13 bra.w shot_hook14 bra.w opening15 bra.w policy1617shot_hook:18 jsr 0xC566                       | exact original aim, including human/special paths19 move.w %sr,-(%sp)20 movem.l %d0-%d7/%a0-%a6,-(%sp)21 bsr.w policy22 tst.w %d023 beq.s hook_restore24 cmp.w 0xFFFFBEDC,%d125 beq.s hook_restore26 move.w %d1,0xFFFFBEDC27 move.w %d1,2(%sp)                | native D0 aim result, preserving its upper word28hook_restore:29 movem.l (%sp)+,%d0-%d7/%a0-%a630 move.w (%sp)+,%ccr31 move.w #5,-(%sp)                 | displaced C310; NOT a helper return address32 jmp 0xC3143334opening:35 .if WITH_CATCH_OPENING36 movem.l %d1-%d7/%a0-%a6,-(%sp)37 move.w 0xFFFFBEDC,-(%sp)38 bsr.w guard                      | do not execute special-mode aim from this probe39 tst.w %d040 .if WITH_FRIENDLY_RECEPTION41 bne.s opening_eligible42 jsr 0x225808                     | a real owned nativeB24 friendly catch may finish43 tst.w %d044 beq.s opening_no45opening_eligible:46 .else47 beq.s opening_no48 .endif49 jsr 0xC56650 .if WITH_FRIENDLY_RECEPTION51 bsr.w policy_opening52 .else53 bsr.w policy54 .endif55 tst.w %d056 beq.s opening_no57 cmpi.w #FINISH_GAP,%d258 blo.s opening_no59 moveq #1,%d060 bra.s opening_restore61opening_no:62 moveq #0,%d063opening_restore:64 move.w (%sp)+,0xFFFFBEDC65 movem.l (%sp)+,%d1-%d7/%a0-%a666 rts67 .else68 moveq #0,%d069 rts70 .endif7172| One genuine CPU shot may already have its native windup animation locked.73| Eligibility is separately adapted per club by the benchmark (this CMP only).74guard:75 moveq #0,%d076 cmpi.w #1,0xFFFFF07A77 bne.w guard_done78 btst #3,0x62(%a3)79 bne.w guard_done80 btst #2,0x63(%a3)81 bne.w guard_done82 tst.w 0x34(%a3)83 ble.w guard_done84 btst #5,0x62(%a3)85 beq.s guard_context86 cmpi.w #0x7FC,0x58(%a3)87 beq.s guard_context88 cmpi.w #0x92E,0x58(%a3)89 bne.w guard_done90guard_context:91 btst #0,0xFFFFC2EA92 bne.w guard_done93 btst #4,0xFFFFC2EA94 bne.w guard_done95 btst #7,0xFFFFC2EC96 bne.w guard_done97 btst #7,0xFFFFC2EE98 bne.w guard_done99 btst #2,0xFFFFC2F2100 bne.w guard_done101 move.b 0xFFFFC2FA,%d0102 andi.w #5,%d0103 bne.s guard_no104 move.w 0xFFFFF738,%d0105 subi.w #0xA502,%d0106 cmpi.w #5,%d0107 bcs.s guard_no                    | native automatic replay can have C2EC bit7 clear108 move.w 0xFFFFB7AA,%d0109 cmpi.w #11,%d0110 bhi.s guard_no111 cmp.w 0x52(%a3),%d0112 bne.s guard_no113 moveq #1,%d0114 rts115guard_no:116 moveq #0,%d0117guard_done:118 rts119120| Native BEDC input; D0 eligible, D1 selected index, D2 selected ray separation.121| D3-D7/A0-A6 preserved. 7FFF means no keeper between puck and goal line.122 .if WITH_FRIENDLY_RECEPTION123| This entry is used ONLY by the catch-opening probe. The general shot target124| policy retains its original busy exclusions. A real owned friendly B24 catch125| may use exactly the same native rays and minimum opening as an ordinary catch.126policy_opening:127 link.w %a6,#-24128 movem.l %d3-%d7/%a0-%a5,-(%sp)129 moveq #0,%d1130 move.w 0xFFFFBEDC,%d1131 move.w #0x7FFF,%d2132 cmpi.w #8,%d1133 bhi.w policy_no134 bsr.w guard135 tst.w %d0136 bne.s policy_geometry137 jsr 0x225808138 tst.w %d0139 beq.w policy_no140 bra.s policy_geometry141 .endif142policy:143 link.w %a6,#-24144 movem.l %d3-%d7/%a0-%a5,-(%sp)145 moveq #0,%d1146 move.w 0xFFFFBEDC,%d1147 move.w #0x7FFF,%d2148 cmpi.w #8,%d1149 bhi.w policy_no150 bsr.w guard151 tst.w %d0152 beq.w policy_no153policy_geometry:154 move.w 0xFFFFB74A,-2(%a6)155 move.w 0xFFFFB75E,%d3156 btst #7,0x62(%a3)157 bne.s puck_depth158 neg.w %d3159puck_depth:160 move.w %d3,-4(%a6)161 cmpi.w #264,%d3162 bge.w behind_goal163 cmpi.w #88,%d3164 blt.w policy_yes                 | retain native clears outside attacking policy165 move.w #264,%d4166 sub.w %d3,%d4167 move.w %d4,-6(%a6)168 move.w %d1,%d3169 lsl.w #2,%d3170 lea 0xC542,%a0171 move.w 2(%a0,%d3.w),-16(%a6)      | keep the actual native chosen shot height172 lea 0xFFFFB04A,%a0173 cmpi.w #6,0x52(%a3)174 bcc.s keeper_base175 adda.w #768,%a0176keeper_base:177 moveq #5,%d7178keeper_scan:179 tst.w 0x34(%a0)180 bne.s keeper_next181 btst #2,0x63(%a0)182 bne.s keeper_next183 moveq #0,%d3184 move.b 0x28(%a0),%d3185 ext.w %d3186 asr.w #1,%d3187 add.w (%a0),%d3188 move.w %d3,-8(%a6)189 moveq #0,%d4190 move.b 0x2A(%a0),%d4191 ext.w %d4192 asr.w #1,%d4193 add.w 0x14(%a0),%d4194 btst #7,0x62(%a3)195 bne.s keeper_depth196 neg.w %d4197keeper_depth:198 sub.w -4(%a6),%d4199 ble.w policy_yes200 cmp.w -6(%a6),%d4201 bhi.w policy_yes202 move.w %d4,-10(%a6)203 bra.s evaluate204keeper_next:205 adda.w #128,%a0206 dbra %d7,keeper_scan207 bra.w policy_yes208evaluate:209 move.w %d1,%d3210 lsl.w #2,%d3211 lea 0xC542,%a0212 move.w (%a0,%d3.w),%d3213 bsr.w ray_gap214 move.w %d3,%d2                  | actual native target's current opening215 move.w %d2,%d6                  | best target, retaining native on ties216 move.w %d1,%d7217 moveq #-16,%d5218 moveq #1,%d4219post:220 move.w %d5,%d3221 bsr.w ray_gap222 cmpi.w #AIM_CLEAR,%d3223 blt.s post_next224 cmp.w %d6,%d3225 ble.s post_next226 move.w %d3,%d6227 moveq #3,%d7                    | right low native target228 tst.w %d5229 bpl.s post_height230 moveq #5,%d7                    | left low native target231post_height:232 cmpi.w #6,-16(%a6)233 bne.s post_high234 moveq #2,%d7235 tst.w %d5236 bpl.s post_next237 moveq #6,%d7238 bra.s post_next239post_high:240 cmpi.w #12,-16(%a6)241 bne.s post_next242 moveq #1,%d7243 tst.w %d5244 bpl.s post_next245 moveq #7,%d7246post_next:247 neg.w %d5248 dbra %d4,post249 move.w %d2,%d3250 addi.w #AIM_IMPROVE,%d3251 cmp.w %d3,%d6252 blt.s policy_yes253 move.w %d7,%d1254 move.w %d6,%d2255policy_yes:256 moveq #1,%d0257 bra.s policy_return258behind_goal:259 moveq #0,%d2260 bra.s policy_yes261policy_no:262 moveq #0,%d0263policy_return:264 movem.l (%sp)+,%d3-%d7/%a0-%a5265 unlk %a6266 rts267268ray_gap:269 sub.w -2(%a6),%d3270 muls.w -10(%a6),%d3271 divs.w -6(%a6),%d3272 add.w -2(%a6),%d3273 sub.w -8(%a6),%d3274 bpl.s gap_return275 neg.w %d3276gap_return:277 rts278