I just TAS'd the rom you posted, and pressing all the buttons every other frame DOES make the code work. So does pressing random buttons in the middle of the code. The only sequence I tried was up, down, up, b, down, down, start, left, right, left, A, right, B, A, but any buttons can probably be pressed in between while the timer is counting down.
Here's my admittedly
crazy (and untested) solution. It allows for multiple button inputs (even all eight at once), and fails if anything that's not part of an input is pressed at any time. It will also wait as long as possible for you to press the rest of the buttons in a multibutton input which I think is nicer than a timer.
Apologies in advance if it's hard to read. My coding style is basically garbage. It's also not super optimized, but it may work even though it's untested. Yell at me if it doesn't work, I would like to fix it if it doesn't.
I may be able to do something less hardcore if multiple button inputs aren't needed. I realized after the post you didn't care about multiple buttons at all. I just sorta read (right_punch) as something like right+A, when you really just had the Konami code verbatim.
Edit: Doesn't work!

Figuring it out now.
Edit 2: It plays at least somewhat nice now. Further stress testing now.
Code: Select all
;NoButtons = Contains whether we are currently waiting for no buttons to be checked
;Non Zero means we are.
;IntNoButtons = Contains whether the first check is waiting for no buttons to be checked
;Non Zero means it is
;code_offset = code_offset
;InputStarted = Used to check for no buttons being pressed after starting a complex input.
;Nonzero means complex input was started
up_punch = %00001000
down_punch = %00000100
left_punch = %00000010
right_punch = %00000001
a_punch = %10000000
b_punch = %01000000
code_check:
.byte up_punch, up_punch, down_punch, down_punch
.byte left_punch, right_punch, left_punch, right_punch
.byte b_punch, a_punch
;code_check:
.byte up_punch | a_punch, down_punch | b_punch, left_punch, right_punch
.byte down_punch | left_punch, down_punch | right_punch, b_punch, a_punch
.byte up_punch, right_punch
test_code:
ldx code_offset;Because when code_offset is 0, old inputs may still be pressed from when the code was reset
beq nobuttonstartcheck;We go to an additional check
truestart:
lda NoButtons;If we're waiting for no buttons to be pressed
bne ComplexCheck;Branch
lda buttonsheld
beq complexinputstartcheck
complexinputreentry:
cmp code_check,x;If the current input matches
beq SetNoButtons;The input we want perfectly, we are now waiting for no buttons to be pressed to advance the offset
;If not...
lda code_check,x;We now reverse the buttons the current input requires
eor #$FF;We do this, so we can check if any of THOSE buttons we don't want are pressed
and buttonsheld;And reset code_offset if so
bne resetcode;If any are pressed, we reset the code
;Else, we go through the loop on the next frame waiting for a perfect match to our input
;And set InputStarted so if the player releases all of the current "good" buttons
;the code will be reset
lda buttonsheld
beq code_rts
lda #$FF
sta <InputStarted
rts
complexinputstartcheck:
ldy InputStarted
beq complexinputreentry
bne resetcode
nobuttonstartcheck:
lda IntNoButtons;If this variable is 0,
beq truestart;we're safe to start the code as normal
lda #$00
sta NoButtons
sta InputStarted
lda buttonsheld;Otherwise we RTS if the current input is non zero
bne code_rts
sta IntNoButtons;or store zero in this variable so the code can safely continue on the next frame
code_rts:
rts
SetNoButtons:
lda #$FF
sta NoButtons
lda #$00
sta InputStarted
rts
ComplexCheck:
lda code_check,x
eor #$FF
sta temp
lda buttonsheld
beq AdvanceCode;If there are no buttons held, we can move the next input
and temp;If a button that was NOT part of our input is pressed
bne resetcode;While other buttons related to the current input are, we reset the code.
rts;If neither of those things are true, we're still waiting for the buttons to be released
AdvanceCode:
inx
cpx #$0A
beq codesucceeded
stx code_offset
lda #$00
sta NoButtons
sta InputStarted
rts
resetcode:
lda #$00
sta NoButtons
sta code_offset
sta InputStarted
lda #$FF
sta IntNoButtons
rts
codesucceeded:
;Do code succeeded things
jmp resetcode
rts
Konami Test Rom:
http://www.mediafire.com/?4y232b65qmr3071
Multi Button Test Rom:
http://www.mediafire.com/download.php?v891d08t1va5da7
Multibutton's code is: up+A, down+B, left, right, down+left, (remember you gotta release all buttons before next input) down+right, B, A, Up, Right
The background turns blue on success.
I definitely should have chosen a code that didn't have something like the down+left, down+right sequence. Still pretty proud of how it works with wrong button inputs even when the current input requires multiple buttons. Roth's is better for rapid fire entry, though. Mine is too strict to enter the code quickly.