X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=16%2Fx_%2Fmodex%2FDEMO07.PAS;fp=16%2Fx_%2Fmodex%2FDEMO07.PAS;h=04fff790e3150f387ecb57354f65a80a104199ae;hb=47cdc66151d973d975d0e31fb8a786eb639bebdb;hp=0000000000000000000000000000000000000000;hpb=4b23f27092a9470a741e3a18261ad389fd1929db;p=16.git diff --git a/16/x_/modex/DEMO07.PAS b/16/x_/modex/DEMO07.PAS new file mode 100755 index 00000000..04fff790 --- /dev/null +++ b/16/x_/modex/DEMO07.PAS @@ -0,0 +1,68 @@ +(* + DEMO07 - Hardware scrolling + Copyright (c) 1994 Alessandro Scotti +*) +uses Crt, Modex; + +const + (* Change this if scrolling seems jerky (this simple program does *) + (* not handle vertical retrace/display very well) *) + STEPS = 5; + +procedure Check( Cond: boolean; var Coord, DeltaC: integer; NewCoord, Sign: integer ); +begin + if( Cond ) then begin + Coord := NewCoord; + DeltaC := Sign*(Random(3)+2); + end; +end; + +var + I, X, Y, DX, DY: integer; +begin + (* Initialize library and graphics mode *) + mxInit; + mxSetMode( MX_320x200 ); + (* Set a 640x400 virtual screen *) + mxSetVirtualScreen( 640, 400 ); + mxSetClip( TRUE ); + + X := 0; + Y := 0; + DX := 1; + DY := 1; + + (* Main loop: draw lines, circles, points and rectangles in separate *) + (* 320x200 windows, while smoothly panning virtual screen *) + while( not KeyPressed ) do begin + (* Points *) + mxSetClipRegion( 0, 0, 320, 200 ); + for I:=1 to STEPS do + mxPutPixel( Random(320), Random(200), Random(16) ); + (* Lines *) + mxSetClipRegion( 0, 200, 320, 200 ); + for I:=1 to STEPS do + mxLine( Random(320), Random(200)+200, Random(320), Random(200)+200, Random(16), OP_SET ); + (* Circles *) + mxSetClipRegion( 320, 0, 320, 200 ); + for I:=1 to STEPS do + mxCircle( Random(320)+320, Random(200), Random(100), Random(16) ); + (* Boxes *) + mxSetClipRegion( 320, 200, 320, 200 ); + for I:=1 to STEPS do + mxFillBox( Random(320)+320, Random(200)+200, Random(100)+1, Random(100)+1, Random(16), OP_SET ); + (* Pan *) + Inc( X, DX ); + Check( X+320 >= 639, X, DX, 319, -1 ); + Check( X < 0, X, DX, 0, +1 ); + Inc( Y, DY ); + Check( Y+200 >= 399, Y, DY, 199, -1 ); + Check( Y < 0, Y, DY, 0, +1 ); + mxPan( X, Y ); + mxWaitRetrace; + end; + + (* Shutdown *) + mxSetMode( MX_TEXT ); + mxTerm; +end.