How to optimize Green Hill Zone PLC in Sonic 1

Discussion in 'Tutorials' started by BetaFilter, Jan 22, 2022.

  1. BetaFilter

    BetaFilter Newcomer Member

    Joined:
    Jul 28, 2021
    Messages:
    16
    Location:
    Canada
    While I was exploring through the various lines of Sonic 1, I realized that Green Hill Zone's art is split into 2 separate parts. The first part is loaded on the title screen while the other is for the main levels. Now take that information into consideration, part 1 of Green Hill Zone's tiles are loaded on the Title Screen, and the pattern load cues load part 1 again, which is pointless considering that they were already loaded on the Title Screen.

    To start off, go to _inc/Pattern Load Cues.asm and find the pattern load cues for Green Hill Zone, which should look like this:

    Code:
    ; ---------------------------------------------------------------------------
    ; Pattern load cues - Green Hill
    ; ---------------------------------------------------------------------------
    PLC_GHZ:   dc.w ((PLC_GHZ2-PLC_GHZ-2)/6)-1
           plcm   Nem_GHZ_1st, 0       ; GHZ main patterns
           plcm   Nem_GHZ_2nd, $39A0   ; GHZ secondary   patterns
           plcm   Nem_Stalk, $6B00   ; flower stalk
           plcm   Nem_PplRock, $7A00   ; purple rock
           plcm   Nem_Crabmeat, $8000   ; crabmeat enemy
           plcm   Nem_Buzz, $8880       ; buzz bomber enemy
           plcm   Nem_Chopper, $8F60   ; chopper enemy
           plcm   Nem_Newtron, $9360   ; newtron enemy
           plcm   Nem_Motobug, $9E00   ; motobug enemy
           plcm   Nem_Spikes, $A360   ; spikes
           plcm   Nem_HSpring, $A460   ; horizontal spring
           plcm   Nem_VSpring, $A660   ; vertical spring
    
    PLC_GHZ2:   dc.w ((PLC_GHZ2end-PLC_GHZ2-2)/6)-1
           plcm   Nem_Swing, $7000   ; swinging platform
           plcm   Nem_Bridge, $71C0   ; bridge
           plcm   Nem_SpikePole, $7300   ; spiked pole
           plcm   Nem_Ball, $7540       ; giant   ball
           plcm   Nem_GhzWall1, $A1E0   ; breakable wall
           plcm   Nem_GhzWall2, $6980   ; normal wall
       PLC_GHZ2end:
    To make it so it doesn't reload the same art, remove this line:

    Code:
    plcm   Nem_GHZ_1st, 0       ; GHZ main patterns
    And there you go! Now when Green Hill Zone gets loaded, it skips straight to loading the secondary patterns! No halting for loading what's already loaded!

    HOWEVER! When you complete a Special Stage and return back to Green Hill Zone, it doesn't load the main patterns, resulting in a mess of Special Stage tiles!

    This can be fixed though, so go to SS_NormalExit, and paste this:

    Code:
           cmpi.b   #id_GHZ,(v_zone).w ; is level GHZ?
           bne.s   @notload   ; if not, branch
           locVRAM   0
           lea   (Nem_GHZ_1st).l,a0 ; load GHZ patterns
           bsr.w   NemDec
       @notload:


    after this:

    Code:
    bsr.w   PaletteWhiteOut
    And there you have it! Now after you beat a Special Stage and you are sent back to Green Hill Zone, it won't be a mess of Special Stage tiles anymore!

    Hopefully this tutorial helps those who wanna optimize Sonic 1 even more.
     
  2. Speems

    Speems Well-Known Member Member

    Joined:
    Mar 14, 2017
    Messages:
    66
    Location:
    Rochester Hills, MI
    Ummm, about that SS_NormalExit code...
    [​IMG]
    It was right after PaletteWhiteOut like you said yet it refused to build.
     
  3. DeltaWooloo

    DeltaWooloo dead account Member

    Joined:
    Aug 7, 2019
    Messages:
    356
    An invalid symbol name tells me you might be using an AS disassembly. It doesn't recognize labels with the @ symbol in mind. Change @notload to .notload or use + rather than the label to fix it.
     
    Last edited: Jan 23, 2022
  4. BetaFilter

    BetaFilter Newcomer Member

    Joined:
    Jul 28, 2021
    Messages:
    16
    Location:
    Canada
    It seems that you are using AS, all you need to do is change that @ to a ., or you can change the entire label to a + and it should fix the error.
     
  5. tilk

    tilk Active Member Member

    Joined:
    Feb 2, 2012
    Messages:
    30
    there's a problem with your aproach: if you make GHZ NOT the first level, then you will still get a mess of art tiles...
     
    DeltaWooloo likes this.
  6. BetaFilter

    BetaFilter Newcomer Member

    Joined:
    Jul 28, 2021
    Messages:
    16
    Location:
    Canada
    Yeah, it's because the title screen loads Green Hill Zone's blocks, art, and chunks first before any other level, so I wasn't thinking too much for if you had a custom title screen. However, if it were to be replaced with let's say Marble Zone, then you'd have to combine the separated Nemesis files of Green Hill Zone into one (which this is done by decompressing the art, attaching the second half to the end of the first half in a hex editor, then re-compressing in Nemesis), which will take the same exact amount of time to load as in the original, but reduces the pattern load cues list. Hopefully this helps.
     
  7. Hame

    Hame Newcomer Trialist

    Joined:
    Jan 12, 2021
    Messages:
    7
    Location:
    Spain
    there is an error and that is that in the staff roll scene when loading green hill also spoils
     
  8. ralakimus

    ralakimus Mommy says I'm just built different Member

    Joined:
    Aug 26, 2013
    Messages:
    1,096
    To be quite frank, I don't really see this as an "optimization", considering that you have to hack in fixes for loading the rest of the tiles in the places where Green Hill Zone isn't being loaded after the title screen to even work properly. The difference in loading time is quite minuscule, too. All this really does is optimize 1 scenario, while slightly complicating the others.
     
    Last edited: May 25, 2022
    DeltaWooloo and ProjectFM like this.
  9. BetaFilter

    BetaFilter Newcomer Member

    Joined:
    Jul 28, 2021
    Messages:
    16
    Location:
    Canada
    Yeah this isn't really an optimization, more so just lazily removing one line of code and then adding a lot of fixes later, my mistake there. I'd highly recommend porting over Sonic 2's Level Art Loader to Sonic 1 as that's incredibly fast and you don't need to do all these little extra fixes, this tutorial is not as useful as Sonic 2's Level Art Loader ported to Sonic 1.