RosettaCodeData/Task/Animation/XPL0/animation.xpl0

24 lines
1.1 KiB
Plaintext

include c:\cxpl\codes;
int CpuReg, Dir, I, J;
char Str;
string 0; \use zero-terminated strings, instead of MSb set
[CpuReg:= GetReg; \provides access to 8086 CPU registers
\ 0123456789012
Str:= "Hello World! ";
Clear;
Dir:= -1; \make string initially scroll to the right
I:= 0; \index to start of displayed portion of string
repeat Cursor(0, 0); \set cursor position to upper-left corner
for J:= 0 to 12 do
[ChOut(0, Str(I)); I:= I+1; if I>12 then I:= 0];
Sound(0, 2, 1); \delay about 1/9 second
I:= I+Dir; \step starting position of displayed string
if I<0 then I:=12; \wraparound
if I>12 then I:= 0;
CpuReg:= GetReg; \get mouse button press information
CpuReg(0):= 5; CpuReg(1):= 0;
SoftInt($33); \reverse direction if left button was pressed
if CpuReg(1) then Dir:= -Dir;
until KeyHit; \any keystroke terminates program
]