Since Bio's original post was quite messy and the code snippets were unorganized, I've rewritten the first post. In this thread you will find commonly used code snippets and routines which you can use in your blocks, sprites and patches.
Blocks:
Change Map16 Number (load the Map16 tile in X, it can be 8-bit or 16-bit)
Causes a block to disappear
Causes a block to shatter
Causes a block to shatter on sprite contact
Check which side of a block Mario touched
Sprites:
Causes the sprite to explode like a Bob-omb
Draw smoke at sprite's position
Stores Mario to the sprite position
Stores sprite to Mario's position
Horizontal proximity check
Vertical proximity check
Spawn a normal sprite
Spawn a custom sprite
Spawn an extended sprite
Set sprite (extended, regular or minor extended) speed based on Mario's speed
Cape collision detection
Fireball Contact Routine
Sprite Interacts With Map16 Tile xxx.
HDMA:
Bright blue to darker blue, background colour gradient. ($2132)
Blue sky gradient
Green sky gradient (Image)
Pink sky gradient (Image)
Night sky gradient (Image)
Sunset gradient (Image)
Window effect (Image)
Wavy HDMA effect
HDMA Brightness gradient
Misc:
Yoshi's Earthquake
Pointer Subroutine
Random Number Generation (Ersanio)
Random Number Generation (1024)
Reset the game
The for() loop in ASM
Lose Yoshi
Convert time to binary
Use JSL with RTS
Hex -> Dec (short)
Hex -> Dec (long)
Layer 3 scroll (left and right codes included)
Stop level at a certain screen (assuming level moves from bottom to top)
Stop level at a certain screen (assuming level moves from top to bottom)
Stop level at a certain screen (assuming level moves from left to right)
Stop level at a certain screen (assuming level moves from right to left)
Find the number ($13BF format) of the level the current player is on.
Blocks:
Change Map16 Number (load the Map16 tile in X, it can be 8-bit or 16-bit)
Causes a block to disappear
Causes a block to shatter
Causes a block to shatter on sprite contact
Check which side of a block Mario touched
Sprites:
Causes the sprite to explode like a Bob-omb
Draw smoke at sprite's position
Stores Mario to the sprite position
Stores sprite to Mario's position
Horizontal proximity check
Vertical proximity check
Spawn a normal sprite
Spawn a custom sprite
Spawn an extended sprite
Set sprite (extended, regular or minor extended) speed based on Mario's speed
Cape collision detection
Fireball Contact Routine
Sprite Interacts With Map16 Tile xxx.
HDMA:
Bright blue to darker blue, background colour gradient. ($2132)
Blue sky gradient
Green sky gradient (Image)
Pink sky gradient (Image)
Night sky gradient (Image)
Sunset gradient (Image)
Window effect (Image)
Wavy HDMA effect
HDMA Brightness gradient
Misc:
Yoshi's Earthquake
Pointer Subroutine
Random Number Generation (Ersanio)
Random Number Generation (1024)
Reset the game
The for() loop in ASM
Lose Yoshi
Convert time to binary
Use JSL with RTS
Hex -> Dec (short)
Hex -> Dec (long)
Layer 3 scroll (left and right codes included)
Stop level at a certain screen (assuming level moves from bottom to top)
Stop level at a certain screen (assuming level moves from top to bottom)
Stop level at a certain screen (assuming level moves from left to right)
Stop level at a certain screen (assuming level moves from right to left)
Find the number ($13BF format) of the level the current player is on.