VESATEST.C 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/2d/rcs/vesatest.c $
  15. * $Revision: 1.3 $
  16. * $Author: john $
  17. * $Date: 1993/12/21 11:40:47 $
  18. *
  19. * .
  20. *
  21. * $Log: vesatest.c $
  22. * Revision 1.3 1993/12/21 11:40:47 john
  23. * *** empty log message ***
  24. *
  25. * Revision 1.2 1993/12/09 17:14:14 john
  26. * VESA test program.
  27. *
  28. * Revision 1.1 1993/12/09 16:53:01 john
  29. * Initial revision
  30. *
  31. *
  32. */
  33. #pragma off (unreferenced)
  34. static char rcsid[] = "$Id: vesatest.c 1.3 1993/12/21 11:40:47 john Exp $";
  35. #pragma on (unreferenced)
  36. #include <stdlib.h>
  37. #include <stdio.h>
  38. #include <conio.h>
  39. #include <malloc.h>
  40. #include "gr.h"
  41. char palette[256*3];
  42. extern void gr_pal_setblock( int start, int number, unsigned char * pal );
  43. void CreatePalette( )
  44. {
  45. int i;
  46. for (i=0; i<64; i++ )
  47. {
  48. // Make 0-63 be red shades
  49. palette[ i*3+0 ] = i; // Red
  50. palette[ i*3+1 ] = 0; // Green
  51. palette[ i*3+2 ] = 0; // Blue
  52. // Make 64-127 be green shades
  53. palette[ i*3+0+64*3 ] = 0; // Red
  54. palette[ i*3+1+64*3 ] = i; // Green
  55. palette[ i*3+2+64*3 ] = 0; // Blue
  56. // Make 128-191 be blue shades
  57. palette[ i*3+0+128*3 ] = 0; // Red
  58. palette[ i*3+1+128*3 ] = 0; // Green
  59. palette[ i*3+2+128*3 ] = i; // Blue
  60. // Make 192-255 be greyscale
  61. palette[ i*3+0+192*3 ] = i; // Red
  62. palette[ i*3+1+192*3 ] = i; // Green
  63. palette[ i*3+2+192*3 ] = i; // Blue
  64. }
  65. }
  66. main()
  67. {
  68. int i;
  69. printf( "This program tests VESA mode 103 (800x600x256).\n" );
  70. printf( "You should see a dark blue screen with a red border,\n" );
  71. printf( "When you hit return once, there should be three\n" );
  72. printf( "horizontal color bands, each one going through\n" );
  73. printf( "shades of red,green,blue, and white, respectively,\n" );
  74. printf( "and all this surrounded by a white frame.\n" );
  75. printf( "Press any key...\n" );
  76. getch();
  77. CreatePalette();
  78. i = gr_init( SM_800x600V );
  79. if (i) {
  80. printf( "Couldn't initialize because " );
  81. switch(i)
  82. {
  83. case 1: printf( "no VGA adapter is installed.\n" ); break;
  84. case 2: printf( "Inferno doesn't support this cards granularity.\n" ); break;
  85. case 3: printf( "your monitor doesn't support 800x600.\n" ); break;
  86. case 4: printf( "your video card doesn't support that VESA mode.\n" ); break;
  87. case 5: printf( "no VESA driver was detected.\n" ); break;
  88. case 6: printf( "a VESA call returned a bad status code.\n" ); break;
  89. case 7: printf( "there isn't enough low memory.\n" ); break;
  90. case 8: printf( "a DPMI call failed.\n" ); break;
  91. case 9: printf( "your card couldn't set the correct logical line width.\n" ); break;
  92. default: printf( "of unknown error %d\n" ); break;
  93. exit(1);
  94. }
  95. }
  96. gr_setcolor( 1 );
  97. gr_urect( 0, 0, 799, 599 );
  98. gr_setcolor( 12 );
  99. gr_ubox(0,0,799, 599);
  100. getch();
  101. gr_pal_setblock( 0, 256, palette );
  102. gr_setcolor( 0 );
  103. gr_urect( 0, 0, grd_curcanv->cv_bitmap.bm_w-1, grd_curcanv->cv_bitmap.bm_h-1 );
  104. for (i=0; i< 256; i++ )
  105. {
  106. gr_setcolor( i );
  107. gr_urect( 0, i*2, 799, i*2+1 );
  108. }
  109. gr_setcolor( 255 ); gr_ubox(0,0,799, 599);
  110. gr_setcolor( 245 ); gr_ubox(1,1,798, 598);
  111. gr_setcolor( 235 ); gr_ubox(2,2,797, 597);
  112. gr_setcolor( 225 ); gr_ubox(3,3,796, 596);
  113. gr_setcolor( 215 ); gr_ubox(4,4,795, 595);
  114. gr_setcolor( 205 ); gr_ubox(5,5,794, 594);
  115. getch();
  116. }
  117.