How to change the order of the levels in Sonic 1 GitHub Disassembly

Discussion in 'Tutorials' started by Angel X, Jun 14, 2020.

  1. Angel X

    Angel X Well-Known Member Member

    Joined:
    Sep 15, 2017
    Messages:
    291
    Location:
    Italy
    Hi everyone and welcome to my guide on how to change the order of the levels in Sonic 1 GitHub Disassembly(https://github.com/sonicretro/s1disasm)!

    -Why this guide?
    I wanted to do this tutorial because of a lack of documentation on this argument and to help who is a beginner.
    Before starting I wanted to thank three members of this forum:
    Inferno,MarkeyJester,
    ProjectFM

    Without them there would not be this guide:D
    For more on how they helped me:http://sonicresearch.org/community/...ic-questions-and-answers-thread.1155/page-291

    Part 1 (location and structure):
    In the old guides it is explained that the levels are in bin format (Level Order.bin or lvl_ord.bin),but in this disassembly they are in ASM format(3A Got Through Card.asm).

    To find the file go to:s1disasm-master\_incObj
    Look inside the file "LevelOrder" and you should find this:
    Code:
    ; ---------------------------------------------------------------------------
    ; Level    order array
    ; ---------------------------------------------------------------------------
    LevelOrder:
            ; Green Hill Zone
            dc.b id_GHZ, 1    ; Act 1
            dc.b id_GHZ, 2    ; Act 2
            dc.b id_MZ, 0    ; Act 3
            dc.b 0, 0
    
            ; Labyrinth Zone
            dc.b id_LZ, 1    ; Act 1
            dc.b id_LZ, 2    ; Act 2
            dc.b id_SLZ, 0    ; Act 3
            dc.b id_SBZ, 2    ; Scrap Brain Zone Act 3
    
            ; Marble Zone
            dc.b id_MZ, 1    ; Act 1
            dc.b id_MZ, 2    ; Act 2
            dc.b id_SYZ, 0    ; Act 3
            dc.b 0, 0
    
            ; Star Light Zone
            dc.b id_SLZ, 1    ; Act 1
            dc.b id_SLZ, 2    ; Act 2
            dc.b id_SBZ, 0    ; Act 3
            dc.b 0, 0
    
            ; Spring Yard Zone
            dc.b id_SYZ, 1    ; Act 1
            dc.b id_SYZ, 2    ; Act 2
            dc.b id_LZ, 0    ; Act 3
            dc.b 0, 0
    
            ; Scrap Brain Zone
            dc.b id_SBZ, 1    ; Act 1
            dc.b id_LZ, 3    ; Act 2
            dc.b 0, 0    ; Final Zone
            dc.b 0, 0
            even
            zonewarning LevelOrder,8
    ; ===========================================================================
    This is the list of the zones!
    WARNING:the structure must not be changed,to change the order of the levels you have to change the date not the list!

    Part2 (code change):
    The code works like this:
    dc.b id_GHZ, 1

    id_GHZ is the name of the zone(in this case Green Hill Zone) and 1 is the Act number to run next(in this case Act 2).
    To change the order of the level the only thing you need to do is modify the third element.

    For example:
    if we want that after Green Hill Zone , the level will be Labyrinth Zone,we have to make this change:

    Code:
     ; Green Hill Zone
            dc.b id_GHZ, 1    ; Act 1
            dc.b id_GHZ, 2    ; Act 2
            dc.b id_LZ, 0    ; Act 3
            dc.b 0, 0


    -What if I want to start on a different level?
    No problem,to change the starting zone(for example Spring Yard Zone) you have to go to "sonic.asm" (found at the beginning of the disassembly) and search for "Tit_ChkLevSel":
    Code:
    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
    on the right add:
    Code:
    move.b    #id_SYZ,(v_zone).w
    or:
    Code:
    move.w    #(id_SYZ<<8)+0,(v_zone).w ; zero is the act number(in this case Act 1)
    Click on "build" and you're done!

    I personally tested the codes and they work (you can try it too).

    I hope this guide has been helpful,
    good work;)












     
  2. Musket777

    Musket777 Newcomer Member

    Joined:
    Nov 21, 2021
    Messages:
    22
    Location:
    VSC
    The guide was helpful indeed. But now,i ran into this. upload_2022-1-7_18-25-34.png

    In SBZ's and SYZ's place, what do i put? do i leave them as normal or what?
     
  3. Angel X

    Angel X Well-Known Member Member

    Joined:
    Sep 15, 2017
    Messages:
    291
    Location:
    Italy
    I don't know if you've tested the code but I'm afraid the problem may remain, because:
    Code:
    ; Green Hill Zone
            dc.b id_GHZ, 1    ; Act 1
            dc.b id_GHZ, 2    ; Act 2
            dc.b id_MZ, 0    ; Act 3 (In this part you are telling him to start with Marble zone anyway)
            dc.b 0, 0
    To change the zone just change the third element:
    Code:
    ; Green Hill Zone
            (element 1) dc.b id_GHZ, 1    ; Act 1
            (element 2)dc.b id_GHZ, 2    ; Act 2
            (element 3)dc.b id_MZ, 0    ; Act 3
            (element 4)dc.b 0, 0
    
            ; Labyrinth Zone
            (element 1)dc.b id_LZ, 1    ; Act 1
            (element 2)dc.b id_LZ, 2    ; Act 2
            (element 3)dc.b id_SLZ, 0    ; Act 3
            (element 4)dc.b id_SBZ, 2    ; Scrap Brain Zone Act 3
    
    (Etc...)
    
    There is also the fact that you have deleted MZ acts( dc.b id_MZ, 1 & dc.b id_MZ, 2),and this could cause problems!
    How would you like the order of the levels?
    Or just want to remove Marble Zone?
     
    Last edited: Jan 7, 2022
  4. Musket777

    Musket777 Newcomer Member

    Joined:
    Nov 21, 2021
    Messages:
    22
    Location:
    VSC
    > There is also the fact that you have deleted MZ acts( dc.b id_MZ, 1 & dc.b id_MZ, 2),and this could cause problems!

    Oh for hell's sake, it had to be me and my Low IQ!

    Well, I was intending to cut out MZ, and LZ. And well, adding an Extra Zone but i don't know how to do that lmao.

    > To change the zone just change the third element:

    Yeah, Darkex told me that, so i did it as i understood. Well i think assumptions are not the best choice!
     
  5. Angel X

    Angel X Well-Known Member Member

    Joined:
    Sep 15, 2017
    Messages:
    291
    Location:
    Italy
    Copy and paste this:
    Code:
    ; ---------------------------------------------------------------------------
    ; Level    order array
    ; ---------------------------------------------------------------------------
    LevelOrder:
            ; Green Hill Zone
            dc.b id_GHZ, 1    ; Act 1
            dc.b id_GHZ, 2    ; Act 2
            dc.b id_SYZ, 0    ; Act 3
            dc.b 0, 0
            ; Labyrinth Zone
            dc.b id_LZ, 1    ; Act 1
            dc.b id_LZ, 2    ; Act 2
            dc.b id_SLZ, 0    ; Act 3
            dc.b id_SBZ, 2    ; Scrap Brain Zone Act 3
            ; Marble Zone
            dc.b id_MZ, 1    ; Act 1
            dc.b id_MZ, 2    ; Act 2
            dc.b id_SYZ, 0    ; Act 3
            dc.b 0, 0
            ; Star Light Zone
            dc.b id_SLZ, 1    ; Act 1
            dc.b id_SLZ, 2    ; Act 2
            dc.b id_SBZ, 0    ; Act 3
            dc.b 0, 0
            ; Spring Yard Zone
            dc.b id_SYZ, 1    ; Act 1
            dc.b id_SYZ, 2    ; Act 2
            dc.b id_SLZ, 0    ; Act 3
            dc.b 0, 0
            ; Scrap Brain Zone
            dc.b id_SBZ, 1    ; Act 1
            dc.b id_LZ, 3    ; Act 2
            dc.b 0, 0    ; Final Zone
            dc.b 0, 0
            even
            zonewarning LevelOrder,8
    ; ===========================================================================
    As you can see I only changed the third element of Green Hill Zone and Spring Yard Zone.
    You can try asking here for details:
    https://sonicresearch.org/community...dding-a-new-level-adding-water-to-zones.6055/
     
  6. Musket777

    Musket777 Newcomer Member

    Joined:
    Nov 21, 2021
    Messages:
    22
    Location:
    VSC
    oh, Thanks! I'll take a look at the tutorials.
     
    Last edited: Jan 8, 2022
    Angel X likes this.