(Sonic 1) Dynamic Collision Arrays per zone

Discussion in 'Tutorials Archive' started by DeoxysKyogre, Aug 17, 2010.

Thread Status:
Not open for further replies.
  1. DeoxysKyogre

    DeoxysKyogre No idea what to put here .-. Member

    Joined:
    Jan 31, 2009
    Messages:
    298
    NOTE BEFORE READING: THIS ISN'T THEOCAS' DYNAMIC COLLISION PER ACT GUIDE. SO DON'T BE THINKING THAT I COPIED THE GUIDE.


    So, you do import art with SonED2, but there are not enough solids to make the collision fully functional in this zone. You'll want to get more collision, right? If so, read this. It might help you.


    .-What you need:


    Sonic The Hedgehog 2005 Hivebrain Dissasembly (ASM68K Fully Recommended to prevent horrible false mistakes)


    SonED2


    .-Index:


    -> Organizing with folders and files.


    -> Stuff to modify in sonic1.asm


    -> How to make SonED2 projects work with this system


    ================================================================================


    =======


    ORGANIZING WITH FOLDERS AND FILES


    ================================================================================


    =======


    We're going to organize the stuff for starting off, i always like to organize stuff to prevent craziness. To do this, go to collide, and you'll see 2 'carray' files:


    carray_n.bin


    carray_r.bin


    Now, remove those, let's make 6 new folders and 2 carray files in the carray_xxx folder. (XXX as a zone) Should be called:


    -> carray_ghz:


    carray_greenhill_n.bin


    carray_greenhill_r.bin


    -> carray_lz:


    carray_labyrinth_n.bin


    carray_labyrinth_r.bin


    -> carray_mz:


    carray_marble_n.bin


    carray_marble_r.bin


    -> carray_syz:


    carray_spyard_n.bin


    carray_spyard_r.bin


    -> carray_slz:


    carray_stlight_n.bin


    carray_stlight_r.bin


    -> carray_sbz:


    carray_scrapbrain_n.bin


    carray_scrapbrain_r.bin


    ================================================================================


    ====


    STUFF TO MODIFY IN SONIC1.ASM


    ================================================================================


    ====


    Now that we're preventing craziness of no-know where to put files, we are going to edit sonic1.asm. Open up this file, and go to the routine "loc_14C6A:" and you'll see this:



    Code:
    		lea	(CollArray1).l,a1
    
    		lea	(CollArray2).l,a2
    
    		bsr.s	FloorLog_Unk2
    
    		lea	(CollArray1).l,a1
    
    		lea	(CollArray1).l,a2
    Replace that with this:



    Code:
    				cmpi.b	#5,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_SYZ; if not, branch
    
    		lea	(CollArray1_SBZ).l,a1 
    
    		lea	(CollArray2_SBZ).l,a2 
    
    		bsr.w	FloorLog_Unk2 
    
    		lea	(CollArray1_SBZ).l,a1 
    
    		lea	(CollArray1_SBZ).l,a2 
    
    LOC_SYZ:
    
    				cmpi.b	#4,($FFFFFE10).w; is level SYZ	?
    
    		bne.s	LOC_SLZ; if not, branch
    
    		lea	(CollArray1_SYZ).l,a1
    
    		lea	(CollArray2_SYZ).l,a2
    
    		bsr.w	FloorLog_Unk2
    
    		lea	(CollArray1_SYZ).l,a1
    
    		lea	(CollArray1_SYZ).l,a2
    
    LOC_SLZ:
    
    				cmpi.b	#3,($FFFFFE10).w; is level SLZ	?
    
    		bne.s	LOC_MZ; if not, branch
    
    		lea	(CollArray1_SLZ).l,a1
    
    		lea	(CollArray2_SLZ).l,a2
    
    		bsr.w	FloorLog_Unk2
    
    		lea	(CollArray1_SLZ).l,a1
    
    		lea	(CollArray1_SLZ).l,a2
    
    LOC_MZ:
    
    				cmpi.b	#2,($FFFFFE10).w; is level MZ	?
    
    		bne.s	LOC_LZ; if not, branch
    
    		lea	(CollArray1_MZ).l,a1
    
    		lea	(CollArray2_MZ).l,a2
    
    		bsr.w	FloorLog_Unk2
    
    		lea	(CollArray1_MZ).l,a1
    
    		lea	(CollArray1_MZ).l,a2
    
    LOC_LZ:
    
    				cmpi.b	#1,($FFFFFE10).w; is level LZ	?
    
    		bne.s	LOC_GHZ; if not, branch
    
    		lea	(CollArray1_LZ).l,a1
    
    		lea	(CollArray2_LZ).l,a2
    
    		bsr.w	FloorLog_Unk2
    
    		lea	(CollArray1_LZ).l,a1
    
    		lea	(CollArray1_LZ).l,a2
    
    LOC_GHZ:
    
    		lea	(CollArray1_GHZ).l,a1
    
    		lea	(CollArray2_GHZ).l,a2
    
    		bsr.s	FloorLog_Unk2
    
    		lea	(CollArray1_GHZ).l,a1
    
    		lea	(CollArray1_GHZ).l,a2
    Later, go to FloorLog_Unk, and YOU see this:



    Code:
    				lea	(CollArray1).l,a1
    
    		lea	(CollArray1).l,a2
    And replace it with this:



    Code:
    				cmpi.b	#5,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_SYZ2; if not, branch
    
    				lea	(CollArray1_SBZ).l,a1
    
    		lea	(CollArray1_SBZ).l,a2
    
    LOC_SYZ2:
    
    				cmpi.b	#4,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_SLZ2; if not, branch
    
    				lea	(CollArray1_SYZ).l,a1
    
    		lea	(CollArray1_SYZ).l,a2
    
    LOC_SLZ2:
    
    				cmpi.b	#3,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_MZ2; if not, branch
    
    				lea	(CollArray1_SLZ).l,a1
    
    		lea	(CollArray1_SLZ).l,a2
    
    LOC_MZ2:
    
    				cmpi.b	#2,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_LZ2; if not, branch
    
    				lea	(CollArray1_MZ).l,a1
    
    		lea	(CollArray1_MZ).l,a2
    
    LOC_LZ2:
    
    				cmpi.b	#1,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_GHZ2; if not, branch
    
    				lea	(CollArray1_LZ).l,a1
    
    		lea	(CollArray1_LZ).l,a2
    
    LOC_GHZ2:
    
    				lea	(CollArray1_GHZ).l,a1
    
    		lea	(CollArray1_GHZ).l,a2
    Then, go to loc_14C0A, and replace this:



    Code:
    lea	(CollArray2).l,a2
    With this:



    Code:
    cmpi.b	#5,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_SYZ3; if not, branch
    
    				lea	(CollArray2_SBZ).l,a2
    
    				bra	 Loc_CollCont
    
    LOC_SYZ3:
    
    				cmpi.b	#4,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_SLZ3; if not, branch
    
    				lea	(CollArray2_SYZ).l,a2
    
    				bra	 Loc_CollCont
    
    LOC_SLZ3:
    
    				cmpi.b	#3,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_MZ3; if not, branch
    
    				lea	(CollArray2_SLZ).l,a2
    
    				bra	 Loc_CollCont
    
    LOC_MZ3:
    
    				cmpi.b	#2,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_LZ3; if not, branch
    
    				lea	(CollArray2_MZ).l,a2
    
    				bra	 Loc_CollCont
    
    LOC_LZ3:
    
    				cmpi.b	#1,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_GHZ3; if not, branch
    
    				lea	(CollArray2_LZ).l,a2
    
    				bra	 Loc_CollCont
    
    LOC_GHZ3:
    
    				lea	(CollArray2_GHZ).l,a2
    
    				bra	 Loc_CollCont
    
    Loc_CollCont:
    We'll do the same as I said above for loc_14B62, but 4 instead of 3 in the labels. This:



    Code:
    lea	(CollArray2).l,a2
    Should look like this:



    Code:
    cmpi.b	#5,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_SYZ4; if not, branch
    
    				lea	(CollArray2_SBZ).l,a2
    
    				bra	 Loc_CollCont2
    
    LOC_SYZ4:
    
    				cmpi.b	#4,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_SLZ4; if not, branch
    
    				lea	(CollArray2_SYZ).l,a2
    
    				bra	 Loc_CollCont2
    
    LOC_SLZ4:
    
    				cmpi.b	#3,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_MZ4; if not, branch
    
    				lea	(CollArray2_SLZ).l,a2
    
    				bra	 Loc_CollCont2
    
    LOC_MZ4:
    
    				cmpi.b	#2,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_LZ4; if not, branch
    
    				lea	(CollArray2_MZ).l,a2
    
    				bra	 Loc_CollCont2
    
    LOC_LZ4:
    
    				cmpi.b	#1,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_GHZ4; if not, branch
    
    				lea	(CollArray2_LZ).l,a2
    
    				bra	 Loc_CollCont2
    
    LOC_GHZ4:
    
    				lea	(CollArray2_GHZ).l,a2
    
    				bra	 Loc_CollCont2
    
    Loc_CollCont2:
    Those 2 last routines are related to CollArray2, as you see. Now we'll modify the ones related CollArray1 to support the array per zone system. So go to loc_14ACA, and you'll see this:



    Code:
    lea	(CollArray1).l,a2
    But this leaves the same on every zone. We MUST change this to support dinamism with this:



    Code:
    				cmpi.b	#5,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_SYZ5; if not, branch
    
    				lea	(CollArray1_SBZ).l,a2
    
    				bra	 Loc_CollCont3
    
    LOC_SYZ5:
    
    				cmpi.b	#4,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_SLZ5; if not, branch
    
    				lea	(CollArray1_SYZ).l,a2
    
    				bra	 Loc_CollCont3
    
    LOC_SLZ5:
    
    				cmpi.b	#3,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_MZ5; if not, branch
    
    				lea	(CollArray1_SLZ).l,a2
    
    				bra	 Loc_CollCont3
    
    LOC_MZ5:
    
    				cmpi.b	#2,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_LZ5; if not, branch
    
    				lea	(CollArray1_MZ).l,a2
    
    				bra	 Loc_CollCont3
    
    LOC_LZ5:
    
    				cmpi.b	#1,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_GHZ5; if not, branch
    
    				lea	(CollArray1_LZ).l,a2
    
    				bra	 Loc_CollCont3
    
    LOC_GHZ5:
    
    				lea	(CollArray1_GHZ).l,a2
    
    				bra	 Loc_CollCont3
    
    Loc_CollCont3:
    One more routine to go. Now go to loc_14A22 and change:



    Code:
     lea	(CollArray1).l,a2
    With:



    Code:
    				cmpi.b	#5,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_SYZ6; if not, branch
    
    				lea	(CollArray1_SBZ).l,a2
    
    				bra	 Loc_CollCont4
    
    LOC_SYZ6:
    
    				cmpi.b	#4,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_SLZ6; if not, branch
    
    				lea	(CollArray1_SYZ).l,a2
    
    				bra	 Loc_CollCont4
    
    LOC_SLZ6:
    
    				cmpi.b	#3,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_MZ6; if not, branch
    
    				lea	(CollArray1_SLZ).l,a2
    
    				bra	 Loc_CollCont4
    
    LOC_MZ6:
    
    				cmpi.b	#2,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_LZ6; if not, branch
    
    				lea	(CollArray1_MZ).l,a2
    
    				bra	 Loc_CollCont4
    
    LOC_LZ6:
    
    				cmpi.b	#1,($FFFFFE10).w; is level SBZ	?
    
    		bne.s	LOC_GHZ6; if not, branch
    
    				lea	(CollArray1_LZ).l,a2
    
    				bra	 Loc_CollCont4
    
    LOC_GHZ6:
    
    				lea	(CollArray1_GHZ).l,a2
    
    				bra	 Loc_CollCont4
    
    Loc_CollCont4:
    But, of course build.bat won't compile yet, because it needs to read the collarray routines first and we didn't apply them. So, you need to make it read all files and folders. So replace this, which only reads 2 files:





    Code:
    CollArray1:	incbin	collide\carray_n.bin; normal collision array
    
    		even
    
    CollArray2:	incbin	collide\carray_r.bin; rotated collision array
    
    		even
    Into THIS:





    Code:
    ;===============================================================================
    
    ====================================
    
    ; Folders and files labels here
    
    ;===============================================================================
    
    ====================================
    
    ; V | GHZ
    
    CollArray1_GHZ:	incbin	collide\carray_ghz\carray_greenhill_n.bin; normal collision array
    
    		even
    
    CollArray2_GHZ:	incbin	collide\carray_ghz\carray_greenhill_r.bin; rotated collision array
    
    		even
    
    
    
    ; V | LZ
    
    CollArray1_LZ:	incbin	collide\carray_lz\carray_labyrinth_n.bin; normal collision array
    
    		even
    
    CollArray2_LZ:	incbin	collide\carray_lz\carray_labyrinth_r.bin; rotated collision array
    
    		even
    
    ; V | MZ
    
    CollArray1_MZ:	incbin	collide\carray_mz\carray_marble_n.bin; normal collision array
    
    		even
    
    CollArray2_MZ:	incbin	collide\carray_mz\carray_marble_r.bin; rotated collision array
    
    		even
    
    
    
    ; V | SYZ
    
    CollArray1_SYZ:	incbin	collide\carray_syz\carray_spyard_n.bin; normal collision array
    
    		even
    
    CollArray2_SYZ:	incbin	collide\carray_syz\carray_spyard_r.bin; rotated collision array
    
    		even
    
    
    
    ; V | SLZ
    
    CollArray1_SLZ:	incbin	collide\carray_slz\carray_stlight_n.bin; normal collision array
    
    		even
    
    CollArray2_SLZ:	incbin	collide\carray_slz\carray_stlight_r.bin; rotated collision array
    
    		even
    
    
    
    ; V | SLZ
    
    CollArray1_SBZ:	incbin	collide\carray_sbz\carray_scrapbrain_n.bin; normal collision array
    
    		even
    
    CollArray2_SBZ:	incbin	collide\carray_sbz\carray_scrapbrain_r.bin; rotated collision array
    
    		even
    
    ;===============================================================================
    
    ================
    
    ;Dynamic Collisions
    
    ;===============================================================================
    
    ================


    ================================================================================

    ====================

    HOW TO MAKE SONED2 PROJECT WORK WITH THIS SYSTEM

    ================================================================================

    ====================

    We got this system working. But we need to make it working in SonED2 so you CAN modify the collision in the level. I'm gonna use GHZ1 for example.

    So, let's see:



    Code:
    Type: 1	
    
    
    
    Zone ID:	0
    
    Act ID:	 0
    
    
    
    Object Def: objdef\s1obj
    
    
    
    8x8 Tiles: ..\artnem\8x8ghz1.bin 
    
    
    
    16x16 Tiles:   ..\map16\ghz.bin
    
    
    
    256x256 Tiles: ..\map256\ghz.bin
    
    
    
    FG Layout: ..\levels\ghz1.bin
    
    BG Layout: ..\levels\ghzbg.bin
    
    
    
    Objects:	   ..\objpos\ghz1.bin
    
    
    
    Palettes-
    
    
    
     Number of files: 2
    
    
    
      Palette 1-
    
    
    
       Start index:		0
    
       Number of entries: 16
    
       File:			  ..\pallet\sonic.bin
    
    
    
      Palette 2-
    
    
    
       Start index:	   16
    
       Number of entries: 48
    
       File:			  ..\pallet\ghz.bin
    
    
    
    Angle Array:			 ..\collide\anglemap.bin
    
    Collision Array:		 ..\collide\X\carray_XX_n.bin
    
    Rotated Collision Array: ..\collide\X\carray_XX_r.bin
    
    
    
    Collision Index 1: ..\collide\ghz.bin
    
    
    
    -EOF-

    X= Zone folder:


    ghz


    mz


    syz


    lz


    slz


    sbz


    XX= Zone Collision array:


    greenhill


    marble


    spyard


    labyrinth


    stlight


    scrapbrain


    NOTE: The (1, 2, 3 in the zone labels are NOT indicating acts!) And if you have branching problems in build.bat, change for example beq.s to beq.w. Or if it's that typical KillSonic error, make a label called Killsonic_jmp and add a jmp command indicating the KillSonic routine, and make the lines from branching to KillSonic indicating to killsonic_jmp instead.


    Credits:


    - Me, for writing the guide


    - Hivebrain, for his 2005 June Dissasembly


    - Theocas, for his guide for dynamic collisions.
     
    Last edited by a moderator: Aug 20, 2010
  2. theocas

    theocas #! Member

    Joined:
    Apr 10, 2010
    Messages:
    375
    Hmm, why does it seem like I have seen this before? Ah yes, I WROTE THE EXACT SAME GUIDE ON THE FORUMS RIGHT BEFORE YOU! We appreciate your efforts to help, but simply re-creating another tutorial with slightly modified code isn't interesting.

    Seriously, make your own fucking code. I worked hard on my system and now to see someone using the exact same technique isn't making me feel very good. In fact, it makes me feel like a total idiot for posting my stuff on here. Don't expect any response from me about whatever. Do it yourself since you seem to be able to rip off other people's code.
     
  3. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    theocas, while your thoughts kinda match what I thought first as well, you didn't really compare this guide to yours. Your code was act-based, this guide is zone-based (at least from what I remember, not sure since you removed your guide).


    But I kinda feel like you, Deoxys, what was the purpose of this topic? Seriously.
     
  4. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    The purpose is to provide a guide that can help one have a different Collision array per zone, I thought that was obvious.

    Welcome to the world of people who have had their code stolen, their ideas copied and their hardwork look piss easy. If you reproduce your guide, I'll gladly send this where it belongs, just don't bitch about it.
     
    Last edited by a moderator: Aug 17, 2010
  5. DeoxysKyogre

    DeoxysKyogre No idea what to put here .-. Member

    Joined:
    Jan 31, 2009
    Messages:
    298
    Theocas, the purpose isn't to make collisions per act, but collision ARRAYS per zone, like Selbi said. Compare your own guide with mine. And even you say I didn't made the code, when I coded it. Yours can help with dynamic tilesets per act, and MINE can help to make FULL new collisions ($FF solids per zone). Dude, it can be related also with collisions, but it's a different thing than your guide (I don't mean this is exactly your guide with a different code). This is DIFFERENT to your guide, I don't know why am I accused to do what i even didn't and you think i ripped off your guide. :(. Next time compare both guides first, please. For the people that are reading this guide, please, don't think I ripped off theocas' guide. It's related to collisions, but a different thing in collisions. I can't believe this. Let's leave it as that absolutely NOTHING happened. I think there's enough flaming. And if you don't want to talk to me, do what you want, you're free to do what you want, really. That's all.


    For Selbi: Just as Markey said, the purpose is to have dynamic collision arrays PER ZONE.


    -DeoxysKyogre.
     
    Last edited by a moderator: Aug 26, 2010
  6. Qjimbo

    Qjimbo Well-Known Member Member

    Joined:
    Feb 27, 2008
    Messages:
    850
    Location:
    Vancouver, BC
    DeoxysKyogre, can we come to comprimise and have Theocas' name added to the credits?


    Theocas, I don't care how annoyed you are, but you need to keep your cool. Keep Deoxys intentions in perspective. I don't want to see angry rants like that in tutorial topics, try to keep it outside the topic in future. I hope you can understand my concern.
     
  7. DeoxysKyogre

    DeoxysKyogre No idea what to put here .-. Member

    Joined:
    Jan 31, 2009
    Messages:
    298
    Done, QJimbo. Let's be here like nothing happened. I hate to see flame wars god.
     
  8. EMK-20218

    EMK-20218 The Fuss Maker Exiled

    Joined:
    Aug 8, 2008
    Messages:
    1,067
    Location:
    Jardim Capelinha, São Paulo
    Nahh... This guide is completely different. Also, this guide is much complete than your guide. You mean "stolen techniques"? I can't understand.


    What the hell are you saying? Hah! You can't being talking seriously, sorry. Both guides are good but not to compare, this guide is much more complete. And different, I think that the majority here will agree on this that I said. This stuff doesn't seems to be stolen or something like this. Sorry.


    Stop kidding, please!
     
  9. Hanoch

    Hanoch Well-Known Member Member

    Joined:
    Aug 3, 2008
    Messages:
    312
    Location:
    Israel
    AFAIK every sonic game in the trilogy uses the same collision array in the whole game. Theocas' guide is using the original collision array in all act 1s, and different collision arrays for all act 2s 3s and 4s. This guide makes it so each zone uses different collision arrays for ALL acts in that zone. If we combine the guides, you will have 24 collision arrays in the game (not including the ending zone).


    So I actually think seeing different collisions between zones is better. Instead of seeing a pattern over and over again.
     
  10. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    Yes agrees, but I think we should move on now don't you? this is a good basic tutorial for those who are using dynamic tilesets so good work on that deoxys.
     
  11. DeoxysKyogre

    DeoxysKyogre No idea what to put here .-. Member

    Joined:
    Jan 31, 2009
    Messages:
    298
    I appreciate your feedback. :rolleyes:
     
Thread Status:
Not open for further replies.