Prev: 8DAA Up: Map Next: 8E75
8DF8: Move and draw Eugene in Eugene's Lair
Used by the routine at 870E. First we move Eugene up or down, or change his direction.
8DF8 LD A,($8074) Pick up the attribute of the last item drawn from 8074
8DFB OR A Have all the items been collected?
8DFC JR Z,$8E0F Jump if so
8DFE LD A,($80DB) Pick up Eugene's direction from 80DB
8E01 OR A Is Eugene moving downwards?
8E02 JR Z,$8E0F Jump if so
8E04 LD A,($80DC) Pick up Eugene's pixel y-coordinate from 80DC
8E07 DEC A Decrement it (moving Eugene up)
8E08 JR Z,$8E1C Jump if Eugene has reached the top of the cavern
8E0A LD ($80DC),A Update Eugene's pixel y-coordinate at 80DC
8E0D JR $8E24
8E0F LD A,($80DC) Pick up Eugene's pixel y-coordinate from 80DC
8E12 INC A Increment it (moving Eugene down)
8E13 CP $58 Has Eugene reached the portal yet?
8E15 JR Z,$8E1C Jump if so
8E17 LD ($80DC),A Update Eugene's pixel y-coordinate at 80DC
8E1A JR $8E24
8E1C LD A,($80DB) Toggle Eugene's direction at 80DB
8E1F XOR $01
8E21 LD ($80DB),A
Now that Eugene's movement has been dealt with, it's time to draw him.
8E24 LD A,($80DC) Pick up Eugene's pixel y-coordinate from 80DC
8E27 AND $7F Point DE at the entry in the screen buffer address lookup table at 8300 that corresponds to Eugene's y-coordinate
8E29 RLCA
8E2A LD E,A
8E2B LD D,$83
8E2D LD A,(DE) Point HL at the address of Eugene's location in the screen buffer at 6000
8E2E OR $0F
8E30 LD L,A
8E31 INC DE
8E32 LD A,(DE)
8E33 LD H,A
8E34 LD DE,$80E0 Draw Eugene to the screen buffer at 6000
8E37 LD C,$01
8E39 CALL $8FF4
8E3C JP NZ,$8D06 Kill Willy if Eugene collided with him
8E3F LD A,($80DC) Pick up Eugene's pixel y-coordinate from 80DC
8E42 AND $78 Point HL at the address of Eugene's location in the attribute buffer at 5C00
8E44 RLCA
8E45 OR $07
8E47 SCF
8E48 RL A
8E4A LD L,A
8E4B LD A,$00
8E4D ADC A,$5C
8E4F LD H,A
8E50 LD A,($8074) Pick up the attribute of the last item drawn from 8074
8E53 OR A Set the zero flag if all the items have been collected
8E54 LD A,$07 Assume we will draw Eugene with white INK
8E56 JR NZ,$8E5F Jump if there are items remaining to be collected
8E58 LD A,($80BD) Pick up the value of the game clock at 80BD
8E5B RRCA Move bits 2-4 into bits 0-2 and clear the other bits; this value (which decreases by one on each pass through the main loop) will be Eugene's INK colour
8E5C RRCA
8E5D AND $07
This entry point is used by the routines at 8E75 (to set the attributes for a Skylab), 8EF1 (to set the attributes for a vertical guardian) and 9135 (to set the attributes for the Kong Beast).
8E5F LD (HL),A Save the INK colour in the attribute buffer temporarily
8E60 LD A,($8020) Pick up the attribute byte of the background tile for the current cavern from 8020
8E63 AND $F8 Combine its PAPER colour with the chosen INK colour
8E65 OR (HL)
8E66 LD (HL),A Set the attribute byte for the top-left cell of the sprite in the attribute buffer at 5C00
8E67 LD DE,$001F Prepare DE for addition
8E6A INC HL Set the attribute byte for the top-right cell of the sprite in the attribute buffer at 5C00
8E6B LD (HL),A
8E6C ADD HL,DE Set the attribute byte for the middle-left cell of the sprite in the attribute buffer at 5C00
8E6D LD (HL),A
8E6E INC HL Set the attribute byte for the middle-right cell of the sprite in the attribute buffer at 5C00
8E6F LD (HL),A
8E70 ADD HL,DE Set the attribute byte for the bottom-left cell of the sprite in the attribute buffer at 5C00
8E71 LD (HL),A
8E72 INC HL Set the attribute byte for the bottom-right cell of the sprite in the attribute buffer at 5C00
8E73 LD (HL),A
8E74 RET
Prev: 8DAA Up: Map Next: 8E75