![]() |
How the game is put together |
Alien 8 is Knight Lore's engine carrying a new game, a year after Knight Lore and a year before Pentagram. Much is Knight Lore's, sometimes to the instruction: the main loop, the object record, the exits, the special objects that became the valves, the menu and the tune player. Much of the rest was reworked here -- the drawing, the depth sort's code, the collision code, the room builder, the control reader -- and those are the parts Pentagram took over nearly unchanged. What is Alien 8's alone is the game: the valves and the chambers, the clock, the remote-controlled robots, the turning robot, the scenes after a game. This page is the map of the whole: where things are, what runs when, and which parts come from where. Knight Lore's own page describes the engine as it was.
The tape's one block of code and data loads at $62FD and runs to the very top of memory; the loader enters it three bytes in, at $6300. Below it, over the system variables and the BASIC loader, the game keeps its variables and its object records, cleared before use. The block holds the level data and the sprites first, then the code, then -- in the part of it that is space, not game -- the screen buffer every picture is drawn into, the stack, and tables built at the start; the tape carries the mastering machine's leftovers there. The ROM is never called, since the game reads the keyboard and makes its sounds itself (its bytes are read only as noise), and interrupts are never enabled: there is no EI in the game, and the pause is a busy wait.
| Addresses | What |
|---|---|
| $5B00-$5B87 | the variables, over the printer buffer and the system variables; Knight Lore's layout, 160 bytes lower, as far as $5B33 |
| $5B88-$6287 | 56 object records of 32 bytes: the robot's legs and top, two for what lies in the room from the places, and 52 for the room |
| $6300-$6307 | the entry: DI, the stack at $F100, and a jump to START |
| $6308-$645F | the font: digits and capitals |
| $6460-$73C7 | the three room sizes, then the room directory: 128 rooms on a 16 by 16 grid |
| $73C8-$76E2 | the object templates and their table, the backgrounds and theirs (BACKGROUND_TABLE) |
| $76E3-$7826 | the 36 places a valve or an extra life lies |
| $7827-$792E | the graphic table: a word per graphic number, the sprite it draws |
| $792F-$A630 | the sprites, end to end |
| $A631-$D1EA | the code, with its tables among it -- the update-routine table (UPDATES), the notes and tunes, the texts, the start records (START_LEGS) |
| $D1EB-$D1FF | Knight Lore's copyright line, unused |
| $D200-$E9FF | the screen buffer, bottom row first, every picture drawn in it before it is copied to the screen |
| $EA00-$F0FF | the stack, down from $F100 |
| $F100-$FFFF | tables built before the menu (BUILD_LOOKUP_TBLS): bits reversed, and each byte shifted by one to seven bits |
AFTER_GAME is four loops, one inside another. A game: the variables and records cleared, the drawing tables built, five lives and 6000 light years, the menu (MENU), the start tune, the start records filled with one of four start rooms (NEW_GAME_START), the valves and extra lives dealt to their places (INIT_SPECIAL_OBJECTS), and every room's colour put back (RESET_ROOM_COLOURS). A life: NEW_LIFE copies the start records over the robot's two and takes a life, and with none left it is the game over (GAME_ENDED). A room: ENTER_ROOM files the valves of the room he left back in their places, builds the room into the object records (BUILD_ROOM), brings in what lies there from the places (FIND_SPECIAL_OBJS_HERE), puts him in the doorway he came by (ADJUST_PLYR_UVZ_FOR_ROOM_SIZE), and sets the drop latch in an even-numbered room. A turn: every one of the 56 records has its update routine run, and at the end of the turn (OBJECT_DONE) the turn is counted, what changed is listed and drawn in depth order (LIST_DRAWN, RENDER_DYNAMIC_OBJECTS), the turn is padded out, the clock runs (RUN_CLOCK), and the pause key is read.
Walking through a doorway jumps straight back to the room loop, dropping two return addresses from the stack by hand, after copying the robot into the start records ($C3B7), so a life starts where he last came in. A death is noticed at the end of a turn, when both of his records have emptied at the end of the sparkle, and goes back to the life loop. The game ends three ways -- the last life, the clock, the twenty-fourth chamber -- all at GAME_ENDED, which shows the summary and then sets GAME_OVER and runs the scene after the game in the same main loop, with no clock and no controls, until one of the scene's own routines goes back to the menu.
An object record's first byte is its graphic number, and that number is both what is drawn (through the graphic table, GRAPHICS) and what runs: UPDATES has a word per graphic, the routine the main loop jumps to with IX on the record and the address of OBJECT_DONE on the stack. So an object animates, or changes its behaviour, by changing its own first byte: a valve becomes a seated valve four graphics on, the robot's legs become the in-between views as he turns and graphic 48, the sparkle, as he dies, and anything gone becomes graphic 1, which the drawing code empties. The table, read from the snapshot, routine by routine (131 words, graphics 0 to 130; graphic 131 has a sprite but no routine, since only the panel draws it):
| Routine | Graphics |
|---|---|
| NO_UPDATE | 0-1, 4-10, 84 |
| LEAPER | 130 |
| SCENE_ROBOT_TOP | 93 |
| OILED_ROBOT | 92 |
| FRAGILE | 129 |
| REMOTE_ROBOT | 124-127 |
| REMOTE_PAD | 128 |
| REMOTE_BUTTON | 122-123 |
| SLOW_CHASER | 120-121 |
| CLOCKWORK_MOUSE | 116-119 |
| SCENE_TOOL | 81-83 |
| SCENE_SPARKS | 80 |
| COLOUR_SCENE_OBJECT | 85, 88-91 |
| CEILING_DROP | 73 |
| WANTED_VALVE | 104-107 |
| SOCKET_SPARKLE | 108-111 |
| SEATED_VALVE | 100-103 |
| SOCKET | 112-115 |
| CRYONAUT | 74 |
| LOOSE_VALVE | 96-99 |
| LOWER_HALF | 11 |
| WANDERER | 94-95 |
| PACER | 86-87 |
| SPARK_CHASER | 76-79 |
| SHUTTLE_V | 67 |
| SHUTTLE_U | 66 |
| CONVEYOR_PLUS_V | 68 |
| CONVEYOR_PLUS_U | 69 |
| CONVEYOR_MINUS_V | 70 |
| CONVEYOR_MINUS_U | 71 |
| COLLAPSING_BLOCK | 45 |
| STILL_DEADLY | 72, 75 |
| SPIKES | 46 |
| DROPPING_BLOCK | 44 |
| PUSHABLE | 28 |
| PUSHABLE_INVERTED | 29 |
| LIFT | 47 |
| BOBBER | 31 |
| SPARKLE_STEP | 48-54, 64 |
| SPARKLE_END_PLACE | 65 |
| SPARKLE_END | 55 |
| PLAYER_APPEARING | 56-62 |
| PLAYER_APPEARED | 63 |
| EXTRA_LIFE | 12 |
| DRAW_AT_L16_D9 | 30 |
| DRAW_AT_L12_D7 | 13 |
| DRAW_AT_L8_D5 | 15 |
| DRAW_AT_L4_D3 | 14 |
| SECOND_PILLAR | 3 |
| FIRST_PILLAR | 2 |
| PLAYER_LEGS | 16-23 |
| TURNING_LEGS | 24-27 |
| TOP_FOLLOWS_LEGS | 32-43 |
Most routines start by setting their own drawing nudge and end by moving through the collision code and, if anything moved, marking the object and what it overlaps to be drawn again (SET_WIPE_AND_DRAW_FLAGS). Scenery that never changes has NO_UPDATE, a RET.
Every turn visits all 56 records, empty or not, and then OBJECT_DONE waits six units of about 20,000 T-states less the drawing the turn has done, so a quiet room does not run faster than a moderately busy one; a room with six units of drawing or more runs as fast as it can. Even an empty room, with the robot standing still, does five units of drawing a turn, so the wait is rarely more than one unit. Watched in the emulator, standing still for 50 turns: 85 frames in an empty room, 95 in the start room $13. The clock counts turns, so it slows with the game.
SEED starts as the ROM's frame counter when the game is first run, has the last game's turn count added at every new game and one added every time round the menu's loop; it picks the start room, and with the refresh register the first kind of valve dealt. RANDOM is stirred with the refresh register after every object's turn and with the turn counter and a byte of the ROM at the end of every turn (OBJECT_DONE), so how long each update took feeds the next number. It decides where the extra lives go, when a thing drops from the ceiling or a leaper jumps, and which way a mouse turns.
| Part | Whose |
|---|---|
| The main loop, the variables, the 32-byte object record, the update table | Knight Lore's; 56 records where Knight Lore has 40, and the stack reset above the screen buffer for every object |
| The exits: the room number moved by 1 or 16, the doorway's pillars, where he comes in | Knight Lore's, nearly to the instruction; the walk into a room one turn longer |
| The robot's jumping, falling, walking and the exit test in his move | Knight Lore's; his turning is Alien 8's own (below) |
| The places: dealt at a new game, brought into a room, written back | Knight Lore's special objects, with four kinds of valve, and the extra lives dealt by a count of their own |
| The menu with directional control, the text printer, the border, the rating | Knight Lore's |
| The tune player and its notes; most sound effects | Knight Lore's, the notes to the byte (its sounds) |
| Movers: shuttling blocks, dropping and collapsing blocks, pushables, the thing that drops from the ceiling | Knight Lore's update routines with Alien 8's graphic numbers |
| Drawing: projection, sprites turned in place, masking through the shift tables, wiping only what moved | Knight Lore's reworked, and carried on into Pentagram instruction for instruction (Pentagram's drawing) |
| The depth sort | Knight Lore's 27-case table (depth sorting), in the code Pentagram kept; Knight Lore's destruction of a thing that shares space, kept for the valves (a bug) |
| Collision: Z, then U, then V, a unit at a time, harm passed both ways | Knight Lore's (collision), with a lander's Z step passed to what it lands on, which carries the robot on conveyors and lifts -- as Pentagram does later |
| The room builder | the code Pentagram's builder is, with its placement nudge live (Pentagram's never runs) |
| Reading the controls | much as Pentagram's reader, over Knight Lore's keyboard routine |
| The turning robot: an in-between view for two turns | Alien 8's own (how the robot moves) |
| Valves, sockets, the 24 chambers, the summary's counts, the arrival | Alien 8's own (the chambers) |
| The light-years clock, the remote-controlled robots, the fragile things, the leapers, the mice, the two-part creatures, conveyors and lifts | Alien 8's own (the station) |
| The scenes after a game: the robot re-programmed, or oiled | Alien 8's own |
Knight Lore's 40 records became 56 and the code that walks them followed: the list of what to draw holds all of them, which Pentagram, with 54, later got wrong. The fullest room fills 49 of the 52 room records. There is no day and night, no transformation and no cauldron; the clock is the time limit instead, and the chambers the goal.