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:
    85
    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;)