The Mimiga Hero

Oct 23, 2018 at 8:01 AM
Junior Member
"It's dangerous to go alone!"
Join Date: Nov 30, 2017
Location:
Posts: 39
Age: 18
#21
3. The face was done for me, so I had little to edit. Besides. A little humor couldn't hurt.
7 & 8. Good idea.
9. I guess I can do that.
11. Already did. Though I need to figure out how to make him say something differant after the first time you talk to him.
25. Eh. I wanted to change it.
28 b. It would.....but maybe in a later update I can try my hand at it.
28 c. That was about Sue in tbe Cage. Though, to answer what you said. Maybe.... But more likely if I were to folllow through with the resavor idea, Toroko would be running and knocking down king again before Quote can even ask what's even going on

29. There used to be a set of stairs. You see the hanging blocks. There used to be stairs till something caused the stairs to collapse. King assumes it was some kind of earthquake. But it could be something else....

Oh and I thought you ment assembly hall. To answer that, no thanks. I got it.
 
Oct 23, 2018 at 2:38 PM
Perfectionist
CS Beta Content Discord Admin
CSE Discord Moderator
"Bleep, Bloop, Bleep, Bloop"
Join Date: Dec 26, 2014
Location: the back of their own hand.
Posts: 1594
Age: 119
#22
3. The face was done for me, so I had little to edit. Besides. A little humor couldn't hurt.
Of course not! It was just a little confusing.
9. I guess I can do that.
You don't have to, but I believe that it would improve the mod.
11. Already did. Though I need to figure out how to make him say something different after the first time you talk to him.
For that you need to set a flag.
<FL+xxxx will set flag xxxx. There are 8000 flags available. You can use Booster's Lab to generate a flag list if you have it, just to make sure the flag you're using isn't in use.
<FLJxxxx:yyyy will jump to event #yyyy if flag xxxx is set.
<FL-xxxx will unset flag xxxx.
Also, in an NPC with "disappear if flag ID set" will set the flag in its flag ID when it dies. (it took me forever to figure that one out :debug:)

25. Eh. I wanted to change it.
Nonono, what I meant is that you don't have to change it from what you made it.
28 b. It would.....but maybe in a later update I can try my hand at it.
Again, I can help you if you'd like. Making something like that could be pretty time consuming and/or require learning how to NPC edit.
29. There used to be a set of stairs. You see the hanging blocks. There used to be stairs till something caused the stairs to collapse. King assumes it was some kind of earthquake. But it could be something else....
Ah. Well, it wouldn't hurt to change those blocks slightly to convey that idea better. Even if that's how you interpreted the original structure, others may not. Doesn't have to be much, you could just put a couple of broken-off stair tiles up there. Be forewarned however that if you use slopes, people can clip through the bottom and sides of them if they are not covered by a solid tile. (i.e. they're only solid on the top)
Oh and I thought you meant assembly hall. To answer that, no thanks. I got it.
Maybe you don't quite know what an assembly edit is? I guess I'll go into it then...
It involves editing the machine code within the executable file itself, rather than any external files (tsc scripts, maps, images, etc.), although utilising it does allow you to change it.
The most simple NPC in Cave Story (NPC 0, "NULL") looks like this:

Code:
Address   Hex dump            Command                                                             Comments
00426530      55              PUSH EBP
00426531      8BEC            MOV EBP,ESP
00426533      83EC 10         SUB ESP,10
00426536      C745 F0 0000000 MOV DWORD PTR SS:[EBP-10],0
0042653D      C745 F4 0000000 MOV DWORD PTR SS:[EBP-0C],0
00426544      C745 F8 1000000 MOV DWORD PTR SS:[EBP-8],10
0042654B      C745 FC 1000000 MOV DWORD PTR SS:[EBP-4],10
00426552      8B45 08         MOV EAX,DWORD PTR SS:[EBP+8]
00426555      8378 74 00      CMP DWORD PTR DS:[EAX+74],0
00426559      75 25           JNE SHORT 00426580
0042655B      8B4D 08         MOV ECX,DWORD PTR SS:[EBP+8]
0042655E      C741 74 0100000 MOV DWORD PTR DS:[ECX+74],1
00426565      8B55 08         MOV EDX,DWORD PTR SS:[EBP+8]
00426568      837A 4C 02      CMP DWORD PTR DS:[EDX+4C],2
0042656C      75 12           JNE SHORT 00426580
0042656E      8B45 08         MOV EAX,DWORD PTR SS:[EBP+8]
00426571      8B48 0C         MOV ECX,DWORD PTR DS:[EAX+0C]
00426574      81C1 00200000   ADD ECX,2000
0042657A      8B55 08         MOV EDX,DWORD PTR SS:[EBP+8]
0042657D      894A 0C         MOV DWORD PTR DS:[EDX+0C],ECX
00426580      8B45 08         MOV EAX,DWORD PTR SS:[EBP+8]
00426583      83C0 54         ADD EAX,54
00426586      8B4D F0         MOV ECX,DWORD PTR SS:[EBP-10]
00426589      8908            MOV DWORD PTR DS:[EAX],ECX
0042658B      8B55 F4         MOV EDX,DWORD PTR SS:[EBP-0C]
0042658E      8950 04         MOV DWORD PTR DS:[EAX+4],EDX
00426591      8B4D F8         MOV ECX,DWORD PTR SS:[EBP-8]
00426594      8948 08         MOV DWORD PTR DS:[EAX+8],ECX
00426597      8B55 FC         MOV EDX,DWORD PTR SS:[EBP-4]
0042659A      8950 0C         MOV DWORD PTR DS:[EAX+0C],EDX
0042659D      8BE5            MOV ESP,EBP
0042659F      5D              POP EBP
004265A0      C3              RETN
I guess I'll break it down a bit. Since, if you know what's going on here on some level then you can realise that it's a lot less scary than it looks. (I mean seriously, 2 years ago from today I found assembly code to be the most intimidating shit ever)

PUSH EBP
MOV EBP,ESP
Basically, this "saves the stack location" for later. The "stack" is a large piece of readily accessible memory, and these two operations make sure that the function that this function was called from can resume properly.
--------
SUB ESP,10
This operation will subtract 16 from ESP. This means that we have room for 4 variables on the stack, each of them four bytes (a "DWORD") in size.
>"What's a DWORD??!"
Double word.
A bit is a single 1 or 0.
A byte is 8 bits.
A word is 2 bytes.
A Dword is 2 words.
>"Why is it called SUB?"
SUB is short for "subtract." It will subtract the second thing from the first. The first being ESP, the second being 10.
>"But it says '10', why does it subtract 16?"
Ah, that's because the '10' is in hexadecimal, or base 16. Our usual counting system is decimal, or base 10. Hexadecimal numbers can be represented by affixing an "h" to the end of them, or a "0x" to the start. Like: "0x10"
In hexadecimal, because it's base 16, the 16th number is "10." So we have 1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,10 instead of 1,2,3,4,5,6,7,8,9,10.
Some examples:
10 in hex(adecimal) is 16 in dec(imal)
20 in hex is 32 in dec.
64 in hex is 100 in dec.
100 in hex is 256 in dec.
>Okay. What is "ESP"?
ESP stands for Extended Stack Pointer. There's also SP (Stack Pointer), which is just 16 bits smaller. As in the name, it's a pointer to the location in the stack where things will be put when you use "PUSH," or similar.

--------
MOV DWORD PTR SS:[EBP-10],0
MOV DWORD PTR SS:[EBP-0C],0
MOV DWORD PTR SS:[EBP-8],10
MOV DWORD PTR SS:[EBP-4],10
Okay! These four operations set the variables that will eventually set the "framerects" for the NPC. The NPC uses the spritesheet NpcSym.pbm.
>What's a framerect?
Well, a framerect is specified by 4 numbers. These numbers are coordinates on the spritesheet that the game uses to render the NPC.
The first number is how far from the left side of the image the sprite starts.
The second is how far from the top of the image the sprite starts.
The third, how far from the left side of the image the sprite ends.
The fourth, how far from the top of the image the sprite ends.
Or, LeftUpRightDown.
This NPC uses 0,0 to 16,16 on NpcSym.pbm, which is just empty... therefore the NPC is invisible unless you put something there. Why does it render anything at all? Because Pixel used to have a temporary sprite in that place in order to debug the game.
>What's MOV?
MOV means move. It will move the contents of the second specified thing into the first.
>Sooo what's PTR SS[EBP-??]
PTR means pointer. You literally don't even need to write this, and it's completely redundant by all accounts.
SS: means stack segment, basically it's looking for data in the stack rather than in memory somewhere.
[EBP-x]... the square brackets mean that the value of EBP isn't what's being changed to 0, what it means EBP is being used as a pointer to a location, in this case the stack, as specified by SS:.
The "-10/C/8/4" just means that it's looking at the address specified by EBP... minus... that number. This is used to read/write to those variables that we allocated space for earlier.

--------
MOV EAX,DWORD PTR SS:[EBP+8]
This sets EAX to whatever's in [EBP+8].
[/b]>What's EAX?!
Aha! EAX is a "Dword sized data register." Basically, it can be used for whatever you like, it's just a really convenient temporary storage location. "EAX" means "Extended Accumulator ... X" ... X is supposed to mean "pair," because the word sized "AX" (Accumulator Pair) is a combination of the two byte sized registers: AL and AH. (Accumulator Low and Accumulator High) Yes, that sounds pretty complicated, but it's basically just trivia that you don't exactly need to know.
>What's in [EBP+8] then??!
Alright, this is pretty important. [EBP+8] is the first argument that was pushed when this function was called. For all NPCs, [EBP+8] should be the pointer to that NPC's allocated memory. This contains everything from their current framerects, to their health, to the sound they make when hurt, and pretty-much any other information that they need to have; like where they are on the map, etc.
X = a register that contains [EBP+8].
alive=[X]
collisionFlags=[X+4]
xCoord=[X+8]
yCoord=[X+C]
xVelocity=[X+10]
yVelocity=[X+14]
xVelocityAgain=[X+18]
yVelocityAgain=[X+1C]
savedXposition=[X+20]
savedYposition=[X+24]
aiNumber=[X+28]
flagID=[X+2C]
eventNumber=[X+30]
spritesheetID=[X+34]
hurtSound=[X+38]
deathSound=[X+3C]
health=[X+40]
weaponEnergy=[X+44]
deathGraphic=[X+48]
direction=[X+4C]
flags=[X+50]
displayRectL=[X+54]
displayRectU=[X+58]
displayRectR=[X+5C]
displayRectD=[X+60]
frameTimer=[X+64]
frameNum=[X+68]
objectTimer=[X+6C]
directive=[X+70]
scriptState=[X+74]
scriptTimer=[X+78]
hitboxRectL=[X+7C]
hitboxRectU=[X+80]
hitboxRectR=[X+84]
hitboxRectD=[X+88]
xOffset=[X+8c]
yOffset=[X+90]
width=[X+94]
height=[X+98]
hitTrue=[X+9C]
damageTaken=[X+A0]
damage=[X+A4]
parent=[X+A8]
Now, Cave Story's code has a furious obsession with moving this pointer into different registers as frequently as possible. As such, for all other occurrences of it I shall not be mentioning it.
It will also use EDX and ECX.
EDX = Extended Data X
ECX = Extended Counter X
Again, they're data registers and can be used for basically whatever.

--------
CMP DWORD PTR DS:[EAX+74],0
Okay, this subtracts 0 from [X+74], and then sets a bunch of flags based on the result (but doesn't change [EAX+74]!). These flags are used in conditional jumps, similar to the sorts of flags used in Cave Story, but the way they behave and are stored is completely different.
>What's [X+74]?
It's the script state of the NPC. In this case, it's used to see whether the NPC has already moved or not, because the NULL NPC moves down by a whole tile if its direction is 2. The script state of an NPC can be set by using <ANP.[/b]
--------
JNE SHORT 00426580
This jumps to 00426580 if the result of that CMP was NOT equal to 0.
[/b]>What's "SHORT"?
It's to differentiate between the two different types of jumps, one of which is much larger but allows you to go much further.
>Where's 00426580?
It can be seen on the listing above, on the far left. (try CTRL+F if you're lost)

--------
MOV DWORD PTR DS:[ECX+74],1
Sets the script state to 1. This is a really space-inefficient way of doing this, but whatever.
Basically, these last three operations ensure that the next bit of code is only run once, except for 426580 and beyond.

--------
CMP DWORD PTR DS:[EDX+4C],2
We already know what a CMP does. [X+4C] is the NPC's direction. This checks to see if the direction is 2 in the first place, like I said earlier.
--------
JNE SHORT 00426580
Sure enough, if [X+4C] isn't 2 it just skips on to 00426580 anyway.
--------
MOV ECX,DWORD PTR DS:[EAX+0C]
[X+C] is the NPC's Y position. This just puts it in to one of our data registers for us to mess with it.
--------
ADD ECX,2000
This will add 0x2000 (8192 dec) to the value.
[/b]Why does it add so much to it?
Well, what it wants to do is add 16 pixels (1 tile) to the NPC's Y position. In Cave Story, X and Y coordinates are stored with huge numbers... for some reason. 0x200 (512 dec) is the value of one pixel. 0x2000 is the value of 16 pixels.

-------
MOV DWORD PTR DS:[EDX+0C],ECX
[/b]Then it just puts the value into [X+C]. If you took out this operation then nothing would actually happen when you set its direction to 2.
You can also achieve the same result as these three operations in one operation:
SUB DWORD PTR DS:[X+0C],2000[/b]
--------
MOV EAX,DWORD PTR SS:[EBP+8]
ADD EAX,54
It's adding directly to the NPC data pointer?!
Yep! That it is. Basically, from now until EAX is set to something else, EAX = X + 54.
So if we used [EAX+4], it would be the same as using [EAX+58].
I don't know why the game even does this, because just using [EAX+58] directly wouldn't take any more space.

--------
MOV ECX,DWORD PTR SS:[EBP-10]
So now it's getting out that variable that we set before, and putting it into ECX. I wonder what's next?
--------
MOV DWORD PTR DS:[EAX],ECX
Well what do you know! It's setting [X+54] (the left framerect for the NPC) to the left framerect variable that we set before.
Basically, that variable that we set before was totally useless, and the game could have just directly moved the values into [X+54],etc... but it's stupid.

--------
MOV EDX,DWORD PTR SS:[EBP-0C]
MOV DWORD PTR DS:[EAX+4],EDX
MOV ECX,DWORD PTR SS:[EBP-8]
MOV DWORD PTR DS:[EAX+8],ECX
MOV EDX,DWORD PTR SS:[EBP-4]
MOV DWORD PTR DS:[EAX+0C],EDX
Then it rinses and repeats for the top, the right side, and the bottom.
--------
MOV ESP,EBP
You know how we had "MOV EBP,ESP" before? Well this undoes that, which is okay because this is code to start exiting the function.
--------
POP EBP
Remember that the first operation was "PUSH EBP"? I kinda glossed over it, but POP will take something that you PUSHed onto the stack, and put it into the specified location, which is EBP.
TL;DR it restores EBP to what it was at the start.
These two operations can be replaced by once operation -- "LEAVE" -- but Cave Story's compiling is intentionally verbose.

--------
RETN
This operation returns us to the previous function, now that we have reset EBP and ESP. (if this was used before the previous two operations, the game would probably crash)
--------
And that's it! That's the whole thing.
That took me a whole hour to write out, although it felt like two to be honest.
I hope that you were able to learn something. If you want to try messing around with that code, or removing some of it, you'll need a copy of OllyDbg (or some other debugger). I recommend Thomas Xin's version. It has helpful colour coding, and a few bugfixes.
Once you open it, open your Doukutsu.exe, then press CTRL+G to open the "go to address" window. Paste in the address of NPC 0, 00426530, and press ENTER/RETURN on your keyboard.
Here's Thomas Xin's guide, which may be of help should you desire to do anything more with assembly.
And here's Thomas Xin's NPC list, which is the definitive list of every NPC in Cave Story, including its number and location in the code.
 
Oct 23, 2018 at 2:44 PM
Junior Member
"It's dangerous to go alone!"
Join Date: Nov 30, 2017
Location:
Posts: 39
Age: 18
#23
Thank you!

And yes I did not know


Say zxin, do you know how to change the credit pics? I followed the instructions on booster's lab but when I replace them they are blank
 
Last edited by a moderator:
Oct 23, 2018 at 6:45 PM
Perfectionist
CS Beta Content Discord Admin
CSE Discord Moderator
"Bleep, Bloop, Bleep, Bloop"
Join Date: Dec 26, 2014
Location: the back of their own hand.
Posts: 1594
Age: 119
#24
Say zxin, do you know how to change the credit pics? I followed the instructions on booster's lab but when I replace them they are blank
What does your script and casts.pbm look like?
 
Oct 23, 2018 at 6:56 PM
Junior Member
"It's dangerous to go alone!"
Join Date: Nov 30, 2017
Location:
Posts: 39
Age: 18
#25
That's not the problem. The credit pics. Such as the one with Ballos screaming or Quote versus the Undead Core.
 
Oct 23, 2018 at 11:49 PM
Best elf
"Life begins and ends with Nu."
Join Date: Jun 27, 2013
Location: Cygnus
Posts: 2225
Age: 25
#26
You have to open the mod with Resource Hacker and under the BITMAP folder, that's where you'll find the Credits images. If you click on "Replace bitmap", you'll be able to replace the credits images with the files you'd like to use
 
Oct 24, 2018 at 1:12 AM
Junior Member
"It's dangerous to go alone!"
Join Date: Nov 30, 2017
Location:
Posts: 39
Age: 18
#27
I did that! But the image would be blank. (Even with the right format and size) and there will be a pink star
 
Oct 25, 2018 at 6:31 PM
Junior Member
"It's dangerous to go alone!"
Join Date: Nov 30, 2017
Location:
Posts: 39
Age: 18
#28
Update:
Thanks to a little help from zxin. I was able to add more flags and make Toroko running away more sense.
Also Quote no longer looks like he's staring into the forth wall....I think.
Also got rid of the little jingle when you interact with a life capsule because you guys don't like it... guess I was too much a jerk.
anyway the link to the Dropbox is in the original post because Dropbox do me a favor by not having to set up new links when I update.
as always, come to me with bugs or ideas so I can fix them


Will there be a resorvar (Fuck my spelling) boss fight? maybe in the future.
Can you save Toroko?


*Whistles*
 
Last edited by a moderator:
Oct 25, 2018 at 6:44 PM
Senior Member
"Huzzah!"
Join Date: Nov 21, 2017
Location: From a far, far away galaxy.
Posts: 208
Age: 15
#29
Other way then the 4 ending ?
 
Oct 30, 2018 at 4:41 PM
Junior Member
"It's dangerous to go alone!"
Join Date: Nov 30, 2017
Location:
Posts: 39
Age: 18
#32
I need help......
No matter what I do I can't seem to get it to work, I followed Booster's Lab instrustions, MisterDestroyer's Instrustions, Replace image, make them the right format, right size, right- UGH!
So I ask someone who can do this, because at this point I'm wondering if my computer is just retarded... to replace the credit pictures...
if you are interested to help, let me know and I'll send them to you.
 
Oct 30, 2018 at 4:45 PM
Senior Member
"Huzzah!"
Join Date: Nov 21, 2017
Location: From a far, far away galaxy.
Posts: 208
Age: 15
#33
Dude, it was simple, you export the credit pic, copy and paste mine on it then replace them.
Guess I'll be doing it then, send me you're last updates(if there some changes of course) and I'll do it
 
Oct 30, 2018 at 4:49 PM
Junior Member
"It's dangerous to go alone!"
Join Date: Nov 30, 2017
Location:
Posts: 39
Age: 18
#34
Dude, it was simple, you export the credit pic, copy and paste mine on it then replace them.
Guess I'll be doing it then, send me you're last updates(if there some changes of course) and I'll do it
It's called My computer's retarded and so am I.
In seriousness though thank you


UPDATE
Finally! the credit pictures have been added. thank you Mister Destroyer for that.
anyway, thank you so much for checking out this mod. 509 views is amazing for me. But of course there will be more updates to come.
Always come to me if you have suggestions or problems. I will listen to you guys and love hearing from you.
link is at the top.
 
Last edited by a moderator:
Oct 31, 2018 at 3:24 AM
Perfectionist
CS Beta Content Discord Admin
CSE Discord Moderator
"Bleep, Bloop, Bleep, Bloop"
Join Date: Dec 26, 2014
Location: the back of their own hand.
Posts: 1594
Age: 119
#35
It's called My computer's retarded and so am I.
In seriousness though thank you


UPDATE
Finally! the credit pictures have been added. thank you Mister Destroyer for that.
anyway, thank you so much for checking out this mod. 509 views is amazing for me. But of course there will be more updates to come.
Always come to me if you have suggestions or problems. I will listen to you guys and love hearing from you.
link is at the top.
Oh hey, you're still here!
So far, you've lasted a lot longer than most first time modders, and I hope to see you continue to work on your mod as long as it pleases you.
Depending on where your ambitions lie, you might be able to finish this one.
 
Oct 31, 2018 at 3:06 PM
Junior Member
"It's dangerous to go alone!"
Join Date: Nov 30, 2017
Location:
Posts: 39
Age: 18
#36
Thank you.

And also an announcement.
If anyone was having any trouble with the current update.
Sorry, the Mychar wasn't assigned to the game....
So I fixed and now it should be good as new
 
Oct 31, 2018 at 6:59 PM
Senior Member
"This is the greatest handgun ever made! You have to ask yourself, do I feel lucky?"
Join Date: Jan 12, 2018
Location: Sitting around in his Throne Room.
Posts: 118
#37
Reading all of this inspires me to post a demo of my mod:
The KingDinner Chronicles
I will get to it.
 
Oct 31, 2018 at 9:11 PM
Junior Member
"It's dangerous to go alone!"
Join Date: Nov 30, 2017
Location:
Posts: 39
Age: 18
#38
Reading all of this inspires me to post a demo of my mod:
The KingDinner Chronicles
I will get to it.
Glad it did. Hope to play it soon
 
Oct 31, 2018 at 9:45 PM
Senior Member
"This is the greatest handgun ever made! You have to ask yourself, do I feel lucky?"
Join Date: Jan 12, 2018
Location: Sitting around in his Throne Room.
Posts: 118
#39
I assure you. It's a short demo, because I'm making a completely new story line for the game. No body is the same.
I hope to hear your comments on it
 
Nov 15, 2018 at 6:13 PM
Junior Member
"It's dangerous to go alone!"
Join Date: Nov 30, 2017
Location:
Posts: 39
Age: 18
#40
BUG FIX
Quote's torso is no longer transparent and Katsuya's lines are fixed
 
Top