Skip to content

Pass Konami sequence element counts#91

Open
mjc wants to merge 2 commits into
lukash:mainfrom
mjc:refloat-fix-konami-length
Open

Pass Konami sequence element counts#91
mjc wants to merge 2 commits into
lukash:mainfrom
mjc:refloat-fix-konami-length

Conversation

@mjc

@mjc mjc commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Passes element counts, rather than byte sizes, when initializing the three footpad gesture sequences.

Why

konami_init expects a uint8_t element count. The old code passed sizeof(sequence), which is the array byte size. After a valid gesture was consumed, the state machine could therefore continue indexing past the end of the sequence.

Changes

  • Pass the element count for the flywheel, headlights-on, and headlights-off sequences.
  • Convert each derived count explicitly at the uint8_t API boundary.
  • Assert at compile time that every fixed sequence fits that representation.

Scope

Only initialization of the three fixed gestures changes. Their contents, timing, and valid state-machine behavior are otherwise unchanged.

Hilariously, it seems possible to do a TAS-style physical reproduction of this but there is no way I am going to spend the time to try. I did get strange behavior after enough trying to trigger it manually though.

Copilot AI review requested due to automatic review settings July 14, 2026 20:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Konami footpad gesture initialization to pass sequence element counts (not byte sizes) into the Konami state machine, preventing potential out-of-bounds indexing after a gesture is consumed.

Changes:

  • Update flywheel Konami gesture initialization to pass array element count.
  • Update headlights-on Konami gesture initialization to pass array element count.
  • Update headlights-off Konami gesture initialization to pass array element count.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main.c Outdated
Comment thread src/main.c Outdated
Comment thread src/main.c Outdated
Comment thread src/main.c Outdated
Comment thread src/main.c Outdated
Comment thread src/main.c Outdated
@mjc
mjc force-pushed the refloat-fix-konami-length branch from 5643199 to 72c0d92 Compare July 20, 2026 16:33
@mjc

mjc commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Added array_size helper and addressed the other feedback.

@mjc
mjc force-pushed the refloat-fix-konami-length branch from 72c0d92 to 96ea667 Compare July 20, 2026 16:42
@mjc

mjc commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

second force push was just formatting.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants