Initial Import from SVN
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
TOPSRC = $(shell cd ../../..; pwd)
|
||||
include $(TOPSRC)/target.mk
|
||||
#include $(TOPSRC)/cross.mk
|
||||
|
||||
CFLAGS += -Wall -Werror
|
||||
|
||||
OBJS = basic.o
|
||||
|
||||
LIBS = -lcurses -ltermcap -lm -lc
|
||||
|
||||
all: basic renumber
|
||||
|
||||
basic: ${OBJS}
|
||||
${CC} ${LDFLAGS} -o basic.elf ${OBJS} ${LIBS}
|
||||
${OBJDUMP} -S basic.elf > basic.dis
|
||||
${SIZE} basic.elf
|
||||
${ELF2AOUT} basic.elf $@ && rm basic.elf
|
||||
|
||||
renumber: renumber.o
|
||||
${CC} ${LDFLAGS} -o renumber.elf $< ${LIBS}
|
||||
${OBJDUMP} -S renumber.elf > renumber.dis
|
||||
${SIZE} renumber.elf
|
||||
${ELF2AOUT} renumber.elf $@ && rm renumber.elf
|
||||
|
||||
clean:
|
||||
rm -f *.o basic renumber *.elf *.dis *~
|
||||
|
||||
install: all
|
||||
install basic $(DESTDIR)/bin/
|
||||
install renumber $(DESTDIR)/bin/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,61 @@
|
||||
10 rem **************************************
|
||||
20 rem *** Play the "blackjack" (21) game ***
|
||||
30 rem **************************************
|
||||
40 dim C(52): m = 1000
|
||||
50 rem
|
||||
60 rem Create deck of cards and shuffle it
|
||||
70 rem
|
||||
80 for i=0 to 51: c(i) = i: next i
|
||||
90 for i=0 to 51: i1=rnd(52): i2=c(i): c(i)=c(i2): c(i2)=i1: next i
|
||||
100 rem
|
||||
110 rem Prompt for amount of bet (on this game)
|
||||
120 rem
|
||||
130 print "You have", m, " dollars"
|
||||
140 input "How much do you wish to bet?", b: if b=0 then stop
|
||||
150 lif b>m then print "You don't have enough money":goto 140
|
||||
160 t = 0: d = 0
|
||||
170 rem
|
||||
180 rem Prompt PLAYER for another card
|
||||
190 rem
|
||||
200 print "Total:", t,:Input " Another card (Y/N)?", a$
|
||||
210 if a$="n" then 380
|
||||
220 lif a$<>"y" then print "Please answer y-Yes or n-No":goto 200
|
||||
230 c = c(d): d = d + 1: gosub 530
|
||||
240 c = c % 13: if c > 9 then c = 9
|
||||
250 if c > 0 then 300
|
||||
260 input "(1)one or (t)ten ?", a$
|
||||
270 if a$="1" then 300
|
||||
280 if a$<>"t" then 260
|
||||
290 c = 9
|
||||
300 t = t + c + 1
|
||||
310 if t <= 21 then 200
|
||||
320 print "You went over 21! - you LOSE!"
|
||||
330 m = m - b: if m > 0 then 80
|
||||
340 print "You went BUST!":end
|
||||
350 rem
|
||||
360 rem Play DEALER
|
||||
370 rem
|
||||
380 t1 = 0
|
||||
390 c = c(d): d = d + 1: print "Dealer draws ",: gosub 530
|
||||
400 c = c % 13: if c > 9 then c = 9
|
||||
410 if c > 0 then 470
|
||||
420 if t1 < 10 then 450
|
||||
430 if (t1+10) > 23 then 460
|
||||
440 if (t1+10) >= t then 450
|
||||
450 c = 9
|
||||
460 print "Dealer chooses", c+1
|
||||
470 t1 = t1 + c + 1: print "Dealer totals", t1: if t1 < t then 390
|
||||
480 lif t1 <= 21 then print "Dealer wins - You LOSE!": goto 330
|
||||
490 print "Dealer loses - You WIN!!!": m = m + b: goto 80
|
||||
500 rem
|
||||
510 rem Subroutine to display text description of a card
|
||||
520 rem
|
||||
530 order 590
|
||||
540 for a = 0 to c / 13: read a$: next a
|
||||
550 order 600
|
||||
560 for a = 0 to c % 13: read a1$:next a
|
||||
570 print a1$, " of ", a$
|
||||
580 return
|
||||
590 data "Hearts", "Diamonds", "Clubs", "Spades"
|
||||
600 data "Ace", "Two", "Three", "Four", "Five", "Six", "Seven"
|
||||
610 data "Eight", "Nine", "Ten", "Jack", "Queen", "King"
|
||||
@@ -0,0 +1,13 @@
|
||||
10 rem ****************************
|
||||
20 rem *** Play the HI/LOW game ***
|
||||
30 rem ****************************
|
||||
40 n = rnd(100)
|
||||
50 c = 0
|
||||
60 input "Guess a number? ", g
|
||||
70 c = c+1
|
||||
80 if g=n then 120
|
||||
90 if g>n then print "lower"
|
||||
100 if g<n then print "higher"
|
||||
110 goto 60
|
||||
120 print "You guessed it in", c, " tries!"
|
||||
130 exit
|
||||
@@ -0,0 +1,20 @@
|
||||
This is a version of Basic adapted for RetroBSD.
|
||||
|
||||
It is based on Micro-Basic from Dave Dunfield:
|
||||
* Copyright 1982-2000 Dave Dunfield
|
||||
* All rights reserved.
|
||||
* Permission granted for personal (non-commercial) use only.
|
||||
|
||||
How to build:
|
||||
- From command prompt type: "make"
|
||||
|
||||
Archive contents:
|
||||
- BASIC.C = original Mikro-C source code
|
||||
- README.TXT = this file
|
||||
- BLKJACK.BAS = example does work
|
||||
- HILOW.BAS = example works ok
|
||||
- Makefile = Makefile
|
||||
- RENUMBER.C = RENUMBER source code
|
||||
___
|
||||
Best wishes,
|
||||
Serge Vakulenko <serge@vak.ru>
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* MICRO-BASIC 2.1 line renumbering program.
|
||||
*
|
||||
* This program reads a MICRO-BASIC source file, and write a new one with
|
||||
* all lines renumbered. All IF/THEN, GOTO, GOSUB and ORDER statements are
|
||||
* adjusted to reflect the new line numbers.
|
||||
*
|
||||
* Copyright 1993-2000 Dave Dunfield
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission granted for personal (non-commercial) use only.
|
||||
*
|
||||
* Compile command: cc renumber -fop
|
||||
*/
|
||||
#ifdef CROSS
|
||||
# include </usr/include/stdio.h>
|
||||
# include </usr/include/ctype.h>
|
||||
#else
|
||||
# include <stdio.h>
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MAX_LINES 10000 /* Maximum # lines in input program */
|
||||
|
||||
/*
|
||||
* Case insensitive test of 'ptr' beginning with 'string'
|
||||
*/
|
||||
int begins_with(char *ptr, char *string)
|
||||
{
|
||||
while(*string)
|
||||
if(toupper(*ptr++) != *string++)
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned i, l, m;
|
||||
char buffer[200], *ptr, *ptr1;
|
||||
static unsigned lines[MAX_LINES], ltop = 0, increment = 10, start = 10;
|
||||
static FILE *fp, *fp1;
|
||||
|
||||
printf("MICRO-BASIC 2.1 line renumbering program\n");
|
||||
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "Use: renumber old new [start [increment]]\n\n");
|
||||
fprintf(stderr, "Copyright 1993-2000 Dave Dunfield\n");
|
||||
fprintf(stderr, "All rights reserved.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fp = fopen(argv[1], "rvq");
|
||||
fp1 = fopen(argv[2], "wvq");
|
||||
if(argc > 3)
|
||||
start = atoi(argv[3]);
|
||||
if(argc > 4)
|
||||
increment = atoi(argv[4]);
|
||||
|
||||
/* Pass #1: Scan and record all line numbers */
|
||||
m = 0;
|
||||
while(fgets(buffer, sizeof(buffer)-1, fp)) {
|
||||
if(!(l = atoi(buffer))) {
|
||||
printf("Invalid line number following line %u\n", m);
|
||||
return 0;
|
||||
}
|
||||
if(l <= m) {
|
||||
printf("Improper line sequence following line %u\n", m);
|
||||
return 0;
|
||||
}
|
||||
lines[ltop++] = m = l;
|
||||
}
|
||||
|
||||
/* Pass #2: Copy lines and replace line numbers */
|
||||
rewind(fp);
|
||||
m = 0;
|
||||
while(fgets(ptr1 = ptr = buffer, sizeof(buffer), fp)) {
|
||||
/* Replace line number with one from the new sequence */
|
||||
fixnum: while(isspace(*ptr))
|
||||
++ptr;
|
||||
while(ptr1 < ptr)
|
||||
putc(*ptr1++, fp1);
|
||||
if(isdigit(*ptr)) {
|
||||
++m;
|
||||
l = atoi(ptr);
|
||||
while(isdigit(*ptr))
|
||||
++ptr;
|
||||
for(i=0; i < ltop; ++i)
|
||||
if(lines[i] == l) {
|
||||
fprintf(fp1, "%u", i * increment + start);
|
||||
break;
|
||||
}
|
||||
}
|
||||
while(*(ptr1 = ptr)) {
|
||||
if(begins_with(ptr, "THEN")) {
|
||||
ptr += 4;
|
||||
goto fixnum;
|
||||
}
|
||||
if(begins_with(ptr, "ORDER")) {
|
||||
ptr += 5;
|
||||
goto fixnum;
|
||||
}
|
||||
if(begins_with(ptr, "GOTO")) {
|
||||
ptr += 4;
|
||||
goto fixnum;
|
||||
}
|
||||
if(begins_with(ptr, "GOSUB")) {
|
||||
ptr += 5;
|
||||
goto fixnum;
|
||||
}
|
||||
if (*ptr != '\r' && *ptr != '\n')
|
||||
putc(*ptr, fp1);
|
||||
++ptr;
|
||||
}
|
||||
putc('\n', fp1);
|
||||
}
|
||||
|
||||
fclose(fp1);
|
||||
fclose(fp);
|
||||
printf("%u lines read, %u fixups\n", ltop, m);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
10 INPUT "Your name: ", U$
|
||||
20 PRINT "Hello ", U$
|
||||
30 INPUT "How many stars do you want: ", N
|
||||
40 S$ = ""
|
||||
50 FOR I = 1 TO N
|
||||
60 S$ = S$ + "*"
|
||||
70 NEXT I
|
||||
80 PRINT S$
|
||||
90 INPUT "Do you want more stars? ", A$
|
||||
100 IF A$ = "" THEN GOTO 90
|
||||
110 IF A$ = "Y" THEN GOTO 30
|
||||
120 IF A$ = "y" THEN GOTO 30
|
||||
130 PRINT "Goodbye ", U$
|
||||
140 END
|
||||
Reference in New Issue
Block a user