Difference between revisions of "S1 Split Guides/Basic ASM Editing (Spin Dash)"
From Sonic Retro
Scarred Sun (talk | contribs) m (→Recommended Tools and Files: Protip: Use "Media:" for files) |
m (Text replacement - "\[\[Category:SCHG How-tos.*" to "") |
||
(24 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{GuideBy|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. | 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. | ||
− | ==Porting the | + | ==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. | 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== | ==Recommended Tools and Files== | ||
− | You can use any text editor to edit the disassembly, however I recommend using ConTEXT and [[Ambil]]'s M68K Highlighter. | + | You can use any text editor to edit the disassembly, however I recommend using ConTEXT and [[User:Ambil|Ambil]]'s M68K Highlighter. |
*[[Media:ConTEXTsetup.zip|ConTEXT v0.98.5]] | *[[Media:ConTEXTsetup.zip|ConTEXT v0.98.5]] | ||
Text editor for editing the disassembly. | Text editor for editing the disassembly. | ||
− | *[[Media: | + | *[[Media:ConTEXT_HighlightM68k.zip|Ambil's M68K highlighter for ConTEXT]] |
Highlighter that allows clearer code editing. After installing ConTEXT, place this in your '''C:\Program Files\ConTEXT\Highlighters''' folder. | Highlighter that allows clearer code editing. After installing ConTEXT, place this in your '''C:\Program Files\ConTEXT\Highlighters''' folder. | ||
Line 29: | Line 29: | ||
− | :3. Now to find the | + | :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''' |
[[Image:asmtut02.png|center]] | [[Image:asmtut02.png|center]] | ||
Line 35: | Line 35: | ||
The set of data we reach is this: | The set of data we reach is this: | ||
− | <asm>Obj01_MdNormal: ; DATA XREF: ROM:Obj01_Modes?o | + | <syntaxhighlight lang="asm">Obj01_MdNormal: ; DATA XREF: ROM:Obj01_Modes?o |
bsr.w Sonic_Spindash | bsr.w Sonic_Spindash | ||
bsr.w Sonic_Jump | bsr.w Sonic_Jump | ||
Line 45: | Line 45: | ||
bsr.w Sonic_AnglePos | bsr.w Sonic_AnglePos | ||
bsr.w Sonic_SlopeRepel | bsr.w Sonic_SlopeRepel | ||
− | rts</ | + | rts</syntaxhighlight> |
− | + | This is the table of Sonic's moves. You can see the Spindash is in there, so we will put it into Sonic 1. | |
− | :4. Hit F3 on ConTEXT | + | :4. Hit F3 on ConTEXT 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 | + | :5. Now click the sonic1.asm tab. 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]] | ||
− | + | <syntaxhighlight lang="asm">; End of function Sonic_JumpHeight | |
− | <asm>; End of function Sonic_JumpHeight | ||
[CODE] | [CODE] | ||
; --------------------------------------------------------------------------- | ; --------------------------------------------------------------------------- | ||
− | ; Subroutine to slow Sonic walking up a slope</ | + | ; Subroutine to slow Sonic walking up a slope</syntaxhighlight> |
− | : | + | :6. Now we've pasted the code in, we have to edit the table of Sonic's routines in Sonic 1. |
[[Image:asmtut05.png|center]] | [[Image:asmtut05.png|center]] | ||
− | : | + | :7. Insert <syntaxhighlight lang="asm">bsr.w Sonic_Spindash</syntaxhighlight> on top of <syntaxhighlight lang="asm">Sonic_Jump</syntaxhighlight>. That will, of course, branch to the Spindash routine. |
[[Image:asmtut06.png|center]] | [[Image:asmtut06.png|center]] | ||
− | : | + | :8. Now save '''sonic1.asm''' and take a look at what we've done. Run '''build.bat''' and let's take a look at our new '''s1built.bin'''. |
− | [[Image: | + | [[Image:SCHG Spin Dash Result.png|center]] |
− | |||
− | |||
− | + | .....Oh dear. This doesn't look right. But the Spindash is there, at least! We need to change the animation, go to <syntaxhighlight lang="asm">move.b #9,$1c(a0)</syntaxhighlight> and change the 9 to a 3. That will make it the Jumping animation, which still looks good. | |
− | <asm> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | :9. Now save the sonic1.asm file, build it again and then open "s1built.bin" in your emulator. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==What you should see== | ==What you should see== | ||
[[Image:spinanim.gif]] | [[Image:spinanim.gif]] | ||
− | We have | + | '''We have now put a Spindash in Sonic 1! In part 2, we will show you how to reset the camera when dashing, as well as share some more ASM goodies! Bye for now!''' |
− | + | {{S1Howtos}} | |
+ | |Basic ASM Editing (Spin Dash)]] |
Latest revision as of 11:10, 25 August 2018
(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:
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
This is the table of Sonic's moves. You can see the Spindash is in there, so we will put it into Sonic 1.
- 4. Hit F3 on ConTEXT 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. Search for ; End of function Sonic_JumpHeight in sonic1.asm and right under that line, paste the Spindash routine there!
; End of function Sonic_JumpHeight
[CODE]
; ---------------------------------------------------------------------------
; Subroutine to slow Sonic walking up a slope
- 6. Now we've pasted the code in, we have to edit the table of Sonic's routines in Sonic 1.
- 7. Insert on top of
bsr.w Sonic_Spindash
. That will, of course, branch to the Spindash routine.Sonic_Jump
- 8. Now save sonic1.asm and take a look at what we've done. Run build.bat and let's take a look at our new s1built.bin.
move.b #9,$1c(a0)
- 9. Now save the sonic1.asm file, build it again and then open "s1built.bin" in your emulator.
What you should see
We have now put a Spindash in Sonic 1! In part 2, we will show you how to reset the camera when dashing, as well as share some more ASM goodies! Bye for now!
|Basic ASM Editing (Spin Dash)]]