Language…
9 users online: Batata Douce, crocodileman94, DimeR, Dzing, Gamet2004,  icrawfish,  Nanako, temsuper1, TheXander - Guests: 272 - Bots: 294
Users: 64,795 (2,377 active)
Latest user: mathew

SMB2 Cobrat by failstream

File Name: SMB2 Cobrat
Submitted: by failstream
Authors: failstream
Tool: PIXI
Type: Standard
Dynamic: No
Disassembly: No
Includes GFX: Yes
Description: The Cobrat from SMB2 that can be ridden and shoots projectiles. This sprite uses four extra bytes that can determine various behavior. I also commented various spots in the sprite where the behavior could be expanded upon (if you know ASM), but since this is the first sprite I've made I might have overlooked something. When using the first 4 behaviors you will want to place the sprite under a map16 tile with priority on.

Byte 1 determines main behavior of the Cobrat.
00) Normal: Waits until Mario approaches, then jumps out and starts running around.
01) Normal w/Projectile
02) Pipe: Stays under ground and pops up every once in awhile based on a timer.
03) Pipe w/Projectile
04) Running: Runs along ground turning around when it encounters a wall or sprite

Bytes 2-4 determine extra options while in the running behavior.

Byte 2: Timer between shooting projectiles. Due to the animation timer anything below 09 will look strange or it won't shoot.

Byte 3: Timer between jumps while on the running. Cobrats won't jump unless touching the ground.

Byte 4: Determines the height the Cobrat jumps. 00 is default height.
Screenshots:
While it is a nice sprite on its own, the problem is that hiding Cobrats don't disappear behind the foreground which means they only work on high priority tiles (which quicksand is but vanilla pipes usually aren't), "pipe" cobrats aren't corrected in their X position (as you'd imply with "pipe") and lastly, the code is... not very clean.

Regarding the latter point, the main problem is that you don't have to save every single byte but more code can be put inline. I also have noticed that you separate the main code into states and it's the subroutines which differenciate between the individual behaviours which is neither clean nor fast nor might even save insertion size!
Sprites are heavy on cycles which is why you should optimise for speed (which results in clean code), not for byte count. Especially the uses of ExecutePtrs really makes the Cobrat slower than it should have been.