Prev: 37363 Up: Map Next: 38379
37490: Routine at 37490
37490 XOR H
37491 ADD A,E
37492 RET
This entry point is used by the routine at 35578. StartAttack — action on the " ATTACK " row: queue the combat job — action state 4 (CrewAction4_Handler -> CrewHitsAlien / CrewHitsAndroid) with base countdown 40, replacing any pending action. Then put the special row back to what the room warrants (49 "RmveGrille" or blank, via the grille-state refresh at $B0B8) and move the cursor on.
37493 LD A,40 base countdown 40
37495 CALL 35814 arm it (SetActionTimer)
37498 LD (IX+3),4 action state = 4 (combat)
37502 LD A,255 (dead: A is overwritten inside the call)
37504 CALL 45240 cell 13 = 49 or blank per RoomGrilleState
37507 LD HL,18646 and redraw the special row
37510 LD (31257),HL
37513 CALL 31634
37516 CALL 34743 advance the cursor off the row
37519 RET
CrewAction4_Handler — dispatched via CrewActionDispatch entry 4 (combat). Branches a combat-state actor into one of two parallel handlers based on whose sprite-class byte (+1) matches the actor's: 1. If the actor's (IX+1) matches the alien slot's identity at $737F → CALL 37584 (CrewHitsAlien) — message #3 "nets the ALIEN" or #4 "hits the ALIEN". 2. Else, if AlienActiveFlag is non-zero AND the actor's (IX+1) matches the alien-target slot's (IX+1) — i.e. the **Android** slot picked by LongGameInit (42276) via LongGameTargetTable (41390) and pointed to by AlienTargetPtr (33701) — → CALL 40941 (CrewHitsAndroid) — message #31 "nets {target}" or #32 "hits the Android". The Android role: LongGameInit randomly picks one of crew slots {1, 2, 4, 6} (Dallas / Kane / Ash / Parker) and stores it in AlienTargetID (33703). That crew member is dormant at first — they appear and behave like a normal crew member. UpdateAlien (40826) turns them hostile the first frame the alien is loose and the slot is still in its template state (the "first encounter"), stamping them into action state 7 and giving them their sprite-class kin as targets via NearestCrewA/B (see 37876). After activation the Android wounds nearby crew through CrewAction7_Handler (40757); CrewHitsAndroid here is the **player-response branch**, dispatched when other crew engage the Android in combat state 4. CAVEAT: the (IX+1) byte is NOT a unique slot ID in the LongGameCrewInit template (41444) — slots 1/2/3 share +1=6, slots 4/5/6 share +1=27. So branch 2's match fires for the whole **sprite class** of the Android, not strictly the chosen slot: - AlienTargetID ∈ {1, 2}: matches {Dallas, Kane, Ripley} - AlienTargetID ∈ {4, 6}: matches {Ash, Lambert, Parker} Whether that ambiguity is intentional design or a missing per-slot ID write is unresolved — verify on an emulator before extending. The short game hard-wires AlienTargetID = 9 (out of range), so branch 2 never fires there. After dispatch, CALL 44924 clears IX+3 (action state) and returns.
37520 LD A,(29567) A = the alien's current room (slot 0 byte +1)
37523 CP (IX+1) current actor IS the alien slot?
37526 JR Z,37547 yes → CrewHitsAlien branch
37528 LD A,(33704) A = AlienActiveFlag
37531 AND A alien loose on ship?
37532 RET Z no: nothing to dispatch
37533 LD HL,(33701) HL = pointer to alien-target crew record
37536 INC HL HL → target's identity byte (+1)
37537 LD A,(HL) A = target's identity
37538 CP (IX+1) current actor IS the alien's target (= the Android)?
37541 RET NZ no: not in combat with either alien or android
37542 CALL 40941 yes → CrewHitsAndroid (msg #32 / #31)
37545 JR 37550
37547 CALL 37584 alien slot → CrewHitsAlien (msg #4 / #3)
37550 CALL 44924 reset IX+3 = 0 (action state cleared post-combat)
37553 NOP
37554 RET
37555 LD A,(31252)
37558 CP 1
37560 RET NZ
37561 LD A,(31241)
37564 LD HL,33700
37567 CP (HL)
37568 RET NZ
37569 LD A,52
37571 CALL 45269
37574 LD HL,18646
37577 LD (31257),HL
37580 CALL 31634
37583 RET
CrewHitsAlien — alien-side combat handler. Called from CrewAction4_Handler (37547) when the actor in state 4 has (IX+1) matching $737F (the alien's identity from CommonGameInit, 42451). The outcome depends on the WEAPON: FindHeldItems (31823) loads the attacking crew member's front-hand item id into HeldItemFront (31248) and the effect dispatches on it. It also houses the Harpoon Gun's kill primitive at 37733. Guards: re-asserts that (IX+1) matches the alien identity, then requires pixel coords IX+4 >= 2 and IX+6 >= 2 (sprite fully placed). Calls 44986 to clear the held-item slots, then FindHeldItems (31823) to fetch the attacker's weapons: 17 (Cat Box) → silent: JP to ClearActionState >= 20 (bare hands) → silent 16 (Net) → "net" outcome: write $FF to $7376 (slot 0 byte +0) to disable the alien, then enqueue message #3 "{actor} nets the ALIEN" else → "hit" outcome at 37646: enqueue message #4 "{actor} hits the ALIEN", then dispatch on the weapon id: - 0-5 Elctrc Prd/Incineratr, 18-19 Spanner: INC alien's wound counter at $73B2 (byte +4 of slot 0). If it reaches the AlienStopCell threshold, JP 44125 (alien- defeated path). - 6-7 Tracker: enqueue msg #5 "Tracker is broken" - 8-11 Fire Extng: decrement the item's charge in ItemCharges; on underflow enqueue msg #6 "extinguisher empty". - 12 Harpn Gun: the kill primitive at 37733 — see AlienKillPrimitive below. - 13-15 Laser Pist: JP 37831 — decrement the charge, then either msg #7 "Laser is exhausted" or JP 41022. This routine parallels 40941 (CrewHitsAndroid) in structure but refers to the alien (slot 0 at $7376) and emits messages #3 / #4 instead of #31 / #32.
37584 LD A,(29567) A = the alien's current room (slot 0 byte +1)
37587 CP (IX+1) re-check: IX is the alien slot
37590 RET NZ defensive: not the alien → bail
37591 LD A,(IX+4) A = pixel X-tile
37594 CP 2
37596 RET C X-tile < 2 → alien not fully on screen, bail
37597 LD A,(IX+6) A = pixel Y
37600 CP 2
37602 RET C Y < 2 → bail
37603 CALL 44986 clear (31248) scan slot, A = CrewIndex
37606 CALL 31823 populate (31248)/(31249) with corridor positions
37609 LD A,(31248) A = alien's corridor scan position
37612 CP 17
37614 JP Z,37555 pos 17 → silent
37617 CP 20
37619 JP NC,37555 pos >= 20 → silent (sentinel cells)
37622 CP 16
37624 JR NZ,37646 pos != 16 → "hits the ALIEN" branch
37626 LD HL,29566 HL = $7376 (alien slot byte 0)
37629 LD (HL),255 mark alien slot as "netted/inactive"
37631 CALL 37924
37634 LD A,(33700) A = CrewIndex (= alien-slot index)
37637 LD L,A L = actor index
37638 LD A,3 A = msg #3 "{actor} nets the ALIEN"
37640 CALL 37176 enqueue
37643 JP 37555
"{actor} hits the ALIEN" branch (CrewHitsAlien continued).
37646 PUSH AF stash (31248) for post-message dispatch
37647 LD A,(33700) A = CrewIndex
37650 LD L,A L = actor index
37651 LD A,4 A = msg #4 "{actor} hits the ALIEN"
37653 CALL 37176 enqueue
37656 POP AF A = (31248) restored
37657 CP 6
37659 JR C,37669
37661 CP 18
37663 JR Z,37669
37665 CP 19
37667 JR NZ,37683
37669 LD HL,29570
37672 INC (HL)
37673 LD A,(33745)
37676 CP (HL)
37677 JP Z,44125
37680 JP 37992
37683 CP 8
37685 JR NC,37700
37687 CALL 37924
37690 LD HL,(33700)
37693 LD A,5
37695 CALL 37176
37698 JR 37669
37700 CP 12
37702 JR NC,37730
37704 LD HL,33746
37707 LD E,A
37708 LD D,0
37710 ADD HL,DE
37711 LD A,(HL)
37712 AND A
37713 JR Z,37719
37715 DEC (HL)
37716 JP 37992
37719 LD HL,(33700)
37722 LD A,6
37724 CALL 37176
37727 JP 37555
AlienKillPrimitive — the Harpoon Gun outcome, reached from CrewHitsAlien (37584) when the attacker's front-hand item (31248) is 12, the Harpn Gun. A harpoon strike is devastating for both sides: 37876 gathers up to three slots (NearestCrewC + NearestCrewA/B) sharing the alien's sprite class; for each, every ItemLocations (29940) entry that the slot carries or that lies in the alien's room is destroyed (set to 255), and if the slot's byte +7 is still zero (alive) it is stamped to 1 (killed) with its byte +4 wound counter cleared. Then the alien's own wound counter is bumped by 5 (harpoon hits push it quickly over the AlienStopCell threshold → dies via JP 44125), the corridor view is rebuilt (CALL 31417) and the per-frame chain continues at AlienScareCheck (37992).
37730 JP NZ,37831 (31248) != 12 → 37831 (decrement ItemCharges)
37733 CALL 37876 populate NearestCrewC + NearestCrewA/B with the three slots sharing the alien's sprite class
37736 LD DE,33695
37739 LD B,3
37741 PUSH BC
37742 PUSH DE
37743 LD A,(DE)
37744 CP 255
37746 JR Z,37801
37748 PUSH AF
37749 ADD A,128 E = victim's back-hand marker
37751 LD E,A
37752 ADD A,32 D = victim's front-hand marker
37754 LD D,A
37755 LD C,(IX+1) C = the alien's room
37758 LD HL,29940 destroy every item the victim holds
37761 LD B,22 or that lies in the alien's room:
37763 LD A,(HL)
37764 CP E
37765 JR Z,37773
37767 CP D
37768 JR Z,37773
37770 CP C
37771 JR NZ,37775
37773 LD (HL),255 ItemLocations entry -> gone
37775 INC HL
37776 DJNZ 37763
37778 POP AF
37779 LD HL,29566
37782 ADD A,A
37783 ADD A,A
37784 ADD A,A
37785 ADD A,7
37787 LD E,A
37788 LD D,0
37790 ADD HL,DE
37791 XOR A
37792 CP (HL)
37793 JR NZ,37801
37795 LD (HL),1
37797 DEC HL
37798 DEC HL
37799 DEC HL
37800 LD (HL),A
37801 POP DE
37802 INC DE
37803 POP BC
37804 DJNZ 37741
37806 LD A,15
37808 CALL 38182
37811 LD HL,29570
37814 LD A,(HL)
37815 ADD A,5
37817 LD (HL),A
37818 LD HL,33745
37821 CP (HL)
37822 JP NC,44125
37825 CALL 31417
37828 JP 37992
37831 LD E,A
37832 LD D,0
37834 LD HL,33746
37837 ADD HL,DE
37838 XOR A
37839 CP (HL)
37840 JR Z,37865
37842 DEC (HL)
37843 LD A,6
37845 CALL 38182
37848 LD HL,29570
37851 LD A,(HL)
37852 ADD A,2
37854 LD (HL),A
37855 LD HL,33745
37858 CP (HL)
37859 JP NC,44125
37862 JP 37992
37865 LD HL,(33700)
37868 LD A,7
37870 CALL 37176
37873 JP 37555
This entry point is used by the routines at 40439 and 40826.
37876 LD HL,65535
37879 LD (33696),HL
37882 LD DE,33696
37885 LD A,(33700)
37888 LD (33695),A
This entry point is used by the routine at 38379.
37891 LD HL,29575
37894 LD C,1
37896 EX AF,AF'
37897 LD A,(IX+1)
37900 LD B,7
37902 CP (HL)
37903 JR NZ,37914
37905 EX AF,AF'
37906 CP C
37907 JR Z,37913
37909 EX DE,HL
37910 LD (HL),C
37911 EX DE,HL
37912 INC DE
37913 EX AF,AF'
37914 PUSH DE
37915 LD DE,8
37918 ADD HL,DE
37919 POP DE
37920 INC C
37921 DJNZ 37902
37923 RET
This entry point is used by the routine at 40826.
37924 LD HL,18486
37927 LD (31257),HL
37930 LD BC,(31248)
37934 LD E,C
37935 LD D,0
37937 LD HL,29940
37940 ADD HL,DE
37941 JP 44938
This entry point is used by the routine at 44880.
37944 CP B
37945 JR NZ,37954
37947 LD (29638),A
37950 CALL 44974
37953 RET
37954 LD L,B
37955 LD H,A
37956 LD (31248),HL
37959 LD A,L
37960 CALL 31857
37963 LD (29638),A
37966 CALL 31634
37969 LD A,255
37971 LD (29639),A
37974 CALL 31634
37977 LD A,(31248)
This entry point is used by the routine at 44880.
37980 LD HL,29940
37983 LD E,A
37984 LD D,0
37986 ADD HL,DE
37987 LD A,(HL)
37988 JP 45295
37991 RET
37992 CALL 37876
37995 XOR A
37996 LD (33698),A
37999 PUSH IX
38001 LD DE,33695
38004 LD B,3
38006 PUSH BC
38007 PUSH DE
38008 LD A,(DE)
38009 CP 8
38011 JR NC,38084
38013 PUSH AF
38014 LD IX,29566
38018 ADD A,A
38019 ADD A,A
38020 ADD A,A
38021 LD E,A
38022 LD D,0
38024 ADD IX,DE
38026 LD A,2
38028 CP (IX+4)
38031 JR NC,38083
38033 LD A,4
38035 CP (IX+3)
38038 JR NZ,38083
38040 LD HL,33698
38043 DEC A
38044 CP (IX+6)
38047 JR NC,38050
38049 INC (HL)
38050 POP AF
38051 CALL 31823
38054 LD HL,33698
38057 LD A,(31248)
38060 CP 13
38062 JR NC,38073
38064 CP 6
38066 JR NZ,38073
38068 CP 7
38070 JR NZ,38073
38072 INC (HL)
38073 LD A,(29570)
38076 SRA A
38078 SRA A
38080 ADD A,(HL)
38081 LD (HL),A
38082 PUSH AF
38083 POP AF
38084 POP DE
38085 INC DE
38086 POP BC
38087 DJNZ 38006
38089 CALL 33589
38092 CP 15
38094 JR Z,38177
38096 LD HL,33698
38099 CP (HL)
38100 JR NC,38177
38102 LD IX,29566
38106 CALL 36717
38109 LD A,(IX+1)
38112 CP (IX+2)
38115 JR Z,38106
38117 LD A,(33700)
38120 PUSH AF
38121 XOR A
38122 LD (33700),A
38125 CALL 36034
38128 POP AF
38129 LD (33700),A
38132 CALL 39695
38135 LD (IX+0),0
38139 LD DE,33695
38142 LD B,3
38144 PUSH BC
38145 PUSH DE
38146 LD A,(DE)
38147 CP 8
38149 JR NC,38169
38151 ADD A,A
38152 ADD A,A
38153 ADD A,A
38154 LD E,A
38155 LD D,0
38157 LD HL,29571
38160 CALL 45366
38163 CP 9
38165 JR C,38169
38167 LD (HL),8
38169 POP DE
38170 INC DE
38171 POP BC
38172 DJNZ 38144
38174 JP 45373
38177 POP IX
38179 JP 37555
This entry point is used by the routine at 37018.
38182 LD HL,29567
38185 LD E,(HL)
This entry point is used by the routines at 38379 and 40826. AddRoomDamage: add A damage points to room E's damage meter — a 2-digit ASCII pair in RoomDamageDigits (30006; tens digit is the severity the engine scan at 39041 compares against). Crossing "30" raises the room-specific alarm messages #22-#25.
38186 BIT 6,E no damage meters in the duct network
38188 RET NZ
38189 LD HL,30006 per-room ASCII damage digits (tens,units)
38192 LD D,0
38194 ADD HL,DE
38195 ADD HL,DE
38196 INC HL HL -> units digit
38197 LD B,A B = damage points to add
38198 PUSH BC
38199 PUSH HL
38200 PUSH DE
38201 LD A,(HL)
38202 CP 53
38204 JR Z,38210
38206 LD (HL),53
38208 JR 38298
38210 LD (HL),48
38212 DEC HL
38213 INC (HL)
38214 LD A,(HL)
38215 CP 51
38217 JR NZ,38281
38219 LD A,E damage tens digit reached '3': room alarms
38220 CP 6 CommdCentr?
38222 JR NZ,38228
38224 LD A,22 msg #22 "Partial loss of control systems"
38226 JR 38288
38228 CP 7 Computer room?
38230 JR NZ,38236
38232 LD A,23 msg #23 "Computer Malfunction detected"
38234 JR 38288
38236 CP 25 Life Support?
38238 JR NZ,38244
38240 LD A,24 msg #24 "Environmental irregularities"
38242 JR 38288
38244 CP 34
38246 JR NZ,38252
38248 LD A,25
38250 JR 38288
38252 CP 17
38254 JR C,38298
38256 CP 20
38258 JR NC,38298
38260 AND 3
38262 LD B,A
38263 LD A,4
38265 ADD A,A
38266 DJNZ 38265
38268 LD HL,31253
38271 OR (HL)
38272 LD (HL),A
38273 LD L,E L = room for the [251] room-name field
38274 LD A,9 msg #9 "WARNING: Fire in {room}"
38276 CALL 37176
38279 JR 38298
38281 CP 55
38283 JR NZ,38293
38285 LD L,E L = room
38286 LD A,8 msg #8 "Structural Damage in {room}"
38288 CALL 37176
38291 JR 38298
38293 CP 58
38295 CALL Z,38317
38298 POP DE
38299 POP HL
38300 POP BC
38301 DJNZ 38198
38303 LD A,(31252)
38306 CP 1
38308 RET NZ
38309 LD A,(31242)
38312 CP E
38313 CALL Z,32143
38316 RET
This entry point is used by the routine at 38379.
38317 PUSH BC
38318 PUSH AF
38319 LD B,100
38321 PUSH BC
38322 CALL 36448
38325 LD A,7
38327 CALL 42515
38330 CALL 36448
38333 LD A,56
38335 CALL 42515
38338 POP BC
38339 LD A,B
38340 AND 7
38342 OUT (254),A
38344 DJNZ 38321
38346 POP AF
38347 POP BC
38348 JP 44524
Ship-status dashboard: counters and ASCII digit cells (previously mis-disassembled as code). The digit cells double as the source text drawn on the status bar, and the endgame renderer copies them into the "The Nostromo will explode in .. minutes .. seconds" screen.
38351 DEFB 0,0,0 per-engine-room (17/18/19) fire-fighting progress, +1 per extinguisher squirt (fire handler, 38379)
38354 DEFB 50 ship-systems tick countdown (reloaded with 100 by the engine-state scan at 39041)
38355 DEFB 3 destruct-second countdown (reloaded with 20 by the ticker at 38846)
38356 DEFB 0 scratch: room of the actor under adjacency test
38357 DEFB 10 oxygen tick reload value
38358 DEFM "TIME: " status-bar label for the destruct countdown
38364 DEFB 0 minutes digit, ASCII ('5' when armed at 38454)
38365 DEFM ":"
38366 DEFB 0,0 seconds digits, ASCII ("00" when armed); the low digit also drives the border flicker while armed
38368 DEFM "TOOH: " oxygen label as stored on the tape (sic)
38374 DEFM "75" oxygen level, ASCII, counting down; msg #26
38376 DEFM "00" "Oxygen status CRITICAL" fires at "05"+"00"
38378 DEFB 0 free-running pace counter gating an event every 8 ticks (inside 38379)
Prev: 37363 Up: Map Next: 38379