| Three / Four human teammates with 4-Way Play (jdc 2026-10-26-r16).
| The game's own "Three" (Players 5) is 2 v 1 and "Four" (6) 2 v 2, and its playoff modes
| have at most two humans. Here Three / Four are teammates in every mode: after the native
| side assignment ($17E42, end $17FE0) pads 2..4 join pad 1's side. TM ($FFF07C) holds the
| count (3 / 4, else 0), set by the season menu's Players row, so it also covers the
| season's playoffs, where the game itself assigns only pads 1 and 2.
| +0 $17FE0 (movem.l (sp)+,d0-d3/a0-a1 / rts -> jmp); +4 coop: Z set when Players is
| Two - Teammates, Three or Four; +8 Players row: d3 = the native new value -> d3 = ours.
    .equ PLAYERS,0xFFFFD04A
    .equ MTAP,0xFFFFD046               | 4-Way Play present
    .equ PMODE,0xFFFFD048
    .equ TM,0xFFFFF07C
    .equ SLOTVIEW,0xFFFFF06C
    .text
    .globl _start
_start:
    bra.w sides
    bra.w coop
    bra.w row

sides:
    .if WITH_QUICKGAME
    tst.w 0xFFFFF84C
    beq.s ordinary_sides
    jsr 0x22900C
    bra.w 9f
ordinary_sides:
    .endif
    tst.w SLOTVIEW
    bne.s adapter_check
    tst.w PMODE
    beq.s adapter_check
    cmpi.w #3,PMODE
    bhi.s adapter_check
    jsr 0x2EB028                     | standalone playoffs: own saved count, including native head-to-head
adapter_check:
    tst.w MTAP
    beq.s 9f
    jsr 0x2EA614                       | a new adapter game starts with empty goalie input latches
    tst.w PMODE                        | league: the visible Players value is authoritative
    beq.s league_count
    btst #0,0xFFFFC2FA                  | preserve two-actor shootout assignment
    bne.s 9f
    move.w TM,%d0
    bra.s 1f
league_count:
    moveq #3,%d0
    cmpi.w #5,PLAYERS
    beq.s 1f
    moveq #4,%d0
    cmpi.w #6,PLAYERS
    bne.s 9f
1:  cmpi.w #3,%d0
    bcs.s 9f
    move.w 0xFFFFC328,%d1              | pad 1's side: 1 home, 2 away
    beq.s 9f
    move.w %d1,0xFFFFC32A
    move.w %d1,0xFFFFC32C
    clr.w 0xFFFFC32E
    cmpi.w #4,%d0
    bcs.s 9f
    move.w %d1,0xFFFFC32E
9:  movem.l (%sp)+,%d0-%d3/%a0-%a1     | the replaced native exit
    rts

coop:                                  | Z = co-op (3, 5, 6); registers kept
    cmpi.w #3,PLAYERS
    beq.s 9f
    cmpi.w #5,PLAYERS
    beq.s 9f
    cmpi.w #6,PLAYERS
9:  rts

row:                                   | d3 = native new Players value (old one in PLAYERS)
    movem.l %d0-%d2/%a0,-(%sp)
    lea seq2(%pc),%a0
    moveq #2,%d2                       | entries
    tst.w MTAP
    beq.s 1f
    lea seq4(%pc),%a0
    moveq #4,%d2
1:  moveq #0,%d1                       | index of the old value (default 0)
2:  move.b (%a0,%d1.w),%d0
    ext.w %d0
    cmp.w PLAYERS,%d0
    beq.s 3f
    addq.w #1,%d1
    cmp.w %d2,%d1
    bcs.s 2b
    moveq #0,%d1
3:  move.w PLAYERS,%d0                 | Right: old + 1 (6 wraps to 0), else Left
    addq.w #1,%d0
    cmp.w %d0,%d3
    beq.s 4f
    cmpi.w #6,PLAYERS
    bne.s 5f
    tst.w %d3
    bne.s 5f
4:  addq.w #1,%d1
    cmp.w %d2,%d1
    bcs.s 6f
    moveq #0,%d1
    bra.s 6f
5:  subq.w #1,%d1
    bpl.s 6f
    move.w %d2,%d1
    subq.w #1,%d1
6:  move.b (%a0,%d1.w),%d3
    ext.w %d3
    clr.w TM
    cmpi.w #5,%d3
    bne.s 7f
    move.w #3,TM
7:  cmpi.w #6,%d3
    bne.s 8f
    move.w #4,TM
8:  movem.l (%sp)+,%d0-%d2/%a0
    rts
seq2: .byte 1,3
seq4: .byte 1,3,5,6
    .even
