Author Topic: QBasic OS  (Read 7576 times)

0 Members and 1 Guest are viewing this topic.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: QBasic OS
« Reply #15 on: March 26, 2020, 05:19:49 pm »
Hi Eric
it seems TicTacToe.BAS a Bob Seguin's product for graphics that travels in the sample package of QB64.

PS It has a bug that I fixed... :-)
Programming isn't difficult, only it's  consuming time and coffee

Offline EricE

  • Forum Regular
  • Posts: 114
    • View Profile
Re: QBasic OS
« Reply #16 on: March 26, 2020, 05:55:04 pm »
Hi TempodiBasic,
I found the code by using Google to search for various substrings of this comment string.
"This game was created by Paul Meyer in the year 2007."
I will look for the fixed sample version.

EDIT
And I found it! We all had the improved, fixed version ready for us to use.

C:\qb64_1.4_win-x86\qb64\programs\samples\n54\big\tictac.bas
« Last Edit: March 26, 2020, 06:04:07 pm by EricE »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: QBasic OS
« Reply #17 on: March 26, 2020, 06:53:48 pm »
Hi Eric
this version that is in the sample package of QB64  has the interface written by Bob Seguin as you can read also if you run it.
Good let run it and then please choose Hard, then as first player make as choice the rightest square (cell) of the middle raw, the AI will respond taking the center with O,  now make as choice the center square of the bottom raw...! You got it! a runtime error for Subscript out of range!
Searching on the [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] you'll find my fix to this.
Or You'll be able to fix following the flow of the program.
Programming isn't difficult, only it's  consuming time and coffee

Offline EricE

  • Forum Regular
  • Posts: 114
    • View Profile
Re: QBasic OS
« Reply #18 on: March 26, 2020, 09:06:49 pm »
Quote
Searching on the [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] you'll find my fix to this

I am sorry to say that I could not find your fix at [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there].

[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] is not complete, there are many links there that just lead back to its main page.

Offline qbkiller101

  • Newbie
  • Posts: 73
    • View Profile
Re: QBasic OS
« Reply #19 on: March 27, 2020, 04:17:27 am »
Quote
Is this the code
yeah

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: QBasic OS
« Reply #20 on: March 29, 2020, 04:34:23 pm »
Hey Guys
on an old Notebook I have found my fix to TicTacToe
here is
as attachment
Programming isn't difficult, only it's  consuming time and coffee

Offline EricE

  • Forum Regular
  • Posts: 114
    • View Profile
Re: QBasic OS
« Reply #21 on: March 29, 2020, 08:21:33 pm »
Thank you TempodiBasic,
However, the attachment you uploaded is damaged.
Did it open ok before you uploaded it?

Offline qbkiller101

  • Newbie
  • Posts: 73
    • View Profile
Re: QBasic OS
« Reply #22 on: March 30, 2020, 05:27:35 am »
I guess he sort of opened the .exe in qb64 or something cuz that's what happens when you open .exe in text editors or compilers

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: QBasic OS
« Reply #23 on: March 30, 2020, 07:18:11 am »
Hi Eric
sorry that is a QB compressed file

here the text version...
Code: QB64: [Select]
  1. DECLARE SUB Winner (Lineup AS INTEGER)
  2. DECLARE SUB ShowWin (b1 AS INTEGER, b2 AS INTEGER, b3 AS INTEGER)
  3. DECLARE SUB GetUserSignal ()
  4. DECLARE SUB EnableMouse (c%)
  5. DECLARE SUB DrawSCREEN ()
  6. DECLARE SUB xo (Row%, Col%, symbol%)
  7.  
  8. DIM SHARED False AS INTEGER, True AS INTEGER: True = NOT False
  9. DIM SHARED SymbolBOX(6000) AS INTEGER '<---NOTE
  10.  
  11. DIM SHARED cH AS INTEGER: 'Cursor Position Horizontal
  12. DIM SHARED cV AS INTEGER: 'Cursor Position Vertical
  13. DIM SHARED click AS INTEGER: ' 0=no click, 1=left click, 2=right
  14. ' EnableMouse 1 = Turn cursor on, return coordinates
  15. ' EnableMouse 0 = Turn cursor off in order to draw stuff, etc.
  16. DIM SHARED cC AS STRING: 'User pressed key
  17. ' GetUserSignal will set return cC or will return Click
  18.  
  19. DIM WhoWon AS INTEGER
  20. DIM MadeAMove AS INTEGER, MovesMade AS INTEGER
  21.  
  22. ' ----------------------------------------------------------
  23. ' Title Screen (Main Program)
  24. ' -----------------------------------------------------------
  25. SCREEN 12 ' modalita schermo / screen mode
  26. RANDOMIZE TIMER ' inizializza generatore di numeri casuali / it inizializes maker of random numbers
  27. DIM Command AS INTEGER, Hard AS INTEGER
  28. ' variabili generali non visibili in SUB per cui usa GOSUB
  29. ' general variables non seen in SUB so He uses GOSUB
  30. GOSUB InitializeScreen ' schermo iniziale con pulsanti / initial screen with buttons
  31.  
  32. DO ' ciclo principale infinito / main loop infinite
  33.     DO: GetUserSignal: LOOP UNTIL click = 1 ' attende il click/ it waits for click
  34.     GOSUB FindClickedCommand ' decodifica il click / it decodes click
  35.     SELECT CASE Command
  36.         CASE 1: ' primo pulsante / first button
  37.             Hard = False
  38.             WhoWon = 0
  39.             GOSUB PlayGame
  40.             GOSUB ShowWhoWon
  41.             GOSUB InitializeScreen
  42.         CASE 2: ' secondo pulsante / second button
  43.             Hard = True
  44.             WhoWon = 0
  45.             GOSUB PlayGame
  46.             GOSUB ShowWhoWon
  47.             GOSUB InitializeScreen
  48.         CASE 3: ' terzo pulsante /third button
  49.             GOSUB DoHelp
  50.             GOSUB InitializeScreen
  51.         CASE 4: 'forth button / quarto pulsante
  52.             EXIT DO ' esce dal ciclo/ it exits from loop
  53.     END SELECT
  54. COLOR 7: CLS ' ripristina i caratteri bianchi e pulisce lo schermo/ it restores white character and clear screen
  55. SYSTEM ' termina liberando le risorse / it stops releasing resources
  56.  
  57. ' ----------------------------------------------------------
  58. ' Game Screen
  59. ' -----------------------------------------------------------
  60. DIM SHARED zX(9) AS INTEGER: ' Where all X's are placed
  61. DIM SHARED zO(9) AS INTEGER: ' Where all O's are placed
  62. DIM SHARED zE(9) AS INTEGER: ' Where empty squares are
  63. DIM theRow AS INTEGER, theColumn AS INTEGER, theBox AS INTEGER
  64.  
  65. FindClickedPosition: ' cerca la posizione del mouse/ it finds position of mouse
  66. CONST Delta = 4
  67. theRow = 0: theColumn = 0: theBox = 0
  68. SELECT CASE cH ' posizione orizzontale / horizontal position
  69.     CASE IS < 170 + Delta: RETURN
  70.     CASE IS < 269 - Delta: theColumn = 1 ' tra 174 e 265 colonna 1 / between 174 and 265 column 1
  71.     CASE IS < 269 + Delta: RETURN
  72.     CASE IS < 368 - Delta: theColumn = 2 ' tra 274 e 364 colonna 2 / between 274 and 364 column 2
  73.     CASE IS < 368 + Delta: RETURN
  74.     CASE IS < 467 - Delta: theColumn = 3 ' tra 372 e 463 colonna 3/ between 372 and 463 column 3
  75. SELECT CASE cV ' posizione verticale / vertical position
  76.     CASE IS < 91 + Delta: RETURN
  77.     CASE IS < 190 - Delta: theRow = 1 ' tra 95 e 186 riga 1/ between 95 and 186 row 1
  78.     CASE IS < 190 + Delta: RETURN
  79.     CASE IS < 289 - Delta: theRow = 2 'tra 194 e 285 riga 2/between 194 3 285 row 2
  80.     CASE IS < 289 + Delta: RETURN
  81.     CASE IS < 388 - Delta: theRow = 3 ' tra 294 e 384 riga 3 / between 294 e 384 row 3
  82. theBox = (3 * (theRow - 1)) + theColumn ' calcola la cella/ it calculates cell
  83. ' nota che si possono invertire TheRow e TheColumn nella formula
  84. ' see that it can invert TheRow and TheColumn in formula
  85.  
  86. ' ----------------------------------------------------------
  87. ' Play Game
  88. ' -----------------------------------------------------------
  89. PlayGame: ' schermata di gioco / screen of game
  90. DrawSCREEN 'draw the screen and create X and O symbols.
  91. FOR i = 1 TO 9: zO(i) = False: zX(i) = False: zE(i) = True: NEXT i
  92. ' inizializza i 3 arrays Empty a vero X e 0 a falso
  93. ' it inizializes the three arrays Empty to true   X and 0 to false
  94. MovesMade = 0 ' mosse fatte = 0 / moves made = 0
  95.     GetUserSignal 'aspetta azione utente/ it waits action of user
  96.     IF click THEN
  97.         MadeAMove = False ' flag fatta una mossa / flag made a move
  98.         GOSUB MakeX ' fa la X       / if it maked X
  99.         IF MadeAMove THEN ' se Š fatta la mossa    / if it made a move
  100.             WhoWon = 1: GOSUB ComputeWin: IF WhoWon = 1 THEN RETURN
  101.             'WhoWon flag per cercare il vincitore / WhoWon is flag to seek for winner
  102.             t% = 0
  103.             FOR i = 1 TO 9: t% = t% + zX(i): NEXT i
  104.             IF t% = -5 THEN WhoWon = 0: RETURN
  105.             ' se ci sono 5 X allora ci saranno 4 0 e sar… pari
  106.             ' if there is 5 X then there shoude be 4 0s and it is tie
  107.             MovesMade = MovesMade + 1 ' conta mosse/ it counts moves
  108.             GOSUB MakeO
  109.             WhoWon = 2: GOSUB ComputeWin: IF WhoWon = 2 THEN RETURN
  110.             'WhoWon flag per cercare il vincitore / WhoWon is flag to seek for winner
  111.         END IF
  112.     END IF
  113.     IF cC = "d" OR cC = CHR$(27) THEN WhoWon = 3 ' utente vuole uscire / users wants to exit
  114.     IF WhoWon > 0 THEN RETURN ' se qualcuno vince ritorna al ciclo principale / if someone wins it returns to main loop
  115.  
  116. MakeX:
  117. GOSUB FindClickedPosition ' decodifica il click/ it decodes click
  118. IF theBox = 0 THEN RETURN ' esce se non ha scelto / t exits if it doesn't choose
  119. IF NOT zE(theBox) THEN RETURN ' esce se la cella non Š vuota/ it exits if cell is not void
  120. xo theRow, theColumn, 1: ' Places an X
  121. zX(theBox) = True: zE(theBox) = False ' aggiorna array X e Empty / it refreshes arrays X and Empty
  122. MadeAMove = True ' flag fatta la mossa
  123.  
  124. MakeO:
  125. GOSUB FindPlaceForO ' modulo IA per 0/ modulo AI for 0
  126. SLEEP 1: WHILE INKEY$ <> "": WEND ' aspetta 1 secondo/ it waits for 1 second
  127. xo theRow, theColumn, 0: 'Places an 0  /mette uno 0
  128. zO(theBox) = True: zE(theBox) = False ' imposta gli array / it sets arrays
  129.  
  130. ComputeWin: ' PC usando 0 vince / PC using 0 wins
  131. IF WhoWon = 1 THEN ' calcola se ha vinto la X/ it calculates if X wins
  132.     IF XWin(1, 2, 3, 1) THEN RETURN
  133.     IF XWin(4, 5, 6, 2) THEN RETURN
  134.     IF XWin(7, 8, 9, 3) THEN RETURN
  135.     IF XWin(1, 4, 7, 4) THEN RETURN
  136.     IF XWin(2, 5, 8, 5) THEN RETURN
  137.     IF XWin(3, 6, 9, 6) THEN RETURN
  138.     IF XWin(1, 5, 9, 7) THEN RETURN
  139.     IF XWin(3, 5, 7, 8) THEN RETURN
  140. ELSE ' calcola se ha vinto lo 0/ it calculates if 0 wins
  141.     IF OWin(1, 2, 3, 1) THEN RETURN
  142.     IF OWin(4, 5, 6, 2) THEN RETURN
  143.     IF OWin(7, 8, 9, 3) THEN RETURN
  144.     IF OWin(1, 4, 7, 4) THEN RETURN
  145.     IF OWin(2, 5, 8, 5) THEN RETURN
  146.     IF OWin(3, 6, 9, 6) THEN RETURN
  147.     IF OWin(1, 5, 9, 7) THEN RETURN
  148.     IF OWin(3, 5, 7, 8) THEN RETURN
  149. WhoWon = 0 ' nessuno vince/ nobody wins
  150.  
  151. FindPlaceForO: ' qui c'Š il problema ovvero opera incompiuta / here is problem otherwise work unfinished
  152. ' See if there is a win for O. If so, take it.
  153. ' See if there is a threat of a win for X. If so, block it.
  154. ' cerca se c'Š  una posizione che fa vincere 0 in tal caso la sceglie
  155. ' cerca se c'Š una posizione che fa vincere X in tal caso le blocca
  156. FOR TestType% = 1 TO 2
  157.     theBox = 0 ' nessuna cella scelta /no cell choosen
  158.     FOR theRow = 1 TO 3: FOR theColumn = 1 TO 3
  159.             ' per tutte le righe e per tutte le colonne
  160.             ' for all rows and all columns
  161.             theBox = theBox + 1 ' aumenta il numero di cella /it increases number of cell
  162.             IF zE(theBox) THEN ' se Š vuota / if it is void
  163.                 tk$ = ""
  164.                 SELECT CASE theBox ' sceglie le celle da controllare/ it chooses cells to control
  165.                     CASE 1: tk$ = "234759"
  166.                     CASE 2: tk$ = "1358"
  167.                     CASE 3: tk$ = "126957"
  168.                     CASE 4: tk$ = "1756"
  169.                     CASE 5: tk$ = "19283746"
  170.                     CASE 6: tk$ = "4539"
  171.                     CASE 7: tk$ = "148935"
  172.                     CASE 8: tk$ = "2579"
  173.                     CASE 9: tk$ = "153678"
  174.                 END SELECT
  175.                 ' controlla le celle / it controls cells
  176.                 FOR i = 1 TO LEN(tk$) STEP 2
  177.                     j = VAL(MID$(tk$, i, 1))
  178.                     k = VAL(MID$(tk$, i + 1, 1))
  179.                     ' prende due celle successive / it takes two cells successive
  180.                     IF TestType% = 1 THEN
  181.                         ' cerca 2 celle con 0 se si, fa  tris / it seeks for 2 cells with 0 if yes it will make tris
  182.                         IF zO(j) + zO(k) < -1 THEN RETURN
  183.                     ELSE
  184.                         ' cerca 2 celle con X se si blocca il tris di X / it searches 2 cells with X if yes it will block tris of X
  185.                         IF zX(j) + zX(k) < -1 THEN RETURN
  186.                     END IF
  187.                 NEXT i
  188.             END IF
  189.     NEXT theColumn: NEXT theRow
  190. NEXT TestType%
  191. ' No move selected above to win or block win, so  / nessuna mossa per vincere o bloccare X quindi
  192. IF Hard THEN ' modalit… difficile / hard mode
  193.     IF MovesMade = 1 THEN ' fatta una sola mossa/ it has made one move
  194.         IF zE(5) THEN ' se la cella centrale Š vuota la prende/ if central cell is empty it takes
  195.             theRow = 2: theColumn = 2: theBox = 5
  196.         ELSE
  197.             IF RND > .5 THEN theRow = 1 ELSE theRow = 3 ' sceglie a caso riga superiore o inferiore/ it chooses at random upper row or lower row
  198.             IF RND > .5 THEN theColumn = 1 ELSE theColumn = 3 ' sceglia a caso colonna 1 o 3/ it choosed at random column 1 or 3
  199.             theBox = (3 * (theRow - 1)) + theColumn ' calcola uno degli angoli della griglia/ it calculates one of angles of grid
  200.             ' anche qui TheRow e TheColumn sono intercambiabili
  201.             ' also here TheRow e TheColumn are interchangeable
  202.         END IF
  203.         RETURN
  204.     ELSEIF MovesMade = 2 THEN 'se X ha fatto 2 mosse / se X has made two moves
  205.         IF zX(5) THEN ' se X sta al centro  / if X is at centre cell
  206.             'se due angoli sono presi esamina gli altri due
  207.             ' if 2 angles are taken it examines the other two  angles
  208.             tk$ = ""
  209.             IF zO(1) AND zX(9) THEN ' se angoli 1 e 9 sono presi/ if angles 1 and 9 are taken
  210.                 tk$ = "37"
  211.             ELSEIF zO(3) AND zX(7) THEN ' se angoli 3 e 7 sono presi/ if angles 3 and 7 are taken
  212.                 tk$ = "19"
  213.             ELSEIF zO(7) AND zX(3) THEN ' se angoli 3 e 7 sono presi/ if angles 3 and 7 are taken
  214.                 tk$ = "19"
  215.             ELSEIF zO(9) AND zX(1) THEN ' se angoli 1 e 9 sono presi/ if angles 1 and 9 are taken
  216.                 tk$ = "37"
  217.             END IF
  218.             IF tk$ <> "" THEN 'se ci sono celle da esaminare/ if there are cells to examine
  219.                 IF RND > .5 THEN
  220.                     theBox = VAL(LEFT$(tk$, 1))
  221.                 ELSE
  222.                     theBox = VAL(LEFT$(tk$, 1))
  223.                 END IF
  224.                 ' sceglie a caso tra la prima cella della riga e la prima cella della riga???
  225.                 'forse ci vuole RIGHT$ nell'ELSE
  226.                 ' it chooses at random between first cell of row and first cell of row! ! ??
  227.                 ' maybe here is right RIGHT$ in ELSE
  228.  
  229.                 theRow = (theBox + 2) \ 3 ' ottiene come risultato 1 o 3 / it gets as results 1 or 3
  230.                 theColumn = theBox - (3 * (theRow - 1)) ' ottiene come risultato 1 o 3/ it gets as results 1 or 3
  231.                 ' le celle da scegliere sono 1 (1,1) 3 (1,3) 7(3,1) 9(3,3) Cella(TheRow,TheColumn)
  232.                 ' the  cells to choose are 1(1,1) 3 (1,3) 7 (3,1) 9 (3,3)  Cell(TheRow,TheColumn)
  233.                 RETURN
  234.             END IF
  235.         ELSE
  236.             'se la X non sta al centro / if X is not at centre
  237.             escape% = 0 ' variabile per uscire dal loop infinito / variable to exit from infinite loop
  238.             DO
  239.                 DO:
  240.                     theBox = 2 * FIX(1 + (RND * 4)):
  241.                     ' genera a caso un numero da 1 a 10  /it makes a rnd_number from 1 to 10
  242.                     ' il 10 capita all'incirca ogni 20 secondi e crea un errore in zE(TheBox)/ the 10 arrives about each 20 seconds and it makes error in zE(TheBox)
  243.                     'cos ci vuole un controllo forte ad esempio un if TheBox = 10 then TheBox = MaxPossibleNotAngle (8)/so it need a strong control for example if TheBox = 10 then TheBox = MaxPossibleNotAngle (8)
  244.  
  245.                     ' codice di verifica/ degub code
  246.                     ' LOCATE 28, 2: PRINT "theBox "; theBox, "zE(theBox) "; zE(theBox), "NOT zE(theBox) "; NOT zE(theBox)
  247.  
  248.                 LOOP WHILE NOT zE(theBox)
  249.                 SELECT CASE theBox
  250.                     CASE 2: IF NOT zX(8) THEN EXIT DO ELSE escape% = escape% + 1 'prende la casella 2 se la casella 8 Š  vuota/ it chooses cell 2 if cell 8 is empty
  251.                     CASE 4: IF NOT zX(6) THEN EXIT DO ELSE escape% = escape% + 1 'prende la casella 4 se la casella 6 Š  vuota/ it chooses cell 4 if cell 6 is empty
  252.                     CASE 6: IF NOT zX(4) THEN EXIT DO ELSE escape% = escape% + 1 'prende la casella 6 se la casella 4 Š  vuota/ it chooses cell 6 if cell 4 is empty
  253.                     CASE 8: IF NOT zX(2) THEN EXIT DO ELSE escape% = escape% + 1 'prende la casella 8 se la casella 2 Š  vuota/ it chooses cell 8 if cell 2 is empty
  254.                 END SELECT
  255.                 ' 1 perchŠ non sceglie un angolo? / why doesn't it choose an angle?
  256.                 '2 cosa fa se la casella opposta Š occupata?/ what does it, if the opposite cell is plenty?
  257.                 ' qui manca del codice per uscire dal loop/ here there is no code to exit loop
  258.                 IF (zX(2) AND zX(4) AND zO(5) AND zE(1)) THEN theBox = 1
  259.                 IF (zX(2) AND zX(6) AND zO(5) AND zE(3)) THEN theBox = 3
  260.                 IF (zX(4) AND zX(8) AND zO(5) AND zE(7)) THEN theBox = 7
  261.                 IF (zX(6) AND zX(8) AND zO(5) AND zE(9)) THEN theBox = 9
  262.  
  263.             LOOP UNTIL (((theBox + 1) MOD 2) OR escape% = 16) '4 * 4 = 16 , in 16 loop tester… almeno una volta le 4 condizioni/ 4*4 = 16 in 16 loops it will test at least a time each of 4 conditions
  264.             theRow = (theBox + 2) \ 3 ' calcola 1,2,2,3 rispettivamente a 2,4,6,8/ it calculates 1,2,2,3 for respectively 2,4,6,8
  265.             theColumn = theBox - (3 * (theRow - 1)) ' calcola 2,1,3,2 seguendo i valori superiori/ it calculates 2,1,3,2 following the above values
  266.             RETURN
  267.         END IF
  268.     END IF
  269. ' OK, no good move was found. Make a random one
  270. ' nessuna buona mossa da fare ne fa una a caso
  271. DO: theBox = 1 + INT(RND * 9): LOOP WHILE NOT zE(theBox)
  272. theRow = (theBox + 2) \ 3
  273. theColumn = theBox - (3 * (theRow - 1))
  274.  
  275. Shuffle:
  276. DO WHILE LEN(w1$) < 4
  277.     r% = 1 + INT(RND * 4)
  278.     IF MID$(w2$, r%, 1) <> "x" THEN
  279.         w1$ = w1$ + MID$(w2$, r%, 1)
  280.         MID$(w2$, r%, 1) = "x"
  281.     END IF
  282.  
  283. ShowWhoWon: ' mostra vincitore/ it shows winner
  284. SELECT CASE WhoWon ' 4 casi Pari , Vinci, Perdi, Abbandoni / 4 cases Tie, win, lose, resigne
  285.     CASE 0: c$ = "Tie! "
  286.     CASE 1: c$ = "YOU WIN! "
  287.     CASE 2: c$ = "YOU LOSE! "
  288.     CASE 3: c$ = "YOU RESIGNED?"
  289. IF WhoWon < 3 THEN SLEEP 2: WHILE INKEY$ <> "": WEND ' se non abbandona aspetta un tasto /if it doesn't resign , it waits a key
  290. FOR i = 1 TO 30
  291.     COLOR 1 + INT(RND * 15)
  292.     LOCATE i, i + 20
  293.     PRINT c$;
  294. SLEEP 3: WHILE INKEY$ <> "": WEND ' aspetta almeno 3 secondi/ it waits at least 3 seconds
  295.  
  296. InitializeScreen: ' crea la schermata iniziale del gioco / it creates initial screen game
  297. LOCATE 4, 23: PRINT "TIC TAC TOE by Paul Meyer & TheBOB"
  298. LOCATE 7, 27: PRINT "(C) 2004 - 2007 Dos-Id Games"
  299. LOCATE 5, 23: PRINT "Debugged and improved IA by TempodiBasic"
  300. ds% = 131: dd% = 97: dz% = 75 ' i 4 pulsanti / 4 buttons
  301. LINE (ds%, 343)-(ds% + dz%, 380), , BF
  302. LINE (ds% + (1 * dd%), 343)-(ds% + (1 * dd%) + dz%, 380), , BF
  303. LINE (ds% + (2 * dd%), 343)-(ds% + (2 * dd%) + dz%, 380), , BF
  304. LINE (ds% + (3 * dd%), 343)-(ds% + (3 * dd%) + dz%, 380), , BF
  305. LOCATE 23, 19: PRINT " Easy "; ' 4 comandi per pulsanti / 4 command for buttons
  306. LOCATE , 31: PRINT " Hard ";
  307. LOCATE , 43: PRINT " Info ";
  308. LOCATE , 55: PRINT " Quit "
  309.  
  310. FindClickedCommand: ' da un significato al click / it gives a signify to click
  311. Command = 0
  312. SELECT CASE cV ' click in posizione verticale fuori oggetti / click in vertical position out of objects
  313.     CASE IS < 343: RETURN
  314.     CASE IS > 380: RETURN
  315. SELECT CASE cH ' click in posizione orizzontale / click in horizontal position
  316.     CASE IS < 130: RETURN ' area vuota / void area
  317.     CASE IS < 205: Command = 1 ' tra 130 e 204 /between 130 and 204
  318.     CASE IS < 227: RETURN ' area vuota / void area
  319.     CASE IS < 303: Command = 2 'tra 227 e 302 / between 227 e 302
  320.     CASE IS < 325: RETURN ' area vuota / void area
  321.     CASE IS < 400: Command = 3 ' tra 325 e 399/ between 325 e 399
  322.     CASE IS < 421: RETURN ' area vuota / void area
  323.     CASE IS < 497: Command = 4 ' tra 421 e 496/ between 421 and 496
  324.  
  325.  
  326. DoHelp: ' subroutine vecchio stile con gosub_return/ soubroutine old style by gosub_return
  327. ' mostra info / it shows info
  328. LOCATE 3, 1
  329. PRINT "Credits"
  330. PRINT "-------"
  331. PRINT "This game was created by Paul Meyer in the year 2007."
  332. PRINT: PRINT "Graphics by TheBob"
  333. PRINT: PRINT "Improved mouse driver, modularity, machine play-to-win";
  334. PRINT " by QBasic Mac"
  335. PRINT " Debugging and improve IA by TempodiBasic"
  336. PRINT: PRINT "History:"
  337. PRINT "http://www.network54.com/Forum/190883/message/1175106480"
  338. PRINT "following QB64 package for years, debugged in 09 07 2016"
  339. PRINT "This is freeware, you may change this as much as you want"
  340. PRINT "as long as you don't claim it as yours."
  341. PRINT "About"
  342. PRINT "-----"
  343. PRINT "This is just a simple TIC TAC TOE game with mouse drivers."
  344. PRINT "This game was created in QuickBasic."
  345. CALL GetUserSignal 'aspetta un click o tasto premuto /it waits for a click o key_pressed
  346.  
  347. SUB DrawSCREEN ' crea schermata gioco / it draws screen of game
  348. STATIC Finished AS INTEGER
  349. ' scrive direttamente codice esadecimale alla RAM video
  350. ' it writes directly Hex code into RAM of video
  351. OUT &H3C8, 0: OUT &H3C9, 0: OUT &H3C9, 0: OUT &H3C9, 18
  352. OUT &H3C8, 4: OUT &H3C9, 63: OUT &H3C9, 0: OUT &H3C9, 0
  353. OUT &H3C8, 9: OUT &H3C9, 0: OUT &H3C9, 12: OUT &H3C9, 48
  354. OUT &H3C8, 11: OUT &H3C9, 0: OUT &H3C9, 18: OUT &H3C9, 54
  355. COLOR 7: LOCATE 3, 31: PRINT "T I C - T A C - T O E"
  356. LINE (170, 90)-(490, 410), 0, BF
  357. LINE (160, 81)-(479, 399), 1, BF
  358. LINE (155, 76)-(483, 404), 8, B
  359. LINE (152, 73)-(487, 407), 8, B
  360. LINE (160, 81)-(160, 399), 9
  361. LINE (160, 81)-(479, 81), 9
  362. LINE (371, 92)-(372, 393), 0, B
  363. LINE (271, 92)-(272, 392), 0, B
  364. LINE (171, 191)-(472, 192), 0, B
  365. LINE (171, 291)-(472, 292), 0, B
  366. LINE (369, 90)-(370, 390), 13, B
  367. LINE (269, 90)-(270, 390), 13, B
  368. LINE (169, 189)-(470, 190), 13, B
  369. LINE (169, 289)-(470, 290), 13, B
  370. LINE (5, 5)-(634, 474), 8, B
  371. LINE (10, 10)-(629, 469), 8, B
  372. IF Finished THEN EXIT SUB
  373. Finished = True ' la prima volta imposta finished = vero  / first time it sets finished = true
  374. ' e poi genera i simboli 0 e X e li mette in array per immagini alle posizioni 0 e 3000
  375. ' and the it makes symbols 0 and X and it puts them in array for images at positions 0 and 3000
  376. FOR x = 194 TO 500
  377.     FOR y = 32 TO 46
  378.         IF POINT(x, y) = 8 THEN PSET (x, y), 7
  379.     NEXT y
  380. PSET (188, 108), 0
  381. DRAW "E3 F30 E30 F6 G30 F30 G6 H30 G30 H6 E30 H30 E3 BF2 P0,0"
  382. PSET (186, 106), 10
  383. DRAW "E3 F30 E30 F6 G30 F30 G6 H30 G30 H6 E30 H30 E3 BF2 P10,10"
  384. CIRCLE (322, 141), 31, 0
  385. CIRCLE (322, 141), 37, 0
  386. PAINT STEP(0, 35), 0
  387. PSET STEP(0, -35), 0
  388. CIRCLE (320, 139), 31, 4
  389. CIRCLE (320, 139), 37, 4
  390. PAINT STEP(0, 35), 4
  391. PSET STEP(0, -35), 1
  392. GET STEP(-40, -40)-STEP(81, 81), SymbolBOX() ' mette 0 in posizione 0 / it puts 0 in position 0
  393. GET (179, 98)-(260, 178), SymbolBOX(3000) 'mette X in posizione 3000 / it puts X in position 3000
  394. xo 1, 1, 2: xo 1, 2, 2 ' cancella i simboli dalle celle / it cancels symbols from cells
  395.  
  396. SUB EnableMouse (c%)
  397. STATIC Status AS INTEGER ' variabile conservata / variable stored
  398. ' status indica lo stato del mouse 0 spento 1 acceso       / status shows 0 mouse off 1 mouse on
  399. ' c% Š la funzione da eseguire 0 spegnere 1 accendere 3 rilevare/ C% is function to act 0 turn off 3 detect
  400. IF Status = 0 AND c% = 0 THEN EXIT SUB
  401. STATIC Mx AS STRING 'variabile conservata/ variable stored
  402. IF Mx = "" THEN 'inizializza Mx / it inizializes Mx
  403.     m$ = "58E85080585080585080850815510C358508058508085080850815C00"
  404.     n$ = "595BECB70BEAB70BE8BFBE6B7B8E7D33BEC978BEA97BE89FBE697DA80"
  405.     Mx = SPACE$(57) ' Mx  Š di 57 bytes / Mx is of 57 bytes
  406.     FOR i% = 1 TO 57
  407.         ' virtuosismo che carica codici esadecimali in Mx suddivisi nelle due stringhe
  408.         ' virtuosity it loads Hexadecimal codexes in Mx broke down them in two strings
  409.         H$ = CHR$(VAL("&H" + MID$(m$, i%, 1) + MID$(n$, i%, 1)))
  410.         MID$(Mx, i%, 1) = H$
  411.     NEXT i%
  412. IF c% = 0 THEN '  se deve spegnerlo/ if it must turn off
  413.     'usa interrupt scritto in Mx per il mouse tramite call absolute
  414.     ' it uses interrupt written in Mx for mouse by call absolute
  415.     CALL ABSOLUTE(2, click, cH, cV, SADD(Mx))
  416.     Status = 0
  417.     EXIT SUB
  418. ' se Š spento il mouse lo accende / if mouse is off, it turn on
  419. 'usa interrupt scritto in Mx per il mouse tramite call absolute
  420. ' it uses interrupt written in Mx for mouse by call  absolute
  421. IF Status = 0 THEN CALL ABSOLUTE(1, click, cH, cV, SADD(Mx))
  422. Status = 1
  423. ' rileva il mouse/ it detects mouse
  424. 'usa interrupt scritto in Mx per il mouse tramite call absolute
  425. ' it uses interrupt written in Mx for mouse by call absolute
  426. CALL ABSOLUTE(3, click, cH, cV, SADD(Mx))
  427. ' la variabile click Š True se l'utente ha cliccato
  428. 'variable click is True if user have made click
  429.  
  430. ' prende input / get input
  431. SUB GetUserSignal
  432.     IF 0 THEN ' Set to 1 for Debugging printout, otherwise 0
  433.         LOCATE 2, 1
  434.         PRINT click; "<Click"
  435.         PRINT cH; "ch (Horizontal)"
  436.         PRINT cV; "cv (Verticle)"
  437.     END IF
  438.     EnableMouse 1 ' attiva mouse  / it enables mouse
  439.     IF click > 0 THEN
  440.         ' se c'Š click la conservo in K% e aspetto che il tasto sia rilasciato
  441.         ' if there is click I store it in k% and I wait until button is released
  442.         k% = click
  443.         WHILE click <> 0: EnableMouse 1: WEND
  444.         click = k%
  445.         EXIT DO ' esce dal loop esterno / it exits from outer loop
  446.     END IF
  447.     cC = INKEY$ ' utente pu•  uscire premendo un tasto / user can exit pressing a key
  448. LOOP WHILE cC = ""
  449. EnableMouse 0 ' spegne il mouse / it turns off mouse
  450.  
  451. ' verifica se O ha vinto / it verifies if O won
  452. FUNCTION OWin% (b1 AS INTEGER, b2 AS INTEGER, b3 AS INTEGER, l AS INTEGER)
  453. IF zO(b1) = 0 OR zO(b2) = 0 OR zO(b3) = 0 THEN EXIT FUNCTION ' se una celle Š vuota esce / if one of these cells is void it exits
  454. Winner l ' evidenzia graficamente il tris / it marks up graphically tris
  455. OWin% = -1
  456.  
  457. SUB Winner (Lineup AS INTEGER) 'evidenzia il tris con una linea/ it shows tris by a line
  458. SELECT CASE Lineup
  459.     CASE 1: LINE (200, 140)-(440, 142), 14, BF: LINE (200, 143)-(440, 144), 0, B
  460.     CASE 2: LINE (200, 240)-(440, 242), 14, BF: LINE (200, 243)-(440, 244), 0, B
  461.     CASE 3: LINE (200, 340)-(440, 342), 14, BF: LINE (200, 343)-(440, 344), 0, B
  462.     CASE 4: LINE (220, 120)-(222, 360), 14, BF: LINE (223, 120)-(223, 360), 0
  463.     CASE 5: LINE (320, 120)-(322, 360), 14, BF: LINE (323, 120)-(323, 360), 0
  464.     CASE 6: LINE (420, 120)-(422, 360), 14, BF: LINE (423, 120)-(423, 360), 0
  465.     CASE 7: PSET (200, 120), 14: DRAW "F240 d H240 d F240 d H240 d C0 F240 d H240"
  466.     CASE 8: PSET (440, 120), 14: DRAW "G240 d E240 d G240 d E240 d C0 G240 d E240"
  467.  
  468. ' disegna la cella con simbolo se symbol Š 0 o 1 o la cella vuota se symbol Š 2
  469. ' it draws cell with symbol if symbol is 0 or 1 or cell void if symbol is 2
  470. SUB xo (Row AS INTEGER, Col AS INTEGER, symbol AS INTEGER)
  471. x = (Col - 1) * 100 + 180
  472. y = (Row - 1) * 100 + 100
  473. Index = symbol * 3000
  474. IF Index < 6000 THEN
  475.     PUT (x, y), SymbolBOX(Index), PSET
  476.     LINE (x, y)-(x + 80, y + 80), 1, BF
  477.  
  478. 'verifica che X ha fatto tris / it verifies if X have got tris
  479. FUNCTION XWin% (b1 AS INTEGER, b2 AS INTEGER, b3 AS INTEGER, l AS INTEGER)
  480. IF zX(b1) = 0 OR zX(b2) = 0 OR zX(b3) = 0 THEN EXIT FUNCTION ' se una delle celle Š  vuota esce/ if one of these cells is voit it exits
  481. Winner l ' evidenzia grafica del tris / it marks up graphically the tris
  482. XWin% = -1
  483.  
  484.  
Programming isn't difficult, only it's  consuming time and coffee

Offline EricE

  • Forum Regular
  • Posts: 114
    • View Profile
Re: QBasic OS
« Reply #24 on: March 30, 2020, 09:55:41 am »
Thank you TempodiBasic.

Offline EricE

  • Forum Regular
  • Posts: 114
    • View Profile
Re: QBasic OS
« Reply #25 on: April 03, 2020, 01:25:04 am »
The source code for the MMURTL V1.0 operating system is available for download.
A whole book in pdf form about MMURTL can also be downloaded.

http://www.ipdatacorp.com/mmurtl/

Both OS and book are by the same author who wrote "Developing Your own 32 Bit Operating System" published in 1995.
There probably are some good ideas contained in both the book and source code.