Prev: 35973 Up: Map Next: 36859
36457: GameEntry
Main game entry point. Initialises the stack, runs the title and options screens, then enters the per-frame main loop. The loop calls every major subsystem once per frame and repeats indefinitely.
Input
Used by the routines at 43610 and 44815.
36457 LD SP,65530 stack at $FFFA (top of game RAM, below extra data)
36460 CALL 33600 ResetScriptPtr: seed ROM-traversal script pointer
36463 CALL 42581 DrawIntroScreen: animated Alien title screen
36466 CALL 42821 DrawShipMap: ship layout / room-selection screen
36469 CALL 43610 OptionsScreen: difficulty selection (keys 1-4)
36472 CALL 44561 ScreenTransition: wipe to black, set white attributes
36475 CALL 45401 InitCrewPositions: sort crew records by pixel Y
36478 CALL 31417 InitGameView: draw initial corridor view
Main per-frame loop body. Re-entered every frame via JR back to here.
36481 CALL 34684 HandleInput: scan keyboard, dispatch crew movement
36484 CALL 40319 FrameTiming: ~1/50s frame wait or play queued sound
36487 CALL 40826 UpdateAlien: alien movement & crew-attack logic
36490 CALL 41264 TriggerAlienEvent: poll alien event timer
36493 CALL 37018 UpdateCrewAI: give first idle crew member a new action
36496 CALL 37363 TickMessageQueue: tick the queued per-crew animation slots
36499 CALL 36859 UpdateJones: walk Jones the cat one room when due
36502 CALL 35973 ResetCrewTimers / corridor pass 1
36505 CALL 34967 AnimateCrewA: XOR-blit crew sprite set A (10-frame)
36508 CALL 35016 AnimateCrewB: XOR-blit cursor / sprite set B (5-frame)
36511 CALL 44880 PlayMusic: emit one beeper note from current phrase
36514 CALL 34967 AnimateCrewA: second blit erases via XOR (double-buf)
36517 CALL 35016 AnimateCrewB: second blit erases via XOR
36520 CALL 37363 TickMessageQueue: second animation-tick pass
36523 CALL 38379 UpdateRoomActors: corridor advance / room actor logic
36526 CALL 44313 DrawStatusPanel: refresh crew-alive portrait column
36529 LD BC,63486 BC = port 63486 ($F7FE): keyboard half-row 1-5
36532 IN A,(C) read key row (active-low: 0 = key pressed)
36534 BIT 0,A test key 1 (pause / restart)
36536 CALL Z,44815 key 1 down → open PauseMenu
36539 CALL 33589 AdvanceScriptPtr: consume next ROM script nibble
36542 CP 0 nibble 0 = no-op
36544 CALL Z,33589 skip a second nibble
36547 CP 0
36549 CALL Z,33600 two consecutive 0s → ResetScriptPtr (reseed from SEED)
36552 JR 36481 tail-loop back to the start of the per-frame body
36554 LD A,(IX+3)
36557 CP 4
36559 JR NZ,36574
36561 CALL 36717
36564 LD (IX+3),1
36568 LD (IX+0),20
36572 XOR A
36573 RET
36574 CP 3
36576 RET NC
36577 JR 36611
This entry point is used by the routine at 35973.
36579 LD A,(33700)
36582 AND A
36583 CPL
36584 RET Z
36585 XOR A
36586 CP (IX+3)
36589 RET Z
36590 LD A,(33703)
36593 LD HL,33700
36596 CP (HL)
36597 JR Z,36554
36599 XOR A
36600 CP (IX+6)
36603 JR Z,36664
36605 LD A,(IX+3)
36608 CP 3
36610 RET NC
36611 LD A,(IX+2)
36614 LD HL,29575
36617 LD DE,8
36620 LD BC,1792
36623 CP (HL)
36624 JR NZ,36627
36626 INC C
36627 ADD HL,DE
36628 DJNZ 36623
36630 LD A,(IX+2)
36633 BIT 6,A
36635 JR Z,36650
36637 LD A,(IX+6)
36640 CP 2
36642 JR C,36664
36644 LD A,C
36645 AND A
36646 JR NZ,36657
36648 CPL
36649 RET
36650 LD A,C
36651 CP 3
36653 JR NC,36657
36655 CPL
36656 RET
36657 LD A,32
36659 CALL 35814
36662 XOR A
36663 RET
36664 BIT 6,(IX+1)
36668 JR Z,36684
36670 LD A,(IX+3)
36673 CP 1
36675 RET NZ
36676 CALL 36150
36679 CALL 35560
36682 XOR A
36683 RET
36684 LD HL,29940
36687 LD A,(33700)
36690 ADD A,128
36692 LD E,A
36693 ADD A,32
36695 LD D,A
36696 LD C,(IX+1)
36699 LD B,22
36701 LD A,(HL)
36702 CP E
36703 JR Z,36708
36705 CP D
36706 JR NZ,36709
36708 LD (HL),C
36709 INC HL
36710 DJNZ 36701
36712 CALL 36717
36715 JR 36611
This entry point is used by the routines at 37018, 37490, 38379 and 40826. PickNextRoom: choose the destination room for the actor whose record IX points at, and store it in record byte +2. The actor's current room is byte +1; bit 6 of +1 selects which network it is travelling in.
36717 LD A,(IX+1) A = actor's current room (bit 6 = duct network)
36720 LD HL,29171 assume corridor adjacency map (RoomAdjCorridors)
36723 BIT 6,A travelling in the ducts?
36725 JR Z,36732 no: keep corridor map
36727 LD HL,29346 yes: use duct map (RoomAdjDucts)
36730 AND 63 strip the network flag -> room ID 0-33
36732 LD E,A
36733 LD D,0
36735 LD B,5
36737 ADD HL,DE
36738 DJNZ 36737 HL = map + room*5 (the room's 5 direction slots)
36740 PUSH HL
36741 CALL 33589 AdvanceScriptPtr: next ROM script nibble
36744 CALL 36763 ScriptNibbleToDirection: nibble -> slot 0-4
36747 LD E,A
36748 POP HL
36749 ADD HL,DE
36750 LD A,(HL) A = destination room for that direction
36751 BIT 6,(IX+1) moving through the ducts?
36755 JR Z,36759
36757 OR 64 yes: tag the destination with the duct flag
36759 LD (IX+2),A record +2 = destination room
36762 RET
ScriptNibbleToDirection Maps a 4-bit ROM-script command (in A, from 33589 AdvanceScriptPtr) to one of 5 direction-class codes: 0-2 → 0 (no direction), 3-5 → 1, 6-8 → 2, 9-11 → 3, 12-15 → 4. Used to translate the deterministic ROM-byte stream into AI movement decisions. Used by the routines at 36859 (UpdateJones), 37018 (UpdateCrewAI) and 38379 (UpdateRoomActors).
36763 CP 3 nibble 0..2?
36765 JR NC,36769
36767 XOR A → direction 0
36768 RET
36769 CP 6 nibble 3..5?
36771 JR NC,36776
36773 LD A,1 → direction 1
36775 RET
36776 CP 9 nibble 6..8?
36778 JR NC,36783
36780 LD A,2 → direction 2
36782 RET
36783 CP 12 nibble 9..11?
36785 JR NC,36790
36787 LD A,3 → direction 3
36789 RET
36790 LD A,4 default (12..15) → direction 4
36792 RET
This entry point is used by the routines at 35451, 35973 and 45290.
36793 LD HL,65535
36796 LD (31250),HL
36799 CALL 32536
36802 LD A,(31242)
36805 LD HL,29567
36808 CP (HL)
36809 JR Z,36830
36811 CALL 39695
36814 LD A,(33704)
36817 AND A
36818 RET Z
36819 LD HL,(33701)
36822 INC HL
36823 LD A,(31242)
36826 CP (HL)
36827 JP 45080
36830 JP 45019
This entry point is used by the routine at 44880.
36833 LD HL,32896
36836 LD (31263),HL
36839 LD A,4
36841 LD (31243),A
This entry point is used by the routine at 44880.
36844 LD A,52
36846 LD (29643),A
36849 LD HL,18646
36852 LD (31257),HL
36855 CALL 31634
36858 RET
Prev: 35973 Up: Map Next: 36859