Tip: You can use Lunar Magic's Overworld Layer 3 Editing system to edit or create your own layer 3 images (castle bricks, fish, rocks) and apply unique effects per level via the Layer 3 Bypass in the main editor.
0x0C commands: (JAL, but quite different here. The RAM Offset is done through LB(Load Byte))
[0C] [00 00 00] [80 XX XX XX]
= 0C is the Command Byte.
[1,2,3]= Always zero, unused?
[4,5,6,7]= The offset in RAM of the ASM function.
0x0C commands do call ASM Funtions found in RAM.
The functions are "looped" because of the 0x08 command and ends with 0x09 command. 0x08 starts a loop, is called every frame. And 0x09 jumps back to the beginning of the loop.
You can use ASM Function "0C 00 00 00 80 2C B1 C0" to inject your own code, as this is an unused debug function in mario's behavior. For this, you calculate the ROM offset of 802CB1C0. For every RAM offset between $80246000 and $80330000 you subtract $80245000 of the RAM offset. $802CB1C0-$80245000 = $861C0 (ROM offset). In $861C0 you put in your code. (Remember to make place for the stack and push your return address to the stack, in case you call a subroutine)