Prev: 41572 Up: Map Next: 42501
42276: LongGameInit
Game-mode handler for "2: Long Game" (dispatched from 43135).
Input
The Long Game is the full-length scenario. All 7 crew start alive but
ONE of them is selected (via the ROM-traversal script, see 33589
AdvanceScriptPtr) to be the **chestburster host** — the crew member
the alien physically hatches out of. That slot is marked by stamping
the HostMarker pattern ($FF on bytes +1 and +7 of its 8-byte record)
so per-frame routines like 31721 (SelectSlotByDrawIdx) can skip it
with a `CP 255` test on byte +1. The host's name is also baked into
the opening status-bar message #33 enqueued at step 7 below.
The script independently chooses the alien's initial stalk target, so each Long Game has both a different host AND a different first victim. The android-traitor mechanic lives on the OTHER randomised slot picked below: AlienTargetID (LongGameTargetTable values {1, 2, 4, 6} = Dallas / Kane / Ash / Parker). That slot is dormant at game start — it appears as just another crew member. UpdateAlien (40826) flips it hostile on the **first encounter** with the alien: the first frame AlienActiveFlag is non-zero AND the slot still carries the template's zero values in bytes +0 and +7, UpdateAlien stamps it into action state 7 (attack) and arms it with sprite-class kin as targets. From then on the Android wounds nearby crew via CrewAction7_Handler (40757), named in status-bar dialogue (msg #30 "{Android} is attacking {target}"). When other crew fight it in combat state 4, CrewHitsAndroid (40941, msg #32 "{actor} hits the Android") logs the response. The alien itself kills crew that share its room via CrewHitsAlien (37584) and the kill primitive at 37733 — independent of this Android subplot. Steps: 1. Point the message queue head (MsgQueueWritePtr 33741) at the queue base MessageQueue (33714) and clear the two run-state bytes 33708/33709. 2. CALL 45222: reseed the script pointer from the ZX SEED system variable and reset the message-dup marker (MsgLastEnqueued 33743) to $FFFF. 3. LDIR 64 bytes from 41444 (LongGameCrewInit) into $7376 to populate the alien slot and the seven crew slots with the long-game starting state (all crew alive, normal alien position). 4. Pull one script nibble, look it up in 41374 (LongGameHostSlotTable) to get the host slot index A_host (one of {1, 2, 5}), then stamp the HostMarker on that record by overwriting bytes +1 and +7 with $FF. 5. Loop pulling more script nibbles, looking them up in 41390 (LongGameTargetTable), until the looked-up value A_target differs from A_host — the Android can't be the same slot the alien just hatched out of. 6. Store A_target in 33703 (AlienTargetID) — this slot is the per-run **Android**: a dormant traitor crew member that UpdateAlien (40826) flips hostile on first encounter with the loose alien. 7. Enqueue message #33 ("Alien has hatched from {actor}") via 37176, with the host slot index as the actor parameter — this is the long game's opening narrative beat. 8. Store &slot[A_target] in 33701 (AlienTargetPtr) so UpdateAlien and CrewHitsAndroid can access the Android's crew record directly. 9. Fall through into the common init at 42380 (CommonGameInit). Used by the dispatcher at 43134 via the table at 43135.
42276 LD HL,33714 HL = MessageQueue (event queue base)
42279 LD (33741),HL event queue head = queue base (empty queue)
42282 XOR A A = 0
42283 LD (33709),A clear run-state byte 33709
42286 LD (33708),A clear run-state byte 33708
42289 CALL 45222 reset message-dup marker + reseed script pointer
42292 LD HL,41444 HL = LongGameCrewInit ($A1E4)
42295 LD DE,29566 DE = $7376 (alien slot + crew table base)
42298 LD BC,64 64 bytes = 8 × 8-byte records
42301 LDIR copy long-game starting crew/alien state
42303 CALL 33589 A = script nibble (0-15)
42306 LD E,A
42307 LD D,0
42309 LD HL,41374 HL = LongGameHostSlotTable ($A19E)
42312 ADD HL,DE
42313 LD A,(HL) A_host = chestburster-host slot index for this run
42314 PUSH AF stash A_host
42315 ADD A,A
42316 ADD A,A
42317 ADD A,A A_host × 8 (record stride)
42318 LD E,A
42319 LD HL,29566
42322 ADD HL,DE HL = &slot[A_host]
42323 INC HL HL = &slot[A_host] + 1 (crew ID byte)
42324 LD A,(HL)
42325 LD (29623),A save original ID at $73E7 (never read; effectively scratch)
42328 LD (HL),255 stamp HostMarker: slot[A_host].byte+1 = $FF
42330 LD DE,6
42333 ADD HL,DE HL = &slot[A_host] + 7 (alive flag)
42334 LD (HL),255 stamp HostMarker: slot[A_host].byte+7 = $FF
42336 CALL 33589 A = next script nibble
42339 LD HL,41390 HL = LongGameTargetTable ($A1AE)
42342 LD E,A
42343 LD D,0
42345 ADD HL,DE
42346 LD C,(HL) C = candidate alien-target index
42347 POP AF A = A_host
42348 CP C
42349 JR NZ,42354 if C != A_host → accept
42351 PUSH AF
42352 JR 42336 else: pull another nibble (avoid colliding with host)
42354 LD HL,33703 HL = &AlienTargetID
42357 LD (HL),C AlienTargetID = C (randomised)
42358 PUSH BC
42359 LD L,A L = A_host (actor param for message)
42360 LD A,33 A = 33 → message "Alien has hatched from {actor}"
42362 CALL 37176 enqueue opening narrative naming the host
42365 POP BC
42366 LD A,C A = AlienTargetID
42367 ADD A,A
42368 ADD A,A
42369 ADD A,A A × 8
42370 LD E,A
42371 LD D,0
42373 LD HL,29566
42376 ADD HL,DE HL = &slot[AlienTargetID]
42377 LD (33701),HL store alien-target record pointer at AlienTargetPtr
This entry point is used by the routine at 44561. CommonGameInit: shared post-init for both Short and Long modes. Called (via JP) from 44767 (ShortGameInit) and fallen into from 42276 (LongGameInit). Resets the alien runtime state, seeds the crew workspace tables, clears the corridor cursor at $757C, picks the initial alien event timer from the script, and switches the room mode to 1 (corridor view) so the player drops straight into gameplay.
42380 XOR A
42381 LD (33704),A
42384 LD HL,32896 HL = $8080: two "frozen" bytes for both channels
42387 LD (31263),HL
42390 LD A,L
42391 LD (39741),A
42394 LD (39753),A
42397 LD HL,41406 HL = InitialItemRooms ($A1BE)
42400 LD DE,29940 DE = ItemLocations ($74B4)
42403 LD BC,22
42406 LDIR place the 22 items in their start rooms
42408 LD B,33 RoomGrilleState: put all grilles in place
42410 LD HL,30076 (33 bytes; room 33's byte stays 0 = open)
42413 LD A,255
42415 LD (HL),A
42416 INC HL
42417 DJNZ 42415
42419 LD E,13 ...except Corridor#6 (room 13):
42421 LD D,0 its grille starts removed
42423 LD HL,30076
42426 ADD HL,DE
42427 LD (HL),D
42428 LD HL,31253
42431 LD (HL),D
42432 CALL 33589
42435 LD (33706),A
42438 CALL 33589
42441 LD E,A
42442 LD D,0
42444 LD HL,41358 HL = AlienInitTable ($A18E)
42447 ADD HL,DE
42448 LD A,(HL) A = AlienInitTable[script_byte]
42449 OR 64 set direction bit (bit 6)
42451 LD (29567),A set the alien's starting room (slot 0 byte +1)
42454 LD HL,41428 HL = ItemChargesInit ($A1D4)
42457 LD DE,33746
42460 LD BC,16
42463 LDIR
42465 LD HL,30006
42468 LD (HL),48
42470 LD DE,30007
42473 LD BC,67
42476 LDIR
42478 LD HL,12336
42481 LD (38376),HL
42484 LD HL,13623
42487 LD (38374),HL
42490 LD A,32
42492 LD (38373),A
42495 LD A,1
42497 LD (31243),A
42500 RET
Prev: 41572 Up: Map Next: 42501