A bit rusty

Discussion in 'Discussion and Q&A Archive' started by Dark Lips, Oct 1, 2010.

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
    so I want either delete the hud or move it to a different positon durring a boss... after a bit of experimenting I have come up with this....



    Code:
    Obj21:
    
    		moveq	#0,d0
    
    		move.b	$24(a0),d0
    
    		move.w	Obj21_Index(pc,d0.w),d1
    
    		jmp	Obj21_Index(pc,d1.w)
    
    ; ===========================================================================
    
    Obj21_Index:	dc.w Obj21_Main-Obj21_Index
    
    		dc.w Obj21_Flash-Obj21_Index
    
    ; ===========================================================================
    
    
    
    Obj21_Bosstest:
    
    				tst.b   ($FFFFFF96).w  &#59; is boss active?
    
    				beq.s   Obj21_HUDBoss  &#59; if yes branch to HUDBoss
    
    				
    
    Obj21_Main:				
    
    		addq.b	#2,$24(a0)
    
    		move.w	#$90,8(a0)	 &#59; HUD X positon
    
    				move.w	#$108,$A(a0)   &#59; HUD Y positon
    
    		move.l	#Map_obj21,4(a0)
    
    			move.w	#$6CA,2(a0)
    
    		move.b	#0,1(a0)
    
    		move.b	#0,$18(a0)
    
    				bsr	 Obj21_Flash
    
    
    
    Obj21_HUDBoss:		
    
    				addq.b	#2,$24(a0)
    
    				move.w	#$300,8(a0)	 &#59; HUD X positon durring boss battle
    
    				move.w	#$108,$A(a0)   &#59; HUD Y positon durring boss battle
    
    			   	move.l	#Map_obj21,4(a0)
    
    			move.w	#$6CA,2(a0)
    
    		move.b	#0,1(a0)
    
    		move.b	#0,$18(a0)
    
    
    
    
    
    Obj21_Flash:				
    
    		tst.w	($FFFFFE20).w		  &#59; do you have any rings?
    
    		beq.s	Obj21_Flash2		  &#59; if not, branch
    
    		clr.b	$1A(a0)			  &#59; make all counters yellow
    
    		jmp	DisplaySprite
    
    
    
    ; ===========================================================================

    However... It just glitches and freezes upon start of a level - I know i am on the right track just that I havnt done much asm recently so i am a bit rusty !!!
     
  2. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415
    First of all, you're doing your boss flag check in wrong place. It must be done after object is initialized, i.e. after Obj21_Main.


    Second of all, the main issue with your code is "bsr Obj21_Flash", which branches to the label, but then returns when "rts" is called.


    Also, last four rows in Obj21_HUDBoss are odd. Just put boss flag check in right place and you won't need them anymore and the object will work properly.
     
  3. Dark Lips

    Dark Lips Well-Known Member Member

    Joined:
    Nov 14, 2008
    Messages:
    293
    Location:
    Wolverhampton UK
    are we talking something like this...



    Code:
    Obj21_Main:				
    
    					tst.b   ($FFFFFF96).w	&#59; is boss active?
    
    					beq.s   Obj21_HUDBoss &#59; if yes branch to HUDBoss
    
    					addq.b	#2,$24(a0)
    
    					move.w   #$90,8(a0)	  &#59; HUD X positon
    
    					move.w   #$108,$A(a0)  &#59; HUD Y positon
    
    					move.l	 #Map_obj21,4(a0)
    
    					move.w   #$6CA,2(a0)
    
    					move.b	#0,1(a0)
    
    					move.b	#0,$18(a0)
    
    					bsr	 Obj21_Flash
    
    
    
    Obj21_HUDBoss:		
    
    				   addq.b	#2,$24(a0)
    
    				   move.w	#$300,8(a0)	&#59; HUD X positon durring boss battle
    
    				   move.w	#$108,$A(a0)  &#59; HUD Y positon durring boss battle

    am I on the right track?
     
  4. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415
    Not really...



    Obj21: ; XREF: Obj_Index
    moveq #0,d0


    move.b $24(a0),d0


    move.w Obj21_Index(pc,d0.w),d1


    jmp Obj21_Index(pc,d1.w)


    ; ===========================================================================


    Obj21_Index: dc.w Obj21_Main-Obj21_Index


    dc.w Obj21_ChkBoss-Obj21_Index


    ; ===========================================================================


    Obj21_Main: ; XREF: Obj21_Main


    addq.b #2,$24(a0)


    move.w #$90,8(a0)


    move.w #$108,$A(a0)


    move.l #Map_obj21,4(a0)


    move.w #$6CA,2(a0)


    move.b #0,1(a0)


    move.b #0,$18(a0)


    Obj21_ChkBoss:


    tst.b ($FFFFF7AA).w ; is boss mode on?


    beq.s Obj21_Flash ; if not branch


    ; your code to move the HUD


    Obj21_Flash: ; XREF: Obj21_Main


    tst.w ($FFFFFE20).w ; do you have any rings?


    beq.s Obj21_Flash2 ; if not, branch


    clr.b $1A(a0) ; make all counters yellow


    jmp DisplaySprite



    When saying "after Obj21_Main", I meant after the last row in this label, i.e. after "move.b #0,$18(a0)".


    Also, I see you were using some custom flag for boss checking. I would advise to use $F7AA instead. This flag is used in original code to check boss mode. This is actually one of the flags to lock the screen, which is actives to lock screen during the boss battle.


    And one more thing. In your code, there was:



    tst.b ($FFFFFF96).w ; is boss active?
    beq.s Obj21_HUDBoss ; if yes branch to HUDBoss



    This is logically incorrect, because beq branches to the label when your flag is zero, so it would better to write "if not, branch" instead.
     
    Last edited by a moderator: Oct 1, 2010
  5. Dark Lips

    Dark Lips Well-Known Member Member

    Joined:
    Nov 14, 2008
    Messages:
    293
    Location:
    Wolverhampton UK
    lol - seriously need to get my head back into gear with this, thanks for the help gonna go have a play with it.
     
  6. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    Basically after the tst.b the beq here is like the opposite. Imagine it being beq, but it does what bne does. Well thats how I see it through experiment.( i'm proberly talking a load of bullshit but meh) Vice versa for bne.s when using the tst command.
     
  7. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    Not sure it will work that way either, if I remember correctly, the "main" code is run only once, so it won't get back to that code and check whether you're in boss mode or not. What I did (mine is for the signpost, but there shouldn't be any difference) was putting the code by the end of the flash routines, before the clr.b and jmp.
     
  8. DanielHall

    DanielHall Well-Known Member Member

    Joined:
    Jan 18, 2010
    Messages:
    860
    Location:
    North Wales
    tst tests for 0. So say you wanted to check for boss mode:



    tst.b ($FFFFFF96).w ; is boss active?
    beq.s Obj21_HUDBoss ; if yes branch to HUDBoss



    It takes you to "Obj21_HUDBoss" if it's not, because it tests for 0. So you should reverse bne and beq when talking about tst.
     
  9. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    Basically what I said, minus the testing 0, I think its been mentioned anyways.
     
    Last edited by a moderator: Oct 3, 2010
  10. DanielHall

    DanielHall Well-Known Member Member

    Joined:
    Jan 18, 2010
    Messages:
    860
    Location:
    North Wales
    I wanted to give an example.
     
  11. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    OK, we get the point guys, let's just drop it here so we don't spur any arguments eh? =)
     
  12. Dark Lips

    Dark Lips Well-Known Member Member

    Joined:
    Nov 14, 2008
    Messages:
    293
    Location:
    Wolverhampton UK
    Thanks for all the input guys ^_^
     
Thread Status:
Not open for further replies.