May 2, 2011 at 10:02 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
switch tables also
 
May 2, 2011 at 11:51 PM
Senior Member
"Ha! Ha! Ha! Mega Man is no match for my Mimiga Man!"
Join Date: Jan 21, 2011
Location:
Posts: 249
A loop or switch table is not necessary, just some math.

HyMyNameIsMatt said:
I believe all that needs to be done about the calls is a variable based on direction in one bullet call as apposed to 6 bullet calls. I'll figure it out. Then I'll need to redo all the bullet codes. But that's simple enough.

Well, here's an optimized Polar Star template from version 2 (not released yet) of my mod that you can use. Hope it helps.

Code:
0x41FF3C:
83 C4 18

Code:
0x41DE60:
55 89 E5 83 EC 1C 8B 45 08 89 45 F8 83 C0 03 89
45 FC 6A 02 E8 C7 5D FE FF 83 C4 04 83 F8 02 7E
05 E9 32 01 00 00 8B 0D 14 E2 49 00 23 0D 14 36
49 00 0F 84 20 01 00 00 6A 01 E8 01 41 FE FF 83
C4 04 85 C0 75 11 6A 01 6A 25 E8 91 27 00 00 83
C4 08 E9 01 01 00 00 A1 54 E6 49 00 89 45 F4 A1
58 E6 49 00 89 45 F0 A1 40 E6 49 00 89 45 EC A1
44 E6 49 00 89 45 E8 A1 48 E6 49 00 03 45 E8 89
45 E4 83 7D E4 00 74 4C 83 7D EC 00 74 0D 8B 45
F4 05 00 02 00 00 89 45 F4 EB 0B 8B 45 F4 2D 00
02 00 00 89 45 F4 83 7D E8 00 74 14 C7 45 EC 01
00 00 00 8B 45 F0 2D 00 10 00 00 89 45 F0 EB 35
C7 45 EC 03 00 00 00 8B 45 F0 05 00 10 00 00 89
45 F0 EB 21 8B 45 F0 05 00 06 00 00 89 45 F0 83
7D EC 00 74 09 C7 45 F4 00 0C 00 00 EB 07 C7 45
F4 00 F4 FF FF 8B 45 EC 50 8B 45 F0 50 8B 45 F4
83 7D E4 00 75 06 03 05 54 E6 49 00 50 8B 45 FC
50 E8 0A 60 FE FF 83 C4 10 6A 00 6A 03 8B 45 F0
50 83 7D E4 00 75 0F 8B 45 F4 03 45 F4 03 05 54
E6 49 00 89 45 F4 8B 45 F4 50 E8 F1 CC FE FF 83
C4 10 6A 01 83 7D 08 03 75 04 6A 31 EB 02 6A 20
E8 8B 26 00 00 83 C4 08 89 EC 5D C3

It's a full 335 bytes shorter (about half the size of the original function), fyi. Since I figure this would also help, here's the Disasm:

Code:
CPU Disasm
Address   Hex dump                 Command                                  Comments
0041DE60  /$  55                   PUSH EBP                                 ; Cave_Story_-_Redesign.0041DE60(guessed Arg1)
0041DE61  |.  89E5                 MOV EBP,ESP
0041DE63  |.  83EC 1C              SUB ESP,1C
0041DE66  |.  8B45 08              MOV EAX,DWORD PTR SS:[EBP+8]
0041DE69  |.  8945 F8              MOV DWORD PTR SS:[EBP-8],EAX
0041DE6C  |.  83C0 03              ADD EAX,3
0041DE6F  |.  8945 FC              MOV DWORD PTR SS:[EBP-4],EAX
0041DE72  |.  6A 02                PUSH 2
0041DE74  |.  E8 87680700          CALL 00403C40
0041DE79  |.  83C4 04              ADD ESP,4
0041DE7C  |.  83F8 02              CMP EAX,2
0041DE7F  |.  7E 05                JLE SHORT 0041DE86
0041DE81  |.  E9 32010000          JMP 0041DFB8
0041DE86  |>  8B0D 14E24900        MOV ECX,DWORD PTR DS:[49E214]
0041DE8C  |.  230D 14364900        AND ECX,DWORD PTR DS:[493614]
0041DE92  |.  0F84 20010000        JE 0041DFB8
0041DE98  |.  6A 01                PUSH 1                                   ; /Arg1 = 1
0041DE9A  |.  E8 0141FEFF          CALL 00401FA0                            ; \Cave_Story_-_Redesign.00401FA0
0041DE9F  |.  83C4 04              ADD ESP,4
0041DEA2  |.  85C0                 TEST EAX,EAX
0041DEA4  |.  75 11                JNE SHORT 0041DEB7
0041DEA6  |.  6A 01                PUSH 1                                   ; /Arg2 = 1
0041DEA8  |.  6A 25                PUSH 25                                  ; |Arg1 = 25
0041DEAA  |.  E8 91270000          CALL 00420640                            ; \Cave_Story_-_Redesign.00420640
0041DEAF  |.  83C4 08              ADD ESP,8
0041DEB2  |.  E9 01010000          JMP 0041DFB8
0041DEB7  |>  A1 54E64900          MOV EAX,DWORD PTR DS:[49E654]
0041DEBC  |.  8945 F4              MOV DWORD PTR SS:[EBP-0C],EAX           ; EBP-0C = PlayerXPosition
0041DEBF  |.  A1 58E64900          MOV EAX,DWORD PTR DS:[49E658]
0041DEC4  |.  8945 F0              MOV DWORD PTR SS:[EBP-10],EAX           ; EBP-10 = PlayerYPosition
0041DEC7  |.  A1 40E64900          MOV EAX,DWORD PTR DS:[49E640]
0041DECC  |.  8945 EC              MOV DWORD PTR SS:[EBP-14],EAX           ; EBP-14 = DirectionFaced
0041DECF  |.  A1 44E64900          MOV EAX,DWORD PTR DS:[49E644]
0041DED4  |.  8945 E8              MOV DWORD PTR SS:[EBP-18],EAX           ; EBP-18 = IsFacingUp
0041DED7  |.  A1 48E64900          MOV EAX,DWORD PTR DS:[49E648]
0041DEDC  |.  0345 E8              ADD EAX,DWORD PTR SS:[EBP-18]
0041DEDF  |.  8945 E4              MOV DWORD PTR SS:[EBP-1C],EAX           ; EBP-1C = IsNotFacingLeftOrRight
0041DEE2  |.  837D E4 00           CMP DWORD PTR SS:[EBP-1C],0
0041DEE6  |.  74 4C                JE SHORT 0041DF34
0041DEE8  |.  837D EC 00           CMP DWORD PTR SS:[EBP-14],0
0041DEEC  |.  74 0D                JE SHORT 0041DEFB
0041DEEE  |.  8B45 F4              MOV EAX,DWORD PTR SS:[EBP-0C]
0041DEF1  |.  05 00020000          ADD EAX,200
0041DEF6  |.  8945 F4              MOV DWORD PTR SS:[EBP-0C],EAX
0041DEF9  |.  EB 0B                JMP SHORT 0041DF06
0041DEFB  |>  8B45 F4              MOV EAX,DWORD PTR SS:[EBP-0C]
0041DEFE  |.  2D 00020000          SUB EAX,200
0041DF03  |.  8945 F4              MOV DWORD PTR SS:[EBP-0C],EAX
0041DF06  |>  837D E8 00           CMP DWORD PTR SS:[EBP-18],0
0041DF0A  |.  74 14                JE SHORT 0041DF20
0041DF0C  |.  C745 EC 01000000     MOV DWORD PTR SS:[EBP-14],1
0041DF13  |.  8B45 F0              MOV EAX,DWORD PTR SS:[EBP-10]
0041DF16  |.  2D 00100000          SUB EAX,1000
0041DF1B  |.  8945 F0              MOV DWORD PTR SS:[EBP-10],EAX
0041DF1E  |.  EB 35                JMP SHORT 0041DF55
0041DF20  |>  C745 EC 03000000     MOV DWORD PTR SS:[EBP-14],3
0041DF27  |.  8B45 F0              MOV EAX,DWORD PTR SS:[EBP-10]
0041DF2A  |.  05 00100000          ADD EAX,1000
0041DF2F  |.  8945 F0              MOV DWORD PTR SS:[EBP-10],EAX
0041DF32  |.  EB 21                JMP SHORT 0041DF55
0041DF34  |>  8B45 F0              MOV EAX,DWORD PTR SS:[EBP-10]
0041DF37  |.  05 00060000          ADD EAX,600
0041DF3C  |.  8945 F0              MOV DWORD PTR SS:[EBP-10],EAX
0041DF3F  |.  837D EC 00           CMP DWORD PTR SS:[EBP-14],0
0041DF43  |.  74 09                JE SHORT 0041DF4E
0041DF45  |.  C745 F4 000C0000     MOV DWORD PTR SS:[EBP-0C],0C00
0041DF4C  |.  EB 07                JMP SHORT 0041DF55
0041DF4E  |>  C745 F4 00F4FFFF     MOV DWORD PTR SS:[EBP-0C],-0C00
0041DF55  |>  8B45 EC              MOV EAX,DWORD PTR SS:[EBP-14]
0041DF58  |.  50                   PUSH EAX                                 ; /Arg4 => [EBP-14]
0041DF59  |.  8B45 F0              MOV EAX,DWORD PTR SS:[EBP-10]           ; |
0041DF5C  |.  50                   PUSH EAX                                 ; |Arg3 => [EBP-10]
0041DF5D  |.  8B45 F4              MOV EAX,DWORD PTR SS:[EBP-0C]           ; |
0041DF60  |.  837D E4 00           CMP DWORD PTR SS:[EBP-1C],0             ; |
0041DF64  |.  75 06                JNE SHORT 0041DF6C                       ; |
0041DF66  |.  0305 54E64900        ADD EAX,DWORD PTR DS:[49E654]            ; |
0041DF6C  |>  50                   PUSH EAX                                 ; |Arg2
0041DF6D  |.  8B45 FC              MOV EAX,DWORD PTR SS:[EBP-4]           ; |
0041DF70  |.  50                   PUSH EAX                                 ; |Arg1 => [EBP-4]
0041DF71  |.  E8 0A60FEFF          CALL 00403F80                            ; \Cave_Story_-_Redesign.00403F80
0041DF76  |.  83C4 10              ADD ESP,10
0041DF79  |.  6A 00                PUSH 0
0041DF7B  |.  6A 03                PUSH 3
0041DF7D  |.  8B45 F0              MOV EAX,DWORD PTR SS:[EBP-10]
0041DF80  |.  50                   PUSH EAX
0041DF81  |.  837D E4 00           CMP DWORD PTR SS:[EBP-1C],0
0041DF85  |.  75 0F                JNE SHORT 0041DF96
0041DF87  |.  8B45 F4              MOV EAX,DWORD PTR SS:[EBP-0C]
0041DF8A  |.  0345 F4              ADD EAX,DWORD PTR SS:[EBP-0C]
0041DF8D  |.  0305 54E64900        ADD EAX,DWORD PTR DS:[49E654]
0041DF93  |.  8945 F4              MOV DWORD PTR SS:[EBP-0C],EAX
0041DF96  |>  8B45 F4              MOV EAX,DWORD PTR SS:[EBP-0C]
0041DF99  |.  50                   PUSH EAX
0041DF9A  |.  E8 F1CCFEFF          CALL 0040AC90
0041DF9F  |.  83C4 10              ADD ESP,10
0041DFA2  |.  6A 01                PUSH 1                                   ; /Arg2 = 1
0041DFA4  |.  837D 08 03           CMP DWORD PTR SS:[EBP+8],3               ; |
0041DFA8  |.  75 04                JNE SHORT 0041DFAE                       ; |
0041DFAA  |.  6A 31                PUSH 31                                  ; |
0041DFAC  |.  EB 02                JMP SHORT 0041DFB0                       ; |
0041DFAE  |>  6A 20                PUSH 20                                  ; |
0041DFB0  |>  E8 8B260000          CALL 00420640                            ; \Cave_Story_-_Redesign.00420640
0041DFB5  |.  83C4 08              ADD ESP,8
0041DFB8  |>  89EC                 MOV ESP,EBP
0041DFBA  |.  5D                   POP EBP
0041DFBB  \.  C3                   RETN
 
May 5, 2011 at 7:07 AM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
Dubby said:
Thank you Celtic, that's very useful to know - especially since I will likely need at least a dozen teleporter slots.

If you need all twelve active simultaneously, then, you'll need to do some assembly hacking to extend the length of that array. Of course, you could also have a way to arrange it so that no more than six are ever active at a time.
 
May 5, 2011 at 1:53 PM
Senior Member
"Ha! Ha! Ha! Mega Man is no match for my Mimiga Man!"
Join Date: Jan 21, 2011
Location:
Posts: 249
Celtic Minstrel said:
If you need all twelve active simultaneously, then, you'll need to do some assembly hacking to extend the length of that array. Of course, you could also have a way to arrange it so that no more than six are ever active at a time.

Oh extending it won't be a problem.
 
May 6, 2011 at 3:25 AM
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
DoubleThink said:
Can anyone tell me what entity flag 0x0040 "special solid" does again? I can't remember where it's used... or flag 0x0002 "no effect about tile 44" for that matter.

To answer your question, the 0x40 "Special Solid" flag treats the entity as a solid object that behaves much the same way as a square tile might. The difference between "Special Solid" and "Solid" is that regular solid will cause you to bounce back if you touch it from the side while special solid will not. Bear in mind that the Solid flag overrides the Special Solid flag, so if you set both then Special Solid will not happen.

Another interesting feature of the Special Solid collision code is that if you land on the entity with this collision mode with sufficient velocity (relative to the entity) it will play the "thud" sound effect, whereas Solid entities will not. Special Solid is used on those Moving Block entities in the labyrinth and I presume the slow lift used in the Core room, and the shutters there... pretty much anything that needs to be solid and not alive.

The collision algorithm for flag 0x40 entity vs. player is different than most others in that it appears to employ some sort of optimization, however whether or not this method he uses actually saves any computing power is questionable since he actually uses floating point instructions to set it up.
 
May 6, 2011 at 3:48 AM
Lvl 1
Forum Moderator
"Life begins and ends with Nu."
Join Date: May 28, 2008
Location: PMMM MMO
Posts: 3713
Age: 31
The special solid also overrides tile solidness, whereas the regular solid does not. To put it simply, a special solid entity can push you through a wall, but a regular solid entity cannot.
 
May 7, 2011 at 9:07 PM
Professional Whatever
"Life begins and ends with Nu."
Join Date: Jan 13, 2011
Location: Lasagna
Posts: 4481
Hah!
Quoting the very first post, I love it. :awesomeface:
How would you go about setting a weapon's EXP to 0?
If you want specifics, I need it for the polar star.
 
May 7, 2011 at 9:35 PM
I don't anymore.
"I'm sorry Mario, but your princess is in another castle."
Join Date: Aug 9, 2010
Location: Greener Pastures
Posts: 1190
Age: 30
LunarSoul said:
Hah!
Quoting the very first post, I love it. :awesomeface:
How would you go about setting a weapon's EXP to 0?
If you want specifics, I need it for the polar star.

<ZAM lowers the level of all weapons to 0 and there is no command for a specific weapon. But you can just unequip the weapon and then re-equip it and it should be at 0 exp.
 
May 7, 2011 at 9:37 PM
Professional Whatever
"Life begins and ends with Nu."
Join Date: Jan 13, 2011
Location: Lasagna
Posts: 4481
I apologize. I meant with assembly.
I was being specific in the wrong way, apparently.
 
May 7, 2011 at 10:45 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
Just call the TSC event through assembly

00421990 - Call TSC Event [08_ScriptID]
 
May 7, 2011 at 11:33 PM
Professional Whatever
"Life begins and ends with Nu."
Join Date: Jan 13, 2011
Location: Lasagna
Posts: 4481
I don't want to use zam, though. I just want to set the EXP of the polar star to 0.
 
May 8, 2011 at 12:34 AM
I don't anymore.
"I'm sorry Mario, but your princess is in another castle."
Join Date: Aug 9, 2010
Location: Greener Pastures
Posts: 1190
Age: 30
LunarSoul said:
I don't want to use zam, though. I just want to set the EXP of the polar star to 0.

Do you recall what I told you ealier?
 
May 8, 2011 at 12:51 AM
Professional Whatever
"Life begins and ends with Nu."
Join Date: Jan 13, 2011
Location: Lasagna
Posts: 4481
Ah, I thought you meant with TSC or something.
...I see. I think I can do with zam.
 
May 13, 2011 at 8:32 PM
Professional Whatever
"Life begins and ends with Nu."
Join Date: Jan 13, 2011
Location: Lasagna
Posts: 4481
Question. Can anyone see what's wrong with this assembly code? I'm trying to find the current weapon ID. If it's the lv 3 polar star, keep going. (JNE goes to a RETN)
Code:
MOV ECX,OFFSET 00499C9C
CMP ECX,6
JNE 0048B904
...
 
May 13, 2011 at 9:07 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
0x499C9C will never ever ever be 6 ever. ie, the jump will always be followed. What you want is this:
Code:
  mov ecx,[499c9c]
cmp ecx,6
jne 0x48B904
...

The brackets indicate that it is a pointer, and thus you are looking for the information at that offset.
 
May 14, 2011 at 3:26 AM
Professional Whatever
"Life begins and ends with Nu."
Join Date: Jan 13, 2011
Location: Lasagna
Posts: 4481
Thanks lace, that should fix my code.
 
May 15, 2011 at 2:21 PM
Senior Member
"Wahoo! Upgrade!"
Join Date: May 14, 2011
Location: In your closet... being a creeper.
Posts: 53
Age: 33
Umm hi. I have a question. I am making a mod and its all messed up in mimiga village. I put a new door with script (works great except doesnt show the open door image when i press down aka flag 2000) and a new transporter with script (works but kinda buggy) and now none of the doors in mimiga village work except the one that I made. please help me. :D

(edit) Ahhh! new problem! Whenever i try to edit weapons it just says error saving file! Help me! :confused:
 
May 15, 2011 at 6:18 PM
Level 73 Procrastinator
"Life begins and ends with Nu."
Join Date: Apr 6, 2009
Location: Forgotten Tower
Posts: 2052
Must construct additional posts

Game Reaper said:
Umm hi. I have a question. I am making a mod and its all messed up in mimiga village. I put a new door with script (works great except doesnt show the open door image when i press down aka flag 2000) and a new transporter with script (works but kinda buggy) and now none of the doors in mimiga village work except the one that I made. please help me. :D
You'd have to describe more about what you did, a lot of things could've gone wrong.
Is this still the original map, I assume? Did you remember to keep the events in descending order? {They go crazy if you don't} Do the doors still have event numbers on them that correspond to events in the TSC for that map?
Game Reaper said:
(edit) Ahhh! new problem! Whenever i try to edit weapons it just says error saving file! Help me! :confused:
Make sure your entire Cave Story folder does not have "Read-Only" checked, in Properties.
 
May 15, 2011 at 6:19 PM
Pirate Member
"Heavy swords for sale. Suitable for most RPG Protagonists. Apply now!"
Join Date: Dec 26, 2007
Location: Lithuania
Posts: 1946
Maybe you somehow replaced the events that represent the other doors? I dunno. Ask GIR.
 
May 15, 2011 at 6:24 PM
Senior Member
"Wahoo! Upgrade!"
Join Date: May 14, 2011
Location: In your closet... being a creeper.
Posts: 53
Age: 33
Let me check...

1)Yes original map
2) The events were not in the right order so I fixed them
3)yup all doors have correct event #'s

Thx for suggestions on whats wrong though!:D
 
Top