Basic Questions and Answers Thread

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

  1. Spanner

    Spanner The Tool Member

    Joined:
    Aug 9, 2007
    Messages:
    2,570
    http://sonicresearch.org/forums/index.php?app=forums&module=extras&section=boardrulesHow about you read these too whilst you're at it? One word posts don't fly here along with your quality of typing.
     
  2. dreggman

    dreggman Newcomer Trialist

    Joined:
    Apr 6, 2012
    Messages:
    11
    about the music? how do i add that to sonic 1?.
     
  3. Kensou

    Kensou Well-Known Member Member

    Joined:
    Aug 19, 2010
    Messages:
    59
    Maybe is a stupid question but I'm tired of editing tile by tile :p


    Is possible to load the Sonic emblem of the title screen of Sonic 1 in SonMapEd?
     
  4. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    You could load the art at the very least, the problem is, the mappings are for the Mega Drive's "Plane A" display, not for sprites, SonMapEd is designed for sprite map editing and not plane map editing, you should consider checking out this nifty tool:


    http://info.sonicretro.org/PlaneED


    For information on the plane mapping format, check out:


    http://sonicresearch...?showtopic=2199
     
  5. Kensou

    Kensou Well-Known Member Member

    Joined:
    Aug 19, 2010
    Messages:
    59
    Thanks Markey! I didn't thought about plane A. Good info.
     
  6. ValleyBell

    ValleyBell Well-Known Member Member

    Joined:
    Dec 23, 2011
    Messages:
    166
    I've been trying do add some code from the Jman PCM driver tutorial to my hack in order to make the PCM table more readable, but it seems that the macro assembler doesn't support some of the macros.


    I'm using the Sonic 2 disassembly by Xenowhirl.



    Code:
    ; ===========================================================================
    
    PCM:	macro   Pitch, Location
    
    	    dc.w	(((((Location&$000000FF)<<$08)+((Location&$00007F00)>>$08))!$0080)&$FFFF)
    
    	    dc.w	(((((((Location_End-$02)-Location)&$000000FF)<<$08)+((((Location_End-$02)-Location)&$00007F00)>>$08))/$02)&$FFFF)
    
    		dc.b	Pitch
    
    		dc.b	((Location&$00008000)>>$08)
    
    		dc.b	((Location&$003F0000)>>$10)
    
    		dc.b	$00
    
    		even
    
    				endm
    
    ; ---------------------------------------------------------------------------
    
    incpcm: macro   File
    
    File:		   binclude  "sound/DAC/File.bin"
    
       			 dc.b	$80,$80
    
    File_End:	   even
    
       	 endm
    
    NULL:
    
    NULL_End:
    
    ; ===========================================================================
    
    
    
    PCM_Table:
    
    		   	 PCM	 $19, BassDrum						   ; 81
    
    
    
    ; ===========================================================================
    
    
    
    		   	 incpcm  BassDrum
    When trying to build it, I errors about BASSDRUM_End not being defined, so including the file works. It is correct that there are no backslashes, btw. The macro assmebler doesn't need them.

    It works perfectly, if I add

    Code:
    BassDrum_End:
    after the incpcm command, but that's not the intention of the incpcm macro.


    So I know that it fails to convert the label File_End to BassDrum_End in the incpcm macro. It works however in the PCM macro.


    Any ideas how I could get this to work correctly?


    If nothing works, I'll make a workaround and add an additional argument to the incpcm macro. (like incpcm BassDrum, BassDrum_End)
     
    Last edited by a moderator: Apr 25, 2012
  7. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    The reason why asm68k needed the backwards slashes was so that it knew it was suppose to print the passed word as a "string of characters" rather than a "pointer to an address", the point in the macro was to make it easier to include a wav file into the source whilst removing the header, and making sure it's aligned and kept within the 8000 byte banks jman's driver insists on limiting to.


    As your samples don't have a header, and as it seems you do not require keeping them in banks, it seems that the macro for the "incpcm" has virtually no use at all, I mean... writing out:



    Code:
    SampleTwo	binclude	"Filename"
    
    SampleTwo_End:


    Is no difficult that writing out:





    Code:
       	 incpcm		Filename


    The "PCM" macro is also to no use, due to lack of backwards slashes, again, they were needed, an example:





    Code:
       	 dc.w	Location_End


    The word Location will be replaced with the string of the sample's name, so if the sample were called "SampleTwo", the assembler would convert it to:





    Code:
       	 dc.l	SampleTwo_End


    Before assembling, without the backward slashes, it would assume that it's just words to be assembled and nothing more:





    Code:
       	 dc.l	Location_End


    Unless you "add" a Location_End to the macro:





    Code:
    PCM:	macro   Pitch, Location, Location_End

    And pass the end location as well.
     
    Last edited by a moderator: Apr 24, 2012
  8. ValleyBell

    ValleyBell Well-Known Member Member

    Joined:
    Dec 23, 2011
    Messages:
    166
    I understood what the backslashes are supposed to do.


    And the PCM macro is of use. It correctly converts Location_End to BassDrum_End in dc.x commands, even without backslashes, else I would get an error about Location_End not being defined. (not about BASSDRUM_End)


    I just surprised me that it works in the dc.b/w commands, but not when defining a label.


    Thanks anyway.


    After some fiddling around (and reading the manual), I figured it out how it works:



    Code:
    incpcm:         macro   File
    
    File:           LABEL *
    
                            binclude  "sound/DAC/File.dec"
    
                            dc.b    $80,$80
    
    File_End:       LABEL *
    
                            even
    
                    endm
    In AS labels in macros are local by default. LABEL * makes them global.


    btw: AS has no filesize() function, so I can't have use it anyway.
     
  9. TheJeli

    TheJeli Umm... Member

    Joined:
    Jun 20, 2011
    Messages:
    245
    Location:
    West London
    Hacking Sonic 4 EP 2.


    Can anyone link me to a good .aax converter? (The one on Sonic Retro was on MegaUpload)
     
  10. Guest

    well this will be a first timer for me posting in this thread. anywho currently i am trying to make the HUD to where when the level loads after the title card sequence, the entire hud itself scrolls as well. kind of like in Bro-Tro for example how the HUD on that scrolled into place as the level starts. so exatly how would i be able to make a simple one?
     
    Last edited: Apr 28, 2012
  11. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    I don't remember what it looks like in bro-tro, but the principle is simple: Change the original coordinates of the hud object (object 21), add a routine to the object to make it move until it reached the coordinates you want, make the object use that routine after it's been initialized, set the routine counter to the normal routine (flash) when it's done.
     
  12. Guest

    and exactly where would the coordinates for the hud be in this case? Im a bit confused on where to find them
     
  13. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    The x coordinates in screen mode are in 8 and the y coordinates in A. If I remember correctly, the original x coordinate is 90 (in hex).
     
  14. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Code:
    Obj21_Main:				; XREF: Obj21_Main
    
    		addq.b	#2,$24(a0)
    
    		move.w	#$90,8(a0)		; X position
    
    		move.w	#$108,$A(a0)		; Y position
    
    		move.l	#Map_obj21,4(a0)
    
    		move.w	#$6CA,2(a0)
    
    		move.b	#0,1(a0)
    
    		move.b	#0,$18(a0)

    The X position is 0090 and the Y position is 0108, because this object presents sprites using the raw positions of the VDP, 0080 will be the very left/top of the screen, you'll need to start the hud to somewhere lower in order to shift it up and left out of the screen further.
     
    Last edited by a moderator: Apr 28, 2012
  15. Guest

    Ok so I tried it out and it worked when you said to change the coordinates. the only thing im trying to figure out now is exactly what line or routine do I have to add to make it actually move into place? I tried using parts of how the title card text moves into place but it didn't work for me. I know this is a bit much but I never tampered with this before so please bare with me if I am Asking a bit too much.
     
    Last edited: Apr 28, 2012
  16. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Code:
            addq.w    #$01,$08(a0)


    To increase the hud right.





    Code:
            subq.w    #$01,$08(a0)


    To decrease the hud left.





    Code:
            addq.w    #$01,$0A(a0)


    To increase the hud down.





    Code:
            subq.w    #$01,$0A(a0)

    To decrease the hud up.


    The number #$01 is the number of pixels it will move each frame, now understand that this is all simple mathematics, if the X position starts at 0080, addq.w #$01, will increase it by 1, making it 0081, then the next frame, it'll increase it by 1, making it 0082, etc, slowly, each frame moving it right.
     
  17. Guest

    Well at least I understand this part now. so pretty much i can just put this anywhere in Obj21_Main: or do i have to add it in a specific part of it like in the beggining or right under the X position line?
     
  18. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    I would personaly put a small rotuine labed Obj21_move: at least after the main where it loads the file and what not, and put the moving code there. Either put it where the main routine can access it automatically or put a jmp somewhere so that it goes to your routine. If you want it to stop moving at somepoint you'll need a check as well to check the x-pos or y-pos and halt all movement when the object meets at the correct position.


    E..g:



    Obj21_Move:
    addq.w #$01,$08(a0)


    cmpi.w #$XX,$08(a0) ; has item rechead the value XX?


    beq.s HaltMovement ; if yes, halt movment


    jmp DisplaySprite ; Display object


    HaltMovement:


    move.w #$XX,$08(a0) ; same as the stop position in case it doesn't stop
     
    Last edited by a moderator: Apr 29, 2012
  19. Guest

    So I got it to somewhat scroll but it keeps scrolling and won't stop. maybe this would be more easier if i just post what i have edited so far. here it is if you need to see it:




    Obj21_Main: ; XREF: Obj21_Main


    addq.b #2,$24(a0)


    move.w #$0,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_Move:


    addq.w #$01,$08(a0)


    cmpi.w #$90,$08(a0) ; has item rechead the value XX?


    beq.s Obj21_HaltMovement ; if yes, halt movment


    jmp DisplaySprite ; Display object


    Obj21_HaltMovement:


    move.b #$90,$08(a0) ; same as the stop position in case it doesn't stop


    jsr Obj21_Flash


    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


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


    Obj21_Flash2:


    moveq #0,d0


    btst #3,($FFFFFE05).w


    bne.s Obj21_Display


    addq.w #1,d0 ; make ring counter flash red


    cmpi.b #9,($FFFFFE23).w ; have 9 minutes elapsed?


    bne.s Obj21_Display ; if not, branch


    addq.w #2,d0 ; make time counter flash red


    Obj21_Display:


    move.b d0,$1A(a0)


    jmp DisplaySprite
     
  20. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Try this instead:



    Code:
    ; ===========================================================================
    
    ; ---------------------------------------------------------------------------
    
    ; Object 21 - SCORE, TIME, RINGS
    
    ; ---------------------------------------------------------------------------
    
    
    
    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_Flash-Obj21_Index
    
    ; ===========================================================================
    
    
    
    Obj21_Main:				; XREF: Obj21_Main
    
    		addq.b	#2,$24(a0)
    
    		move.w	#$00,8(a0)			; MJ: changed to 00 from 90
    
    		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_Flash:				; XREF: Obj21_Main
    
    		moveq	#$06,d0				; MJ: prepare +8
    
    		add.w	$08(a0),d0			; MJ: load X position and increase it by 8
    
    		cmpi.w	#$0090,d0			; MJ: has it reached the end?
    
    		blt	Obj21_NoMove			; MJ: if not, branch
    
    		move.w	#$0090,d0			; MJ: set directly at end
    
    
    
    Obj21_NoMove:
    
    		move.w	d0,$08(a0)			; MJ: save new X position
    
    		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
    
    ; ===========================================================================

    The routine "Obj21_Main:" is the start off routine, this will only be run through once, after it "Obj21_Flash:" is ran, and it continues to be ran every frame. So here's what I've done:

    1. In "Obj21_Main:" I've changed the "move.w #$90,8(a0)" to "move.w #$00,8(a0)", so it starts on the X position outside the left of the screen.
    2. "moveq #$06,d0" and "add.w $08(a0),d0" will load the X position to d0, and increase it by 6.
    3. "cmpi.w #$0090,d0" and "blt Obj21_NoMove" will check if d0 is lower than 0090, or if it's 0090 or higher, if it is lower than 0090, it will jump over to "Obj21_NoMove" and continue, if it is 0090 or higher, it will not jump, and it will move to "move.w #$0090,d0", which will keep it at 0090, preventing it from moving further and then continue to "Obj21_NoMove".
    4. "move.w d0,$08(a0)" will save the new X position of the hud that we've had in d0 and have been changing.

    Every frame it'll keep increasing it by 6, and then checking if it has reached the end, if it has not, it'll save the new position + 6 (moving it right by 6 pixels), so every frame the hud will move right 6 pixels, moving it closer and closer to it's destination each frame, once it reaches 0090 or maybe even higher, it'll move it back to the position 0090 and save it, preventing it from going any further, so no matter how much it increases, it'll remain at 0090.