Nintendo Jump tables

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

User avatar
Yggi
Posts: 29
Joined: Wed Dec 22, 2010 9:14 am
Location: Germany

Re: Nintendo Jump tables

Post by Yggi »

I must agree with Movax12 that it would have been easier to just load the x,y registers with the table address and then call the JumpEngine. It's faster. And also uses less code, but I don't know how much tables SMB uses (loading the address before the JumpEngine call costs additional code).
Actually, I thought about it more..keeping the same structure, and using x,y for the table pointer (or zeropage) is okay, but then you would need two RTS or still use PLA,PLA,RTS to return to the code that first called into the jump table, so it might as well be done this way.
The stack wouldn't need to be used at all if you use jmp istead of jsr to call the JumpEngine.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Nintendo Jump tables

Post by tokumaru »

Yggi wrote:The stack wouldn't need to be used at all if you use jmp istead of jsr to call the JumpEngine.
And how would you return, then?
User avatar
Yggi
Posts: 29
Joined: Wed Dec 22, 2010 9:14 am
Location: Germany

Re: Nintendo Jump tables

Post by Yggi »

tokumaru wrote:
Yggi wrote:The stack wouldn't need to be used at all if you use jmp istead of jsr to call the JumpEngine.
And how would you return, then?
By RTS? "OperModeExecutionTree" still needs to be called using JSR.
I meant, the stack wouldn't be needed for the JumpEngine-Part.
Post Reply