Warning: I have no idea why I didn't add a deprecation warning to this last month, but seeing as it got activity, I will now. xkas is an old and obsolete tool and you should use Asar instead, as it's more stable and way easier to use. The tutorial by itself is also not good (even though that doesn't matter because you shouldn't be using xkas in 2016).
Hello and welcome to my first tutorial! In it, I will show you how to apply Xkas (ASM) patches easily! No more talking. Let's begin!
What will you need?
1. Microsoft Windows XP/Vista/7;
2. A patch;
4. Your ROM hack;
5. Lunar Expand;
6. Free Space Logger (Slogger) - Search for it in the tools section.
Wait, wait, what's a patch?
A patch is a custom piece of ASM that goes into the game. A patch can modify anything, starting from the Nintendo Presents screen to the ending credits.
So, how do I apply a "patch"?
1. Make a backup of your ROM.
2. Open Lunar Expand and expand your ROM to 4MB. (OPTIONAL)
If your patch requires freespace...
1. Move the ROM into Slogger's folder.
2. Drag it on "slogger.exe".
3.1. Open the newly created text file.
3.2. Expand Notepad (by using the maximize button)
4. Search for a 0x8000 in the Size field (there should be plenty of them).
5. On the right, there's a section called "LoROM Address". Copy the address of the 0x8000 you chose.
6. Open your patch with a program, such as Notepad and search for a comment telling you that said line is freespace. The line commonly looks like:
1) org $xxxxxx
2) !freespace = $xxxxxx
7. Change the X-es to the copied address.
8. Save the patch.
If you expand your ROM to 4MB, you don't need to expand is a second time.
Huge and fat note: NEVER use the LoROM Offsets that end with "(!)". They are SRAM and will crash your game if you use them.
These were the steps you need to do, in order to set the freespace. The steps below are required, no matter if the patch does, or doesn't require freespace.
1. Move your ROM and your patch to the folder where Xkas lies.
2. Create a new file and name it "patch.bat". Windows will ask you do you really want to change the extension. Say yes. Open the newly created file with Notepad. Type in:
xkas.exe PatchName.asm RomFilename.smc
Note: Replace PatchName.asm with your patch's name and RomFilename.smc with your ROM's filename. Both of these CANNOT contain spaces.
Note 2: To apply something else, just edit the file.
3. Open the batch file and hit any key.
4. Test you ROM!
I hope that was useful!
This is a more advanced section. Do not do anything described here UNLESS you got the way to patch stuff. Also, I do recommend knowing a bit of ASM.
Here's the way to see how much bytes a patch has eaten up:
1. Open the main ASM file in a text editor.
2. After "header" and "lorom" make a new line and put "reset bytes", no quotes, on it.
3. At the very end of the patch, on a new line, put "print bytes".
4. Now, every time you patch the certain patch, Xkas will tell you how many bytes it used!
And now, here's an explanation for the two things we added.
- Resets a "variable" and starts counting bytes. (Confirmation please)
- This will print out the counted bytes.
- A command that will print something out. You can also use quotes to print out text. This is basically the "echo" command in PHP. Here's an example of this command being used:
print "This patch used ",bytes," bytes."
Q: I got the Blank Screen of Death (BSoD)!
A: You didn't do something right. Restore your hack with the backup, and try again.
Q: I can't see the author's note in the patch!
A: This means that the patch doesn't require freespace. Patch it as it is.
Q: I don't fully understand step 6 of the freespace part. What's a 'comment'?
A: A comment starts with a semi-colon (;). Anything after it is ignored. (for the current line only)
Q: hwo do ya make a pach im confused this tut dident cover it it sucks
A: This tutorial is on how to apply a patch. Look for another tutorial to learn how to make one.
Edit (7th June 2012): Organized the tutorial a bit more and simplified some steps.
Edit (16th August 2012): Added a new section.