RosettaCodeData/Task/Image-noise/XPL0/image-noise.xpl0
2023-07-01 13:44:08 -04:00

26 lines
1.3 KiB
Text

include c:\cxpl\codes; \intrinsic 'code' declarations
int CpuReg, \address of CPU register array (from GetReg)
FPS, \frames per second, the display's update rate
Sec, \current second of time (from real-time clock)
SecOld, \previous second of time
X, Y;
[SetVid($101); \set 640x480 graphics
CpuReg:= GetReg; \get address of array to access CPU registers
FPS:= 0;
repeat CpuReg(0):= $0200; \get current time in seconds from BIOS
SoftInt($1A); \software interrupt
Sec:= CpuReg(3)>>8 & $FF; \register DH contains seconds
if Sec = SecOld then \if same as before then
FPS:= FPS+1 \ bump FPS counter
else [SecOld:= Sec; \otherwise save old seconds and
CrLf(6);
IntOut(6, FPS); \ display FPS counter (once per second)
Text(6, " FPS");
FPS:= 0; \ reset FPS counter
];
for Y:= 0, 240-1 do \fill image with random black and white pixels
for X:= 0, 320-1 do
Point(X, Y, if Ran(2) then $F\white\ else 0\black\);
until KeyHit;
SetVid(3); \restore normal text mode
]