home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / xlib / demo1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-15  |  19.3 KB  |  512 lines

  1. /* VERY QUICK AND ULTRA-DIRTY DEMO USING XLIB */
  2.  
  3. /* Simple Demo of MODE X Split screen and panning  */
  4. /* Compile using Turbo C and Tasm                  */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <conio.h>
  9. #include <ctype.h>
  10. #include <alloc.h>
  11. #include <dos.h>
  12. #include "Xlib_all.h"
  13.  
  14. #define MAX_OBJECTS  10
  15.  
  16. typedef struct {
  17.    int X,Y,Width,Height,XDir,YDir,XOtherPage,YOtherPage;
  18.    char far * Image;
  19.    char far * bg;
  20.    char far * bgOtherPage;
  21. } AnimatedObject;
  22.  
  23. AnimatedObject objects[MAX_OBJECTS];
  24. int object_count=0;
  25.  
  26. static char  bm[] = {4,12,
  27.   /* plane 0 */
  28.   2,2,2,2,2,1,1,1,2,1,1,1,2,3,3,1,
  29.   2,0,0,3,2,0,0,3,2,0,0,3,2,0,0,3,
  30.   2,3,3,1,2,1,1,1,2,1,1,1,2,2,2,2,
  31.   /* plane 1 */
  32.   2,2,2,2,1,1,1,1,1,1,1,1,1,3,3,1,
  33.   1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,
  34.   1,3,3,1,1,1,1,1,1,1,1,1,2,2,2,2,
  35.   /* plane 2 */
  36.   2,2,2,2,1,1,1,1,1,1,1,1,1,3,3,1,
  37.   1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,
  38.   1,3,3,1,1,1,1,1,1,1,1,1,2,2,2,2,
  39.   /* plane 3 */
  40.   2,2,2,2,1,1,1,2,1,1,1,2,1,3,3,2,
  41.   3,0,0,2,3,0,0,2,3,0,0,2,3,0,0,2,
  42.   1,3,3,2,1,1,1,2,1,1,1,2,2,2,2,2};
  43.  
  44. static char  bm2[] = {4,12,
  45.    /* plane 0 */
  46.    2,2,2,2,2,4,4,4,2,4,4,4,2,2,2,4,
  47.    2,0,0,2,2,0,0,2,2,0,0,2,2,0,0,2,
  48.    2,2,2,4,2,4,4,4,2,4,4,4,2,2,2,2,
  49.    /* plane 1 */
  50.    2,2,2,2,4,4,4,4,4,4,4,4,4,2,2,4,
  51.    4,0,0,4,4,0,0,4,4,0,0,4,4,0,0,4,
  52.    4,2,2,4,4,4,4,4,4,4,4,4,2,2,2,2,
  53.    /* plane 2 */
  54.    2,2,2,2,4,4,4,4,4,4,4,4,4,2,2,4,
  55.    4,0,0,4,4,0,0,4,4,0,0,4,4,0,0,4,
  56.    4,2,2,4,4,4,4,4,4,4,4,4,2,2,2,2,
  57.    /* plane 2 */
  58.    2,2,2,2,4,4,4,2,4,4,4,2,4,2,2,2,
  59.    2,0,0,2,2,0,0,2,2,0,0,2,2,0,0,2,
  60.    4,2,2,2,4,4,4,2,4,4,4,2,2,2,2,2};
  61.  
  62.  
  63. /* initialize a new object */
  64. void init_object(int x,int y,int width, int height, int xdir, int ydir,
  65.   char far * image){
  66.   int i;
  67.   objects[object_count].X = objects[object_count].XOtherPage = x;
  68.   objects[object_count].Y = objects[object_count].YOtherPage = y;
  69.   objects[object_count].Width = width;
  70.   objects[object_count].Height = height;
  71.   objects[object_count].XDir = xdir;
  72.   objects[object_count].YDir = ydir;
  73.   objects[object_count].Image = image;
  74.   objects[object_count].bg = (char far *) farmalloc(4*width*height+20);
  75.   objects[object_count].bgOtherPage = (char far *) farmalloc(4*width*height+20);
  76.   x_get_pbm(x,y,(unsigned)width,height,VisiblePageOffs,
  77.     objects[object_count].bg);
  78.   x_get_pbm(x,y,(unsigned)width,height,HiddenPageOffs,
  79.     objects[object_count].bgOtherPage);
  80.   object_count++;
  81. }
  82.  
  83. /* Move the specified object, bouncing at the edges of the screen and
  84.    remembering where the object was before the move for erasing next time */
  85. void MoveObject(AnimatedObject * ObjectToMove) {
  86.    int X, Y;
  87.    char far *cptr;
  88.    X = ObjectToMove->X + ObjectToMove->XDir;
  89.    Y = ObjectToMove->Y + ObjectToMove->YDir;
  90.    if ((X < 0) || (X > (ScrnLogicalPixelWidth-((ObjectToMove->Width)<<2)))) {
  91.       ObjectToMove->XDir = -ObjectToMove->XDir;
  92.       X = ObjectToMove->X + ObjectToMove->XDir;
  93.    }
  94.    if ((Y < 0) || (Y > (ScrnLogicalHeight-ObjectToMove->Height))) {
  95.       ObjectToMove->YDir = -ObjectToMove->YDir;
  96.       Y = ObjectToMove->Y + ObjectToMove->YDir;
  97.    }
  98.    /* Remember previous location for erasing purposes */
  99.    ObjectToMove->XOtherPage = ObjectToMove->X;
  100.    ObjectToMove->YOtherPage = ObjectToMove->Y;
  101.    ObjectToMove->X = X; /* set new location */
  102.    ObjectToMove->Y = Y;
  103.    cptr = ObjectToMove->bg;
  104.    ObjectToMove->bg = ObjectToMove->bgOtherPage;
  105.    ObjectToMove->bgOtherPage = cptr;
  106. }
  107.  
  108. void animate(void){
  109.  int i;
  110.  for(i=object_count-1;i>=0;i--){
  111.   x_put_pbm(objects[i].XOtherPage,objects[i].YOtherPage,
  112.      HiddenPageOffs,objects[i].bgOtherPage);
  113.  }
  114.  for(i=0;i<object_count;i++){
  115.   MoveObject(&objects[i]);
  116.  
  117.   x_get_pbm(objects[i].X,objects[i].Y,
  118.     (unsigned)objects[i].Width,objects[i].Height,HiddenPageOffs,
  119.     objects[i].bg);
  120.   x_put_masked_pbm(objects[i].X,objects[i].Y,HiddenPageOffs,
  121.     objects[i].Image);
  122.  }
  123. }
  124.  
  125. void clear_objects(void){
  126.  int i;
  127.  for(i=object_count-1;i>=0;i--){
  128.   x_put_pbm(objects[i].XOtherPage,objects[i].YOtherPage,
  129.      HiddenPageOffs,objects[i].bgOtherPage);
  130.  }
  131. }
  132.  
  133.  
  134. int textwindow_x=0,textwindow_y=0;
  135. char far * pal,far * pal2;
  136. char palscrolldir=1;
  137. char far * newfnt;
  138.  
  139.  
  140. void textwindow(int Margin){
  141.    int x0=0+Margin;
  142.    int y0=0+Margin;
  143.    int x1=ScrnPhysicalPixelWidth-Margin;
  144.    int y1=ScrnPhysicalHeight-Margin;
  145.    x_rect_fill(x0, y0, x1,y1,VisiblePageOffs,1);
  146.    x_line(x0,y0,x1,y0,2,VisiblePageOffs);
  147.    x_line(x0,y1,x1,y1,2,VisiblePageOffs);
  148.    x_line(x0,y0,x0,y1,2,VisiblePageOffs);
  149.    x_line(x1,y0,x1,y1,2,VisiblePageOffs);
  150.    x_line(x0+2,y0+2,x1-2,y0+2,2,VisiblePageOffs);
  151.    x_line(x0+2,y1-2,x1-2,y1-2,2,VisiblePageOffs);
  152.    x_line(x0+2,y0+2,x0+2,y1-2,2,VisiblePageOffs);
  153.    x_line(x1-2,y0+2,x1-2,y1-2,2,VisiblePageOffs);
  154.    textwindow_x=x0;
  155.    textwindow_y=y0;
  156.  
  157. }
  158.  
  159.  
  160. void wait_for_keypress(void){
  161.   x_show_mouse();
  162.   while(kbhit()) getch();
  163.   palscrolldir^=1;
  164.  
  165.   do {
  166.     x_rot_pal_struc(pal,palscrolldir);
  167.     MouseFrozen=1;
  168.     x_put_pal_struc(pal);
  169.     x_update_mouse();
  170.   } while (!kbhit() && !(MouseButtonStatus==LEFT_PRESSED));
  171.   while(MouseButtonStatus==LEFT_PRESSED);
  172.   while(kbhit()) getch();
  173.  
  174. }
  175.  
  176.  
  177. void exitfunc(void){
  178.   x_mouse_remove();
  179.   x_text_mode();
  180.   printf("Thanks to everyone who assisted in the development of XLIB.\n");
  181.   printf("\nSpecial thanks to Matthew Mackenzie for contributing \n");
  182.   printf("lots of code, documentation and ideas.\n\n");
  183.   printf("If you make any money using this code and you're the generous\n");
  184.   printf("type please send us some, or at least a copy of your program!\n");
  185. }
  186.  
  187. int terminate(void){
  188.   exit(0);
  189. }
  190.  
  191. void intro_1(void){
  192.   x_set_rgb(1,40,40,40); /* BG Gray */
  193.   x_set_rgb(2,63,63,0);  /* Bright Yellow  */
  194.   x_set_rgb(3,63,0,0);   /* Bright Red     */
  195.   x_set_rgb(4,0,63,0);   /* Bright Green   */
  196.   x_set_rgb(5,0,0,63);   /* Bright Blue    */
  197.   x_set_rgb(6,0,0,28);   /* Dark Blue      */
  198.   x_set_rgb(7,0,28,0);   /* Dark Green     */
  199.   x_set_rgb(8,28,0,0);   /* Dark red       */
  200.   x_set_rgb(9,0,0,38);   /* Med Blue       */
  201.  
  202.   textwindow(20);
  203.   x_set_font(1);
  204.   x_printf(textwindow_x+54,textwindow_y+4,VisiblePageOffs,6,"     XLIB Version 4.0");
  205.   x_printf(textwindow_x+53,textwindow_y+3,VisiblePageOffs,2,"     XLIB Version 4.0");
  206.   x_set_font(0);
  207.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"       Not the Unix version");
  208.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,2,"       Not the Unix version");
  209.  
  210.   x_printf(textwindow_x+24,168,VisiblePageOffs,6,"     Press any key to continue");
  211.   x_printf(textwindow_x+23,167,VisiblePageOffs,2,"     Press any key to continue");
  212. }
  213.  
  214. void subsequent_page(void){
  215.   x_hide_mouse();
  216.   textwindow(20);
  217.   x_set_font(1);
  218.   x_printf(textwindow_x+54,textwindow_y+4,VisiblePageOffs,6,"     XLIB Version 4.0");
  219.   x_printf(textwindow_x+53,textwindow_y+3,VisiblePageOffs,2,"     XLIB Version 4.0");
  220.   x_set_font(0);
  221.   x_printf(textwindow_x+24,168,VisiblePageOffs,6,"     Press any key to continue");
  222.   x_printf(textwindow_x+23,167,VisiblePageOffs,2,"     Press any key to continue");
  223. }
  224.  
  225. void load_user_fonts(void){
  226.   FILE *f;
  227.   f=fopen("6x8b.fnt","rb");
  228.   /* read char by char as fread wont read to far pointers in small model */
  229.   { int i; char c;
  230.     for (i=0;i<256*8+4;i++){
  231.       fread(&c,1,1,f);
  232.       *(newfnt+i)=c;
  233.     }
  234.   }
  235.  
  236.   fclose(f);
  237.   x_register_userfont(newfnt);
  238.  
  239. }
  240.  
  241.  
  242.  
  243. void main(){
  244.   int  i, j, xinc, yinc, Margin;
  245.   char ch;
  246.   WORD curr_x=0, curr_y=0;
  247.  
  248.   pal    = (char far *) farmalloc(256*3);
  249.   pal2   = (char far *) farmalloc(256*3);
  250.   newfnt = (char far *) farmalloc(256*16+4);
  251.  
  252.  
  253.  
  254.   /* INITIALIZE XLIB */
  255.  
  256.   /* we set up Mode X 360x200x256 with a logical width of ~ 500 */
  257.   /* pixels; we actually get 496 due to the fact that the width */
  258.   /* must be divisible by 8                                     */
  259.  
  260.   x_text_mode(); /* make sure VGA is in color mode, if possible */
  261.   x_set_mode(X_MODE_360x200,500);           /* actually is set to 496      */
  262.   x_set_splitscreen(ScrnPhysicalHeight-60); /* split screen 60 pixels high */
  263.   x_set_doublebuffer(220);
  264.   x_text_init();
  265.   x_hide_splitscreen();
  266.   x_mouse_init();
  267.   MouseColor=2;
  268.   atexit(exitfunc);
  269.  
  270.   /* DRAW BACKGROUND LINES */
  271.  
  272.   for(j=0;j<ScrnPhysicalHeight;j++){
  273.    x_line(0,j,ScrnLogicalPixelWidth,j,16+(j%239),VisiblePageOffs);
  274.   }
  275.  
  276.   ctrlbrk(terminate);
  277.   x_get_pal_struc(pal, 240,16);
  278.   load_user_fonts();
  279.  
  280.   intro_1();
  281.   x_set_font(2);
  282.   x_hide_mouse();
  283.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, "   Hi, folks. This is yet another FREEWARE Mode X");
  284.   x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " graphics library. It is by no means complete,");
  285.   x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " but I believe it contains a rich enough set of");
  286.   x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " functions to achieve its design goal - to be");
  287.   x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " a game development oriented library for");
  288.   x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " Borland TC/BC/BC++ and TASM programmers.");
  289.  
  290.   x_printf(textwindow_x+5,50+48,VisiblePageOffs,9, "   This library comes with TASM and C sources.");
  291.   x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, " It was inspired by the DDJ Graphics column and");
  292.   x_printf(textwindow_x+5,50+64,VisiblePageOffs,9, " many INTERNET and USENET authors who, unlike the");
  293.   x_printf(textwindow_x+5,50+72,VisiblePageOffs,9, " majority of programmers (you know who you are!),");
  294.   x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, " willingly share their code and ideas with others.");
  295.  
  296.   x_printf(textwindow_x+5,50+88,VisiblePageOffs,9, "   I can't afford, nor do I want, to copyright");
  297.   x_printf(textwindow_x+5,50+96,VisiblePageOffs,9, " this code - but if you use it, some credit would ");
  298.   x_printf(textwindow_x+5,50+104,VisiblePageOffs,9," be appreciated. ");
  299.  
  300.   wait_for_keypress();
  301.  
  302.   subsequent_page();
  303.   x_set_font(0);
  304.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"Supported 256 colour resolutions.");
  305.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"Supported 256 colour resolutions.");
  306.   x_set_font(2);
  307.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, " 320x200   Standard for games       ~ 4 pages");
  308.   x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " 320x240   DDJ Mode X square pixels ~ 3.5 pages");
  309.   x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " 360x200   My favourite for games   ~ 3 pages  ");
  310.   x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " 360x240                            ~ 2.8 pages");
  311.   x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " 320x400                            ~ 2 pages  ");
  312.   x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " 320x480   All subsequent modes support");
  313.   x_printf(textwindow_x+5,50+48,VisiblePageOffs,9, " 360x400     less than two pages.");
  314.   x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, " 360x480");  
  315.   x_printf(textwindow_x+5,50+64,VisiblePageOffs,9, "   We are currently in 360x200 mode.");
  316.   x_printf(textwindow_x+5,50+72,VisiblePageOffs,9, "   Remember that standard VGA only supports 64K");
  317.   x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, " of video RAM, and these modes are specifically");
  318.   x_printf(textwindow_x+5,50+88,VisiblePageOffs,9, " designed for standard VGA cards and monitors.");
  319.   x_printf(textwindow_x+5,50+98,VisiblePageOffs,2,"  Update: Version 4.0 includes 4 new resolutions -");
  320.   x_printf(textwindow_x+5,50+106,VisiblePageOffs,2,"       376x282, 360x360, 376x308, and 376x564.");
  321.  
  322.  
  323.   wait_for_keypress();
  324.  
  325.   subsequent_page();
  326.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"      Text display functions.");
  327.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"      Text display functions.");
  328.   x_set_font(2);
  329.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, "   Several text printing functions are provided.");
  330.   x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " They support the VGA ROM 8x14 and 8x8 fonts as");
  331.   x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " well as user-defined fonts (like this 6x8 font).");
  332.   x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " Furthermore, a function similar to printf is");
  333.   x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " included which provides formatted text output.");
  334.   x_set_font(1);
  335.   x_printf(textwindow_x+5,50+42,VisiblePageOffs,2, "    ROM 8x14");
  336.   x_set_font(0);
  337.   x_printf(textwindow_x+5,50+46,VisiblePageOffs,2, "              ROM 8x8");
  338.   x_set_font(2);
  339.   x_printf(textwindow_x+5,50+46,VisiblePageOffs,2, "                              User-defined 6x8");
  340.  
  341.   wait_for_keypress();
  342.  
  343.  
  344.   subsequent_page();
  345.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"    Advanced screen functions.");
  346.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"    Advanced screen functions.");
  347.   x_set_font(2);
  348.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, "   The library supports virtual screens larger");
  349.   x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " than the physical screen, panning of such");
  350.   x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " screens, and a split screen option.");
  351.   x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, "   These functions can be used together or");
  352.   x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " in isolation, and in the lower resolutions");
  353.   x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " double buffering can also be accomplished.");
  354.  
  355.   x_rect_fill(0, 0, ScrnPhysicalPixelWidth,60,SplitScrnOffs,5);
  356.   x_line(0,0,ScrnPhysicalPixelWidth,0,2,SplitScrnOffs);
  357.   x_set_font(1);
  358.   x_printf(10,10,SplitScrnOffs,2, " This is a split screen, tops for scores.");
  359.   x_set_font(0);
  360.   for (i=ScrnPhysicalHeight;i>ScrnPhysicalHeight-60;i--){
  361.     x_adjust_splitscreen(i);
  362.   }
  363.   x_printf(10,25,SplitScrnOffs,2, " Even better for scrolling games etc.");
  364.  
  365.   x_cp_vid_rect(0,0,ScrnLogicalPixelWidth,ScrnLogicalHeight,0,0,
  366.         VisiblePageOffs,HiddenPageOffs,
  367.         ScrnLogicalPixelWidth,ScrnLogicalPixelWidth);
  368.  
  369.  
  370.   x_show_mouse();
  371.   wait_for_keypress();
  372.  
  373.   curr_x=curr_y=0;
  374.   
  375.  
  376.   init_object(60,90,4, 12, -1, 1, MK_FP(FP_SEG(bm2),FP_OFF(bm2)));
  377.   init_object(30,30,4, 12, 1, 1, MK_FP(FP_SEG(bm),FP_OFF(bm)));
  378.   init_object(80,120,4, 12, 2, 1, MK_FP(FP_SEG(bm),FP_OFF(bm)));
  379.   init_object(300,200,4, 12, 1, -2, MK_FP(FP_SEG(bm),FP_OFF(bm)));
  380.   init_object(360,30,4, 12, -1, -1, MK_FP(FP_SEG(bm),FP_OFF(bm)));
  381.   init_object(360,10,4, 12, -2, 2, MK_FP(FP_SEG(bm),FP_OFF(bm)));
  382.  
  383.   x_hide_mouse();
  384.  
  385.   while (!kbhit()&& !(MouseButtonStatus==LEFT_PRESSED)){
  386.     animate();
  387.     if (objects[0].X>=curr_x+ScrnPhysicalPixelWidth-32 &&
  388.     curr_x < MaxScrollX) curr_x++;
  389.     else if (objects[0].X < curr_x+16 && curr_x > 0) curr_x--;
  390.     if (objects[0].Y>=curr_y+ScrnPhysicalHeight-92 &&
  391.        curr_y < MaxScrollY) curr_y++;
  392.     else if (objects[0].Y < curr_y+16 && curr_y > 0) curr_y--;
  393.     x_page_flip(curr_x,curr_y);
  394.   }
  395.   while(MouseButtonStatus==LEFT_PRESSED);
  396.   while(kbhit()) getch();
  397.  
  398.   clear_objects();
  399.   x_page_flip(curr_x,curr_y);
  400.  
  401.  
  402.   x_set_start_addr(0,0);
  403.  
  404.  
  405.   for (j=0;j<4;j++){
  406.     x_hide_splitscreen();
  407.     delay(100);
  408.     x_show_splitscreen();
  409.     delay(100);
  410.   }
  411.  
  412.  
  413.   for (i=ScrnPhysicalHeight-60;i<=ScrnPhysicalHeight;i++){
  414.     x_adjust_splitscreen(i);
  415.   }
  416.  
  417.   x_hide_mouse();
  418.   subsequent_page();
  419.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"        Palette functions.");
  420.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"        Palette functions.");
  421.   x_set_font(2);
  422.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, "   A number of palette manipulation functions");
  423.   x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " are provided. You have already seen some of");
  424.   x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " them in action. Another common operation is");
  425.   x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " palette fading.                     ");
  426.  
  427.   i=0;
  428.   ch=255;
  429.   while (x_cpcontrast_pal_struc(pal, pal2,ch-=2)){
  430.     x_put_pal_struc(pal2);
  431.     x_rot_pal_struc(pal,palscrolldir);
  432.     i++;
  433.   };
  434.   for (j=0;j<i;j++){
  435.     x_cpcontrast_pal_struc(pal, pal2,ch+=2);
  436.     x_put_pal_struc(pal2);
  437.     x_rot_pal_struc(pal,palscrolldir);
  438.   };
  439.   wait_for_keypress();
  440.  
  441.   subsequent_page();
  442.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"    NEW Version 3.0 Functions!");
  443.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"    NEW Version 3.0 Functions!");
  444.   x_set_font(2);
  445.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, " NEW functions not demonstrated here include:");
  446.   x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, "  - RLE data compression");
  447.   x_printf(textwindow_x+5,50+20,VisiblePageOffs,9, "  - FAST compiled masked bitmaps");
  448.   x_printf(textwindow_x+5,50+30,VisiblePageOffs,9, "  - Hardware detection");
  449.   x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, "  - Bug fixes");
  450.  
  451.   x_show_mouse();
  452.   wait_for_keypress();
  453.  
  454.   x_hide_mouse();
  455.   for (i = 0; i < 150; i++) {
  456.       x_circle(0, 0, i, 181 - i, VisiblePageOffs);
  457.       x_circle(360 - i, 0, i, i + 30, VisiblePageOffs);
  458.       x_circle(0, 200 - i, i, i + 30, VisiblePageOffs);
  459.       x_circle(360 - i, 200 - i, i, 181 - i, VisiblePageOffs);
  460.   }
  461.   for (i = 0; i < 100; i++)
  462.     x_filled_circle(80 + i, i, 201 - (i << 1), 30+i, VisiblePageOffs);
  463.   x_show_mouse();
  464.   wait_for_keypress();
  465.  
  466.   subsequent_page();
  467.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"    NEW Version 4.0 Functions!");
  468.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"    NEW Version 4.0 Functions!");
  469.   x_set_font(2);
  470.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, " NEW functions not demonstrated here include:");
  471.   x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, "  - FAST VRAM-based masked bitmaps, including");
  472.   x_printf(textwindow_x+5,50+18,VisiblePageOffs,9, "      support for clipping regions");
  473.   x_printf(textwindow_x+5,50+28,VisiblePageOffs,9, "  - Faster, smaller compiled bitmaps");
  474.   x_printf(textwindow_x+5,50+38,VisiblePageOffs,9, "  - Improved planar bitmap performance and");
  475.   x_printf(textwindow_x+5,50+46,VisiblePageOffs,9, "      additional support for clipping");
  476.   x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, "  - mouse module");
  477.   x_printf(textwindow_x+5,50+66,VisiblePageOffs,9, "  - Detection of math co-processor and mouse");
  478.   x_printf(textwindow_x+5,50+76,VisiblePageOffs,9, "  - Bezier curve module");
  479.   x_printf(textwindow_x+5,50+86,VisiblePageOffs,9, "  - Four new resolutions, including one with");
  480.   x_printf(textwindow_x+5,50+94,VisiblePageOffs,9, "      square pixels (376x282)");
  481.   x_printf(textwindow_x+5,50+104,VisiblePageOffs,9, "  - More bug fixes");
  482.  
  483.   wait_for_keypress();
  484.  
  485.   subsequent_page();
  486.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"             PLEASE...");
  487.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"             PLEASE...");
  488.   x_set_font(2);
  489.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, "   Please mention my name in programs that use XLIB");
  490.   x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " just to make me feel it was worth the effort.");
  491.   x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " If you have any bug to report please feel free to");
  492.   x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " mail me a message. Any hints, suggestions and");
  493.   x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " contributions are welcome and encouraged.");
  494.   x_printf(textwindow_x+5,50+52,VisiblePageOffs,9, " I have contributed this code to the public domain.");
  495.   x_printf(textwindow_x+5,50+60,VisiblePageOffs,9, "    Please respect my wishes and leave it there.");
  496.  
  497.   x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, "   Finally, I hope you all find this stuff useful,");
  498.   x_printf(textwindow_x+5,50+96,VisiblePageOffs,9, " Themie Gouthas - EGG@DSTOS3.DSTO.GOV.AU");
  499.  
  500.   wait_for_keypress();
  501.  
  502.   x_hide_mouse();
  503.  
  504.   x_shift_rect (27, 27, 360-27, 177, 27, 23, VisiblePageOffs);
  505.   x_rect_fill(25, 173, 335, 176, VisiblePageOffs, 1);
  506.   for (i = 0; i < 50; i++) {
  507.     x_shift_rect (27, 26, 360-27, 177 - (i * 3), 27, 23, VisiblePageOffs);
  508.   }
  509. }
  510.  
  511.  
  512.