Actions

SCHG How-to

Dynamic Collision system in Sonic 1

From Sonic Retro

(Original guide by Theocas)

This system works best with the dynamic art and palette system, but if every zone has the same art and you still want dynamic collision for some reason, read on. I originally wrote this over on SSRG, but I thought I might as well add it here. This tutorial will tell you how to load different collision indexes for each act, with support for a 4th act. First of all, find ColIndexLoad: in your disasm.
		move.l	ColPointers(pc,d0.w),($FFFFF796).w
This loads the collision pointer for the correct zone into a RAM address. Make 4 subroutines titled ColIndexLoadAct1, ColIndexLoadAct2, ColIndexLoadAct3 and ColIndexLoadAct4. Even if you don't have a 4th act for your zones, Scrap Brain 3 is actually Act 4 of Labyrinth so it is required. Now that you have these subroutines, turn ColIndexLoad into this:
ColIndexLoad:				; XREF: Level
		moveq	#0,d0
		move.b	($FFFFFE10).w,d0
		lsl.w	#2,d0
		cmp.b	#$00, ($FFFFFE11).w
		beq.s	ColIndexLoadAct1
		cmp.b	#$01, ($FFFFFE11).w
		beq.s	ColIndexLoadAct2
		cmp.b	#$02, ($FFFFFE11).w
		beq.s	ColIndexLoadAct3
		cmp.b	#$03, ($FFFFFE11).w
		beq.s	ColIndexLoadAct4

Now Make the subroutines you just created read like so:

ColIndexLoadAct1:
		move.l	ColPointers(pc,d0.w),($FFFFF796).w
		bra.w	ColIndexLoad_locret
		
ColIndexLoadAct2:
		move.l	ColPointers2(pc,d0.w),($FFFFF796).w
		bra.w	ColIndexLoad_locret
		
ColIndexLoadAct3:
		move.l	ColPointers3(pc,d0.w),($FFFFF796).w
		bra.w	ColIndexLoad_locret
		
ColIndexLoadAct4:
		move.l	ColPointers4(pc,d0.w),($FFFFF796).w
		bra.w	ColIndexLoad_locret

ColIndexLoad_locret:
		rts

Oh, yeah, the ColIndexLoad_locret method. Can you guess what it does? It simply contains and rts, or Return To Subroutine. Now for actually adding those pointers for each additional act. See this line?

ColPointers:
	include "_inc\Collision index pointers.asm"

As you might have guessed, make 3 copies of that line, but adding the numbers 2, 3 and 4 to ColPointers and the file name before .asm. If you did it correctly, it will look like this:

; ---------------------------------------------------------------------------
; Collision index pointers for Act 1
; ---------------------------------------------------------------------------
ColPointers:
	include "_inc\Collision index pointers.asm"
	
; ---------------------------------------------------------------------------
; Collision index pointers for Act 2
; ---------------------------------------------------------------------------
ColPointers2:
	include "_inc\Collision index pointers2.asm"
	
; ---------------------------------------------------------------------------
; Collision index pointers for Act 3
; ---------------------------------------------------------------------------
ColPointers3:
	include "_inc\Collision index pointers3.asm"
	
; ---------------------------------------------------------------------------
; Collision index pointers for Act 4
; ---------------------------------------------------------------------------
ColPointers4:
	include "_inc\Collision index pointers4.asm"
Make 3 copies of Collision index pointers.asm and rename them just like you did in the include above. Now you just need the actual content to put in these files. This is what the Act 2 file looks like:
; ---------------------------------------------------------------------------
; Collision index pointers for Act 2
; ---------------------------------------------------------------------------
	dc.l Col_GHZ2
	dc.l Col_LZ2
	dc.l Col_MZ2
	dc.l Col_SLZ2
	dc.l Col_SYZ2
	dc.l Col_SBZ2

You get where I'm going? Do the same for Act 3, but changing the 2 to 3. The Act 4 file requires special treatment - well, not really, but if you want to edit the collision for SBZ3/LZ4 seperatly you should make it exactly like the Act 1 file, but add a 4 after Col_LZ. If you don't plan on doing that, you can just change the include for the Act 4 file to the Act 1 file. You can always change it once you've added the new file. Now go into the collide folder in your disasm and make 2 copies of all these files. Rename them to GHZ, GHZ2, and GHZ3. Now you need to actually include them in the ROM. Find Col_GHZ: in your disasm, and replace the entire block with this:

Col_GHZ:	incbin	collide\ghz.bin		; GHZ index
		even
Col_GHZ2:	incbin	collide\ghz2.bin		; GHZ 2 index
		even
Col_GHZ3:	incbin	collide\ghz3.bin		; GHZ 3 index
		even
Col_LZ:		incbin	collide\lz.bin		; LZ index
		even
Col_LZ2:		incbin	collide\lz2.bin		; LZ index
		even
Col_LZ3:		incbin	collide\lz3.bin		; LZ index
		even
Col_MZ:		incbin	collide\mz.bin		; MZ index
		even
Col_MZ2:		incbin	collide\mz2.bin		; MZ index
		even
Col_MZ3:		incbin	collide\mz3.bin		; MZ index
		even
Col_SLZ:	incbin	collide\slz.bin		; SLZ index
		even
Col_SLZ2:	incbin	collide\slz2.bin		; SLZ index
		even
Col_SLZ3:	incbin	collide\slz3.bin		; SLZ index
		even
Col_SYZ:	incbin	collide\syz.bin		; SYZ index
		even
Col_SYZ2:	incbin	collide\syz2.bin		; SYZ index
		even
Col_SYZ3:	incbin	collide\syz3.bin		; SYZ index
		even
Col_SBZ:	incbin	collide\sbz.bin		; SBZ index
		even
Col_SBZ2:	incbin	collide\sbz2.bin		; SBZ index
		even
Col_SBZ3:	incbin	collide\sbz3.bin		; SBZ index
		even

If you did all this, you should be ready to go! Compile and see your dynamic collision. You will also need to fix the SonED2 Project files, but that will not be covered today because it's a thing that takes all of 5 minutes to do.

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)

|Dynamic Collision system in Sonic 1]]