Reste plus qu'à lui apprendre le Basic VG5000, Oric, EXL, Amstrad....
Code : Tout sélectionner
10 REM Tic Tac Toe game in Microsoft Basic
20 REM Initialize the game board
30 DIM board(3,3)
40 FOR x = 1 TO 3
50 FOR y = 1 TO 3
60 board(x,y) = " "
70 NEXT y
80 NEXT x
90 REM Main game loop
100 FOR turn = 1 TO 9
110 PRINT "Tic Tac Toe"
120 PRINT "Turn: "; turn
130 PRINT "1 2 3"
140 FOR x = 1 TO 3
150 PRINT x;
160 FOR y = 1 TO 3
170 PRINT board(x,y);
180 NEXT y
190 PRINT
200 NEXT x
210 REM Get player input
220 INPUT "Enter row (1-3): ", row
230 INPUT "Enter column (1-3): ", col
240 REM Check for valid input
250 IF row < 1 OR row > 3 OR col < 1 OR col > 3 THEN 220
260 REM Check if the spot is already taken
270 IF board(row,col) <> " " THEN 220
280 REM Place the player's mark on the board
290 IF turn MOD 2 = 1 THEN board(row,col) = "X" ELSE board(row,col) = "O"
300 REM Check for a win
310 IF board(1,1) = board(1,2) AND board(1,2) = board(1,3) THEN PRINT "Player "; board(1,1); " wins!" : END
320 IF board(2,1) = board(2,2) AND board(2,2) = board(2,3) THEN PRINT "Player "; board(2,1); " wins!" : END
330 IF board(3,1) = board(3,2) AND board(3,2) = board(3,3) THEN PRINT "Player "; board(3,1); " wins!" : END
340 IF board(1,1) = board(2,1) AND board(2,1) = board(3,1) THEN PRINT "Player "; board(1,1); " wins!" : END
350 IF board(1,2) = board(2,2) AND board(2,2) = board(3,2) THEN PRINT "Player "; board(1,2); " wins!" : END
360 IF board(1,3) = board(2,3) AND board(2,3) = board(3,3) THEN PRINT "Player "; board(1,3); " wins!" : END
370 IF board(1,1) = board(2,2) AND board(2,2) = board(3,3) THEN PRINT "Player "; board(1,1); " wins!" : END
380 IF board(3,1) = board(2,2) AND board(2,2) = board(1,3) THEN PRINT "Player "; board(3,1); " wins!" : END
390 NEXT turn
400 PRINT "It's a tie!"
En ASM Z80
Code : Tout sélectionner
; Tic Tac Toe game for Z80
section .data
board: db 0,0,0,0,0,0,0,0,0 ; Initialize the game board
player: db 1 ; Keep track of which player's turn it is
section .text
global _start
_start:
; Main game loop
ld hl, board ; Set HL to the start of the board
call draw_board
call get_input
call check_win
call switch_player
jp _start
; Draw the current state of the board on the screen
draw_board:
ld de, board ; Set DE to the start of the board
ld bc, 9 ; Set BC to the number of spaces on the board
call print_board
ret
; Get input from the player
get_input:
call read_input
ret
; Check if the game has been won
check_win:
call check_rows
call check_columns
call check_diagonals
ret
; Switch the current player
switch_player:
ld a, player
cp 1
jr z, set_player_2
ld a, 1
jr set_player
set_player_2:
ld a, 2
set_player:
ld player, a
ret
; Print the board
print_board:
; code to print the board
ret
; Read input from the player
read_input:
; code to read input from the player
ret
; Check rows for a win
check_rows:
; code to check rows for a win
ret
; Check columns for a win
check_columns:
; code to check columns for a win
ret
; Check diagonals for a win
check_diagonals:
; code to check diagonals for a win
ret
CarlNotez que ce code n'est qu'un squelette de programme, il manque les instructions pour afficher le plateau de jeu, récupérer les entrées utilisateurs, vérifier les victoires, etc.. Il est nécessaire d'utiliser des instructions spécifiques à la plateforme Z80 pour gérer les entrées/sorties, l'affichage et la mémoire pour pouvoir compléter le code et le rendre fonctionnel.