How to easily edit the loop/S-tube data in Sonic 1 Hivebrain 2005

Discussion in 'Tutorials Archive' started by Ashuro, Aug 26, 2017.

  1. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Ok guys, i just want to do this because... because i want to do this.

    If you've just created a new looping chunk or a new S-tube, you have to enter the chunk number to this file: misc\loopnums.bin, to make it work. (The limit per zone is 2 loop chunks and 2 S-tube chunks).

    When you want to edit this file (loopnums.bin), you have to use a hexadecimal editor (like HxD).

    But you can do it in ASM, just go to this line in sonic1.asm:
    Code:
    LoopTileNums: incbin misc\loopnums.bin
    even
    
    And change it to:

    Code:
    LoopTileNums:
    ;  byte data | Loop 1, Loop 2, S-Tube 1, S-Tube 2
            dc.b     $B5, $7F, $1F, $20 ; Green Hill Zone
            dc.b     $7F, $7F, $7F, $7F  ; Labyrinth Zone
            dc.b     $7F, $7F, $7F, $7F ; Marble Zone
            dc.b     $AA, $B4, $7F, $7F ; Star Light Zone
            dc.b     $7F, $7F, $7F, $7F ; Spring Yard Zone
            dc.b     $7F, $7F, $7F, $7F ;Scrap Brain Zone
            dc.b     $7F, $7F, $7F, $7F ;Ending Sequence
            even 
    Just change the value you want.
    In GHZ, the looping data is stored in the chunk n°35 + $80 = $B5, the second loop entry is empty ($7F is an "empty value"), you can replace it with the number of your choice, example if you have a new looping as chunk n°17, so do this:
    $17 + $80 = $97.

    the S-tubes don't need to do this + $80.

    EDIT: Litte update, as Novedicus said:
    "It should be noted that for the given loop chunk you set, you will need another chunk right after it. The first chunk is for path 1 and the second chunk is for path 2. The engine swaps the chunks as Sonic moves on the loop, so that he can properly get through it."
    (S-tubes are not affected).
    So for example, you create a looping in the chunk entry n°$26. This chunk will be plane A, so the n°$27 is plane B.
    When you get familiar with this, you can do a lot of things, not only loopings, but some stuff like a slope:
    Sans titre.png

    If you're using the Hivebrain/GitHub, this is a good method to create a path swapper illusion with this.


    Voilà, this is another useless tutorial.
     
    Last edited: Aug 26, 2017
  2. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Don't be so hard on yourself.

    There are alot of items within the current disassemblies which have been ripped to binary files, probably to allow tools to utilise and edit them, but of course, some never caught on, like this loop set. I know SonED didn't use this file to its advantage, not sure about SonLVL.

    The point is, some data needs to be kept within the assembly source code itself, especially if you're a programmer, as it's easier to edit, and you should be proud to express it to help others further their projects. The smallest things are often the most helpful.

    Well done.
     
    vladikcomper, ProjectFM and Ashuro like this.
  3. Devon

    Devon help me, i am in hell Member

    Joined:
    Aug 26, 2013
    Messages:
    1,406
    Location:
    your mom
    It should be noted that for the given loop chunk you set, you will need another chunk right after it. The first chunk is for path 1 and the second chunk is for path 2. The engine swaps the chunks as Sonic moves on the loop, so that he can properly get through it.

    Other than that, nice job.
     
    Ashuro likes this.
  4. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    EDIT: Thanks MJ!, i did it because i want the newcomers/beginners to get it easily, because it seems simple for us but it is hard for beginners, newcomers, guys i was.

    EDIT 2: Oh yes Novedicus, i forget this point. :p
     
  5. MainMemory

    MainMemory Well-Known Member Exiled

    Joined:
    Mar 29, 2011
    Messages:
    923
    SonLVL does not use the loop number file, but it does have a pre-set list of chunks which should automatically be placed with the loop flag set for each level in the project file.
     
    Ashuro likes this.
  6. GenesisDoes

    GenesisDoes What Nintendont Member

    Joined:
    Jan 2, 2016
    Messages:
    161
    Location:
    Pittsburgh, PA
    For those using Sonic 1 Github disasm, these chunk ID values for S-tubes/loops are in both "_inc/LevelSizeLoad & BgScrollSpeed.asm" and "_inc/LevelSizeLoad & BgScrollSpeed (JP1).asm" at label "LoopTileNums".

    On a sidenote, a downside of Sonic 1's cheap loop behavior is that (even if you extend the chunk amount per level via ROM chunks) you are limited to $7F chunks per level. I plan on eventually writing a guide this year to allow for $FF ROM Chunks for certain levels (at the expense of losing the old loop behavior), as seen in Socket the Hedgeduck.
     
    KrebbitX likes this.
  7. Trinitronity

    Trinitronity Well-Known Member Member

    Joined:
    Sep 12, 2016
    Messages:
    94
    So...will that guide also have a new loop behavior then? Because Sonic kinda needs the loops...
     
  8. AURORA☆FIELDS

    AURORA☆FIELDS so uh yes Exiled

    Joined:
    Oct 7, 2011
    Messages:
    759
    If we want to get really technical here, the loops are NOT switching you between Plane A or Plane B. Simply saying, in this instance, it is more accurately path 1 and 2 (Even though technically they don't exist in Sonic 1, the way the loops work is in practice identical). Unlike Sky Sanctuary Zone, where you technically can go to Plane B with the floating platforms.
     
    Ashuro likes this.
  9. LuigiXHero

    LuigiXHero Well-Known Member Member

    Joined:
    Mar 22, 2014
    Messages:
    280
    To expand, how Sonic 1 works (and this is probably obvious) is that it swap the chunk with the next chunk in the chunk list. That's why you need two chunks of the same art next to each other since both chunks use different collision setups. Sonic 2 and 3 have proper paths where each chunk has 2 collision indexes that you can swap between. Personally I like the path setup more since you save chunks and affects the entire level rather then just a chunk or two, making it much more flexible.
     
    MainMemory and Ashuro like this.
  10. MainMemory

    MainMemory Well-Known Member Exiled

    Joined:
    Mar 29, 2011
    Messages:
    923
    And that's why the Sonic 1: Project Two-Eight disassembly was made. And technically, if you really wanted, you could make dual-path 256x256 chunks, but say goodbye to SonED2 support (SonLVL is fully customizable in that regard, as long as the size is a multiple of 16).