Basic Questions and Answers Thread

Discussion in 'Discussion & Q&A' started by Malevolence, Jul 7, 2009.

  1. DeoxysKyogre

    DeoxysKyogre No idea what to put here .-. Member

    Joined:
    Jan 31, 2009
    Messages:
    298
    Thanks, it worked.
     
  2. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415
    Bosses in Sonic 1 have the copies of their coordinates in $30(a0) (X-axis) and $38(a0) (Y-axis). These are "clean" (or maybe "raw", I don't know the exact word to describe, poor my English) coordinates, so you'd better to use them in your code.


    This is done to let the boss move slightly up and down during the flight, so the ship won't loose its course.


    There is also a byte to set the Y-amplitude, $3F(a0). Every time the sine is calculated from the value of this byte, and the result is added to raw Y-pos ($38(a0)):



    ; Move ship slightly up and down during the flight
    move.b $3F(a0),d0 ; Y-amplitude


    jsr (CalcSine).l


    asr.w #6,d0 ; d0 contains sine, divide it by 64


    add.w $38(a0),d0 ; add secondary Y-pos to d0


    move.w d0,$C(a0) ; move the result to actual Y-pos


    move.w $30(a0),8(a0)


    addq.b #2,$3F(a0) ; increase the amplitude value



    So, $C(a0) is Y-pos including the flying amplitude. That's why its value is slightly changing every frame, so it useless to use it for checking bosses coordinates.


    Use $38(a0), like Animemaster said.


    EDIT: Heh, the problem is already solved, I type for too long time =\
     
    Last edited by a moderator: Jan 22, 2011
  3. EMK-20218

    EMK-20218 The Fuss Maker Exiled

    Joined:
    Aug 8, 2008
    Messages:
    1,067
    Location:
    Jardim Capelinha, São Paulo
    Instead of SonEd2, try edit it using the Esrael Neto's Assembler Editor.
     
    Last edited by a moderator: Jan 22, 2011
  4. FireRat

    FireRat Do Not Interact With This User, Anywhere!!! Exiled

    Joined:
    Oct 31, 2009
    Messages:
    535
    Yes. If you don't know how, I can send you some projects of levels and specialstages
     
  5. DeoxysKyogre

    DeoxysKyogre No idea what to put here .-. Member

    Joined:
    Jan 31, 2009
    Messages:
    298
    Now, I'm trying that the boss hits Sonic when Sonic tries to hit him with certain frames


    So, basically what I did is:



    Code:
    loc_177E6:
    
    				cmpi.b	#0,($FFFFFE11).w; is act number 02 (act 3)?
    
    		beq.w	CutsceneEggman; if yes, branch
    
    		move.b	$3F(a0),d0
    
    				
    
    		jsr	(CalcSine).l
    
    		asr.w	#6,d0
    
    		add.w	$38(a0),d0
    
    		move.w	d0,$C(a0)
    
    		move.w	$30(a0),8(a0)
    
    		addq.b	#2,$3F(a0)
    
    			   
    
    		cmpi.b	#8,$25(a0)
    
    		bcc.w	locret_1784A
    
    		tst.b	$22(a0)
    
    		bmi.w	loc_1784C
    
    				
    
    		tst.b	$20(a0)
    
    		bne.w	locret_1784A
    
    				 cmpi.b  #$2,$1A(a0)
    
    				beq.w   Hurt
    
    				cmpi.b  #$3,$1A(a0)
    
    				beq.w   Hurt
    
    				cmpi.b  #$4,$1A(a0)
    
    				beq.w   Hurt
    
    				cmpi.b  #$5,$1A(a0)
    
    				beq.w   Hurt
    
    				cmpi.b  #$6,$1A(a0)
    
    				beq.w   Hurt 
    
    		tst.b	$3E(a0)
    
    		bne.s	Obj3D_ShipFlash
    
    				
    
    		
    
    		move.b	#$50,$3E(a0); set number of	times for ship to flash
    
    		move.w	#$AC,d0
    
    		jsr	(PlaySound_Special).l;	play boss damage sound

    But when I hit the boss, when he uses the frames, even Sonic's not touching him, he gets hurt. How do I fix that?


    EDIT: Hurt jumps relatively to Obj36_Hurt.


    EDIT2: a0's the boss
     
    Last edited by a moderator: Jan 23, 2011
  6. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415
    I guess this happens because you don't check if Sonic's touched the boss, so Sonic gets hurt anyways after the boss was hit:



    tst.b $20(a0) ; is touch response zero (the boss was hit)?
    bne.w locret_1784A ; if not, branch


    ; you code, that hurt Sonic if boss uses specific frames



    The touch response byte ($21) is cleared after Sonic hits the object, the boss in our case. This happens in TouchResponse subroutine. Then, if boss code notes this byte to be cleared, the ship start flashing for several frames. After flashing is over, touch response byte is restored with $F value.


    Using jumping to Obj36_Hurt is not really good decision. If you do so, you'll have to have extra checks for if Sonic has touched the object. It's far better to use touch response byte, because it was designed for the cases like this.


    Set this byte to $81 if you want the boss to hurt Sonic anyways. Another part of engine, TouchResponse subroutine will do the rest for you.


    So, change your code to something like this:



    loc_177E6:
    cmpi.b #0,($FFFFFE11).w; is act number 02 (act 3)?


    beq.w CutsceneEggman; if yes, branch


    move.b $3F(a0),d0


    jsr (CalcSine).l


    asr.w #6,d0


    add.w $38(a0),d0


    move.w d0,$C(a0)


    move.w $30(a0),8(a0)


    addq.b #2,$3F(a0)


    cmpi.b #8,$25(a0)


    bcc.w locret_1784A


    tst.b $22(a0)


    bmi.w loc_1784C


    tst.b $20(a0)


    bne.w TestFrames


    < ... > ; flashing stuff


    TestFrames:


    cmpi.b #$2,$1A(a0)


    beq.w @Hurt


    cmpi.b #$3,$1A(a0)


    beq.w @Hurt


    cmpi.b #$4,$1A(a0)


    beq.w @Hurt


    cmpi.b #$5,$1A(a0)


    beq.w @Hurt


    cmpi.b #$6,$1A(a0)


    beq.w @Hurt


    move.b #$F,$21(a0)


    rts


    @Hurt move.b #$81,$21(a0)


    rts
     
  7. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    Quoting due to new page:

    Ah you got in before me!, yeah pretty much what was said above really. Touchresponse does basically what you need.
     
    Last edited by a moderator: Jan 24, 2011
  8. FireRat

    FireRat Do Not Interact With This User, Anywhere!!! Exiled

    Joined:
    Oct 31, 2009
    Messages:
    535
    Hi. I'm creating a cutscene, but this time I have a small problem.


    I maked sonic invicible, and maked it float on the air. It's to make the camera scroll correctly. But when I need restore sonic to the normal mode, sonic falls really to QUICKLY and dies. How to reset the fall velocity?
     
  9. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Code:
    		move.w	#$0000,($FFFFD012).w
    
     
  10. FireRat

    FireRat Do Not Interact With This User, Anywhere!!! Exiled

    Joined:
    Oct 31, 2009
    Messages:
    535
    Thanks!!
     
  11. HiddenPalace

    HiddenPalace Active Member Member

    Joined:
    Feb 9, 2010
    Messages:
    33
    I made a new level and everything builds correctly but the game won't load the new level art.


    This level has all new tiles and is not related to the other sonic 2 levels.


    I am using the sonic 2 svn disassembly.


    Why won't it load the new art?
     
  12. FireRat

    FireRat Do Not Interact With This User, Anywhere!!! Exiled

    Joined:
    Oct 31, 2009
    Messages:
    535
    How is your "PLC" and your "Mainlevelloadblocks" (or something like this)?
     
    Last edited by a moderator: Jan 26, 2011
  13. FireRat

    FireRat Do Not Interact With This User, Anywhere!!! Exiled

    Joined:
    Oct 31, 2009
    Messages:
    535
    New question: How to flip horizontally a sprite of a object?
     
  14. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415

    bset #0,$22(a0)



    In fact, there is bit #0 in 1(a0), which is basically designed to do the same, but it's better to use $22(a0).


    In most of objects, first two bits of render flag, byte 1, are updated according to the same bits in byte $22. Normally, AnimateSprite routine does it.
     
    Last edited by a moderator: Jan 30, 2011
  15. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    There are several ways (N = null/ignore):


    NNNNNNNY Setting bit Y of the $22nd byte for mirror:



    bset #$00,$22(a?)
    ori.b #$01,$22(a?)


    move.b #$01,$22(a?)



    NNNNNNYN Setting bit Y of the $22nd byte for flip:



    bset #$01,$22(a?)
    ori.b #$02,$22(a?)


    move.b #$02,$22(a?)



    NNNNYNNN NNNNNNNN Setting bit Y of the $02nd byte for mirror:



    bset #$03,$02(a?)
    ori.b #$08,$02(a?)


    move.b #$08,$02(a?)



    NNNYNNNN NNNNNNNN Setting bit Y of the $02nd byte for flip:



    bset #$04,$02(a?)
    ori.b #$10,$02(a?)


    move.b #$10,$02(a?)



    The mappings for Sonic 1:



    dc.b $YY,$SS,$V1,$V2,$XX



    V1 = NNNYXNNN


    X = mirror bit


    Y = flip bit


    The mappings for Sonic 2:



    dc.b $YY,$SS,$V1,$V2,$NN,$NN,$XX,$XX



    V1 = NNNYXNNN


    X = mirror bit


    Y = flip bit
     
  16. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    Question: how could I monitor the content of the vram? (in real time)


    Regen has that in the vdp debugger, but it won't let me see the bottom of the vram (the last 30 tiles). :/
     
  17. FireRat

    FireRat Do Not Interact With This User, Anywhere!!! Exiled

    Joined:
    Oct 31, 2009
    Messages:
    535
    Last edited by a moderator: Jan 30, 2011
  18. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    Same problem, the last 30 tiles are missing :|


    Maybe it's related to my screen's dpi. Well, I guess I'll dump the vram instead :/
     
  19. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Hmm, I'm gonna try something unique here and pretty cool.


    Find lable "Obj01_Control:", just after the instruction "clr.b ($FFFFF7CC).w" and just before the instruction "rts", put this in:



    dc.b $45,$F9,$00,$C0,$00,$00,$43,$EA,$00,$04,$32,$BC,$83,$2A,$32,$BC
    dc.b $92,$9A,$32,$3C,$07,$D0,$74,$01,$22,$BC,$6D,$00,$00,$02,$61,$00


    dc.b $00,$08,$22,$BC,$6D,$80,$00,$02,$76,$27,$34,$81,$D2,$42,$51,$CB


    dc.b $FF,$FA



    Save, Build, and play, activate debug mode, and during level, press "B", this will bring up a window showing the last 30 tiles in V-Ram (and the first few tiles after it because after 7FF it wraps, etc, blah, blah, blah).


    EDIT: I set the tile starting ID to 7D0, If you want to change the tile starting ID to somethine else, then on the second line, you'll see $07,$D0,, just change that value to something else =P
     
    Last edited by a moderator: Jan 30, 2011
  20. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    That's both perfect and amazing (though it isn't showing a window as expected, but replaces the tiles at the bottom of the screen instead, which may be even more convenient).


    Many thanks ^^


    Edit: thinking about it, it may be a window from the vdp's standpoint, I thought those were an additional layer but it looks like they're replacing plane A instead.
     
    Last edited by a moderator: Jan 30, 2011