--- title: "Money Pail" id: 53807 type: "computer_media" slug: "money-pail" url: "http://localhost/computer_media/money-pail/" markdown_url: "http://localhost/computer_media/money-pail.md" published_at: "2024-05-13T18:56:53+00:00" modified_at: "2026-03-30T21:44:08+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2019/02/20230809-041332.jpg" excerpt: "Dollar bills rain from the sky — move your pail with two keys, catch up to five bills, then rush to the bank before more money falls past you." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" genre: - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_contents: - id: 53877 title: "SINCUS Exchange Tape 101 – Entertainment" type: "computer_media" url: "http://localhost/computer_media/sincus-exchange-tape-101-entertainment/" - id: 54965 title: "ISTUG Public Domain Library 5" type: "computer_media" url: "http://localhost/computer_media/istug-public-domain-library-5/" - id: 55430 title: "Timex Sinclair Public Domain Library Tape 2004" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-2004/" media_type: "Program" images: - url: "http://localhost/wp-content/uploads/2024/05/money-pail-2.png" - url: "http://localhost/wp-content/uploads/2024/05/money-pail-1.png" media_type_tags: "Game" --- Money Pail is a catching game in which dollar bills of random denominations fall from the top of the screen and the player moves a pail left and right using the N and M keys to collect them. The pail has a capacity of five bills before it must be taken to a bank column on the right side of the screen, which is triggered automatically when the pail reaches column 27. Eight user-defined graphics (UDGs \a through \h) are loaded from DATA statements to draw the pail sprite and a progressive fill animation representing the bank vault. The SOUND statement is used extensively for audio feedback, including a multi-channel coin-collection fanfare and movement beeps whose pitch corresponds to the vertical position of the falling bill. Skill level selection adjusts two variables, `d` (BEEP delay) and `h` (starting row for the drop loop), controlling both fall speed and how early bills become visible. *** ## Program Analysis ### Program Structure The code is organized into clearly separated functional blocks accessed via `GO SUB`: - **Lines 1–10:** Startup beep and entry jump to the main initialization routine at line 1000. - **Lines 100–150:** Score/collection subroutine — awards a point, plays a SOUND fanfare, and updates the pail graphic. - **Lines 200–230:** Bank subroutine — resets the score counter, accumulates total, animates the bank filling up, and plays a two-tone beep. - **Lines 1000–1060:** Main game initialization: calls UDG loader (6000), calls intro/skill screen (4000), sets border/paper/ink, initializes variables, and draws the HUD. - **Lines 2000–2140:** Core game loop — 20 drops per round, each with a falling bill and player movement inner loop. - **Lines 3000–3040:** End-of-round handler — prompts for replay, loops back to line 1020 (skipping UDG reload). - **Lines 4010–4100:** Introduction screen, instructions, and skill level selector. - **Lines 6010–6050:** UDG definition loader — reads 8×8-byte bitmaps from DATA into UDGs \a through \h. - **Lines 9998–9999:** Save/verify block. ### User-Defined Graphics Eight UDGs (\a–\h) are defined at lines 6010–6036, each loaded by a dedicated `FOR` loop reading 8 bytes from the `DATA` block at line 6040. The 64 bytes encode eight tiles. UDGs \a, \b, \c form the three-character pail sprite displayed at line 21. UDG \d through \h appear to encode a progressive bar used in the bank fill animation at line 220, where successive `PRINT AT` statements walk upward from row 12 to row 2 in steps of 2 to simulate bills stacking. The DATA at line 6040 follows a clear pattern: each successive 8-byte group adds one more set bit column from the left (192, 0, 3, then increasing fill patterns), suggesting a partial-fill visual sequence rather than pictographic characters. ### Core Game Loop The outer loop (lines 2010–2140) iterates 20 times per round (`FOR a=1 TO 20`). Each iteration: 1. Picks a random denomination: `q=10*(INT(RND*9)+1)`, giving multiples of 10 from 10 to 90. The label `a$` is built as `"$"+CHR$(q/10+48)+"0"` — a three-character string like `$30`. 2. Picks a random horizontal column `c` in the range 3–24. 3. Runs an inner loop (`FOR b=h TO 20`) where the bill falls one row per iteration. The starting row `h` is set by the skill level, making harder levels start higher and therefore give less reaction time. 4. Inside the inner loop, player movement is handled inline: `LET p=p-(INKEY$="n")+(INKEY$="m")` with boundary clamping: `LET p=p+(p=0)-(p=28)`. 5. After the fall, checks for a bank visit (line 2115, `p=27`) and a catch (line 2120, `c=p+1 AND sc<5`). ### Key BASIC Idioms and Techniques - **Boolean arithmetic for movement clamping:**`p+(p=0)-(p=28)` exploits the fact that Sinclair BASIC returns −1 for true conditions; the expression effectively clamps `p` between 1 and 27 without IF statements. - **Inline INKEY$ polling:** Rather than a separate input-reading routine, INKEY$ is read directly inside the falling-bill loop, giving responsive controls without halting the drop animation. - **SOUND for multi-channel audio:** Line 100 uses a chained `SOUND` statement with channels 6–13 for a rich collection fanfare, followed by a silence command on channels 8–10. - **Dynamic score display via CHR$:** Line 110 constructs `b$` using `CHR$(146+sc)`, selecting a UDG that visually represents the fill level of the pail (sc ranging 0–5), providing a live capacity indicator. - **Skill-level encoding:** Line 4080 derives both fall speed (`d=7-2*VAL c$`) and starting row (`h=7-d`) from a single digit input, coupling animation speed and difficulty in one calculation. - **HUD using block graphics:** Line 1060 uses block graphic escapes (`\ :`, `\:`, `\:`) to draw bordered labels for PAIL, BILLS, and BANK scores on a single line. ### Anomalies and Notes - Line 2115 checks `p=27` for a bank visit; the right wall is clamped at `p=28` (exclusive), so column 27 is the effective rightmost reachable position, doubling as the bank trigger. This means the player cannot move right of the bank column without banking — a deliberate design constraint. - The variable `x` accumulates the dollar value caught (`x=x+10*VAL a$(2)`, extracting the digit character of the denomination), while `sc` counts bill count (max 5). These serve distinct display purposes: `x` for dollar amount shown in the HUD at column 7, `sc` for pail fill graphic. - Line 4050 uses `PAUSE 0` with no following INKEY$ check — it waits for any key press to exit the instructions screen, relying on PAUSE 0’s built-in keypress detection rather than a polling loop. - Line 3030 calls `GO SUB 4060` (skipping the intro text at 4010–4050) before restarting at 1020 (skipping UDG reload at 1000–1010), correctly avoiding redundant re-initialization on replay. - UDGs \d through \h are defined in the DATA at lines 6032–6036 but are not explicitly referenced elsewhere in the visible listing by name; they may be used implicitly through the `CHR$(146+sc)` calculation in line 110, as UDG \d corresponds to char 147 (144+3) and subsequent UDGs cover sc values 3–7. ### Variable Summary | Variable | Purpose | | --- | --- | | `sc` | Current number of bills caught (0–5) | | `x` | Dollar value of bills currently in pail | | `t` | Total banked dollar amount | | `p` | Pail horizontal column position | | `b$` | Three-char pail UDG sprite string | | `a$` | Current falling bill label (e.g. “$30”) | | `c` | Falling bill column | | `d` | Speed/delay factor (derived from skill level) | | `h` | Starting row for bill drop (derived from skill level) | | `q` | Denomination value (multiple of 10) | ## Source Code ``` 5 BEEP .3,20 10 GO TO 1000 100 LET sc=sc+1: SOUND 6,6;7,7;8,16;9,16;10,16;12,56;13,8: PAUSE 10: SOUND 8,0;9,0;10,0 110 LET b$=CHR$ 144+CHR$ (146+sc)+CHR$ 146 120 LET x=x+10*VAL a$(2): PRINT AT 0,7;x 150 RETURN 200 LET sc=0: LET t=t+x: LET x=0: PRINT AT 0,7;"00 ";AT 0,27;t: BEEP .05,48: BEEP .07,44 210 LET b$="\a\b\c": PRINT AT 21,28;b$ 220 FOR e=12 TO 2 STEP -2: PRINT AT e,29;"$";AT e+2,29;" ": NEXT e: PRINT AT 2,29;" " 230 RETURN 1000 GO SUB 4000 1010 GO SUB 6000 1020 BORDER 2: PAPER 7: INK 0: CLS 1025 LET b$="\a\b\c" 1030 PRINT AT 15,29;"B";TAB 29;"A";TAB 29;"N";TAB 29;"K";AT 21,29;AT 20,29;"^" 1040 LET t=0: LET p=14: LET sc=0: LET x=0 1050 PRINT AT 21,p;b$ 1060 PRINT AT 0,0;"\ :PAIL\: $00";TAB 10;"\ :BILLS\: 0";TAB 20;"\ :BANK\ :$00" 2000 REM DROP 2010 FOR a=1 TO 20 2040 LET q=10*(INT (RND*9)+1): LET a$="$"+CHR$ (q/10+48)+"0": LET c=INT (RND*22)+3: PRINT AT 0,17;21-a;" " 2060 REM GO 2070 FOR b=h TO 20: PRINT AT b,c;a$: BEEP d/100,b: LET p=p-(INKEY$="n")+(INKEY$="m"): LET p=p+(p=0)-(p=28): PRINT AT 21,p;" ";b$;" ";AT b,c;" ": NEXT b 2110 REM HIT 2115 IF p=27 THEN GO SUB 200 2120 IF c=p+1 AND sc<5 THEN GO SUB 100 2140 NEXT a 3000 REM END 3010 PRINT AT 10,5;"Press 'P' to try again" 3020 LET d$=INKEY$: IF d$<>"p" THEN GO TO 3020 3030 GO SUB 4060: GO TO 1020 3040 STOP 4010 INK 0: PAPER 7: BORDER 2: CLS 4020 PRINT AT 2,9;"\ .\..\..\..\..\..\..\..\..\..\..\. ";TAB 9;"\ :MONEY PAIL\: ";TAB 9;"\ '\''\''\''\''\''\''\''\''\''\''\' " 4030 PRINT AT 7,1;"If there were tens of dollars falling from the sky, how much of it could you catch with a small pail?";AT 12,1;"NOTE: Your pail only holds 5 bills. Take your money to the bank and come back for more.";AT 18,1;" USE KEYS N & M TO MOVE PAIL " 4040 PRINT AT 21,4;"Press ENTER to continue" 4050 PAUSE 0: CLS 4060 PRINT AT 3,7;"ENTER SKILL LEVEL:";AT 6,9;"(1) easy";TAB 9;"(2) so-so";TAB 9;"(3) hard";AT 10,5;" " 4070 LET c$=INKEY$: IF c$<"1" OR c$>"3" THEN GO TO 4070 4080 LET d=7-2*VAL c$: LET h=7-d 4090 PRINT ; FLASH 1;AT 13,11;"READY?"; FLASH 0 4095 PAUSE 60 4100 RETURN 6010 FOR n=0 TO 7: READ l: POKE USR "\a"+n,l: NEXT n 6020 FOR n=0 TO 7: READ m: POKE USR "\b"+n,m: NEXT n 6030 FOR n=0 TO 7: READ r: POKE USR "\c"+n,r: NEXT n 6032 FOR n=0 TO 7: READ e: POKE USR "\d"+n,e: NEXT n 6033 FOR n=0 TO 7: READ i: POKE USR "\e"+n,i: NEXT n 6034 FOR n=0 TO 7: READ o: POKE USR "\f"+n,o: NEXT n 6035 FOR n=0 TO 7: READ u: POKE USR "\g"+n,u: NEXT n 6036 FOR n=0 TO 7: READ y: POKE USR "\h"+n,y: NEXT n 6040 DATA 192,192,192,192,192,192,255,255,0,0,0,0,0,0,255,255,3,3,3,3,3,3,255,255,0,0,0,0,0,255,255,255,0,0,0,0,255,255,255,255,0,0,0,255,255,255,255,255,0,0,255,255,255,255,255,255,0,255,255,255,255,255,255,255 6050 RETURN 9998 CLEAR : SAVE "MoneyPail" LINE 1 9999 VERIFY "" ```