Language…
8 users online: ASSATAKKU, dequeiroz,  Kevin, MarsAmpere, MrDeePay, onigirikun, SweatyNoodle, Zavok - Guests: 64 - Bots: 324
Users: 58,857 (2,245 active)
Latest user: stealthypony

Removing Asar patches manually

ASM PatchesTool-Specific

How to remove Asar patches.

If you want to remove a patch, the solution is not to port all of your stuff to a new rom. There's an easier way.

Here's how you do it.
Go to your patch file. As an example, I will be using Ersanio's SMB3 P-Meter. Download.

Now, there are 2 types of edits patches make: simple edits and hijacks. Removing edits is easier, so I will show you how to do that, first.

In Speedbar.asm, you will find the following:
Code
ORG $008CA9
db $3D,$3C,$3D,$3C,$3D,$3C,$3D,$3C	;Arrange the statusbar so the P-meter can fit in...
db $3D,$3C,$3D,$3C,$3E,$3C,$3F,$3C	;
db $FC,$3C,$2E,$3C			;

ORG $008CDF
db $76		;(Put the little clock before the timer)

Now, to reverse this:
Count the amount of edited bytes. For the first ORG, that is 20. For the second, just 1.
Then, open a clean SMW ROM in a hex editor. I prefer using shex because of its SNES address support.
Copy over 20 bytes, and put them in a new patch like this, using the same org:
Code
org $008CA9
db $FC,$38,$3D,$3C,$3E,$3C,$3F,$3C
db $FC,$38,$FC,$38,$FC,$38,$2E,$3C
db $26,$38,$FC,$38


Do the same for the other ORG:
Code
ORG $008CDF
db $FC


Now, to remove a hijack. A hijack is when there's a JSL or JML into freespace. (anything in freecode comes after a "freecode" or "freedata" command in asar)
First, we will clean up the free space.
Code
ORG $008E1A
	autoclean JML Main	;Hijack routine
	NOP		;And point to new routine.
	

Count the amount of bytes between the org and the JSL, plus one. In this case, that amount is 1.
In order to clean the freespace, do the following:
Code
autoclean read3(ORG+OFFSET)

So in this case, autoclean read3($0081EA+1)
After that, count the amount of bytes your hijack uses. In this case, it's 5. (JML is 4 bytes, nop is 1)
Then, look in your hex editor again and place the 5 bytes of that location.
Code
db $AD,$93,$14,$05,$9D

You need to do this (removing the hijack spot, not cleaning the freespace) for each hijack the patch makes.

The finished product should look like this:
Code
org $008CA9
db $FC,$38,$3D,$3C,$3E,$3C,$3F,$3C
db $FC,$38,$FC,$38,$FC,$38,$2E,$3C
db $26,$38,$FC,$38
ORG $008CDF
db $FC

autoclean read3($0081EA+1)

org $008E1A
db $AD,$93,$14,$05,$9D


This is your Anti-Patch. If you patch this with asar, the original patch will be removed.
Does it work with xkas patches applied with asar with on top ;@xkas???
This is actually quite a good tutorial. It definitely works!
I'll suggest a couple of improvements. First of all, it's worth mentioning that some patches rely on hijacks by Lunar Magic, which might mess stuff up if you copy the original bytes from a clean ROM. If the patch requires that you save a level (or the overworld) or insert graphics or anything like that, it could be a good idea to first do that to the "clean" ROM to ensure you're restoring code which Lunar Magic might've changed.
Also, it'd be good to have a little guide telling you how much bytes the more common instructions take up, as it might be a bit confusing to some. Have a look (yes, I know that dl is not an opcode):
InstructionSize
JMP3 bytes
JML4 bytes
JSR3 bytes
JSL4 bytes
NOP1 byte
BRA2 bytes
dl3 bytes

Generally, the opcode itself is 1 bytes and then there's another byte for every two digits of its parameter. Branching opcodes are 2 bytes.

Originally posted by Super-toad 65
Does it work with xkas patches applied with asar with on top ;@xkas???

It should, yes. Really all this is doing is cleaning up the freespace and restoring the original code.
Originally posted by HuFlungDu
The issue with asar anti is that it will require a slightly different algorithm, because asar uses automatic freespace finding. I could probably get it working eventually, but since I don't use asar, I don't think I'll have the motivation to actually do it.
Tool. Asar anti! #smw{>:|}
Userbar made by Green Jerry




And for the leaveyoshi.asm how do I unpatch
My unreleased ROM hack: Mario Saves Summer

ASM PatchesTool-Specific