Basic Questions and Answers Thread

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

  1. Chainspike

    Chainspike Newcomer Trialist

    Joined:
    May 9, 2017
    Messages:
    8
    I have two (hopefully simple) questions. I am using the Sonic 2 2007 Xenowhirl disassembly.

    1. I redrew the ring sprites to use only Sonic's palette using Flex2. The only problem is that rings in the level continue to use palette line 1 (instead of 0). Dropped rings, and rings spawned with debug mode all appear correctly, however.

    2. How would I go about adding water to another level in Sonic 2? I was able to do it with the GitHub disassembly (somewhat) but, I'm not sure how to begin here. Help is appreciated.
     
  2. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    For the second question, adding water is usually a pretty simple process in Sonic 2. To start, the game is hard coded to only support water in zones past Hidden Palace Zone. If you want to add water to a zone slot prior to Hidden Palace (like Emerald Hill, Oil Ocean, Hill Top, etc.), you'll need to modify the game to support full water tables. The Github disassembly does all the hard work for you with the "useFullWaterTables" macros. If you really want to support water in earlier levels, you could examine what the macros that use "useFullWaterTables" do in the Github disassembly to determine what needs to change in your Xenowhirl disassembly. If your just starting, I'd recommend only bothering with zones past Hidden Palace, since that already works with the vanilla Sonic 2 engine.

    As for actually adding water, there are some checks after "Level_ClrRam" that handle setting up water. That does most of the stuff you'd typically think of in terms of adding water to a level. Doing that alone will often cause the underwater palettes to appear like a neon red and green mess; you'd still have to add new palettes for the underwater section. The checks for loading the underwater palettes happen in "Level_LoadPal", and extra palette entries can be added to "PalPointers" to add new color data. I'd recommend examining how the existing levels are handled in these areas and trying to copy what they do.

    From there, water should function as normal, and you'll be able to adjust it's height in the "WaterHeight" table (keep in mind that the table starts with Hidden Palace Zone, and goes up from there; this is why Emerald Hill and other zones don't support water by default; the useFullWaterTables macros in the github disassembly fix this). Finally, you'd have to fix Super Sonic to use the correct underwater palette cycle for the new zone (it happens somewhere in "PalCycle_SuperSonic_normal"). There might be more to it, but I'm not at my home computer right now, so I can't test these things out at the moment.


    EDIT: Now that I think about it, it may be possible to support full water tables for all zones without modifying the engine, just by including data before the label:
    Code:
    ;prior water data, accessed by backtracking from WaterHeight label
        dc.w   $600, $600    ; EHZ
        dc.w   $600, $600    ; Zone 1
        dc.w   $600, $600    ; WZ
        dc.w   $600, $600    ; Zone 3
        dc.w   $600, $600    ; MTZ
        dc.w   $600, $600    ; MTZ
        dc.w   $600, $600    ; WFZ
        dc.w   $600, $600    ; HTZ
    WaterHeight:
        dc.w  $600, $600    ; HPZ
        dc.w  $600, $600    ; Zone 9
        dc.w  $600, $600    ; OOZ
        dc.w  $600, $600    ; MCZ
        dc.w  $600, $600    ; CNZ
        dc.w  $600, $710    ; CPZ
        dc.w  $600, $600    ; DEZ
        dc.w  $410, $510    ; ARZ
        endif
    Don't just take my word for it though, there may be more to it.
     
  3. AsuharaMoon

    AsuharaMoon kakyoin did you lay this egg Member

    Joined:
    Aug 15, 2013
    Messages:
    67
    It's there any way to modify Sonic 1's Title Screen mapping VRAM location without changing its position?

    [​IMG]
     
  4. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Let me make sure I understand you correctly.

    You have moved the VRAM address where the art is loaded to (i.e. you've moved it from $4000 to what looks like $3B00), but now the mappings aren't right, and you want to correct them?

    Somewhere in the routine "TitleScreen:", you will find this:
    Code:
    		lea	(Eni_Title).l,a0 ; load	title screen mappings
    		move.w	#0,d0
    		bsr.w	EniDec
    Replace the "0" in that move instruction with "(($3B00-$4000)/$20)":
    Code:
    		move.w	#(($3B00-$4000)/$20),d0
    The value inside d0 is a word adjustment or "displacement" if you will. It is designed to be applied to the mappings while it is being decompressed. The new value will push the VRAM address of the mappings back by $500 ($28) tiles (basically by the amount in which you pushed the art backwards in VRAM).

    If this is not what you were asking, then you will have to elaborate better.
     
  5. AsuharaMoon

    AsuharaMoon kakyoin did you lay this egg Member

    Joined:
    Aug 15, 2013
    Messages:
    67
    Yes, that's just what I needed. On the one hand it seems to work, but...

    [​IMG]

    I don't know what may be causing this. Moreover, I tried changing the main values to a $3C00 or $3D00, and the results are the same.
     
  6. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    The reason is because when decompressed, tile maps that use 0000 (for the blank tile) are being pushed back just like the rest of the mappings. I did not anticipate this because ironically the title screen art has the first art tile blank, yet the mappings associated with the art did not use this blank tile, and instead used the very first VRAM tile. Ironic and strange actually... especially if you consider that the enigma routine had a method to allow them to dynamically and specifically adjust the mappings for them. I would recommend editing the mappings and manually subtracting $28 from every word except for 0000's.

    However, if you just want a quick solution to this and don't care about optimisation, then you can do this instead:

    Change this:
    Code:
    		lea	(Eni_Title).l,a0 ; load	title screen mappings
    		move.w	#0,d0
    		bsr.w	EniDec
    		lea	($FF0000).l,a1
    		move.l	#$42060003,d0
    		moveq	#$21,d1
    		moveq	#$15,d2
    		bsr.w	ShowVDPGraphics
    To this:
    Code:
    		lea	(Eni_Title).l,a0 ; load	title screen mappings
    		move.w	#0,d0
    		bsr.w	EniDec
    
    		lea	($FF0000).l,a1			; load RAM address of mappings
    		lea	($C00000).l,a5			; load VDP data port
    		lea	$04(a5),a6			; load VDP control port
    		move.l	#$42060003,d4			; prepare VDP VRAM write address
    		move.l	#$00800000,d5			; prepare line advancement amount
    		move.w	#(($3B00-$4000)/$20),d1		; set shift tile amount
    		moveq	#$16-1,d3			; set number of tiles on Y
    
    TS_NextY:
    		move.l	d4,(a6)				; set VDP write mode address
    		add.l	d5,d4				; advance to next plane row
    		moveq	#$22-1,d2			; set number of tiles on X
    
    TS_NextX:
    		move.w	(a1)+,d0			; load tile map
    		beq.s	TS_NoSubtract			; if it's 0 (blank tile), branch
    		add.w	d1,d0				; shift pattern index address
    
    TS_NoSubtract:
    		move.w	d0,(a5)				; save tile map to VRAM
    		dbf	d2,TS_NextX			; repeat for all tiles on X
    		dbf	d3,TS_NextY			; repeat for all tiles on Y
    This will account for tile maps that always need a blank tile.
     
    Last edited: Jun 9, 2018
    AsuharaMoon likes this.
  7. AsuharaMoon

    AsuharaMoon kakyoin did you lay this egg Member

    Joined:
    Aug 15, 2013
    Messages:
    67
    It worked perfectly! Thanks a lot, Markey!
     
  8. RouRouRou

    RouRouRou Ain't no fun if the aliens can't have none. Member

    Joined:
    Nov 20, 2016
    Messages:
    97
    Okay, I have a few questions.

    First off, I intend to make a certain level in my hack an "Act 4."
    The problem is since my ASM knowledge is very limited, I don't know how I'd do this.
    I assume for the art and mappings all I'll need to do is use SonMapEd and MS paint.
    Here's how I THINK I'm meant to do it.

    Open just the art file for the title card letters and numbers, use the image from the SonicRetro S.M.E. guide for some free art space. (Sure, less room in VRAM (that's what it's called right?), but it gets overwritten by various bits of level art after it goes offscreen anyway.) Then I make my image in paint, make mappings for it in MapEd, save art, put the new mappings in with other title card mappings, badda bing badda boom first part done. After that I just adjust the mappings to my needs.

    Why is there practically a tutorial here? Just so people know if I'm doing it right or wrong to tell me.

    What I'm concerned about is HOW I'd actually get the 4 to load.
    I need it to be in Final Zone (SBZ3) as I'm using the Final mappings for another level.

    I assume I'd have to make a routine similar to the "Check SBZ3 (LZ4)" and "Check FZ (Getting used for SYZ3)" routines, but I just need it to change the "3" to a "4."
    Why I want this is because at the moment I have two Scrap Brain Act 3s and that's a bit silly. Making the second SBZ3 into SBZ4 would benefit it as it would logically make more sense.

    My second question is in a different field entirely, what happened to the old Hacking Contest site? (2013-16)
    I decided to go take a look to find out what the Newtrogic High trophy was about and I got a "500 Internal Server Error"
    Is it getting taken down? Is it under maintenance? Or maybe it's just having a server error.


    Thanks in advance.

    IMPORTANT EDIT: I'm using one of the Hivebrain disassembles not SVN/Git.
    Edit 2: Ignore question 2, it's back up. It does seem that you can't download ROMs now...
     
    Last edited: Jun 17, 2018
  9. Lunatic

    Lunatic Newcomer Trialist

    Joined:
    Jul 21, 2017
    Messages:
    5
    Thank you both. ^^
     
    EMK-20218 likes this.
  10. Chainspike

    Chainspike Newcomer Trialist

    Joined:
    May 9, 2017
    Messages:
    8
    Thanks. The water worked very similar to how it does in Github. I also fixed the ring palette issue by using the Github disassembly instead (I prefer it anyway).
     
  11. Tanman Tanner

    Tanman Tanner Well-Known Member Member

    Joined:
    Dec 23, 2016
    Messages:
    116
    Location:
    Buffalo, New York
    I'm currently working on a Sonic 2 SMS ROM Hack (from the disassembly provided by SonicRetro). I can't figure out for the life of me how to change the level order, outside of switching around the level's palettes and tilesets. I believe Ravenfreak produced a tutorial to explain how to do it - if anyone has it/knows what to do, could you please put it here?
     
  12. Prilix

    Prilix A normal romhacker In Limbo

    Joined:
    Sep 19, 2017
    Messages:
    20
    Location:
    Argentina
    One question, is there any way to edit the Special Stages of Sonic 1 (Hivebrain)?
     
  13. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
  14. Tanman Tanner

    Tanman Tanner Well-Known Member Member

    Joined:
    Dec 23, 2016
    Messages:
    116
    Location:
    Buffalo, New York
    Hey everyone, I got another Sonic 2 SMS related question.
    In the game, there's a sound trigger that plays for when a player gets an extra life (via 1-up monitors or getting 100 rings).
    What I want it to do is play the Music_Emerald song in place of it.
    So far, I've done that, but here's the actual problem - the song plays, but it doesn't return to the stage's theme once it's done.
    Here's an example of the problem in action:

    I'm not sure what to actually do to make this properly work, but I do have the code on hand for those willing to help.
    The code affected:
    Code:
    IncrementRingCounter:
    LABEL_25C3:
        ld    a, (RingCounter)
        add   a, $01
        daa
        ld    (RingCounter), a
        ;check for 100 rings
        or    a
        jr    nz, Engine_UpdateRingCounterSprites
        ;we have 100 rings; increment life counter
        ld    hl, LifeCounter
        inc   (hl)
        call  Engine_CapLifeCounterValue
        ld    a, Music_Emerald
        ld    (Sound_MusicTrigger1), a
    
    Collision_Monitor_Rings:    ;4817
        res   0, (hl)
        ld    a, (RingCounter)
        add   a, $10      ;add 10 rings to the counter (bcd)
        daa
        ld    (RingCounter), a
        ld    a, SFX_10Rings
        ld    (Sound_MusicTrigger1), a
    
    .IFEQ Version 2
        call  Engine_UpdateRingCounterSprites
     
        ld    a, (RingCounter)
        cp    $10
        ret   nc
     
        ld    a, (LifeCounter)
        inc   a
        ld    (LifeCounter), a
        ld    a, Music_Emerald
        ld    (Sound_MusicTrigger1), a
        jp    Engine_CapLifeCounterValue
    .ELSE
        jp    Engine_UpdateRingCounterSprites
    .ENDIF
    
    Collision_Monitor_Life:     ;482A
        res     1, (hl)
            ld      a, (LifeCounter)
            cp      $99
            ret     z
        add     a, $01
        daa
            ld      (LifeCounter), a
            ld      a, Music_Emerald
        ld      ($DD04), a
        jp    Engine_CapLifeCounterValue
    
     
    Last edited: Jun 21, 2018
  15. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    This is a shot in the dark, but perhaps the 1up music has a flag in the song itself that returns the music to normal. That's how the 16 bit games handle it.
     
    MarkeyJester likes this.
  16. Xan and Female Silver

    Xan and Female Silver Newcomer Trialist

    Joined:
    Jun 20, 2018
    Messages:
    8
    Location:
    Between dimensions
    So, I was wondering if anyone else has already tried adding the Bounce (Like, Bounce Bracelet) in a rom hack before? If so, what's the hack, and how'd it work out?
     
  17. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,016
    Does the Bubble Shield bounce count? Sonic Classic Heroes does that.
     
    TheInvisibleSun likes this.
  18. Xan and Female Silver

    Xan and Female Silver Newcomer Trialist

    Joined:
    Jun 20, 2018
    Messages:
    8
    Location:
    Between dimensions
    I guess, if it doesn't require the shield.
     
  19. Tanman Tanner

    Tanman Tanner Well-Known Member Member

    Joined:
    Dec 23, 2016
    Messages:
    116
    Location:
    Buffalo, New York
    Thank you for the suggestion.
    You're probably right, but I still can't find it in regards to ASM in the disassembly.
    The only thing I have found that relates to the sound effect itself is its pointer, $A6.
    The disassembly itself doesn't show a SFX file for the pointer, so it might be written in s2.asm or one of the sound_ files.

    EDIT: Found it, see next page.
     
    Last edited: Jun 27, 2018
  20. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    It's not like the shield itself is making Sonic bounce, all you have to do is disable the check for whether Sonic has the bubble shield or not.

    Also I gave Amy a bounce attack in Sonic 2 Secret Rings Edition.