Tic-tac-toe: Difference between revisions
Content deleted Content added
mNo edit summary |
m Simplified code to turn off flashing cursor |
||
Line 2,294: | Line 2,294: | ||
</pre> |
</pre> |
||
=={{header|XPL0}}== |
|||
[[File:TTTXPL0.GIF|right]] |
[[File:TTTXPL0.GIF|right]] |
||
<lang XPL0>\The computer marks its moves with an "O" and the player uses an "X". The |
<lang XPL0>\The computer marks its moves with an "O" and the player uses an "X". The |
||
Line 2,315: | Line 2,314: | ||
int X, O; \bit arrays for player and computer |
int X, O; \bit arrays for player and computer |
||
\ bit 0 corresponds to playing square 1, etc. |
\ bit 0 corresponds to playing square 1, etc. |
||
func CallInt(Int, AX, BX, CX, DX, BP, DS, ES); \Call software interrupt |
|||
int Int, AX, BX, CX, DX, BP, DS, ES; \(unused arguments need not be passed) |
|||
⚫ | |||
[CpuReg:= GetReg; |
|||
CpuReg(0):= AX; |
|||
CpuReg(1):= BX; |
|||
CpuReg(2):= CX; |
|||
CpuReg(3):= DX; |
|||
CpuReg(6):= BP; |
|||
CpuReg(9):= DS; |
|||
CpuReg(11):= ES; |
|||
⚫ | |||
return CpuReg(0); \return AX register |
|||
]; \CallInt |
|||
Line 2,407: | Line 2,391: | ||
proc PlayGame; \Play one game |
proc PlayGame; \Play one game |
||
int I, V, V0; |
|||
[ChOut(0, $0C\FF\); \clear screen with a form feed |
[ChOut(0, $0C\FF\); \clear screen with a form feed |
||
HLine(X0-1, Y0+1); \draw grid (#) |
HLine(X0-1, Y0+1); \draw grid (#) |
||
Line 2,445: | Line 2,428: | ||
⚫ | |||
[SetVid(1); \set 40x25 text mode |
[SetVid(1); \set 40x25 text mode |
||
CpuReg:= GetReg; \turn off annoying flashing cursor |
|||
CpuReg(0):= $0100; \ with BIOS interrupt 10h, function 01h |
|||
CpuReg(2):= $2000; \set cursor type to disappear |
|||
⚫ | |||
loop [PlayGame; |
loop [PlayGame; |
||
Key:= ChIn(1); \keep playing games until Esc key is hit |
Key:= ChIn(1); \keep playing games until Esc key is hit |