Basic Questions and Answers Thread

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

  1. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    Thanks but I already knew that. The code for GHZ uses extra stuff to account for the y-axis changing and I don't know how to make it work the code I generated. Also, changing the scrollblock will just make the background stay in place.
     
  2. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    I'm trying to edit the TitleCards in Sonic 2 and I have disabled red, yellow and blue parts. Now as expected just the Level name, Zone and Act appear, however the first part of the level you see is not loaded:

    [​IMG]

    I've looked at the level routine and the titlecard routines but i'm not sure what makes this effect happen. I know it's linked to the blue background that scrolls up at the end of the titlecard sequence, but i'm not sure how to fix this.
     
  3. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    The title card's red/blue/yellow boarders are drawn onto the FG plane, they animated based on drawing new map tiles in the correct calculatory fashion. As a result, the blue one, when finishing, simply triggers the draw code to draw horizontal strips of blocks one frame at a time, one strip at a time, this illusion makes it appear as if the blue board was infront of the level and is scrolling up.

    Since you've removed the code responsible for dealing with the blue board, the level strips do not draw. Therefore, you'll have to do the old method of drawing the level on startup. Now if I recall correctly, Sonic 2 has a flag/trigger which handles an entire screen redraw at any time. I believe it was called "Dirty_flag" (Stupid name, I wanna smash the teeth of the one who came up with it):

    Code:
    		st.b	(Dirty_flag).w				; set entire frame "redraw" flag
     
  4. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Thanks Markey, that works great. Unfortunately i've ran into another issue. I didn't want to ask for help again but this has baffled me.

    The Title Card loads as wanted, then this shows for a frame:

    [​IMG]

     Then the full EHZ palette loads for a few frames, it goes black then fades to this:

    [​IMG]

    It seems to be the title screen palette... For some reason. I got the fade code from Sonic 1, it's also used in Sonic 3K


    move.w #$202F,(Palette_fade_range).w ; fade in 2nd, 3rd & 4th palette lines
    jsr Pal_FadeToAlt
    I added the label Pal_FadeToAlt like it is in Sonic 1


    Pal_FadeTo:
    move.w #$3F,(Palette_fade_range).w
    Pal_FadeToAlt:
    moveq #0,d0
    lea (Normal_palette).w,a0
    ...

    It works fine in Sonic 1, what's wrong here?
     
  5. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    One thing I do know, is that in Sonic 1, only the first palette line is loaded, the other three are faded. In Sonic 2, the first two lines are loaded, the other two are loaded later.

    So your first problem with that blue background there, is the second line being loaded too soon. You also have to take into account the palette cycling will be running, so the water sparkles will start sooner than they are suppose to as well

    As for the palette fading incorrectly in general, you have to have the palette loaded into "Second_palette", the original Sonic 2 I would imagine loaded the level palettes into "Normal_palette" for an immediate effect. Since the title screen was the last screen to load the palette into the "Second_palette", naturally the level would fade the title screen's palette in.

    The "Normal_palette" is constantly displaying, the "Second_palette" is what the Normal_palette" is to fade to.
     
    Last edited by a moderator: May 10, 2015
  6. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,016
    Oh, you poor soul. You're actually going for that? You've ran into the same two major issues I experienced when porting S1's title cards to S2. I still haven't gotten it perfect...

    If I can just go back to your first problem, with the art not loading initially, S1 handles it differently:

    Check out DrawInitialBG, and compare it to S1's LoadTilesFromStart. The big difference is that S1's processes, not only the BG, but the FG. It is done through these lines:


    lea (v_screenposx).w,a3
    lea (v_lvllayout).w,a4
    move.w #$4000,d2
    bsr.s DrawChunks

    The S2 equivalent being:


    lea (Camera_X_pos).w,a3
    lea (Level_Layout).w,a4 ; foreground
    move.w #$4000,d2 ; This selects a VRAM write and moves to PNT A
    bsr.s +

    As for your second issue: as MarkeyJester said, it's all to do with which selection of RAM is written to. Check loadZoneBlockMaps. At the end, it uses PalLoad2. This writes to the 'Normal_palette' he mentioned. S1's LevelDataLoad uses PalLoad1, which writes to 'Second_palette', or 'Target_palette' as the Git disasm likes to call it.
     
    Last edited by a moderator: May 11, 2015
  7. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Thanks again you guys. Just have to work out the kinks with the second palette line now. Got it all working!
     
    Last edited by a moderator: May 11, 2015
  8. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    Could someone please tell me how to use the SolidObject routine in Sonic 2? I found the code below, and have been experimenting with it, but I'm having trouble figuring out some of it...

    move.w #$1B,d1
    move.w #$10,d2
    move.w #$10,d3
    move.w x_pos(a0),d4
    bsr.w SolidObjectI don't know how to define the center of the object (it often has collision "drifting" from where the visible area I want to be solid actually is), and while I'm pretty sure that d2 and d3 are the x and y lengths, d1 and d4 are completely unknown to me...
     
  9. LooneyDude

    LooneyDude Back after a long absence! Member

    Joined:
    Feb 1, 2014
    Messages:
    277
    Location:
    EVERYWHERE
    In Sonic 1, is there a way to have the credits without the gameplay footage? Preferably using the GitHub disassembly?
     
  10. HackGame

    HackGame The ROM Hacker Member

    Joined:
    Jul 18, 2014
    Messages:
    142
    Location:
    Green Hill Zone
    Go to Cred_ClrPal:

    Replace this code:

             bsr.w    EndingDemoLoad

    With this:

            addq.w    #1,(v_creditsnum).w

    (You can remove EndingDemoLoad subroutine since it's useless.)
     
    Last edited by a moderator: May 14, 2015
  11. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    416
    Location:
    Town Creek, AL
    Question concerning extra level in sonic 1. I decided to scrap HPZ in RIS1:AGBW and decided to port HPZ's emerald to go to this extra level. Have not done yet. I've updated sonlvl & decide to delete HPZ blocks chunks & tiles & begin experimenting with the import button, first with a section of smb's 2-2. It loaded GHz tiles instead, layout was accurate but camera was not on sonic and he instantly dies...

    Also tried loading instead GHz tiles blocks chunks & camera still wrong (but that I can fix), the question is, how to load blocks chunks and tiles instead of GHz's
     
  12. ThomasThePencil

    ThomasThePencil resident psycho Member

    Joined:
    Jan 29, 2013
    Messages:
    910
    Location:
    the united states. where else?
    I'm not entirely sure if this has already been asked about or not, so I'll just post it here:

    In the game where everyone's favorite two-tailed fox is introduced (read: Sonic 2), in Chemical Plant, there are small tubes throughout the two acts that take you in at a certain location, bowl you around a bit, and spit you out at a completely different location where a lid with a spring covers the exit. However, it doesn't seem as though these are controlled by any actual code in the game directly, but rather by a few text files or something.

    TL;DR - Can somebody provide an explanation of how the CPZ tubes in Sonic 2 work? The more detailed, the better, but just something enough to help me figure out how to mod where they take you is good.
     
    Last edited by a moderator: May 29, 2015
  13. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    I'm still not sure exactly how the path you take is chosen, but the paths themselves are in two separate tables (misc/obj1E_a and misc/obj1E_b [.bin or .asm depending on the disassembly]), each of which has the same format, starting with a list of word-sized offsets, then each piece of data having the length of the data in bytes, followed by a series of word-sized positions.

    obj1E_a is used for the initial part where they "bowl you around a bit", and the positions are relative to the position of the object. obj1E_b is used for the main part where you're zipping around the level, and the positions are absolute.
     
  14. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    I added CPZ's speed booster to Sonic 1 and removed the flashing code and the stuff for Tails. The problem is the art isn't showing up correctly. Whatever I set for the art it needs to use, it just shows random tiles from the level instead of the piece of art that it's supposed to load. This hasn't happened with other objects I ported.

    It loads tiles for it at $A300 and is lowest on PLC_GHZ2 so it has the most priority.

    Here's the code:

    Obj04: ; Offset_0x016468:
            moveq   #0,d0
            move.b  $24(a0),d0
            move.w  Offset_0x016476(pc,d0),d1
            jmp     Offset_0x016476(pc,d1)

    Offset_0x016476:
            dc.w    Offset_0x01647E-Offset_0x016476
            dc.w    Offset_0x0164B4-Offset_0x016476  

    Offset_0x01647A:
            dc.w    $1000,$0A00

    Offset_0x01647E:
            addq.b  #2,$24(a0)
            move.w  $518,$2(a0)
            move.l  #Map_Obj04,4(a0) ; Offset_0x01658A
            ori.b   #4,$1(a0)
            move.b  #$20,$19(a0)
            move.b  #1,$18(a0)
            move.b  $28(a0),d0
            andi.w  #2,d0
            move.w  Offset_0x01647A(pc,d0),$30(a0)

    Offset_0x0164B4:
            move.w  $8(a0),d0
            move.w  d0,d1
            subi.w  #$10,d0
            addi.w  #$10,d1
            move.w  $C(a0),d2
            move.w  d2,d3
            subi.w  #$10,d2
            addi.w  #$10,d3
            lea     ($FFFFD000).w,a1
            btst    #1,$22(a1)
            bne.s   Offset_0x016540
            move.w  $8(a1),d4
            cmp.w   d0,d4
            bcs     Offset_0x016540
            cmp.w   d1,d4
            bcc     Offset_0x016540
            move.w  $C(a1),d4
            cmp.w   d2,d4
            bcs     Offset_0x016540
            cmp.w   d3,d4
            bcc     Offset_0x016540
            move.w  d0,-(a7)
            bsr     Offset_0x016544
            move.w  (a7)+,d0

    Offset_0x016540:
            lea (Ani_obj04).l,a1
            jsr AnimateSprite
            jmp    MarkObjGone

    Offset_0x016544:
            move.w  $30(a0),$10(a1)
            bclr    #0,$22(a1)
            btst    #0,$22(a0)
            beq.s   Offset_0x016562
            bset    #0,$22(a1)
            neg.w   $10(a1)

    Offset_0x016562:
            move.w  #$F, $2E(a1)
            move.w  $10(a1),$14(a1)
            bclr    #5,$22(a0)
            bclr    #6,$22(a0)
            bclr    #5,$22(a1)
            move.w  #$CC,d0
            jmp     PlaySound              ; Offset_0x0014C6
     
  15. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    Change 'move.w  $518,$2(a0)' to 'move.w  #$518,$2(a0)'.
     
  16. TimpZ

    TimpZ Well-Known Member Member

    Joined:
    Apr 30, 2013
    Messages:
    63
    Location:
    Lund
    This might be a longshot but does anyone have any experience doing edits to Sonic CD 2011? I got the retrun unpacker tool so I have the game assets in workable files but now things become tricky.

    I don't want to do anything particularly fancy, I just want to fix the timer bug where the hundredths value won't be cleared between stages. So I'm wondering if I'm poking around in the game with Cheat Engine to find what happens in RAM, how do I tell what files to edit? Are the bin-files in "scripts" written in m68k assembly or some other language? Any tip in general where to look?
     
  17. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    ​I forgot where and when I read that (probably it was tasvideos but I cba to look for the topic), but the path is chosen by looking at the seconds in the timer. If it's even, it takes a path; if it's odd, it takes the other path.
     
  18. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    ​That's only part of it, some subtypes have only one path that they use all the time, and there are some other weird things happening in the code, and that doesn't say how it decides which path from the path list to use.
     
  19. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    Test, please ignore this post.  Testing for double (triple) posts...

    EDIT: Why are you testing?  Here is the reason​.
     
    Last edited by a moderator: Jun 3, 2015
  20. Niko

    Niko All's well that ends well, right? Member

    Joined:
    Mar 1, 2014
    Messages:
    245
    Location:
    $C800
    I have a quick question about using online emulators to share our hacks on here?
    Are we allowed to embed an online emulator (such as NESbox's Sega Genesis emulator) to present our hacks, as long as we ALSO include a download nearby?

    (I figure this doesn't need it's own topic, so I ask here.)