![]() |
Routines |
| Prev: 8B85 | Up: Map | Next: 8C2D |
|
Used by the routines at LOSE_FOOD_EIGHT, EAT_FOOD, UPDATE_KNIGHT, LOSE_FOOD_THIRTY_TWO, PLACE_PLAYER and MUSHROOM_DRAIN.
The life force in $5E28 is drawn as the roast down the right-hand side, eaten away as it falls. $5E29 remembers the level the picture was last drawn at, and both are shifted right three times before being compared, so nothing happens until a whole eighth of the roast has gone -- most calls return at the third instruction.
It does not have its own copy of the picture. It reaches into the sprite tables, moves the roast's entry at ROAST_SPRITE forward by however many rows have been eaten and shortens the height bytes of GFX_B5 and GFX_B4, the second byte of each, to match, draws, and then puts all three back from the stack. The tables are only wrong for the few hundred T-states it takes to draw.
Watched live: at rest ROAST_SPRITE holds GFX_B5 and GFX_B5's height byte holds $1E, and breaking just before the restore catches ROAST_SPRITE reading $C522 and then $C51C as the roast goes down -- the same entry, advanced past the rows that have been eaten.
|
||||||||
| DRAW_FOOD | 8B8A | LD A,($5E28) | The level, in eighths. | |||||
| 8B8D | SRL A | |||||||
| 8B8F | SRL A | |||||||
| 8B91 | SRL A | |||||||
| 8B93 | LD C,A | |||||||
| 8B94 | LD A,($5E29) | What was drawn last time, also in eighths. | ||||||
| 8B97 | SRL A | |||||||
| 8B99 | SRL A | |||||||
| 8B9B | SRL A | |||||||
| 8B9D | LD B,A | |||||||
| 8B9E | CP C | The same, so the picture is still right. | ||||||
| 8B9F | RET Z | |||||||
| 8BA0 | LD A,($C543) | Keep the roast's real height to put back afterwards. | ||||||
| 8BA3 | LD E,A | |||||||
| 8BA4 | LD A,($C48D) | |||||||
| 8BA7 | LD D,A | |||||||
| 8BA8 | PUSH IX | |||||||
| 8BAA | LD IX,FOOD_RECORD | Not an actor, so borrow FOOD_RECORD. | ||||||
| 8BAE | PUSH DE | |||||||
| 8BAF | JR C,DRAW_FOOD_3 | |||||||
| 8BB1 | LD A,(GFX_B5) | |||||||
| 8BB4 | LD E,A | |||||||
| 8BB5 | LD D,$00 | |||||||
| 8BB7 | LD A,C | |||||||
| 8BB8 | PUSH BC | |||||||
| 8BB9 | CALL MULTIPLY | |||||||
| 8BBC | POP BC | |||||||
| 8BBD | LD DE,(ROAST_SPRITE) | The roast's entry in the sprite pointer table. | ||||||
| 8BC1 | PUSH DE | |||||||
| 8BC2 | ADD HL,DE | |||||||
| 8BC3 | LD (ROAST_SPRITE),HL | Moved past the eaten rows, and put back before returning. | ||||||
| 8BC6 | LD E,(HL) | |||||||
| 8BC7 | INC HL | |||||||
| 8BC8 | LD D,(HL) | |||||||
| 8BC9 | LD A,($C48D) | GFX_B5+1: the bones' height byte | ||||||
| 8BCC | SUB C | |||||||
| 8BCD | JR Z,DRAW_FOOD_1 | |||||||
| 8BCF | PUSH DE | |||||||
| 8BD0 | LD (HL),A | |||||||
| 8BD1 | LD A,(GFX_B5) | |||||||
| 8BD4 | DEC HL | |||||||
| 8BD5 | LD (HL),A | |||||||
| 8BD6 | PUSH HL | |||||||
| 8BD7 | LD A,$14 | |||||||
| 8BD9 | LD (IX+$00),A | |||||||
| 8BDC | LD HL,$77C8 | |||||||
| 8BDF | LD A,H | |||||||
| 8BE0 | SUB C | |||||||
| 8BE1 | LD H,A | |||||||
| 8BE2 | LD ($8C30),HL | FOOD_RECORD+3: where the roast is drawn | ||||||
| 8BE5 | CALL DRAW_RECORD | |||||||
| 8BE8 | LD HL,($8C30) | FOOD_RECORD+3: where the roast is drawn | ||||||
| 8BEB | CALL PIXEL_TO_SCREEN | |||||||
| 8BEE | LD A,(GFX_B5) | |||||||
| 8BF1 | LD B,A | |||||||
| DRAW_FOOD_0 | 8BF2 | LD (HL),$00 | ||||||
| 8BF4 | INC L | |||||||
| 8BF5 | DJNZ DRAW_FOOD_0 | |||||||
| 8BF7 | POP HL | |||||||
| 8BF8 | POP DE | |||||||
| 8BF9 | LD (HL),E | |||||||
| 8BFA | INC HL | |||||||
| 8BFB | LD (HL),D | |||||||
| DRAW_FOOD_1 | 8BFC | POP HL | ||||||
| 8BFD | LD (ROAST_SPRITE),HL | |||||||
| DRAW_FOOD_2 | 8C00 | POP DE | ||||||
| 8C01 | LD A,E | |||||||
| 8C02 | LD ($C543),A | GFX_B4+1: the whole roast's height byte | ||||||
| 8C05 | LD A,D | |||||||
| 8C06 | LD ($C48D),A | GFX_B5+1: the bones' height byte | ||||||
| 8C09 | POP IX | |||||||
| 8C0B | LD A,($5E28) | |||||||
| 8C0E | LD ($5E29),A | |||||||
| 8C11 | RET | |||||||
| DRAW_FOOD_3 | 8C12 | LD A,C | ||||||
| 8C13 | LD ($C543),A | GFX_B4+1: the whole roast's height byte | ||||||
| 8C16 | LD A,$13 | |||||||
| 8C18 | LD (IX+$00),A | |||||||
| 8C1B | LD HL,$77C8 | |||||||
| 8C1E | LD ($8C30),HL | FOOD_RECORD+3: where the roast is drawn | ||||||
| 8C21 | CALL DRAW_RECORD | |||||||
| 8C24 | LD B,$06 | |||||||
| DRAW_FOOD_4 | 8C26 | LD (HL),$00 | ||||||
| 8C28 | INC L | |||||||
| 8C29 | DJNZ DRAW_FOOD_4 | |||||||
| 8C2B | JR DRAW_FOOD_2 | |||||||
| Prev: 8B85 | Up: Map | Next: 8C2D |