Actions

SCHG How-to

Fix the Level Select menu in Sonic 1

From Sonic Retro

Revision as of 10:21, 29 June 2012 by KingofHarts (talk | contribs) (Fixed a small typo)

(Original guide by STHX)

The first part is based on information contained in SCHG:Sonic the Hedgehog/Text Editing, the second part has some original research. Also, this guide is useless if you use ESE, since it can easily change the Level Select menu and the pointers by itself, but it helps if you use a disassembly.

NOTE: Hivebrain's Sonic 1 Disassembly 2005 used. (andlabs - updated to ASM68K) Sorry if it has differences from other disassemblies. Step 2B added for any SVN DASM users.

Anyway, let's start:

Introduction

If you have been a part of the Sonic Retro community for a long time, chances are you have played Sonic The Hedgehog, and if you played it, you know it has a Level Select code (UP DOWN LEFT RIGHT to activate it, A+START to enter the level select menu). However, the Zone order in the menu (in the game's first version) is not the actual in-game order, but the original planned order.

Sonic1 level select.png

This guide will show you how to change it and still maintain its functions. You will need an Hex Editor for this.

Step 1: The Text

From the Hivebrain 2005 Disassembly open with an hex editor the file menutext.bin in the misc folder. (or Level Select Text.bin in the SVN DASM) You should have something like this:

17 22 15 15 1E FF 18 19 1C 1C FF 10 1F 1E 15 FF FF 23 24 11 17 15 FF 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 1C 11 12 0F 22 19 1E 24 18 FF 10 1F 1E 15 FF FF FF 23 24 11 17 15 FF 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 1D 11 22 12 1C 15 FF 10 1F 1E 15 FF FF FF FF FF FF 23 24 11 17 15 FF 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 23 24 11 22 FF 1C 19 17 18 24 FF 10 1F 1E 15 FF FF 23 24 11 17 15 FF 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 23 20 22 19 1E 17 FF 0F 11 22 14 FF 10 1F 1E 15 FF 23 24 11 17 15 FF 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 23 13 22 11 20 FF 12 22 11 19 1E FF 10 1F 1E 15 FF 23 24 11 17 15 FF 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 16 19 1E 11 1C FF 10 1F 1E 15 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 20 15 13 19 11 1C FF 23 24 11 17 15 FF FF FF FF FF FF FF FF FF FF FF 23 1F 25 1E 14 FF 23 15 1C 15 13 24 FF FF FF FF FF FF FF FF FF FF FF FF

Now, if you have read the article SCHG:Sonic the Hedgehog/Text Editing, you know that all of this bytes can be translated to a character. In particular:

00 = 0 01 = 1 02 = 2 03 = 3 04 = 4
05 = 5 06 = 6 07 = 7 08 = 8 09 = 9
0A = $ 0B = - 0C = = 0D = ◄ 0E = ◄
0F = Y 10 = Z 11 = A 12 = B 13 = C
14 = D 15 = E 16 = F 17 = G 18 = H
19 = I 1A = J 1B = K 1C = L 1D = M
1E = N 1F = O 20 = P 21 = Q 22 = R
23 = S 24 = T 25 = U 26 = V 27 = W
28 = X FF = (space)

if your hex editor supports TBL files, you can use this below:

00=0
01=1
02=2
03=3
04=4
05=5
06=6
07=7
08=8
09=9
0A=$
0B=-
0C==
0D=<
0E=>
0F=Y
10=Z
11=A
12=B
13=C
14=D
15=E
16=F
17=G
18=H
19=I
1A=J
1B=K
1C=L
1D=M
1E=N
1F=O
20=P
21=Q
22=R
23=S
24=T
25=U
26=V
27=W
28=X
FF= 

These are the corresponding values, that, when rearranged will look like this:

17 22 15 15 1E FF 18 19 1C 1C FF 10 1F 1E 15 FF FF 23 24 11 17 15 FF 01 (GREEN HILL ZONE STAGE 1)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 (STAGE 2)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 (STAGE 3)
1C 11 12 0F 22 19 1E 24 18 FF 10 1F 1E 15 FF FF FF 23 24 11 17 15 FF 01 (LABYRINTH ZONE STAGE 1)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 (STAGE 2)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 (STAGE 3)
1D 11 22 12 1C 15 FF 10 1F 1E 15 FF FF FF FF FF FF 23 24 11 17 15 FF 01 (MARBLE ZONE STAGE 1)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 (STAGE 2)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 (STAGE 3)
23 24 11 22 FF 1C 19 17 18 24 FF 10 1F 1E 15 FF FF 23 24 11 17 15 FF 01 (STAR LIGHT ZONE STAGE 1)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 (STAGE 2)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 (STAGE 3)
23 20 22 19 1E 17 FF 0F 11 22 14 FF 10 1F 1E 15 FF 23 24 11 17 15 FF 01 (SPRING YARD ZONE STAGE 1)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 (STAGE 2)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 (STAGE 3)
23 13 22 11 20 FF 12 22 11 19 1E FF 10 1F 1E 15 FF 23 24 11 17 15 FF 01 (SCRAP BRAIN ZONE STAGE 1)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 (STAGE 2)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 (STAGE 3)
16 19 1E 11 1C FF 10 1F 1E 15 FF FF FF FF FF FF FF FF FF FF FF FF FF FF (FINAL ZONE)
23 20 15 13 19 11 1C FF 23 24 11 17 15 FF FF FF FF FF FF FF FF FF FF FF (SPECIAL STAGE)
23 1F 25 1E 14 FF 23 15 1C 15 13 24 FF FF FF FF FF FF FF FF FF FF FF FF (SOUND SELECT)

Now you can change the code to make it reflect the true in-game Zone order (Green Hill Zone, Marble Zone, Spring Yard Zone, Labyrinth Zone, Star Light Zone, Scrap Brain Zone, Final Zone). In the end, you should have something like this:

17 22 15 15 1E FF 18 19 1C 1C FF 10 1F 1E 15 FF FF 23 24 11 17 15 FF 01 (GREEN HILL ZONE STAGE 1)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 (STAGE 2)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 (STAGE 3)
1D 11 22 12 1C 15 FF 10 1F 1E 15 FF FF FF FF FF FF 23 24 11 17 15 FF 01 (MARBLE ZONE STAGE 1)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 (STAGE 2)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 (STAGE 3)
23 20 22 19 1E 17 FF 0F 11 22 14 FF 10 1F 1E 15 FF 23 24 11 17 15 FF 01 (SPRING YARD ZONE STAGE 1)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 (STAGE 2)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 (STAGE 3)
1C 11 12 0F 22 19 1E 24 18 FF 10 1F 1E 15 FF FF FF 23 24 11 17 15 FF 01 (LABYRINTH ZONE STAGE 1)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 (STAGE 2)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 (STAGE 3)
23 24 11 22 FF 1C 19 17 18 24 FF 10 1F 1E 15 FF FF 23 24 11 17 15 FF 01 (STAR LIGHT ZONE STAGE 1)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 (STAGE 2)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 (STAGE 3)
23 13 22 11 20 FF 12 22 11 19 1E FF 10 1F 1E 15 FF 23 24 11 17 15 FF 01 (SCRAP BRAIN ZONE STAGE 1)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 02 (STAGE 2)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 23 24 11 17 15 FF 03 (STAGE 3)
16 19 1E 11 1C FF 10 1F 1E 15 FF FF FF FF FF FF FF FF FF FF FF FF FF FF (FINAL ZONE)
23 20 15 13 19 11 1C FF 23 24 11 17 15 FF FF FF FF FF FF FF FF FF FF FF (SPECIAL STAGE)
23 1F 25 1E 14 FF 23 15 1C 15 13 24 FF FF FF FF FF FF FF FF FF FF FF FF (SOUND SELECT)

Save, test, build, and you should have done it. However, now that the text is changed, there seems to a bigger problem...

STHX LS guide 2.png

Because if you select Marble Zone Stage 1...

STHX LS guide 3.png

You will go to Labyrinth Zone instead! So, does this mean we screwed up? Yes, but only because the level pointers were not altered, and now we will change them.

Step 2A: The Level Pointers

From the Hivebrain 2005 Disassembly open with an hex editor the file ls-point.bin in the misc folder. You should have something like this:

00 00 00 01 00 02 01 00 01 01 01 02 02 00 02 01 02 02 03 00 03 01 03 02 04 00 04 01 04 02 05 00 05 01 01 03 05 02 07 00 80 00

This file tells the game in what Zone the various selections of the Level Select Menu will take Sonic (The Level Pointers). But... What does it mean?

Before going on, let me explain something on the Zones. The game gives a hex value to all Zones and to all Acts, and the order follows (Again) the original planned order of the levels. Each level is identified with a pair of bytes, the first indicates the zone number (remember, they are in Hex, and they start at 00):

00 = Green Hill Zone
01 = Labyrinth Zone
02 = Marble Zone
03 = Star Light Zone
04 = Spring Yard Zone
05 = Scrap Brain Zone
06 = Ending level (The one where you go after clearing Final Zone)
07 = Special Stage

While the second indicate the zone act:

00 = Act 1
01 = Act 2
02 = Act 3
03 = Act 4 (No, it's not a mistake. Sonic The Hedgehog has a fourth Act, I'll explain this after)

Still unclear? Then let's arrange the code:

(GREEN HILL ZONE STAGE 1) 00 00
(STAGE 2) 00 01
(STAGE 3) 00 02
(LABYRINTH ZONE STAGE 1 01 00
(STAGE 2) 01 01
(STAGE 3) 01 02
(MARBLE ZONE STAGE 1) 02 00
(STAGE 2) 02 01
(STAGE 3) 02 02
(STAR LIGHT ZONE STAGE 1) 03 00
(STAGE 2) 03 01
(STAGE 3) 03 02
(SPRING YARD ZONE STAGE 1) 04 00
(STAGE 2) 04 01
(STAGE 3) 04 02
(SCRAP BRAIN ZONE STAGE 1) 05 00
(STAGE 2) 05 01
(STAGE 3) 01 03 [Remember the fourth act thing? Then do not forget that SBZ Act 3 is in truth LZ act 4. This is important! FZ is the true SBZ Act 3]
(FINAL ZONE) 05 02
(SPECIAL STAGE) 07 00
(SOUND SELECT) 80 00 [This does not point to any level]

Now it's a lot easier to understand that bunch of Hex values. Now change them so they reflect the new Text in the menu. In the end you should have something like this:

00 00 00 01 00 02 02 00 02 01 02 02 04 00 04 01 04 02 01 00 01 01 01 02 03 00 03 01 03 02 05 00 05 01 01 03 05 02 07 00 80 00 

Which, if rearranged:

(GREEN HILL ZONE STAGE 1) 00 00
(STAGE 2) 00 01
(STAGE 3) 00 02
(MARBLE ZONE STAGE 1) 02 00
(STAGE 2) 02 01
(STAGE 3) 02 02
(SPRING YARD ZONE STAGE 1) 04 00
(STAGE 2) 04 01
(STAGE 3) 04 02
(LABYRINTH ZONE STAGE 1 01 00
(STAGE 2) 01 01
(STAGE 3) 01 02
(STAR LIGHT ZONE STAGE 1) 03 00
(STAGE 2) 03 01
(STAGE 3) 03 02
(SCRAP BRAIN ZONE STAGE 1) 05 00
(STAGE 2) 05 01
(STAGE 3) 01 03
(FINAL ZONE) 05 02
(SPECIAL STAGE) 07 00
(SOUND SELECT) 80 00

Save, build, and try again to select Marble Zone Stage 1.

STHX LS guide 5.png

Success!!! The level select menu will not only have the the Zones arranged in the right order, but you will actually go there when you select them.

Step 2B: Level Pointers in the SVN Disassembly

If you're using the SVN Disassembly of Sonic 1, there is no .bin file for the level select pointers. It is instead in the sonic.asm file.

Make a search for LevSel_Ptrs. You should find this: <asm> LevSel_Ptrs: if Revision=0 ; old level order dc.b id_GHZ, 0 dc.b id_GHZ, 1 dc.b id_GHZ, 2 dc.b id_LZ, 0 dc.b id_LZ, 1 dc.b id_LZ, 2 dc.b id_MZ, 0 dc.b id_MZ, 1 dc.b id_MZ, 2 dc.b id_SLZ, 0 dc.b id_SLZ, 1 dc.b id_SLZ, 2 dc.b id_SYZ, 0 dc.b id_SYZ, 1 dc.b id_SYZ, 2 dc.b id_SBZ, 0 dc.b id_SBZ, 1 dc.b id_LZ, 3 ; Scrap Brain Zone 3 dc.b id_SBZ, 2 ; Final Zone else </asm> and directly below it you will see: <asm>

;correct level order

dc.b id_GHZ, 0 dc.b id_GHZ, 1 dc.b id_GHZ, 2 dc.b id_MZ, 0 dc.b id_MZ, 1 dc.b id_MZ, 2 dc.b id_SYZ, 0 dc.b id_SYZ, 1 dc.b id_SYZ, 2 dc.b id_LZ, 0 dc.b id_LZ, 1 dc.b id_LZ, 2 dc.b id_SLZ, 0 dc.b id_SLZ, 1 dc.b id_SLZ, 2 dc.b id_SBZ, 0 dc.b id_SBZ, 1 dc.b id_LZ, 3 dc.b id_SBZ, 2 </asm> You can erase everything in the first box up there except for <asm> if Revision=0 </asm> and the label of course, and replace it with the second box of code.

Final note

This can help you if you plan to change the Zone names (Or the order) in your hack, and still have a perfect Level Select Menu. Have fun!

SCHG How-To Guide: Sonic the Hedgehog (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix the SEGA Sound | Display the Press Start Button Text | Fix the Level Select Menu | Fix the Hidden Points Bug | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix the Walk-Jump Bug | Correct Drowning Bugs | Fix the Death Boundary Bug | Fix the Camera Follow Bug | Fix Song Restoration Bugs | Fix the HUD Blinking | Fix the Level Select Graphics Bug | Fix a remember sprite related bug
Changing Design Choices
Change Spike Behavior | Collide with Water After Being Hurt | Fix Special Stage Jumping Physics | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Remove the Speed Cap | Port the REV01 Background Effects | Port Sonic 2's Level Art Loader | Retain Rings Between Acts | Add Sonic 2 (Simon Wai Prototype) Level Select | Improve ObjectMove Subroutines | Port Sonic 2 Level Select
Adding Features
Add Spin Dash ( Part 1 / Part 2 / Part 3 / Part 4 ) | Add Eggman Monitor | Add Super Sonic | Add the Air Roll
Sound Features
Expand the Sound Index | Play Different Songs Per Act | Port Sonic 2 Final Sound Driver | Port Sonic 3's Sound Driver | Port Flamewing's Sonic 3 & Knuckles Sound Driver | Change The SEGA Sound
Extending the Game
Load Chunks From ROM | Add Extra Characters | Make an Alternative Title Screen | Use Dynamic Tilesets | Make GHZ Load Alternate Art | Make Ending Load Alternate Art | Add a New Zone | Set Up the Goggle Monitor | Add New Moves | Add a Dynamic Collision System | Dynamic Special Stage Walls System | Extend Sprite Mappings and Art Limit | Enigma Credits | Use Dynamic Palettes
Miscellaneous
Convert the Hivebrain 2005 Disassembly to ASM68K
Split Disassembly Guides
Set Up a Split Disassembly | Basic Level Editing | Basic Art Editing | Basic ASM Editing (Spin Dash)