Beginner's Guide to Cavestory Assembly

Apr 6, 2010 at 7:55 AM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
Beginner's Guide to Cavestory Assembly

All right, I've written this, and I give this to you in the form of 39 lessons!

Guys, I found something important. On Windows 7 64-bit, OllyDbg 2.00 may not work right (the "Copy to Executable" feature is gone, which is kinda important). To fix this, you must use OllyDbg 2.01 alpha 3 instead. It'll have the "Copy to Executable" feature.

Download:
Beginner's Guide to Cave Story Assembly v2.00
Beginner's Guide to Cave Story Assembly v1.04b
Beginner's Guide to Cavestory Assembly v1.04
Beginner's Guide to Cavestory Assembly v1.03
Beginner's Guide to Cavestory Assembly v1.02
Beginner's Guide to Cavestory Assembly v1.01
Beginner's Guide to Cavestory Assembly v1.00

Mirror Links:
v2.00
v1.04b
v1.04
v1.03
v1.02
v1.01
v1.00

It's a bunch of HTML files that you need to download onto your computer. Open the page "Welcome.html" to begin reading the guide.

Here's a sample of what the guide looks like:

p98407-0-sample.png


I've tried to explain everything as simply as possible (sort of, now it's getting kinda long), to avoid any confusion.

Feel free to point out errors and make suggestions.

This guide isn't finished yet. In the future, I plan to add info about NPC hacking, framerects, calls & procedures/functions, bitwise instructions, logical shift instructions, floating point instructions, optimization, TSC command hacking, bit rotation instructions, rendering, and more. (everything crossed off is already in the guide)

Audio versions of the guide:
Assembly Tutorial Part 1
Assembly Tutorial Part 2
 
Apr 6, 2010 at 9:22 AM
Been here way too long...
"Big Joe Tire and Battery Restaurant! Opening Soon! Eat at Big Joes!"
Join Date: Sep 16, 2009
Location:
Posts: 519
Re: Beginner's Guide to Cavestory Assembly

If this works, I will make mahin mansex you.
 
Apr 6, 2010 at 12:22 PM
Been here way too long...
"Life begins and ends with Nu."
Join Date: Jan 4, 2008
Location: Lingerie, but also, like, fancy curtains
Posts: 3054
Re: Beginner's Guide to Cavestory Assembly

I can help you if you want, but it looks like you're pretty good on your own so far.
 
Apr 6, 2010 at 4:49 PM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
Re: Beginner's Guide to Cavestory Assembly

Lace said:
I can help you if you want, but it looks like you're pretty good on your own so far.

All right. There are definitely some topics that I'm not very clear on, so I may need to ask some questions. I just want to share the info I've already got.
 
Apr 6, 2010 at 8:49 PM
Um... Chosen One? Yeah that'll work. : P
"Keep on rollin'!"
Join Date: Jun 25, 2009
Location:
Posts: 451
Re: Beginner's Guide to Cavestory Assembly

Vercci said:
If this works, I will make mahin mansex you.
Lace said:
I can help you if you want, but it looks like you're pretty good on your own so far.
This is win.
 
Apr 6, 2010 at 11:12 PM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5998
You seem to have a better comprehension of this stuff than I do. It seems to be quite well done so far - I especially like the house analogy :]
 
Apr 7, 2010 at 8:04 PM
Hyperbolic
"What're YOU lookin' at?"
Join Date: Jul 10, 2009
Location:
Posts: 1004
Age: 39
Re: Beginner's Guide to Cavestory Assembly

I am so grateful Carrotlord! Thanks for making this
 
Apr 17, 2010 at 4:43 AM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
Re: Beginner's Guide to Cavestory Assembly

The guide has been updated with 6 new lessons!

Here are the new topics:
-Added more info to OllyDebug Lesson
-Jumps
-Calls and Returns
-Functions
-Math Instructions
-NPC Hacking Info
 
Apr 17, 2010 at 6:10 AM
Only Love, Maximum Love, Forever
"Life begins and ends with Nu."
Join Date: May 6, 2009
Location: somewhere new
Posts: 2137
Age: 29
Re: Beginner's Guide to Cavestory Assembly

Whoa! Just like I asked!:eek:

So I was sitting at the computer one day, and then I thought: "what if carrotlord added more to his guide?" so I sent him a pm, and a few days later, his new guide comes out and there it is!

Hi I'm cultr1 and Beginner's Guide to ASM 1.01 was my idea!

*this message brought to you by thinly disguised windows 7 commercial ripoffs*
 
Apr 18, 2010 at 9:32 AM
Bonds that separate us
Forum Administrator
"Life begins and ends with Nu."
Join Date: Aug 20, 2006
Location:
Posts: 2846
Age: 33
Re: Beginner's Guide to Cavestory Assembly

More amazing stuff. You guys deserve no end of praise for the level of effort you put into making this section as accessible as possible. Sticky :o :o :o
 
Apr 20, 2010 at 11:03 AM
Been here way too long...
"Ha! Ha! Ha! Mega Man is no match for my Mimiga Man!"
Join Date: May 25, 2009
Location: Sweden
Posts: 273
Age: 33
Re: Beginner's Guide to Cavestory Assembly

I have just a faint idea of what Assembly is; but that should squeeze me into your target audience. I'll download it.
 
May 2, 2010 at 5:47 PM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5998
Can you include a section on floating point manipulation? If you want, I can write up some basics since I'm working on figuring out how it goes at the moment. Of special interest would be the fsin and fcos functions...
 
May 2, 2010 at 7:23 PM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
Re: Beginner's Guide to Cavestory Assembly

Noxid said:
Can you include a section on floating point manipulation? If you want, I can write up some basics since I'm working on figuring out how it goes at the moment. Of special interest would be the fsin and fcos functions...

Well, I have no idea how the floating-point system works in assembly, so if you could write up something, that'll be great! It's essentially a way to use numbers with a decimal expansion (so you aren't limited to integers, right?)
 
May 6, 2010 at 3:21 AM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
Re: Beginner's Guide to Cavestory Assembly

All right. Sorry for the double post, but the guide has been updated to the v1.02 version!

Version 1.02
-Lots of floating-point information
-Table of contents appearance has been changed
-Hex lesson is slightly more clear. Also other minor changes.
-Even more NPC hacking (still not done yet though)
-Negative numbers guide and using IDIV with negative numbers (CDQ)
-Basic Optimization guide
-Fixed more grammar issues
-More people are mentioned on about page

The special feature this time is the floating-point stuff, with 3 whole lessons. If you never use those floating-point instructions, perhaps you should take a look at this.
 
May 6, 2010 at 3:54 AM
Been here way too long...
"Life begins and ends with Nu."
Join Date: Jan 4, 2008
Location: Lingerie, but also, like, fancy curtains
Posts: 3054
Re: Beginner's Guide to Cavestory Assembly

Just checked this out and a sorta important note on functions: while all functions in cs start w/ push ebp blablabla, this is not necessary for a function to work (ie, in hacker made functions). What it's doing is creating a new section in the stack exclusively for the function, mostly so functions don't mess with eachother. Of course, when you want functions to be directly in eachother ramspace (like if you're making curlz shoot other entities), you would leave out all of that.

Bit of a nitpick, but you can't breed a new generation of assemblers that think functions need to be made a certain way when they don't.
 
May 6, 2010 at 11:32 PM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
Re: Beginner's Guide to Cavestory Assembly

Is this what you're trying to get at?

Code:
Regular functions:

functionA:
PUSH EBP
MOV EBP,ESP
SUB ESP,(something)    ;allocate local memory
...
PUSH (argument)
PUSH (argument)
CALL (functionB)
...
MOV ESP,EBP
POP EBP
RETN

functionB:
PUSH EBP
MOV EBP,ESP
SUB ESP,(something)
...
MOV ESP,EBP
POP EBP
RETN

versus

Code:
Hacker Made functions:

functionA:
PUSH EBP
MOV EBP,ESP
SUB ESP,(something)    ;allocate local memory
...
CALL (functionB)
...
MOV ESP,EBP
POP EBP
RETN

functionB:
MOV [EBP+8],(something)   ;mess with argument1 of functionA directly
MOV [EBP-4],(something)   ;mess with local data
...
(do other stuff)
...
RETN

If not, then I'm not sure. Maybe I should be more clear on how the stack works with ESP and EBP.
 
May 7, 2010 at 1:00 PM
Banned
"Bleep, Bloop, Bleep, Bloop"
Join Date: Mar 1, 2009
Location:
Posts: 1587
Age: 28
Re: Beginner's Guide to Cavestory Assembly

Lace said:
Bit of a nitpick, but you can't breed a new generation of assemblers that think functions need to be made a certain way when they don't.

>implying that all across the world people arent taught the exact same way

Seriously, Lace. I know it's not the best way to help somebody learn something completely new, but the excuse has always been "we're doing it this way so it's easier to do correctly later." Not exactly the best excuse, and it's not usually that valid, but I and a few people I know have always been able to pick up on this and figure out that somewhere along the line, somebody lied. I can't say it really does help, but he's trying, isn't he?
 
May 7, 2010 at 10:27 PM
Been here way too long...
"Life begins and ends with Nu."
Join Date: Jan 4, 2008
Location: Lingerie, but also, like, fancy curtains
Posts: 3054
Re: Beginner's Guide to Cavestory Assembly

I can't truthfully say I fully understand you fire, but yes.
It's a good practice, anyways.


Carrot, it was in the NPC section.
 
May 8, 2010 at 1:38 AM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
Re: Beginner's Guide to Cavestory Assembly

Lace said:
I can't truthfully say I fully understand you fire, but yes.
It's a good practice, anyways.


Carrot, it was in the NPC section.

Yeah, I know it was in the NPC section. The title is called "Building Your Own Function", and that probably wasn't the best title. The point of that section is so that people would understand why Cavestory uses PUSH EBP... MOV EBP, ESP.. and so on, not exactly on how to make your own function and use it for your own purposes.

I do agree that I should be more clear on the fact that it is certainly not the only way to build a function.

@Fire: From the way you worded it, I don't think I fully understand what you mean.
Indeed, the guide right now does use lots of "simplifications", especially when explaining the stack. Instead of trying to explain every freaking detail and confusing the heck out of people, I go with the simple explanation.

So, the correct label might be: "some of this stuff technically isn't true, but it's easier to understand this way: ..."
Of course, you could call it lying, but whatever.

-----
Oh yeah, I do plan to fix that part about functions. Do you guys want anything specific added to the guide to clarify the situation about functions? If not, I'll just do it based on what Lace said and what I'm assuming he wants.

EDIT: Fixed it in v1.03, I guess.
 
Jun 22, 2010 at 12:06 AM
Banned
"Master using it, and you can have this!"
Join Date: Jan 2, 2010
Location: Behind you, holding a gun, aimed at your head. *bo
Posts: 88
Re: Beginner's Guide to Cavestory Assembly

thecrown said:
Vercci said:
If this works, I will make mahin mansex you.

Lace said:
I can help you if you want, but it looks like you're pretty good on your own so far.

This is win.

Sorry if late, but... ToTaLLy!
 
Top