;Behaves $130 ;What this block does, will spawn a normal sprite or custom sprite. If the sprite ;that the block spawn exist at least once (as in, on screen, or processing off ;screen), it will play an incorrect sound. This is so that the player cannot spam ;sprites by repeatly hitting the block. !sprite_type = 0 ;>0 = smw sprites, 1 = custom sprites. !sprite_num = $04 ;>sprite number. !sa1_slots = 12 ;>number of slots total, use 12 for normal, 22 for sa-1 slots. !limit = 1 ;>How many same sprites the block would spawn up to. db $42 JMP MarioBelow : JMP MarioAbove : JMP MarioSide : JMP SpriteV : JMP SpriteH JMP MarioCape : JMP MarioFireBall : JMP TopCorner : JMP HeadInside : JMP BodyInside MarioBelow: LDA #$20 ;\Touch only for 1 frame. STA $7D ;/ PHX ;>preserve x register just in case STZ $00 ;>This counts how many disired sprite being processed. STZ $01 ;>This counts how many total slots used (so it plays incorrect sfx also if all slots full) LDX.b #!sa1_slots-1 ;>initalize slot countdown (note that slot 0 exist, thats why -1 is there). - LDA $14C8,x ;\If slot free, then next slot (check ALL slots!). BEQ + ;/ ;slot filled: INC $01 ;>count how many total slots used. LDA $7FAB10,x ;\Check if normal sprite match. AND #$08 ;| BNE + ;| LDA $9E,x ;| CMP #!sprite_num ;/ BNE + ; ;match spr numb INC $00 ;>if match, count it. + DEX ;\Check other slot. BPL - ;/ PLX ;>end preserve. LDA $00 ;\If the sprite this block spawns is at the disired limit, CMP.b #!limit ;|then don't spawn BCS TooMuch ;/ LDA $01 ;\If all slots are 12/12 (no sa-1) or 22/22 (sa-1) filled CMP.b #!sa1_slots ;|then don't spawn. (no -1 because it slot indexes starts at 0, and the counter starts at 0) BCS TooMuch ;/ LDA !sprite_num ;\Spawn the sprite. CLC ;| %spawn_sprite() ;/ %move_spawn_above_block() RTL TooMuch: LDA #$2A ;\Play wrong sound STA $1DFC ;/ SpriteV: SpriteH: MarioCape: MarioFireBall: MarioSide: TopCorner: MarioAbove: HeadInside: BodyInside: RTL