Thriller · the program listingsScreen 1: the woods

About the listingsTitle programCard programThe woodsThe graveyardThe mansionPictures, tunes and sounds

The werewolf, the girl, the scrolling woods and the house. The woods are a wide map of characters that slides past; the wolf and the girl are players laid over it.

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.

THRILLER1.ACT · 1424 lines · the file itself

Its 42 PROCs and FUNCs, in the order they appear:

1; **************************************2; *  T H R I L L E R    -   screen 1   *3; *    "Save your girl from the        *4; *         haunted house!"            *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; (The 1984 sketch called this screen11; "Catch the girl as you are a12; werewolf!" We made it a rescue.)13;14; The full moon has made a werewolf of15; you. Your girl has run from the wolf,16; straight toward the old house at the17; far side of the woods, and she does18; not know what is waiting inside it.19; Reach her before she reaches the20; door: one touch breaks the spell, you21; are yourself again, and she is safe.22; Trees stop you, logs trip you and23; brambles slow you down. The button24; makes the wolf leap: fast, straight,25; and clear over logs and brambles.26; When a cloud hides the moon you are27; only a man again, and slow. Then the28; button calls to her: she knows your29; voice, and stops to look back.30;31; In this listing {inv}...{/inv} marks32; text typed in inverse video.33;34; HOW THIS PROGRAM WORKS35; The woods are made of characters: a36; map 256 columns wide and 19 rows37; high, in a four-colour character38; mode. The TV shows 40 columns of it,39; and new columns are planted just off40; the right as the picture slides.41; Above are two rows of sky and a42; skyline; below are two lines of43; ordinary text for the score.44; He and she are players and missiles:45; small pictures laid over the screen46; that move a dot at a time. He is47; three players, one for each colour.48; She is the fourth player plus the49; four missiles.50; Main runs one loop for each TV51; frame, a sixtieth of a second: move52; him, move her, slide the woods,53; place the players, see if he has54; touched her, drift the clouds, play55; one step of the music.56; Touch her and the night is won. If57; she reaches the door first a life is58; lost. No lives left ends the game.5960INCLUDE "D:SHAPES1.ACT" ; wset,wolf61INCLUDE "D:SHAPES.ACT"  ; hero,girl62INCLUDE "D:MUSIC1.ACT"  ; bass,lead,drum63INCLUDE "D:LAUGH.ACT"   ; laugh,LAUGHLEN6465; names for the characters that make66; the woods, two addresses in page 6,67; two colours for player 1 (FUR and68; SKIN) and the sound effects69DEFINE STAR="65",GRASS="66",70  TRUNK="87",LOG="88",BRAMBLE="90",71  STUMP="92",GLOVE="111", ; characters72  DLIST="$640",      ; our display list73  LMS="$64B",        ; its first map row74  FUR="$18",SKIN="$28",75  SLEAP="1",STRIP="2",SHOWL="3",76  SWHIM="4",SCALL="5",77  SGLOVE="6"         ; sound effects7879; the bytes the five programs share80; (the title program, the card81; program and the three screens).82; They are in page 6,83; which DOS leaves alone between loads.84; chain: 0 this screen was run by85;   itself, 1 the title program ran it86; wins: screens won so far this game87; result: 1 the screen was won, 0 the88;   game is over89BYTE chain=$6F0,wins=$6F1,lives=$6F2,90  result=$6F591CARD score=$6F392; ease: tries lost on this visit to93; the screen. Each one makes the94; next try a little easier.95BYTE ease9697; places in the Atari's own memory:98; the frame clock, the attract timer,99; the top of memory, the console100; keys, two sound volume registers101; and the horizontal positions of the102; four players and four missiles103BYTE rtclok=20,atract=77,ramtop=106,104  consol=53279,105  gfine=$CB,  ; HSCROL for the woods106  ffine=$CC,  ; and for the skyline107  audc1=$D201,audc2=$D203,108  hposp0=$D000,hposp1=$D001,109  hposp2=$D002,hposp3=$D003,110  hposm0=$D004,hposm1=$D005,111  hposm2=$D006,hposm3=$D007112; addresses: screen memory, player113; memory, our character set, the map114CARD scrn,pmb,chb,mapb115116; Where things are, in dots from the117; left end of the map (which is 256118; characters wide and slides along)119CARD cam,   ; the left edge of the TV120  hbx,gbx,  ; him and her121  togo,     ; how far she is from home122  gleft,    ; columns still to plant123  glen      ; how long this chase is124125; lcol: the map column at the left of126;   the TV. gencol: the next column127;   to plant128; quiet: columns to leave bare at the129;   start. dens: things planted at a130;   time. fpos: where the skyline is131; hy: his top line. hpy: where he was132;   last drawn. hacc: the part of a133;   dot left over from his speed134; hstep: counts his steps, to pick135;   the picture. wolfm: 1 wolf, 0 man136; leap: frames of leap left. lcool:137;   frames until he can leap again138; stun: frames he is knocked still139; hfree: frames he cannot trip again140; called: 1 once he has called her141; flash: frames his suit flickers142; gy,gpy,gacc,gstep: the same for her143; gstop: frames she stands looking144;   back. gstuck: frames a tree has145;   held her up. gdodge: which way146;   she is going round it (1 up,147;   2 down)148; gspd: her speed. pan: her speed149;   when the wolf is close. fal: how150;   near the house she falters151; ctm: frames until the clouds move.152;   cdel: frames between moves. ncl:153;   how many clouds. cmax: sets how154;   long they can be. covered: 1 if155;   a cloud hides the moon156; chase: which night. got: 1 when he157;   has reached her. frm: counts158;   frames. hshown, bshown: what the159;   text lines last showed, so they160;   are printed only on a change161BYTE lcol,gencol,quiet,dens,fpos,162  hy,hpy,hacc,hstep,wolfm,leap,lcool,163  stun,hfree,called,flash,164  boost,  ; frames of extra speed left165  gy,gpy,gacc,gstep,gstop,gstuck,166  gdodge,gspd,pan,fal,167  ctm,cdel,ncl,cmax,covered,168  chase,got,frm,hshown,bshown169170; the music and the sound effects171; mpos: place in the tune. mtm:172;   frames left in this step. tempo:173;   frames to a step174; bnote,bvol: the bass note and its175;   volume. lnote,lvol: the lead.176;   enote,evol: its echo177; dtyp,dvol,dpit: the drum sounding178; sfx: the effect playing (0 none).179;   sfxt: frames of it left180BYTE mpos,mtm,tempo,bnote,bvol,181  lnote,lvol,enote,evol,182  dtyp,dvol,dpit,sfx,sfxt183184; ccx, clen: where each cloud is and185;   how long. hop: how many lines the186;   wolf is lifted at each stage of a187;   leap. fan is not used here.188BYTE ARRAY ccx(3),clen(3), ; clouds189  skyb(80),          ; the empty sky190  girll(208),        ; her, looking back191  hop=[2 4 6 6 6 4 2],192  fan=[121 96 81 60 81 60 47 40]193194; Two display list interrupts, copied195; to page 6. The first runs under the196; skyline: it sets the fine scroll for197; the woods and changes the colours.198;  PHA; LDA $CB; STA WSYNC; STA HSCROL199;  LDA #$C4; STA COLPF0200;  LDA #$24; STA COLPF2201;  LDA #$00; STA COLBK202;  LDA #$1F; STA VDSLST; PLA; RTI203; The second runs under the woods. It204; colours the two text lines and sets205; the fine scroll for the skyline:206;  PHA; LDA #$34; STA WSYNC; STA COLPF2207;  LDA #$0E; STA COLPF1208;  LDA #0; STA COLBK209;  LDA $CC; STA HSCROL210;  LDA #0; STA VDSLST; PLA; RTI211; the leaves, night by night: summer,212; autumn, winter (snow), spring. A213; salute to Eastern Front (1941).214BYTE ARRAY leaf=[$C4 $36 $0A $B8]215216; the machine code of the two217; interrupts, 31 bytes each218BYTE ARRAY dlicode=[219 $48 $A5 $CB $8D $0A $D4 $8D $04 $D4220 $A9 $C4 $8D $16 $D0 $A9 $24 $8D $18221 $D0 $A9 $00 $8D $1A $D0 $A9 $1F $8D222 $00 $02 $68 $40223 $48 $A9 $34 $8D $0A $D4 $8D $18 $D0224 $A9 $0E $8D $17 $D0 $A9 $00 $8D $1A225 $D0 $A5 $CC $8D $04 $D4 $A9 $00 $8D226 $00 $02 $68 $40]227228; The piece that greets a win: the229; table happokey and the procedures230; that play it (HpStart, HpTick,231; HpStop). It has procedures in it,232; so it comes in after the233; declarations above.234INCLUDE "D:HAPPOKEY.ACT"235236; wait for the next sixtieth of a second237; It also holds off the Atari's238; attract mode (the colour cycling239; when no key is pressed) and counts240; the frames in frm.241PROC Frame()242  BYTE f243  f=rtclok244  DO UNTIL rtclok<>f OD245  atract=0 frm==+1246RETURN247248; start sound effect t, to last n249; frames. Effect() plays it, a frame250; at a time.251PROC Sfx(BYTE t,n)252  sfx=t sfxt=n253RETURN254255; mirror n bytes of player shape256; (each byte is turned end for end, so257; the picture faces the other way)258PROC Flip(BYTE ARRAY src,dst CARD n)259  CARD i260  BYTE b,m,k261  FOR i=0 TO n-1 DO262    b=src(i) m=0263    FOR k=0 TO 7 DO264      m=m LSH 1265      IF (b&1)=1 THEN m==+1 FI266      b=b RSH 1267    OD268    dst(i)=m269  OD270RETURN271272; done once: memory and shapes. From273; the top down: 19 pages of map (one274; for each row of the woods), 1K of275; characters, 2K of players.276PROC Init()277  ; take 32 pages (8K) off the top of278  ; memory for ourselves279  ramtop==-32280  Graphics(0)281  ; pmb: players. chb: characters, 2K282  ; above. mapb: the map, 1K above283  ; that.284  pmb=ramtop*256 chb=pmb+2048285  mapb=pmb+3072286  Zero(pmb,2048)287  ; copy the Atari's own characters288  ; (at 57344), then put ours over289  ; them from character 65 on (65 x290  ; 8 bytes = 520)291  MoveBlock(chb,57344,1024)292  MoveBlock(chb+520,wset,384)293  ; the interrupts go to page 6294  MoveBlock($600,dlicode,62)295  ; her, mirrored (looking back)296  Flip(girl,girll,208)297RETURN298299; The game screen. Our own display300; list: two rows of sky, the skyline,301; 19 rows of woods (each with its own302; address, so the woods can slide) and303; two lines of ordinary text.304PROC Screen()305  CARD p306  BYTE i307  Graphics(0)308  ; no cursor; left margin at 0;309  ; scrn = where screen memory is310  Poke(752,1) Poke(82,0)311  scrn=PeekC(88)312  ; The display list is a table that313  ; says what kind each line of the314  ; TV is. Three blank strips, then315  ; two rows of sky from scrn ($44:316  ; four-colour characters, with an317  ; address to follow).318  Poke(DLIST,$70) Poke(DLIST+1,$70)319  Poke(DLIST+2,$70)320  Poke(DLIST+3,$44) PokeC(DLIST+4,scrn)321  Poke(DLIST+6,4)322  Poke(DLIST+7,$D4)  ; skyline: scrolls,323  PokeC(DLIST+8,scrn+80) ; then a DLI324  ; 19 rows of woods ($54: the same,325  ; but able to slide sideways). Row326  ; i is page i of the map; the low327  ; byte of its address is the map328  ; column at the left of the TV.329  p=DLIST+10330  FOR i=0 TO 18 DO331    Poke(p,$54) Poke(p+1,0)332    Poke(p+2,(mapb RSH 8)+i)333    p==+3334  OD335  Poke(p-3,$D4)      ; the second DLI336  ; two text lines, from row 22 of337  ; the ordinary screen (22 x 40 =338  ; 880), then back to the top339  Poke(p,$42) PokeC(p+1,scrn+880)340  Poke(p+3,2)341  Poke(p+4,$41) PokeC(p+5,DLIST)342  ; tell the Atari to use our list,343  ; our characters and our players344  PokeC(560,DLIST)345  Poke(756,chb RSH 8)346  Poke(54279,ramtop) ; PMBASE347  Poke(53277,3)      ; GRACTL348  Poke(623,49)       ; players in front,349                     ; missiles = 5th,350                     ; P0 over P1 = both351                     ; colours ORed: his352                     ; socks, the wolf's353                     ; eye and teeth354  Poke(559,62)       ; one-line players355  Poke(704,$34) ; his red suit356  Poke(705,FUR) ; fur, or skin357  Poke(706,$02) ; claws; hair and shoes358  Poke(707,$86) ; her dress359  Poke(708,$06) ; clouds (then leaves)360  Poke(709,$0C) ; the moon; pale things361  Poke(710,$92) ; skyline (then wood)362  Poke(711,$26) ; her skin;363                ; the lit windows364  Poke(712,0)365  ; point the interrupt vector at366  ; page 6 and switch interrupts on367  PokeC(512,$600) Poke(54286,192)368RETURN369370; ---------- the two text lines ----------371372; show a message at the right of the373; upper text line, wiping the old one374PROC Msg(BYTE ARRAY s)375  Position(17,22)376  Print("                      ")377  Position(17,22) Print(s)378RETURN379380; print the score on the bottom line381PROC ShowScore()382  Position(7,23) PrintC(score)383RETURN384385; show whether he is WOLF or MAN386PROC ShowForm()387  Position(1,22)388  IF wolfm=1 THEN Print("WOLF")389  ELSE Print("MAN ") FI390RETURN391392; what the button will do just now393PROC ShowButton()394  BYTE b395  b=0396  IF wolfm=1 THEN397    IF lcool=0 AND leap=0 THEN b=1 FI398  ELSEIF called=0 THEN b=2 FI399  IF b<>bshown THEN400    bshown=b Position(6,22)401    IF b=1 THEN Print("LEAP")402    ELSEIF b=2 THEN Print("CALL")403    ELSE Print("    ") FI404  FI405RETURN406407; how far she is from the house, in408; steps of 16 dots (four characters).409; Printed only when it changes.410PROC ShowHome()411  BYTE n412  n=togo RSH 4413  IF n<>hshown THEN414    hshown=n Position(29,23)415    PrintB(n) Put(32)416  FI417RETURN418419; print both text lines afresh: the420; labels, the night, a heart for each421; life and all the numbers422PROC ShowAll()423  BYTE i424  Position(1,23) Print("SCORE")425  Position(14,23) Print("NIGHT ")426  PrintB(chase)427  Position(23,23) Print("HOUSE")428  Position(34,23) Print("     ")429  Position(34,23)430  ; character 0 is a heart431  FOR i=1 TO lives DO Put(0) OD432  ShowScore() ShowForm()433  hshown=255 ShowHome()434  bshown=255 ShowButton()435RETURN436437; --------------- the woods ---------------438439; the house, with its door four columns440; back from the newest column441PROC House()442  BYTE r,i443  CARD p444  ; clear a space 8 wide, rows 3-10445  FOR r=3 TO 10 DO446    Zero(mapb+r*256+gencol-7,8)447  OD448  ; p: the left end of the house in449  ; a map row. A row is 256 bytes,450  ; so p+256 is the cell below and451  ; p-252 is one row up, four along.452  p=mapb+1280+gencol-7   ; row 5453  Poke(p-252,104)        ; the chimney454  ; the roof: narrow, then wide455  Poke(p+2,93) Poke(p+3,94)456  Poke(p+4,94) Poke(p+5,95)457  p==+256458  Poke(p,93) Poke(p+7,95)459  FOR i=1 TO 6 DO Poke(p+i,94) OD460  ; three rows of wall (rows 7-9)461  FOR r=7 TO 9 DO462    p==+256463    FOR i=0 TO 7 DO Poke(p+i,96) OD464    IF r=7 THEN        ; lit windows:465      Poke(p+1,230) Poke(p+2,231)466      Poke(p+5,230) Poke(p+6,231)467    ELSEIF r=9 THEN    ; wide upstairs,468      Poke(p+1,225) Poke(p+6,225)469    FI                 ; narrow below470  OD471  ; the crooked door, two wide472  ; (p is in row 9; p-253 is row 8)473  Poke(p-253,98) Poke(p+3,99)474  Poke(p-252,100) Poke(p+4,101)475RETURN476477; a tree, a log, a bramble patch or a478; stump, in the three newest columns479PROC Thing()480  BYTE t,k481  CARD p482  ; pick a row from 2 to 18 in the483  ; newest column; give up if the484  ; cell to its left is taken485  p=mapb+(2+Rand(17))*256+gencol486  IF Peek(p-1)>GRASS THEN RETURN FI487  ; 5 times in 10 a tree, 2 a log,488  ; 2 brambles, 1 a stump489  t=Rand(10)490  IF t<5 THEN          ; a tree491    ; it needs room above: the crown492    ; is 3 wide and 2 high, over the493    ; trunk (p-256 is one row up,494    ; p-512 two)495    IF Peek(p-257)>GRASS496       OR Peek(p-513)>GRASS497    THEN RETURN FI498    k=81               ; in leaf, or499    IF Rand(4)=0 THEN k=105 FI ; bare500    Poke(p-514,k) Poke(p-513,k+1)501    Poke(p-512,k+2) Poke(p-258,k+3)502    Poke(p-257,k+4) Poke(p-256,k+5)503    Poke(p-1,TRUNK)504  ELSEIF t<7 THEN505    Poke(p-1,LOG) Poke(p,LOG+1)506  ELSEIF t<9 THEN507    Poke(p-1,BRAMBLE) Poke(p,BRAMBLE+1)508  ELSE Poke(p-1,STUMP) FI509RETURN510511; Once in a while, a white glove lies512; in the woods. Run over it for a513; burst of speed.514PROC Glove()515  CARD p516  ; only on bare ground or grass517  p=mapb+(2+Rand(16))*256+gencol518  IF Peek(p-1)<=GRASS AND Peek(p)<=GRASS519  THEN520    Poke(p-1,GLOVE) Poke(p,GLOVE+1)521  FI522RETURN523524; plant one more column of the woods,525; just off the right of the TV526PROC GenCol()527  BYTE r,k528  CARD p529  ; bare ground, with a tuft of grass530  ; now and then531  p=mapb+gencol532  FOR r=0 TO 18 DO533    IF Rand(14)=0 THEN Poke(p,GRASS)534    ELSE Poke(p,0) FI535    p==+256536  OD537  ; gleft counts down to the house.538  ; Until then every fourth column539  ; gets dens things, but not the540  ; first columns (quiet) or the541  ; last 12 before the house.542  IF gleft>0 THEN543    gleft==-1544    IF gleft=0 THEN House()545    ELSEIF gleft>12 AND quiet=0546       AND (gencol&3)=3547    THEN548      FOR k=1 TO dens DO Thing() OD549    FI550    ; one column in 32 has an even551    ; chance of a glove552    IF gleft>12 AND quiet=0553       AND (gencol&31)=17554    THEN555      IF Rand(2)=0 THEN Glove() FI556    FI557  FI558  IF quiet>0 THEN quiet==-1 FI559  gencol==+1560RETURN561562; The map is only 256 columns wide.563; When the TV gets near the end of it,564; move what is in view back to the565; start, and everybody with it.566PROC Wrap()567  BYTE r568  CARD p569  ; copy columns 200-255 to 0-55.570  ; 200 columns are 800 dots.571  p=mapb572  FOR r=0 TO 18 DO573    MoveBlock(p,p+200,56) p==+256574  OD575  cam==-800 hbx==-800 gbx==-800576  gencol==-200 lcol==-200577RETURN578579; The TV follows her, so she is always580; in sight, 88 dots from its left581; edge. He has to keep up: the left582; edge of the TV carries him along.583PROC Scroll()584  BYTE i,d585  CARD p586  ; has she run ahead? move the TV587  IF gbx>cam+88 THEN588    d=gbx-cam-88 cam==+d fpos==+d589  FI590  ; keep him on the TV591  IF hbx<cam+4 THEN hbx=cam+4 FI592  IF hbx>cam+150 THEN hbx=cam+150 FI593  ; Four dots to a character: the594  ; whole columns go into the display595  ; list (lcol) and the odd dots into596  ; the fine scroll. The -4 is there597  ; because a scrolling row is 48598  ; wide and starts four characters599  ; to the left of the TV picture.600  lcol=((cam+3) RSH 2)-4601  IF lcol>=200 THEN Wrap() FI602  ; plant ahead: 52 columns from lcol603  WHILE gencol<lcol+52 DO GenCol() OD604  ; the same column for all 19 rows605  p=LMS606  FOR i=0 TO 18 DO607    Poke(p,lcol) p==+3608  OD609  gfine=(4-(cam&3))&3610  ; the skyline goes by at half speed611  ; (it is the same four characters612  ; over and over, so 16 dots of613  ; fine scroll go round for ever)614  ffine=(16-((fpos RSH 1)&15))&15615RETURN616617; what is on the ground under a figure618; whose picture starts at line y?619BYTE FUNC Cell(CARD x BYTE y)620  BYTE r621  ; x is in dots, four to a column622  x=x RSH 2623  IF x>=gencol THEN RETURN (0) FI624  ; Players count lines from 32 at625  ; the top of the TV, and the woods626  ; start 24 lines down. So y-33 is627  ; a line near the feet of a figure628  ; 26 lines high. 8 lines to a row.629  r=(y-33) RSH 3630RETURN (Peek(mapb+r*256+x))631632; 1 if character c blocks the way: a633; tree trunk or a stump634BYTE FUNC Solid(BYTE c)635  IF c=TRUNK OR c=STUMP THEN636    RETURN (1) FI637RETURN (0)638639; ---------------- the sky ----------------640641; Build the sky: 80 bytes, two rows of642; 40, with stars and the moon (four643; characters). skyb keeps a copy with644; no clouds. Then the skyline.645PROC Sky()646  BYTE i647  Zero(skyb,80)648  FOR i=1 TO 12 DO649    skyb(Rand(80))=STAR650  OD651  skyb(6)=67 skyb(7)=68  ; the moon652  skyb(46)=69 skyb(47)=70653  MoveBlock(scrn,skyb,80)654  ; 48 characters: a scrolling row655  ; is wider than the TV656  FOR i=0 TO 47 DO       ; the skyline657    Poke(scrn+80+i,77+(i&3))658  OD659RETURN660661; the moon comes out (w=1) or goes in662; Called by Clouds. Sets his colour,663; a sound and a message. flash makes664; his suit flicker for 16 frames.665PROC Change(BYTE w)666  wolfm=w leap=0 flash=16667  IF w=1 THEN668    Poke(705,FUR) Sfx(SHOWL,40)669    Msg("THE MOON! RUN, WOLF!")670  ELSE671    Poke(705,SKIN) Sfx(SWHIM,20)672    called=0673    Msg("CLOUDS... JUST A MAN")674  FI675  ShowForm()676RETURN677678; The clouds drift to the left, a679; column at a time. ccx is a cloud's680; left end plus 16, so that it can be681; partly off the left of the TV.682PROC Clouds()683  BYTE i,k,x,n,cov684  ; only every cdel+1 frames685  IF ctm>0 THEN ctm==-1 RETURN FI686  ctm=cdel687  ; clean sky, then draw them again688  MoveBlock(scrn,skyb,80)689  cov=0690  FOR i=0 TO ncl-1 DO691    ccx(i)==-1 n=clen(i)692    IF ccx(i)+n<=16 THEN ; round again693      ccx(i)=56+Rand(40)694      n=5+Rand(cmax) clen(i)=n695    FI696    ; a cloud is two rows high: a697    ; left end, middles and a right698    ; end. Draw what is on the TV.699    FOR k=0 TO n-1 DO700      x=ccx(i)+k701      IF x>=16 AND x<56 THEN702        x==-16703        IF k=0 THEN704          Poke(scrn+x,71)705          Poke(scrn+40+x,74)706        ELSEIF k=n-1 THEN707          Poke(scrn+x,73)708          Poke(scrn+40+x,76)709        ELSE710          Poke(scrn+x,72)711          Poke(scrn+40+x,75)712        FI713      FI714    OD715    ; is it right over the moon?716    ; (the moon is columns 6 and 7:717    ; 22 and 23 with the 16 added)718    IF ccx(i)<=22 AND ccx(i)+n>=24719    THEN cov=1 FI720  OD721  ; moon just hidden, or just out?722  IF cov<>covered THEN723    covered=cov Change(1-cov)724  FI725RETURN726727; ------------ him and her ------------728729; draw him: pick the right picture and730; copy it into the three players that731; make him up732PROC DrawHero()733  CARD s734  BYTE y735  ; s: which picture. Each is 78736  ; bytes: 26 lines for each of the737  ; three players. Wolf: two running738  ; and one leaping (lifted by hop).739  ; Man: two walking.740  y=hy741  IF wolfm=1 THEN742    IF leap>0 THEN743      s=wolf+156 y=hy-hop(leap RSH 2)744    ELSE745      s=wolf+((hstep RSH 2)&1)*78746    FI747  ELSE748    s=hero+((hstep RSH 3)&1)*78749  FI750  ; A player has 256 bytes, one for751  ; each line of the TV. Player 0 is752  ; at pmb+1024, 1 at +1280, 2 at753  ; +1536. Putting 26 bytes at +y754  ; draws them from line y down.755  IF y<>hpy THEN   ; wipe the old one756    Zero(pmb+1024+hpy,26)757    Zero(pmb+1280+hpy,26)758    Zero(pmb+1536+hpy,26)759    hpy=y760  FI761  MoveBlock(pmb+1024+y,s,26)762  MoveBlock(pmb+1280+y,s+26,26)763  MoveBlock(pmb+1536+y,s+52,26)764RETURN765766; as a man he can call to her767; (once each time he is a man). She768; stops for 45 frames.769PROC Call()770  called=1 Sfx(SCALL,16)771  gstop=45 Msg("SHE KNOWS YOUR VOICE")772RETURN773774; the wolf has run into a log: he is775; stunned for 25 frames. hfree gives776; him 60 frames in which he cannot777; trip again.778PROC Trip()779  stun=25 hfree=60 Sfx(STRIP,10)780  Msg("TRIPPED ON A LOG!")781RETURN782783; he picks up the glove under his feet784PROC Take()785  BYTE r786  CARD p787  ; find the map cell under him788  r=(hy-33) RSH 3789  p=mapb+r*256+((hbx+4) RSH 2)790  ; a glove is two characters: wipe791  ; both792  IF Peek(p)=GLOVE+1 THEN p==-1 FI793  Poke(p,0) Poke(p+1,0)794  ; 200 frames of speed, and 50795  ; points for picking it up796  boost=200 score==+50 ShowScore()797  Sfx(SGLOVE,24)798  Msg("THE GLOVE! FASTER!")799RETURN800801; Move him, once a frame: read the802; stick and button, work out his speed803; from what he is and what is804; underfoot, then move if no tree is805; in the way.806PROC Hero()807  BYTE s,c,spd,d808  CARD nx809  ; s is the stick. Stunned: no810  ; stick. Leaping: the stick is811  ; forced right (7) for 24 frames,812  ; then 45 frames before the next.813  ; Otherwise the button leaps (wolf)814  ; or calls (man, once).815  s=Stick(0)816  IF stun>0 THEN stun==-1 s=15817  ELSEIF leap>0 THEN818    leap==-1 s=7   ; straight ahead819    IF leap=0 THEN lcool=45 FI820  ELSE821    IF lcool>0 THEN lcool==-1 FI822    IF Strig(0)=0 THEN823      IF wolfm=1 THEN824        IF lcool=0 THEN825          leap=24 s=7 Sfx(SLEAP,12)826        FI827      ELSEIF called=0 THEN Call() FI828    FI829  FI830  ; a glove under him?831  c=Cell(hbx+4,hy)832  IF c=GLOVE OR c=GLOVE+1 THEN833    Take() FI834  ; speed: wolf 32, man 16, a leap835  ; 44. On the ground, brambles836  ; halve it; a log slows the man to837  ; 6 and trips the wolf.838  IF wolfm=1 THEN spd=32 ELSE spd=16 FI839  IF leap>0 THEN spd=44840  ELSE             ; what is underfoot?841    c=Cell(hbx+4,hy)842    IF c=BRAMBLE OR c=BRAMBLE+1 THEN843      spd=spd RSH 1844    ELSEIF c=LOG OR c=LOG+1 THEN845      IF wolfm=0 THEN spd=6846      ELSEIF hfree=0 AND stun=0 THEN847        Trip() s=15848      FI849    FI850  FI851  IF hfree>0 THEN hfree==-1 FI852  ; the glove: half as fast again853  IF boost>0 THEN854    spd=spd+(spd RSH 1) FI855  ; speeds are sixteenths of a dot856  ; hacc adds them up; d is the whole857  ; dots to move this frame858  hacc==+spd d=hacc RSH 4 hacc==&15859  ; hstep picks the walking picture860  IF s<>15 THEN hstep==+1 FI861  ; right (stick bit 8 is clear):862  ; look at the cell at his front863  IF (s&8)=0 THEN864    nx=hbx+d865    IF Solid(Cell(nx+6,hy))=1 THEN866      IF leap>0 THEN ; into a tree!867        leap=0 lcool=45 stun=30868        Sfx(STRIP,10)869      FI870    ELSE hbx=nx FI871  ; left, but not off the TV872  ELSEIF (s&4)=0 AND hbx>cam+4+d THEN873    nx=hbx-d874    IF Solid(Cell(nx+1,hy))=0 THEN875      hbx=nx FI876  FI877  ; up and down, two lines a frame,878  ; inside the woods (lines 50-180)879  IF (s&1)=0 AND hy>50 THEN880    IF Solid(Cell(hbx+4,hy-2))=0 THEN881      hy==-2 FI882  FI883  IF (s&2)=0 AND hy<180 THEN884    IF Solid(Cell(hbx+4,hy+2))=0 THEN885      hy==+2 FI886  FI887  DrawHero()888RETURN889890; She runs for the house. She goes891; round trees, shies away from the892; wolf when he is close, and stumbles893; a little in logs and brambles. The894; wolf is only a shade faster than a895; frightened girl: he has to leap.896; Near the house she falters.897PROC Girl()898  BYTE c,d,w899  CARD nx,s900  ; standing still after his call?901  IF gstop>0 THEN gstop==-1902  ELSE903    ; w: 1 = step up, 2 = step down.904    ; A tree 8 or 12 dots ahead: pick905    ; a way round and keep to it.906    w=0907    IF Solid(Cell(gbx+8,gy))=1908       OR Solid(Cell(gbx+12,gy))=1909    THEN               ; a tree ahead910      IF gdodge=0 THEN911        IF gy>112 THEN gdodge=1912        ELSE gdodge=2 FI913      FI914      w=gdodge915    ELSE916      ; clear ahead. Every other917      ; frame: near the house, make918      ; for the door's level (110).919      ; If the wolf is close behind920      ; and level, edge away.921      gdodge=0 gstuck=0922      IF (frm&1)=0 THEN923        IF togo<240 THEN ; the door!924          IF gy>110 THEN w=1925          ELSEIF gy<110 THEN w=2 FI926        ELSEIF wolfm=1 AND hbx+56>gbx927           AND hy+12>gy AND gy+12>hy928        THEN929          IF hy<gy THEN w=2930          ELSE w=1 FI931        ELSEIF (frm&7)=0 THEN932          ; back toward the middle933          IF gy>110 THEN w=1934          ELSEIF gy<110 THEN w=2 FI935        FI936      FI937    FI938    ; take the step, unless a tree is939    ; there. At the edge of the940    ; woods, go round the other way.941    IF w=1 THEN942      IF gy<=50 THEN gdodge=2943      ELSEIF Solid(Cell(gbx+4,gy-2))=0944      THEN gy==-2 FI945    ELSEIF w=2 THEN946      IF gy>=180 THEN gdodge=1947      ELSEIF Solid(Cell(gbx+4,gy+2))=0948      THEN gy==+2 FI949    FI950    ; her speed this frame951    c=Cell(gbx+4,gy)952    d=gspd953    ; with the wolf at her heels she954    ; finds a little more speed955    IF wolfm=1 AND hbx+48>gbx THEN956      d=pan FI957    ; logs and brambles halve it; so958    ; does faltering near the house959    IF c>=LOG AND c<=BRAMBLE+1 THEN960      d=d RSH 1 FI961    IF togo<fal THEN d=d RSH 1 FI962    ; (sixteenths of a dot, as his)963    gacc==+d d=gacc RSH 4 gacc==&15964    nx=gbx+d965    ; blocked by a tree: wait, but966    ; after 20 frames go through.967    ; togo counts down to the door.968    IF Solid(Cell(nx+6,gy))=1969       AND gstuck<20970    THEN gstuck==+1971    ELSE972      gbx=nx gstep==+1973      IF togo>d THEN togo==-d974      ELSE togo=0 FI975    FI976  FI977  ; her picture: looking back, or one978  ; of two running. 26 bytes go to979  ; player 3 (pmb+1792) and 26 to980  ; the missiles (pmb+768).981  IF gstop>0 THEN s=girll982  ELSE s=girl+((gstep RSH 2)&1)*52 FI983  IF gy<>gpy THEN984    Zero(pmb+1792+gpy,26)985    Zero(pmb+768+gpy,26)986    gpy=gy987  FI988  MoveBlock(pmb+1792+gy,s,26)989  MoveBlock(pmb+768+gy,s+26,26)990RETURN991992; put the players where the TV now is993; 48 is the players' number for the994; left edge of the TV picture.995PROC Place()996  BYTE x997  x=hbx-cam+48998  ; (position 0 is off the TV, so he999  ; blinks while stunned)1000  IF (stun&2)=2 THEN x=0 FI ; dazed1001  hposp0=x hposp1=x hposp2=x1002  ; her: player 3, and the four1003  ; missiles side by side, each two1004  ; dots wide1005  x=gbx-cam+481006  hposp3=x hposm3=x hposm2=x+21007  hposm1=x+4 hposm0=x+61008  IF flash>0 THEN  ; he is changing1009    flash==-11010    IF (flash&2)=2 THEN Poke(704,$3E)1011    ELSE Poke(704,$34) FI1012  ELSEIF boost>0 THEN ; the glove: his1013    boost==-1         ; suit shimmers1014    IF (boost&4)=4 THEN Poke(704,$3E)1015    ELSE Poke(704,$34) FI1016  FI1017RETURN10181019; reaching her is enough, as a wolf or1020; as a man1021; (within 7 dots and 14 lines). Sets1022; got, which ends the main loop.1023PROC Touch()1024  IF stun=01025     AND hbx+7>gbx AND gbx+7>hbx1026     AND hy+14>gy AND gy+14>hy1027  THEN got=1 FI1028RETURN10291030; ------------- sound -------------10311032; play one frame of the sound effect1033; on voice 3. sfxt counts down, and1034; most effects slide in pitch with it.1035PROC Effect()1036  BYTE t1037  sfxt==-11038  IF sfx=SLEAP THEN   ; a rush of air1039    Sound(3,20+sfxt*4,8,6)1040  ELSEIF sfx=STRIP THEN ; a thump1041    Sound(3,250-sfxt*12,10,10)1042  ELSEIF sfx=SHOWL THEN ; the howl1043    t=40-sfxt1044    IF t<12 THEN Sound(3,120-t*6,10,10)1045    ELSE Sound(3,36+t,10,10) FI1046  ELSEIF sfx=SWHIM THEN ; a whimper1047    Sound(3,160-sfxt*5,10,8)1048  ELSEIF sfx=SGLOVE THEN ; a sparkle1049    Sound(3,30+sfxt*3,10,8)1050  ELSEIF sfxt>8 THEN  ; "hey!"1051    Sound(3,60,10,10)1052  ELSE Sound(3,45,10,10) FI1053  IF sfxt=0 THEN sfx=0 FI1054RETURN10551056; the band, called once a frame: bass1057; on voice 0, lead on 1, its echo on 2,1058; drums or a sound effect on 3. The1059; lead only plays for the wolf.1060PROC Music()1061  BYTE b,l,e,d1062  ; between steps, let the notes fade1063  IF mtm>0 THEN1064    mtm==-11065    IF bvol>3 THEN bvol==-1 FI1066    IF lvol>4 AND (mtm&1)=0 THEN1067      lvol==-1 FI1068  ELSE1069    ; a new step of the tune. In the1070    ; tables 0 is silence, 1 holds the1071    ; note, anything else is a new1072    ; note. The echo is the lead,1073    ; three steps late.1074    mtm=tempo-11075    b=bass(mpos) l=lead(mpos)1076    e=lead((mpos-3)&127)1077    d=drum(mpos&15)1078    IF b=0 THEN bvol=01079    ELSEIF b>1 THEN bnote=b bvol=8 FI1080    IF l=0 THEN lvol=01081    ELSEIF l>1 THEN lnote=l lvol=8 FI1082    IF e=0 THEN evol=01083    ELSEIF e>1 THEN enote=e evol=3 FI1084    ; drums: 1 kick, 2 snare, 3 hat1085    IF d=1 THEN dtyp=1 dvol=12 dpit=1001086    ELSEIF d=2 THEN dtyp=2 dvol=91087    ELSEIF d=3 THEN dtyp=3 dvol=4 FI1088    mpos=(mpos+1)&1271089  FI1090  ; send it all to the sound chip1091  Sound(0,bnote,12,bvol)1092  IF wolfm=1 THEN1093    Sound(1,lnote,10,lvol)1094    Sound(2,enote,10,evol)1095  ELSE1096    Sound(1,0,0,0) Sound(2,0,0,0)1097  FI1098  ; voice 3: an effect if there is1099  ; one, else the drum dying away1100  IF sfx>0 THEN Effect()1101  ELSEIF dvol>0 THEN1102    IF dtyp=1 THEN    ; kick1103      Sound(3,dpit,10,dvol)1104      dpit==+45 dvol==-41105    ELSEIF dtyp=2 THEN ; snare1106      Sound(3,14,8,dvol) dvol==-31107    ELSE              ; hat1108      Sound(3,1,8,dvol) dvol=01109    FI1110  ELSE Sound(3,0,0,0) FI1111RETURN11121113; start the tune from the top, with1114; every voice silent1115PROC MusicOn()1116  mpos=0 mtm=0 bvol=0 lvol=0 evol=01117  dvol=0 sfx=01118RETURN11191120; The digitized laugh: see screen 2.1121; Each byte holds two samples of four1122; bits, poked into two channels as1123; plain volume levels, about 4,000 a1124; second.1125PROC Laugh(BYTE n)1126  CARD i,c,fs,st1127  BYTE b,v,d,k,o,p1128  BYTE ARRAY ft(128)1129  ; ft: the 16 levels at 1/8 to 8/81130  ; of full strength, 16 to a row,1131  ; shrunk toward the middle level 81132  FOR k=1 TO 8 DO1133    FOR v=0 TO 15 DO1134      IF v<8 THEN d=8-((8-v)*k+4)/81135      ELSE d=8+((v-8)*k+4)/8 FI1136      ft((k-1)*16+v)=$10%d1137    OD1138  OD1139  ; n=1: once, fading over its last1140  ; quarter. n=2: once at full strength1141  ; (row 112), then again, fading all1142  ; the way through. st is where the1143  ; fade starts; it drops a row every1144  ; fs bytes.1145  IF n=1 THEN fs=LAUGHLEN/281146  ELSE fs=LAUGHLEN/7 FI1147  o=1121148  FOR p=1 TO n DO1149    st=LAUGHLEN c=fs-11150    IF p=n THEN st=LAUGHLEN-fs*7 FI1151    FOR i=0 TO LAUGHLEN-1 DO1152      b=laugh(i)1153      v=ft(o+(b RSH 4)) audc1=v audc2=v1154      FOR d=1 TO 9 DO OD1155      v=ft(o+(b&15)) audc1=v audc2=v1156      FOR d=1 TO 9 DO OD1157      IF i>=st THEN1158        c==+11159        IF c=fs THEN1160          c=01161          IF o>0 THEN o==-16 FI1162        FI1163      FI1164    OD1165  OD1166  audc1=0 audc2=01167RETURN11681169; ------------- the game -------------11701171; how hard is tonight?1172; Called before each try. chase is the1173; night; ease softens it.1174PROC NewChase()1175  ; she is quicker every night; on1176  ; night 7 she is as fast as the wolf,1177  ; after that a shade faster, and only1178  ; a leap will close the gap1179  gspd=25+chase1180  IF gspd>33 THEN gspd=33 FI1181  ; (slower after each lost try)1182  gspd==-ease1183  ; her speed with the wolf at her heels1184  pan=gspd+31185  IF pan<30 THEN pan=30 FI1186  ; more trees and logs1187  dens=21188  IF chase>2 THEN dens=3 FI1189  IF chase>4 THEN dens=4 FI1190  IF chase>6 THEN dens=5 FI1191  ; less far to the house1192  IF chase<9 THEN glen=900-chase*501193  ELSE glen=450 FI1194  ; and she falters later, near the door1195  IF chase<8 THEN fal=130-chase*101196  ELSE fal=50 FI1197  ; clouds: faster, more, longer1198  cdel=24-chase*21199  IF chase>5 THEN cdel=14 FI1200  ncl=21201  IF chase>3 THEN ncl=3 FI1202  cmax=3+chase1203  IF cmax>8 THEN cmax=8 FI1204  ; and the music speeds up1205  tempo=61206  IF chase>4 THEN tempo=5 FI1207  ; the colour the first interrupt1208  ; gives the leaves and the grass1209  ; ($60A is a byte inside its code)1210  Poke($60A,leaf((chase-1)&3))1211RETURN12121213; set everybody out for another try1214PROC Round()1215  ; wipe the missiles and all four1216  ; players (1280 bytes) and the map1217  ; (19 rows of 256)1218  Zero(pmb+768,1280)1219  Zero(mapb,4864)1220  ; the TV at the start of the map;1221  ; 46 bare columns; glen to plant1222  cam=16 lcol=0 gencol=0 fpos=01223  quiet=46 gleft=glen1224  ; him at dot 24, a wolf1225  hbx=24 hy=110 hpy=110 hacc=0 hstep=01226  wolfm=1 leap=0 lcool=0 stun=01227  hfree=0 called=0 flash=0 boost=01228  ; her 80 dots ahead1229  gbx=104 gy=110 gpy=110 gacc=01230  gstep=0 gstop=0 gstuck=0 gdodge=01231  ; the door is 5 columns back from1232  ; the last one planted; togo is1233  ; her distance from it in dots1234  togo=(glen-5)*4-gbx1235  got=0 covered=0 ctm=cdel1236  ; three clouds, right of the moon1237  ccx(0)=42 clen(0)=71238  ccx(1)=76 clen(1)=61239  ccx(2)=110 clen(2)=81240  Poke(705,FUR)1241  Sky() Scroll() ShowAll()1242  Msg("THE HOUSE IS HAUNTED!")1243  MusicOn()1244RETURN12451246; He has reached her. The spell breaks:1247; he is himself again, and she is safe.1248PROC Saved()1249  BYTE i,pounce1250  SndRst()1251  ; was he in mid leap?1252  pounce=leap1253  ; a man again1254  wolfm=0 leap=0 Poke(705,SKIN)1255  DrawHero() ShowForm()1256  ; she turns, and holds out her arms1257  MoveBlock(pmb+1792+gy,girll+156,26)1258  MoveBlock(pmb+768+gy,girll+182,26)1259  IF pounce>0 THEN1260    Msg("A FLYING TACKLE! +50")1261  ELSE1262    Msg("IT'S YOU! SHE IS SAFE")1263  FI1264  ; HAPPOKEY.ACT, 3.2 seconds of music1265  ; on the sound chip's four voices,1266  ; once through: a table of 193 rows,1267  ; one for each sixtieth of a second.1268  ; HpTick() pokes the next row into1269  ; the sound registers and clears1270  ; hpon after the last. i counts the1271  ; frames.1272  i=01273  HpStart()1274  WHILE hpon<>0 DO1275    Frame()1276    HpTick()1277    i==+11278    Poke(704,$30+(i&14)) ; the change1279  OD1280  SndRst()1281  Poke(704,$34)1282  ; 100 points for saving her, 21283  ; more for every 16 dots she was1284  ; still short of the door (the1285  ; HOUSE number), and 50 for1286  ; catching her with a leap1287  score==+100+(togo RSH 4)*21288  IF pounce>0 THEN score==+50 FI1289  ShowScore()1290RETURN12911292; she is through the door, and whoever1293; lives there is delighted1294PROC Taken()1295  BYTE i1296  SndRst()1297  Msg("THE HOUSE HAS HER!")1298  ; she is gone from the picture1299  Zero(pmb+1792,256) Zero(pmb+768,256)1300  FOR i=0 TO 30 DO     ; it slams1301    Frame()1302    IF i<10 THEN Sound(0,200,8,14-i)1303    ELSE SndRst() FI1304  OD1305  ; twice for his last life1306  IF lives=1 THEN Laugh(2)1307  ELSE Laugh(1) FI1308  ; a life lost: rub out one heart1309  lives==-11310  Position(34+lives,23) Put(32)1311RETURN13121313; Back to the title program, which1314; shows the card for the next screen1315; and loads it. (The loading is not1316; written: under DOS 2.0S it is a1317; binary load of D:THRILLER.OBJ and a1318; jump to its start.)1319PROC Next()1320  ; interrupts and players off, and1321  ; all eight moved off the TV1322  SndRst()1323  Poke(54286,64) Poke(53277,0)1324  hposp0=0 hposp1=0 hposp2=0 hposp3=01325  hposm0=0 hposm1=0 hposm2=0 hposm3=01326RETURN13271328; All lives are gone. If the title1329; program ran us, wait three seconds1330; and hand back with result=0. If1331; not, wait for the START key.1332PROC GameOver()1333  BYTE i1334  IF chain=1 THEN1335    Msg("GAME OVER")1336    FOR i=0 TO 180 DO Frame() OD1337    result=0 Next()1338  ELSE1339    Msg("GAME OVER: PRESS START")1340    DO Frame() UNTIL consol=6 OD1341  FI1342RETURN13431344; The title page, shown only when this1345; screen is run by itself: big text,1346; the tune, and a wait for START.1347PROC Title()1348  ; interrupts and players off1349  Poke(54286,64) Poke(53277,0)1350  hposp0=0 hposp1=0 hposp2=0 hposp3=01351  hposm0=0 hposm1=0 hposm2=0 hposm3=01352  ; big text (GRAPHICS 2, no window)1353  ; in the Atari's own characters1354  Graphics(18) Poke(756,224)1355  Poke(708,$36) Poke(709,$0E)1356  Poke(710,$C8) Poke(711,$1A)1357  Position(6,1) PrintD(6,"THRILLER")1358  Position(5,3) PrintD(6,"screen one")1359  Position(3,5)1360  PrintD(6,"SAVE YOUR GIRL")1361  Position(6,6)1362  PrintD(6,"FROM THE")1363  Position(3,7)1364  PrintD(6,"HAUNTED HOUSE!")1365  Position(4,9) PrintD(6,"press start")1366  Position(0,11)1367  PrintD(6,"designed 1984 d.lutz")1368  ; play the tune until START (wolfm1369  ; is set so that the lead plays)1370  MusicOn() tempo=6 wolfm=11371  DO1372    Frame() Music()1373    IF (frm&3)=0 THEN ; the title drips1374      Poke(708,$32+Rand(4)*2) FI1375  UNTIL consol=6 OD1376  SndRst()1377RETURN13781379; The whole game. One pass of the1380; inner loop is one TV frame; the1381; loop round it is one try at a1382; night; the outer one is one game.1383PROC Main()1384  Init()1385  DO1386    ; run by itself: title, new game1387    IF chain=0 THEN1388      Title() score=0 lives=3 wins=01389    FI1390    Screen() ease=01391    DO1392      ; wins/3+1: the night number1393      chase=wins/3+1 NewChase()1394      Round()1395      DO1396        ; one TV frame1397        Frame()1398        Hero() Girl() Scroll() Place()1399        Touch() Clouds() Music()1400        ShowHome() ShowButton()1401      UNTIL got=1 OR togo=0 OD1402      ; he touched her: a win1403      IF got=1 THEN1404        Saved()1405        ; run from the title program:1406        ; one more screen won; go back1407        IF chain=1 THEN1408          wins==+1 result=1 Next()1409          RETURN1410        FI1411        ; by itself: a harder night1412        ; (wins+3 is one more night)1413        wins==+3 ease=01414      ELSE1415        ; she got home: a life lost,1416        ; and the next try is easier1417        Taken()1418        IF ease<2 THEN ease==+1 FI1419      FI1420    UNTIL lives=0 OD1421    GameOver()1422    IF chain=1 THEN RETURN FI1423  OD1424RETURN