Actions

SCHG How-to

Difference between revisions of "Fix Sonic 2 Sega Screen"

From Sonic Retro

m
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
Made For Sonic 2 all revisions
+
This guide is backported from AMPS in Sonic 2, and is expected to work in all versions of the standard disassembly. This guide was written by [https://info.sonicretro.org/User:RobiWanKenobi RobiWanKenobi].
  
Guide By [https://info.sonicretro.org/User:RobiWanKenobi RobiWanKenobi]
+
Let's say you've decided to change Sonic's sprites to something else, no harm, except this actually affects the Sega screen. The screen calls for the same art/mappings as the player object, which any changes would affect both aspects. Fortunately, the Sonic object in the Sega screen can use standalone art and mappings, so let's do that. It's effective for when you're porting sprites from Sonic 3 and Knuckles or doing custom sprites.
==Github==
 
  
If you have ported in sprites from other Sonic games or other games in general, you may have noticed the Sega screen is messed up.
+
Go into the art folder, then the uncompressed folder, and make a copy of the Sonic sprites. Do the same for his mappings and DPLC's in the mappings folder (sprite and spriteDPLC subfolders respectively). All three duplicate files should be named "SegaSonic.bin".
 
 
This is good to do if you plan on porting sprites without that aren't converted to sonic 2's mappings and DPLCs.
 
 
 
Make a copy of the Sonic 2 sprites, mappings, and DPLCs for Sonic. Make in art/uncompressed SegaSonic.bin with a copy of the sonic 2 sprites, Also SegaSonicMap.bin and in mappings/spriteDPLC make SegaSonic.bin with the sonic 2 DPLCS
 
 
 
Now in s2.asm
 
 
 
Find this line of code for Sonic's art.
 
  
 +
Let's apply our changes! In s2.asm, find this line of code for Sonic's art.
  
 
<syntaxhighlight lang="asm">
 
<syntaxhighlight lang="asm">
Line 26: Line 18:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Right after the art import for Sonic add in.
+
We're going to add in the extra art file, so copy and paste the block of code with the only difference is that the duplicate will call for the Sega screen-specific art like so:
 
 
  
 
<syntaxhighlight lang="asm">
 
<syntaxhighlight lang="asm">
Line 36: Line 27:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Now right below this section of code.
+
Now we're going to add the extra mapping file, so let's scroll down to find this line of code:
 
 
  
 
<syntaxhighlight lang="asm">
 
<syntaxhighlight lang="asm">
Line 46: Line 36:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Add this line of code
+
Add a new line underneath calling for the separate mapping file, like so:
  
 
<syntaxhighlight lang="asm">
 
<syntaxhighlight lang="asm">
 
;--------------------------------------------------------------------------------------
 
;--------------------------------------------------------------------------------------
Mapunc_SegaSonic: BINCLUDE "mappings/sprite/SegaSonicMap.bin"
+
Mapunc_SegaSonic: BINCLUDE "mappings/sprite/SegaSonic.bin"
 
;--------------------------------------------------------------------------------------
 
;--------------------------------------------------------------------------------------
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Now replace this line of code.
+
Now we're going to expand upon the DPLC code, with this change allowing us to have distinct files in use. Don't worry, we'll resolve some other issues later. This is where the DPLC file is called:
 
 
  
 
<syntaxhighlight lang="asm">
 
<syntaxhighlight lang="asm">
Line 70: Line 59:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
With this line of code.
+
This header should instead call for the Sega screen file, so in the standard MapRUnc header, change "Sonic.bin" to "SegaSonic.bin" and add another code block to use the standard Sonic art for in-game stuff. For example (and what we will use later in this guide as said example), the gameplay sprite DPLC's will be referred to as Sonic3 in the header. The gameplay sprite DPLC file will not be renamed, obviously. You should have this after adding the new header:
 
 
  
 
<syntaxhighlight lang="asm">
 
<syntaxhighlight lang="asm">
Line 83: Line 71:
 
MapRUnc_Sonic: BINCLUDE "mappings/spriteDPLC/SegaSonic.bin"
 
MapRUnc_Sonic: BINCLUDE "mappings/spriteDPLC/SegaSonic.bin"
 
;--------------------------------------------------------------------------------------
 
;--------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------
+
;Sonic's in-game sprites
;Sonic's ingame sprites
 
 
MapRUnc_Sonic3: BINCLUDE "mappings/spriteDPLC/Sonic.bin"
 
MapRUnc_Sonic3: BINCLUDE "mappings/spriteDPLC/Sonic.bin"
 
;--------------------------------------------------------------------------------------
 
;--------------------------------------------------------------------------------------
 
</syntaxhighlight>
 
</syntaxhighlight>
  
But now, if you have other sprites, you will notice that the sonic sprites are messed up, to fix that, go to <syntaxhighlight lang="asm"> LoadSonicDymPLC_Part2</syntaxhighlight>  and change this.
+
Now we are going to apply these changes to the actual Sega screen and gameplay. And if you've changed Sonic's art, it's going to be noticeable. Further in the main s2.asm file, head over to LoadSonicDymPLC_Part2 and you will see this:
 
 
  
 
<syntaxhighlight lang="asm">
 
<syntaxhighlight lang="asm">
Line 106: Line 92:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
To this
+
All we need to do is change the header being called for the DPLC used in gameplay sprites. The line you need to change is right underneath the move.b command for Sonic_LastLoadedDPLC. Change it to MapRUnc_Sonic3. Now scroll down to ObjB0_Init, and you should see this:
 
 
 
 
<syntaxhighlight lang="asm">
 
LoadSonicDynPLC_Part2:
 
cmp.b (Sonic_LastLoadedDPLC).w,d0
 
beq.s return_1B89A
 
move.b d0,(Sonic_LastLoadedDPLC).w
 
lea (MapRUnc_Sonic3).l,a2
 
add.w d0,d0
 
adda.w (a2,d0.w),a2
 
move.w (a2)+,d5
 
subq.w #1,d5
 
bmi.s return_1B89A
 
move.w #tiles_to_bytes(ArtTile_ArtUnc_Sonic),d4
 
</syntaxhighlight>
 
 
 
Now change this
 
 
 
  
 
<syntaxhighlight lang="asm">
 
<syntaxhighlight lang="asm">
Line 154: Line 122:
  
 
 
To this
+
Much like before, all we need to do is change the header. This time, it's the uncompressed art file for the Sega screen in the third to last line. You should change said header to ArtUnc_SegaSonic. If this has been done correctly, the Sega screen will call for the correct file and gameplay sprites will be intact.
 
 
 
 
<syntaxhighlight lang="asm">
 
ObjB0_Init:
 
bsr.w LoadSubObject
 
move.w #$1E8,x_pixel(a0)
 
move.w #$F0,y_pixel(a0)
 
move.w #$B,objoff_2A(a0)
 
move.w #2,(SegaScr_VInt_Subrout).w
 
bset #0,render_flags(a0)
 
bset #0,status(a0)
 
 
 
; Initialize streak horizontal offsets for Sonic going left.
 
; 9 full lines (8 pixels) + 6 pixels, 2-byte interleaved entries for PNT A and PNT B
 
lea (Horiz_Scroll_Buf + 2 * 2 * (9 * 8 + 6)).w,a1
 
lea Streak_Horizontal_offsets(pc),a2
 
moveq #0,d0
 
moveq #$22,d6 ; Number of streaks-1
 
- move.b (a2)+,d0
 
add.w d0,(a1)
 
addq.w #2 * 2 * 2,a1 ; Advance to next streak 2 pixels down
 
dbf d6,-
 
 
 
lea off_3A294(pc),a1 ; pointers to mapping DPLC data
 
lea (ArtUnc_SegaSonic).l,a3
 
lea (Chunk_Table).l,a5
 
moveq #4-1,d5 ; there are 4 mapping frames to loop over
 
</syntaxhighlight>
 
 
 
if done right, it works, even with sonic 3 sprites.
 
  
[[File:FixedSegaScreen.png]]
+
[[File:FixedSegaScreen.png]] [[File:S3_SpritesInFix.png]]
  
[[File:S3_SpritesInFix.png]] This is from a rom hack that uses this fix, but, I am able to use stock sonic 2 for it too
 
  
 
{{S2Howtos}}
 
{{S2Howtos}}

Latest revision as of 08:37, 3 August 2023

This guide is backported from AMPS in Sonic 2, and is expected to work in all versions of the standard disassembly. This guide was written by RobiWanKenobi.

Let's say you've decided to change Sonic's sprites to something else, no harm, except this actually affects the Sega screen. The screen calls for the same art/mappings as the player object, which any changes would affect both aspects. Fortunately, the Sonic object in the Sega screen can use standalone art and mappings, so let's do that. It's effective for when you're porting sprites from Sonic 3 and Knuckles or doing custom sprites.

Go into the art folder, then the uncompressed folder, and make a copy of the Sonic sprites. Do the same for his mappings and DPLC's in the mappings folder (sprite and spriteDPLC subfolders respectively). All three duplicate files should be named "SegaSonic.bin".

Let's apply our changes! In s2.asm, find this line of code for Sonic's art.

;---------------------------------------------------------------------------------------
; Uncompressed art
; Patterns for Sonic  ; ArtUnc_50000:
;---------------------------------------------------------------------------------------
	align $20
ArtUnc_Sonic:	BINCLUDE	"art/uncompressed/Sonic's art.bin"
;---------------------------------------------------------------------

We're going to add in the extra art file, so copy and paste the block of code with the only difference is that the duplicate will call for the Sega screen-specific art like so:

;---------------------------------------------------------------------
	align $20
ArtUnc_SegaSonic:	BINCLUDE	"art/uncompressed/SegaSonic.bin"
;---------------------------------------------------------------------------------------

Now we're going to add the extra mapping file, so let's scroll down to find this line of code:

;--------------------------------------------------------------------------------------
; Sprite Mappings
; Sonic			; MapUnc_6FBE0: SprTbl_Sonic:
;--------------------------------------------------------------------------------------

Add a new line underneath calling for the separate mapping file, like so:

;--------------------------------------------------------------------------------------
Mapunc_SegaSonic:	BINCLUDE	"mappings/sprite/SegaSonic.bin"
;--------------------------------------------------------------------------------------

Now we're going to expand upon the DPLC code, with this change allowing us to have distinct files in use. Don't worry, we'll resolve some other issues later. This is where the DPLC file is called:

;--------------------------------------------------------------------------------------
; Sprite Dynamic Pattern Reloading
; Sonic DPLCs   		; MapRUnc_714E0:
;--------------------------------------------------------------------------------------
; WARNING: the build script needs editing if you rename this label
;          or if you move Sonic's running frame to somewhere else than frame $2D
;Sega Screen Sonic
MapRUnc_Sonic:	BINCLUDE	"mappings/spriteDPLC/Sonic.bin"
;--------------------------------------------------------------------------------------

This header should instead call for the Sega screen file, so in the standard MapRUnc header, change "Sonic.bin" to "SegaSonic.bin" and add another code block to use the standard Sonic art for in-game stuff. For example (and what we will use later in this guide as said example), the gameplay sprite DPLC's will be referred to as Sonic3 in the header. The gameplay sprite DPLC file will not be renamed, obviously. You should have this after adding the new header:

;--------------------------------------------------------------------------------------
; Sprite Dynamic Pattern Reloading
; Sonic DPLCs   		; MapRUnc_714E0:
;--------------------------------------------------------------------------------------
; WARNING: the build script needs editing if you rename this label
;          or if you move Sonic's running frame to somewhere else than frame $2D
;Sega Screen Sonic
MapRUnc_Sonic:	BINCLUDE	"mappings/spriteDPLC/SegaSonic.bin"
;--------------------------------------------------------------------------------------
;Sonic's in-game sprites
MapRUnc_Sonic3:	BINCLUDE	"mappings/spriteDPLC/Sonic.bin"
;--------------------------------------------------------------------------------------

Now we are going to apply these changes to the actual Sega screen and gameplay. And if you've changed Sonic's art, it's going to be noticeable. Further in the main s2.asm file, head over to LoadSonicDymPLC_Part2 and you will see this:

LoadSonicDynPLC_Part2:
	cmp.b	(Sonic_LastLoadedDPLC).w,d0
	beq.s	return_1B89A
	move.b	d0,(Sonic_LastLoadedDPLC).w
	lea	(MapRUnc_Sonic).l,a2
	add.w	d0,d0
	adda.w	(a2,d0.w),a2
	move.w	(a2)+,d5
	subq.w	#1,d5
	bmi.s	return_1B89A
	move.w	#tiles_to_bytes(ArtTile_ArtUnc_Sonic),d4

All we need to do is change the header being called for the DPLC used in gameplay sprites. The line you need to change is right underneath the move.b command for Sonic_LastLoadedDPLC. Change it to MapRUnc_Sonic3. Now scroll down to ObjB0_Init, and you should see this:

ObjB0_Init:
	bsr.w	LoadSubObject
	move.w	#$1E8,x_pixel(a0)
	move.w	#$F0,y_pixel(a0)
	move.w	#$B,objoff_2A(a0)
	move.w	#2,(SegaScr_VInt_Subrout).w
	bset	#0,render_flags(a0)
	bset	#0,status(a0)

	; Initialize streak horizontal offsets for Sonic going left.
	; 9 full lines (8 pixels) + 6 pixels, 2-byte interleaved entries for PNT A and PNT B
	lea	(Horiz_Scroll_Buf + 2 * 2 * (9 * 8 + 6)).w,a1
	lea	Streak_Horizontal_offsets(pc),a2
	moveq	#0,d0
	moveq	#$22,d6	; Number of streaks-1
-	move.b	(a2)+,d0
	add.w	d0,(a1)
	addq.w	#2 * 2 * 2,a1	; Advance to next streak 2 pixels down
	dbf	d6,-

	lea	off_3A294(pc),a1 ; pointers to mapping DPLC data
	lea	(ArtUnc_Sonic).l,a3
	lea	(Chunk_Table).l,a5
	moveq	#4-1,d5 ; there are 4 mapping frames to loop over


Much like before, all we need to do is change the header. This time, it's the uncompressed art file for the Sega screen in the third to last line. You should change said header to ArtUnc_SegaSonic. If this has been done correctly, the Sega screen will call for the correct file and gameplay sprites will be intact.

FixedSegaScreen.png S3 SpritesInFix.png


SCHG How-To Guide: Sonic the Hedgehog 2 (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix Super Sonic Bugs | Use Correct Height When Roll Jumping | Fix Jump Height Bug When Exiting Water | Fix Screen Boundary Spin Dash Bug | Correct Drowning Bugs | Fix Camera Y Position for Tails | Fix Tails Subanimation Error | Fix Tails' Respawn Speeds | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix Rexon Crash | Fix Monitor Collision Bug | Fix EHZ Deformation Bug | Correct CPZ Boss Attack Behavior | Fix Bug in ARZ Boss Arrow's Platform Behavior | Fix ARZ Boss Walking on Air Glitch | Fix ARZ Boss Sprite Behavior | Fix Multiple CNZ Boss Bugs | Fix HTZ Background Scrolling Mountains | Fix OOZ Launcher Speed Up Glitch | Fix DEZ Giant Mech Collision Glitch | Fix Boss Deconstruction Behavior | Fix Speed Bugs | Fix 14 Continues Cheat | Fix Debug Mode Crash | Fix 99+ Lives | Fix Sonic 2's Sega Screen
Design Choices
Remove the Air Speed Cap | Disable Floor Collision While Dying | Modify Super Sonic Transformation Methods & Behavior | Enable/Disable Tails in Certain Levels | Collide with Water After Being Hurt | Retain Rings When Returning at a Star Post | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Insert LZ Water Ripple Effect | Restore Lost CPZ Boss Feature | Prevent SCZ Tornado Spin Dash Death | Improve ObjectMove Subroutines | Port S3K Rings Manager | Port S3K Object Manager | Port S3K Priority Manager | Edit Level Order with ASM‎ | Alter Ring Requirements in Special Stages | Make Special Stage Characters Use Normal DPLCs | Speed Up Ring Loss Process | Change spike behaviour in Sonic 2
Adding Features
Create Insta-kill and High Jump Monitors | Create Clone and Special Stage Monitors | Port Knuckles
Sound Features
Expand Music Index to Start at $00 | Port Sonic 1 Sound Driver | Port Sonic 2 Clone Driver | Port Sonic 3 Sound Driver | Port Flamewing's Sonic 3 & Knuckles Sound Driver | Expand the Music Index to Start at $00 (Sonic 2 Clone Driver Version) | Play Different Songs Per Act
Extending the Game
Extend the Level Index Past $10 | Extend the Level Select | Extend Water Tables | Add Extra Characters | Free Up 2 Universal SSTs