Subject: [stella] New jumptable implementation. From: R Mundschau <rmundsc@xxxxxxxxx> Date: Thu, 02 Jan 2003 21:20:52 -0600 |
Hi, This is my first post, so let me start by introducing myself. My name is Rob Mundschau. I never programmed for the 2600 before, but I do have considerable experience programming the Commodore 64. Lately I have grown interested in the 2600 Homebrew scene, and I hope to make some games. I have been browsing the archives, and I haven't found any mention of technique I know of for implementing a jump table. Excuse me is this was mentioned before, and I missed it. The smallest implementation I saw on the list so far is: # Assume index is in X LDA TableLo,X STA Vector LDA TableHi,X STA Vector+1 JMP (Vector) # Put Lo and Hi jump tables here. As an alternative we can use the stack in combination with a RTS command: # Assume index is in X LDA TableHi,X PHA LDA TableLo,X # I hope I pushed these in the right order... PHA RTS # Put Lo and Hi Jump tables here: Using the PHA instructions saves 2 bytes of ROM. The RTS takes one more clock cycle than the indirect JMP instruction so the routine takes one clock more overall. There is one more catch. You must subtract 1 from the addresses in the Jump table because the RTS instruction adds 1 to the PC value it loads from the stack. If the Lo byte is $00, then you must subtract 1 from the Hi byte as the borrow for the subtraction. Cheers, Rob M. ---------------------------------------------------------------------------------------------- Archives (includes files) at http://www.biglist.com/lists/stella/archives/ Unsub & more at http://www.biglist.com/lists/stella/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[stella] Psst! Hey, buddy, wanna bu, Christopher Tumber | Thread | Re: [stella] New jumptable implemen, Thomas Jentzsch |
Re: [stella] Mortal Kurling!, Christopher Tumber | Date | [stella] ASCII or PDF Manual or Syn, R Mundschau |
Month |