Basic Questions and Answers Thread

Discussion in 'Discussion & Q&A' started by Malevolence, Jul 7, 2009.

  1. RandomName

    RandomName Newcomer Member

    Joined:
    Jun 3, 2020
    Messages:
    21
    Location:
    Russia
    Haven't you forgot to change level size in SonLvl?
     
  2. Giovanni

    Giovanni It's Joevanni, not Geovanni. Member

    Joined:
    Apr 16, 2015
    Messages:
    183
    Location:
    Italy
    I clearly have not. I have created a level that is 128 x 16 chunks in size (using a very slightly modded version of SonLVL). It loads "fine" if the previously mentioned value is $80 (with the background spilling to the foreground), but every single level breaks if I change the value in any way. My best theory for the cause of this is the way the game reads the layout. If my theory is correct, the game still interlaces the foreground and the background every #$80 bytes. However, what I'm changing here is how the layouts are written. I've no clue if this theory is correct, and if it is, I've no clue where in Sonic 1's code it is determined that levels should be read like this.
     
    Last edited: Feb 1, 2021
  3. RandomName

    RandomName Newcomer Member

    Joined:
    Jun 3, 2020
    Messages:
    21
    Location:
    Russia
    Haven't you forgot to edit level chunk y position calculation in level rendering, level collision, etc.? If you don't understand what I mean here's the example: To support level width in 256 chunks in GetBlockData in original Sonic 1 in github dissasembly you need to change this:
    Code:
    ; Turn Y coordinate into index into level layout
            move.w    d4,d3
            lsr.w    #1,d3
            andi.w    #$380,d3
    
    Into this:
    Code:
    ; Turn Y coordinate into index into level layout
            move.w    d4,d3
            andi.w    #(8-1)*256,d3
    
     
  4. Giovanni

    Giovanni It's Joevanni, not Geovanni. Member

    Joined:
    Apr 16, 2015
    Messages:
    183
    Location:
    Italy
    This certainly does extend my levels horizontally.
    However, this also directly conflicts with my support for vertically extended levels. The way I coded vertical support actually had me change the #$380 from the original code into a #$780, but now that it's gone, I no longer have vertically extended levels.

    With the horizontal level size extended, how would I extend it vertically?
     
    Last edited: Feb 1, 2021
  5. RandomName

    RandomName Newcomer Member

    Joined:
    Jun 3, 2020
    Messages:
    21
    Location:
    Russia
    I will explain this using this line of code: andi.w #(8-1)*256,d3
    256 is size of each line, (8-1) is amount of all lines in file-1. Sonic 2,3 and Project 128 have FG and BG layout in the same file each BG line after FG line, so amount of lines in file is amount of lines in level*2 in these games.
     
    Giovanni likes this.
  6. Giovanni

    Giovanni It's Joevanni, not Geovanni. Member

    Joined:
    Apr 16, 2015
    Messages:
    183
    Location:
    Italy
    It definitely is a shock for me to find out that it works like this!
    Thank you for all the help and for the easy to understand explanation!
     
  7. RandomName

    RandomName Newcomer Member

    Joined:
    Jun 3, 2020
    Messages:
    21
    Location:
    Russia
    No problem! In addition I will say that both amount of lines in file(without -1 part) and size of each line should be power of 2, because of the how "and" instruction works
     
    Giovanni likes this.
  8. Giovanni

    Giovanni It's Joevanni, not Geovanni. Member

    Joined:
    Apr 16, 2015
    Messages:
    183
    Location:
    Italy
    For future reference, I need a list of objects in Sonic 1 that work properly only if v_objspace is placed at $FFFFD000 (e.g. Bridges, Swinging platforms).
     
  9. Inferno

    Inferno Rom Hacker Member

    Joined:
    Oct 27, 2015
    Messages:
    77
    Location:
    Hidden Palace Zone, Westside Island
    I mean... if you have equates, all of them should work regardless of RAM location, though, from experience, there might be one or two objects that aren't properly equated in GitHub.
     
  10. Giovanni

    Giovanni It's Joevanni, not Geovanni. Member

    Joined:
    Apr 16, 2015
    Messages:
    183
    Location:
    Italy
    Two of them being bridges and swinging platforms in GHZ. If unmodified, they will stop working if the v_objspace equate is moved. Which is why I asked for other objects that would not work if the v_objspace equate was to be moved and that would require modification.
     
  11. Inferno

    Inferno Rom Hacker Member

    Joined:
    Oct 27, 2015
    Messages:
    77
    Location:
    Hidden Palace Zone, Westside Island
    That's strange, I didn't have that issue myself.
     
  12. Stdh

    Stdh Newcomer Trialist

    Joined:
    Jan 11, 2021
    Messages:
    6
    so this may sound stupid but here is my question:
    how can you change the beginning zone? (like beginning in mz instant of ghz)
    im using the asm68k disassembly btw
     
  13. Selbi

    Selbi The Euphonic Mess Retired Staff

    Joined:
    Jul 20, 2008
    Messages:
    2,413
    Location:
    Northern Germany
    In Title_LoadText you'll find a line that sets the level ID ($FFFFFE10) to #0, which is GHZ Act 1. So you want to change that to your desired level ID, using the format #$0Z0A, where Z is the Zone and A is the Act, both starting at zero. So for example staring at SLZ Act 2 would be:

    Code:
            move.w   #$0301,($FFFFFE10).w ; set level to SLZ2
    Do note that the level order does not correspond to the Zone ID order, so better research that too.
     
    Stdh likes this.
  14. AGKRegalEntertainment

    AGKRegalEntertainment Newcomer Exiled

    Joined:
    Feb 2, 2021
    Messages:
    10
    Location:
    Pasig City, Metro Manila
    Hello, I have a problem with GHZ2 new layout.

    s1built.004.png

    How can I fix this?

    NOTE: This is my WIP hack of Green Greens.

    EDIT: Level collision problem?
     
    Last edited: Feb 8, 2021
  15. Soldaten

    Soldaten The Coilgun Retired Staff

    Joined:
    Mar 10, 2016
    Messages:
    240
    Explaining what the problem actually is will go a long way in someone being able to help you. Secondly, you don't need to be creating a new thread every time you want to ask a question, the Basic Q&A thread is there for you.
     
  16. Mr. Joker 27 Music prod.

    Mr. Joker 27 Music prod. Musician, composer, remixer. Member

    Joined:
    Aug 26, 2016
    Messages:
    181
    Pay attention to the staff, the same I told you yesterday, use that thread to ask. Don't waste your trialist post.
     
  17. AGKRegalEntertainment

    AGKRegalEntertainment Newcomer Exiled

    Joined:
    Feb 2, 2021
    Messages:
    10
    Location:
    Pasig City, Metro Manila
    Ok, please delete this thread...
     
  18. Angel X

    Angel X Well-Known Member Member

    Joined:
    Sep 15, 2017
    Messages:
    202
    Location:
    Italy
    Last edited: Feb 10, 2021
  19. PikaNoob

    PikaNoob Newcomer Trialist

    Joined:
    Jan 18, 2021
    Messages:
    5
    Location:
    United Kingdom
    How can you put loops in marble zone and other zones that don't have loops?
     
    Stdh likes this.
  20. Giovanni

    Giovanni It's Joevanni, not Geovanni. Member

    Joined:
    Apr 16, 2015
    Messages:
    183
    Location:
    Italy
    First of all, you'll need to create art and collision for the loop. I'm no artist, so I can not provide advice for that, but I can suggest you look into GHZ's loop collision (which is defined by chunks $35 and $36) so that you can get an idea of how a loop (and its collision) works in Sonic 1.

    Once you have created your loop, you will also need to make changes to this table:

    Code:
    LoopTileNums:
    
    ;         loop    loop    tunnel    tunnel
    
        dc.b    $B5,    $7F,    $1F,    $20    ; Green Hill
        dc.b    $7F,    $7F,    $7F,    $7F    ; Labyrinth
        dc.b    $7F,    $7F,    $7F,    $7F    ; Marble
        dc.b    $AA,    $B4,    $7F,    $7F    ; Star Light
        dc.b    $7F,    $7F,    $7F,    $7F    ; Spring Yard
        dc.b    $7F,    $7F,    $7F,    $7F    ; Scrap Brain
        zonewarning LoopTileNums,4
        dc.b    $7F,    $7F,    $7F,    $7F    ; Ending (Green Hill)
    If you're working from the GitHub disassembly, this table can be found in "_incObj\LevelSizeLoad & BGScrollSpeed.asm" (if you're hacking REV01, the JP1 variant is what you want to edit)

    Here's how it works. You want your loop to be divided into two chunks, and you want your chunks to be one next to another (Again, use chunks $35 and $36 of GHZ for reference). Once you do that, you replace a "loop" value with the ID of the first chunk plus $80 (for example, $35 + $80 = $B5, which explains the $B5 in GHZ's line of the table).

    I should also note that if you're a SonLVL user, you should edit the INI file of your disassembly accordingly.
     
    Last edited: Feb 9, 2021