Language…
8 users online: AnEvilGhost, DasFueller, hoangng, RoboticMouse,  RussianMan, steelsburg,  Teyla,  Thomas - Guests: 106 - Bots: 270
Users: 64,666 (2,405 active)
Latest user: Dongulusrift

how to change a default block

Sorry for the inconvenience. It's because I'm new to this, he asked me if a default block like the one that generates a green turtle shell can be changed for another sprite like the number of sprite 85, that's where I have the venous mushroom?


I assume you mean you're trying to have a block spawn a poison mushroom? Although it's possible to change one of the blocks in the original game to spawn that instead, it's a bit awkward due to it being a custom sprite. It'll be a lot easier to just use a custom block instead. In particular, this block would let you spawn any sprite you want very easily.


Regardless, if you do still want to modify the original block, you'd want to look at the two tables at $0288A3 and $0288B4, which contain sprite IDs to spawn for each block. The first table is when not riding Yoshi, and the second table is when riding Yoshi. Specifically, the shell is at index D of both these tables. What you'd have to do is add some code to hijack around where the tables are accessed at $02893A in order to add some handling to spawn a custom sprite instead of one of the original game's sprites. Specifically, look at lines 32-48 of Pixi's SpawnSprite.asm file for an example code on how to spawn a custom sprite.

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
Originally posted by Thomas
I assume you mean you're trying to have a block spawn a poison mushroom? Although it's possible to change one of the blocks in the original game to spawn that instead, it's a bit awkward due to it being a custom sprite. It'll be a lot easier to just use a custom block instead. In particular, this block would let you spawn any sprite you want very easily.


Regardless, if you do still want to modify the original block, you'd want to look at the two tables at $0288A3 and $0288B4, which contain sprite IDs to spawn for each block. The first table is when not riding Yoshi, and the second table is when riding Yoshi. Specifically, the shell is at index D of both these tables. What you'd have to do is add some code to hijack around where the tables are accessed at $02893A in order to add some handling to spawn a custom sprite instead of one of the original game's sprites. Specifically, look at lines 32-48 of Pixi's SpawnSprite.asm file for an example code on how to spawn a custom sprite.


the venous mushroom is internal, it occupies a space in an empty sprite slot, what I want is what the block is in charge of generating a green shell. be default for what the default block I generated sprite 85 is very simple.
If you really want to change the content of a vanilla block, you can use the follow patch:
Code
macro ChangeBlockContent(index, sprite, state)
org $0288A3+<index>
db <sprite>
org $0288B4+<index>
db <sprite>
org $0288C5+<index>
db <state>
endmacro

%ChangeBlockContent($0D, $85, $08) ; Assuming the mushroom is indeed sprite $85