Centiseconds in Sonic 1

Discussion in 'Discussion and Q&A Archive' started by ddrmaxromance, Mar 23, 2008.

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

    ddrmaxromance Well-Known Member Member

    Joined:
    Aug 17, 2007
    Messages:
    102
    Okay, this isn't a big thing for my hack Soniquest, but I've always wanted to insert the milliseconds feature that used in most projects nowadays into my hack.


    As of now, my asm is loading the data, but it's just not showing up correctly on the screen (in the HUD). Instead, it appears in objects, more specifically the starposts.


    [​IMG]


    Wasn't the ASM code for this once available to the public? And if you want to see my coding:



    Code:
    Hud_ChkTime:
    
    		tst.b	($FFFFFE1E).w	; does the time	need updating?
    
    		beq.w	Hud_ChkLives	; if not, branch
    
    		tst.w	($FFFFF63A).w	; is the game paused?
    
    		bne.w	Hud_ChkLives	; if yes, branch
    
    		lea	($FFFFFE22).w,a1
    
    		cmpi.l	#$93B3B,(a1)+	; is the time 9.59?
    
    		beq.w	TimeOver	; if yes, branch
    
    		addq.b	#1,-(a1)
    
    		jsr	Miliseconds
    
    		cmpi.b	#$3C,(a1)
    
    		bcs.w	Hud_ChkLives
    
    		move.b	#0,(a1)
    
    		addq.b	#1,-(a1)
    
    		cmpi.b	#$3C,(a1)
    
    		bcs.s	loc_1C734
    
    		move.b	#0,(a1)
    
    		addq.b	#1,-(a1)
    
    		cmpi.b	#9,(a1)
    
    		bcs.s	loc_1C734
    
    		move.b	#9,(a1)
    
    		bra loc_1c734
    
    		
    
    Miliseconds:
    
    		move.l	a1,-(sp)
    
    		moveq	#0,d0
    
    		moveq	#0,d1
    
    		move.b	($FFFFFE25).w,d1
    
    		move.b	d1,d0
    		divu.w	#3,d0
    		mulu.w	#2,d0
    		add.b	d0,d1
    		sub.w	#1,d1
    		bpl   Negativenum
    		move.w	#0,d1
    
    Negativenum:
    		cmp.w	#100,d1
    		blo.w	Hundrednum
    		move.w	#99,d1
    
    Hundrednum:
    		cmp.b	#3,($FFFFFE25).w
    		bne     Secnum
    		move.w	#5,d1
    
    Secnum:
    		move.l	#$73E00003,d0
    		jsr	Hud_Secs
    		move.l	(sp)+,a1
    		rts


    I have no clue what I'm supposed to do Hud_Secs subroutine, or where to go from here.
     
    Last edited by a moderator: Mar 24, 2008
  2. Shadow Fire

    Shadow Fire Well-Known Member Member

    Joined:
    Aug 6, 2007
    Messages:
    303
    I modified the topic title. You're after centiseconds, I believe. If you're trying to go for what Megamix and The Lost Land have for timers, then yes, it's centiseconds... not milliseconds.


    Centiseconds: xx'yy"zz


    Milliseconds: xx'yy"zzz


    In regards to the routine, I could just pass you my source, but then again, I didn't make it possible for it to be in my hack. Stephen and Ordos (I think) did.
     
  3. ddrmaxromance

    ddrmaxromance Well-Known Member Member

    Joined:
    Aug 17, 2007
    Messages:
    102
    Well, I actually did want milliseconds. But I figured the coding from Megamix and Lost Land could add the additional number into the HUD. It shouldn't be too hard, but I think I screwed up somewhere in my ASM.
     
  4. Tweaker

    Tweaker OI! MIRON! Member

    Joined:
    Aug 10, 2007
    Messages:
    324
    This is a pretty simple one. There's two steps involved.


    First off, see this line?



    Code:
    move.l #$73E00003,d0
    That's a VDP instruction. In this context, what you need to know is that it's setting the destination in VRAM for the numbers to be dynamically reloaded. The parts you want to edit are the first 3 nybbles, or $73E. This is the tile offset in VRAM that the tiles are being loaded to--to convert this value to a VRAM address, multiply it by $20.


    Once you pick the VRAM address you want, divide the value by $20 and replace those 3 nybbles with it. After that, you simply need to edit the HUD mappings to read from that VRAM address in order to display the centisecond counter. You could ask Shadow Fire for help in that regard if you don't know what to do, but otherwise that should be all you need to know.
     
Thread Status:
Not open for further replies.