Spike bug / feature problem

Discussion in 'Discussion and Q&A Archive' started by Dark Lips, Oct 6, 2009.

Thread Status:
Not open for further replies.
  1. Dark Lips

    Dark Lips Well-Known Member Member

    Joined:
    Nov 14, 2008
    Messages:
    293
    Location:
    Wolverhampton UK
    Hiya, before you all jump on me and say "megamix copy" or "get your own ideas" I just want to say that this is a valid option for any sonic 1 hack as different people have different tastes... I learned this from reading the various responses to S factor and its Spike bug / Feature so anyway I am trying to make the spikebug have a toggle from the s2 style options screen.....



    Code:
    Obj36_Hurt:			&#59; XREF: Obj36_SideWays; Obj36_Upright
    
    		move.w	($FFFFFF74).w,($FFFF88F8).w&#59; set
    
    				cmpi.w	#1,($FFFF88F8).w&#59; was the Spike Behavior enabled?
    
    			bne.s   Obj36_Hurtoff
    
    		   
    
    Obj36_HurtOn:
    
    			   	tst.b	($FFFFFE2D).w&#59; is Sonic invincible?
    
    		bne.s	Obj36_Display&#59; if yes, branch
    
    			move.l	a0,-(sp)
    
    		movea.l	a0,a2
    
    				lea	($FFFFD000).w,a0
    
    		cmpi.b	#4,$24(a0)
    
    		bcc.s	loc_CF20
    
    		move.l	$C(a0),d3
    
    		move.w	$12(a0),d0
    
    		ext.l	d0
    
    		asl.l	#8,d0
    
    		sub.l	d0,d3
    
    		move.l	d3,$C(a0)
    
    		jsr	HurtSonic		   
    
    		   
    
    Obj36_Hurtoff:
    
    		tst.b	($FFFFFE2D).w&#59; is Sonic invincible?
    
    		bne.s	Obj36_Display&#59; if yes, branch
    
    		tst.w	($FFFFD030).w&#59; +++ is Sonic invulnerable?
    
    		bne.s	Obj36_Display&#59; +++ if yes, branch
    
    		move.l	a0,-(sp)
    
    		movea.l	a0,a2
    
    				lea	($FFFFD000).w,a0
    
    		cmpi.b	#4,$24(a0)
    
    		bcc.s	loc_CF20
    
    		move.l	$C(a0),d3
    
    		move.w	$12(a0),d0
    
    		ext.l	d0
    
    		asl.l	#8,d0
    
    		sub.l	d0,d3
    
    		move.l	d3,$C(a0)
    
    		jsr	HurtSonic
    
    
    
    loc_CF20:
    
    		movea.l	(sp)+,a0
    
    
    
    Obj36_Display:
    
    		bsr.w	DisplaySprite
    
    		move.w	$30(a0),d0
    
    		andi.w	#$FF80,d0
    
    		move.w	($FFFFF700).w,d1
    
    		subi.w	#$80,d1
    
    		andi.w	#$FF80,d1
    
    		sub.w	d1,d0
    
    		cmpi.w	#$280,d0
    
    		bhi.w	DeleteObject
    
    		rts

    At the moment it makes no difference if spikebug/feature is on or off it still ats like Sonic2 any ideas?
     
  2. andlabs

    andlabs Newcomer Member

    Joined:
    Jul 21, 2009
    Messages:
    13
    That's some very messy code, with lots of variables and duplicate code. What you should do instead is have one variable that determines if spike damage behavior is on, and if so, check for invulnerability, then do the rest of the routine.


    Try this:



    Code:
    Obj36_Hurt:		   &#59; XREF: Obj36_SideWays; Obj36_Upright
    
    		tst.w	($FFFFFF74).w&#59; did we turn on spike damage behavior?
    
    		beq	 Obj36_DoDamage&#59; no
    
    		tst.w	 ($FFFFD030)&#59; is Sonic invulnerable?
    
    		bne.s	Obj36_Display&#59; yes
    
    
    
    Obj36_DoDamage:
    
    				   tst.b	($FFFFFE2D).w; is Sonic invincible?
    
    		bne.s	Obj36_Display; if yes, branch
    
    			move.l	a0,-(sp)
    
    		movea.l	a0,a2
    
    ; ...
     
    Last edited by a moderator: Oct 6, 2009
  3. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    This might help you.
     
Thread Status:
Not open for further replies.