![]() |
Routines |
| Prev: C489 | Up: Map | Next: C52F |
|
Used by the routine at StartGame.
Sets the attributes of the items in the inventory tube. Each item is a block of two by two attributes. Items 01 to 04 flash in the colours of items 05 to 08 when the player is within five cells of the monster that they belong to.
|
||||
|
Colour each place in the inventory tube.
|
||||
| ColourInventoryItems | C4DC | LD BC,$C52F | Point at the table of colours, and at the lowest item at 5AC2 (in the attribute buffer). | |
| C4DF | LD HL,$5AC2 | |||
| C4E2 | EXX | Switch to the shadow registers, point at the inventory and set a counter for the eleven places in it. | ||
| C4E3 | LD DE,$BC03 | |||
| C4E6 | LD B,$0B | |||
| ColourInventoryItems_Loop | C4E8 | LD A,(DE) | Fetch the item, and return if there are no more items. | |
| C4E9 | AND A | |||
| C4EA | RET Z | |||
| C4EB | CP $05 | Jump to ColourInventoryItems_Monster if the item is one of the four that belong to monsters. | ||
| C4ED | JR C,ColourInventoryItems_Monster | |||
| ColourInventoryItems_Colour | C4EF | EXX | Look up the colour of the item in the table of colours. | |
| C4F0 | EX DE,HL | |||
| C4F1 | LD L,A | |||
| C4F2 | LD H,$00 | |||
| C4F4 | ADD HL,BC | |||
| C4F5 | LD A,(HL) | |||
| C4F6 | EX DE,HL | |||
| C4F7 | LD (HL),A | Colour the top two attributes of the item. | ||
| C4F8 | INC HL | |||
| C4F9 | LD (HL),A | |||
| C4FA | LD DE,$FFDF | Move to the row of attributes above. | ||
| C4FD | ADD HL,DE | |||
| C4FE | LD (HL),A | Colour the bottom two attributes of the item. | ||
| C4FF | INC HL | |||
| C500 | LD (HL),A | |||
| C501 | ADD HL,DE | Move up one more row, to the next item. | ||
| C502 | EXX | Swap back to the main registers. | ||
| C503 | INC DE | Move on to the next place in the inventory, and loop back until all eleven have been coloured. | ||
| C504 | DJNZ ColourInventoryItems_Loop | |||
| C506 | RET | Return. | ||
|
Items 01 to 04 belong to the monsters. Find out whether the monster is near the player.
|
||||
| ColourInventoryItems_Monster | C507 | PUSH AF | Keep the item and the pointer to the inventory. | |
| C508 | PUSH DE | |||
| C509 | CPL | Turn the number of the item into the number of the monster, from 03 to 00. | ||
| C50A | ADD A,$05 | |||
| C50C | ADD A,A | Multiply it by sixteen, to get the distance to the object of the monster. | ||
| C50D | ADD A,A | |||
| C50E | ADD A,A | |||
| C50F | ADD A,A | |||
| C510 | LD E,A | Put the distance in DE. | ||
| C511 | LD D,$00 | |||
| C513 | LD IX,$BD5E | Start with the first monster. | ||
| C517 | ADD IX,DE | Add the distance, to point at the right monster. | ||
| C519 | LD C,$05 | Set the distance to 05 cells. | ||
| C51B | CALL CheckPlayerClose | Check whether the monster is close to the player. | ||
| C51E | JR C,ColourInventoryItems_Flash | Jump to ColourInventoryItems_Flash to make the item flash if the player is within five cells of the monster. | ||
| C520 | POP DE | Get the item and the pointer to the inventory back. | ||
| C521 | POP AF | |||
| C522 | JR ColourInventoryItems_Colour | Jump to ColourInventoryItems_Colour to give the item its usual colour. | ||
| ColourInventoryItems_Flash | C524 | POP DE | Get the item and the pointer to the inventory back. | |
| C525 | POP AF | |||
| C526 | LD A,($BBB2) | Use the lowest two bits of the frame counter, plus five, as the colour of the item, so that it flashes. | ||
| C529 | AND $03 | |||
| C52B | ADD A,$05 | |||
| C52D | JR ColourInventoryItems_Colour | Jump to ColourInventoryItems_Colour to colour the item. | ||
| Prev: C489 | Up: Map | Next: C52F |