Prev: 41572 Up: Map Next: 42501
42276: LongGameInit
Game-mode handler for "2: Long Game" (dispatched from 43135).
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 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 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.
UpdateAndroid 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, UpdateAndroid 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, named in status-bar dialogue (msg #30 "{Android} is attacking {target}"). When other crew fight it in combat state 4, CrewHitsAndroid (msg #32 "{actor} hits the Android") logs the response. The alien itself kills crew that share its room via CrewHitsAlien and the kill primitive at 37733 — independent of this Android subplot.
Steps:
  • 1. Point the message queue head (MsgQueueWritePtr) at the queue base MessageQueue and clear the two run-state bytes 33708/33709.
  • 2. CALL 45222: reseed the script pointer from the ZX FRAMES system variable and reset the message-dup marker (MsgLastEnqueued) to $FFFF.
  • 3. LDIR 64 bytes from LongGameCrewInit into $737E 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 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. The host's vacated room is first copied into Brett's room byte (slot 7 +1, $73B7): Brett, whom LongGameCrewInit leaves in room 0, takes the host's seat so both dinner-scene groups stay at three crew.
  • 5. Loop pulling more script nibbles, looking them up in 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 AlienTargetID — this slot is the per-run ANDROID: a dormant traitor crew member that UpdateAndroid flips hostile once the crew has wounded the alien 6+ times (TriggerAlienEvent).
  • 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 AlienTargetPtr so UpdateAndroid and CrewHitsAndroid can access the Android's crew record directly.
  • 9. Fall through into the common init at 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 = $737E (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 index the host-slot table by the nibble
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 base of ActorRecords
42322 ADD HL,DE HL = &slot[A_host]
42323 INC HL HL = &slot[A_host] + 1 (crew ID byte)
42324 LD A,(HL) A = the host's starting room (byte +1)
42325 LD (29623),A Brett (slot 7, init room 0) inherits the host's seat, keeping both dinner groups at three
42328 LD (HL),255 stamp HostMarker: slot[A_host].byte+1 = $FF
42330 LD DE,6 step from +1 to +7
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 same slot as the host?
42349 JR NZ,42354 if C != A_host → accept
42351 PUSH AF re-stash A_host and retry
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 save C = the Android's slot
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 base of ActorRecords
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 44738. CommonGameInit: shared post-init for both Short and Long modes. Called (via JP) from ShortGameInit_Done (the tail of ShortGameInit) and fallen into from LongGameInit. Resets the alien runtime state, seeds the crew workspace tables, re-arms the duct grilles at $757C (RoomGrilleState), rolls Jones's start room and the alien's lair from the script, and switches the room mode to 1 (corridor view) so the player drops straight into gameplay.
42380 XOR A AlienActiveFlag = 0: the Android starts dormant
42381 LD (33704),A
42384 LD HL,32896 HL = $8080: two "frozen" bytes for both channels
42387 LD (31263),HL freeze both map-marker animation channels
42390 LD A,L A = $80
42391 LD (39741),A freeze the alien-body encounter layer...
42394 LD (39753),A ...and the Jones run layer
42397 LD HL,41406 HL = InitialItemRooms ($A1BE)
42400 LD DE,29940 DE = ItemLocations ($74F4)
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 ShipSystemFlags = 0: destruct off, airlocks
42431 LD (HL),D sealed, no fires
42432 CALL 33589 Jones starts in a random
42435 LD (33706),A room 0-15 (script nibble)
42438 CALL 33589 the alien's lair is drawn from
42441 LD E,A a 16-entry room table...
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 ...hidden in the ducts above it (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 per-item charge counters for items 0-15
42460 LD BC,16
42463 LDIR load the initial charges
42465 LD HL,30006 RoomDamageDigits: set every room's 2-digit
42468 LD (HL),48 meter to ASCII '00' — prime the first '0'
42470 LD DE,30007 and LDIR it across
42473 LD BC,67 the other 67 bytes (34 rooms x 2 digits)
42476 LDIR
42478 LD HL,12336 HL = $3030 = '00': the oxygen meter's low digit pair
42481 LD (38376),HL
42484 LD HL,13623 high pair = '7','5': oxygen starts at 7500
42487 LD (38374),HL
42490 LD A,32 leading character = space
42492 LD (38373),A
42495 LD A,1 RoomTypeByte = 1: open on the deck-1 view
42497 LD (31243),A
42500 RET
Prev: 41572 Up: Map Next: 42501