1985 · Activision

Little Computer People

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

A man and his dog live in a house that is a single picture loaded with the program. He runs on 128 small state machines, reads what you type through 156 words and 34 rules, adds up your manners, and keeps a clock of his own. What the manual never told you is on Discoveries.

01 · The house

One picture, loaded whole

The house is a multicolour bitmap that arrives with the program: 8,000 bytes of pixels at $6000, 1,000 colour pairs at $5C00, and 1,000 colours for colour RAM. A file cannot load colour RAM, so the crack copies them in from $CC00 before the game starts. The game never draws the house. It redraws only the spots that change.

Drawn by this page from the three blocks of the snapshot. Moving parts are the cells the game redraws in place, each by its own routine. Objects are the 16 doors, drawers and props that have frames of their own, drawn by $96ED from the tables at $97F0. Places are the 54 fixed spots the figures walk to, from $1D36, $1D6D and $1DA4.

02 · The cast

183 images, packed three bytes at a time

Every image that moves is unpacked when it is needed from $E5C1–$FFB9. A count byte either copies that many literal rows of three bytes or repeats one row that many times. The 183 images take 6,649 bytes instead of 11,529. The small objects shrink most, some to 8 bytes; a body pose takes about 44.

Every image, and the man and the dog moving through the house on the game’s own code, are on the Graphics tab.

The person on screen is four hardware sprites: his body, his head, and a black outline behind each. The dog is two and anything he carries is one. The main loop shares the eight sprites out once a pass, nearest figure first ($0FD2), and writes them at raster line $FA. There is no raster multiplexing.

His head comes in three sets of fifteen images, one set for each mood ($0D65): happy, content and sad.

His face in the three moods

The three moods, with the mood byte $035F set to 0, 1 and 2.

03 · Talking to him

156 words, 34 rules and a score for manners

Every word he knows carries five bytes of concept bits, and words with the same bits are synonyms. As you type, the bits of each word are added to the sentence, and after every word the game tries its 34 rules in order. A rule fires when all of its bits are there. Then the sentence gets a score, and the score decides whether he does it.

A copy of the parser at $C040: words are split at anything that is not a letter, looked up in list 1 ($C234, verbs, feelings and manners) and then list 2 ($C5E0, things, rooms and games), and tested against the rules at $C96A after every word ($C1C5). The score adds 3, 1 or 0 for his mood and 0 to 3 at random.

At 8 or more the main loop empties the queue of waiting requests and he does this one at once; at 12 or more he turns to face you first (activity 46). Below 8 the request waits in a 16-entry queue at $E12A: from 4 to 7 the activity chooser takes it later, and below 4 it stays there until a request that scores 8 or more empties the queue. With his mood set to sad, "light a fire" scores 4 and is still waiting 25 seconds later, and "please light a fire" scores 8 and starts at once.

All 34 rules

Struck-out words can never be found: WHAT'S because the apostrophe splits it, and the second entries of START, LIKE, APATHETIC and IS because the lookup stops at the first. A rule that needs one of them can never fire.

04 · His day

128 activities and a chooser

Everything he does is an activity: a small state machine whose phase picks a handler from a table. The table sits in the code right after the call that uses it, as a list of handler addresses minus one. The call does not come back: the routine pushes the chosen address and returns to that instead ($3F0C). There are 103 of these tables. The activity number lives in $8D9B and is dispatched through a table of 128 at $8DC9.

Nine minutes left alone, with the activity number sampled four times a second. Activity 0, the chooser, appears only for a moment between the others.

When an activity ends, the chooser ($E13F) decides what comes next, in this order: a request from a CTRL key, a typed request, food and water, bed, the activities fixed to the time of day, the morning and evening lists, and then a random pick from lists that depend on the time of day, the weekday and his routine setting.

The house clock

Every 256 frames a counter steps down from 9, and at 0 the house clock ticks ($09EB): 2,304 frames. Twelve ticks make an hour, so a day in the house is 12 × 24 × 2,304 frames. One tick is 45,287,427 cycles, exactly 2,304 PAL frames or 45.97 seconds, which makes his day 3 hours 41 minutes long. The time you type at the start sets only the wall clock in the study.

Food, water and illness

Hunger and thirst each rise from 0 to 3 on their own timers, every 20 ticks and every 15. A need that rises from 2 makes him ill: his skin turns green (sprite multicolour $D026 = 5). The illness gets a level worse every twelve ticks and ends once both needs are below 3 ($392F). He looks after his needs before anything else, so with food and water in the house he eats, drinks and recovers. With the cupboard and the tank empty, the illness rises one level each house hour, and at level 3 he goes to bed.

Ill and in bed

Ill, in bed on the middle floor: the green is his skin colour.

On the phone in the easy chair

Answering the phone, which also rings by itself every 32 to 63 ticks.

05 · The keys

Eight CTRL keys

The game reads the keyboard matrix itself, from the main loop, not the interrupt ($05C7): a key has to stay down until a pass of the loop comes round. CTRL with a letter gives its control code, and $2B54 turns each code into a delivery, a ring or a request.

KeyThe manualThe codeIn play
CTRL Ffood at the front dooractivity 44 fills the kitchen cupboard ($3028); ignored while the cupboard is full ($30B4 = $0F)nothing at first; activity 44 at once with the cupboard part empty
CTRL Wfills the water tankone line a press, up to 11 of the tank's 12 ($2B51)5 to 11, then no further
CTRL Arings the alarm clockthe bell rings ($2B4E); ignored while a record playsbell and sound; he carries on
CTRL Ddog foodactivity 33 fetches it, 34 fills the bowl33 at once
CTRL Cthe phone ringsactivity 25: he sits in the easy chair and talks25 at once
CTRL Ppetting, in the easy chairat the chair, the arm pats him and his mood becomes happy ($2C39); elsewhere activity 6 walks him there6 at once
CTRL Ra recordactivity 50 takes it to the stereo50 at once
CTRL Ba bookactivity 51 takes it to the study51 at once

06 · Letters

Two letters, chosen by the cupboard and the tank

Ask him to write and he goes to the typewriter in the attic and types a letter into the band above the roof. There are two bodies. The thank-you comes only while there is both food in the cupboard and water in the tank ($55C4); otherwise he writes the complaint. Both are signed "Your Friend".

The thank-you letter

"Thank you for keeping me well stocked with food and water."

The complaint letter

"Please notice that my supplies are running low. I can't stay happy and healthy without your support."

The letter is put together at $7F40, which is the record player's work area. The complaint is 158 characters long and writes over the copy of the SID registers the player keeps at $7FCD. It does no harm, because he switches the record off before he starts to type.

07 · The music

Music: four piano pieces, and a record played upside down

Two sound drivers share the SID. One plays the records on the attic stereo, clocked by a CIA timer. The other plays the piano and all the effects, ticked by the raster interrupt. Both drivers' note tables are exact for an NTSC machine, so on PAL everything plays about two-thirds of a semitone flat.

The piano and effects driver ($B000–$B63F, and its interpreter in the RAM under the I/O chips, $D000–$D586), ported to JavaScript and played through the site's model of the SID. Each sound starts as the game starts it. A piece is installed as sound 12 (activity 78, $AB1A) and started on the driver's second set of channels ($364A); when the piece raises its end flag ($B012), sound $10 silences it ($36B4). The model runs a PAL machine's clock at 50 frames a second, so the pieces play at a PAL C64's speed and pitch, two-thirds of a semitone below the NTSC tuning of the note table.

Talking is twelve calls of sound $15, each started the way the mouth routine's request starts it (slot 18, $35E4). A call picks its syllable and its phrase with the driver's own random byte ($B0D3), which the driver stirs every frame from three counters ($B52A). The port does the same from the driver's state in the listing's snapshot, so each call is the one the game would play on that frame. The ten frames between calls are a stand-in: in the game, the next call comes when his mouth next opens wide. The driver never reads the SID's noise or envelope output. Its one read of the chip is LDA $D7AC at $B4FB, a write-only register, and there the port takes 0, the value the reSID emulator gives once the chip's data bus has faded.

The pieces never route a voice through the filter. Each piece's start loads filter preset 0 ($B6A1: no voice routed, volume 15), and no piece loads another, so the player shows a note in place of the Filter switch. The talking uses it all the time. Each syllable is noise on voices 1 and 2 through a band-pass filter at resonance 15, with one of four cutoffs, $40, $60, $80 or $A0 in $D416 (presets at $B6CD–$B6DC, loaded by command $0D). The phrase on voice 1 then loads a preset of its own, band-pass on voices 1 and 2 or low-pass on voice 1 alone, and moves the cutoff every frame (commands $1D, $18 and $19): in the twelve calls here it runs from 0 to 1,952 of 2,047. The Filter switch plays the sounds three ways, and changes them while they play. Off leaves the filter out. 6581 is the original C64's chip, on the cutoff curve the reSID emulator (version 0.16) measured from one such chip. 8580 is the chip of later C64s. Real 6581s differ from one another in where each setting puts the cutoff, and they distort, which this model does not (site/lib/sid.js).

The piano pieces are Mozart's Sonata in C, K. 545, Beethoven's Für Elise, the fugue in C minor from the first book of Bach's Well-Tempered Clavier, and a fourth piece that has not been identified. Activity 78 picks one at random, and while he plays, the game builds his image from three part images chosen by which keys the driver is holding down ($1585).

The record tunes

The record player's driver is not ported. These are recordings of the SID's registers, one frame at a time for 20 seconds, with each tune forced where the game picks it at random ($AB14). Played back here with plain waveforms and no envelopes; the timing is the machine's own.

Record tune 2 is tune 0 upside down

The steps between the first notes of the melody, in semitones, as the SID played them: record tune 0 in the upper row and tune 2 in the lower, up for a step up. Every step of tune 2 is the step of tune 0 with its sign turned over, and in tune 2 all three voices play that melody in octaves.

The squawks

Whenever his mouth opens wide, the mouth routine ($24C8) asks for sound $15, Talking in the player above. Each call starts with a random syllable of noise through one of four band-pass filters and goes on with a random phrase of gliding notes. During one phone call that happened 24 times.

08 · Where it lives

From the jump table to the vectors

WhereWhat
$0340–$08D2jump table, settings, cold start, time prompt, keyboard, raster interrupt
$0931–$13EEmain loop, house clock, illness, figure sprites
$16AE–$3F3Awalking and the dog, activities, house events, sound requests, typing, record tunes, the switch
$3F3B–$46BCthe record player's driver
$5000–$5BF7font, eating, letters, the computer
$6000–$7F3Fthe house picture
$8020–$8D98the four piano pieces
$8D99–$AFFBactivity dispatch, activities, house objects and their frames
$B000–$BFFCthe piano and effects driver, text output, request scan
$C000–$CB8Athe parser, its words and rules
$CC00–$CFE7the house's colour RAM
$D000–$DD8Ethe effects driver's interpreter and data, in the RAM under the I/O chips
$E000–$E452dancing, the chooser, the piano
$E453–$FFB9the 183 packed images