[S1] Considerably speeding up level loading

Discussion in 'Engineering & Reverse Engineering' started by Natsumi, Nov 10, 2014.

  1. Cyber Axe

    Cyber Axe

    Oldbie
    D'oh i was using this for for reference https://info.sonicretro.org/SCHG:Sonic_the_Hedgehog_(16-bit)/RAM_Editing, and $39 aligned with a variable that the spin-dash guide used so thought i could use it.

    I moved spin-dash to $29 as i thought that meant it would end up using the unused 7th bit from $22 (which seems to work fine)

    Edit: I am now using this v_objspace+$39 which seems to work speed wise, though now i'm getting a corrupt title card and still getting 5 coins on respawn, which i'm now looking into
     
    Last edited: Jun 21, 2020
  2. MainMemory

    MainMemory

    Have no fear...Amy Rose is here! Tech Member
    4,412
    67
    28
    SonLVL
    Why are you putting it in Sonic's Object RAM? Find an unused byte anywhere else in RAM.
     
  3. Cyber Axe

    Cyber Axe

    Oldbie
    Hadn't noticed it was in Sonics space i'd missed that last time i looked (tiredness and ADHD don't combo well),

    I have tried several values including $FFFFCF80 which is not recommended but is the start of the largest unused range from the looks of it (I had also tried several of these values previously before i had erroneously settled on the $39 offset)

    $FFFFCF80 still gives garbled title screen but has the fast loading and the ring issue, the several other unused values I've tried have similar coin effects, slow load or a black screen.

    Am i reading the offsets correctly? does each offset = 1 byte? or do i need a range of FF in size?

    plus surely only 3 bits are needed to store all the zones? unless it also needs to store the acts then 5?

    going to check over all the code again to make sure I've not missed something

    Edit: I fixed the ring issue, i had a variable accidentally set to 1 that wasn't clearing the rings on level reload
     
    Last edited: Jun 21, 2020
  4. MainMemory

    MainMemory

    Have no fear...Amy Rose is here! Tech Member
    4,412
    67
    28
    SonLVL
    You only need one byte of RAM for this.
     
  5. Cyber Axe

    Cyber Axe

    Oldbie
    I said bits not bytes
     
  6. MainMemory

    MainMemory

    Have no fear...Amy Rose is here! Tech Member
    4,412
    67
    28
    SonLVL
    Well you can't allocate less than one byte, so I don't see why it matters.
     
  7. Cyber Axe

    Cyber Axe

    Oldbie
    I merely mentioned it as those extra bits can be used elsewhere to keep ram use to a minimum, though granted Sonic 1 doesn't seem to be that hurting for available unused ram.
     
  8. MainMemory

    MainMemory

    Have no fear...Amy Rose is here! Tech Member
    4,412
    67
    28
    SonLVL
    Yeah but then you're wasting cycles masking and shifting every time you want to read or write the variable.
     
  9. Cyber Axe

    Cyber Axe

    Oldbie
    For some reason i get corrupt title cards so I added the title card code back into Level_ClrStuff:

    Note: I've renamed the Nem_ graphics to Gra_ So i can load in different compression in alternate primary pattern files

    Code (Text):
    1.  
    2. Level_ClrStuff:
    3.         move.w    d0,(v_rings).w                    ; clear rings
    4.         move.l    d0,(v_time).w                        ; clear time
    5.         move.b    d0,(v_shoes).w                    ; clear speed shoes
    6.         move.b    d0,(v_shield).w                    ; clear shield
    7.         ; @Note test invinciblity as that probably needs cleared as you can die while invincible on GHZ 2
    8.         move.w    d0,(v_framecount).w
    9.  
    10.         ; Uncompressed Level Code by Aurora Fields - Fixes Title Card Corruption in Github Disassembly (however has a slightly animation bug with act number, happens with original title card code too)
    11.         locVRAM    $B000,vdp_control_port
    12.         lea    Gra_TitleCard,a0                                                                                             ; load title card patterns
    13.         move.l  #((Gra_TitleCard_End-Gra_TitleCard)/32)-1,d0                            ; the title card art length in tiles
    14.         jsr LoadUncArt                                                                                              ; load uncompressed art
    15.  
    16.  
    17.         jsr    (Hud_Base).l
    18.       bra.w    Level_ClrRam
    19.