Difference between revisions of "S1 Split Guides/Basic ASM Editing (Spin Dash)"
From Sonic Retro
Scarred Sun (talk | contribs) m (Text replace - '[[Category:SCHG How-tos|' to '{{S1Howtos}} [[Category:SCHG How-tos|') |
Mrsoniclover (talk | contribs) (→Steps) |
||
Line 47: | Line 47: | ||
rts</asm> | rts</asm> | ||
− | '''Obj01''' is the most important object, it's the Sonic object! This table contains all of Sonic's | + | '''Obj01''' is the most important object, it's the Sonic object! This table contains all of Sonic's moves. For example, <asm>bsr.w Sonic_Jump</asm> is the line for Sonic jumping, however it is not the real code for it. It is where it says <asm>Sonic_Jump:</asm> and there is THE real code. |
− | :4. Hit F3 on ConTEXT to find the next occurance and we're taken to the | + | :4. Now anyway, Hit F3 on ConTEXT to find the next occurance and we're taken to the Spindash routine itself! |
[[Image:asmtut03.png|center]] | [[Image:asmtut03.png|center]] | ||
Line 56: | Line 56: | ||
The next step is to select from '''Sonic_Spindash:''' all the way down to '''<nowiki>; End of function Sonic_Spindash</nowiki>'''. Copy this into the clipboard. | The next step is to select from '''Sonic_Spindash:''' all the way down to '''<nowiki>; End of function Sonic_Spindash</nowiki>'''. Copy this into the clipboard. | ||
− | :5. Now click the sonic1.asm tab. What we have to do now is place the | + | :5. Now click the sonic1.asm tab. What we have to do now is place the Spindash routine in it's equivalent place in Sonic 1. Search for '''<nowiki>; End of function Sonic_JumpHeight</nowiki>''' in sonic1.asm and right under that line, paste the spindash routine there! |
[[Image:asmtut04.png|center]] | [[Image:asmtut04.png|center]] | ||
− | |||
<asm>; End of function Sonic_JumpHeight | <asm>; End of function Sonic_JumpHeight | ||
Line 69: | Line 68: | ||
; Subroutine to slow Sonic walking up a slope</asm> | ; Subroutine to slow Sonic walking up a slope</asm> | ||
− | : | + | :6. Now we've pasted the code in, we have to edit the table of Sonic's routines in Sonic 1. Remember the table we saw earlier in Nick Arcade beta? Sonic 1 doesn't have it! So, go to <asm>Obj01_MdNormal</asm> and here it is again! |
[[Image:asmtut05.png|center]] | [[Image:asmtut05.png|center]] | ||
− | : | + | :7. Now we insert 1 line ourselves: '''bsr.w Sonic_Spindash'''. Note, put this on top of "Sonic_Jump". |
[[Image:asmtut06.png|center]] | [[Image:asmtut06.png|center]] | ||
− | : | + | :8. Now is a good time to save '''sonic1.asm''', stop and take a look at what we've done. Run '''build.bat''' and let's take a look at our '''s1built.bin'''. |
[[Image:SCHG Spin Dash Result.png|center]] | [[Image:SCHG Spin Dash Result.png|center]] | ||
− | + | Uh-oh,the Spin Dash animation is an Unused warping animation. So to change that, go to <asm>move.b #9,$1c(a0)</asm> and change it to <asm>move.b #3,$1c(a0)</asm> so it's the jumping animation, to make it like the Sonic CD Spindash. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | :9. Now save the assembly file and build it again and then open "s1built.bin" in your emulator....You will see the working spindash! | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==What you should see== | ==What you should see== |
Revision as of 13:35, 29 March 2013
(Original guide by Qjimbo)
You might not think the words "basic" and "assembly" could belong in the same sentence, however what we plan to do in this tutorial takes a more modular approach to our disassembly than you might have thought was possible.
Contents
Porting the Spin Dash from the Early Prototype
And that is today's project! We are going to use the Early Prototype disassembly that drx made, reason being that he took care over to ensure it used all the same label names as Hivebrain's Sonic 1 disassembly. This means porting data from it is a lot more straightforward than from the existing Sonic 2 disassembly.
Recommended Tools and Files
You can use any text editor to edit the disassembly, however I recommend using ConTEXT and Ambil's M68K Highlighter.
Text editor for editing the disassembly.
Highlighter that allows clearer code editing. After installing ConTEXT, place this in your C:\Program Files\ConTEXT\Highlighters folder.
The disassembly of the Sonic 2 Nick Arcade Beta
Useful resource for understanding 68k assembly instructions.
Steps
- 1. First things first, we need to extract the disassembly out of the rar file. Extract it into the same folder as our Sonic 1 project (C:\SonED2-1\s1h\).
- 2. Now, we can open all the files we are going to use in ConTEXT. Open C:\SonED2-1\s1h\sonic1.asm and C:\SonED2-1\s1h\Sonic 2 (Early prototype).asm . ConTEXT uses tabs so it's easy to switch between which file we are editing.
- 3. Now to find the Spin Dash routine in the Nick Arcade beta. Select the Sonic 2 (Early prototype).asm tab and do a search for Sonic_Spindash
The set of data we reach is this:
<asm>Obj01_MdNormal: ; DATA XREF: ROM:Obj01_Modes?o
bsr.w Sonic_Spindash
bsr.w Sonic_Jump
bsr.w Sonic_SlopeResist
bsr.w Sonic_Move
bsr.w Sonic_Roll
bsr.w Sonic_LevelBoundaries
jsr SpeedToPos
bsr.w Sonic_AnglePos
bsr.w Sonic_SlopeRepel
rts</asm>
Obj01 is the most important object, it's the Sonic object! This table contains all of Sonic's moves. For example, <asm>bsr.w Sonic_Jump</asm> is the line for Sonic jumping, however it is not the real code for it. It is where it says <asm>Sonic_Jump:</asm> and there is THE real code.
- 4. Now anyway, Hit F3 on ConTEXT to find the next occurance and we're taken to the Spindash routine itself!
The next step is to select from Sonic_Spindash: all the way down to ; End of function Sonic_Spindash. Copy this into the clipboard.
- 5. Now click the sonic1.asm tab. What we have to do now is place the Spindash routine in it's equivalent place in Sonic 1. Search for ; End of function Sonic_JumpHeight in sonic1.asm and right under that line, paste the spindash routine there!
<asm>; End of function Sonic_JumpHeight
[CODE]
- ---------------------------------------------------------------------------
- Subroutine to slow Sonic walking up a slope</asm>
- 6. Now we've pasted the code in, we have to edit the table of Sonic's routines in Sonic 1. Remember the table we saw earlier in Nick Arcade beta? Sonic 1 doesn't have it! So, go to <asm>Obj01_MdNormal</asm> and here it is again!
- 7. Now we insert 1 line ourselves: bsr.w Sonic_Spindash. Note, put this on top of "Sonic_Jump".
- 8. Now is a good time to save sonic1.asm, stop and take a look at what we've done. Run build.bat and let's take a look at our s1built.bin.
Uh-oh,the Spin Dash animation is an Unused warping animation. So to change that, go to <asm>move.b #9,$1c(a0)</asm> and change it to <asm>move.b #3,$1c(a0)</asm> so it's the jumping animation, to make it like the Sonic CD Spindash.
- 9. Now save the assembly file and build it again and then open "s1built.bin" in your emulator....You will see the working spindash!
What you should see
We have working Spin Dash, however it is a little too slow. In part 2 I will explain how to speed this up, as well as share more ASM goodies!
Thanks go to Quickman for coming up with the concept and for directing me in porting the Spin Dash!