Thriller · the program listingsScreen 2: the graveyard
About the listingsTitle programCard programThe woodsThe graveyardThe mansionPictures, tunes and sounds
The graveyard, the ghouls that climb out of it, the dance and the dawn. One screen, no scrolling, up to eight ghouls drawn as characters and two people drawn as players.
Never compiled. These listings were written as the design of the game, in Action!, within
what a 48K Atari 800 of 1984 could do. They have not been through the Action! cartridge or run on an Atari. What plays on
the game page is a line-for-line translation into JavaScript, made by hand, PROC for PROC. Expect small
mistakes a compiler would have caught, and note the parts marked NOT WRITTEN: loading one program from another off the disk.
THRILLER2.ACT · 1212 lines · the file itself
Its 40 PROCs and FUNCs, in the order they appear:
- Dli
- Frame
- Sfx
- Flip
- Rev2
- FlipG
- Init
- Screen
- Msg
- ShowScore
- ShowTime
- ShowGroove
- ShowAll
- Scene
- DrawG
- EraseG
- Blocked
- StepG
- Ghouls
- Spawn
- DrawHero
- Dance
- Hero
- Girl
- Push
- Bumps
- Clock
- Effect
- Music
- MusicOn
- Laugh
- NewNight
- Dusk
- Round
- Lost
- Dawn
- Next
- GameOver
- Title
- Main
1; **************************************2; * T H R I L L E R - screen 2 *3; * "Protect your girlfriend from *4; * grisly ghouls!" *5; **************************************6; Designed in 1984 by Dale Lutz, on a7; sheet of paper. Written in 2026 by8; Dale and Claude, in Action!, for a9; 48K Atari 800 and one joystick.10;11; You are the fellow in the red suit.12; Ghouls climb out of their graves and13; shamble toward your girl, who stays a14; step behind you. Walk into a ghoul to15; shove it back. Press the button to16; dance: the ghouls nearby can't help17; joining in, and a dancing ghoul that18; you touch goes back into the ground.19; Keep her safe until dawn.20;21; In this listing {inv}...{/inv} marks22; text typed in inverse video.23;24; HOW THIS PROGRAM WORKS25; The graveyard and the ghouls are26; characters, in a four-colour27; character mode: 22 rows of 40. A28; ghoul is six characters, two wide29; and three high, and moves by whole30; characters. bkg keeps a31; copy of the empty graveyard, to put32; back wherever a ghoul has been.33; He and she are players and missiles:34; small pictures laid over the screen35; that move a dot at a time. He is36; three players, one for each colour.37; She is the fourth player plus the38; four missiles. Two lines of ordinary39; text at the bottom show the score.40; Main runs one loop for each TV41; frame, a sixtieth of a second: move42; him, move her, move the ghouls,43; perhaps raise a new one, see who is44; touching whom, run the clock and45; play one step of the music.46; The night is won when the clock47; reaches dawn. A life is lost if a48; ghoul keeps hold of her too long.4950INCLUDE "D:SHAPES.ACT" ; cset,hero,girl51INCLUDE "D:MUSIC.ACT" ; bass,lead,drum52INCLUDE "D:LAUGH.ACT" ; laugh,LAUGHLEN5354; A ghoul's state is a number. 1 to 355; are climbing out of the grave and 656; to 8 are sinking back (GSINK is the57; first of those). The rest have58; names.59DEFINE MAXG="8", ; ghouls at once60 GWALK="4",GDANCE="5",GSINK="6",61 GDAZE="9",GGRAB="10", ; ghoul states62 GMAX="160", ; a full groove63 SBUMP="1",SRISE="2",SSINK="3",64 SDANCE="4" ; sound effects6566; the bytes the five programs share67; (the title program, the card68; program and the three screens).69; They are in page 6,70; which DOS leaves alone between loads.71; chain: 0 this screen was run by72; itself, 1 the title program ran it73; wins: screens won so far this game74; result: 1 the screen was won, 0 the75; game is over76BYTE chain=$6F0,wins=$6F1,lives=$6F2,77 result=$6F578CARD score=$6F379; ease: tries lost on this visit to80; the screen. Each one makes the81; next try a little easier.82BYTE ease8384; places in the Atari's own memory:85; the frame clock, the attract timer,86; the top of memory, the console87; keys, the background colour, two88; sound volume registers and the89; horizontal positions of the four90; players and four missiles91BYTE rtclok=20,atract=77,ramtop=106,92 consol=53279,colbk=712,93 audc1=$D201,audc2=$D203,94 hposp0=$D000,hposp1=$D001,95 hposp2=$D002,hposp3=$D003,96 hposm0=$D004,hposm1=$D005,97 hposm2=$D006,hposm3=$D00798; addresses: screen memory, player99; memory, our character set100CARD scrn,pmb,chb101102; him, her, and the night103; hx,hy: his place, in player dots and104; lines. hdir: 0 facing right, 1105; left. hstep: counts his steps.106; hdance: frames of dance left107; lx,ly,ldir,lstep: the same for her108; groove: the dance meter, 0 to GMAX.109; gshown: what the meter last showed110; night: which night. tleft: seconds111; to dawn. ttick: frames so far in112; this second113; maxg: most ghouls allowed tonight.114; ngh: how many are up. gdel: frames115; between a ghoul's steps116; spn: frames until the next may rise.117; spdel: the usual wait118; caught: 1 when she is lost. frm:119; counts frames120BYTE hx,hy,hdir,hstep,hdance,121 lx,ly,ldir,lstep,122 groove,gshown,night,123 tleft,ttick,maxg,ngh,gdel,124 spn,spdel,caught,frm,125 early, ; ghouls still to hurry up126 hpush, ; frames his claws stay out127 hpdir, ; and to which side128 held, ; a ghoul has hold of her129 grabt, ; frames left to free her130 gtime ; frames you are given131132; the music and the sound effects133; mpos: place in the tune. mtm:134; frames left in this step. tempo:135; frames to a step136; bnote,bvol: the bass note and its137; volume. lnote,lvol: the lead.138; enote,evol: its echo139; dtyp,dvol,dpit: the drum sounding140; sfx: the effect playing (0 none).141; sfxt: frames of it left142BYTE mpos,mtm,tempo,bnote,bvol,143 lnote,lvol,enote,evol,144 dtyp,dvol,dpit,sfx,sfxt145146; the ghouls: state, column and row147; (of the top left character), a timer,148; which step, which way, dance beats149; A state of 0 means no ghoul there;150; see Ghouls() for the others.151BYTE ARRAY gst(MAXG),gx(MAXG),152 gy(MAXG),gtm(MAXG),gfr(MAXG),153 gdir(MAXG),gdn(MAXG)154155BYTE ARRAY bkg(880), ; the graveyard156 herol(858), ; him, facing left157 girll(208) ; her, facing left158159; where the eight graves are160; (gvx: the column. gvy: the top row161; of the plot of earth)162BYTE ARRAY gvx=[3 13 25 35 2 36 8 30],163 gvy=[6 5 5 6 13 13 19 19],164; the sky in the last seconds of night165 sky=[$2A $28 $36 $34 $44 $52166 $62 $72 $80 $90 $90 $00],167; riff: the notes of the dance sound.168; fan is not used here.169 riff=[121 96 81 60 47 40],170 fan=[121 96 81 60 81 60 47 40]171172; The piece that greets a win: the173; table happokey and the procedures174; that play it (HpStart, HpTick,175; HpStop). It has procedures in it,176; so it comes in after the177; declarations above.178INCLUDE "D:HAPPOKEY.ACT"179180; The display list interrupt. It runs181; under the graveyard and gives the two182; text lines their own colours:183; PHA; LDA #$34; STA WSYNC; STA COLPF2184; LDA #$0E; STA COLPF1; PLA; RTI185PROC Dli=*()186[$48 $A9 $34 $8D $0A $D4 $8D $18 $D0187 $A9 $0E $8D $17 $D0 $68 $40]188189; wait for the next sixtieth of a second190; It also holds off the Atari's191; attract mode (the colour cycling192; when no key is pressed) and counts193; the frames in frm.194PROC Frame()195 BYTE f196 f=rtclok197 DO UNTIL rtclok<>f OD198 atract=0 frm==+1199RETURN200201; start sound effect t, to last n202; frames. Effect() plays it, a frame203; at a time.204PROC Sfx(BYTE t,n)205 sfx=t sfxt=n206RETURN207208; mirror n bytes of player shape209; (each byte is turned end for end, so210; the picture faces the other way)211PROC Flip(BYTE ARRAY src,dst CARD n)212 CARD i213 BYTE b,m,k214 FOR i=0 TO n-1 DO215 b=src(i) m=0216 FOR k=0 TO 7 DO217 m=m LSH 1218 IF (b&1)=1 THEN m==+1 FI219 b=b RSH 1220 OD221 dst(i)=m222 OD223RETURN224225; a character row with its four226; two-bit pixels in the other order227BYTE FUNC Rev2(BYTE b)228RETURN (((b&3) LSH 6)%((b&12) LSH 2)229 %((b&48) RSH 2)%(b RSH 6))230231; mirror a ghoul (two characters wide,232; three high) into six more characters233PROC FlipG(BYTE ARRAY src,dst)234 BYTE r,k235 CARD p236 FOR r=0 TO 2 DO237 ; a character is 8 bytes and a238 ; row of the ghoul is two of239 ; them. Left and right swap.240 p=r*16241 FOR k=0 TO 7 DO242 dst(p+k)=Rev2(src(p+8+k))243 dst(p+8+k)=Rev2(src(p+k))244 OD245 OD246RETURN247248; done once: memory and shapes249PROC Init()250 ramtop==-16 ; 2K of players and 1K251 Graphics(0) ; of characters up top252 ; pmb: players. chb: characters253 pmb=ramtop*256 chb=pmb+2048254 Zero(pmb,2048)255 ; the Atari's own characters (at256 ; 57344), then ours over them from257 ; character 65 on (65 x 8 = 520)258 MoveBlock(chb,57344,1024)259 MoveBlock(chb+520,cset,312)260 ; the cross and the leaning stone261 ; go in after the mirrored ghouls262 MoveBlock(chb+928,cset+312,64)263 ; ghoul pictures start at264 ; character 80 (640 / 8): two265 ; walking steps, each mirrored266 FlipG(chb+640,chb+832) ; walking left267 FlipG(chb+688,chb+880)268 ; him and her, facing left269 Flip(hero,herol,858)270 Flip(girl,girll,208)271RETURN272273; the game screen: GRAPHICS 0 with its274; first 22 lines changed to ANTIC mode275; 4 (four-colour characters) and two276; lines of ordinary text left below277PROC Screen()278 CARD dl279 BYTE i280 Graphics(0)281 ; no cursor; left margin at 0282 Poke(752,1) Poke(82,0)283 ; scrn: screen memory. dl: the284 ; display list, the Atari's table285 ; that says what kind each line is286 scrn=PeekC(88) dl=PeekC(560)287 ; (dl+3 is the first line; it has288 ; an address after it, hence $44)289 Poke(dl+3,$44)290 FOR i=6 TO 25 DO Poke(dl+i,4) OD291 Poke(dl+26,$84) ; ...and the DLI292 ; use our characters, and turn the293 ; players on294 Poke(756,chb RSH 8)295 Poke(54279,ramtop) ; PMBASE296 Poke(53277,3) ; GRACTL297 Poke(623,49) ; players in front,298 ; missiles = 5th,299 ; P0 over P1 = both300 ; colours ORed: his301 ; white socks302 Poke(559,62) ; one-line players303 Poke(704,$34) ; his red suit304 Poke(705,$28) ; his skin305 Poke(706,$02) ; his hair and shoes306 Poke(707,$86) ; her dress307 Poke(708,$C6) ; ghoul flesh, grass308 Poke(709,$08) ; stone, rags309 Poke(710,$24) ; ghoul trousers, earth310 Poke(711,$26) ; her skin; a dancing311 ; ghoul's trousers312 Poke(712,0)313 ; point the interrupt vector at Dli314 ; and switch interrupts on315 PokeC(512,Dli) Poke(54286,192)316RETURN317318; ---------- the two text lines ----------319320; show a message at the right of the321; upper text line, wiping the old one322PROC Msg(BYTE ARRAY s)323 Position(17,22)324 Print(" ")325 Position(17,22) Print(s)326RETURN327328; print the score on the bottom line329PROC ShowScore()330 Position(7,23) PrintC(score)331RETURN332333; print the seconds left until dawn334PROC ShowTime()335 Position(28,23) PrintB(tleft) Put(32)336RETURN337338; draw the groove meter: eight blocks,339; one for every 20 of groove. Printed340; only when it changes.341PROC ShowGroove()342 BYTE i,n343 n=groove/20344 IF n<>gshown THEN345 gshown=n Position(8,22)346 FOR i=1 TO 8 DO347 IF i<=n THEN Put(160)348 ELSE Put('.) FI349 OD350 FI351RETURN352353; print both text lines afresh: the354; labels, the night, a heart for each355; life and all the numbers356PROC ShowAll()357 BYTE i358 Position(1,22) Print("GROOVE")359 Position(1,23) Print("SCORE")360 Position(14,23) Print("NIGHT ")361 PrintB(night)362 Position(23,23) Print("DAWN")363 Position(32,23) Print(" ")364 Position(32,23)365 ; character 0 is a heart366 FOR i=1 TO lives DO Put(0) OD367 ShowScore() ShowTime()368 gshown=255 ShowGroove()369RETURN370371; ------------- the graveyard -------------372373; Build the empty graveyard in bkg, 22374; rows of 40 (so row r, column c is at375; r*40+c), and copy it to the screen.376PROC Scene()377 BYTE i378 CARD p379 Zero(bkg,880)380 ; rows 0 and 1 are sky381 FOR i=1 TO 14 DO ; stars382 bkg(Rand(80))=65383 OD384 bkg(33)=76 bkg(34)=77 ; the moon385 bkg(73)=78 bkg(74)=79386 FOR i=0 TO 39 DO ; the fence387 bkg(80+i)=67388 OD389 ; (rows 3 to 21: 120 is row 3)390 FOR i=1 TO 24 DO ; grass391 p=120+Rand(19)*40+Rand(40)392 bkg(p)=66393 OD394 ; a grave is 2 wide and 4 high: a395 ; stone over a plot of earth. p is396 ; the stone, two rows above gvy.397 FOR i=0 TO 7 DO ; eight graves:398 p=(gvy(i)-2)*40+gvx(i) ; a stone399 bkg(p)=68 bkg(p+1)=69400 bkg(p+40)=70 bkg(p+41)=71401 IF (i&3)=1 THEN ; a cross402 bkg(p)=116 bkg(p+1)=117403 bkg(p+40)=118 bkg(p+41)=119404 ELSEIF (i&3)=3 THEN ; one that leans405 bkg(p)=120 bkg(p+1)=121406 bkg(p+40)=122 bkg(p+41)=123407 FI408 bkg(p+80)=72 bkg(p+81)=73 ; and a409 bkg(p+120)=74 bkg(p+121)=75 ; plot410 OD411 MoveBlock(scrn,bkg,880)412RETURN413414; --------------- the ghouls ---------------415416; draw the top n rows of ghoul i, with417; its feet (or what there is) on the418; bottom row of its three419PROC DrawG(BYTE i,n)420 BYTE c,r421 CARD p422 ; c: its first character. Each423 ; picture is six in a run. 80 on:424 ; walking right. 104 on: walking425 ; left. 92 on: dancing.426 IF gst(i)=GDANCE THEN427 c=220+gfr(i)*6 ; inverse: 92+128428 ELSEIF gdir(i)=0 THEN c=80+gfr(i)*6429 ELSE c=104+gfr(i)*6 FI430 ; start n rows up from its feet;431 ; 40 characters to a screen row432 p=scrn+(gy(i)+3-n)*40+gx(i)433 FOR r=1 TO n DO434 Poke(p,c) Poke(p+1,c+1)435 p==+40 c==+2436 OD437RETURN438439; put back the graveyard under ghoul i440PROC EraseG(BYTE i)441 BYTE r442 CARD o443 ; o: its place, both on the screen444 ; and in the copy kept in bkg445 o=gy(i)*40+gx(i)446 FOR r=1 TO 3 DO447 MoveBlock(scrn+o,bkg+o,2)448 o==+40449 OD450RETURN451452; would ghoul i, at nx,ny, be standing453; on another one?454; (a ghoul is 2 wide and 3 high)455BYTE FUNC Blocked(BYTE i,nx,ny)456 BYTE j457 FOR j=0 TO MAXG-1 DO458 IF j<>i AND gst(j)>0 THEN459 IF nx+2>gx(j) AND gx(j)+2>nx460 AND ny+3>gy(j) AND gy(j)+3>ny461 THEN RETURN (1) FI462 FI463 OD464RETURN (0)465466; one shambling step toward the girl467PROC StepG(BYTE i)468 BYTE x,y,nx,ny,tx,ty,dx,dy,j469 x=gx(i) y=gy(i) nx=x ny=y470 ; tx,ty: where she is, in471 ; characters. Players count from472 ; 48 across and 32 down, with 4473 ; dots and 8 lines to a character.474 ; Ghouls keep out of the top three475 ; rows (sky and fence).476 tx=(lx-48) RSH 2 ty=(ly-32) RSH 3477 IF ty<3 THEN ty=3 FI478 ; how far off she is, each way479 IF x<tx THEN dx=tx-x ELSE dx=x-tx FI480 IF y<ty THEN dy=ty-y ELSE dy=y-ty FI481 ; one time in five, a step in any482 ; direction. Otherwise close the483 ; bigger gap.484 IF Rand(5)=0 THEN ; a lurch off course485 j=Rand(4)486 IF j=0 AND x<38 THEN nx=x+1487 ELSEIF j=1 AND x>0 THEN nx=x-1488 ELSEIF j=2 AND y<19 THEN ny=y+1489 ELSEIF j=3 AND y>3 THEN ny=y-1 FI490 ELSEIF dx>dy THEN491 IF x<tx THEN nx=x+1 ELSE nx=x-1 FI492 ELSEIF dy>0 THEN493 IF y<ty THEN ny=y+1 ELSE ny=y-1 FI494 FI495 ; face the way it is going496 IF nx>x THEN gdir(i)=0497 ELSEIF nx<x THEN gdir(i)=1 FI498 ; move, if no other ghoul is there499 IF Blocked(i,nx,ny)=0 THEN500 EraseG(i) gx(i)=nx gy(i)=ny501 FI502 ; the other leg, and a wait before503 ; the next step504 gfr(i)==!1505 DrawG(i,3)506 gtm(i)=gdel+Rand(6)507RETURN508509; every ghoul, every frame510; States: 0 none; 1-3 climbing out;511; GWALK; GDANCE; 6-8 sinking; GDAZE512; shoved; GGRAB holding her. gtm513; counts frames until its next move.514PROC Ghouls()515 BYTE i,s516 FOR i=0 TO MAXG-1 DO517 s=gst(i)518 IF s>0 THEN519 IF gtm(i)>0 THEN gtm(i)==-1520 ELSEIF s<3 THEN ; climbing out521 gst(i)=s+1 gtm(i)=20522 DrawG(i,s+1) Sfx(SRISE,10)523 ; fully out, or over a shove:524 ; start walking525 ELSEIF s=3 OR s=GDAZE THEN526 gst(i)=GWALK gtm(i)=gdel527 ELSEIF s=GWALK THEN StepG(i)528 ; dancing: gdn beats of 7529 ; frames, then walk again530 ELSEIF s=GDANCE THEN531 gdn(i)==-1532 IF gdn(i)=0 THEN gst(i)=GWALK FI533 gfr(i)==!1 gtm(i)=7534 DrawG(i,3)535 ELSEIF s=GGRAB THEN ; tugging at her536 gfr(i)==!1 gtm(i)=6537 DrawG(i,3)538 ELSE ; sinking: 6, 7, 8539 ; show one row fewer each540 ; time, then free the slot541 EraseG(i)542 IF s=8 THEN gst(i)=0 ngh==-1543 ELSE544 DrawG(i,8-s)545 gst(i)=s+1 gtm(i)=6546 FI547 FI548 FI549 OD550RETURN551552; now and then another one wakes up553PROC Spawn()554 BYTE i,g,x,y,px,py555 ; spn counts down the frames556 IF spn>0 THEN spn==-1 RETURN FI557 ; (if we give up below, try again558 ; in 15 frames)559 spn=15560 IF ngh>=maxg THEN RETURN FI561 ; i: the first free slot562 i=0563 WHILE gst(i)>0 DO i==+1 OD564 ; a grave at random. A ghoul's top565 ; row is one above the plot.566 g=Rand(8) x=gvx(g) y=gvy(g)-1567 IF Blocked(i,x,y)=1 THEN RETURN FI568 ; not right under her feet569 ; (px,py: the grave in player dots570 ; and lines, as she is)571 px=48+x*4 py=32+y*8572 IF lx+14>px AND px+14>lx573 AND ly+34>py AND py+34>ly574 THEN RETURN FI575 ; up it comes, facing the middle576 gx(i)=x gy(i)=y gfr(i)=0577 IF x>19 THEN gdir(i)=1578 ELSE gdir(i)=0 FI579 gst(i)=1 gtm(i)=20 ngh==+1580 DrawG(i,1) Sfx(SRISE,10)581 ; the first two of a try come up582 ; quickly, to get things going583 IF early>0 THEN584 early==-1 spn=30+Rand(30)585 ELSE spn=spdel+Rand(60) FI586RETURN587588; ------------ him and her ------------589590; draw him: pick the right picture and591; copy it into the three players that592; make him up593PROC DrawHero()594 CARD s595 BYTE b596 ; a picture is 78 bytes: 26 lines597 ; for each of the three players598 IF hdance>0 THEN599 ; six beats: claws out to the600 ; right, an arm up, claws out to601 ; the left, the other arm up, the602 ; crouch, and a spin to finish603 b=hdance RSH 3604 IF b>4 THEN s=hero+312605 ELSEIF b=4 THEN s=hero+156606 ELSEIF b=3 THEN s=herol+312607 ELSEIF b=2 THEN s=hero+234608 ELSEIF b=1 THEN s=hero+390609 ELSE s=hero+468 FI610 ELSEIF hpush>0 THEN ; shoving a ghoul611 IF hpdir=0 THEN s=hero+312612 ELSE s=herol+312 FI613 ELSEIF hdir=0 THEN614 s=hero+((hstep RSH 3)&1)*78615 ELSE616 s=herol+((hstep RSH 3)&1)*78617 FI618 ; players 0, 1 and 2 are at619 ; pmb+1024, +1280 and +1536. Each620 ; has a byte for each TV line, so621 ; adding hy puts him at that line.622 MoveBlock(pmb+1024+hy,s,26)623 MoveBlock(pmb+1280+hy,s+26,26)624 MoveBlock(pmb+1536+hy,s+52,26)625 ; and all three at the same dot626 hposp0=hx hposp1=hx hposp2=hx627RETURN628629; the dance: every ghoul close enough630; has to join in for a while631PROC Dance()632 BYTE i,cx,cy,n633 n=0634 ; 48 frames of dance; the meter is635 ; spent636 hdance=48 groove=0 Sfx(SDANCE,24)637 ; cx,cy: where he is, in characters638 cx=(hx-48) RSH 2 cy=(hy-32) RSH 3639 ; ghouls within 14 columns and 9640 ; rows dance for 22 beats641 FOR i=0 TO MAXG-1 DO642 IF gst(i)=GWALK OR gst(i)=GDAZE643 OR gst(i)=GGRAB THEN644 IF gx(i)+14>cx AND cx+14>gx(i)645 AND gy(i)+9>cy AND cy+9>gy(i)646 THEN647 gst(i)=GDANCE gdn(i)=22 gtm(i)=0648 n==+1649 FI650 FI651 OD652 ; four or more dancing at once653 ; score 200 points654 IF n=0 THEN655 Msg("NOBODY IS WATCHING...")656 ELSEIF n<4 THEN657 Msg("THEY CAN'T HELP IT!")658 ELSE ; a full chorus line659 score==+200 ShowScore()660 Msg("WHAT A SHOW! +200")661 FI662RETURN663664; Move him, once a frame. He cannot665; walk while he dances. The button666; starts a dance, but only when the667; groove meter is full.668PROC Hero()669 BYTE s670 IF hpush>0 THEN hpush==-1 FI671 IF hdance>0 THEN hdance==-1672 ELSE673 ; stick bits: 8 right, 4 left,674 ; 1 up, 2 down (0 = pushed). One675 ; dot or two lines a frame,676 ; inside the graveyard.677 s=Stick(0)678 IF s<>15 THEN hstep==+1 FI679 IF (s&8)=0 AND hx<200 THEN680 hx==+1 hdir=0 FI681 IF (s&4)=0 AND hx>48 THEN682 hx==-1 hdir=1 FI683 IF (s&1)=0 AND hy>54 THEN hy==-2 FI684 IF (s&2)=0 AND hy<182 THEN hy==+2 FI685 IF Strig(0)=0 AND groove=GMAX THEN686 Dance() FI687 FI688 DrawHero()689RETURN690691; she keeps a step behind him, and she692; is only half as quick693PROC Girl()694 BYTE tx695 CARD s696 ; tx: 10 dots behind his back697 IF hdir=0 THEN tx=hx-10698 ELSE tx=hx+10 FI699 IF tx<48 THEN tx=48 FI700 IF tx>200 THEN tx=200 FI701 ; she can't follow while one has her702 IF (frm&1)=0 AND held=0 THEN703 IF lx<tx THEN704 lx==+1 ldir=0 lstep==+1705 ELSEIF lx>tx THEN706 lx==-1 ldir=1 lstep==+1 FI707 IF ly<hy THEN ly==+2 lstep==+1708 ELSEIF ly>hy THEN ly==-2 lstep==+1 FI709 FI710 ; her picture: 52 bytes each, 26711 ; for player 3 (pmb+1792) and 26712 ; for the missiles (pmb+768)713 IF ldir=0 THEN s=girl ELSE s=girll FI714 s==+((lstep RSH 2)&1)*52715 ; held: her hands fly to her cheeks716 IF held>0 THEN s=girl+104 FI717 MoveBlock(pmb+1792+ly,s,26)718 MoveBlock(pmb+768+ly,s+26,26)719 ; the four missiles side by side720 hposp3=lx hposm3=lx hposm2=lx+2721 hposm1=lx+4 hposm0=lx+6722RETURN723724; shove ghoul i away from him725PROC Push(BYTE i)726 BYTE nx,ny,s727 ; stick straight up or down sends728 ; it 3 rows that way. Otherwise it729 ; goes 4 columns to the side it is730 ; on. Never off the graveyard.731 nx=gx(i) ny=gy(i) s=Stick(0)732 IF s=14 THEN ; straight up733 IF ny>5 THEN ny==-3 ELSE ny=3 FI734 ELSEIF s=13 THEN ; straight down735 IF ny<16 THEN ny==+3 ELSE ny=19 FI736 ELSEIF 48+nx*4>=hx THEN737 IF nx<34 THEN nx==+4 ELSE nx=38 FI738 ELSE739 IF nx>4 THEN nx==-4 ELSE nx=0 FI740 FI741 ; (it stays put if another ghoul is742 ; in the way)743 IF Blocked(i,nx,ny)=0 THEN744 EraseG(i) gx(i)=nx gy(i)=ny745 DrawG(i,3)746 FI747 ; dazed for 50 frames748 gst(i)=GDAZE gtm(i)=50749 ; his claws go out toward it750 hpush=12751 IF 48+gx(i)*4>=hx THEN hpdir=0752 ELSE hpdir=1 FI753 ; 5 points for every shove754 score==+5 ShowScore() Sfx(SBUMP,8)755RETURN756757; who is touching whom758; Called every frame. Also sets held,759; if any ghoul has hold of her.760PROC Bumps()761 BYTE i,px,py762 held=0763 FOR i=0 TO MAXG-1 DO764 IF gst(i)=GWALK OR gst(i)=GDANCE765 OR gst(i)=GGRAB THEN766 ; px,py: the ghoul in player767 ; dots and lines768 px=48+gx(i)*4 py=32+gy(i)*8769 ; is he touching it?770 IF hx+6>px AND px+6>hx771 AND hy+22>py AND py+22>hy772 THEN773 ; a dancing ghoul goes back774 ; into the ground: 50 points775 IF gst(i)=GDANCE THEN776 gst(i)=GSINK gtm(i)=0777 score==+50 ShowScore()778 Sfx(SSINK,20)779 ELSE780 ; one that had hold of her:781 ; 20 points, then the shove782 ; (5 more)783 IF gst(i)=GGRAB THEN784 score==+20785 Msg("THAT WAS CLOSE!")786 FI787 Push(i)788 FI789 FI790 ; a ghoul that reaches her takes791 ; hold: shove it off, quickly!792 IF gst(i)=GWALK AND lx+5>px793 AND px+5>lx AND ly+18>py794 AND py+18>ly795 THEN796 gst(i)=GGRAB gtm(i)=0797 Msg("SHE NEEDS YOU! QUICK!")798 FI799 IF gst(i)=GGRAB THEN held=1 FI800 FI801 OD802RETURN803804; the groove meter and the clock805PROC Clock()806 ; the groove fills by one every807 ; other frame, but not in a dance808 IF groove<GMAX AND (frm&1)=0809 AND hdance=0810 THEN groove==+1 FI811 ShowGroove()812 ; while a ghoul holds her, grabt813 ; runs down, her dress flashes and814 ; a sound repeats. At 0 she is815 ; lost. Let go: grabt starts again.816 IF held=1 THEN817 grabt==-1818 Poke(707,$86+(grabt&8))819 IF (grabt&7)=0 THEN Sfx(SRISE,4) FI820 IF grabt=0 THEN caught=1 FI821 ELSE822 grabt=gtime Poke(707,$86)823 FI824 ; 60 frames make a second. The last825 ; 12 seconds colour the sky.826 ttick==+1827 IF ttick=60 THEN828 ttick=0 tleft==-1 ShowTime()829 IF tleft<12 THEN colbk=sky(tleft) FI830 FI831RETURN832833; ------------- sound -------------834835; play one frame of the sound effect836; on voice 3. sfxt counts down, and837; most effects slide in pitch with it.838PROC Effect()839 sfxt==-1840 IF sfx=SBUMP THEN ; a thump841 Sound(3,250-sfxt*12,10,10)842 ELSEIF sfx=SRISE THEN ; earth moving843 Sound(3,200+Rand(40),0,8)844 ELSEIF sfx=SSINK THEN ; going down845 Sound(3,200-sfxt*8,10,8)846 ELSE ; the dance847 Sound(3,riff(5-(sfxt RSH 2)),10,10)848 FI849 IF sfxt=0 THEN sfx=0 FI850RETURN851852; the band, called once a frame: bass853; on voice 0, lead on 1, its echo on 2,854; drums or a sound effect on 3855PROC Music()856 BYTE b,l,e,d857 ; between steps, let the notes fade858 IF mtm>0 THEN859 mtm==-1860 IF bvol>3 THEN bvol==-1 FI861 IF lvol>4 AND (mtm&1)=0 THEN862 lvol==-1 FI863 ELSE864 ; a new step of the tune. In the865 ; tables 0 is silence, 1 holds the866 ; note, anything else is a new867 ; note. The echo is the lead,868 ; three steps late.869 mtm=tempo-1870 b=bass(mpos) l=lead(mpos)871 e=lead((mpos-3)&127)872 d=drum(mpos&15)873 IF b=0 THEN bvol=0874 ELSEIF b>1 THEN bnote=b bvol=8 FI875 IF l=0 THEN lvol=0876 ELSEIF l>1 THEN lnote=l lvol=8 FI877 IF e=0 THEN evol=0878 ELSEIF e>1 THEN enote=e evol=3 FI879 ; drums: 1 kick, 2 snare, 3 hat880 IF d=1 THEN dtyp=1 dvol=12 dpit=100881 ELSEIF d=2 THEN dtyp=2 dvol=9882 ELSEIF d=3 THEN dtyp=3 dvol=4 FI883 mpos=(mpos+1)&127884 FI885 ; send it all to the sound chip886 Sound(0,bnote,12,bvol)887 Sound(1,lnote,10,lvol)888 Sound(2,enote,10,evol)889 ; voice 3: an effect if there is890 ; one, else the drum dying away891 IF sfx>0 THEN Effect()892 ELSEIF dvol>0 THEN893 IF dtyp=1 THEN ; kick894 Sound(3,dpit,10,dvol)895 dpit==+45 dvol==-4896 ELSEIF dtyp=2 THEN ; snare897 Sound(3,14,8,dvol) dvol==-3898 ELSE ; hat899 Sound(3,1,8,dvol) dvol=0900 FI901 ELSE Sound(3,0,0,0) FI902RETURN903904; start the tune from the top, with905; every voice silent906PROC MusicOn()907 mpos=0 mtm=0 bvol=0 lvol=0 evol=0908 dvol=0 sfx=0909RETURN910911; The digitized laugh. Each byte holds912; two samples of four bits. Bit 4 of913; AUDC makes a channel put out its914; volume as a steady level, so poking915; one sample after another draws the916; sound wave. Two channels at once are917; twice as loud. The empty loops set918; the pace: about 4,000 a second.919PROC Laugh(BYTE n)920 CARD i,c,fs,st921 BYTE b,v,d,k,o,p922 BYTE ARRAY ft(128)923 ; ft: the 16 levels at 1/8 to 8/8924 ; of full strength, 16 to a row,925 ; shrunk toward the middle level 8926 FOR k=1 TO 8 DO927 FOR v=0 TO 15 DO928 IF v<8 THEN d=8-((8-v)*k+4)/8929 ELSE d=8+((v-8)*k+4)/8 FI930 ft((k-1)*16+v)=$10%d931 OD932 OD933 ; n=1: once, fading over its last934 ; quarter. n=2: once at full strength935 ; (row 112), then again, fading all936 ; the way through. st is where the937 ; fade starts; it drops a row every938 ; fs bytes.939 IF n=1 THEN fs=LAUGHLEN/28940 ELSE fs=LAUGHLEN/7 FI941 o=112942 FOR p=1 TO n DO943 st=LAUGHLEN c=fs-1944 IF p=n THEN st=LAUGHLEN-fs*7 FI945 FOR i=0 TO LAUGHLEN-1 DO946 b=laugh(i)947 v=ft(o+(b RSH 4)) audc1=v audc2=v948 FOR d=1 TO 9 DO OD949 v=ft(o+(b&15)) audc1=v audc2=v950 FOR d=1 TO 9 DO OD951 IF i>=st THEN952 c==+1953 IF c=fs THEN954 c=0955 IF o>0 THEN o==-16 FI956 FI957 FI958 OD959 OD960 audc1=0 audc2=0961RETURN962963; ------------- the game -------------964965; how hard is tonight?966; Called for each night, and again967; after each lost try (for ease).968PROC NewNight()969 ; more ghouls at once970 maxg=2+night971 IF maxg>MAXG THEN maxg=MAXG FI972 ; fewer frames between their steps973 IF night<10 THEN gdel=34-night*3974 ELSE gdel=5 FI975 gdel==+ease*4976 ; a shorter wait for the next one977 IF night<9 THEN spdel=150-night*14978 ELSE spdel=24 FI979 ; less time to free her980 IF night<6 THEN gtime=90-night*12981 ELSE gtime=20 FI982 gtime==+ease*20983 ; and faster music984 tempo=8985 IF night>3 THEN tempo=7 FI986 IF night>6 THEN tempo=6 FI987RETURN988989; the nights get longer, too990; tleft: seconds until dawn. Not set991; again after a lost try: the clock992; carries on from where it was.993PROC Dusk()994 IF night<6 THEN tleft=35+night*5995 ELSE tleft=60 FI996RETURN997998; set everybody out for another try999PROC Round()1000 BYTE i1001 ; no ghouls; a full groove meter1002 FOR i=0 TO MAXG-1 DO gst(i)=0 OD1003 ngh=0 spn=20 caught=0 ttick=01004 early=21005 held=0 grabt=gtime1006 hdance=0 hpush=0 groove=GMAX1007 ; wipe the missiles and all four1008 ; players (1280 bytes)1009 Zero(pmb+768,1280)1010 ; him in the middle, her beside1011 hx=128 hy=118 hdir=0 hstep=01012 lx=114 ly=118 ldir=0 lstep=01013 ; the sky, if dawn is near1014 IF tleft<12 THEN colbk=sky(tleft)1015 ELSE colbk=0 FI1016 Scene() ShowAll()1017 Msg("PROTECT YOUR GIRL!")1018 MusicOn()1019RETURN10201021; a ghoul has her1022PROC Lost()1023 BYTE i1024 SndRst()1025 Msg("THE GHOULS GOT HER!")1026 FOR i=0 TO 50 DO ; her scream1027 Frame()1028 Sound(0,70-i+(i&1)*2,10,12)1029 Sound(1,72-i,10,6)1030 IF (i&2)=0 THEN colbk=$341031 ELSE colbk=0 FI1032 OD1033 SndRst() colbk=01034 ; twice for his last life1035 IF lives=1 THEN Laugh(2)1036 ELSE Laugh(1) FI1037 ; a life lost: rub out one heart1038 lives==-11039 Position(32+lives,23) Put(32)1040RETURN10411042; the sun is up: every ghoul goes home1043PROC Dawn()1044 BYTE i,md1045 CARD s1046 SndRst()1047 Msg("DAWN! SHE IS SAFE")1048 ; they sink one after another1049 FOR i=0 TO MAXG-1 DO1050 IF gst(i)>0 THEN1051 gst(i)=GSINK gtm(i)=i*5 FI1052 OD1053 ; she holds out her arms to him...1054 IF lx<hx THEN s=girl ELSE s=girll FI1055 s==+1561056 MoveBlock(pmb+1792+ly,s,26)1057 MoveBlock(pmb+768+ly,s+26,26)1058 ; ...and he moonwalks, toward the1059 ; middle: facing one way, gliding1060 ; the other1061 IF hx>124 THEN md=0 ELSE md=1 FI1062 ; HAPPOKEY.ACT, 3.2 seconds of music1063 ; on the sound chip's four voices,1064 ; once through: a table of 193 rows,1065 ; one for each sixtieth of a second.1066 ; HpTick() pokes the next row into1067 ; the sound registers and clears1068 ; hpon after the last. i counts the1069 ; frames.1070 i=01071 HpStart()1072 WHILE hpon<>0 DO1073 Frame()1074 HpTick()1075 i==+11076 ; once a frame: sink the ghouls1077 ; and move him. Pictures from1078 ; 546 on are the moonwalk.1079 Ghouls()1080 IF i<160 THEN1081 IF md=0 THEN s=hero ELSE s=herol FI1082 s==+546+((i RSH 3)&3)*781083 IF (i&1)=0 THEN1084 IF md=0 AND hx>52 THEN hx==-1 FI1085 IF md=1 AND hx<196 THEN hx==+1 FI1086 FI1087 ELSE ; and a spin to finish1088 s=hero+4681089 FI1090 MoveBlock(pmb+1024+hy,s,26)1091 MoveBlock(pmb+1280+hy,s+26,26)1092 MoveBlock(pmb+1536+hy,s+52,26)1093 hposp0=hx hposp1=hx hposp2=hx1094 OD1095 SndRst()1096 ; 100 points times the night number1097 score==+night*100 ShowScore()1098RETURN10991100; Back to the title program, which1101; shows the card for the next screen1102; and loads it. (The loading is not1103; written: under DOS 2.0S it is a1104; binary load of D:THRILLER.OBJ and a1105; jump to its start.)1106PROC Next()1107 ; interrupts and players off, and1108 ; all eight moved off the TV1109 SndRst()1110 Poke(54286,64) Poke(53277,0)1111 hposp0=0 hposp1=0 hposp2=0 hposp3=01112 hposm0=0 hposm1=0 hposm2=0 hposm3=01113RETURN11141115; All lives are gone. If the title1116; program ran us, wait three seconds1117; and hand back with result=0. If1118; not, wait for the START key.1119PROC GameOver()1120 BYTE i1121 IF chain=1 THEN1122 Msg("GAME OVER")1123 FOR i=0 TO 180 DO Frame() OD1124 result=0 Next()1125 ELSE1126 Msg("GAME OVER: PRESS START")1127 DO Frame() UNTIL consol=6 OD1128 FI1129RETURN11301131; The title page, shown only when this1132; screen is run by itself: big text,1133; the tune, and a wait for START.1134PROC Title()1135 ; interrupts and players off1136 Poke(54286,64) Poke(53277,0)1137 hposp0=0 hposp1=0 hposp2=0 hposp3=01138 hposm0=0 hposm1=0 hposm2=0 hposm3=01139 ; big text (GRAPHICS 2, no window)1140 ; in the Atari's own characters1141 Graphics(18) Poke(756,224)1142 Poke(708,$36) Poke(709,$0E)1143 Poke(710,$C8) Poke(711,$1A)1144 Position(6,1) PrintD(6,"THRILLER")1145 Position(5,3) PrintD(6,"screen two")1146 Position(4,5)1147 PrintD(6,"PROTECT YOUR")1148 Position(2,6)1149 PrintD(6,"GIRLFRIEND FROM")1150 Position(3,7)1151 PrintD(6,"GRISLY GHOULS!")1152 Position(4,9) PrintD(6,"press start")1153 Position(0,11)1154 PrintD(6,"designed 1984 d.lutz")1155 ; play the tune until START1156 MusicOn() tempo=81157 DO1158 Frame() Music()1159 IF (frm&3)=0 THEN ; the title drips1160 Poke(708,$32+Rand(4)*2) FI1161 UNTIL consol=6 OD1162 SndRst()1163RETURN11641165; The whole game. One pass of the1166; inner loop is one TV frame; the1167; loop round it is one try at a1168; night; the outer one is one game.1169PROC Main()1170 Init()1171 DO1172 ; run by itself: title, new game1173 IF chain=0 THEN1174 Title() score=0 lives=3 wins=01175 FI1176 Screen() ease=01177 ; wins/3+1: the night number1178 night=wins/3+1 NewNight() Dusk()1179 DO1180 Round()1181 DO1182 ; one TV frame1183 Frame()1184 Hero() Girl() Ghouls() Spawn()1185 Bumps() Clock() Music()1186 UNTIL caught=1 OR tleft=0 OD1187 IF caught=1 THEN1188 ; a ghoul kept hold of her: a1189 ; life lost. The next try is1190 ; easier, on the same clock.1191 Lost()1192 IF ease<2 THEN ease==+1 FI1193 NewNight()1194 ELSE1195 ; the clock ran out: a win1196 Dawn()1197 ; run from the title program:1198 ; one more screen won; go back1199 IF chain=1 THEN1200 wins==+1 result=1 Next()1201 RETURN1202 FI1203 ; by itself: on to a harder,1204 ; longer night1205 wins==+3 ease=01206 night=wins/3+1 NewNight() Dusk()1207 FI1208 UNTIL lives=0 OD1209 GameOver()1210 IF chain=1 THEN RETURN FI1211 OD1212RETURN