Skip to content

Fix potential crash when loading presets - #291

Open
InsaneFirebat wants to merge 1 commit into
tewtal:next-updatefrom
InsaneFirebat:fix_2.7.11.1
Open

Fix potential crash when loading presets#291
InsaneFirebat wants to merge 1 commit into
tewtal:next-updatefrom
InsaneFirebat:fix_2.7.11.1

Conversation

@InsaneFirebat

Copy link
Copy Markdown
Collaborator

I was experimenting with making demos load faster in the practice hack by copying preset_start_gameplay. I came across a crash after cutting out some things that were specific to presets. The hitbox color feature overwrote a stray RTL to expand the routine below it. preset_start_gameplay was calling the old address. The routine is supposed to start like this

load_common_target_colors:
    %ai16()
    LDX #$001E
  .first_loop
    LDA $9A81A0,X : STA $7EC3A0,X
    DEX #2 : BPL .first_loop

But it worked out to this on the first loop

    db $C2 ; the skipped byte that used to be RTL
load_common_target_colors:
    BMI $A2 ; crash if negative flag is set
    ASL $BF00,X
    LDY #$9A81
    STA $7EC3A0,X
    DEX #2
    BPL .first_loop

We don't notice the effects of this because X = $20, only one extra loop. The fix is replacing JSL $82E139 with JSL load_common_target_colors in presets.asm

$82E139 was overwritten for the hitbox viewer color feature
@InsaneFirebat InsaneFirebat added the bug Something isn't working label Sep 2, 2026
@idlechild

Copy link
Copy Markdown
Collaborator

Good find

This ended up being so minor I'm wondering if it's worth merging now (I'm not opposed to it)

@InsaneFirebat
InsaneFirebat changed the base branch from master to next-update September 3, 2026 07:54
@InsaneFirebat

Copy link
Copy Markdown
Collaborator Author

It's on next-update now. I don't think it will crash but I didn't bother checking where the negative flag actually came from. It's passing through some PHP/PLP in the routine before it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants