Skip to content
A Day At The Animal Races (ZX Spectrum) by Marco's Retrobits cover

Video game

A Day At The Animal Races (ZX Spectrum) by Marco's Retrobits

March 12, 2023
Racing

About

A DAY AT THE ANIMAL RACES BASIC 10 Liner video game for the Sinclair ZX Spectrum by Marco "Marco's Retrobits" Varesio: https://retrobits.itch.io English language blog: https://retrobits.altervista.org Italian language blog: https://somebitsofme.altervista.org YouTube channel: https://youtube.com/@marcosretrobits Download/play: online https://retrobits.itch.io/animalrace10l Gameplay video: A Day At The Animal Races is a BASIC 10 liner version for the Sinclair ZX Spectrum 48K computer of the VIP Animal Race gambling videogame. The original game was programmed by Brian Astle for the CHIP-8 interpreter running on the COSMAC VIP computer and published in the RCA COSMAC VIP Game Manual in 1978. In this video ( ), you can see it in action on the Sinclair ZX Spectrum Next, running in my CHIP-8 virtual machine. How to play Five different animals race against one another and you have the chance to test your expertise at picking the winner. Wait until the animals are ready to start, then select an animal by pressing a number 1 through 5 and then Enter. Decide how much you want to bet (up to a limit of $9), then press that key, followed by Enter. You can change the selected animal by inputting an invalid bet. The selected animal and the corresponding number will be highlighted in cyan to remind you of your choice and the race will start. After the race is over, your winnings or losses will be computed and the new total displayed. Press Enter to start the the next race. You can win the game by accumulating $256 or more. Hints for expert players: all animals move at approximately the same speed, but they start from different positions. The odds for each animal are related to the starting position but include a random element. Some races favor the player and you should bet up to the limit on these. Some races are unfavorable and you should bet carefully on these. PROGRAM DESCRIPTION The program uses user-defined graphic characters (UDGs) to print and animate the animals. All UDGs available on the ZX Spectrum 16/48K (graphic characters "A" to "U") are used. In the 128K models, the last 2 UDG characters have been reserved for the "SPECTRUM" and "PLAY" keywords, so the game will not display correctly on these machines. Variables m Your money. b Your bet. s The selected animal. r Race result (0: race is not over; -1: you lost the race; 1: you won the race). c(5) Array storing the horizontal position (column) of each animal. a Animal iterator. i Loop iterator; frame counter. s$ String storing the user-defined graphic characters (UDGs) for the animals animations. For each animal, there are 5 characters; the first is used when the animal is still; the remaining 4 (3 for the elephant) define the sequence of characters printed when the animal is running. f$ For each animal, stores how many user-defined graphic characters (UDGs) are used for the running animation (3 for the elephant and 4 for other animals): "43444". Data is encoded as string for compactness. t$ Animals user-defined graphics data definitions, encoded as string. u$ Temporary string used for building t$. m$, n$ User messages. u, v Indices to access messages stored in n$. Program listing Please note that this program listing is formatted in order to be used with the bas2tap utility, which converts a BASIC listing in an ASCII text file to a .TAP emulator tape image. In particular, "{XX}" represents the character with code XX (hexadecimal). 1 LET t$="&%%%1---&%%%1--'&%%%1--4#bbb{60}HHG#bbb{60}HHK#bbb{60}HGe#bbb{60}HH7#&)17I####&)a'&##" 2 LET t$=t$+"#&)a')###&)a+/###.AaEE###.AaEC###.AaEd###.AaE%###.AaE7#":READ u$:LET t$=t$+u$ 3 BORDER 1:PAPER 1:INK 7:DIM c(5):FOR i=1 TO LEN t$:POKE USR"A"+i-1,CODE t$(i)-35:NEXT i:LET f$="43444":LET m$="You have $" 4 RESTORE 9:LET m=10:LET s$="{90}{91}{90}{92}{90}{93}{94}{95}{96} {97}{98}{99}{9A}{97}{9B}{9C}{9D}{9E}{9F}{A0}{A1}{A2}{A3}{A4}":LET n$="Race againYou win !You lose !" 5 CLS:FOR a=1TO5:LET c(a)=5*RND:PRINT AT a*2,0;a;AT a*2,INT c(a)+2;s$(1+5*(a-1)):NEXT a:PLOT 245,84:DRAW 0,80:LET i=0 6 LET a=1:INPUT (m$);(m);". Animal? ";s;" Bet? ";b:RANDOMIZE:GO TO 6+(s>0)*(s<6)*(b>0)*(b<=m)*(b<10) 7 LET c(a)=c(a)+RND:GO SUB 10:LET r=(c(a)>=28)*((a=s)-(a<>s)):LET i=i+(a=5):LET a=(a<5)*a+1:GO TO 7+(r<>0) 8 LET m=m+b*r:LET u=11+10*(r=-1):LET v=1+10*(m>254)+20*(m<1):PRINT AT21,0;n$(u TO u+8);"$";b,m$;m 9 INPUT(n$(v TO v+9));LINE t$:GO TO 4+(m>0)*(m<255):DATA "##%6A55##%6A5E####%6A54###%6A5-###%6A57#" 10 PRINT INK 7-2*(a=s);AT a*2,0;a;AT a*2,INT c(a)+1;" "+s$(2+5*(a-1)+(i-INT(i/VAL f$(a))*VAL f$(a))):RETURN Source code explained Program initialization Line 1 and 2 are used to build the t$ string, which stores data used for the animals user-defined graphics definition. Since the length of the whole string exceeded two lines, the last part of the string is stored as DATA in line 9. Compared to a list of numeric data values, the string made up of the corresponding characters (the code is incremented by 35 in order to use printable characters only) offers a more compact representation. Line 3 sets up the colours (blue border and white ink on blue paper), allocates the animals horizontal positions array c, defines the graphic animal characters using data stored in t$ by means of a loop and initializes the string f$, telling how many characters are using for animating each animal, and the message m$, used to inform the player about the total money available. Game initialization Line 4 contains statements used for both program initialization and game initialization. This is not a good programming practice, but in 10 liners you have to deal with program and lines length, so this might happen! The RESTORE statements resets the start of DATA to line 9. This is not necessary for normal game operation, but avoids crashes in case the player breaks the game and then runs it again. The array storing the animals graphic characters s$ is initialized, as well as the string n$, which contains multiple user messages. The initial available money m is set to $10. Hacking tip: you start the game with more money by changing the value used to initialize the variable m. Line 5 clears the screen, computes the starting position c(a) of each animal, prints the still animals and draws the finishing line. The i variable, used to compute the index of the animal animation characters that must be printed at each iteration of the game loop, is initialized to 0. Line 6 initializes the animal iterator a to the first animal and asks the player to select an animal and the bet amount. If the selected animal and the bet are valid, the program can continue to line 7. After the animal number and bet have been input, the random number generator is also reinitialized. Race game loop In line 7, current animal horizontal position c(a) is advanced by a random value and the animal is reprinted on the screen by executing the subroutine at line 10. The race status flag r is updated according to current animal position: if the animal has not yet reached the finishing line (at column 28), the race is not over and r is set to 0. Otherwise, if the winner is the animal s chosen by the player, r is set to 1; conversely, if the winner is not the player's animal, r is set to -1. If the loop is over, i.e. all five animals have advanced (current animal a = 5), i is incremented for the next iteration and a is reset to 1; otherwise, i is left unchanged and a is incremented, so that the next animal will be updated. The last statement goes back to line 7 if the race is not over, otherwise the program continues to line 8. Line 8 updates the total money amount by adding or subtracting the bet depending on the race result r and then determines the indices used for building the messages to inform the player about the outcome. The "You win $" or "You lose $" message follow by the bet and the updated total money are printed at line 21. Line 9 prints the following messages based on the game status: "You win!" if the game is over because you accumulated more t

System requirements

System requirements for this game aren't available yet — check back soon.

Related games