Prev: 36183 Up: Map Next: 36275
36215: Draw strength bar at bottom of screen
Used by the routines at 28092 and 35993.
36215 LD A,35 Load A with index of object 35 (Mirror)
36217 CALL 34256 Check whether Magic Knight is carrying the Mirror...
36220 RET NZ ...and if not, return
36221 LD HL,20642 Point HL to position of start of health bar in display file
36224 LD A,(25315) Load A with Magic Knight's strength
36227 RRCA Divide strength by eight, rounding down to nearest integer...
36228 RRCA ...
36229 RRCA ...
36230 AND 15 ...and if lowest four bits are reset (i.e. don't need to draw part of a character block)...
36232 JR Z,36251 ...then skip ahead to 36251
36234 LD B,A Load number of full character blocks to draw into B
36235 LD A,255 Place 255 into A
36237 PUSH HL Store HL (display file position of start of health bar block)
36238 PUSH BC Store BC (B = number of full character blocks to draw)
36239 LD B,4 Load B with 4 (health bar has 4 stripes)
36241 LD (HL),A Draw a byte (i.e. a "block" of 8 health units) to health bar
36242 INC H Advance HL two rows down (as bar is made of alternating horizontal stripes)...
36243 INC H ...
36244 DJNZ 36241 And if there's another stripe of the 4 to draw, then loop back and draw it
36246 POP BC Restore BC (B = number of full character blocks to draw)
36247 POP HL Restore HL (display file position of start of health bar)
36248 INC HL Advance HL (horizontally) one character to draw next full block, if applicable
36249 DJNZ 36237 If there's another block to draw, then loop back to draw it
36251 LD A,(25315) Load A with Magic Knight's strength
36254 AND 7 Get fractional part (i.e. amount by which strength is more than a multiple of eight)
36256 JR NZ,36261 If it is not zero, then skip ahead to 36261
36258 XOR A Set A to zero
36259 JR 36267 Skip ahead to draw the blank rows (see trivia)
36261 LD B,A Load fractional part of strength into B
36262 XOR A Set A to zero
36263 SCF Set the carry flag
36264 RRA Move carry flag bit into MSB of A
36265 DJNZ 36263 Decrease B and loop back if not zero (i.e. place a bit at the LHS of A for each unit of strength that is left!)
36267 LD B,4 Load B with 4 (health bar has 4 stripes)
36269 LD (HL),A Draw a byte (i.e. a "block" of 8 health units) to health bar
36270 INC H Advance HL two rows down (as bar is made of alternating horizontal stripes)...
36271 INC H ...
36272 DJNZ 36269 Loop back to draw next row
36274 RET Return
Prev: 36183 Up: Map Next: 36275