Prev: D978 Up: Map Next: D9EB
D9A3: Update Village Item
The routine for objects of type 30 to 3F, the items that appear in the village (see SpawnItem). An item wanders about at random while the player stays in the cell that it appeared in, and is picked up when the player touches it. It turns into a burst, and goes back to the items that are available, when the player has gone from the cell or is dead.
UpdateVillageItem D9A3 LD A,($BC8E) Jump to UpdateVillageItem_Dead if the player is not there (the type of the player is not 10 to 2F).
D9A6 SUB $10
D9A8 CP $20
D9AA JR NC,UpdateVillageItem_Dead
D9AC LD A,($BC90) Jump to UpdateVillageItem_Left if the player is not in the column of the item.
D9AF CP (IX+$02)
D9B2 JR NZ,UpdateVillageItem_Left
D9B4 LD A,($BC92) Jump to UpdateVillageItem_Left if the player is not in the row of the item.
D9B7 CP (IX+$04)
D9BA JR NZ,UpdateVillageItem_Left
D9BC LD B,$04 Use 04 bits for the velocity.
D9BE CALL ChooseRandomVelocity Choose a random velocity.
D9C1 CALL SetDirectionFromVelocity Set the direction that the item is facing from its velocity.
D9C4 CALL MoveObject Move the item.
D9C7 CALL NextSpriteNumber Change the sprite of the item.
D9CA CALL CheckPlayerCollision Return if the item is not touching the player.
D9CD RET NC
D9CE CALL PickUpItem Pick up the item.
D9D1 LD (IX+$00),$0C Turn the item into a burst and return.
D9D5 RET
The player is dead.
UpdateVillageItem_Dead D9D6 LD (IX+$00),$0D Turn the item into a burst, with a different sprite, and jump to UpdateVillageItem_Return.
D9DA JR UpdateVillageItem_Return
The player has left the cell.
UpdateVillageItem_Left D9DC LD (IX+$00),$0C Turn the item into a burst.
Add the item to the items that are available for the kind of tile.
UpdateVillageItem_Return D9E0 LD C,(IX+$05) Fetch the kind of tile that the item was found on.
D9E3 LD B,$00
D9E5 LD HL,$BBCE Point at the number of items for the kind of tile.
D9E8 ADD HL,BC
D9E9 INC (HL) Add one to the number of items that are available.
D9EA RET Return.
Prev: D978 Up: Map Next: D9EB