Prev: 49627 Up: Map Next: 49802
49661: Draw Monster Icons
Used by the routines at StartGame and UpdateThrownItem.
Draws the icons of the four monsters in the status panel. The icon of a monster that is still alive is drawn as a plain shape. The icon of a monster that has been killed is drawn with all of its detail, in the colour of the monster.
Monsters alive Monsters killed DrawMonsterIcons
monster-icons-alive monster-icons-killed
DrawMonsterIcons 49661 LD IY,48478 Start with the first monster.
49665 LD DE,22511 Set the screen address of the bottom row of the first icon to 22511 (in the screen buffer).
49668 LD B,4 Set a counter for the four monsters.
DrawMonsterIcons_Loop 49670 PUSH BC Keep the counter and the screen address.
49671 PUSH DE
49672 LD A,B Work out the type of the first frame of this monster's sprite (108, 104, 100 or 96).
49673 ADD A,A
49674 ADD A,A
49675 ADD A,92
49677 LD BC,28318 Point at the table of sprite addresses.
49680 CALL GetTableEntry Find the address of the sprite in the table.
49683 EX DE,HL Swap the sprite address and the screen address over.
49684 LD A,(DE) Check whether the sprite is stored flipped (bit 6 of its first byte).
49685 AND 64
49687 PUSH BC Keep the registers safe.
49688 PUSH HL
49689 CALL NZ,MirrorSprite Flip the sprite back to its normal way round if it is flipped.
49692 POP HL Get the registers back.
49693 POP BC
49694 EX DE,HL Swap the sprite address and the screen address over again.
49695 LD A,(HL) Fetch the width of the sprite in bytes.
49696 INC HL
49697 AND 63
49699 LD B,A
49700 LD C,(HL) Fetch the height of the sprite in rows.
49701 INC HL
49702 LD A,(IY+0) Check whether the monster has been killed, and jump to DrawMonsterIcons_DeadRow if it has.
49705 SUB 96
49707 CP 16
49709 JR NC,DrawMonsterIcons_DeadRow
DrawMonsterIcons_AliveRow 49711 PUSH BC Keep the width and the screen address of the row.
49712 PUSH DE
DrawMonsterIcons_AliveByte 49713 LD A,(HL) Draw a byte of the row as the plain shape of the sprite, and loop back until the whole row has been drawn.
49714 INC HL
49715 CPL
49716 OR (HL)
49717 INC HL
49718 CPL
49719 LD (DE),A
49720 INC E
49721 DJNZ DrawMonsterIcons_AliveByte
49723 POP DE Get the width and the screen address of the row back.
49724 POP BC
49725 CALL ScreenPosition1PixelAbove Move up to the row above.
49728 DEC C Loop back until every row of the icon has been drawn.
49729 JR NZ,DrawMonsterIcons_AliveRow
DrawMonsterIcons_Next 49731 POP DE Get the counter and the screen address back.
49732 POP BC
49733 INC E Move on by three characters, to the place for the next icon.
49734 INC E
49735 INC E
49736 PUSH DE Move on to the next monster.
49737 LD DE,16
49740 ADD IY,DE
49742 POP DE
49743 DJNZ DrawMonsterIcons_Loop Loop back until the icons of all four monsters have been drawn.
49745 RET Return.
The monster has been killed, so draw its full pixel image.
DrawMonsterIcons_DeadRow 49746 PUSH BC Keep the width and the screen address of the row.
49747 PUSH DE
DrawMonsterIcons_DeadByte 49748 INC HL Draw a byte of the row from the full pixel image of the sprite, and loop back until the whole row has been drawn.
49749 LD A,(HL)
49750 INC HL
49751 LD (DE),A
49752 INC E
49753 DJNZ DrawMonsterIcons_DeadByte
49755 POP DE Get the width and the screen address of the row back.
49756 POP BC
49757 CALL ScreenPosition1PixelAbove Move up to the row above.
49760 DEC C Loop back until every row of the icon has been drawn.
49761 JR NZ,DrawMonsterIcons_DeadRow
Colour the icon with the colour of the monster.
49763 POP DE Get the counter and the screen address back, and keep them for the next icon.
49764 POP BC
49765 PUSH BC
49766 PUSH DE
49767 LD A,B Look up the colour of the monster.
49768 LD HL,50479
49771 CALL AddAToHL
49774 LD C,(HL) Keep the colour.
49775 EX DE,HL Get the screen address of the icon.
49776 LD A,H Work out the address of the matching attribute.
49777 RRCA
49778 RRCA
49779 RRCA
49780 AND 3
49782 LD H,A
49783 LD DE,22528 Add 22528 (in the attribute buffer).
49786 ADD HL,DE
49787 LD DE,65502 Set the distance from one row of attributes to the row above.
49790 LD B,6 Set a counter for the six rows of the icon.
DrawMonsterIcons_Colour 49792 LD (HL),C Colour the three attributes of a row of the icon, and loop back until all six rows have been coloured.
49793 INC L
49794 LD (HL),C
49795 INC L
49796 LD (HL),C
49797 ADD HL,DE
49798 DJNZ DrawMonsterIcons_Colour
49800 JR DrawMonsterIcons_Next Jump to DrawMonsterIcons_Next to move on to the next icon.
Prev: 49627 Up: Map Next: 49802