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:
    6
    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. Pacguy

    Pacguy :3 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,051
    Location:
    Little Planet (Past)
    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 Active Member Member

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

    [​IMG]
     
  4. MarkeyJester

    MarkeyJester Blue hair? What a freak! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,617
    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 Active Member Member

    Joined:
    Aug 15, 2013
    Messages:
    43
    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 Blue hair? What a freak! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,617
    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 Active Member Member

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

    RuthlessTheHooman Newcomer Trialist

    Joined:
    Nov 20, 2016
    Messages:
    6
    Location:
    Floral Fields Zone
    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 at 12:59 AM
  9. Lunatic

    Lunatic Newcomer Trialist

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

    Chainspike Newcomer Trialist

    Joined:
    May 9, 2017
    Messages:
    6
    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).