Code nostalgia with Quick Basic

With my wife I was discussing the discipline of doing backups, in doing so I was thinking of how old my oldest file would be. How many years could I go back in time? I’m not talking about backup retention schemes but about my oldest creation, the oldest modification date. So exploring the crypts of dusty ARJ archives looking at the bits and pieces I stored, I found some old code of mine that was so dusty and old, it made me smile and filled me with a feeling of nostalgia. I wanted to share this code nostalgia with you.

Facts and stats

Last modification date: 18 december 1991 (previous century :-))
My age back then: 11 years
Platform: MS-DOS
Language: Quick Basic
Project: Programming the mastermind game
Status: buggy/but some parts work

The code

Surprised about the ramblings of my 11-year old self, I came to the idea of reviving the code. With some fiddling with the dosbox emulator it was suprisingly easy to make it work again! I put a recording at the end of this post. It’s somewhat magic to see 25 years old code working on current computer.

Useless for sure, it contains a bug concerning the black pins, but it doesn’t matter, I was happy that night 🙂

 

GOTO mastermind

mastermind:
CLS
SCREEN 8
COLOR 0, 2
RANDOMIZE TIMER

FOR t = 1 TO 300
kleur:
i = RND
IF i < .25 THEN
  kleur = 1
ELSE
  IF i < .5 THEN
    kleur = 1
  ELSE
    IF i < .75 THEN
      kleur = 6
    ELSE
      kleur = 9
    END IF
  END IF
END IF

teken:
lr = INT(RND * 600)
bb = INT(RND * 300)
LINE (lr, bb)-(lr + 8, bb + 8), kleur, BF
NEXT t

COLOR 14, 2
LOCATE 12, 27
PRINT "Welkom in Mastermind"
LOCATE 15, 20
PRINT "Geprogrammeerd door Marco de Krijger @"
PLAY "l8 a< b< c> d> e> f> l4 g "
DO
FOR flash = 1 TO 400
  NEXT flash
  LOCATE 22, 30
  COLOR 5, 2
  PRINT "Druk een toets"
  FOR flashing = 1 TO 400
  NEXT flashing
  LOCATE 22, 30
  COLOR 10, 2
  PRINT "Druk een toets"
LOOP WHILE INKEY$ = ""

mastmind:
CLS
SCREEN 9
COLOR 10, 2
LOCATE 2, 30
PRINT "M A S T E R M I N D"
LOCATE 25, 5
PRINT "Druk 'H' voor Help"
COLOR 12, 2
LOCATE 4, 5

'bepalen toevalsgetallen tussen 0 en 9
RANDOMIZE TIMER
FOR i = 1 TO 4
  x$(i) = MID$(STR$(INT(10 * RND)), 2, 1)
NEXT i

beurt = 1

l1:
nummer = 1
beurt$ = MID$(STR$(beurt), 2)
IF beurt <= 9 THEN LOCATE , 5
PRINT " ";
PRINT "("; beurt$; ")    ";

l2:
toets$ = INKEY$
IF toets$ = "" THEN GOTO l2

IF toets$ < "0" OR toets$ > "9" THEN GOTO l2
poging$(nummer) = toets$
PRINT toets$; "    ";
IF nummer < 4 THEN
  nummer = nummer + 1
  GOTO l2
END IF
PRINT "        ";

zwart = 0
wit = 0
'beoordelen 1
FOR i = 1 TO 4
  bron(i) = 0
  doel(i) = 0
NEXT i
FOR i = 1 TO 4
  IF poging$(i) <> x$(i) THEN GOTO nxt1
  zwart = zwart + 1
  doel(i) = 1
  bron(i) = 1
nxt1:
NEXT i

'beoordelen 2
FOR i = 1 TO 4
  FOR j = 1 TO 4
    IF zwart + wit = 4 THEN GOTO nxt2
    IF i = j THEN GOTO nxt2
    IF doel(j) THEN GOTO nxt2
    IF bron(i) THEN GOTO nxt2
    IF pogint$(i) <> x$(j) THEN GOTO nxt2
    wit = wit + 1
    doel(j) = 1
    bron(i) = 1
nxt2:
  NEXT j
NEXT i

'goed/fout/einde
IF zwart = 4 THEN GOTO klaar

'1: niets goed
IF zwart = 0 AND wit = 0 THEN
  PRINT "                          [niets]"
  GOTO daarna
END IF

'2: alleen wit
IF zwart = 0 THEN
  FOR i = 1 TO wit
    PRINT CHR$(63); "  ";
  NEXT i
  PRINT
  GOTO daarna
END IF

'3: alleen zwart
IF wit = 0 THEN
  FOR i = 1 TO zwart
    PRINT CHR$(33); "  ";
  NEXT i
  PRINT
  GOTO daarna
END IF

'4: zwart en wit
FOR i = 1 TO zwart
  PRINT CHR$(33); "  ";
NEXT i
FOR i = 1 TO wit
  PRINT CHR$(63); "  ";
NEXT i
PRINT

daarna:
PRINT
IF beurt < 10 THEN
  LOCATE , 5
  beurt = beurt + 1
  GOTO l1
ELSE
  LOCATE , 6
  COLOR 14, 2
  PRINT "        ";
  FOR i = 1 TO 4
    PRINT x$(i); "    ";
  NEXT i
  PRINT "Is de juiste combinatie."
  GOTO einde4
END IF

klaar:
FOR i = 1 TO 4
  PRINT CHR$(33); "  ";
NEXT i
COLOR 14, 2
PRINT "         geraden!"

einde4:
COLOR 14, 2
LINE (220, 90)-(410, 160), 5, BF
LINE (219, 90)-(410, 161), 8, B
LINE (233, 100)-(397, 150), 9, BF
LINE (246, 111)-(385, 140), 12, B
LOCATE 9, 32
PRINT "Nog een keer j/n?"
LOCATE 10, 32
PRINT "                 "
LOCATE 10, 40
INPUT "", keuze$
IF keuze$ = "n" THEN
GOTO banana
END IF
IF keuze$ = "j" THEN
GOTO mastmind
ELSE
LOCATE 10, 32
PRINT "Ongeldig antwoord"
FOR wacht = 1 TO 1500
NEXT wacht
GOTO einde
END IF

1000 SYSTEM

 

And the screen capture:

code nostalgia

Leave a Reply

Your email address will not be published. Required fields are marked *