]> 4ch.mooo.com Git - 16.git/blob - 16/x_/modex/DEMO07.PAS
trying to translate that lib into open watcom...
[16.git] / 16 / x_ / modex / DEMO07.PAS
1 (*\r
2     DEMO07 - Hardware scrolling\r
3     Copyright (c) 1994 Alessandro Scotti\r
4 *)\r
5 uses Crt, Modex;\r
6 \r
7 const\r
8   (* Change this if scrolling seems jerky (this simple program does *)\r
9   (* not handle vertical retrace/display very well) *)\r
10   STEPS = 5;\r
11 \r
12 procedure Check( Cond: boolean; var Coord, DeltaC: integer; NewCoord, Sign: integer );\r
13 begin\r
14   if( Cond ) then begin\r
15     Coord := NewCoord;\r
16     DeltaC := Sign*(Random(3)+2);\r
17   end;\r
18 end;\r
19 \r
20 var\r
21   I, X, Y, DX, DY: integer;\r
22 begin\r
23   (* Initialize library and graphics mode *)\r
24   mxInit;\r
25   mxSetMode( MX_320x200 );\r
26   (* Set a 640x400 virtual screen *)\r
27   mxSetVirtualScreen( 640, 400 );\r
28   mxSetClip( TRUE );\r
29 \r
30   X := 0;\r
31   Y := 0;\r
32   DX := 1;\r
33   DY := 1;\r
34 \r
35   (* Main loop: draw lines, circles, points and rectangles in separate *)\r
36   (* 320x200 windows, while smoothly panning virtual screen *)\r
37   while( not KeyPressed ) do begin\r
38     (* Points *)\r
39     mxSetClipRegion( 0, 0, 320, 200 );\r
40     for I:=1 to STEPS do\r
41       mxPutPixel( Random(320), Random(200), Random(16) );\r
42     (* Lines *)\r
43     mxSetClipRegion( 0, 200, 320, 200 );\r
44     for I:=1 to STEPS do\r
45       mxLine( Random(320), Random(200)+200, Random(320), Random(200)+200, Random(16), OP_SET );\r
46     (* Circles *)\r
47     mxSetClipRegion( 320, 0, 320, 200 );\r
48     for I:=1 to STEPS do\r
49       mxCircle( Random(320)+320, Random(200), Random(100), Random(16) );\r
50     (* Boxes *)\r
51     mxSetClipRegion( 320, 200, 320, 200 );\r
52     for I:=1 to STEPS do\r
53       mxFillBox( Random(320)+320, Random(200)+200, Random(100)+1, Random(100)+1, Random(16), OP_SET );\r
54     (* Pan *)\r
55     Inc( X, DX );\r
56     Check( X+320 >= 639, X, DX, 319, -1 );\r
57     Check( X < 0, X, DX, 0, +1 );\r
58     Inc( Y, DY );\r
59     Check( Y+200 >= 399, Y, DY, 199, -1 );\r
60     Check( Y < 0, Y, DY, 0, +1 );\r
61     mxPan( X, Y );\r
62     mxWaitRetrace;\r
63   end;\r
64 \r
65   (* Shutdown *)\r
66   mxSetMode( MX_TEXT );\r
67   mxTerm;\r
68 end.\r