Providers
Debian Linux
SDF
MinGW-W64
Verizon
Research
Search Engines
Bing
DuckDuckGo
Google
Metacrawler
SearX
Miscellaneous
Faqs and RFCs
Open Directory Project
W3Schools Online Web Tutorials
Wikipedia
Multimedia
CTIS
For the Pigs Among Us
Family Photos
My House
My Photos (1999-2002?)
My Photos (2005)
Retro Computers
Minions of Mirth
Main
Criticals
Criticals (Single Player)
Ghaqua
Maps and Points of Interest
Miscellaneous
Monster Templates
Miscellaneous
Area Codes
Bard’s Tale
Dungeons & Dragons Online
My Blog
Quote of the Day
RogueBasin
Slashdot
The Adventuer’s Guild
Weather
GitHub:eprive/Z80-MBC3
Programming
Main
Across
Biorhythm
BMP Chips
Complex Roots
Magic Square
Magic Square(js)
Matrix(js)
More DOS Programs
Roll
Strip Dups (bash)
Wacky Wood-Worker
How To
Enlightenment 0.16.7.2 Startup Patch
How to Create an OS X Iconset
My RedHat Howto
SSH to VMS (Deathrow OpenVMS Cluster)
Tools
Allowable Mortgage Interest
Dates and Mileage
Day of the Year
Fun With Time
Downloads
Educational
Utilities
ROADRACE.C
/* ROADRACE.C by Michael J. Chappell June 15, 2015 A fairly direct port of ROADRACE.BAS Copyright 1979 by Phil Feldman and Tom Rugg. Source code compiles under MIX Power C. Compiled for FreeDOS and should work under MS-DOS or PC-DOS. Tested under DOSBox 0.73 on Mac OS X 10.8.5 */ #include <stdio.h> #include "trs81.h" int w /* road width */, v /* visibility */; int m /* miles */, n /* days */, t /* total miles */, h /* total time */; int l, r; /* position of left and right side of the road */ int el=2, er=58; /* leftmost and rightmost road positions */ int c; /* position of car */ int z, zc, zp; /* poke arguments for car location */ int b=32 /* blank */; int p /* printing position */; int j, k; /* loop indices */ int c1=175, c2=159; /* left and right car characters */ int d[10]={0, 82, 79, 65, 68, 82, 65, 67, 69, 32}; /* poke args for disp mesg */ char l$=',', r$='.'; /* left and right keys */ /* '\xbf' is full block set tandy charset */ char ls$[]="\xbf ", rs$[]=" \xbf", /* strings to display */ lt$[3]={184,135,0}, rt$[3]={139,180,0}; /* road segments */ char qs$[]="\xbf O \xbf"; char q$ /* user replies */; char temp$[256]; char sp$[] = " "; float lc, rc; /* random cutoffs to move road left or right */ float q; /* work variable */ int main(int argc, char **argv) { Initialize(); lc = 0.45; rc = 1 - lc; do { Print("\n"); do { t = 0; n = 0; Print("ROAD WIDTH (4-15)? "); scanf("%d",&w); } while ((w<4)||(w>15)); Print("\nVISIBILITY CONDITIONS\n"); Print(" 1 - TERRIBLE\n"); Print(" 2 - BAD\n"); Print(" 3 - FAIR\n"); Print(" 4 - GOOD\n\n"); do { Print("VISIBILITY (1-4)? "); scanf("%d", &v); } while ((v<1)||(v>4)); do { n++; l = 24; r = l+w+2; z = 16384-128*v; c = (l+r)/2; h = 0; for (j=1;j<=16;j++) { q$=Inkey$(); RoadAhead(0); } Starter(); for(;;) { ForLoop(100); h++; q=Rnd(0); ScrollUp(); PrintAt(960); if ((q>rc)&&(r<er)) RoadRight(1); else if ((q<lc)&&(l>el)) RoadLeft(1); else RoadAhead(1); zc = z+c; zp = zc+1; q$=Inkey$(); if (q$==l$) c--; if (q$==r$) c++; if ((Peek(zc)==b)&&(Peek(zp)==b)) { Poke(zc,c1); Poke(zp,c2); } else break; } for (j=1; j<=8; j++) { q$=Inkey$(); Poke(zc,b); Poke(zp,b); ForLoop(150); Poke(zc,c1); Poke(zp,c2); ForLoop(150); } m=h*5; t+=m; sprintf(temp$, "\nYOU WENT %d MILES FOR A TOTAL OF %d " "MILES IN %d DAY%s\n\n", m, t, n, (n==1?".":"S.")); Print(temp$); Print("HIT \'C\' - CONTINUE RACE\n"); Print(" \'R\' - RESTART RACE\n"); Print(" \'Q\' - QUIT RACE"); for (;;) { q$=Inkey$(); if ((q$=='c')||(q$=='r')||(q$=='q')) break; } } while (q$=='c'); sprintf(temp$, "\nAVERAGE MILES PER DAY=%.1f\n", (float)t/n); Print(temp$); } while (q$=='r'); while (!Inkey$()); } /* main */ void RoadAhead(int arg) { PrintTab(l); sprintf(temp$,"%s %*s", rs$, w, ls$); Print(temp$); if (arg!=1) Print("\n"); return; } /* RoadAhead */ void RoadLeft(int arg) { PrintTab(l); sprintf(temp$,"%s %*s", lt$, w-1, lt$); Print(temp$); l--; r--; if (arg!=1) Print("\n"); return; } /* RoadLeft */ void RoadRight(int arg) { PrintTab(l+1); sprintf(temp$,"%s %*s", rt$, w-1, rt$); Print(temp$); l++; r++; if (arg!=1) Print("\n"); return; } /* RoadRight */ void Starter(void) { p=z+c; DrawCar(); p=z+c-15360-20; p=p-320; /* '\xb0' is bottom third set tandy charset */ PrintStrAt(p, "\xb0\xb0\xb0\xb0\xb0"); for (j=1;j<=5;j++) { p+=64; PrintStrAt(p, qs$); } /* '\x83' is top third set tandy charset */ PrintStrAt(p+64, "\x83\x83\x83\x83\x83"); ForLoop(1800); for (j=4;j>=0;j--) { ForLoop(900); /* '\x8f' is top two thirds set tandy charset */ PrintChrAt(p+2-64*j, '\x8f'); } PrintChrAt(896, ' '); return; } /* Starter */ void Initialize(void) { InitializeTRS80(0); Random(); l=18; r=28; w=10; Cls(); RoadAhead(0); RoadRight(0); for (j=1; j<=2; j++) { RoadLeft(0); } for (j=1; j<=10; j++) { RoadRight(0); } p=15383; Poke(p,c1); Poke(p+1,c2); ForLoop(1500); p+=65; DrawCar(); for (j=1; j<=2; j++) { p+=63; DrawCar(); } p+=65; DrawCar(); for (j=1;j<=9;j++) { p+=65; DrawCar(); Poke(p,d[j]); Poke(p+1,b); } DrawCar(); return; } /* Initialize */ void DrawCar(void) { Poke(p,c1); Poke(p+1,c2); ForLoop(150); return; } /* DrawCar */
This source has been viewed 10 times.
Tuesday, 1 July 2025
Michael J. Chappell
Contact me at:
mcsuper5@freeshell.org