![]() |
Routines |
| Prev: 50619 | Up: Map | Next: 50749 |
|
Used by the routine at StartGame.
Every sixteen frames, when the player is standing on a kind of tile that still has items to give, makes an item appear at the player's position. The item is placed in the first free one of the four objects from ObjectTable_Items, at a random position within the cell. The number of items that are left for each kind of tile is held in the table at ItemsLeft.
|
||||
|
Wait until it is time to spawn an item.
|
||||
| SpawnItem | 50638 | LD A,(48130) | Return if the player is still materialising. | |
| 50641 | CP 112 | |||
| 50643 | RET NZ | |||
| 50644 | LD A,(48050) | Return unless the frame counter is a multiple of sixteen. | ||
| 50647 | AND 15 | |||
| 50649 | RET NZ | |||
| 50650 | LD IY,48334 | Start with the first of the four item objects, set the distance from one object to the next (16 bytes) and set a counter for the four items. | ||
| 50654 | LD DE,16 | |||
| 50657 | LD B,4 | |||
|
Find a free item object.
|
||||
| SpawnItem_Find | 50659 | LD A,(IY+0) | Jump to SpawnItem_Spawn if this item object is free. | |
| 50662 | AND A | |||
| 50663 | JR Z,SpawnItem_Spawn | |||
| 50665 | ADD IY,DE | Move on to the next item object and loop back until all four have been tried, and then return. | ||
| 50667 | DJNZ SpawnItem_Find | |||
| 50669 | RET | |||
|
Place the item in the player's cell, if the tile still has items left.
|
||||
| SpawnItem_Spawn | 50670 | LD A,(48272) | Fetch the column and row of the player's cell. | |
| 50673 | LD L,A | |||
| 50674 | LD A,(48274) | |||
| 50677 | LD H,A | |||
| 50678 | LD E,L | |||
| 50679 | LD D,H | |||
| 50680 | CALL FindMapTile | Find out what kind of tile is in the cell. | ||
| 50683 | LD C,A | Fetch the number of items that are left for this kind of tile, and return if there are none. | ||
| 50684 | LD B,0 | |||
| 50686 | LD HL,48078 | |||
| 50689 | ADD HL,BC | |||
| 50690 | LD A,(HL) | |||
| 50691 | AND A | |||
| 50692 | RET Z | |||
| 50693 | DEC (HL) | Take one from the number of items that are left. | ||
| 50694 | LD (IY+2),E | Set the column and row of the item to those of the player's cell, and the tile to the kind of tile. | ||
| 50697 | LD (IY+4),D | |||
| 50700 | LD (IY+5),C | |||
| 50703 | LD A,C | Choose the type of the item (48, 52, 56 or 60) from the kind of tile. | ||
| 50704 | AND 3 | |||
| 50706 | ADD A,A | |||
| 50707 | ADD A,A | |||
| 50708 | OR 48 | |||
| 50710 | LD (IY+0),A | Make the object an item. | ||
| 50713 | LD HL,(48042) | Put the item at a random place along the X axis of the cell. | ||
| 50716 | LD A,L | |||
| 50717 | AND 127 | |||
| 50719 | ADD A,64 | |||
| 50721 | LD (IY+1),A | |||
| 50724 | LD A,H | Put the item at a random place along the Y axis of the cell. | ||
| 50725 | AND 127 | |||
| 50727 | ADD A,64 | |||
| 50729 | LD (IY+3),A | |||
| 50732 | LD A,8 | Make the item eight units wide and deep. | ||
| 50734 | LD (IY+8),A | |||
| 50737 | LD (IY+9),A | |||
| 50740 | LD (IY+12),248 | Set the drawing offsets of the item to 248 and 4. | ||
| 50744 | LD (IY+13),4 | |||
| 50748 | RET | Return. | ||
| Prev: 50619 | Up: Map | Next: 50749 |