Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,486,619
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 04-26-24 09:52 AM
Guest: Register | Login

0 users currently in ROM Hacking | 6 guests

Main - ROM Hacking - FSNASM and general ASM question. New thread | New reply


Frozen2Dream
Posted on 06-06-10 09:44 AM (rev. 2 of 06-06-10 09:46 AM) Link | Quote | ID: 131782


Octorok
Level: 15

Posts: 1/33
EXP: 13502
Next: 2882

Since: 06-06-10

Last post: 4974 days
Last view: 4961 days
On Hyrule Magic, when you click on the ASM Hacks part and click new, it asks for a FSNASM?
Can I put any ASM in there? 65816 for example.
Just asking, because the FSNASM thing confused me.
I googled it, and I think it has something to do with a ASM assembler? or something? But whatever download/link I find is dead. (so yes, I did look, dont complain about me wanting it on a silver platter, lol)

Also, about general ASM.
I know what cool things you can do with it, due to some SMW hacks i've seen, and other such things. I have been wanting to get into learning how to do it, but the thing is, 1. the tutorial kinda went over my head for some reason. 2. Its not how I learn.

How I learned to do the things I know tus far (some programming for a game called Starsiege Tribes. and just some general low level game hackage) I have learned from reverse engineering. Getting something already in a game, and taking it appart.
This has gotten me far, so far, but I havent found any way to reverse engineer ASM o.o

So my questions are: Is FSNASM somehow necessary for Lunar Magic/Zelda LTTP ASM Hacks? If so, where can I download the file needed?

How can I go about taking appart ASM thats already in a game? Preferably with the ability to tinker and screw with it.


EDIT: Sorry about not putting a tag on the thread. By the time I saw those options ontop I already clicked post..xD Sorry about my impatience.

____________________

Anyone mind teaching me ASM? D:
For some reason, although I read guides, somehow I am still confused, but I also understand it a bit more.
Anyway, if youd like to help at all, add me on Frozen2Dream@hotmail.com

Xenesis
Posted on 06-06-10 10:01 AM Link | Quote | ID: 131784


Level: 46

Posts: 302/416
EXP: 672113
Next: 39661

Since: 02-20-07

Last post: 4384 days
Last view: 3093 days
If you're wanting to screw around with ASM code in a game, you need an emulator that supports debugging functions. I don't do SNES ASM work myself, but I hear Geiger's Snes9x Debugger is the thing to use.

I don't know if Geiger's debugger supports temporary opcode editing, but if you want to screw around you can always edit the instructions contained in the ROM with a hex editor to screw around.

You'll probably want to find yourself an instruction set reference manual for your chosen system - you're working a a lower level than traditional programming (actually modifying CPU commands here) so you'll need to have a firm grasp of what each CPU instruction does.

I can't help you with Hyrule Magic stuff though, I'm not knowledgeable there.....

blackhole89
Posted on 06-06-10 10:02 AM Link | Quote | ID: 131785


The Guardian
Moloch whose eyes are a thousand blind windows!
Level: 124

Posts: 3140/4196
EXP: 21532868
Next: 303733

Since: 02-19-07
From: Ithaca, NY, US

Last post: 471 days
Last view: 84 days



FSNASM apparently is an assembler (as in a program to translate human-readable assembly source into machine code) that was written by the same guy who made Hyrule Magic. It seems like the application itself has dropped off the face of the internet at the moment, but chances are good that some of the resident Zelda 3 people (MathOnNapkins, Torin...) still have a copy and could put it on the uploader for you.

For reverse engineering assembly, you are probably best off with a disassembler (i.e. a tool that does the reverse conversion from machine code to a human-readable format). This (probably quite useful if you want to screw around) and that (haven't tested) follow very different approaches.
For NES (6502), there also is an input plugin for the excellent code analysis tool IDA, but I don't think anyone has made one for 65c816 so far.

Also, I added the appropriate tags for you.

____________________



Frozen2Dream
Posted on 06-06-10 10:13 AM (rev. 3 of 06-06-10 03:12 PM) Link | Quote | ID: 131786


Octorok
Level: 15

Posts: 3/33
EXP: 13502
Next: 2882

Since: 06-06-10

Last post: 4974 days
Last view: 4961 days
Those are the two quickest replies I have ever seen on a game hacking forum o.o;...

Thanks guys, Ill take a look at the links given. xD hopefully a bit of tinkering around will help me understand things a bit better.

I'll wait a little bit for MathOnNapkins or someone else to (hopefully) respond with a download link for FSNASM, before I actually PM them about it. Rather give them a chance to post before bothering them

But yeah, if I cant understand anything after tinkering with those disassemblers, ill look up and find the one for the NES.
Im sure id be able to learn some ASM from the NES, even though they are a little different.


Anyway thanks again guys.

____________________

Anyone mind teaching me ASM? D:
For some reason, although I read guides, somehow I am still confused, but I also understand it a bit more.
Anyway, if youd like to help at all, add me on Frozen2Dream@hotmail.com

Xenesis
Posted on 06-06-10 03:20 PM Link | Quote | ID: 131787


Level: 46

Posts: 303/416
EXP: 672113
Next: 39661

Since: 02-20-07

Last post: 4384 days
Last view: 3093 days
Eh, I saw the question anyhow so I'm going to answer it

Well, you would expect it to run the same opcodes. If something is changing in the game, eg an enemy position the values loaded by those opcodes would be different.

Say you've got an enemy that walks right one pixel every frame and that was the only thing it could do, you'd likely see something like the following:

Load (enemy X position address into a register)
Add X 0x1
Save (enemy X position from register into address)

So, regardless of what that enemy does, it goes in the X direction by 1 every frame.

If you had something that moved in many directions however you might see something like this:

Load (enemy X position address into R1)
Load (Change in X position into R2)
Add R1, R2
Save (enemy X position from R1 into address)
Load (enemy Y position address into R1)
Load (Change in Y position into R2)
Add R1, R2
Save (enemy Y position from R1 into address)

Difference here, you'll find that there will be some other code that will change the value that is added to the X and Y position. So you can set a breakpoint on the new position to find your new code. Of course it can vary from extremely simple (like my first example) or profoundly complicated.

It's just a matter of familiarity (you'll get into the logic of the game you're working on after a while, they all have their own personalities) and being comfortable with working with assembly code.

Frozen2Dream
Posted on 06-06-10 04:17 PM (rev. 4 of 06-06-10 04:26 PM) Link | Quote | ID: 131788


Octorok
Level: 15

Posts: 4/33
EXP: 13502
Next: 2882

Since: 06-06-10

Last post: 4974 days
Last view: 4961 days
xD thanks.
I edited it back out because I think I got the hang of it.
My only problem is the Interactive-Disassembler im using (Geigers Snes9x Debugger) didnt seem to have a 'advance one frame, and show the ASM' button that worked right.
I mean, all the code I see, Isnt everything that could be shown.

For example, lets take what im trying to do now.

I cut the speed down to 5%
Press the Use Item button. with the Lamp equiped.
Right before I use the item, I step a few frames, and as the flame goes off, it shows me all the ASM.

But, it DOESNT show me all the ASM, I dont think..o.o
Because when I try to trace the offset/numbers that it gives me when I use my lamp, and I use my lamp again. Nothing pops up, meaning, its not the lamp its tracing.

Or maybe I just have the whole thing wrong, idk.

Then when I tried to change said number in the ASM kit I was given, my whole game screws up.
I assume if it was the flames offset/opcode, then the game would screw up AFTER I use the lamp.

I think im misunderstanding the whole thing, but im trying to figure it out xD
Im pretty determined to learn some ASM, itll allow me to take my game hacking to a whole new level, doesnt matter the game or system (as long as said system has a assembler to work with it o.o; )


Thanks for the support so far though, I really do appreciate it.

That aside I think I could get the hang of everything else easily.
I think everything works like this (example only, and probably a stupid one):
You do action A.
Action A has a pointer that says "Load this ASM from this location"
Then it does, the ASM does something.

and how most ASm patches work I think, is it injects custom ASM into the game, and changes said pointer to load that ASM instead of the original.

My current problem is finding the pointers of what I want..o.o Doesnt seem to be working right.
Right now, as just a test, im trying to get the Lamp to do something different. Anything really(even screw the game over. Which itll probably do at first if I ever get anything to work), as long as its a start. lol..

and wtf D: Im hallucinating. Im seeing random Dinos on the Forum page that wasnt there.

____________________

Anyone mind teaching me ASM? D:
For some reason, although I read guides, somehow I am still confused, but I also understand it a bit more.
Anyway, if youd like to help at all, add me on Frozen2Dream@hotmail.com

Haz
Posted on 06-06-10 04:25 PM Link | Quote | ID: 131789


Fuzz Ball
Level: 64

Posts: 290/956
EXP: 2125025
Next: 89072

Since: 03-02-10
From: Michigan, USA

Last post: 4008 days
Last view: 1939 days
BOMB THOSE DEERDONGOS!!!!!!!!!!!!!!!!!!!

Xenesis
Posted on 06-06-10 04:29 PM Link | Quote | ID: 131790


Level: 46

Posts: 304/416
EXP: 672113
Next: 39661

Since: 02-20-07

Last post: 4384 days
Last view: 3093 days
That's generally because advancing one frame is game specific really. Each game is coded to draw updated graphics once per frame to the various video functions of your particular hardware.

That being said, there's a frame counter somewhere, although unless you're trying for a TAS they're not that helpful I find. :/

For what you just did, a better idea would be to do something like:

-Find the RAM address of Link's Magic Meter
-Set a breakpoint for when the value of the magic meter is changed
-Resume the game and use the lantern. The game will break, as you've used some MP. You might have to watch the code carefully, but it'll likely return from what is a nested subroutine. You can probably find where in the ROM it's getting something (like the value of MP to use). If you can reverse it, you can generally get to the overall function that handles item use or something.

It's a simple place to start

Depending on how you're reading it you can follow it a fair way up. Being an old game, Zelda's likely to have a lot of hardcoded functions.


That aside I think I could get the hang of everything else easily.
I think everything works like this (example only, and probably a stupid one):
You do action A.
Action A has a pointer that says "Load this ASM from this location"
Then it does, the ASM does something.

and how most ASm patches work I think, is it injects custom ASM into the game, and changes said pointer to load that ASM instead of the original.

Yeah, that's pretty much how it works.


My current problem is finding the pointers of what I want..o.o Doesnt seem to be working right.
Right now, as just a test, im trying to get the Lamp to do something different. Anything really(even screw the game over. Which itll probably do at first if I ever get anything to work), as long as its a start. lol..

Make sure you start with simple things like changing the MP something uses, the damage a sword hit or something does - that'll get you familiar with the code so you can actually start figuring out how things work.

Frozen2Dream
Posted on 06-06-10 05:06 PM (rev. 10 of 06-07-10 04:13 AM) Link | Quote | ID: 131791


Octorok
Level: 15

Posts: 5/33
EXP: 13502
Next: 2882

Since: 06-06-10

Last post: 4974 days
Last view: 4961 days
Thing is, whenever link uses something, the game unfreezes and resumes gameplay, and it stops doing a step by step disassemble.
The sway it looks like this works, is you have to click on something to go frame by frame. But it only shows one thing being done at a time. Most of the time its cluttered with trying to load sounds.
When my controller imput goes though, and links lamp goes off, the game unfreezes and I cant catch what opcodes its trying to run.
This could pose a problem later.

But ima try the same thing with health. Just having a enemy run into me requires no imput from me o.o

$06/83A7 CA DEX A:0000 X:0001 Y:0000 P:envMXdizc
That came up the exact same frame as when my heart got cut in half.

Now if I understand this currectly, 83A7 is where the ASM is located, DEX is the opcode its trying to run at that location.

i assume the X:0001 is somehow trying to tell it that 1 piece of HPhas been lost? (half a heart?)

Yet when I set a breakpoint at 83A7, and try to get myself hurt, the game just plays like normal and nothing happens.

Again, I think my problem is im misunderstanding this. xD;
When I look up 83A7 in the ASM kit, it doesnt exist. It exists 83A6 instead.
Sorry if I seem a bit stupid with this.

Found my health though the Find Cheats function though. Located at 7EF36D.
Though I guess thats not the point o.o im trying to find it though the debugger, not that. Meh.


All this makes me wonder how people like MathOnNapkins got the magic meter to glow. It doesnt have any value, nor does it change in a graphical way except for decrease. Im sure ill learn as I go though.

Edit:
Yay im making some progress. I can make link move while doing a spin attack. xD
Kinda buggy. But eh, its progress.

When I learn how to do this well, im going to make it so link can almost fully control the level2 boomerang for a few seconds.

____________________

Anyone mind teaching me ASM? D:
For some reason, although I read guides, somehow I am still confused, but I also understand it a bit more.
Anyway, if youd like to help at all, add me on Frozen2Dream@hotmail.com

MathOnNapkins
Posted on 06-07-10 04:22 AM Link | Quote | ID: 131804


Super Koopa
Level: 62

Posts: 773/842
EXP: 1935502
Next: 49184

Since: 02-19-07
From: durff

Last post: 4488 days
Last view: 4011 days
Posted by Frozen2Dream

On Hyrule Magic, when you click on the ASM Hacks part and click new, it asks for a FSNASM? Can I put any ASM in there? 65816 for example.



I know I have FSNASM somewhere around here, but I've had trouble finding it since you brought up the question. I accidentally run into it on one of my computers every few months XD. I don't use it because I don't generally use Hyrule Magic other than for referencing information.

Posted by Frozen2Dream

So my questions are: Is FSNASM somehow necessary for Lunar Magic/Zelda LTTP ASM Hacks? If so, where can I download the file needed?



FSNASM is only necessary if you want to use Hyrule Magic to patch in ASM changes to your ROM. Myself, I use xkas, which is the most often used assembler for rom hacking (the SMW hacks for example). WLA-DX is another assembler often used to make a game from scratch.

Posted by Frozen2Dream

How can I go about taking appart ASM thats already in a game? Preferably with the ability to tinker and screw with it.



I've got nearly a full disassembly of the game if you want it. It's not fully commented, as the code from the game is massive - many many lines of code. It's hard to teach someone how to reverse engineer. All I can say is it requires persistence. I have most definitely NOT figured out everything in this game but I have some pretty expansive documents on many features of the game availabe.

Posted by Frozen2Dream

My only problem is the Interactive-Disassembler im using (Geigers Snes9x Debugger) didnt seem to have a 'advance one frame, and show the ASM' button that worked right.



You'd want to use tracing for that. It won't show up in the text window in the debugger. Basically you press advance one frame, turn on tracing, then advance one more frame, then turn off tracing. The trace file should be in the directory the rom is at.

Posted by Frozen2Dream

Various ASM questions



There's really too much here to address. Teaching someone ASM is not really appropriate for a thread. You have to be learning to learn some of the stuff on your own, but if you want to ask specific questions via PM, you're more than welcome to.

____________________
Zelda Hacking Forum
hobbies: delectatio morosa

Frozen2Dream
Posted on 06-07-10 04:42 AM (rev. 2 of 06-07-10 05:10 PM) Link | Quote | ID: 131805


Octorok
Level: 15

Posts: 7/33
EXP: 13502
Next: 2882

Since: 06-06-10

Last post: 4974 days
Last view: 4961 days
Thanks. ill just use xkas, and sorry about the overhaul of questions o.o
I dont really have any anymore, because I think I got the hang of ALMOST everything so far.
I mean, I can make link run around while doing a spin attack, thats a start right? xD; Right now im trying to kind of toy with the boomerang to understand it.


And if your talking about the Bank00-19.rtf's. Then yeah, I found them on your site. They have alot of misc stuff for me to look though, which defiantly helps.
If your not talking about that, then yeah, can you send me your disassembly? It may help me more.
Im glad I dont NEED fsnasm for any reason. Its not even on the internet anymore it seems. I wonder why the guy who made Hyrule Magic didnt just go ahead and stach it in with hyrue magic in the first place o.o;..

And i cant get Black Magic to work right D: lol..
But thats not a bother, if it was i would have asked in your forums to begin with.
I see potential with it, ill download it when its a bit less...buggy xD nice work though.

EDIT:
I think im learning pretty quick.
I made the hookshot give you health every time you hit a enemy with it o.o gives me a idea for my hack.
Anyway, thanks for the start guys. Helped a bunch.

____________________

Anyone mind teaching me ASM? D:
For some reason, although I read guides, somehow I am still confused, but I also understand it a bit more.
Anyway, if youd like to help at all, add me on Frozen2Dream@hotmail.com

NetSplit
Posted on 06-18-10 06:03 AM Link | Quote | ID: 132091


Level: 32

Posts: 154/178
EXP: 188031
Next: 18411

Since: 02-26-07

Last post: 2217 days
Last view: 2142 days
Given that FSNASM seems to have fallen off the face of the planet, I've uploaded my copy: http://acmlm.kafuka.org/uploader/get.php?id=3213

I might be remembering wrong, but I think this one is slightly newer than the Hyrule Magic one, allowing you to use tabs without exploding. I don't have a readme for it; I'm not sure if I ever did. The author doesn't seem to have a readme anymore, either. So, I'll go ahead and note down everything I know about it and what I could get from the author last time I talked to him.

Running it on the command line yields:

FSNASM (C) 1999,2001-2002 Sephiroth of Gigasoft
Usage: FSNASM [option] srcfile
Options:
-l: Produce LO-ROM
-o : Select output filename

You can use .b, .w, and .l to be explicit about what version of a particular instruction you want (so, for example, LDA.w). If you don't use those, the assembler will make its best guess.

Commands are: charset, defchar, endb, base, data, block, align, end, code, global, zram, incbin and org

"block" corresponds to resb in nasm
data, code, ram, zram and org define sections
I believe 'end' ends these segments.

defchar "EXAMPLECHARSET" "AZ"=1,"az"=27,"09"=118," "=0,s".'!?:,-;&/"=63,"\n"=129
charset "EXAMPLECHARSET"
;You can use \ to escape, for characters like "

ZRAM corresponds to addresses 0-$1fff i think, or maybe it's 0-$ff

the base directive tells it where the code really is
endb ends the base directive

If you're coding for the NES, you can use org $c00000 to put the code at the beginning of the ROM. With -l (the LoROM option), that would be org $808000

You can use incbin to include data. For example:
incbin "NESFONT.dat"
to include some NESFONT.dat file, which would presumably be your font graphics.

Use dc.x to include data, where x is b, w, or l. Data can be a mix of numbers (hex ($) or dec) and labels (or operations on labels, such as yourlabel-1)


I've used this for NES development before and it works well. I had to do org $c00000 at the start, define the header (example: dc.b "NES",26,2,1,1,0,0,0,0,0,0,0,0,0), base $8000, and then you're ready to code (just be sure to endb, end, and set up your interrupt vectors at the end of the file). You can do variable = $blah to set up your variables. I think labels require a colon after the declaration unless they're naming a table, in which case it's just yourlabel dc.x yourdata.

Hopefully someone finds this useful.

Videogamer555
Posted on 08-31-19 10:17 PM (rev. 2 of 08-31-19 10:19 PM) Link | Quote | ID: 167102

Newcomer
Level: 6

Posts: 2/4
EXP: 560
Next: 347

Since: 11-12-10

Last post: 1439 days
Last view: 1439 days
Posted by NetSplit
Given that FSNASM seems to have fallen off the face of the planet, I've uploaded my copy: http://acmlm.kafuka.org/uploader/get.php?id=3213

I might be remembering wrong, but I think this one is slightly newer than the Hyrule Magic one, allowing you to use tabs without exploding. I don't have a readme for it; I'm not sure if I ever did. The author doesn't seem to have a readme anymore, either. So, I'll go ahead and note down everything I know about it and what I could get from the author last time I talked to him.

Running it on the command line yields:

FSNASM (C) 1999,2001-2002 Sephiroth of Gigasoft
Usage: FSNASM [option] srcfile
Options:
-l: Produce LO-ROM
-o : Select output filename

You can use .b, .w, and .l to be explicit about what version of a particular instruction you want (so, for example, LDA.w). If you don't use those, the assembler will make its best guess.

Commands are: charset, defchar, endb, base, data, block, align, end, code, global, zram, incbin and org

"block" corresponds to resb in nasm
data, code, ram, zram and org define sections
I believe 'end' ends these segments.

defchar "EXAMPLECHARSET" "AZ"=1,"az"=27,"09"=118," "=0,s".'!?:,-;&/"=63,"\n"=129
charset "EXAMPLECHARSET"
;You can use \ to escape, for characters like "

ZRAM corresponds to addresses 0-$1fff i think, or maybe it's 0-$ff

the base directive tells it where the code really is
endb ends the base directive

If you're coding for the NES, you can use org $c00000 to put the code at the beginning of the ROM. With -l (the LoROM option), that would be org $808000

You can use incbin to include data. For example:
incbin "NESFONT.dat"
to include some NESFONT.dat file, which would presumably be your font graphics.

Use dc.x to include data, where x is b, w, or l. Data can be a mix of numbers (hex ($) or dec) and labels (or operations on labels, such as yourlabel-1)


I've used this for NES development before and it works well. I had to do org $c00000 at the start, define the header (example: dc.b "NES",26,2,1,1,0,0,0,0,0,0,0,0,0), base $8000, and then you're ready to code (just be sure to endb, end, and set up your interrupt vectors at the end of the file). You can do variable = $blah to set up your variables. I think labels require a colon after the declaration unless they're naming a table, in which case it's just yourlabel dc.x yourdata.

Hopefully someone finds this useful.


And now your link is dead too. I NEED a copy of FSNASM. Hyrule Magic WILL NOT WORK without it. I just loaded my copy of Zelda:Kamigami No Triforce (Japanese version of A Link to the Past), and tried to load one of the overworld regions, and Hyrule Magic crashed. It needs FSNASM to disassemble the game in order to extract the actual level data. HM provides the user interface, but the real work is done with FSNASM. I Need this. I'm sorry for bringing up such an old post, but I need this program, and you seem to be the only person in existence who has a copy. And your link gives me this error:

Forbidden

You don't have permission to access /uploader/get.php on this server.

blackhole89
Posted on 09-01-19 04:39 AM Link | Quote | ID: 167103


The Guardian
Moloch whose eyes are a thousand blind windows!
Level: 124

Posts: 4181/4196
EXP: 21532868
Next: 303733

Since: 02-19-07
From: Ithaca, NY, US

Last post: 471 days
Last view: 84 days



Sorry, the uploader was down for a few days because of a malware scare we had. NetSplit's link should now work again.

____________________



Main - ROM Hacking - FSNASM and general ASM question. New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.035 seconds. (347KB of memory used)
MySQL - queries: 72, rows: 105/106, time: 0.017 seconds.