Actions

SCHG How-to

Difference between revisions of "Port Sonic 2 Level Select to Sonic 1"

From Sonic Retro

(Other)
(Fixing Level Order in Level Select Menu)
Line 371: Line 371:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
'''Now You Have the Rev01 Level Select Order'''
 
'''Now You Have the Rev01 Level Select Order'''
Now you can edit the text in the level select. To edit "debug mode" code go to the label "Code_Debug_Mode:".
+
 
 +
To edit "debug mode" code go to the label "Code_Debug_Mode:".
 
To edit "all emeralds" code go to label "Code_All_Emeralds:"
 
To edit "all emeralds" code go to label "Code_All_Emeralds:"
 
That's all. All permissions for this level select code goes to [[User:Esrael|Esrael]]. Result:
 
That's all. All permissions for this level select code goes to [[User:Esrael|Esrael]]. Result:

Revision as of 12:19, 9 November 2018

(Original guide by DelayHacks, updated for the SVN/GitHub disassembly by The Catman 22)

You need to download the level select by Esrael:

Download.svg Download Sonic 2 Level Select in Sonic 1
File: s2menu.rar (29 kB) (info)

and extract it to the root of your dissassembly.

Hivebrain's 2005 disassembly

After downloading and extracting the file, go to the end of the main file (sonic1.asm) and you'll find this:

; end of 'ROM'
EndOfRom:


		END

Add this line before it:

	include	"s2_menu.asm"	; Sonic 2 level select

Now go to:

Title_ChkLevSel:
		tst.b	($FFFFFFE0).w		; check	if level select	code is	on
		beq.w	PlayLevel		; if not, play level
		btst	#iA,(Joypad|Held).w	; check if A is held
		beq.w	PlayLevel		; if not, play level
		moveq	#2,d0
		bsr.w	PalLoad2		; load level select pallet
		lea	($FFFFCC00).w,a1
		moveq	#0,d0
		move.w	#$DF,d1

and replace with this:

Title_ChkLevSel:
		tst.b	($FFFFFFE0).w		; check	if level select	code is	on
		beq.w	PlayLevel		; if not, play level
		btst	#iA,(Joypad|Held).w	; check if A is held
		beq.w	PlayLevel		; if not, play level
		jmp	Level_Select_Menu	; if yes, goto Sonic 2 level select	
		moveq	#2,d0
		lea	($FFFFCC00).w,a1
		moveq	#0,d0
		move.w	#$DF,d1

SVN/GitHub disassembly

After downloading and extracting the file, go to the end of the main file (sonic.asm) and you'll find this:

; end of 'ROM'
EndOfRom:


		END

Add this line before it:

	include	"s2_menu.asm"	; Sonic 2 level select

Now go to:

Tit_ChkLevSel:
		tst.b	(f_levselcheat).w ; check if level select code is on
		beq.w	PlayLevel	; if not, play level
		btst	#bitA,(v_jpadhold1).w ; check if A is pressed
		beq.w	PlayLevel	; if not, play level

		moveq	#palid_LevelSel,d0
		bsr.w	PalLoad2	; load level select palette
		lea	(v_hscrolltablebuffer).w,a1
		moveq	#0,d0
		move.w	#$DF,d1

and replace with this:

Tit_ChkLevSel:
		tst.b	(f_levselcheat).w ; check if level select code is on
		beq.w	PlayLevel	; if not, play level
		btst	#bitA,(v_jpadhold1).w ; check if A is pressed
		beq.w	PlayLevel	; if not, play level
		jmp	Level_Select_Menu; Go to Sonic 2 Level Select
		moveq	#palid_LevelSel,d0
		bsr.w	PalLoad2	; load level select palette
		lea	(v_hscrolltablebuffer).w,a1
		moveq	#0,d0
		move.w	#$DF,d1

Open s2_menu.asm and change this:

Menu_Palette:
                incbin  'data\menu\menu.pal' 
Menu_ClearScreen:
                jmp     ClearScreen
Menu_ShowVDPGraphics:                
                jmp     ShowVDPGraphics                
Menu_NemesisDec: 
                jmp     NemDec  
Menu_LoadPLC2:      
                jmp     LoadPLC2
Menu_RunPLC:                    
                jmp     RunPLC_RAM                           
Menu_EnigmaDec
                jmp     EniDec
Menu_Pal_FadeTo:
                jmp     Pal_FadeTo
Menu_Pal_FadeFrom:
                jmp     Pal_FadeFrom     
Menu_Play_Music:
                jmp     PlaySound  
Menu_PalLoad1:
                jmp     PalLoad1
Menu_DelayProgram:
                jmp     DelayProgram

to this:

Pal_Menu:
                incbin  'data\menu\menu.pal'    
Menu_ClearScreen:
                jmp     ClearScreen
Menu_ShowVDPGraphics:                
                jmp     TilemapToVRAM                
Menu_NemesisDec: 
                jmp     NemDec  
Menu_LoadPLC2:      
                jmp     NewPLC
Menu_RunPLC:                    
                jmp     RunPLC                          
Menu_EnigmaDec
                jmp     EniDec
Menu_Pal_FadeTo:
                jmp     PaletteFadeIn
Menu_Pal_FadeFrom:
                jmp     PaletteFadeOut     
Menu_Play_Music:
                jmp     PlaySound  
Menu_PalLoad1:
                jmp     PalLoad1
Menu_DelayProgram:
                jmp     WaitForVBla

Other

Hivebrain's 2005 disassembly

Open "_inc\Pallet pointers.asm" and after this:

	dc.l Pal_Ending
	dc.w $FB00
	dc.w $1F

add this:

	dc.l Menu_Palette; pallet address
	dc.w $FB00	; RAM address
	dc.w $1F	; (pallet length / 2) - 1

Now you have Sonic 2's level select palette.

SVN/GitHub disassembly

Open "_inc\Palette pointers.asm" and after this:

	ptr_Pal_Ending:		palp	Pal_Ending,v_pal_dry,$40		; $13 (19) - ending sequence

add this:

	ptr_Pal_Menu:		palp	Pal_Menu,v_pal_dry,$40		; 2 - level select

Now you have Sonic 2's level select palette.

Fixing bug

In the level select will be this:

Special Stage 1
              2
              3

To fix this (this is with "ending sequence" and "final" too), find this piece of code:

;-------------------------------------------------------------------------------                
; Carrega o Texto do Menu de Seleзгo de Fases               
;-------------------------------------------------------------------------------
                lea     ($FFFF0000), A3
                move.w  #$045F, D1
Offset_0x026B4E:
                move.w  #$0000, (A3)+
                dbra    D1, Offset_0x026B4E
                lea     ($FFFF0000), A3
                lea     (Menu_Level_Select_Text), A1
                lea     (Menu_Text_Positions), A5
                moveq   #$00, D0
                move.w  #$0009, D1  ; Quantidade de textos a ser carregada e posiзгo do Sound Test
Menu_Loop_Load_Text:
                move.w  (A5)+, D3
                lea     $00(A3, D3), A2
                moveq   #$00, D2
                move.b  (A1)+, D2
                move.w  D2, D3
Offset_0x026B7A:
                move.b  (A1)+, D0
                move.w  D0, (A2)+
                dbra    D2, Offset_0x026B7A
                move.w  #$000D, D2
                sub.w   D3, D2
                bcs.s   Offset_0x026B92
Offset_0x026B8A:
                move.w  #$0000, (A2)+
                dbra    D2, Offset_0x026B8A
Offset_0x026B92:
                move.w  #$0011, (A2)       ; Load "1"
                lea     $0050(A2), A2
                move.w  #$0012, (A2)       ; Load "2"
                lea     $0050(A2), A2
                move.w  #$0013, (A2)       ; Load "3"
                dbra    D1, Menu_Loop_Load_Text
;-------------------------------------------------------------------------------                
                moveq   #$0E, D1
Menu_Clear_Act_x:                                               ; Limpa os nъmeros dos acts nгo usados e carrega o "*" do Sound Test
                move.w  #$0000, (A2)                            ; Load " "
                lea     $0050(A2), A2
                dbra    D1, Menu_Clear_Act_x
;                lea     $FF10(A2), A2
;                move.w  #$001A, (A2)          ; Load "*"

And change it to this:

;-------------------------------------------------------------------------------                
; Carrega o Texto do Menu de Seleзгo de Fases               
;-------------------------------------------------------------------------------
		lea		($FFFF0000),a3
		move.w	#$045F,d1

Offset_0x026B4E:
		move.w	#$0000,(a3)+
		dbra	d1,Offset_0x026B4E
		lea		($FFFF0000),a3
		lea		(Menu_Level_Select_Text),a1
		lea		(Menu_Text_Positions),a5
		moveq	#$00,d0
		move.w	#$0009,d1	; Quantidade de textos a ser carregada e posiзгo do Sound Test

Menu_Loop_Load_Text:
		move.w	(a5)+,d3
		lea		$00(a3,d3),a2
		moveq	#$00,d2
		move.b	(a1)+,d2
		move.w	d2,d3

Offset_0x026B7A:
		move.b	(a1)+,d0
		move.w	d0,(a2)+
		dbra	d2,Offset_0x026B7A
		move.w	#$000D,d2
		sub.w	d3,d2
		bcs.s	Offset_0x026B92

Offset_0x026B8A:
		move.w	#$0000,(a2)+
		dbra	d2,Offset_0x026B8A

Offset_0x026B92:
		move.w	#$0011,(a2) 	 	 	 ; Load "1"
		lea		$0050(a2),a2
		move.w	#$0012,(a2) 	 	 	 ; Load "2"
		lea		$0050(a2),a2
		move.w	#$0013,(a2) 	 	 	 ; Load "3"
		dbra	d1,Menu_Loop_Load_Text
;-------------------------------------------------------------------------------
		moveq	#$0E,d1
		lea		$FFFFFBA0(a2),a2

Menu_Clear_Act_x:						; Limpa os nъmeros dos acts nгo usados e carrega o "*" do Sound Test
		move.w	#$0000,(a2)				; Load " "
		lea		$0050(a2),a2
		dbra	d1,Menu_Clear_Act_x
;		lea     $FF10(a2), a2
;		move.w  #$001A, (a2)          ; Load "*"

Bug Fixed!

Changing sounds

Now go to "s2menu.asm". See this line?

Level_Select_Menu_snd   = $0081

Replace "81" with music you want in the level select (# of music + 80). See this line?

Emerald_Snd             = $0093

and replace "93" with sound what you want after "All emeralds code". To edit ring sound after "debug mode" code, change B5 in this line:

Ring_Snd                = $00B5

To edit texts, find label "Menu_Level_Select_Text:" and you see

                dc.b    $0E, _G, _R, _E, _E, _N, __, _H, _I, _L, _L, __, __, __, __, __
                dc.b    $0E, _L, _A, _B, _Y, _R, _I, _N, _T, _H, __, __, __, __, __, __
                dc.b    $0E, _M, _A, _R, _B, _L, _E, __, __, __, __, __, __, __, __, __
                dc.b    $0E, _S, _P, _R, _I, _N, _G, __, _Y, _A, _R, _D, __, __, __, __
                dc.b    $0E, _S, _T, _A, _R, __, _L, _I, _G, _H, _T, __, __, __, __, __
                dc.b    $0E, _S, _C, _R, _A, _P, __, _B, _R, _A, _I, _N, __, __, __, __
                dc.b    $0E, _F, _I, _N, _A, _L, __, __, __, __, __, __, __, __, __, __   
                dc.b    $0E, _S, _P, _E, _C, _I, _A, _L, __, _S, _T, _A, _G, _E, __, __
                dc.b    $0E, _E, _N, _D, _I, _N, _G, __, _S, _E, _Q, _U, _E, _N, _C, _E
                dc.b    $0E, _S, _O, _U, _N, _D, __, _T, _E, _S, _T, __, __, _st,__, __

Fixing Level Order in Level Select Menu

To Correct the Level Order , find this piece of code:

Menu_Level_Select_Array:
                dc.w    $0000, $0001, $0002
                dc.w    $0100, $0101, $0102
                dc.w    $0200, $0201, $0202
                dc.w    $0300, $0301, $0302
                dc.w    $0400, $0401, $0402
                dc.w    $0500, $0501, $0103
                dc.w    $0502, $4000, $0600
                dc.w    $FFFF

And change it to this:

Menu_Level_Select_Array:
                dc.w    $0000, $0001, $0002	;GHZ
                dc.w    $0200, $0201, $0202	;MZ
                dc.w    $0400, $0401, $0402	;SYZ				
                dc.w    $0100, $0101, $0102 ;LZ
                dc.w    $0300, $0301, $0302	;SLZ
                dc.w    $0500, $0501, $0103	;SBZ
                dc.w    $0502, $4000, $0600	
                dc.w    $FFFF

Now for the Level Select text, find this:

Menu_Level_Select_Text: 
                dc.b    $0E, _G, _R, _E, _E, _N, __, _H, _I, _L, _L, __, __, __, __, __
                dc.b    $0E, _L, _A, _B, _Y, _R, _I, _N, _T, _H, __, __, __, __, __, __
                dc.b    $0E, _M, _A, _R, _B, _L, _E, __, __, __, __, __, __, __, __, __
                dc.b    $0E, _S, _P, _R, _I, _N, _G, __, _Y, _A, _R, _D, __, __, __, __
                dc.b    $0E, _S, _T, _A, _R, __, _L, _I, _G, _H, _T, __, __, __, __, __
                dc.b    $0E, _S, _C, _R, _A, _P, __, _B, _R, _A, _I, _N, __, __, __, __
                dc.b    $0E, _F, _I, _N, _A, _L, __, __, __, __, __, __, __, __, __, __   
                dc.b    $0E, _S, _P, _E, _C, _I, _A, _L, __, _S, _T, _A, _G, _E, __, __
                dc.b    $0E, _E, _N, _D, _I, _N, _G, __, _S, _E, _Q, _U, _E, _N, _C, _E
                dc.b    $0E, _S, _O, _U, _N, _D, __, _T, _E, _S, _T, __, __, _st,__, __

And change it to this:

Menu_Level_Select_Text: 
                dc.b    $0E, _G, _R, _E, _E, _N, __, _H, _I, _L, _L, __, __, __, __, __
                dc.b    $0E, _M, _A, _R, _B, _L, _E, __, __, __, __, __, __, __, __, __
                dc.b    $0E, _S, _P, _R, _I, _N, _G, __, _Y, _A, _R, _D, __, __, __, __
                dc.b    $0E, _L, _A, _B, _Y, _R, _I, _N, _T, _H, __, __, __, __, __, __
                dc.b    $0E, _S, _T, _A, _R, __, _L, _I, _G, _H, _T, __, __, __, __, __
                dc.b    $0E, _S, _C, _R, _A, _P, __, _B, _R, _A, _I, _N, __, __, __, __
                dc.b    $0E, _F, _I, _N, _A, _L, __, __, __, __, __, __, __, __, __, __   
                dc.b    $0E, _S, _P, _E, _C, _I, _A, _L, __, _S, _T, _A, _G, _E, __, __
                dc.b    $0E, _E, _N, _D, _I, _N, _G, __, _S, _E, _Q, _U, _E, _N, _C, _E
                dc.b    $0E, _S, _O, _U, _N, _D, __, _T, _E, _S, _T, __, __, _st,__, __

Now You Have the Rev01 Level Select Order

To edit "debug mode" code go to the label "Code_Debug_Mode:". To edit "all emeralds" code go to label "Code_All_Emeralds:" That's all. All permissions for this level select code goes to Esrael. Result:

S2levelselectInS1.png

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)