DiscoSnorlax Posted January 21, 2004 Share Posted January 21, 2004 I was playing around with some assembly, and I was wondering: How do you get random numbers on the 2600? For example, let's say some code looks like this: LDA #$00 ;2 STA COLUBK ;3 How do I make it load a random number instead? Btw, what do the numbers commented onto each line mean? If I had to guess, I'd suspect that they tell how long something takes to do, but I don't actually know. Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted January 21, 2004 Share Posted January 21, 2004 Yes, those commented numbers are the number of machine cycles it takes to execute that particular instruction. The 2600 is very dependant upon them (especially in the display kernal itself...when 1 additional clock cycle can spell the difference of a good display or one with messed up colors). Nothing is really "random". What is done is that the program fetches values from Ram (preferably values that are constantly being updated)...and then does additional instructions to twist that value around. This usually involves more lines. For example...like grabbing a value from a clock timer, performing ROL, and then EOR' ing it with another ram location, before saving it to the target address. So how can you squeeze more lines of code in? Two ways... One is to disassemble the game and reverse-engineer it so that you can add/subtract program lines at will. The second is to find an area of memory that the existing program doesn't use...and write your routine there ending with a RTS instruction. And then change the original area to JSR there. Quote Link to comment Share on other sites More sharing options...
DiscoSnorlax Posted January 21, 2004 Author Share Posted January 21, 2004 Could I just replace a bunch of NOPs I found grouped together with the new code?? Also, would INTIM or TIM64T be timers? The names sound suspiciously like they are... Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted January 21, 2004 Share Posted January 21, 2004 When you find NOPs in a disassembly, they are usually there for a purpose (most likely wasting time in the display kernal). If you happen to find 6 of them strung together with NO LABELS in between, you can replace those with 1 JSR routine that goes right to an RTS instruction...effectively wasting 12 cycles and saving you 3 bytes of rom (6 NOP x 2 cycles each). In short answer, no. Those should be left alone...or the display will become messed up. The 2600's display is dependant on how long certian parts of the program take. It doesn't say, OK put this object at coordinate 20 and the other one at 50...it needs to waste a certian amount of time to get those coordinates. Instead, look around the code for areas of the program that can be cut completely out. In older programs, you can usually find CMP#$00 instructions...those don't even need to exist at all (since when you load or update a register, the zero flag will already be set if it's zero). You can hack 2k games easiest...just turn it into a 4k rom... http://atariage.com/forums/viewtopic.php?p...p=508768#508768 Quote Link to comment Share on other sites More sharing options...
EricBall Posted January 21, 2004 Share Posted January 21, 2004 Also, would INTIM or TIM64T be timers? The names sound suspiciously like they are... Check out the 6532 datasheets at www.6502.org, just remember that the 2600 doesn't use the interrupts. TIM64T sets & starts the timer counting down. INTIM reads out the current value. INTIM might be a random value on system startup, but is typically used by games to start & end VBLANK and VSYNC without counting lines. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.