I'm running into some strange issues with my code.
I came across the following code in the SMB1 source:
I have tried integrating it into my project. I want to use it as a
way to handle control flow. Here's what my source looks like in my
controller handler:
The test sound routines simply play a c note in different ocatives.
The sound triggers, but here is what my stack looks like afterwards:
It seems to be caught in an infinite loop. I'm not sure exactly how that
can be. I've written small demos using 6502 Macro Assembler. I've plugged
in the same code and it works fine.
I'm using asm6. Everything else is just a ported NerdyNights tutorial.
Is there any way to assess what went wrong?
I came across the following code in the SMB1 source:
Code:
JumpEngine:
asl ;shift bit from contents of A
tay
pla ;pull saved return address from stack
sta $04 ;save to indirect
pla
sta $05
iny
lda ($04),y ;load pointer from indirect
sta $06 ;note that if an RTS is performed in next routine
iny ;it will return to the execution before the sub
lda ($04),y ;that called this routine
sta $07
jmp ($06) ;jump to the address we loaded
asl ;shift bit from contents of A
tay
pla ;pull saved return address from stack
sta $04 ;save to indirect
pla
sta $05
iny
lda ($04),y ;load pointer from indirect
sta $06 ;note that if an RTS is performed in next routine
iny ;it will return to the execution before the sub
lda ($04),y ;that called this routine
sta $07
jmp ($06) ;jump to the address we loaded
I have tried integrating it into my project. I want to use it as a
way to handle control flow. Here's what my source looks like in my
controller handler:
Code:
; when button a is pressed
LDA #0 ; start with first routine
JSR JumpEngine
.dw TestSound1
.dw TestSound2
LDA #0 ; start with first routine
JSR JumpEngine
.dw TestSound1
.dw TestSound2
The test sound routines simply play a c note in different ocatives.
The sound triggers, but here is what my stack looks like afterwards:
It seems to be caught in an infinite loop. I'm not sure exactly how that
can be. I've written small demos using 6502 Macro Assembler. I've plugged
in the same code and it works fine.
I'm using asm6. Everything else is just a ported NerdyNights tutorial.
Is there any way to assess what went wrong?