| Generate native seven editable8-byte lines from actual owned player slots.
| Four disjoint forward trios, three disjoint D pairs, best native-overall G.
| Prefer each natural LW/C/RW; generic F then other unused forwards may flex.
| Within a role use highest actual base overall, then earliest sorted slot.
| Extra skater comes from the otherwise unused fourth trio. No large RAM cache.
line_initializer:
    move.w %sr,-(%sp)
    movem.l %d0-%d7/%a0-%a6,-(%sp)
    bsr.w enabled
    beq.w line_original
    lea -40(%sp),%sp
    movea.l %sp,%a6
    clr.l (%a6)
    lea 0x16A(%a2),%a5
    move.w 0x28(%a2),%d7
    moveq #0,%d5
    moveq #1,%d6
line_forward:
    bsr.w best_line_slot
    tst.l %d0
    bmi.w line_failed
    move.b %d0,4(%a6,%d5.w)
    bsr.w use_line_slot
    addq.w #1,%d5
    addq.w #1,%d6
    cmpi.w #4,%d6
    blo.s line_forward_next
    moveq #1,%d6
line_forward_next:
    cmpi.w #12,%d5
    blo.s line_forward
    moveq #0,%d5
    moveq #5,%d6
line_defender:
    bsr.w best_line_slot
    tst.l %d0
    bmi.w line_failed
    move.b %d0,16(%a6,%d5.w)
    bsr.w use_line_slot
    addq.w #1,%d5
    cmpi.w #6,%d5
    blo.s line_defender
    moveq #0,%d6
    bsr.w best_line_slot
    tst.l %d0
    bmi.w line_failed
    move.b %d0,22(%a6)
    moveq #0,%d5
line_write:
    move.b 22(%a6),%d2
    addq.b #1,%d2
    move.b %d2,(%a5)+
    lea line_units(%pc),%a0
    moveq #0,%d0
    move.b (%a0,%d5.w),%d0
    move.w %d0,%d1
    add.w %d1,%d1
    lea 16(%a6),%a0
    adda.w %d1,%a0
    move.b (%a0)+,%d2
    addq.b #1,%d2
    move.b %d2,(%a5)+
    move.b (%a0),%d2
    addq.b #1,%d2
    move.b %d2,(%a5)+
    mulu.w #3,%d0
    lea 4(%a6),%a0
    adda.w %d0,%a0
    moveq #2,%d1
line_three_forwards:
    move.b (%a0)+,%d2
    addq.b #1,%d2
    move.b %d2,(%a5)+
    dbra %d1,line_three_forwards
    move.b 14(%a6),%d2
    addq.b #1,%d2
    move.b %d2,(%a5)+
    clr.b (%a5)+
    addq.w #1,%d5
    cmpi.w #7,%d5
    blo.s line_write
    lea 40(%sp),%sp
    movea.l 0x1E(%a2),%a0
    adda.w 6(%a0),%a0
    adda.w #64,%a0
    move.l %a0,32(%sp)
    move.l %a5,36(%sp)
    tst.w 0xFFFFD058
    bne.s line_auto
    clr.l (%sp)                    | Native Off used MOVEQ13, clearing high D0.
line_auto:
    move.w #0xFFFF,2(%sp)
    andi.w #0xFFF0,60(%sp)         | Last native longword is positive/nonzero.
    movem.l (%sp)+,%d0-%d7/%a0-%a6
    move.w (%sp)+,%sr
    rts
line_failed:
    | Validated20+rosters guarantee all pools; record any impossible cache fault.
    move.w #0x4C46,0xFFFFF85E
    clr.w TAG
    lea 40(%sp),%sp
line_original:
    movem.l (%sp)+,%d0-%d7/%a0-%a6
    move.w (%sp)+,%sr
    tst.w 0xFFFFD058
    beq.s line_off
    jmp 0x171D6
line_off:
    jmp 0x171F4
use_line_slot:
    move.l (%a6),%d1
    bset %d0,%d1
    move.l %d1,(%a6)
    rts

| D7 club,D6 wanted role,A6 local work; keep D5 iteration and A5 output.
best_line_slot:
    clr.w 24(%a6)
best_phase:
    move.w #0xFFFF,26(%a6)
    moveq #-1,%d4
    moveq #0,%d3
best_candidate:
    move.l (%a6),%d1
    btst %d3,%d1
    bne.s best_next
    move.w %d7,%d0
    move.w %d3,%d1
    bsr.w uid
    tst.l %d0
    bmi.s best_next
    lea 0x239B80,%a0
    moveq #0,%d2
    move.b (%a0,%d0.w),%d2
    tst.w 24(%a6)
    bne.s best_flex
    cmp.w %d6,%d2
    bne.s best_next
    bra.s best_score
best_flex:
    cmpi.w #1,24(%a6)
    bne.s best_any_forward
    cmpi.w #4,%d2
    bne.s best_next
    bra.s best_score
best_any_forward:
    cmpi.w #1,%d2
    blo.s best_next
    cmpi.w #4,%d2
    bhi.s best_next
best_score:
    lea 0x239EC0,%a0
    moveq #0,%d2
    move.b (%a0,%d0.w),%d2
    cmp.w %d4,%d2
    ble.s best_next
    move.w %d2,%d4
    move.w %d3,26(%a6)
best_next:
    addq.w #1,%d3
    cmpi.w #26,%d3
    blo.s best_candidate
    moveq #0,%d0
    move.w 26(%a6),%d0
    cmpi.w #0xFFFF,%d0
    bne.s best_done
    cmpi.w #1,%d6
    blo.s best_missing
    cmpi.w #3,%d6
    bhi.s best_missing
    addq.w #1,24(%a6)
    cmpi.w #3,24(%a6)
    blo.w best_phase
best_missing:
    moveq #-1,%d0
best_done:
    rts
line_units:
    .byte 0,1,2,0,1,0,2
    .even

| Native main-card hot/cold selection must inspect the current cached first line.
active_line_a0:
    move.w %sr,-(%sp)
    move.l %d0,-(%sp)
    bsr.w enabled
    beq.s active_line_old
    adda.w #0x16A,%a0
    move.l (%sp)+,%d0
    move.w (%sp)+,%sr
    rts
active_line_old:
    move.l (%sp)+,%d0
    move.w (%sp)+,%sr
    movea.l 0x1E(%a0),%a0
    adda.w 6(%a0),%a0
    rts
