Jump to content
IGNORED

Freeway hack question


vb_master

Recommended Posts

I've attached a rough assembly file. Undoubtedly, some tags need to be discovered before the file can be completely relocatable. But you should be able to make changes that do not change the addresses of the bitmaps at the end of the file. All of those MUST occur exactly where they originated from until the indirect tags can be discovered...in order to add/subtract lines at will. I identifed the START tag at the end of the file for you...START = high byte

Note: Changing the little X's in the bitmaps will have no effect (because they are just comments)...you need to change the $ hex values right next to ".byte"

 

When you edit it, be sure to save it as an MS-DOS text file (i.e. unformatted).

Then to convert it back into a binary called freehack.bin (for example)...enter this:

 

dasm freeway.asm -f3 -ofreehack.bin

 

(note the -f3 and -o next to the filename)

Try it out without changing anything first...then do a file compare to see if any differences exist :)

freeway.zip

post-222-1074580030_thumb.jpg

Link to comment
Share on other sites

Ok I downgraded to v2 and I used the color chart to modify COLUP0 and COLUP1 to be 5A and 5B. When I compile with DASM, it works and now when I run it through the car, score and characters and black, I mean -- when I just get run over by a car, it justs rolls over me like nothing happened. Weird... :?

Link to comment
Share on other sites

Noooo! :lol:

 

I'm sorry. :P

COLUP0 is always $06 and COLUP1 is always $07.

You can't change those values up at the top...those are the ram ADDRESSES that the colors are saved to. So farther down in the program, values are loaded into one of the registers (like A, X, or Y), and then saved to those. That creates the color. Here's an example...

 

LDA  LFD00,x;load accumulator with a value

STA COLUP0;save it to ram address $06

LDA LFD01,x;load the accumulator with the next value

STA COLUP1;and save it to ram address $07

 

What is happening here is that the X register is being used as an offset to fetch values from a table at LFD00...and the values that are there are passed to the player color ram addresses. So in order to change the colors, you need to backtrack where the program is getting it's information (at LFD00 in this example). Sometimes, it would be getting it's info from ANOTHER ram address...which means that you would have to backtrack to see where an instruction saves a value to THAT ram address. And etc. etc.

 

So why does the disassembly even say COLUP1 and COLUP0? Why not just say 7 and 6? Because it makes it easier to see where those colors are being saved ;)

Link to comment
Share on other sites

Think I've found it...

 

LF011:

      LDA    LF6F0,X;4

      EOR    $86    ;3

      AND    $87    ;3

      STA    $88,X  ;4

      CPX    #$04   ;2

      BCS    LF020  ;2

      STA    COLUP0,X;4

.

.

.

.

LF6F0:

      .byte $4A;f6f0 | X  X X |

      .byte $1E;f6f1 |   XXXX |

      .byte $0C;f6f2 |    XX  |

      .byte $06;f6f3 |     XX |

      .byte $00;f6f4 |        |

      .byte $08;f6f5 |    X   |

 

The table LF6F0 is read by the above routine. Those values are also used by something else...so I dunno if they can be changed in the table itself just by looking at this part of the program. There might be more as well...

 

Try hacking those values in the .byte lines (note - changing the placement of the X's will have no effect...these are comments only. Hack the $ value instead).

Link to comment
Share on other sites

The end of routine LF2E3 holds very high-pitched sound...

       PHA           ;3

      AND    #$03   ;2

      ADC    #$02   ;2

      STA    AUDF0,X;4

      PLA           ;4

      LDY    #$04   ;2



 

See that AND? It's stripping away all high values...keeping only byte values contained in the first 2 bits (which would be values 0 to 3). Then, a value of 2 is added in the next line (ADC #$02). So what would happen if you changed that #$02 to something higher? It will make a lower sound :)

 

High values = low pitched sound, low values = high pitched sound.

Link to comment
Share on other sites

To do that you would need to either change the instructions or find an area of memory that you can jump to (that will hold your new routine). Then instead of doing all the calculations right at the memory address above, JSR to your routine. When the program encounters an RTS instruction there, it will return right to the spot that it left from. This is getting beyond simple hacking and more into actual 6502 coding...so you might want to read some of those tutorials to discover what those instructions do.

Link to comment
Share on other sites

Freeway is only 2k though. You can turn it into a 4k rom by adding this to the assembly...

 

LF800:





      .ds 2042,0



 ORG $fffa

      .byte $00,$00,<START,>START,$40,$80

 

I just added a "fill" command, and copied the vectors to be at the end of the file. In the original routine, instead of having the AND and ADC instructions, you can use JSR LF800 / NOP instead.

 

Try this assembly...the routine is already moved. What is important is that X is not changed in whatever routine you make at LF800. You can use the A and Y registers...since they are loaded with a new values below the original sound routine anyway. When the routine does an RTS, the value that you want for the sound should be sitting in the accumulator.

Whatever instructions are added, must be subtracted from the byte count in the .ds line...if you add 4 instructions at 2 bytes each, you must subtract 8 from the number there (so the rom will be an exact 4096 bytes). If you compile it and it is suddenly 4099 for example, you didn't lower the number enough.

 

That's almost 2k of routines you can add. But you'll still need to make sure that you don't waste too much time at any point there.

fw.zip

Link to comment
Share on other sites

That's because I split it (so you can change it around). The routine is waaaay at the end :)

 

 

       PHA           ;3


;       AND    #$03   ;2 do not compile these ...
;       ADC    #$02   ;2 ...in order to use the added JSR instead :)

      JSR    LF800  ;3

      NOP           ;2 ...NOP takes care of the leftover byte



      STA    AUDF0,X;4

      PLA           ;4

      LDY    #$04   ;2

 

See that JSR and NOP? That took the space previously used by the two instructions that are altering the accumulator...and instead is jumping to the start of the next 2k bank...

 

LF800:

      AND    #$03   ;2

      ADC    #$02   ;2

      RTS



      .ds 2037,0

 

So you can try using combinations of SBC, ASL, ROL, anything that changes the accumulator. Stick an RTS at the end, and it will jump right back to store it in the AUDF0 hardware register :D Be sure to subtract the number of bytes you add from the .ds instruction below it - that one fills up the rest of the memory.

 

It's best to patch code in this manner (by replacing values) since the game will probably contain lookup tables that Distella did not label. Putting your replacement code in unused bytes will keep the game from getting pointers from the wrong memory addresses and crashing/garbled.

Link to comment
Share on other sites

lol

You don't really need to know how it works unless you want to learn 650x coding proper...just that it works. See those instructions at LF800? Suppose you erased them and typed this instead:

LF800:

     ORA    #$FD

     SEC

     SBC    $EE

     LSR

     RTS

 

That routine is 2 bytes longer than the length of the original...so you'll also need to change the .ds line...

      .ds 2035,0

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...