My question topic

Discussion in 'Discussion and Q&A Archive' started by sonic, Jul 8, 2008.

Thread Status:
Not open for further replies.
  1. sonic

    sonic Well-Known Member Member

    Joined:
    Mar 27, 2008
    Messages:
    62
    Location:
    Michigan
    I want to start a mod for Sonic the Hedgehog, using the 2005 split disassembly and I have some questions:


    1. How do you port music from Sonic the Hedgehog 2 beta to Sonic the Hedgehog?


    2. How do I add a 0 for the tens place, when displaying ring counts less than ten? EX: 00, 01, 02, etc. instead of just 0, 1, 2...


    3. How do I edit the way the camera works?


    Those are all of the questions I have right now,
     
  2. shobiz

    shobiz Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    198
    Location:
    Karachi, Pakistan
    http://info.sonicretro.org/SCHG:Music_Hack...3E_Sonic_2_Beta


    The Retro wiki has a lot of info, you should go through it

    Should theoretically be quite easy to do once you get the hang of ASM and take a look at the HUD routines. I'm guessing there'll be code to wipe the tens place for ring counts less than 10, so you'll probably have to remove that.

    That's a pretty general question. What effect are you aiming for?
     
  3. sonic

    sonic Well-Known Member Member

    Joined:
    Mar 27, 2008
    Messages:
    62
    Location:
    Michigan
    For the camera, I want to have it so Sonic can be off centered like in this Sonic the Hedgehog 2 mock-up picture:


    [​IMG]


    Alright, I'll tell you just exactly why I asked these questions. I want to make the game behave like that screenshot. I asked about the music because I specifically wanted to port the unused Oil Ocean Zone music to the first game. I asked about the ring counter because it's like that in this mock-up. I asked about the camera because of the mock-up, too. I want to turn Marble Zone into this area. The hacks that already had a desert level didn't satisfy me. Plus, they were Sonic the Hedgehog 2 hacks. It would be a more believable hack if it were a Sonic the Hedgehog hack, because the mock-up has Sonic's sprites from the first game. I want the camera to only move when Sonic goes off of the screen. This way, he can be off centered. I'm going to name the area Sabaku Zone because it fits over Marble Zone. It's the same number of title card letters. How do I change the camera so it behaves like I talked about?
     
  4. shobiz

    shobiz Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    198
    Location:
    Karachi, Pakistan
    Hmm, that's a bit extreme and would make the game quite hard to play - I'd suggest keeping at least some boundary.


    Anyway, to answer your question, in ScrollHoriz2, you have these lines:



    Code:
    ScrollHoriz2:			&#59; XREF: ScrollHoriz
    
    		move.w	($FFFFD008).w,d0&#59; get Sonic's X position
    
    		sub.w	($FFFFF700).w,d0&#59; subtract camera X position
    
    		subi.w	#$90,d0	&#59; is the result less than 144?
    
    		bcs.s	loc_65F6&#59; if it is, branch to the main scroll routine
    
    		subi.w	#$10,d0	&#59; subtract 16 more. Is the result still positive?
    
    		bcc.s	loc_65CC&#59; if it is (meaning Sonic's X pos - camera X pos >= 160), branch
    
    		clr.w	($FFFFF73A).w&#59; otherwise, don't scroll
    
    		rts
    Comments are added by me. As you can see, this is the routine which decides whether to scroll horizontally or not on a particular frame. You can modify the numbers $90 and $10 to set different scroll boundaries.


    As an example, instead of this, say you want the screen to only scroll when Sonic is within 80 ($50) pixels of either edge. Obviously you'd change the $90 to $50. To calculate the second value, remember that you're double subtracting. In order for Sonic to be $50 pixels from the right edge of the screen, he'd be ($140 - $50) = $F0 pixels from the left edge. However, since you've already subtracted $50, you'd need to subtract ($F0 - $50) = $A0 more, therefore you'd change the $10 to $A0. Hope this helps
     
    Last edited by a moderator: Jul 8, 2008
  5. sonic

    sonic Well-Known Member Member

    Joined:
    Mar 27, 2008
    Messages:
    62
    Location:
    Michigan
    Thanks, I'll try it later.


    I tried it and it worked! Thanks. I think I'll leave the camera alone, though. It causes Sonic to die in some spots because he gets too far ahead.
     
    Last edited by a moderator: Jul 9, 2008
  6. shobiz

    shobiz Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    198
    Location:
    Karachi, Pakistan
    If you're talking about the GHZ double S-pipe, it's a pretty easy fix, courtesy of Xenowhirl and Lightning - change Boundary_Bottom to:



    Code:
    Boundary_Bottom:
    
    		move.w	($FFFFF726).w,d0
    
    		move.w	($FFFFF72E).w,d1
    
    		cmp.w	d0,d1		&#59; screen still scrolling down?
    
    		blt.s	Boundary_Bottom_locret&#59; if so, don't kill Sonic
    
    		cmpi.w	#$501,($FFFFFE10).w&#59; is level SBZ2 ?
    
    		bne.w	KillSonic	&#59; if not, kill Sonic
    
    		cmpi.w	#$2000,($FFFFD008).w
    
    		bcs.w	KillSonic
    
    		clr.b	($FFFFFE30).w	&#59; clear lamppost counter
    
    		move.w	#1,($FFFFFE02).w&#59; restart the level
    
    		move.w	#$103,($FFFFFE10).w&#59; set level to SBZ3 (LZ4)
    
     
    
    Boundary_Bottom_locret:
    
    		rts
    (taken from http://info.sonicretro.org/SCHG_How-to:Add..._1#Fixing_bugs)
     
  7. Jimmy

    Jimmy "GIVE HIM BREAD FIST!" Member

    Joined:
    Apr 2, 2008
    Messages:
    41
    Location:
    Slough. England
    I'd also recommend getting rid of the speed cap =P
     
  8. sonic

    sonic Well-Known Member Member

    Joined:
    Mar 27, 2008
    Messages:
    62
    Location:
    Michigan
    Thanks for the info. I'm going to edit the main scroll routine because if I made it so that the camera moved when Sonic was off of the screen, I'd have to change how far over the camera moves.
     
    Last edited by a moderator: Jul 9, 2008
  9. shobiz

    shobiz Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    198
    Location:
    Karachi, Pakistan
    If you want to see an extreme scroll edit example, you can take a look at Sonic 1: Bouncy Edition - among loads of other changes, the hack features a snap screen.
     
  10. sonic

    sonic Well-Known Member Member

    Joined:
    Mar 27, 2008
    Messages:
    62
    Location:
    Michigan
    Nice! That snap screen is just what I was looking for. I want to use it in my hack. How do you do that? Also, I noticed that he ported the REV 01 deformation effects. I tried to do that and it didn't work. It gave me errors when it was building the rom. I followed the guide on Sonic Retro, too. I don't know what I did wrong.
     
  11. shobiz

    shobiz Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    198
    Location:
    Karachi, Pakistan
    TBH I'm not really sure - making the screen scroll only when the player is right at the edge is easy, but Sonic 1's edge tile update routines can I believe only handle 16 pixels changes per frame, so to make all 320 pixels update instantly would require modifying LoadTilesAsYouMove as well.

    What error messages did you get?
     
  12. sonic

    sonic Well-Known Member Member

    Joined:
    Mar 27, 2008
    Messages:
    62
    Location:
    Michigan
    The error message said that part of the rom was out of memory. I'll post a screenshot of the error message.

    I'll try modifying LoadTilesAsYouMove and see what I get. I'll need to redo porting the deformation effects before I can get the message again, because I deleted that ASM file.


    This is the code for LoadTilesAsYouMove:



    Code:
    LoadTilesAsYouMove:		&#59; XREF: Demo_Time
    
    		lea	($C00004).l,a5
    
    		lea	($C00000).l,a6
    
    		lea	($FFFFFF32).w,a2
    
    		lea	($FFFFFF18).w,a3
    
    		lea	($FFFFA440).w,a4
    
    		move.w	#$6000,d2
    
    		bsr.w	sub_6954
    
    		lea	($FFFFFF34).w,a2
    
    		lea	($FFFFFF20).w,a3
    
    		bsr.w	sub_69F4
    
    		lea	($FFFFFF30).w,a2
    
    		lea	($FFFFFF10).w,a3
    
    		lea	($FFFFA400).w,a4
    
    		move.w	#$4000,d2
    
    		tst.b	(a2)
    
    		beq.s	locret_6952
    
    		bclr	#0,(a2)
    
    		beq.s	loc_6908
    
    		moveq	#-$10,d4
    
    		moveq	#-$10,d5
    
    		bsr.w	sub_6C20
    
    		moveq	#-$10,d4
    
    		moveq	#-$10,d5
    
    		bsr.w	sub_6AD8
    
    
    
    loc_6908:
    
    		bclr	#1,(a2)
    
    		beq.s	loc_6922
    
    		move.w	#$E0,d4
    
    		moveq	#-$10,d5
    
    		bsr.w	sub_6C20
    
    		move.w	#$E0,d4
    
    		moveq	#-$10,d5
    
    		bsr.w	sub_6AD8
    
    
    
    loc_6922:
    
    		bclr	#2,(a2)
    
    		beq.s	loc_6938
    
    		moveq	#-$10,d4
    
    		moveq	#-$10,d5
    
    		bsr.w	sub_6C20
    
    		moveq	#-$10,d4
    
    		moveq	#-$10,d5
    
    		bsr.w	sub_6B04
    
    
    
    loc_6938:
    
    		bclr	#3,(a2)
    
    		beq.s	locret_6952
    
    		moveq	#-$10,d4
    
    		move.w	#$140,d5
    
    		bsr.w	sub_6C20
    
    		moveq	#-$10,d4
    
    		move.w	#$140,d5
    
    		bsr.w	sub_6B04
    
    
    
    locret_6952:
    
    		rts	
    
    ; End of function LoadTilesAsYouMove
     
    Last edited by a moderator: Jul 11, 2008
Thread Status:
Not open for further replies.