Prev: CD10 Up: Map Next: CD9E
CD58: The ending: a villain carried over the pit and sunk into it (graphics 144-151)
Each of the four waits, unseen, while the record before it holds a villain still on its way (144-151), so they go one at a time. Then it moves across, at most four a turn, to four to the right of the pit's front picture (record 9's x), and then sinks four a turn until its y is below 48, when it is gone and its record emptied. It swaps between its two frames every turn, and is drawn in its own colour -- red, magenta, green and cyan for the villains of 96, 100, 104 and 108 -- with a rising sound (ENDING_BEEP) all the while it moves.
Input
IX the record
ENDING_VILLAIN CD58 LD A,(IX+$00) the other of its two frames
CD5B XOR $01
CD5D LD (IX+$00),A
CD60 LD A,(IX-$10) the one before still on its way: wait
CD63 SUB $90
CD65 CP $08
CD67 RET C
CD68 CALL ENDING_BEEP the sound, a little higher each turn
CD6B LD A,($BD28) how far across from four right of the pit's front, at most four
CD6E ADD A,$04
CD70 CALL STEP_TOWARDS_X
CD73 AND A not there yet: across
CD74 JR Z,SINK_ENDING_VILLAIN
CD76 ADD A,(IX+$0A)
CD79 LD (IX+$0A),A
DRAW_ENDING_VILLAIN CD7C LD A,(IX+$00) its colour, $42 to $45 by bits 1-2 of the graphic, and draw it
CD7F RRCA
CD80 AND $03
CD82 ADD A,$42
CD84 LD (ENDING_COLOUR),A
CD87 JP DRAW_ENDING_PICTURE
SINK_ENDING_VILLAIN CD8A LD A,(IX+$0B) over the pit: down four, and drawn until y is below 48
CD8D SUB $04
CD8F LD (IX+$0B),A
CD92 CP $30
CD94 JR NC,DRAW_ENDING_VILLAIN
CD96 XOR A gone: the sound off, the record empty
CD97 LD (EFFECT_TIME),A
CD9A LD (IX+$00),A
CD9D RET
Prev: CD10 Up: Map Next: CD9E