Tic-tac-toe: Difference between revisions

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