experimental/coach_lines.s

Download file

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

1| CPU Hard coach chooses a stronger first forward unit from its existing normal2| lines. A temporary cache supplies BOTH native personnel and energy lookups;3| original lineups, saved profiles, attributes and native fatigue remain intact.4 .text5 .globl _start6_start:7 bra.w personnel8 bra.w energy9personnel:10 movem.l %d0-%d7/%a0/%a2-%a6,-(%sp)11 move.w 0x16(%a2),%d012 bsr.w prepare13 movem.l (%sp)+,%d0-%d7/%a0/%a2-%a614 move.w 0x16(%a2),%d015 jmp 0x1585416energy:17 movem.l %d0-%d7/%a0/%a2-%a6,-(%sp)18 bsr.w prepare19 movem.l (%sp)+,%d0-%d7/%a0/%a2-%a620 asl.w #3,%d021 jmp 0x12EBE22prepare:23 lea 0x16A(%a2),%a124 cmpi.w #2,%d025 bhi.w prepare_done26 cmpa.w #0xC6CE,%a227 beq.w home_team28 cmpa.w #0xCA32,%a229 bne.w prepare_done30 moveq #2,%d231 lea 0xFFFFF520,%a532 bra.w team_ready33home_team:34 moveq #1,%d235 lea 0xFFFFF500,%a536team_ready:37 cmpi.w #1,0xFFFFF07A38 bne.w prepare_done39 btst #0,0xFFFFC2FA40 bne.w prepare_done41 btst #2,0xFFFFC2FA42 bne.w prepare_done43 btst #2,0xFFFFC2F244 bne.w prepare_done45 lea 0xFFFFC328,%a046 moveq #3,%d147human_scan:48 cmp.w (%a0)+,%d249 beq.w prepare_done50 dbra %d1,human_scan51 move.l 0x1E(%a2),%d052 cmpi.l #0x200,%d053 blo.w prepare_done54 cmpi.l #0x300000,%d055 bhs.w prepare_done56 | Keep a private24-byte copy; never rewrite the game's own line arrays.57 movea.l %a1,%a058 movea.l %a5,%a459 moveq #5,%d060copy_lines:61 move.l (%a0)+,(%a4)+62 dbra %d0,copy_lines63 link.w %a6,#-1664 clr.l -4(%a6)65 clr.w -6(%a6)66 moveq #0,%d767choose_slot:68 moveq #-1,%d5                    | best score69 moveq #0,%d6                     | best one-based roster ID70 moveq #0,%d4                     | line0..271scan_line:72 moveq #3,%d3                     | forward positions3..573scan_forward:74 move.w %d4,%d075 lsl.w #3,%d076 add.w %d3,%d077 moveq #0,%d278 move.b (%a5,%d0.w),%d279 beq.w scan_next80 cmpi.w #26,%d281 bhi.w scan_next82 cmp.w -2(%a6),%d283 beq.w scan_next84 cmp.w -4(%a6),%d285 beq.w scan_next86 cmp.w -6(%a6),%d287 beq.w scan_next88 move.w %d2,%d089 subq.w #1,%d090 add.w %d0,%d091 move.w 0x66(%a2,%d0.w),%d192 cmpi.w #-3,%d193 beq.w scan_next94 cmpi.w #-4,%d195 beq.w scan_next96 tst.w %d197 bgt.w scan_next98 bsr.w score_forward99 cmp.w %d5,%d0100 ble.w scan_next101 move.w %d0,%d5102 move.w %d2,%d6103 move.w %d1,-8(%a6)              | handedness of best candidate104scan_next:105 addq.w #1,%d3106 cmpi.w #5,%d3107 bls.w scan_forward108 addq.w #1,%d4109 cmpi.w #2,%d4110 bls.w scan_line111 tst.w %d6112 beq.w no_three113 move.w %d7,%d0114 add.w %d0,%d0115 neg.w %d0116 move.w %d6,-2(%a6,%d0.w)117 moveq #4,%d3                    | strongest forward at centre118 tst.w %d7119 beq.w selected_slot120 cmpi.w #1,%d7121 bne.w remaining_wing122 moveq #5,%d3                    | left shooter on the right for a one-timer123 tst.w -8(%a6)124 beq.w wing_chosen125 moveq #3,%d3126wing_chosen:127 move.w %d3,-10(%a6)128 bra.w selected_slot129remaining_wing:130 moveq #8,%d3131 sub.w -10(%a6),%d3132selected_slot:133 moveq #0,%d2134 move.b (%a5,%d3.w),%d2          | displaced first-line player135 cmp.w %d2,%d6136 beq.w slot_done137 | Swap the two real roster IDs across all3normal lines. This keeps the other138 | units valid and lets the existing native energy/bench rules rotate players.139 moveq #0,%d4140swap_line:141 moveq #3,%d3142swap_forward:143 move.w %d4,%d0144 lsl.w #3,%d0145 add.w %d3,%d0146 move.b (%a5,%d0.w),%d1147 cmp.b %d2,%d1148 bne.w swap_selected149 move.b %d6,(%a5,%d0.w)150 bra.w swap_next151swap_selected:152 cmp.b %d6,%d1153 bne.w swap_next154 move.b %d2,(%a5,%d0.w)155swap_next:156 addq.w #1,%d3157 cmpi.w #5,%d3158 bls.w swap_forward159 addq.w #1,%d4160 cmpi.w #2,%d4161 bls.w swap_line162slot_done:163 addq.w #1,%d7164 cmpi.w #3,%d7165 blo.w choose_slot166 unlk %a6167 movea.l %a5,%a1168 rts169no_three:170 unlk %a6171 lea 0x16A(%a2),%a1172prepare_done:173 rts174175| D2 = one-based real roster ID. Returns D0 score,D1 handedness; preserves176| every other working register. No attribute/energy/RNG writes.177score_forward:178 movem.l %d2-%d7/%a0,-(%sp)179 .if WITH_TRANSFERS180 jsr 0x23600C181 beq.s score_forward_original182 move.w 0x28(%a2),%d0183 move.w %d2,%d1184 subq.w #1,%d1185 jsr 0x236008186 bra.w attributes187score_forward_original:188 .endif189 movea.l 0x1E(%a2),%a0190 adda.w (%a0),%a0191 move.w %d2,%d0192 subq.w #1,%d0193 beq.w attributes194skip_record:195 adda.w (%a0),%a0196 addq.w #8,%a0197 subq.w #1,%d0198 bne.w skip_record199attributes:200 adda.w (%a0),%a0201 moveq #0,%d0202 move.b 1(%a0),%d0203 andi.w #15,%d0                  | native leg power204 moveq #0,%d1205 move.b 2(%a0),%d1206 move.w %d1,%d2207 andi.w #15,%d2208 add.w %d2,%d2                  |2*offensive awareness209 add.w %d2,%d0210 lsr.w #4,%d1211 mulu.w #3,%d1                  |3*speed212 add.w %d1,%d0213 moveq #0,%d1214 move.b 3(%a0),%d1215 andi.w #15,%d1216 add.w %d1,%d1                  |2*shot power217 add.w %d1,%d0218 moveq #0,%d1219 move.b 5(%a0),%d1220 move.w %d1,%d2221 andi.w #15,%d2222 mulu.w #3,%d2                  |3*shot accuracy223 add.w %d2,%d0224 lsr.w #4,%d1225 add.w %d1,%d0                  |stick handling226 moveq #0,%d1227 move.b 7(%a0),%d1228 lsr.w #4,%d1229 add.w %d1,%d0                  |passing230 moveq #0,%d1231 move.b 4(%a0),%d1232 andi.w #1,%d1233 movem.l (%sp)+,%d2-%d7/%a0234 rts235