Language…
21 users online:  Anorakun,  Ayami, Cal-of-Gearva, E-man38,  Fernap, Foxy_9000_, GrenCarret, JupiHornet, Lane, LightAligns, margot, MarioSonic4life, MarioTeam,  NopeContest, PhantasyReal, Royal Nico TS, Rykon-V73, smoulder, VecchiaZim, WhiteYoshiEgg, Zavok - Guests: 115 - Bots: 227
Users: 55,677 (2,384 active)
Latest user: rottencola

Sprite Programming [Legacy]

The links and pictures are broken because my server on bplaced.net went down (it's been a couple of weeks or so). I should update it soon though.

Regarding your sprite,

dcb "MAIN"
RTL
JSR GRAPHICS ROUTINE HERE
JSR GET_DRAW_INFO

You got that wrong. An RTL is placed just after dcb "MAIN" so no code would be run. Secondly, your label is defined wrong (there are spaces in the name) and doesn't exist (where is that label?).

It's supposed to be like this:

dcb "MAIN"
PHB
PHK
PLB ; Wrapper
JSR Graphics
PLB
RTL

And before the first LDA $00,

Graphics:
While testing the lesson 4 (adding interaction) sprite, my game crashes when I touch the sprite in-level. When I replaced "JSL $01A7DC" with CLC, it did nothing, and with SEC, it gave me 10 coins and disappeared, so I'm assuming the problem is with that command. Is there something I missed (or messed up)?


Here's the code I'm using for the collision:
Code
CheckContact	JSL $01A7DC
		BCC NoContact	;Check for contact between this sprite and Mario (return if none)

		LDA #10	
		STA $13CC	;Give player 10 coins
		LDA #$01
		STA $1DFC	;Plays some sound effect

		STZ $14C8,x	;Disable sprite
		RTS


NoContact	RTS		;Changed from RTL because that made the game crash as the sprite came on-screen
I don't see how it worked because if you check all.log the JSL $01A7DC is the mario contact routine.

Furthermore, your using a JSL so you have to use a RTL.



Give Mario some love?~
How would one add sound effects in asm. (Invincibility to be exact)
The register for sfx is $1DF9.

For a list of sounds check here

Give Mario some love?~
How do I make it play the invincibility SONG though?
LDA $0D
STA $1DFB
I think that will work.

Give Mario some love?~
Originally posted by zKiP
I don't see how it worked because if you check all.log the JSL $01A7DC is the mario contact routine.

Furthermore, your using a JSL so you have to use a RTL.


I know I need the RTL if I use JSL, but I had a JSR to call that routine (stupid mistake on my part). I guess I should have posted the entire code before >_>". Either way, that problem's been fixed, but the game still crashes when Mario touches the sprite...

Another bit that might be useful is that when the game crashes, the death music plays, but the screen goes blank.

Well, here's all my code; thanks in advance for any help:
Code
;============================================================
;
; Tutorial sprite
;
; The Blue 'shroom
;
;============================================================

	dcb "INIT"
		RTL         

	dcb "MAIN"
		PHB
		PHK
		PLB
		JSR SPRITE_ROUTINE
		PLB
		RTL


;==========  Spite Routine  ==========

SPRITE_ROUTINE	JSR Graphics
		LDA $14C8,x
		CMP #$08
		BNE Return	;Return if sprite status is not normal

		LDA $9D
		BNE Return	;Return if sprites are locked

		JSL CheckContact

		RTS

;==========  GRAPHICS ROUTINE  ==========

Graphics	JSR GET_DRAW_INFO

		LDA $00
		STA $0300,y	;X-pos to OAM

		LDA $01
		STA $0301,y	;y-pos to OAM

		LDA #$24
		STA $0302,y	;tile number to OAM

		LDA #%00000110
		ORA $64
		STA $0303,y	;Sets Tile properties

		INY;------|
		INY;      |
		INY;      |
		INY;------|----> Draws the tile

		LDY #$02	;The tiles were 16x16
		LDA #$00	;(16x16 tiles drawn) - 1
		JSL $01B7B3	;Finish writing to the OAM
		RTS

;==========  Other Sprite Routines  ==========


CheckContact	JSL $01A7DC
		BCC Return	;Check for contact between this sprite and Mario (return if none)

		LDA #10	
		STA $13CC	;Give player 10 coins
		LDA #$01	;Some sound effect
		STA $1DFC

		STZ $14C8,x
		RTL



;==========  Return Routine  ==========

Return	RTL


After that there is the unmodified GET_DRAW_INFO routine from the library file.
LDA $9D
BNE Return ;Return if sprites are locked

Return:
RTL

I think that's one problem. That is supposed to be an RTS, but I noticed you're also using it in a subroutine accessed by a JSL. I guess you could add another label with an RTS to fix it.
Originally posted by Xkip

LDA $0D
STA $1DFB
I think that will work.

This doesn't play the song...
Can someone please show me the correct graphics routine for the blueshroom, cuase I can't get this right.
I noticed that before you started talking about GET_DRAW_INFO, the links for the examples are broken. It's hard to know what's going on without them, so...:/
Yeah. Hey guess what. I have it. All of the links and stuff. Backed up. But of course, cruel twisted fate has my webhosting fuck up, and never getting a chance to use a computer.

World Community Grid: Thread | Team
 
Assuming that Iceguy is OK with it(Please forgive if your not.)

Here is a link to my backup of his ASM from the tutorial.


NOTE: This is backed up from his PM to me of the tutorial before it was posted here. The files may not be the same.

Give Mario some love?~
Thanks zKiP. That should be useful.
Originally posted by SomeGuy
Originally posted by Xkip

LDA $0D
STA $1DFB
I think that will work.

This doesn't play the song...


Try replacing $0D with #$0D.



 
What's the difference between JSR and JSL?
JSR has a shorter limit of 128 bytes it csn jump, and subroutines jumped to must end in RTS.
JSL has an 8000 byte limit of how far it can jump, and subroutines jumped to must end in RTL.
JSR takes 3 bytes, JSL takes 4, if I'm not mistaken.

World Community Grid: Thread | Team
 
Originally posted by Santacus Clausimus
JSR has a shorter limit of 128 bytes it csn jump

Quote
JSL has an 8000 byte limit of how far it can jump

Who told you that?
JSR can go anywhere in the current bank (xx:8000-xx:FFFF), while JSL can go anywhere it wants.

Also, 8000 makes no sense. Did you mean 32768?
<blm> zsnes users are the flatearthers of emulation
*looks through my printed ASM tutorials*

Iceguy's ASM tutorial on TMN

World Community Grid: Thread | Team