Language…
13 users online:  Atari2.0, DanMario24YT, Dennsen86, derv82, drkrdnk, eltiolavara9, Fozymandias, Maw, Nayfal, prisvag, Red2010, Serena, steelsburg - Guests: 290 - Bots: 260
Users: 64,795 (2,375 active)
Latest user: mathew

64X40 sprite help

So I am trying to make a sprite that basically moves like the Dino Rhino only a bit larger. Its kind of a brontosaurus kind of character and so its basically double the height of a dino rhino and a little longer in the back for a tail. I cant figure out how to animate it. I have tried learning how sprite animation works but it is a bit overwhelming for me and I can't seem to figure it out. Can anyone help?
Trust the Fungus.


Typically, animation is handled by a RAM address for the animation frame (generally $1602). You can then multiply this value by the number of tiles per frame in order to get indices to tables containing the data for each tile.

For example, if you had a 64x64 sprite (16 tiles), your animation routine would look something like this:

Code
	LDA $1602,x	; do some binary math here to multiply by 16
	ASL #4
	PHX
	TAX
	LDA #$16	; number of tiles to write
	STA $0F
    .tileLoop
	LDA $00
	CLC : ADC XOffs,x
	STA $0300,y
	;... (likewise for other bytes)
	INY #4
	INX
	DEC $0F
	BNE .tileLoop
	PLX
	; done! jsl to $01B7B3 now
	RTS

XOffs:
	db $00,$10,$20,$30	; frame 0 (notice there are 16 bytes)
	db $00,$10,$20,$30
	db $00,$10,$20,$30
	db $00,$10,$20,$30

	db $00,$10,$20,$30	; frame 1
	db $00,$10,$20,$30
	db $00,$10,$20,$30
	db $00,$10,$20,$30
	
	;...


For unusual tile counts, you have to get a bit creative with your numbers by combining bitshifts (ASL) with adding copies of $1602. For instance, to multiply by 12 (which has a binary representation of 1100):
Code
	LDA $1602,x
	ASL			; multiply by 2 (x -> 2x)
	CLC : ADC $1602		; add one copy (2x -> 3x)
	ASL #2			; multiply by 4 (3x -> 12x)

If you compare the binary representation with the math here, it might make sense how you get to that (1 -> 10 -> 11 -> 1100). Of course, for numbers with a lot of bits set (e.g. 0x2F), it'll just be faster to actually throw it into the SNES's multiplication registers.

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
Okay, I am still very confused. Basically all I am trying to do is make this sprite work like the other giant rideable sprites in the sprite sections. I am using the friendly mega mole as a base but am having a hard time configuring it. Still don't know a lot about asm so its frustrating. I finally got it to move right but now I can't figure out how to tell the thing to only let mario ride it when he is on the head. Any ideas?





and here is the code to the mega mole. It also hurts yoshi if he touches the contact point from the bottom which I am not sure how to fix.

MegaMoleCode
Trust the Fungus.


The solid block routine uses the sprite's sprite hitbox as a base for the size of the standing area. Thankfully, you can modify that hitbox right before calling the routine, by modifying the sprite clipping bits of $1662 and adjusting the sprite's position to where you want the hitbox to be placed. Then, after calling the routine, restore the original values to those.

So, your code would end up something like this (untested, but hopefully working):
Code
	LDA $1662,x
	PHA
	AND #$C0
	ORA #$xx		; sprite clipping value to use for the head
	STA $1662,x

	LDA $E4,x
	PHA
	CLC : ADC #$xx		; x offset from base position (may want use a table based on direction it's facing)
	STA $E4,x
	LDA $14E0,x
	PHA
	ADC #$00
	STA $14E0,x

	LDA $D8,x
	PHA
	CLC : ADC #$xx		; y offset from base position
	STA $D8,x
	LDA $14D4,x
	PHA
	ADC #$00
	STA $14D4,x

	JSL $01B44F		; run solid block routine

	PLA : STA $14D4,x	; restore everything
	PLA : STA $D8,x
	PLA : STA $14E0,x
	PLA : STA $E4,x
	PLA : STA $1662,x

(also, just in case you didn't know, you should use the misc table at $1528 as the number of pixels the sprite moved since the last frame; the solid block routine uses it to move Mario with the sprite)

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
Thanks. That helped. Still have some tweaking to do but it's coming along
Trust the Fungus.