Prev: D847 Up: Map Next: D88E
D865: End the game when the four villains are gone and their sparkles have left the screen
Used by the routine at NEW_GAME.
Called by the main loop every turn (NEW_GAME). Returns while any villain record is in use (a dying villain counts), or while any sparkle (SPARKLE_FLY) was drawn this turn; otherwise the game is over with the quest done, and GAME_OVER plays the ending. A sparkle off the screen is not waited for.
CHECK_QUEST_DONE D865 LD HL,VILLAINS Any of the four villain records in use? Then not yet
D868 LD DE,$0010
D86B LD B,$04
D86D XOR A
CHECK_QUEST_DONE_0 D86E OR (HL)
D86F ADD HL,DE
D870 DJNZ CHECK_QUEST_DONE_0
D872 RET NZ
D873 LD IX,FINDS Look through the four sparkle records
D877 LD B,$04
CHECK_QUEST_DONE_1 D879 LD A,(IX+$00) Is this one a sparkle, graphic 140-143?
D87C SUB $8C
D87E CP $04
D880 JR NC,CHECK_QUEST_DONE_2
D882 BIT 1,(IX+$07) Still on the screen: not yet
D886 RET NZ
CHECK_QUEST_DONE_2 D887 ADD IX,DE Next record
D889 DJNZ CHECK_QUEST_DONE_1
D88B JP GAME_OVER The villains are gone: game over, with the ending
Prev: D847 Up: Map Next: D88E