home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / MODEX104.ZIP / TEST5.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-14  |  16KB  |  488 lines

  1. {                      ModeX Turbo Pascal Demo Program                       }
  2. {                  Converted to Turbo Pascal by Scott Wyatt                  }
  3. {          Original program written in QuickBasic by Matt Prichard           }
  4. {                       Released to the Public Domain                        }
  5. {                                                                            }
  6. {          Thanks to Matt Prichard for his *EXCELLENT* ModeX Library         }
  7. {           Additional Comments by Matt Pritchard                             }
  8.  
  9. Uses Crt;
  10.  
  11. {$L modex2.obj}        { This file is the external ModeX Library .OBJ }
  12. {$F+}
  13.  
  14.     { Mode Setting Routines }
  15.  
  16. Function SET_VGA_MODEX (Mode,MaxXpos,MaxYpos,Pages : integer) : integer; external;
  17. Function SET_MODEX (Mode:integer) : Integer; external;
  18.  
  19.     { Graphics Primitives }
  20.  
  21. Procedure CLEAR_VGA_SCREEN (Color:integer); external;
  22. Procedure SET_POINT (Xpos,Ypos,Color : integer); external;
  23. Function READ_POINT (Xpos,Ypos:integer) : integer; external;
  24. Procedure FILL_BLOCK (Xpos1,Ypos1,Xpos2,Ypos2,Color:integer); external;
  25. Procedure DRAW_LINE (Xpos1,Ypos1,Xpos2,Ypos2,Color:integer); external;
  26.  
  27.     { VGA DAC Routines }
  28.  
  29. Procedure SET_DAC_REGISTER (RegNo,Red,Green,Blue:integer); external;
  30. Procedure GET_DAC_REGISTER (RegNo,Red,Green,Blue:integer); external;
  31.  
  32.     { Page and Window Control Routines }
  33.  
  34. Procedure SET_ACTIVE_PAGE (PageNo:integer); external;
  35. Function GET_ACTIVE_PAGE : integer; external;
  36. Procedure SET_DISPLAY_PAGE (PageNo:integer); external;
  37. Function GET_DISPLAY_PAGE : integer; external;
  38. Procedure SET_WINDOW (DisplayPage,XOffset,YOffset : integer); external;
  39. Function GET_X_OFFSET : integer; external;
  40. Function GET_Y_OFFSET : integer; external;
  41. Procedure SYNC_DISPLAY; external;
  42.  
  43.     { Text Display Routines }
  44.  
  45. Procedure GPRINTC (CharNum,Xpos,Ypos,ColorF,ColorB:integer); external;
  46. Procedure TGPRINTC ( CharNum,Xpos,Ypos,ColorF : integer); external;
  47. Procedure PRINT_STR (Var Text;MaxLen,Xpos,Ypos,ColorF,ColorB:integer); external;
  48. Procedure TPRINT_STR (Var Text;MaxLen,Xpos,Ypos,ColorF:integer); external;
  49. Procedure SET_DISPLAY_FONT (Var FontData;FontNumber:integer); external;
  50.  
  51.     { Sprite and VGA memory -> Vga memory Copy Routines }
  52.  
  53. Procedure DRAW_BITMAP (Var Image;Xpos,Ypos,Width,Height:integer); external;
  54. Procedure TDRAW_BITMAP (Var Image;Xpos,Ypos,Width,Height:integer); external;
  55. Procedure COPY_PAGE (SourcePage,DestPage:integer); external;
  56. Procedure COPY_BITMAP (SourcePage,X1,Y1,X2,Y2,DestPage,DestX1,DestY1:integer); external;
  57.  
  58. {$F-}
  59.  
  60.  
  61. TYPE Sprite = Record
  62.     Xpos : INTEGER;
  63.     Ypos : INTEGER;
  64.     XDir : INTEGER;
  65.     YDir : INTEGER;
  66.     Shape : INTEGER;
  67.     LastX : INTEGER;
  68.     LastY : INTEGER;
  69.      END;
  70.  
  71.  
  72. CONST MaxShapes = 32;
  73.       Circle_16 : Array[1..16,1..16] of byte =
  74.       ((  0,  0,  0,  0,  0,  0, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0),
  75.        (  0,  0,  0,  0, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0),
  76.        (  0,  0,  0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0),
  77.        (  0,  0, 20, 20, 20, 20,  0,  0,  0,  0, 20, 20, 20, 20,  0,  0),
  78.        (  0, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0, 20, 20, 20, 20,  0),
  79.        (  0, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0, 20, 20, 20,  0),
  80.        ( 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20, 20, 20),
  81.        ( 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20, 20, 20),
  82.        ( 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20, 20, 20),
  83.        ( 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20, 20, 20),
  84.        (  0, 20, 20, 20,  0,  0,  0,  0,  0,  0,  0,  0, 20, 20, 20,  0),
  85.        (  0, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0, 20, 20, 20, 20,  0),
  86.        (  0,  0, 20, 20, 20, 20,  0,  0,  0,  0, 20, 20, 20, 20,  0,  0),
  87.        (  0,  0,  0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0),
  88.        (  0,  0,  0,  0, 20, 20, 20, 20, 20, 20, 20, 20,  0,  0,  0,  0),
  89.        (  0,  0,  0,  0,  0,  0, 20, 20, 20, 20,  0,  0,  0,  0,  0,  0));
  90.       Square_16 : Array[1..16,1..16] of byte =
  91.       (( 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21),
  92.        ( 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21),
  93.        ( 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21),
  94.        ( 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21),
  95.        ( 21, 21, 21, 21,  0,  0,  0,  0,  0,  0,  0,  0, 21, 21, 21, 21),
  96.        ( 21, 21, 21, 21,  0,  0,  0,  0,  0,  0,  0,  0, 21, 21, 21, 21),
  97.        ( 21, 21, 21, 21,  0,  0,  0,  0,  0,  0,  0,  0, 21, 21, 21, 21),
  98.        ( 21, 21, 21, 21,  0,  0,  0,  0,  0,  0,  0,  0, 21, 21, 21, 21),
  99.        ( 21, 21, 21, 21,  0,  0,  0,  0,  0,  0,  0,  0, 21, 21, 21, 21),
  100.        ( 21, 21, 21, 21,  0,  0,  0,  0,  0,  0,  0,  0, 21, 21, 21, 21),
  101.        ( 21, 21, 21, 21,  0,  0,  0,  0,  0,  0,  0,  0, 21, 21, 21, 21),
  102.        ( 21, 21, 21, 21,  0,  0,  0,  0,  0,  0,  0,  0, 21, 21, 21, 21),
  103.        ( 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21),
  104.        ( 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21),
  105.        ( 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21),
  106.        ( 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21));
  107.        Diamond : Array[1..8,1..8] of byte =
  108.       ((  0,  0,  0, 22, 22,  0,  0,  0),
  109.        (  0,  0, 22, 22, 22, 22,  0,  0),
  110.        (  0, 22, 22,  0,  0, 22, 22,  0),
  111.        ( 22, 22,  0,  0,  0,  0, 22, 22),
  112.        ( 22, 22,  0,  0,  0,  0, 22, 22),
  113.        (  0, 22, 22,  0,  0, 22, 22,  0),
  114.        (  0,  0, 22, 22, 22, 22,  0,  0),
  115.        (  0,  0,  0, 22, 22,  0,  0,  0));
  116.        Rectangle : Array[1..8,1..3] of byte =
  117.       (( 23, 23, 23),
  118.        ( 23, 23, 23),
  119.        ( 23, 23, 23),
  120.        ( 23, 23, 23),
  121.        ( 23, 23, 23),
  122.        ( 23, 23, 23),
  123.        ( 23, 23, 23),
  124.        ( 23, 23, 23));
  125.  
  126.        { Global Variables ? }
  127.  
  128. Var
  129.   XCenter,X1,Y1,X2,Y2,Z,Colr,XChars,YChars,X,Y,N,Gap : Integer;
  130.   s : string;
  131.   s1 : Array[1..35] of Char;
  132.   ch : Char;
  133.   obj : Array[1..64] of Sprite;
  134.   ScreenX,ScreenY : Integer;
  135.   c, dc, SpriteX, SpriteY, CurrentPage, LastPage : Integer;
  136.   SetColor, SDir, PrevColor, PDir : Byte;
  137.   XView, YView : Integer;
  138.   XView_Change, YView_Change : Integer;
  139.   Right : Boolean;
  140.   Number_Of_Shapes : Byte;
  141.  
  142.  
  143.     { Error Handler - Returns to Text Mode & Displays Error }
  144.  
  145. Procedure ERROR_OUT(s : string);
  146.   Begin
  147.     asm
  148.       mov ah,0
  149.       mov al,3
  150.       int 10h
  151.     end;
  152.   WriteLn(s);
  153.   Halt(0);
  154. END;
  155.  
  156.     { Routine to Print a PASCAL string using Print_Str }
  157.  
  158. Procedure Print_Text(s : string; X,Y,BColor,FColor : integer);
  159. Var
  160.   s1 : Array[1..135] of Char;
  161.   i : byte;
  162. Begin
  163.   For i := 1 to Length(s) DO
  164.     s1[i] := s[i];
  165.   Print_Str(s1,Length(s),X,Y,BColor,FColor);
  166. End;
  167.  
  168.     { Routine to Transparently Print a PASCAL string using TPrint_Str }
  169.  
  170. Procedure TPrint_Text(s : string; X,Y,Color : integer);
  171. Var
  172.   s1 : Array[1..135] of Char;
  173.   i : byte;
  174. Begin
  175.   For i := 1 to Length(s) DO
  176.     s1[i] := s[i];
  177.   TPrint_Str(s1,Length(s),X,Y,Color);
  178. End;
  179.  
  180.     { Routines to show test patterns for a given mode }
  181.  
  182. Procedure Demo_Res(Mode, Xmax, Ymax : integer);
  183. Begin
  184.  
  185.   Str(mode,s);
  186.   If Set_ModeX(Mode) = 0 Then
  187.     Error_Out('Unable to SET_MODEX '+s);
  188.   Clear_VGA_Screen(0);
  189.  
  190.   XCenter := Xmax div 2;
  191.   X1 := 10;
  192.   Y1 := 10;
  193.   X2 := Xmax - 1;
  194.   Y2 := Ymax - 1;
  195.  
  196.   FOR Z := 0 TO 3 DO
  197.     Begin
  198.       Colr := 31 - Z * 2;
  199.       Draw_Line(X1 + Z, Y1 + Z, X2 - Z, Y1 + Z, Colr);
  200.       Draw_Line(X1 + Z, Y1 + Z, X1 + Z, Y2 - Z, Colr);
  201.       Draw_Line(X1 + Z, Y2 - Z, X2 - Z, Y2 - Z, Colr);
  202.       Draw_Line(X2 - Z, Y1 + Z, X2 - Z, Y2 - Z, Colr);
  203.     End;
  204.  
  205.   XChars := Xmax div 10;
  206.   YChars := Ymax div 10;
  207.  
  208.   FOR X := 0 TO XChars - 1 DO
  209.     Begin
  210.       TGPRINTC(48 + ((X + 1) MOD 10), X * 10 + 1, 1, 9 + ((X div 8) MOD 7));
  211.       DRAW_LINE(X * 10 + 9, 0, X * 10 + 9, 3, 15);
  212.     End;
  213.   FOR Y := 0 TO YChars - 1 DO
  214.     Begin
  215.       TGPRINTC(48 + ((Y + 1) MOD 10), 1, Y * 10 + 1, 9 + ((Y div 10) MOD 7));
  216.       DRAW_LINE(0, Y * 10 + 9, 3, Y * 10 + 9, 15);
  217.     End;
  218.  
  219.    { Test Line Drawing }
  220.  
  221.   FOR X := 0 TO 63 DO
  222.     Begin
  223.       N := 15 + ((X * 3) div 4);
  224.       SET_DAC_REGISTER(64 + X, N, N, N);
  225.       SET_DAC_REGISTER(128 + X, 0, N, N);
  226.       DRAW_LINE(103 - X, 60, 40 + X, 123, 64 + X);
  227.       DRAW_LINE(40, 60 + X, 103, 123 - X, 128 + X);
  228.     End;
  229.   s := 'Line Test';
  230.   PRINT_Text(s,37,130,1,0);
  231.  
  232.   { Test Block Fills }
  233.  
  234.   Y := 60;
  235.   Gap := 0;
  236.   FOR X := 0 TO 9 DO
  237.     Begin
  238.       FILL_BLOCK(120, Y, 120 + X, Y + Gap, 64 + X);
  239.       FILL_BLOCK(140 - (15 - X), Y, 150 + X, Y + Gap, 230 + X);
  240.       FILL_BLOCK(170 - (15 - X), Y, 170, Y + Gap, 128 + X);
  241.       Y := Y + Gap + 2;
  242.       Gap := Gap + 1;
  243.     End;
  244.   s := 'Fill Test';
  245.   Print_Text(s,110, 46, 2,0);
  246.  
  247.   { Test Pixel Write and Read }
  248.  
  249.   FOR X := 190 TO 250 DO
  250.     FOR Y := 60 TO 122 DO
  251.       SET_POINT( X, Y, X + Y + X + Y);
  252.  
  253.   s := 'Pixel Test';
  254.   Print_Text(s,182, 130, 3,0);
  255.  
  256.   FOR X := 190 TO 250 DO
  257.     FOR Y := 60 TO 122 DO
  258.       IF READ_POINT(X, Y) <> ((X + Y + X + Y) AND 255) THEN
  259.         WriteLn('READ_PIXEL Failure');
  260.  
  261.     { Display rest of screen }
  262.  
  263.   s := ' This is a MODE X demo ';
  264.   Print_Text(s,XCenter - (Length(s) * 4), 20, 3, 1);
  265.   s := 'Screen Resolution is     by    ';
  266.   X := XCenter - (Length(s) * 4);
  267.   Print_Text(s,X,30,4,0);
  268.   Str(XMax,s);
  269.   Print_Text(s, X + 8 * 21, 30, 8, 0);
  270.   Str(YMax,s);
  271.   Print_Text(s, X + 8 * 28, 30, 15, 0);
  272.  
  273.   FOR X := 0 TO 15 DO
  274.     Begin
  275.       SET_DAC_REGISTER( 230 + X, 63 - X * 4, 0, 15 + X * 3);
  276.       DRAW_LINE(30 + X, Ymax - 6 - X, Xmax - 20 - X, Ymax - 6 - X, 230 + X);
  277.     End;
  278.   s := 'Press <ANY KEY> to Continue';
  279.   For x := 1 to length(s) DO
  280.     s1[x] := s[x];
  281.   TPrint_Str(s1, length(s), XCenter - (26 * 4), Ymax - 18, 5);
  282.  
  283.   Ch := ReadKey;
  284.   IF Ch = #27 Then
  285.     Error_Out('Abort');
  286.  
  287. End;
  288.  
  289.  
  290.     { Initialize Sprites for Sprite Demo }
  291.  
  292. Procedure Init_Sprites;
  293. Var i : byte;
  294. Begin
  295.   For i := 1 to 64 DO
  296.     Begin
  297.       Obj[i].XPos := Random(300)+10;
  298.       Obj[i].YPos := Random(200)+20;
  299.       Obj[i].XDir := Random(10)-5;
  300.       Obj[i].YDir := Random(10)-5;
  301.       If (Obj[i].XDir = 0) AND (Obj[i].YDir = 0) Then
  302.         Begin
  303.           Obj[i].XDir := Random(5) + 1;
  304.           Obj[i].YDir := Random(5) + 1;
  305.         End;
  306.       Obj[i].Shape := Random(4)+1;
  307.       Obj[i].LastX := obj[i].XPos;
  308.       Obj[i].LastY := obj[i].YPos;
  309.     End;
  310. End;
  311.  
  312. Procedure Set_Sprites(number : byte);
  313. Var i : Byte;
  314. Begin
  315.   For i := 1 to number DO
  316.     Begin
  317.       obj[i].LastX := obj[i].XPos;
  318.       obj[i].LastY := obj[i].YPos;
  319.       obj[i].XPos := obj[i].XPos + obj[i].XDir;
  320.       obj[i].YPos := obj[i].YPos + obj[i].YDir;
  321.       If (obj[i].XPos > 335) OR (obj[i].XPos < 5 ) Then
  322.         obj[i].XDir := -(obj[i].XDir);
  323.       If (obj[i].YPos > 220) OR (obj[i].YPos < 5) Then
  324.         obj[i].YDir := -(obj[i].YDir);
  325.     End;
  326.   For i := 1 to number DO
  327.     Case obj[i].Shape of
  328.       1 : TDraw_Bitmap(Circle_16,obj[i].XPos,obj[i].YPos,16,16);
  329.       2 : TDraw_Bitmap(Square_16,obj[i].XPos,obj[i].YPos,16,16);
  330.       3 : TDraw_Bitmap(Diamond,obj[i].XPos,obj[i].YPos,8,8);
  331.       4 : TDraw_Bitmap(Rectangle,obj[i].XPos,obj[i].YPos,3,8);
  332.     End;
  333. End;
  334.  
  335. Procedure Remove_Sprites(p,number : byte);
  336. Var i : byte;
  337. Begin
  338.   For i := 1 to number DO
  339.     Copy_Bitmap(2,obj[i].LastX,obj[i].LastY,obj[i].LastX+16,obj[i].LastY+16,p,Obj[i].LastX,Obj[i].LastY);
  340. End;
  341.  
  342. Procedure Page_Demo;
  343. Begin
  344.   Number_Of_Shapes := 64;
  345.   XView_Change := 1;
  346.   YView_Change := 1;
  347.   XView := 1;
  348.   YView := 1;
  349.   Right := TRUE;
  350.   ScreenX := 360;
  351.   ScreenY := 240;
  352.   PrevColor := 0;
  353.   SetColor := 3;
  354.   SDir := 1;
  355.   PDir := 1;
  356.   Str(0,s);
  357.  
  358.   IF SET_VGA_MODEX(0, ScreenX, ScreenY, 3) = 0 THEN
  359.     ERROR_OUT('Unable to SET_VGA_MODEX' + S);
  360.  
  361.   SET_ACTIVE_PAGE(0);
  362.   CLEAR_VGA_SCREEN(0);
  363.   PRINT_TEXT('This is a Test of the Following Functions:', 10, 9, 15, 0);
  364.   DRAW_LINE( 10, 18, 350, 18, 4);
  365.   Print_Text('SET_ACTIVE_PAGE', 10, 20, 1, 0);
  366.   Print_Text('SET_DISPLAY_PAGE', 10, 30, 3,0);
  367.   Print_Text('SET_DAC_REGISTER', 10, 40, 3, 0);
  368.   Print_Text('CLEAR_VGA_SCREEN', 10, 50, 13, 0);
  369.   Print_Text('TDRAW_BITMAP', 10, 60, 14, 0);
  370.   Print_Text('COPY_PAGE', 10, 70, 3, 0);
  371.   Print_Text('COPY_BITMAP', 10, 80, 13, 0);
  372.   Print_Text('GPRINTC', 10, 90, 1, 0);
  373.   Print_Text('TGPRINTC', 10, 100, 3, 0);
  374.   Print_Text('SYNC_DISPLAY', 10, 110, 3, 0);
  375.   Print_Text('SET_WINDOW', 10, 120, 14, 0);
  376.   Print_Text('VIRTUAL SCREEN SIZES', 190, 20, 1, 0);
  377.   Print_Text('    SMOOTH SCROLLING', 190, 30, 3, 0);
  378.   Print_Text('    SPRITE ANIMATION', 190, 40, 13, 0);
  379.   Print_Text('       PAGE FLIPPING', 190, 50, 3, 0);
  380.   Print_Text('       COLOR CYCLING', 190, 60, 14, 0);
  381.  
  382.   FOR X := 0 TO 60 DO
  383.     Begin
  384.       SET_DAC_REGISTER( 50 + X, 3 + X, 0, 60 - X);
  385.       SET_DAC_REGISTER( 150 + X, 3 + X, 0, 60 - X);
  386.     End;
  387.  
  388.   c := 0;
  389.   DC := 1;
  390.   FOR X := 0 TO ScreenX div 2 DO
  391.     Begin
  392.       DRAW_LINE( ScreenX div 2 - 1, ScreenY div 4, X, ScreenY - 1, c + 50);
  393.       DRAW_LINE( ScreenX div 2, ScreenY div 4, ScreenX - X - 1, ScreenY - 1, c + 50);
  394.       c := c + DC;
  395.       IF (c = 0) OR (c = 60) THEN DC := -DC;
  396.     End;
  397.  
  398.   TPrint_Text('Press <ESC> to Continue', 82, 190, 15);
  399.   TPrint_Text('<+> = Fewer Shapes  <-> = More Shapes', 32, 204, 12);
  400.   COPY_PAGE( 0, 1);
  401.   COPY_PAGE( 0, 2);
  402.  
  403.   Ch := #0;
  404.   CurrentPage := 1;
  405.   LastPage := 0;
  406.   Set_Sprites(Number_Of_Shapes);
  407.   For c := 1 to 4 DO
  408.     Set_Dac_Register(19+c,63-(c*10),0,0);
  409.  
  410.   While Ch <> #27 DO
  411.     Begin
  412.       Set_Active_Page(currentpage);
  413.       Set_Sprites(Number_Of_Shapes);
  414.       If Right Then
  415.         Begin
  416.           XView := XView + XView_Change;
  417.           If (XView > 38) OR (XView < 2) Then
  418.             Begin
  419.               XView_Change := -(XView_Change);
  420.               Right := FALSE;
  421.             End;
  422.         End
  423.       Else
  424.         Begin
  425.           YView := YView + YView_Change;
  426.           If (YView > 38) OR (YView < 2) Then
  427.             Begin
  428.               YView_Change := -(YView_Change);
  429.               Right := TRUE;
  430.             End;
  431.         End;
  432.  
  433.       Set_Window(currentpage,XView,YView);
  434.       Set_Display_Page(currentpage);
  435.       Set_Dac_Register(50 + PrevColor, 3 + PrevColor, 0, 60 - PrevColor);
  436.       Set_Dac_Register(50 + SetColor, SetColor, 10, 63 - SetColor);
  437.       Set_Dac_Register(150 + PrevColor, 3 + PrevColor, 0, 60 - PrevColor);
  438.       Set_Dac_Register(150 + SetColor, 63, 63, SetColor);
  439.       SetColor := SetColor + SDir;
  440.       IF (SetColor = 60) OR (SetColor = 0) THEN SDir := -SDir;
  441.       PrevColor := PrevColor + PDir;
  442.       IF (PrevColor = 60) OR (PrevColor = 0) THEN PDir := -PDir;
  443.       Remove_Sprites(lastpage,Number_Of_Shapes);
  444.  
  445.       If Keypressed Then
  446.         Begin
  447.           Ch := ReadKey;
  448.           Case Ch of
  449.             '-' : If Number_Of_Shapes > 1 Then
  450.                     Begin
  451.                       c := Number_Of_Shapes;
  452.                       Copy_Bitmap(2,obj[c].XPos,obj[c].YPos,obj[c].XPos+16,obj[c].YPos+16,
  453.                          currentpage,obj[c].XPos,obj[c].YPos);
  454.                       Dec(Number_Of_Shapes);
  455.                     End;
  456.             '+' : If Number_Of_Shapes < 64 Then Inc(Number_Of_Shapes);
  457.           End;
  458.         End;
  459.       lastpage := (lastpage+1) MOD 2;
  460.       currentpage := (currentpage+1) MOD 2;
  461.     End;
  462. END;
  463.  
  464.     { MAIN ROUTINE - Run Through Demos and Exit }
  465.  
  466. Begin
  467.  
  468.   Randomize;
  469.   Init_Sprites;
  470.  
  471.   Demo_Res(0, 320, 200);
  472.   Demo_Res(1, 320, 400);
  473.   Demo_Res(2, 360, 200);
  474.   Demo_Res(3, 360, 400);
  475.   Demo_Res(4, 320, 240);
  476.   Demo_Res(5, 320, 480);
  477.   Demo_Res(6, 360, 240);
  478.   Demo_Res(7, 360, 480);
  479.   Page_Demo;
  480.  
  481.   asm
  482.     mov ah,0
  483.     mov al,3
  484.     int 10h
  485.   end;
  486.   WriteLn('THIS MODE X DEMO IS FINISHED');
  487.  
  488. END.