    .ifndef WITH_DIRECTIONAL
    .equ WITH_DIRECTIONAL,0
    .endif
    .ifndef WITH_PASS_SPEED
    .equ WITH_PASS_SPEED,0
    .endif
| Optional targeted B-pass lift. Normal keeps the native cap12; Low caps at6.
| Horizontal intercept arithmetic, A flips, C shots and blind passes are not hooked.
| Exports +0 lift, +4 mapped load, +8 mapped season store, +12 menu writer.
| F0DC: active enum0Normal/1Low. Tagged/complemented bytes50AF/51AE persist at
| logical1EEE..1EEF per season; native1EF6..1FFF remains untouched. Standalone
| r5 standalone preference uses Light shared gap4D20..21; r4 2E20 was outside
| the Full gap and overlapped goalie data. r4 layout is retained only for rollback.
    .equ VALUE,0xFFFFF0DC
    .equ SREC,0x203DDD
    .if WITH_PASS_SPEED
    .equ NREC,0x209A41                | logical4D20, Light-bank shared-profile gap excluded by slot copies
    .else
    .equ NREC,0x205C41
    .endif
    .equ VIEW,0xFFFFF06C
    .equ MAP,0xA130F1
    .text
    .globl _start
_start:
    bra.w lift
    bra.w load
    bra.w season_store
    bra.w writer
    .if WITH_PASS_SPEED
    bra.w mapped_put                  | +16 writer for the shared lift/speed record, mapper already on
    .endif
lift:
    .if WITH_PASS_SPEED
    cmpi.w #1,0xFFFFF0E8
    bne.s ordinary_lift
    move.l %d2,-(%sp)
    move.w 0xFFFFF0EA,%d2              | original native timing, before independent speed solve
    bsr.s lift_value
    move.l (%sp)+,%d2
    jmp 0xBF70
ordinary_lift:
    bsr.s lift_value
    jmp 0xBF70
lift_value:
    .endif
    move.b %d2,0xFFFFB776             | exact original unbounded vertical assignment
    cmpi.w #1,VALUE
    beq.s low
    cmpi.w #12,%d2
    blt.s lift_done
    move.b #12,0xFFFFB776
    bra.s lift_done
low:
    cmpi.w #6,%d2
    blt.s lift_done
    move.b #6,0xFFFFB776
lift_done:
    .if WITH_PASS_SPEED
    rts
    .else
    jmp 0xBF70                       | native horizontal intercept/timing continues with D2 intact
    .endif

record:
    lea SREC,%a0
    tst.w VIEW
    bne.s record_ready
    lea NREC,%a0
record_ready:
    rts
load:
    .if WITH_DIRECTIONAL
    jmp 0x2E6810
    .else
    move.w %sr,-(%sp)
    movem.l %d0-%d1/%a0,-(%sp)
    bsr.s record
    clr.w VALUE                      | absent/corrupt/old preference always Normal
    .if WITH_PASS_SPEED
    clr.w 0xFFFFF0E8
    .endif
    moveq #0,%d0
    move.b (%a0),%d0
    move.w %d0,%d1
    .if WITH_PASS_SPEED
    andi.w #0xFC,%d1
    .else
    andi.w #0xFE,%d1
    .endif
    cmpi.w #0x50,%d1
    bne.s loaded
    not.b %d0
    cmp.b 2(%a0),%d0
    bne.s loaded
    not.b %d0
    .if WITH_PASS_SPEED
    move.w %d0,%d1
    lsr.w #1,%d1
    andi.w #1,%d1
    move.w %d1,0xFFFFF0E8
    .endif
    andi.w #1,%d0
    move.w %d0,VALUE
loaded:
    movem.l (%sp)+,%d0-%d1/%a0
    move.w (%sp)+,%sr
    rts
    .endif
season_store:
    tst.w VIEW                       | called only within the existing active-bank checksum path
    beq.s season_done
    move.w %sr,-(%sp)
    movem.l %d0/%a0,-(%sp)
    lea SREC,%a0
    bsr.s put
    movem.l (%sp)+,%d0/%a0
    move.w (%sp)+,%sr
season_done:
    rts
    .if WITH_PASS_SPEED
mapped_put:
    bsr.w record
    .endif
put:
    .if WITH_DIRECTIONAL
    jmp 0x2E6814
    .else
    moveq #0x50,%d0
    cmpi.w #1,VALUE
    bne.s write_record
    addq.w #1,%d0
write_record:
    .if WITH_PASS_SPEED
    cmpi.w #1,0xFFFFF0E8
    bne.s record_encoded
    addq.w #2,%d0
record_encoded:
    .endif
    move.b %d0,(%a0)
    not.b %d0
    move.b %d0,2(%a0)
    rts
    .endif
writer:
    cmpi.w #1,%d3
    bhi.w flags
    tst.w VIEW
    beq.s writable
    tst.w 0xFFFFE3E8                  | completed-game index of the selected season header
    beq.s writable
    cmpi.w #1,0xFFFFE3F0
    beq.w flags
    cmpi.w #3,0xFFFFE3F0
    beq.w flags
    cmpi.w #4,0xFFFFE3F0
    beq.w flags
writable:
    cmp.w VALUE,%d3
    beq.w flags
    move.w %sr,-(%sp)
    movem.l %d0-%d1/%a0-%a1,-(%sp)
    ori.w #0x700,%sr
    move.w %d3,VALUE
    move.b #1,MAP
    bsr.w record
    bsr.s put
    lea 0x200001,%a0
    tst.w VIEW
    bne.s checksum
    .if WITH_PASS_SPEED
    lea 0x208001,%a0
    .else
    lea 0x204001,%a0
    .endif
checksum:
    moveq #0,%d0
    move.w #0x1FFE-1,%d1
sum:
    add.b (%a0),%d0
    addq.l #2,%a0
    dbra %d1,sum
    not.b %d0
    move.b %d0,(%a0)
    not.b %d0
    move.b %d0,2(%a0)
    move.b #0,MAP
    movem.l (%sp)+,%d0-%d1/%a0-%a1
    move.w (%sp)+,%sr
flags:
    tst.w %d2                        | native row writer return contract
    rts
