Prev: AF3F Up: Map Next: B055
AF79: A valve (graphics 96 to 99), and activating a chamber
Reached through UPDATES. A valve falls under gravity, can be pushed, and is the one thing that can be picked up and carried (TAKE_OR_LEAVE), and makes a sound pitched by its position each turn it moves. In a chamber whose socket is of its kind (the socket's graphic less 16) it also steers itself, a unit a turn in U and V, towards the socket; when it sits exactly on it -- the same U and V, and 12 above the socket's base -- it activates the chamber.
Activating: the valve becomes a seated one (graphic 4 more, SEATED_VALVE); the screen's inks run through all eight colours twice, with a sparkle's sound; the room's ink becomes white for the rest of the game (through ROOM_COLOUR_AT) and the screen and panel are recoloured (COLOUR_PANEL); CHAMBERS goes up by one, and the twenty-fourth sets WON and ends the game (GAME_ENDED). Otherwise the new count is printed and copied to the screen.
The second test of the kinds, after the valve is found sitting on the socket, can never fail: the valve would have steered only to a socket of its kind. Had it failed, the valve would have become graphic 64, the dying sparkle, and been lost (SPARKLE_STEP). Nothing reaches it (read; never run).
LOOSE_VALVE AF79 CALL DRAW_AT_L12_D5 draw 12 left and 5 down
AF7C LD HL,$0470 find the room's socket, graphics 112 to 115
AF7F CALL FIND_GRAPHIC_HERE
AF82 JR NC,LOOSE_VALVE_2
AF84 LD A,(IY+$00) not of this valve's kind: only a valve
AF87 AND $03
AF89 LD C,A
AF8A LD A,(IX+$00)
AF8D AND $03
AF8F CP C
AF90 JR NZ,LOOSE_VALVE_2
AF92 LD A,(IX+$01) a step of one in U towards the socket
AF95 SUB (IY+$01)
AF98 JR Z,LOOSE_VALVE_0
AF9A LD A,$01
AF9C JP M,LOOSE_VALVE_0
AF9F NEG
LOOSE_VALVE_0 AFA1 LD (IX+$09),A
AFA4 LD A,(IX+$02) and in V
AFA7 SUB (IY+$02)
AFAA JR Z,LOOSE_VALVE_1
AFAC LD A,$01
AFAE JP M,LOOSE_VALVE_1
AFB1 NEG
LOOSE_VALVE_1 AFB3 LD (IX+$0A),A
AFB6 LD A,(IX+$01) not over it yet
AFB9 CP (IY+$01)
AFBC JR NZ,LOOSE_VALVE_2
AFBE LD A,(IX+$02)
AFC1 CP (IY+$02)
AFC4 JR NZ,LOOSE_VALVE_2
AFC6 LD A,(IY+$03) sitting on it: activate
AFC9 ADD A,$0C
AFCB CP (IX+$03)
AFCE JR Z,LOOSE_VALVE_4
LOOSE_VALVE_2 AFD0 CALL DEC_DZ_AND_UPDATE_UVZ fall, and move
AFD3 BIT 0,(IX+$0D) just put down: its sound
AFD7 JR NZ,LOOSE_VALVE_3
AFD9 CALL IS_OBJ_MOVING not moving: done
AFDC RET Z
LOOSE_VALVE_3 AFDD RES 0,(IX+$0D) no step left in U or V; a sound pitched by where it is; redraw
AFE1 CALL CLEAR_DUV
AFE4 JP SOUND_AND_DRAW
LOOSE_VALVE_4 AFE7 LD A,(IX+$00) the kinds again
AFEA XOR (IY+$00)
AFED AND $03
AFEF JR Z,LOOSE_VALVE_5
AFF1 LD (IX+$00),$40 never: the sparkle, and the valve lost
AFF5 JP SET_WIPE_AND_DRAW_FLAGS
LOOSE_VALVE_5 AFF8 LD A,(IX+$00) seated: graphic 100-103
AFFB OR $04
AFFD LD (IX+$00),A
B000 CALL SOUND_AND_DRAW a sound; redraw
B003 LD D,$10 sixteen times
LOOSE_VALVE_6 B005 LD HL,$5800 every attribute's ink one on
B008 LD BC,$0300
LOOSE_VALVE_7 B00B LD A,(HL)
B00C AND $F8
B00E LD E,A
B00F LD A,(HL)
B010 INC A
B011 AND $07
B013 OR E
B014 LD (HL),A
B015 INC HL
B016 DEC BC
B017 LD A,B
B018 OR C
B019 JR NZ,LOOSE_VALVE_7
B01B CALL SPARKLE_SOUND a sparkle's sound
B01E LD BC,$0200 and a pause
LOOSE_VALVE_8 B021 DEC BC
B022 LD A,B
B023 OR C
B024 JR NZ,LOOSE_VALVE_8
B026 DEC D sixteen times: the inks back where they were
B027 JR NZ,LOOSE_VALVE_6
B029 LD HL,(ROOM_COLOUR_AT) the room's ink white, in its record and for now
B02C LD A,(HL)
B02D OR $07
B02F LD (HL),A
B030 AND $07
B032 LD (ROOM_INK),A
B035 CALL COLOUR_PANEL recolour the screen and the panel
B038 LD HL,CHAMBERS one more chamber
B03B LD A,(HL)
B03C ADD A,$01
B03E DAA
B03F LD (HL),A
B040 CP $24 not the twenty-fourth
B042 JR NZ,LOOSE_VALVE_9
B044 LD A,$01 won: the end
B046 LD (WON),A
B049 JP GAME_ENDED
LOOSE_VALVE_9 B04C CALL PRINT_CHAMBERS print the count
B04F LD BC,$1820 and copy its 16 by 8 pixels to the screen
B052 JP BLIT_2X8
Prev: AF3F Up: Map Next: B055