Prev: CB22 Up: Map Next: CB65
CB40: Handler: Time
Used by the routine at B12B.
Handler_Time CB40 LD HL,$C272 HL=Time_Remaining.
Fetch the small unit of time (e.g. for "250" this is "50").
CB43 LD A,(HL) A=*HL.
Take off one unit of time (see Infinite Time).
CB44 SUB $01 A-=01 with BCD conversion.
CB46 DAA
CB47 LD (HL),A Write A to *HL.
CB48 RET NC Return if A is higher than 00.
We've ticked over the small unit, so move onto the larger unit.
CB49 INC HL Increment HL by one.
Fetch the large unit of time (e.g. for "250" this is "2").
CB4A LD A,(HL) A=*HL.
Take off one unit of time.
CB4B SUB $01 A-=01 with BCD conversion.
CB4D DAA
CB4E LD (HL),A Write A to *HL.
CB4F JR NZ,Handler_Time_Up Jump to Handler_Time_Up if A is not zero.
Flash the bonus/ time countdown when the large unit is zero.
CB51 LD HL,$583B HL=583B (attribute buffer address for the bonus/ time counter).
CB54 LD B,$04 B=04 (counter).
Handler_Time_Flash CB56 SET 7,(HL) Set bit 7 (the flash bit) of *HL.
CB58 INC L Increment L by one.
CB59 DJNZ Handler_Time_Flash Decrease counter by one and loop back to Handler_Time_Flash until counter is zero.
CB5B RET Return.
Is there any time left?
Handler_Time_Up CB5C RET NC Return if A is higher than 00 (if there is still time left).
There's no time left, signify the game is over.
CB5D POP HL Clear the stack.
CB5E POP HL
CB5F LD HL,$B008 HL=B008.
CB62 SET 2,(HL) Set bit 2 of *HL.
CB64 RET Return.
Prev: CB22 Up: Map Next: CB65