Kitchen Chaos

This file is part of and Timex Sinclair Public Domain Library Tape 2004. Download the collection to get this file.
Date: 1985
Type: Program
Platform(s): TS 2068
Tags: Game

This program implements a kitchen-themed arcade game called “Kitchen Chaos” in which the player moves a pan (using Z and X keys) at the bottom of the screen to catch falling eggs. Three separate “flights” of eggs follow waypoint paths stored as coordinate pairs in DATA statements at lines 710–730, with each egg’s position animated through a 48-element array read into the three-row array v(3,48). User-defined graphics (UDGs a through u, 21 characters total) are loaded via machine-code POKEs at line 1010, providing the sprites for the pan, falling eggs, kitchen scenery, and decorative elements. The screen layout uses PLOT/DRAW for geometric outlines and CIRCLE for a clock-like decoration, while a short musical tune with paired note/duration data is played at game-over using a nested BEEP/PAUSE loop at lines 3010–3045.


Program Analysis

Program Structure

The program is organized into clearly delineated sections connected by GO SUB and GO TO jumps:

  1. Initialization (lines 1–40): Declares all arrays, sets the high score, and calls the UDG loader.
  2. Data load (lines 55–61): RESTOREs to line 700 and fills the waypoint array v(3,48).
  3. Game reset (lines 90–190): Resets score, lives, position, and sprite counters, then draws the screen and optionally plays the title tune.
  4. Main game loop (lines 500–590): Iterates over three sprite channels (n=1 TO 3), moves each active sprite along its waypoint path, handles player input, and checks for collision.
  5. End-of-life handler (lines 600–650): Decrements lives, resets sprites, plays a sound flourish, and loops back to the game reset.
  6. Game-over screen (lines 660–699): Displays the title, final score, and high score, then waits for SPACE.
  7. Subroutines: Screen draw (900), score update (800), UDG loader (1000), and music player (3000/3010).
  8. UDG data (lines 1020–1110): Binary data for 21 UDG characters (a–u).
  9. Music data (line 3060): Note/pause pairs for the game-over tune.
  10. Debug/utility lines (9000–9010): Print all UDGs to stream 3 for visual checking; not reached in normal play.

Array Layout

ArraySizePurpose
v(3,48)3×48Waypoint coordinates (y,x pairs) for each of the three sprites
z(3)3Current index into each sprite’s waypoint list (steps by 2)
p(3)3INK color for each sprite (3, 6, 7)
i(3)3Active flag: 1 = sprite is moving, 0 = waiting for its start counter
s(3)3Frame counter threshold at which each sprite activates
d(3), e(3)3 eachPrevious draw position (row, col) used to erase the sprite’s last position

Sprite Animation Technique

Each of the three falling objects is represented by a two-cell tall UDG pair. The sprite positions are pre-encoded as (y, x) coordinate pairs stored in the v array, loaded from DATA at lines 710–730. On each iteration the pointer z(n) advances by 2, selecting the next waypoint. The previous screen position is stored in d(n) and e(n) and cleared with spaces before drawing at the new position (line 523), giving smooth flicker-free movement without CLS.

All three sprites share identical waypoint data (lines 710–730 are identical), so they follow the same path but are staggered by randomized activation counters s(2) and s(3) (line 130). Sprite 1 always activates immediately (i(1)=1, line 126).

UDG Loading

Line 1010 uses a single FOR loop from USR "a" to USR "u"+7 (covering all 21 UDG slots, 168 bytes) to POKE each byte read from DATA. This is the standard Spectrum/TS2068 UDG initialization idiom. The data at lines 1020–1110 contains the letter a embedded as a literal DATA value in several places (e.g., DATA 0,128,255,254,255,128,0,a,a,63,…), which would be read as the numeric variable a (initialized to 0 by default on the TS2068) — effectively substituting 0 for those bytes. This is either intentional (blank pixels) or an artifact of data entry using variable a as a shorthand for 0.

Collision Detection

Collision between a falling sprite and the pan is detected at line 531 by checking whether the sprite has reached row 17 (y=17) and whether the attribute at the cell one row below (ATTR (y+1,x)) is not equal to 7. Since the floor/pan area uses INK 7, a non-7 attribute at that position indicates the pan is not underneath, triggering the hit/death sequence. This attribute-based collision is a well-known Spectrum technique that avoids coordinate comparison.

Player Input and Pan Movement

Input is polled inside the sprite loop at lines 538–545. INKEY$ is checked without a PAUSE, so it is non-blocking. The pan (h column variable) jumps in increments of 10 columns (Z left, X right) clamped between 1 and 21, giving three discrete positions. The pan sprite is four UDG characters wide (UDGs \a\b\c\d) drawn at AT 18,h. The previous pan position is erased with four spaces at line 539 before redrawing at the new position.

Music and Sound

The game-over/title tune (subroutine at line 3000) reads note and pause pairs from line 3060. Each note is played with BEEP .1*pause,note followed by PAUSE pause and a short trailing BEEP .01,note. The variable le controls how many notes are played: 32 for the full tune (line 3005) or 13 for a short intro (line 170). A descending glissando (FOR f=60 TO 1 STEP -3) closes the sequence. In-game sound effects use short fixed-frequency BEEPs for movement and a rapid random-ink flash loop on collision (line 531).

Screen Construction

The kitchen background is built entirely in subroutine 900 using a combination of PRINT AT with block-graphic UDGs, PLOT/DRAW for geometric lines (window frame, counter edge), and CIRCLE for a clock face (line 973). Floor rows 19–21 are filled with solid-block characters (\:: = █) in INK 1 (blue). The high-score display at line 985 is updated each time the screen is redrawn.

Notable Anomalies and Notes

  • DIM z(3) is declared twice — at line 5 and again at line 15 — with no effect other than redundancy.
  • The DATA at lines 710–730 is identical for all three sprites, meaning all three objects follow exactly the same path. Variety comes only from staggered start times.
  • Line 537 is referenced as a GO TO target at line 513 (IF NOT i(n) THEN GO TO 537), but the next existing line is 538, which is functionally the same jump destination. The missing line 537 is harmless because GO TO to a non-existent line falls through to the next higher line.
  • Lines 9000–9010 are developer debug utilities that print all UDG characters to the lower screen stream; they are never reached during normal execution.
  • The scoring at line 810 awards 100*n points, making sprites 2 and 3 worth more than sprite 1 (200 and 300 vs. 100), adding difficulty incentive.

Content

Appears On

One of a series of library tapes compiled from multiple user groups.

Related Products

Related Articles

Related Content

Image Gallery

Kitchen Chaos

Source Code

    1 LET hi=1500
    2 REM  U S E 'Z' and 'X' T O M O V E  P A N.
    5 DIM v(3,48): DIM z(3)
   10 DIM p(3): LET p(1)=3: LET p(2)=6: LET p(3)=7
   15 DIM i(3): DIM z(3)
   17 DIM s(3)
   20 DIM d(3): DIM e(3)
   25 FOR f=1 TO 3: LET d(f)=8: LET e(f)=3: NEXT f
   30 RESTORE 1000
   40 GO SUB 1000
   55 RESTORE 700
   60 FOR g=1 TO 3: FOR f=1 TO 48
   61 READ v(g,f): NEXT f: NEXT g
   90 LET li=3
   95 LET sc=0
  100 REM variables
  110 LET h=1: LET h1=h
  115 FOR f=1 TO 3: LET z(f)=1: NEXT f
  120 LET c=0
  121 LET y=8
  122 LET x=3
  125 LET s(1)=1
  126 LET i(1)=1
  130 FOR f=2 TO 3: LET s(f)=INT (RND*60+40): NEXT f
  150 GO SUB 900
  170 LET le=13: GO SUB 3010
  190 GO TO 500
  500 REM loop
  501 LET c=c+1
  510 FOR n=1 TO 3
  511 IF c=s(n) THEN LET i(n)=1
  513 IF NOT i(n) THEN GO TO 537
  515 LET y=v(n,z(n)): LET x=v(n,z(n)+1): LET z(n)=z(n)+2
  520 PRINT INK p(n);AT y-1,x;CHR$ (146+2*n);AT y,x;CHR$ (147+2*n)
  523 PRINT AT d(n)-1,e(n);" ";AT d(n),e(n);" ": LET d(n)=y: LET e(n)=x
  531 IF y=17 AND ATTR (y+1,x)<>7 THEN FOR f=1 TO 10: PRINT INK RND*7;AT y+1,x;"\m\n";AT y,x;"  ";AT y-1,x;"  ": BEEP .001,50: NEXT f: GO TO 600
  535 IF z(n)=49 THEN LET z(n)=1: GO SUB 800: PRINT INK 4;AT 9,28;"  ";AT 10,28;"  ";AT 11,28;"\m\n": BEEP .1,-7: BEEP .01,20: PRINT AT 11,28;"  "
  538 IF INKEY$="" THEN GO TO 557
  539 PRINT INK 4;AT 18,h;"    "
  540 IF INKEY$="x" AND h<21 THEN LET h=h+10: BEEP .05,0
  545 IF INKEY$="z" AND h>1 THEN LET h=h-10: BEEP .05,-10
  557 PRINT INK 7;AT 18,h;"\a\b\c\d"
  560 NEXT n
  590 GO TO 500
  600 REM endgame
  610 LET li=li-1: PRINT AT 20,26;li: IF li=0 THEN GO TO 660
  615 FOR f=1 TO 3: LET z(f)=1: LET i(f)=0: NEXT f
  620 FOR f=1 TO 10: BEEP .01,f: NEXT f
  630 FOR f=60 TO 10 STEP -5: BEEP .01,f: NEXT f
  650 GO TO 100
  660 REM The End
  663 IF sc>hi THEN LET hi=sc
  665 FOR f=1 TO 3: LET z(f)=1: LET i(f)=0: NEXT f
  670 GO SUB 3000
  680 PAPER 0: BORDER 0: INK 7: CLS 
  690 FOR f=1 TO 3: PRINT : NEXT f
  692 PRINT "         K I T C H E N"
  693 PRINT 
  694 PRINT "           C H A O S"
  695 PRINT : PRINT TAB 8; INK 2; BRIGHT 1;"YOUR SCORE: ";SC
  696 PRINT INK 6;AT 16,5;"\e";AT 17,5;"\f"; INK 7;AT 16,24;"\i";AT 17,24;"\j"
  697 PRINT INK 6; PAPER 1; FLASH 1;AT 21,6;"PRESS SPACE TO PLAY"
  698 IF INKEY$=" " THEN BEEP .2,5: GO TO 90
  699 GO TO 698
  700 REM Data
  705 REM for flight
  706 REM __________
  710 DATA 8,3,9,3,11,3,13,3,15,3,17,3,15,4,13,5,11,6,10,8,11,10,13,11,15,12,17,13,15,14,13,16,12,18,13,20,15,22,17,23,15,24,13,25,11,27,10,29
  720 DATA 8,3,9,3,11,3,13,3,15,3,17,3,15,4,13,5,11,6,10,8,11,10,13,11,15,12,17,13,15,14,13,16,12,18,13,20,15,22,17,23,15,24,13,25,11,27,10,29
  730 DATA 8,3,9,3,11,3,13,3,15,3,17,3,15,4,13,5,11,6,10,8,11,10,13,11,15,12,17,13,15,14,13,16,12,18,13,20,15,22,17,23,15,24,13,25,11,27,10,29
  800 REM score
  810 LET sc=sc+(100*n): PRINT INK 7; BRIGHT 1;AT 20,11;sc
  820 IF n>1 THEN LET c=0: LET i(n)=0: LET s(n)=INT (RND*10)+1
  830 RETURN 
  900 REM screen
  908 PRINT INK 5;AT 7,12;"\s \s \s";AT 8,12;"\t \t \t"
  910 PAPER 0: BORDER 0: INK 4: CLS 
  920 PLOT 0,175: DRAW 60,0: DRAW 0,-48: DRAW -60,0: DRAW 0,48
  925 PLOT 8,168: DRAW 44,0: DRAW 0,-32: DRAW -44,0: DRAW 0,32
  927 PLOT 30,168: DRAW 0,-32
  928 PLOT 65,127: DRAW 70,0: DRAW 0,3: DRAW -70,0: DRAW 0,-3
  929 PLOT 61,175: DRAW 188,0
  930 PRINT AT 3,3;"o";AT 3,4;"o"
  935 PRINT INK 2; BRIGHT 1;AT 0,17;"\k"; INK 6;AT 1,17;"\l"
  940 FOR f=19 TO 21: PRINT INK 1;AT f,0;"\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::": NEXT f
  950 PRINT INK 7;AT 7,27;"\..\..\..\..\..";AT 8,27;"\..\..\::\::\::": FOR f=9 TO 13: PRINT INK 7;AT f,31;"\::": NEXT f: FOR f=14 TO 18: PRINT INK 7;AT f,27;"\::\::\::\::\::": NEXT f
  953 PRINT INK 3;AT 14,26;"\ ."
  955 PRINT INK 6;AT 13,27;"\a"; INK 5;AT 13,28;"\b\c\d"
  960 PRINT INK 7;AT 20,5;"SCORE:";sc
  970 PRINT INK 7;AT 20,20;"LIVES:";li
  973 CIRCLE INK 5;190,140,10: CIRCLE INK 5;190,140,12: INK 7: PLOT 190,140: DRAW 5,5: PLOT 190,140: DRAW -5,7
  975 PRINT INK 5;AT 4,9;"\o";AT 5,9;"\p"; INK 2;AT 4,10;"\q";AT 5,10;"\r"; INK 7;AT 4,11;"\o";AT 5,11;"\p"; INK 3;AT 4,12;"\q\q\o";AT 5,12;"\r\r\p"
  976 PRINT INK 7;AT 5,15;"\u"
  983 PLOT 210,165: DRAW 40,0: DRAW 1,-20: DRAW -3,-10: DRAW 3,-3: DRAW -37,0: DRAW -3,3: DRAW 1,20: DRAW -1,10
  985 PRINT INK 6;AT 2,28;"HI:"; INK 2;AT 3,27;hi
  990 RETURN 
 1000 REM udg
 1010 FOR g=USR "a" TO USR "u"+7: READ a: POKE g,a: NEXT g: RETURN 
 1020 DATA 0,128,255,254,255,128,0,a,a,63,255,45,255,7,3,1,0,255,a,a,a,a,128,255,0,255,250,244,232,a,24,240
 1030 DATA 24,60,124,a,108,111,a,124,112,124,122,58,a,28,34,99
 1040 DATA 0,54,127,255,231,215,74,195,231,255,254,116,36,66,195,0
 1050 DATA 252,244,a,122,74,202,234,122,29,125,61,a,a,a,a,127
 1060 DATA 24,a,60,36,60,36,60,126,251,253,a,a,a,a,122,60
 1070 DATA 8,0,26,25,8,35,51,1,0,134,106,96,74,24,32,0
 1080 DATA 254,130,146,186,146,162,170,178,162,186,146,186,162,186,130,124
 1090 DATA 254,a,a,a,a,a,a,a,a,a,a,a,a,a,a,124
 1100 DATA 24,36,24,a,a,a,a,a,a,52,122,a,a,a,52,24
 1110 DATA 60,36,a,24,36,60,a,a
 3000 REM tune
 3005 LET le=32
 3010 RESTORE 3000
 3020 FOR f=1 TO le: READ note: READ pause
 3030 BEEP .1*pause,note: PAUSE pause
 3035 BEEP .01,note
 3040 NEXT f
 3045 FOR f=60 TO 1 STEP -3: BEEP .01,f: NEXT f
 3050 RETURN 
 3060 DATA 8,2,5,2,8,4,8,2,5,2,8,4,10,2,8,2,6,2,5,2,3,2,5,2,6,2,5,1,6,1,8,2,1,2,1,1,1,1,1,2,1,1,3,1,5,1,6,1,8,4,8,2,3,2,3,2,6,2,5,2,3,2,1,8
 9000 PRINT #3;"\a\b\c\dabcd\ee\ff\gg\h \ii\jj\kk\ll\mm\nn\oo\pp\qq\rr\ss\tt\uu"
 9010 FOR n=144 TO 164: PRINT #3;CHR$ n,CHR$ (n-79): NEXT n
 9998 STOP 
 9999 SAVE "Kitchen" LINE 1

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top