Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
1 user currently in Super Mario World hacking: labmaster | 3 guests
Acmlm's Board - I2 Archive - Super Mario World hacking - Subroutines in Super Mario World
  
User name:
Password:
Reply:
 

UserPost
blackhole89
Posts: 701/971
Actually, assembler programming isn't all that hard if you have a proper macro assembler which supports labels and stuff. The most annoying twist about assembler coding as we know it is that, if we want to insert anything to already present code, we either have to build hooks or recalculate tons of pointers with unpredictable results.
Back in DOS ages, people used to write even rather large projects in MASM or TASM, as program size and speed mattered a lot more by then.
francois
Posts: 7/9
Originally posted by Kyouji Craw
Yeh. They didn't start writing in higher-level languages until the N64.


That's interesting! So to make a game like Super Mario World in assembly would have been quite a task, right? I guess because of the slowness of both the NES and SNES I guess C would have been too slow. Is it even possible to make assembly programming feel like object-oriented programming? Would object-oriented programming even be necessary for a game like Super Mario World?
Alastor the Stylish
Posts: 6485/7620
Yeh. They didn't start writing in higher-level languages until the N64.
knuck
Posts: 1264/1818
Uh, most if not all NES games were written in pure assembly. I think that most SNES games were too.
francois
Posts: 3/9
Originally posted by Darth Mole
Originally posted by francoispress
Originally posted by FloBo
@darth mole: Uhm,... about tracing, I think there are quite many motivated hackers who just don't know how to trace efficiently.. me included. If I want to trace, I try something. And I don't succeed. Then again, I try, and nothing seems to work. When I finally get a Tracelog (like once D4S created for my Lufia-issues), I seem to be so confused that I can't get any idea on how to interpret what happens during that code-segment...

Are there no simple tutorials about how to trace data with geigers SNES-debugger?! I really do want to learn how to handle this.... But seems like I'm just too stupid...


Assembly is a bitch. That's why I never took to machine code. Has anyone disassembled
Super Mario World sucessfully? Is there anything in that code that looks like a subroutine?
I wonder if Nintendo's programmers used assembly when making Super Mario World. Do you think they also could have used C?


Yeah, there is. In fact, every time you see a JSR / JSL instruction, you know is a subroutine (unless, of course, you were unlucky and disassembled a piece of something that was no 65c816 machine code, like, graphics data).
Disassembling, tracing, writing your own assembly code etc. is the everyday work of an ambitioned SMW hacker, you know.
As for C, I am not sure. Chances there are they did, but even if it is the case, they used an extremely optimizing compiler so, in most cases, chances to recover C code are not present.
Yet, there actually are some places in the coede that look like they originally weren't written in assembly. A good example for this is the sprite handler sub-fork routine (noticed that, in mw reconfigurator, many entirely different sprites had the same handler routine pointer?). Every sane asm programmer would have placed a location table somewhere in ROM and done indirect jumps to the actual routines. However, this piece of code looks like this:

CMP #$12
BNE #$04
JSL $123456
CMP #$13
BNE #$04
JSL $789ABC
CMP #$14
BNE #$04
...

or, transscripted as it would look like in C:

if(sprite_id==0x12) HandlerRoutine12h();
else if(sprite_id==0x13) HandlerRoutine13h();
else if(sprite_id==0x14) ...

Note that, in C code, this just looks like the work of a lazy programmer, while in assembler, the lazy programmer certainly would have chosen the pointer table variant (as it is significantly easier to code).

(This piece of code, actually, is one of the locations I am currently rewriting to make SMW capable of handling more sprites at a time. While d4s just patched most of the time-critical routines to FastROM (thus making the processor frequency the 65c816 runs at itself increase locally), I am (also) optimizing the actual SMW code by cleaning up useless process cycle wastes like this)

Geiger/Evil Peer's SNES9x tracer is mostly self-explaining. What you simply should do is:
- setting a "start address" and an "end address" in one of the dialog boxes of the "Trace Menu"
- pausing the game and clicking on "Trace" in the same menu when you reached the position you want to trace at
The tracer will wait until the 65c816 executes the code at the "start address" the first time, dump some few previously executed instructions and continue dumping every instruction executed until it reaches the "end address".




Hmm... I did think that Super Mario World was written in C. Who in their right mind would write a game like that solely in assembly?
blackhole89
Posts: 700/971
Originally posted by francoispress
Originally posted by FloBo
@darth mole: Uhm,... about tracing, I think there are quite many motivated hackers who just don't know how to trace efficiently.. me included. If I want to trace, I try something. And I don't succeed. Then again, I try, and nothing seems to work. When I finally get a Tracelog (like once D4S created for my Lufia-issues), I seem to be so confused that I can't get any idea on how to interpret what happens during that code-segment...

Are there no simple tutorials about how to trace data with geigers SNES-debugger?! I really do want to learn how to handle this.... But seems like I'm just too stupid...


Assembly is a bitch. That's why I never took to machine code. Has anyone disassembled
Super Mario World sucessfully? Is there anything in that code that looks like a subroutine?
I wonder if Nintendo's programmers used assembly when making Super Mario World. Do you think they also could have used C?


Yeah, there is. In fact, every time you see a JSR / JSL instruction, you know is a subroutine (unless, of course, you were unlucky and disassembled a piece of something that was no 65c816 machine code, like, graphics data).
Disassembling, tracing, writing your own assembly code etc. is the everyday work of an ambitioned SMW hacker, you know.
As for C, I am not sure. Chances there are they did, but even if it is the case, they used an extremely optimizing compiler so, in most cases, chances to recover C code are not present.
Yet, there actually are some places in the coede that look like they originally weren't written in assembly. A good example for this is the sprite handler sub-fork routine (noticed that, in mw reconfigurator, many entirely different sprites had the same handler routine pointer?). Every sane asm programmer would have placed a location table somewhere in ROM and done indirect jumps to the actual routines. However, this piece of code looks like this:

CMP #$12
BNE #$04
JSL $123456
CMP #$13
BNE #$04
JSL $789ABC
CMP #$14
BNE #$04
...

or, transscripted as it would look like in C:

if(sprite_id==0x12) HandlerRoutine12h();
else if(sprite_id==0x13) HandlerRoutine13h();
else if(sprite_id==0x14) ...

Note that, in C code, this just looks like the work of a lazy programmer, while in assembler, the lazy programmer certainly would have chosen the pointer table variant (as it is significantly easier to code).

(This piece of code, actually, is one of the locations I am currently rewriting to make SMW capable of handling more sprites at a time. While d4s just patched most of the time-critical routines to FastROM (thus making the processor frequency the 65c816 runs at itself increase locally), I am (also) optimizing the actual SMW code by cleaning up useless process cycle wastes like this)

Geiger/Evil Peer's SNES9x tracer is mostly self-explaining. What you simply should do is:
- setting a "start address" and an "end address" in one of the dialog boxes of the "Trace Menu"
- pausing the game and clicking on "Trace" in the same menu when you reached the position you want to trace at
The tracer will wait until the 65c816 executes the code at the "start address" the first time, dump some few previously executed instructions and continue dumping every instruction executed until it reaches the "end address".

HabsoluteFate
Posts: 155/179
Originally posted by Smallhacker
What happened to the SMW Open Source Project, by the way?


Surprisingly enough lack of interest although it's somewhat become the Super Mario World Dev Environment.

I'm still working on that one but things have been crazy and i've had to put it aside for the last 3 weeks...I don't intend on giving up on it though...i have some bug fixes for the latest feature to take care of and a new version will be releases shortly afterwards....

i dont have a timeline as to when the next release will come out though...
MathOnNapkins
Posts: 1833/2189
Yes, but the disassembled "subroutines" are in assembly, which you hate so much. d4s's answer is very sarcastic tongue-in-cheek.

Either way, it would be pretty pointless to convert them to, say, VB style routines or C style routines b/c you usually have to interpret the assembly yourself to figure out what it should say in C, or VB. No program could do that for you or it would already exist.

It might get some things right but it would not accurately capture the semantics. BCC and BCS operations in particular are cryptic in assembly, and don't easily translate to if - else statements directly unless you know what the assembly code is doing.

Anyone who wants to alter snes game code will need to learn assembly, there is no way around it.
d4s
Posts: 212/325
Originally posted by francoispress


Has anyone disassembled
Super Mario World sucessfully? Is there anything in that code that looks like a subroutine?



yes!
maybe about 1000 of them.
francois
Posts: 1/9
Originally posted by Smallhacker
What happened to the SMW Open Source Project, by the way?


Super Mario World open source? I never heard of it.
Smallhacker
Posts: 1630/2273
What happened to the SMW Open Source Project, by the way?
francoispress
Posts: 30/30
Originally posted by FloBo
@darth mole: Uhm,... about tracing, I think there are quite many motivated hackers who just don't know how to trace efficiently.. me included. If I want to trace, I try something. And I don't succeed. Then again, I try, and nothing seems to work. When I finally get a Tracelog (like once D4S created for my Lufia-issues), I seem to be so confused that I can't get any idea on how to interpret what happens during that code-segment...

Are there no simple tutorials about how to trace data with geigers SNES-debugger?! I really do want to learn how to handle this.... But seems like I'm just too stupid...


Assembly is a bitch. That's why I never took to machine code. Has anyone disassembled
Super Mario World sucessfully? Is there anything in that code that looks like a subroutine?
I wonder if Nintendo's programmers used assembly when making Super Mario World. Do you think they also could have used C?
FloBo
Posts: 52/101
@darth mole: Uhm,... about tracing, I think there are quite many motivated hackers who just don't know how to trace efficiently.. me included. If I want to trace, I try something. And I don't succeed. Then again, I try, and nothing seems to work. When I finally get a Tracelog (like once D4S created for my Lufia-issues), I seem to be so confused that I can't get any idea on how to interpret what happens during that code-segment...

Are there no simple tutorials about how to trace data with geigers SNES-debugger?! I really do want to learn how to handle this.... But seems like I'm just too stupid...
blackhole89
Posts: 699/971
If you want to receive further information, you might also try to directly PM one of the board's resident SMW assembly geeks (BMF, HyperHacker, mikeyk, HabsoluteFate, myself, ... sorry if I forgot anyone). All of us are familiar with tracing (or so I think), so you also stand a good chance to find out what you want when asking for something that is not known yet.
Sukasa
Posts: 567/1981
No, very little of it has been mapped. look in the ROM locations thread for any routines that have been mapped, as well as a non-stickied "the ASM locaton thread".
francoispress
Posts: 18/30
Has anyone decoded any of the subroutines in Super Mario World, like the ones related to collision detection or drawing of the sprite or any other possible operations not specifically related to hardware but to the game itself?
Acmlm's Board - I2 Archive - Super Mario World hacking - Subroutines in Super Mario World


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.035 seconds.