1986 · Activision

Alter Ego

This minisite was contributed by air, 64kramsystem. It’s agent-generated and needs a human editor. Clone https://github.com/gamesexplained/gamesexplained and follow kit/START.md to curate games/c64/alter-ego with me to Gold.

A whole life, from the womb to old age, told one scene at a time. Twenty-five answers set a personality before birth, every scene reads and changes it, and the bigger a scene is on the disk, the more of the life it uses up.

01 · The game

A life on a map of pictures

Alter Ego plays out one person's life in seven phases: Infancy, Childhood, Adolescence, Young Adulthood, Adulthood, Middle Adulthood and Old Age. A new game asks for a name and then for a personality, answered as twenty-five statements, TRUE or FALSE, or left to the computer. A life can begin in any of the seven phases.

Each phase is a map. Its rows are the years, and each row holds pictures joined by lines: a heart, a pair of people, a book, a body. Choosing a picture plays its scenes: a page of text, then often a question with a few answers to pick with the arrow. What the player answers changes the personality, the money and what comes next, and every scene moves the years on. A phase ends when its years run out or every picture has been played, and the next phase begins.

A brown panel on a blue screen: Welcome to Adolescence, with a quotation from Jonathan Swift, and CONTINUE at its foot
Each phase opens with a page of its own.
The map of Adolescence: white framed pictures on blue joined by lines, a column of pictures down each side and the arrow below them
Adolescence's map. The pictures down the middle are its scenes; the columns at each side are its choices.

The Play tab is the whole game, written again in JavaScript. The Stages tab draws every phase's map whole, and Graphics has the arrow and the bar of sprites that brings each page on.

02 · Personality

An answer moves a trait part of the way to 100 or to 0

Before birth, the game sets twelve traits to 50 and then applies each answer in turn. An answer can set a trait outright, move it a share of the way still left to 100, or take a share of what it has. Each share is rounded down before the next answer is applied, so the same answers always give the same person. Pick a statement and answer it.

What this answer does

Each answer is a record of up to eight changes, in one table for TRUE ($94AE) and one for FALSE ($971F), which the scoring routine applies in order (ScorePersonalityQuestionnaire, $8E29). The game's own routine gives the same twelve scores as this page for sixty sets of answers, among them every single answer turned over. The statements are the game's own words.

The two tables never move Intelligence, Physical or Vocational: those three start every life at 50. Statement 22, "My parents were extremely strict disciplinarians", answered TRUE is the only answer that sets a thirteenth number, one the scenes read later. Left to chance, each answer is one bit of the sound chip's noise (the SID's third voice, read at $D41B), so the computer is as likely to answer TRUE as FALSE.

03 · The map

Each picture on the map is a block of scenes on the disk

A phase's map is three 16-bit words to a row, each word a place on the map. Its low byte is the number of a scene block, its next four bits the picture, and its top four bits the lines out of it. The arrow moves over the three places of a row and over the two columns of choices beside the map, and fire plays what is under it (play_life_stage, $84DC). A place that has been played loses its picture and keeps its lines. The Stages tab draws all seven maps and decodes any word on them.

The eight choices are words too. A choice of type 1 shows the age in years and months, type 5 the whole status, and the others play the next of the choice's own scenes. The function keys pick a choice: f1, f3, f5 and f7 the left column's from the top down, and f2, f4, f6 and f8 the right column's, as they sit on the C64's keyboard.

A scene block ends by telling the map what to do next (play_life_map_cell, $8A85):

The block ends withWhat follows
255, 254 or $FFFFthe picture is crossed off the map
251the scene does not count: every number it changed is put back
252the choice plays its next scene
$FFFDthree lines saying the experience is inappropriate for you at this time
250the phase is over
253the life is over

A scene that may not count is possible because the game copies all its shared numbers to $8145 before every block and copies them back on 251.

A phase also ends when the age passes the phase's last year or when no picture is left. The block behind the phase's choice of type 5 then plays as its closing scene, and the menu that ends every phase asks whether to go on, save or quit (finish_life_stage, $8CFF).

04 · Time

A scene's size on the disk is the time it takes

Each block's length in bytes is in the phase's header, so that the game can find the block in the file. The same length moves the years on: the game multiplies it by a rate in the header and adds the result to the age, as a fraction of a year (advance_age_and_finances, $91CD). A choice's scene counts a third of its length. The later phases have higher rates, so the same scene takes a few weeks of Infancy and several months of Middle Adulthood. Pick a phase and a block.

The rate is the third word of the phase's header ($803F, read by load_stage_header). The time added is (length × rate + 512) ÷ 1,024, in 65,536ths of a year, kept at $7FC4; each whole year carried out of it adds one to the age at $7F74. The lengths are the phases' own, from the headers on the disks.

The same fraction pays the wages. A job's salary is multiplied by the time the scene took, less a tax, and without a job the cost of living is taken instead. The cash and the debt are kept as thousands and units in two words each, worked out in 32 bits and divided back by 1,000.

05 · Scenes

Every scene reads and changes one table of numbers about the player

The whole of a life is 64 numbers of 16 bits at $7F40, which the game calls on in every scene and saves to the disk. The first twelve are the traits the questionnaire set. The others hold the job, the age, the money and what has happened in the life.

NumberAddressWhat it holds
0 to 11$7F40the twelve traits, 0 to 100, from Calmness to Vocational
12$7F58the job, 0 for none
26$7F74the age in years
27 and 28$7F76the cash, units and thousands
33 and 34$7F82the debt, units and thousands
36$7F88a possession about to be bought
37$7F8Athe salary
49$7FA2set by statement 22, strict parents

A scene is a chain of descriptors, and each descriptor is played in the same order (interpret_interaction_descriptor, $9BF9). First come its conditions: five bytes each, a number's index and the lowest and highest value it may have. A descriptor whose conditions fail is not played: the chain goes on to the descriptor its second byte names, and when the first of a block fails, the game says instead that the experience is inappropriate for you at this time. Then come its changes to the numbers, four bytes each, then the answers the player may pick, then the text. Some changes are left to chance, by the same sound-chip noise as the questionnaire's, and the answer picked decides which descriptor plays next. The Play tab runs these descriptors as the game does.

06 · Text

Scene text is packed with a dictionary that grows as it is read

The scenes' text is packed with LZW, a method that replaces each repeated run of letters with a number for an earlier run. The game reads the numbers eight at a time, each group nine or ten bytes long, so that each number is nine or ten bits. The first 256 numbers are single bytes. Each number read adds a new run to the dictionary, up to 1,024 runs. Only the first two numbers of a scene are nine bits wide: as soon as the first new run is added the numbers become ten bits wide, and the game starts a fresh group of ten bytes and throws away the six unused numbers of the first one.

Scene 26 of Infancy's fileSize
numbers read4,130
packed bytes read5,169
bytes of text and descriptors made7,872
descriptors39
dictionary, prefixes and last bytes3,072

A decoder written apart from the game's reads scene 26 of MAP1 to the same 7,872 bytes and the same dictionary as the game's own (decompress_grouped_lzw_slice, $A4F7; the prefixes from $B57B, the last bytes from $BD7B). The game decodes only the descriptor it needs, into $C2A2 (load_local_map_chunk, $9A14).

07 · The end

After Old Age a new life begins

A life ends in one of two ways: a scene that ends with 253, or the end of Old Age. Either way the game moves on to the phase after the seventh, which is Infancy again. The new life keeps the twelve traits and the name and clears almost everything else. Discoveries has the end of a life played out on the original program, and what the next one inherits.

08 · The program

Most of Alter Ego is written for a machine that is not a 6502

Most of the game was compiled for a stack machine of 16-bit numbers, which the C64 does not have. A small 6502 program, the interpreter at $7033-$7926, plays that machine's part: it reads each one-byte instruction and jumps to its handler through two tables of 256 addresses ($7927 and $7A27). The instructions work on two registers, a first value and a second, and on a stack of locals and arguments. There are 90 of these procedures in the three loads, and the slow work is left to 6502 code: drawing, the disk, the text decoder and 32-bit arithmetic.

The procedure below is the game's pause, called each time the arrow moves in a menu and after a choice is made: it counts to its argument divided by 16 and does nothing else (delay_scaled_iterations, $545B). Step through its 18 instructions.

first value0
second value0
argument n0
local i0
instructions0

The bytes are the game's, from $5460 to $5478. In C the procedure would read: n = n / 16; for (i = 0; i < n; i++);. Each turn of the loop costs eight instructions, and the instruction after the store ($546E) makes the value of i++ the old i again, a value the game never uses.

09 · Saving

A saved life is 380 bytes

The game keeps five lives on the disk, in the files AES0 to AES4, and a directory of them in AESD: five lines of 32 bytes, each the name and the age. One routine reads and writes a save (transfer_save_slot_state, $4E0F), handed either the read or the write as an argument, so the two can never disagree about the order:

BytesFromWhat
128$7F40the 64 numbers about the player
48$81C5the phase's eight choices
180$81F7the phase's map, with what has been played crossed off
16$82CBthe name
2$82BDthe phase
2$82ABthe possessions, one bit each
4$7FC0which scenes of the lifelong choices have been played, one bit each

The months since the last birthday, kept at $7FC4 just after them, are not saved, so a resumed life starts again at its birthday (Discoveries).