Basic Questions and Answers Thread

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

  1. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    401
    Location:
    Town Creek, AL
    Pokepunch try changing .w to .l see if that works... Sometimes it don't & crashes the game, as mine's done in sonic 1

    also having trouble with something (Sonic 1)


    Error: illegal value (196)

    and the line contains


    sndtst:        move.l    SndTst_Sounds(pc,d0.w),d0

    this.

    should also note

    Code:
    LevSel_PlaySnd:
    		cmpi.b	#$A0,d0
    		blt	LevSel_NoSFX
    		subi.b	#$A0,d0
    		andi.w	#$007F,d0			; MJ: keep in range
    		add.w	d0,d0				; MJ: multiply by 4
    		add.w	d0,d0				; MJ: ''
    		jsr	sndtst	; MJ: load correct address
    psls:		bsr.w	PlaySound			; MJ: play sound
    		bra.w	LevelSelect			; MJ: continue
    
    LevSel_NoSFX:	subi.b	#$80,d0				; MJ: minus 80
    		beq	LevelSelect			; MJ: if null, branch
    		subq.b	#$01,d0				; MJ: Minus 1
    		andi.w	#$001F,d0			; MJ: keep in range
    		add.w	d0,d0				; MJ: multiply by 4
    		add.w	d0,d0
    						; MJ: ''
    		jsr	mustst
    Mus_GoBack:	bsr.w	PlayMusic			; MJ: play music
    		bra.w	LevelSelect			; MJ: continue
    
    
    mustst:		cmpi.b	#1,(PlayListEntry).w
    		beq	PlayList2
    		move.l	SndTst_Musics(pc,d0.w),d0
    		bra	Mus_Goback
    Playlist2:		move.l	SndTst_Music(pc,d0.w),d0
    		bra	mus_Goback
    sndtst:		move.l	SndTst_Sounds(pc,d0.w),d0
    		bra	psls
    SndTst_Musics:	dc.l Music81, Music82
    		dc.l Music83, Music84
    		dc.l Music85, Music86
    		dc.l Music87, Music88
    		dc.l Music89, Music8A
    		dc.l Music8B, Music8C
    		dc.l Music8D, Music8E
    		dc.l Music8F, Music90
    		dc.l Music91, Music92
    		dc.l Music93, EHZ
    		dc.l CPZ, HTZ
    		dc.l HiddenPalaceZone, MGZ1
    sndtst_Music:	dc.l BloodyTears, SMB3
    		dc.l GameComplete, SK1Up
    		dc.l FrontDoor, SuperRichter
    		dc.l Plague2, LostSilver
    		dc.l Blimp, Mental
    		dc.l SRLevel, Plague
    		dc.l Run, SML2Stage1
    		dc.l GameComplete, SK1Up
    		dc.l SKMenu, CastleBegins
    		dc.l Brinstar, HiddenPalaceZone
    		dc.l CastleBegin, Bridge
    		dc.l Music83, Music84
    ; ===========================================================================
    ; ---------------------------------------------------------------------------
    ; Sound list for sound test
    ; ---------------------------------------------------------------------------
    
    SndTst_Sounds:	dc.l SoundA0, SoundA1, SoundA2
    		dc.l SoundA3, SoundA4, SoundA5
    		dc.l SoundA6, SoundA7, SoundA8
    		dc.l SoundA9, SoundAA, SoundAB
    		dc.l SoundAC, SoundAD, SoundAE
    		dc.l SoundAF, SoundB0, SoundB1
    		dc.l SoundB2, SoundB3, SoundB4
    		dc.l SoundB5, SoundB6, SoundB7
    		dc.l SoundB8, SoundB9, SoundBA
    		dc.l SoundBB, SoundBC, SoundBD
    		dc.l SoundBE, SoundBF, SoundC0
    		dc.l SoundC1, SoundC2, SoundC3
    		dc.l SoundC4, SoundC5, SoundC6
    		dc.l SoundC7, SoundC8, SoundC9
    		dc.l SoundCA, SoundCB, S3KSpring
    		dc.l SoundCD, SoundCE, SoundCF
    
     
    Last edited by a moderator: Sep 14, 2014
  2. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Thanks, but I have already tried that to no avail.
     
  3. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    915
    Pokepunch: the error means that the address is not within the range available for word addressing (000000..007FFF or FF8000..FFFFFF), but that doesn't make any sense, since all RAM addresses outside of the chunk table (FF0000..FF7FFF) should be able to use word addressing.

    warr1or2: that error means that the instruction move.l SndTst_Sounds(pc,d0.w),d0 is too far away from SndTst_Sounds. PC-relative addressing can only go 127 bytes ahead of or 128 bytes behind the current instruction, and SndTst_Sounds is 192 bytes away. You'll have to either move the table and instruction closer, or use lea SndTst_Sounds,a1 / move.l (a1,d0.w),d0
     
  4. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    I have now fixed that issue but have now I have an even bigger issue. Sprites don't seem to display such as Sonic on the SEGA screen, and when starting the game it crashes on the title card. I have narrowed this down to the changes that are made to DisplaySprite. When the changes are applied along with the rest of the guide it results in this. If I change the DisplaySprite routine back to default while keeping the rest of the changes from the guide the game can run albeit with most object having messed up priorities.

    Here is the default DisplaySprites:


    DisplaySprite:
    lea (Sprite_Table_Input).w,a1
    move.w priority(a0),d0
    lsr.w #1,d0
    andi.w #$380,d0
    adda.w d0,a1
    cmpi.w #$7E,(a1)
    bhs.s return_16510
    addq.w #2,(a1)
    adda.w (a1),a1
    move.w a0,(a1)

    return_16510:
    rts
    ; End of function DisplaySprite

    ; ---------------------------------------------------------------------------
    ; Subroutine to display a sprite/object, when a1 is the object RAM
    ; ---------------------------------------------------------------------------

    ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||

    ; sub_16512:
    DisplaySprite2:
    lea (Sprite_Table_Input).w,a2
    move.w priority(a1),d0
    lsr.w #1,d0
    andi.w #$380,d0
    adda.w d0,a2
    cmpi.w #$7E,(a2)
    bhs.s return_1652E
    addq.w #2,(a2)
    adda.w (a2),a2
    move.w a1,(a2)

    return_1652E:
    rts
    ; End of function DisplaySprite2 
    Here is the modified one from the guide:

    Code:
    DisplaySprite:
    	lea	(Sprite_Table_Input).w,a1
    	move.w	priority(a0),a1
    	cmpi.w	#$7E,(a1)
    	bhs.s	return_16510
    	addq.w	#2,(a1)
    	adda.w	(a1),a1
    	move.w	a0,(a1)
    
    return_16510:
    	rts
    ; End of function DisplaySprite
    
    ; ---------------------------------------------------------------------------
    ; Subroutine to display a sprite/object, when a1 is the object RAM
    ; ---------------------------------------------------------------------------
    
    ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
    
    ; sub_16512:
    DisplaySprite2:
    	lea	(Sprite_Table_Input).w,a2
    	move.w	priority(a1),a2
    	cmpi.w	#$7E,(a2)
    	bhs.s	return_1652E
    	addq.w	#2,(a2)
    	adda.w	(a2),a2
    	move.w	a1,(a2)
    
    return_1652E:
    	rts
    ; End of function DisplaySprite2 
     
  5. TrustyGun

    TrustyGun Newcomer Trialist

    Joined:
    Aug 24, 2014
    Messages:
    13
    Location:
    Why do you care, Stalker?
    I deleted all the art in Labyrinth Zone (I like starting from the ground up), and made a few chunks, using completely original art, gave it it's solidity map, and opened it up in game. There is a problem though: once Sonic touches the ground, he starts moving forward like he was on the slide from LZ. How do I fix it? 
     
  6. Clownacy

    Clownacy Well-Known Member Retired Staff

    Joined:
    Aug 15, 2014
    Messages:
    919
    Git: _incLZWaterFeatures.asm, Slide_Chunks.

    Hivebrain: sonic1.asm, byte_3FC0, 9 bytes in.

    This is a list of chunks which are recognised as 'slide chunks'. Just change the values to your new slide chunks, and you'll be good to go.
     
  7. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    915
    The difference I'm seeing here is that the original DisplaySprite puts the priority in d0, does some math with it, then adds it to a1, whereas the new code simply overwrites a1, making the earlier lea pointless. If priority(a0) really does contain a RAM address, then you'll want to change it to movea.w, so it's sign-extended, otherwise, you'll want to change the move.w to adda.w. The same applies for DisplaySprite2, with different registers.
     
  8. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Thank you, changing the move to adda fixed it. Thanks.
     
  9. Vicious

    Vicious Newcomer Trialist

    Joined:
    Sep 10, 2014
    Messages:
    4
    Location:
    Bs. As.
    Hi! No, just add a sprite of shadow and delete the sprite of original sonic in sonmaped, and save all (tile graphic, pallette, mapping and patter cue).

    Hi man, thanks for answer.So what I have to do to see rom build without error? I have to edit and save only the graphics without touching the other files ?.
     
  10. ThomasThePencil

    ThomasThePencil resident psycho Member

    Joined:
    Jan 29, 2013
    Messages:
    911
    Location:
    the united states. where else?
    Hi man, thanks for answer.So what I have to do to see rom build without error? I have to edit and save only the graphics without touching the other files ?.



    I don't know much about S3K, but I know that the best way to do this kind of thing is to split Sonic's art, mappings, and DPLCs into two separate files: one for normal Sonic and one for Super/Hyper Sonic. They're all important.

    After that, you can just BINCLUDE the new files using the label MapUnc_SuperSonic, ArtUnc_SuperSonic, and MapRUnc_SuperSonic, making a few code changes accordingly. They're pretty trivial changes, though, so I won't say what they are. Just look at Sonic's "turn super" code and his "load DPLCs" code.
     
    Last edited by a moderator: Sep 14, 2014
  11. Shockwave

    Shockwave 3 Time Stones Member

    Joined:
    Dec 18, 2013
    Messages:
    121
    Location:
    LA, CA
    What you could do to keep Super Sonic's mappings intact and allow ROM to build is copy Sonic's art along with the mappings and PLCs. Open up both the mappings and PLCs for Sonic in a text editor and copy them to new files, saving them as "Map - SuperSonic" and "PLC - SuperSonic". Also take the art file for Sonic and make a copy of that named SuperSonic. Then, in the main ASM file, search for the routine Sonic_Load_PLC. It should look like this:



    Sonic_Load_PLC:

    moveq #0,d0
    move.b $22(a0),d0

    Sonic_Load_PLC2:
    cmp.b ($FFFFF766).w,d0
    beq.s locret_12D20
    move.b d0,($FFFFF766).w
    lea (PLC_Sonic).l,a2
    tst.b (Super_Sonic_Knux_flag).w
    beq.s loc_12CD6
    lea (PLC_SuperSonic).l,a2

    loc_12CD6:
    add.w d0,d0
    adda.w (a2,d0.w),a2
    move.w (a2)+,d5
    subq.w #1,d5
    bmi.s locret_12D20
    move.w #$D000,d4
    move.l #ArtUnc_Sonic,d6
    cmpi.w #$1B4,d0
    bcs.s loc_12CF8
    move.l #ArtUnc_Sonic_Extra,d6

    loc_12CF8:


    Right underneath the line "move.l #ArtUnc_Sonic,d6", add these:



    tst.b (Super_Sonic_Knux_flag).w
    beq.s loc_12CD6_ChkExtra
    move.l #ArtUnc_SuperSonic,d6

    loc_12CD6_ChkExtra:


    Finally, search up the label PLC_Sonic and add these right below it:



    ArtUnc_SuperSonic: binclude "General/Sprites/Sonic/Art/SuperSonic.bin"
    even

    Map_SuperSonic: include "General/Sprites/Sonic/Map - SuperSonic.asm"

    PLC_SuperSonic: include "General/Sprites/Sonic/PLC - SuperSonic"


    Now, if you were to build the ROM directly after saving this, you would obviously get double defined errors due to the shared labels between the original mappings and PLCs and the new ones just made. However, if you're gonna modify the originals in SonMapEd, it will replace all the labels once you've saved the changes, which will allow you to build without any issues. Everything should be fine at this point but of course let me know if I overlooked something again.

    Edit: Whoops, didn't notice TSR's post.
     
    Last edited by a moderator: Sep 14, 2014
  12. TrustyGun

    TrustyGun Newcomer Trialist

    Joined:
    Aug 24, 2014
    Messages:
    13
    Location:
    Why do you care, Stalker?
     Thanks! Worked great.
     
  13. Stardust Gear

    Stardust Gear A Programmer Member

    Joined:
    Apr 27, 2014
    Messages:
    134
    I have a SMPS request:

    Ristar - Busy Flare.

    I need this with good drums (and try to make the sine-wave sirens stereos).
     
  14. Crimson Neo

    Crimson Neo I changed a lot. Member

    Joined:
    Sep 9, 2013
    Messages:
    497
    Location:
    Where I didn't wanted to be.
  15. Irixion

    Irixion Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    670
    Location:
    Ontario, Canada
    I locked the topic because there's too many requests and no one filling them. If people start filling some of the requests, I'll unlock the topic.
     
  16. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    401
    Location:
    Town Creek, AL
    question...

    I ported the spindash some time back & overlooked 2 things. The loading of the spindust to be put above Obj01_Control &  the Lamppost error.. both fixed now, but my question is with loading art.

    move.b    #5,$FFFFD1C0.w Loads the spindust object, but move.b    #2,($FFFFD1DC).w    is to set the dash dust animation

    someone tell me how this works, cause i'm trying to load the Dagger for Richter.

    move.b    #2,$FFFFD1C2.w to load the dagger, i put it above move.b    #5,$FFFFD1C0.w which is above Obl01_Control

    the full Weapons code


    BelmontWeapons: ; XREF: Obj_Index
    moveq #0,d0
    move.b $24(a0),d0
    move.w BelmontWeapons_Index(pc,d0.w),d1
    jmp BelmontWeapons_Index(pc,d1.w)
    ; ===========================================================================
    BelmontWeapons_Index:
    dc.w Dagger-BelmontWeapons_Index
    dc.w Axe-BelmontWeapons_Index
    dc.w Cross-BelmontWeapons_Index
    dc.w Holy_Water-BelmontWeapons_Index
    ; ===========================================================================
    Dagger: move.l #U_Weapons,d1 ; Call for Regular Shield Art
    move.w #2,$FFFFd12c ; Load Art from this location (VRAM location*20)
    ; In this case, VRAM = $541*20
    move.w #$200,d3
    jsr (QueueDMATransfer).l
    ; ---------------------------------------------------------------------------



    addq.b #2,$24(a0)
    move.l #Map_Dagger, $0004(A0) ; Load Dagger into place
    move.b #4,1(a0)
    move.b #1,$18(a0)
    move.b #$18,$19(a0)
    move.w #$541,2(a0) ; Set VRAM location

    lea (DaggerAni).l, a1 ; Load Animation Scripts into a1
    move.w $300,x_vel(a0)
    Axe: Nop
    Cross: Nop
    Holy_Water: Nop
    rts
    Map_Dagger: include "RichterWeaponsDagger.asm"
    even
    DaggerAni: include "RichterWeaponsDaggeranim.asm"
    even

    and the code for throwing one (Which ain't loading Dagger & not switching to the Throwing animation)

    Code:
    Richter_TossDagger:
    		tst.b	(Character).w	; Is this Sonic?
    		beq	TossWeapon_rts	; If so, Branch. Sonic is not capable
    		CMPI.B	#5,$1C(a0)	; Standing?
    		bne	TossWeapon_rts	; no, then branch
    		move.b	($FFFFF603).w,d0	; read controller
    		andi.b	#btnB,d0			; pressing B ?
    		beq.w	TossWeapon_Rts		; if not, return
    		move.b	#$24,$1C(a0)	;use Tossing Animation
    		move.b	#2,($FFFFD1De).w; Set the Dagger animation to 2
    		move.l	#SoundA2,d0	; Load SoundA2 to d0
    		jsr	playSound	; PlaySound
     TossWeapon_rts: rts
    		; Richter's Looking up animation needs to change before further coding
    		
    
     
  17. ralakimus

    ralakimus pretty much a dead account Member

    Joined:
    Aug 26, 2013
    Messages:
    1,068
    If you want to load art, then you take the RAM that the object is loaded to and add $1C to it. Also, $FFFFD1C2 is not a valid space in Object RAM. To be a valid space, it has to be divisible by $40. $FFFFD1C0 is perfectly valid. $FFFFD1C2 is the VRAM location/$20 or just called "art_tile" for $FFFFD1C0.

    There are problems with this code.

    1. The first routine is supposed to set up the object, not to load it to RAM or set up its art.

    2. Under (Ani_dagger).l,(a1), you're supposed to have "jsr    AnimateSprite" under it, or it won't animate.

    3. Instead of having the weapons be treated like the spindash dust, you could just have it as a normal object, with each routine after the first being a weapon and they all jump to a subroutine to animate and draw the sprite. Just have the art compressed as Nemesis (if you haven't already) and load it in the main PLC. Then make a subroutine for Sonic and just use SingleObjLoad to load the weapon and set up how it moves in that subroutine. That menas you have to get rid of any movement code in your object. You can just have each weapon routine in the object do gravity and set up its animations.

    Now, it appears you already have a subroutine ready, so have the object load there and the animation won't change because of his movement subroutine. His movement subroutine sets his animation to $5 when not moving. Instead of checking his animation, check is x velocity ($10(a0)) to make sure it is 0. Make sure the subroutine is only loaded during his normal mode (not in the air or rolling).

    When checking for the B button, it's best to make the jump and jump height subroutine check buttons A and C, and not B.
     
    Last edited by a moderator: Sep 15, 2014
  18. Painto

    Painto Well-Known Member Member

    Joined:
    Mar 24, 2014
    Messages:
    317
    Location:
    Lublin, Poland
    In Sonic 1 sound fadeout ($E0) is also fading out sound effects (at least in my hack). Is there any way to fix this?
     
    Last edited by a moderator: Sep 16, 2014
  19. Clownacy

    Clownacy Well-Known Member Retired Staff

    Joined:
    Aug 15, 2014
    Messages:
    919
    Well, hi there (of course I'm gonna answer a sound driver question)!

    FadeOutMusic (Sound_E0) begins with a pair of 'jsr's; delete them. Those silence the (special) SFXes, so getting rid of the branches should remove that feature. The label really should be FadeOutAll.
     
    Last edited by a moderator: Sep 16, 2014
  20. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    I have just ported Knuckles to Sonic 2 and I am experiencing a rather strange issue. When I first ported him in without fixing anything up knuckles would flash when moving due to me following the S3K priority guide, he could still glide normally. However when changing the SST $30 to invulnerable_time (What do I call these? Macros?) Knuckles no longer flashes but now when he glides he uses the glide animation but just falls down and can't climb. The S3K priority guide involved changing inertia to $30 and [SIZE=14.3999996185303px]invulnerable_time to $20. I have tried looking through his gliding code to no avail. I'm not sure why this would even happen.[/SIZE] 
     
    Last edited by a moderator: Sep 16, 2014