VESATEST.C 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. #pragma off (unreferenced)
  14. static char rcsid[] = "$Id: vesatest.c 1.3 1993/12/21 11:40:47 john Exp $";
  15. #pragma on (unreferenced)
  16. #include <stdlib.h>
  17. #include <stdio.h>
  18. #include <conio.h>
  19. #include <malloc.h>
  20. #include "gr.h"
  21. char palette[256*3];
  22. extern void gr_pal_setblock( int start, int number, unsigned char * pal );
  23. void CreatePalette( )
  24. {
  25. int i;
  26. for (i=0; i<64; i++ )
  27. {
  28. // Make 0-63 be red shades
  29. palette[ i*3+0 ] = i; // Red
  30. palette[ i*3+1 ] = 0; // Green
  31. palette[ i*3+2 ] = 0; // Blue
  32. // Make 64-127 be green shades
  33. palette[ i*3+0+64*3 ] = 0; // Red
  34. palette[ i*3+1+64*3 ] = i; // Green
  35. palette[ i*3+2+64*3 ] = 0; // Blue
  36. // Make 128-191 be blue shades
  37. palette[ i*3+0+128*3 ] = 0; // Red
  38. palette[ i*3+1+128*3 ] = 0; // Green
  39. palette[ i*3+2+128*3 ] = i; // Blue
  40. // Make 192-255 be greyscale
  41. palette[ i*3+0+192*3 ] = i; // Red
  42. palette[ i*3+1+192*3 ] = i; // Green
  43. palette[ i*3+2+192*3 ] = i; // Blue
  44. }
  45. }
  46. main()
  47. {
  48. int i;
  49. printf( "This program tests VESA mode 103 (800x600x256).\n" );
  50. printf( "You should see a dark blue screen with a red border,\n" );
  51. printf( "When you hit return once, there should be three\n" );
  52. printf( "horizontal color bands, each one going through\n" );
  53. printf( "shades of red,green,blue, and white, respectively,\n" );
  54. printf( "and all this surrounded by a white frame.\n" );
  55. printf( "Press any key...\n" );
  56. getch();
  57. CreatePalette();
  58. i = gr_init( SM_800x600V );
  59. if (i) {
  60. printf( "Couldn't initialize because " );
  61. switch(i)
  62. {
  63. case 1: printf( "no VGA adapter is installed.\n" ); break;
  64. case 2: printf( "Inferno doesn't support this cards granularity.\n" ); break;
  65. case 3: printf( "your monitor doesn't support 800x600.\n" ); break;
  66. case 4: printf( "your video card doesn't support that VESA mode.\n" ); break;
  67. case 5: printf( "no VESA driver was detected.\n" ); break;
  68. case 6: printf( "a VESA call returned a bad status code.\n" ); break;
  69. case 7: printf( "there isn't enough low memory.\n" ); break;
  70. case 8: printf( "a DPMI call failed.\n" ); break;
  71. case 9: printf( "your card couldn't set the correct logical line width.\n" ); break;
  72. default: printf( "of unknown error %d\n" ); break;
  73. exit(1);
  74. }
  75. }
  76. gr_setcolor( 1 );
  77. gr_urect( 0, 0, 799, 599 );
  78. gr_setcolor( 12 );
  79. gr_ubox(0,0,799, 599);
  80. getch();
  81. gr_pal_setblock( 0, 256, palette );
  82. gr_setcolor( 0 );
  83. gr_urect( 0, 0, grd_curcanv->cv_bitmap.bm_w-1, grd_curcanv->cv_bitmap.bm_h-1 );
  84. for (i=0; i< 256; i++ )
  85. {
  86. gr_setcolor( i );
  87. gr_urect( 0, i*2, 799, i*2+1 );
  88. }
  89. gr_setcolor( 255 ); gr_ubox(0,0,799, 599);
  90. gr_setcolor( 245 ); gr_ubox(1,1,798, 598);
  91. gr_setcolor( 235 ); gr_ubox(2,2,797, 597);
  92. gr_setcolor( 225 ); gr_ubox(3,3,796, 596);
  93. gr_setcolor( 215 ); gr_ubox(4,4,795, 595);
  94. gr_setcolor( 205 ); gr_ubox(5,5,794, 594);
  95. getch();
  96. }