This tutorial aims to teach you how to insert .asm patches. These aren't the same as .bps patches like the ones you use to share and play whole hacks, but rather additions and changes you can make to your game using the ASM programming language, the language the Super Nintendo Entertainment System (SNES) understands.
Of course, that doesn't mean you have to program anything yourself or learn anything complicated just to apply a patch, it's all in the file you downloaded already!
Your job is simply to use a program called Asar to apply the patch to your Super Mario World ROM. It doesn't matter if the ROM is "clean" or not, .asm patches will generally work on any ROM.
What you will need
- Asar, the program that inserts the patch into our ROM for us
- An .asm patch -- in this tutorial I will use the Overworld Counters patch as an example, but all patches follow the same principle
- Your Super Mario World ROM
Extract asar.exe and the patch you downloaded, owcount.asm in this example, to the same folder (say, a "patches" folder in your main hack folder) and place your ROM into the same folder.
You can ignore everything other than asar.exe in Asar's .zip file.
Table of Contents
Before we start, a few explanations about what .asm files are. They're plain text files, they're simply .txt files renamed to .asm.
That being the case, try opening them in your text editor. Do not use a rich text editor like Word or an Office program, any plain text editor like Notepad will work.
To do so, simply double-click it or right-click it and select "Open with...", then select your text editor from the list that shows up and make sure it is set to always open the file with this program.
Open it up and you should see what you can see in the image on the right. A lot of code. It might look cryptic to you if you don't know ASM, but you won't need to mess with any of the vital bits.
The only two things you have to keep in mind are what comments and defines are:
- A "comment" is that comes after a semi-colon (the ; character), it's not actual code and is just there for you to read. A lot of patches will come with instructions near the top about their usage or what to change if you want to customize it.
The Overworld Counters patch does not come with any instructions near the top, but instead has a few comments if you look down just a little:
As you can see, the text after the semi-colons is plain english, it's just commentary.
This means that if you don't want a specific counter on the overworld you simply delete that entire line, like "JSR OWScore" in the case of the score counter or "JSR OWYICoin" if you don't want any Yoshi Coin counters on your overworld.
- A "define" is anything that starts with an exclamation mark (the ! character). All these do is create names we can read for addresses or numbers. You will usually see at least a handful of defines near the top of any patch, including this one:
These will usually be explained further with comments, but as you might be able to guess from just the names here, changing the hexadecimal number after the equals sign (the = character) changes the position of the counter on the overworld screen.
Leave these values as they are for this patch, since the default positions are already really well placed.
Other patches will usually have a lot simpler defines, like yes/no options and specific commands to use.
Every patch has its own options and settings, you should always at least open up any patch you download and read the instructions near the top before applying it to your ROM.
If it comes with a readme file, make sure to take a look at those too, else you might run into unforeseen issues. This patch came with one as well, it explains what you can change and gives you some tips should you want to customize it further.
On top of that, there is one very important thing to keep track of in patches: Free RAM. This example patch doesn't use any, but a lot of patches do.
If you open a patch and see a define called "!FreeRAM", "!freeram" or anything like that, make sure it is not the same value as any other patch you have applied to your ROM.
If it IS the same value, open up the SMW RAM Map
and search for addresses labelled "Empty" using the CTRL-F keyboard shortcut, one like this:
Look at the box marked in red on the left and replace the "!FreeRAM" value with that. In this case, that would be "!FreeRAM = $0D9C". The last 4 ciphers are enough if the value starts with "$7E", but you will copy the whole thing if it starts with "$7F", for example "!FreeRAM = $7FA000".
All this sounds like a lot at first, but you will see that patches generally work perfectly fine out of the box, without requiring any further changes. Patching will become second nature eventually.
There are two quick ways to patch individual patches: by double-clicking Asar and through the Command Prompt (cmd).
Generally, using Asar itself is easier and faster and I will explain a method to speed up patching multiple patches at once further below, but knowing how to use Asar in the Command Prompt is good either way.
Patching through Asar
For this method, simply double-click on Asar itself and a black window will pop up, introducing itself as "Asar, by Alcaro" and asking you to enter the patch's name. Write in your patch's filename, in this example that would be "owcount.asm", and hit enter.
Next it will ask you for the name of your ROM. Again, just write in the filename of your hack, like "Super Mario World.smc", "My Hack.smc" or whatever else your own ROM might be titled. Hit enter and squadala, we done.
Make sure that Asar does not throw any errors but instead reports that "Assembling has completed without problems", close the window by pressing any key and boot your ROM up in an emulator to see if the patch did what it promised.
Patching through the Command Prompt
This method takes a bit longer, but is good to know should you be more acquainted with the Command Prompt already or if you need to patch multiple patches, since the window will not close by itself and previous commands can be copied back by tapping the Up-Arrow key.
It's a lot more time efficient when you're testing changes in a patch over and over as well, since you can simply tap the Up-Arrow and hit enter to re-patch it each time.
To open the Command Prompt, hold shift while right-clicking on the folder Asar is in. There will be a normally hidden entry in the context menu called "Open command window here". Click it and the Command Prompt will pop up.
To apply a patch from here, type the following and hit enter:
asar.exe "owcount.asm" "My Hack.smc"
If the patch was applied correctly, there will be no confirmation, but also no errors. It should look like the image to the right.
Now, try hitting the Up-Arrow key in this window. The previous line will be copied again and you can hit enter once more to apply the patch a second time, or a third or fourth time.
You don't have to re-open the Command Prompt window after changing anything in your ROM either, it will only access the ROM the second you hit enter.
Batch (.bat) Files
Sometimes you may want to insert a lot of patches at once or have to insert multiple patches over and over to test specific settings. It would be really annoying to have to open Asar, enter the patch name and ROM name and close it every single time.
Sometimes you might have to port your hack to a new ROM because of a critical issue that can't be fixed and going through all the effort of doing this a second time is really tedious.
This is where batch files come in handy.
To use batch files, simply create a new text file in your patch folder, right next to Asar. Name it something like "asar.bat", the name is not that important as long as it ends in ".bat".
Make sure you overwrite the .txt file extension, do not name it "asar.bat.txt". Click on "Yes" when it warns you about changing the file extension since that is what we want, and now you've created a batch file successfully. It should change its icon to look like in the image to the right.
All batch files do is run a series of pre-written Command Prompt commands whenever you double-click them. You might be able to guess how this can help you keep track of which patches you have applied to your ROM already.
Right click your .bat file and pick the second option: "Edit".
This will open it up in Notepad. Copy and paste these lines into the file and save it:
asar.exe "owcount.asm" "My Hack.smc"
From now on, if you double-click your batch file, it will let Asar apply the "owcount.asm" patch to a ROM named "My Hack.smc" in the same folder.
The "@pause" line is simply a command to make the window not close immediately upon finishing the patching process, so you can see whether any errors appeared or whether the patches all applied fine.
Try running the batch file we've written, it should look just like the Command Prompt window, with the only difference being that it closes immediately after pressing any key in it.
To add more patches to this batch file later on, simply right click it, hit "Edit" again and add more lines after the first, like so:
asar.exe "owcount.asm" "My Hack.smc"
asar.exe "another patch.asm" "My Hack.smc"
asar.exe "biggie cheese.asm" "My Hack.smc"
Should you have to port your hack to a new ROM, you will now have a simple batch file you can click to apply every single patch you had applied to your ROM originally again, with absolutely no hassle involved.
Noting down FreeRAM
As I explained earlier, it is important not to have conflicting "!FreeRAM" defines in your patches, otherwise patches will interfere with each other and start to screw up your hack in often really strange and devastating ways.
To avoid this, I'd advise you to create a .txt file noting down which addresses you've used up, formatted something like this for easier CTRL-F access:
100 Coin Roulette:
It is a lot easier to do this as you go than to end up having to check every single patch you've applied to your ROM before every time you want to apply a new one, just to make sure there are no conflicts.
For the record, here
is a complete list of all empty FreeRAM in Super Mario World. Make sure to read the comments to be sure it's not used by other common tools already.
Also note how a lot of addresses are multiply bytes in length. This means that that address and the x following addresses are all free; in the case of "$7E0DC3", which is 4 bytes long, that means that addresses "$7E0DC3", "$7E0DC4", "$7E0DC5" and "$7E0DC6" are all free for use as individual FreeRAM addresses.
When I try to apply my patch, I get an error about "JMP (something,x)". What do I do?
This is a common issue brought about by an Asar update. Open the .asm file in your text editor and find the line it is complaining about using CTRL-F.
Then add a ".w" after the "JMP", so it looks like this: "JMP.w (something,x)". That should fix it!
I have another question!
If there's anything you need help with regarding this topic, feel free to post a reply about it in this thread and hopefully someone will answer you!