Prev: ABF5 Up: Map Next: AD13
AC6B: Count the chambers and the cryonauts for the summary
Used by the routine at GAME_ENDED.
Called by GAME_ENDED at the end of a game, after the valves in the room have been written back to their places (UPDATE_SPECIAL_OBJS). Walks the room directory (ROOM02). A room is a chamber if the first object groups after its backgrounds are the frozen crew, object templates 21 and 22 (graphic 74) -- exactly the 24 rooms with a socket. A chamber with a seated valve lying in it (graphics 100-103, looked for in the places, PLACES) counts in SUMMARY_ACTIVE; any other in SUMMARY_IDLE, and its crew -- a group's count, for each group of templates 21 and 22 in a row -- in SUMMARY_LOST. All three are BCD. The game's summary calls them the activated and unactivated cryogenic chambers and the cryonauts lost: with none activated, 24 and 132 (measured: the summary screen in the simulator, and the room data counted the same way).
A record is read as the builder reads it: the byte count at +1 bounds the walk, the backgrounds end with $FF, and a group is a header and a position for each copy.
SUMMARISE_CHAMBERS AC6B LD DE,SUMMARY_LOST the three counts to zero
AC6E LD B,$04
AC70 CALL ZERO_DE
AC73 LD HL,ROOM02 the first room
SUMMARISE_CHAMBERS_0 AC76 LD C,(HL) C = the room, B = the count of its bytes
AC77 INC HL
AC78 LD B,(HL)
SUMMARISE_CHAMBERS_1 AC79 LD A,(HL) look for the $FF after the backgrounds; the count running out first means no objects
AC7A INC HL
AC7B INC A
AC7C JR Z,SUMMARISE_CHAMBERS_3
AC7E DJNZ SUMMARISE_CHAMBERS_1
SUMMARISE_CHAMBERS_2 AC80 LD BC,OBJECT_TABLE the next room, until the end of the directory at OBJECT_TABLE
AC83 AND A
AC84 SBC HL,BC
AC86 RET NC
AC87 ADD HL,BC
AC88 JR SUMMARISE_CHAMBERS_0
SUMMARISE_CHAMBERS_3 AC8A DEC B the bytes left after the $FF
AC8B LD A,(HL) the first group crew (template 21 or 22)?
AC8C AND $F8
AC8E CP $A8
AC90 JR Z,SUMMARISE_CHAMBERS_5
AC92 CP $B0
AC94 JR Z,SUMMARISE_CHAMBERS_5
SUMMARISE_CHAMBERS_4 AC96 LD A,B no: skip the rest of the record
AC97 CALL ADD_HL_A
AC9A JR SUMMARISE_CHAMBERS_2
SUMMARISE_CHAMBERS_5 AC9C LD IY,PLACES a chamber: look for a place in this room
SUMMARISE_CHAMBERS_6 ACA0 LD A,(IY+$08) in this room?
ACA3 CP C
ACA4 JR Z,SUMMARISE_CHAMBERS_8
SUMMARISE_CHAMBERS_7 ACA6 LD DE,$0009 nine bytes on, to the end of the places at GRAPHICS
ACA9 ADD IY,DE
ACAB PUSH HL
ACAC PUSH IY
ACAE POP HL
ACAF LD DE,GRAPHICS
ACB2 AND A
ACB3 SBC HL,DE
ACB5 PUSH HL
ACB6 POP IY
ACB8 POP HL
ACB9 JR NC,SUMMARISE_CHAMBERS_9
ACBB LD DE,GRAPHICS
ACBE ADD IY,DE
ACC0 JR SUMMARISE_CHAMBERS_6
SUMMARISE_CHAMBERS_8 ACC2 LD A,(IY+$00) a seated valve? If not, look on
ACC5 SUB $64
ACC7 CP $04
ACC9 JR NC,SUMMARISE_CHAMBERS_7
ACCB LD A,(SUMMARY_ACTIVE) activated: count it, and on to the next room
ACCE ADD A,$01
ACD0 DAA
ACD1 LD (SUMMARY_ACTIVE),A
ACD4 JR SUMMARISE_CHAMBERS_4
SUMMARISE_CHAMBERS_9 ACD6 LD DE,SUMMARY_LOST_LOW not activated: add the group's crew to those lost
ACD9 EX DE,HL
ACDA LD A,(DE)
ACDB AND $07
ACDD INC A
ACDE ADD A,(HL)
ACDF DAA
ACE0 LD (HL),A
ACE1 DEC HL
ACE2 LD A,(HL)
ACE3 ADC A,$00
ACE5 DAA
ACE6 LD (HL),A
ACE7 EX DE,HL past the group: its header and a position a copy
ACE8 LD A,(HL)
ACE9 AND $07
ACEB ADD A,$02
ACED LD E,A
ACEE CALL ADD_HL_A
ACF1 LD A,E the record's bytes used up
ACF2 NEG
ACF4 ADD A,B
ACF5 LD B,A
ACF6 JR Z,SUMMARISE_CHAMBERS_10
ACF8 LD A,(HL) another group of crew: count it too
ACF9 AND $F8
ACFB CP $A8
ACFD JR Z,SUMMARISE_CHAMBERS_9
ACFF CP $B0
AD01 JR Z,SUMMARISE_CHAMBERS_9
AD03 LD A,B skip the rest of the record
AD04 CALL ADD_HL_A
SUMMARISE_CHAMBERS_10 AD07 LD A,(SUMMARY_IDLE) count the chamber not activated
AD0A ADD A,$01
AD0C DAA
AD0D LD (SUMMARY_IDLE),A
AD10 JP SUMMARISE_CHAMBERS_2
Prev: ABF5 Up: Map Next: AD13