Sprite: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 7:
{| class="wikitable"
|-
! Offset !! Length !! [[Data types|Type]] !! Description
|-
| 0x00 || 2 || bit field || [[#Sprite properties|Sprite properties]]
Line 17:
| 0x06 || 2 || int16 || Y position
|-
| 0x08 || 4 || optional pointer32 || Pointer to sprite tile data
|-
| 0x0C || 2 || uint16 x2 || Parent entity ID
Line 61:
{| class="wikitable"
|-
! Offset !! Length !! [[Data types|Type]] !! Description
|-
| 0x00 || 1 || byte || Tile count (also see [[#Extended sprite tile data|extended sprite tile data]])
Line 72:
{| class="wikitable"
|-
! Offset !! Length !! [[Data types|Type]] !! Description
|-
| 0x00 || 2 || int16 || X position
Line 83:
|}
 
The sprite graphics are located at [[$84:8000]] and each 16x16 tile is 0x80 bytes long, so the address of the graphics for a given tile number can be calculated as "0x20000 + TileNumber * 0x80".
 
==== Tile properties ====
Line 100:
== Sprite types ==
 
{| class="wikitable col3_center col4_center"
Highlighted rows are sprite types that are considered solid (see [[#Solid sprites|solid sprites]]).
 
{| class="wikitable"
|-
! Type !! Description !! Solid to<br />players !! Solid to<br />monsters
|-
| 0x0000 || None. Sprites set to this type will have no collision. || ||
|-
| 0x0001 || Victim || || ✓
|-
| 0x0002 || Monster that does no damage || || ✓
|- class="highlightrow"
| 0x0003 || Monster
|- class="highlightrow"
| 0x0004 || [[Ant]] that isn't holding an item pickup
|-
| 0x0003 || Monster || ✓ || ✓
| 0x0005 || Zeke
|-
| 0x0004 || [[Ant]] that isn't holding an item pickup || ✓ || ✓
| 0x0006 || Julie
|-
| 0x0005 || Zeke || || ✓
| 0x0007 || Wall breaking from player punching it as a monster
|-
| 0x0006 || Julie || || ✓
| 0x0008 || Unused type that damages [[evil doll axe]]s
|- class="highlightrow"
| 0x0009 || Monster projectiles
|- class="highlightrow"
| 0x000A || [[Giant baby]] flattening the player
|- class="highlightrow"
| 0x000B || Bubble shot by [[martian]]
|-
| 0x0007 || Wall breaking from player punching it as a monster || ||
| 0x000C || [[Squirt gun]] [[item pickup]]
|-
| 0x0008 || Unused type that damages [[evil doll axe]]s || ||
| 0x000D || [[Fire extinguisher]] item pickup
|-
| 0x0009 || Monster projectiles || ✓ || ✓
| 0x000E || [[Martian bubble gun]] item pickup
|-
| 0x000A || [[Giant baby]] flattening the player || ✓ || ✓
| 0x000F || [[Weed-eater]] item pickup
|-
| 0x000B || Bubble shot by [[martian]] || ✓ || ✓
| 0x0010 || [[Ancient artifact]] item pickup
|-
| 0x00110x000C || [[BazookaSquirt gun]] [[item pickup]] || ||
|-
| 0x00120x000D || [[SodaFire pop cansextinguisher]] item pickup || ||
|-
| 0x00130x000E || [[TomatoesMartian bubble gun]] item pickup || ||
|-
| 0x00140x000F || [[Ice popsWeed-eater]] item pickup || ||
|-
| 0x00150x0010 || [[BananasAncient artifact]] item pickup || ||
|-
| 0x00160x0011 || [[PlateBazooka]] item pickup || ||
|-
| 0x00170x0012 || [[SilverwareSoda pop cans]] item pickup || ||
|-
| 0x00180x0013 || [[FootballTomatoes]] item pickup || ||
|-
| 0x00190x0014 || [[FlamethrowerIce pops]] item pickup || ||
|-
| 0x000F0x0015 || [[Weed-eaterBananas]] item pickup || ||
|-
| 0x00310x0016 || Unused[[Plate]] item pickup type|| ||
|-
| 0x0017 || [[Silverware]] item pickup || ||
|-
| 0x0018 || [[Football]] item pickup || ||
|-
| 0x0019 || [[Flamethrower]] item pickup || ||
|- class="breakrow"
| 0x0021 || [[Key]] item pickup || ||
|-
| 0x000C0x0022 || [[SquirtSpeed gunshoes]] [[item pickup]] || ||
|-
| 0x000E0x0023 || [[MartianMonster bubble gunpotion]] item pickup || ||
|-
| 0x000D0x0024 || [[FireGhost extinguisherkid potion]] item pickup || ||
|-
| 0x00100x0025 || [[AncientRandom artifactpotion]] item pickup || ||
|-
| 0x00220x0026 || [[SpeedGrey shoespotion]] item pickup || ||
|-
| 0x00230x0027 || [[Monster potionHamburger]] item pickup || ||
|-
| 0x00240x0028 || [[GhostFirst kidaid potionkit]] item pickup || ||
|-
| 0x00250x0029 || [[RandomPandora's potionbox]] item pickup || ||
|-
| 0x00260x002A || [[GreySkeleton potionkey]] item pickup || ||
|-
| 0x00270x002B || [[HamburgerDecoys]] item pickup || ||
|-
| 0x00280x002C || [[FirstPile aidof kitkeys]] item|| || pickup
|-
| 0x00290x002D || [[Pandora'sSecret boxitem]] item|| || pickup
|-
| 0x002A0x002E || [[Skeleton key1up]] item|| || pickup
|-
| 0x002B0x002F || [[DecoysGold]] item|| || pickup
|-
| 0x002C0x0030 || [[PileDollar of keysbills]] || ||
|-
| 0x002D0x0031 || [[SecretUnused item]] pickup type || ||
|-
| 0x0032 || Unused item pickup type || ||
| 0x002E || [[1up]]
|-
| 0x0033 || Unused || ||
| 0x002F || [[Gold]]
|-
| 0x00300x0034 || [[DollarJelly billsblob]] shot || ✓ || ✓
|-
| 0x0035 || [[Football player]] || ✓ || ✓
| 0x0031 || Unused item pickup type
|-
| 0x00320x0036 || UnusedFrozen itemmonster pickup|| ✓ || type
|-
| 0x0037 || Exit door || || ✓
| 0x0033 || Unused
|- class="highlightrow"
| 0x0034 || [[Jelly blob]] shot
|- class="highlightrow"
| 0x0035 || [[Football player]]
|- class="highlightrow"
| 0x0036 || Frozen monster
|-
| 0x0038 || [[Decoys]]/Player who is invincible after dying || ✓ || ✓
| 0x0037 || Exit door
|- class="highlightrow"
| 0x0038 || [[Decoys]]/Player who is invincible after dying
|- class="breakrow"
| 0x0040 || Victim insta-killer used by [[Debug.asm]] || ||
|- class="breakrow"
| 0x005C || [[Squirt gun]] shot from Zeke || || ✓
|-
| 0x005D || [[Fire extinguisher]] shot from Zeke || || ✓
|-
| 0x005E || [[Martian bubble gun]] shot from Zeke || || ✓
|-
| 0x005F || [[Weed-eater]] shot from Zeke || || ✓
|-
| 0x0060 || [[Ancient artifact]] shot from Zeke/invincible after dying damage from Zeke || || ✓
|-
| 0x0061 || [[Bazooka]] shot from Zeke || || ✓
|-
| 0x0062 || [[Soda pop cans]]/[[Flamethrower]] shot from Zeke || || ✓
|-
| 0x0063 || [[Tomatoes]] shot from Zeke || || ✓
|-
| 0x0064 || [[Ice pops]]/[[Bananas]] shot from Zeke || || ✓
|-
| 0x0065 || Unused, but damages [[fire]] || || ✓
|-
| 0x0066 || [[Plate]] shot from Zeke || || ✓
|-
| 0x0067 || [[Silverware]] shot from Zeke || || ✓
|-
| 0x0068 || [[Football]] shot from Zeke || || ✓
|-
| 0x0069 || Pop-up wall || || ✓
|-
| 0x006A || Unused weapon shot type || || ✓
|-
| 0x006B || Unused weapon shot type || || ✓
|-
| 0x006C || Unused weapon shot type || || ✓
|-
| 0x006D || Unused weapon shot type || || ✓
|-
| 0x006E || Unused weapon shot type || || ✓
|-
| 0x006F || [[Pandora's box]] shot from Zeke || || ✓
|-
| 0x0070 || [[Monster potion]] punch from Zeke || || ✓
|- class="breakrow"
| 0x00FF || SpriteOne-shot monster/victim went off screen || ||
|}
 
Line 271 ⟶ 269:
== Collision ==
 
[[Entity|Entities]] can call [[$80:8475]] to set a collision handler for the sprites they own. When a sprite collides with another sprite, the collision handler of the parent entity of each sprite is called, with the type of the sprite it collided with provided in the accumulator. In addition, [[$7E:0076]] and [[$7E:0078]] can be used to access the two sprites involved in the collision. The collision handlers are set per entity, so even if an entity has multiple sprites, they must share the same collision handler. Collision handlers are run outside the context of the entity, so [[$80:8353]] cannot be called to wait. However, the direct page will be set to the entity memory, so data from there can be accessed.
 
The collision handler returns a value in the carry flag. If this value is set, then the entity will be immediately resumed, regardless of how much was left in its current wait timer.
 
Sprites are considered collided if their X and Y positions are both less than 8 pixels apart, they are both on-screen (meaning they must be visible), they both have non-zero sprite type, and they have different sprite types. Collision can also triggered over an arbitrary area by calling [[$80:BF1B]]. The same restrictions on sprite type apply to this as well.
 
=== Solid sprites ===
 
Certain sprite types are considered solid. That is, players andor monsters will not be able to move through them. Sprite types that are solid are highlightedshown in the [[#Sprite types|sprite type]] table above. In addition, types 0x39 through 0x5B are solid to both players and monsters, and types 0x71 and greater are solid to monsters, but these types are not used in the original game.
 
Solid sprites are implemented in a different way from normal sprite collision. An entity must manually call [[$80:BFC8]] to check if a given position is overlappingsolid to players, or [[$80:BF67]] to check if a position is solid spriteto monsters.
 
The area for solid sprites is slightly smaller than for regular collision. A position is considered touching a solid sprite if it is within 6 pixels of the right or bottom, or within 5 pixels of the left or top. The area is smaller so that sprites will trigger regular collision before stopping due to running into a solid sprite.