TEST.CPP 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : GraphicBufferClass Test Program *
  23. * *
  24. * File Name : DRAWTEST.CPP *
  25. * *
  26. * Programmer : Steve Tall *
  27. * *
  28. * Start Date : September 25, 1995 *
  29. * *
  30. * Last Update : September 27, 1995 [ST] *
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * WinMain -- Program entry point *
  35. * Set_Mode -- Set up direct draw system *
  36. * WndProc -- Callback procedure for main window *
  37. * Font_Test -- Test GVPC::Print *
  38. * Rect_Test -- Test GVPC::Draw_Rect and GVPC::Draw_Line *
  39. * Clear_Test -- Test GVPC::Clear *
  40. * Pixel_Test -- Test GVPC::Put_Pixel *
  41. * Read_Pixel_Test -- Test GVPC::Read_Pixel *
  42. * Scale_Test -- Test GVPC::Scale *
  43. * Blit_Test1 -- Test GVPC::Blit from video mem to video mem *
  44. * Blit_Test1 -- Test GVPC::Blit from system mem to video mem *
  45. * Fill_Rect_Test -- Test GVPC::Fill_Rect *
  46. * Remap_Test -- Test GVPC::Remap *
  47. * Quad_Test -- Test GVPC::Fill_Quad *
  48. * Copy_Test -- Test GVPC::To_Buffer and BufferClass::To_Page *
  49. * Test_All -- Calls the other tests *
  50. * *
  51. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  52. #define WIN32
  53. #define WIN32
  54. #include <windows.h>
  55. #include <windowsx.h>
  56. #include "..\gbuffer.h"
  57. #include <ddraw.h>
  58. #include <font.h>
  59. #include <tile.h>
  60. #include <file.h>
  61. #include <iconcach.h>
  62. #include <wwmem.h>
  63. #define NAME "DRAWBUFF test"
  64. #define TITLE "DRAWBUFF library test"
  65. void Test_All (void);
  66. //
  67. // Misc globals for testing
  68. //
  69. int Test=0; // Number of test currently in progress
  70. BOOL AllDone; // Flag that we should exit
  71. int x1,y1,x2,y2; // Coordinates for rectangle drawing
  72. int BlitXAdd; //
  73. int BlitXDir; // Vars for blit testing
  74. int BlitYAdd; //
  75. int BlitYDir; //
  76. int BlitStretchX; //
  77. int BlitStretchY; // Vars for scale testing
  78. int BlitStretchXAdd; //
  79. int BlitStretchYAdd; //
  80. char RemapTable[256]; // Table for colour remap testing
  81. int FontPrintX; // Vars for test font printing
  82. int FontPrintY; //
  83. int StampX; //
  84. int StampY; // Vars for moving the stamp test icon around
  85. int StampXDir; // the screen
  86. int StampYDir; //
  87. #define MAX_TESTS 14 // Number of tests we have defined
  88. #define MODE_WIDTH 640 // Width in pixels of required video mode
  89. #define MODE_HEIGHT 400 // Height in pixels of required video mode
  90. int ScreenWidth=MODE_WIDTH;
  91. BOOL GameInFocus = TRUE;
  92. extern "C"{
  93. char CurrentPalette [768];
  94. }
  95. int WindowList[][8] = {
  96. {20>>3,20,(MODE_WIDTH-20)>>3,MODE_HEIGHT-20,0,0,0,0} /* screen window */
  97. };
  98. char SpanBuff[500000]; //Dont know how big this should be so its *BIG*
  99. GraphicBufferClass *ScreenBuffer=NULL; // Global pointer to screen GraphicBufferClass
  100. GraphicBufferClass *BackBuffer=NULL; // Global pointer to a back buffer
  101. void *IconPointer; // Global pointer to our test icons
  102. PALETTEENTRY pe[256]; // DD Palette entries
  103. unsigned char Palette[256*3]; // Place to load palette to
  104. extern LPDIRECTDRAWPALETTE PalettePtr; // Pointer to direct draw palette object
  105. //
  106. // Prototypes
  107. //
  108. long FAR PASCAL _export WndProc (HWND, UINT, UINT, LONG) ;
  109. BOOL Set_Video_Mode(HWND hwnd, int w, int h, int bits_per_pixel);
  110. void Reset_Video_Mode(void);
  111. extern "C" void Wait_Vert_Blank(void);
  112. void Block_Mouse(GraphicBufferClass *ptr){}
  113. void Unblock_Mouse(GraphicBufferClass *ptr){}
  114. //
  115. // Externs
  116. //
  117. extern LPDIRECTDRAW DirectDrawObject;
  118. extern HWND MainWindow;
  119. typedef struct tColourList {
  120. char Red;
  121. char Green;
  122. char Blue;
  123. } ColourList;
  124. ColourList ColourLookup[9]={
  125. 0,0,0,
  126. 63,0,0,
  127. 0,63,0,
  128. 0,0,63,
  129. 63,0,63,
  130. 63,63,0,
  131. 0,63,63,
  132. 32,32,32,
  133. 63,63,63
  134. };
  135. extern "C" void Set_Palette_Register(int number,int red ,int green ,int blue);
  136. void Colour_Debug (int call_number)
  137. {
  138. Set_Palette_Register (0,ColourLookup[call_number].Red ,
  139. ColourLookup[call_number].Green,
  140. ColourLookup[call_number].Blue);
  141. }
  142. /***********************************************************************************************
  143. * WinMain -- Program entry point *
  144. * *
  145. * *
  146. * *
  147. * INPUT: Standard Windows startup parameters *
  148. * *
  149. * OUTPUT: msg.wParam *
  150. * *
  151. * WARNINGS: None *
  152. * *
  153. * HISTORY: *
  154. * 9/27/95 1:28PM ST : Created *
  155. *=============================================================================================*/
  156. int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
  157. LPSTR lpszCmdParam, int nCmdShow)
  158. {
  159. static char szAppName[] = "HelloWin" ;
  160. HWND hwnd ;
  161. MSG msg ;
  162. WNDCLASS wndclass ;
  163. int i,j,k;
  164. char a[10];
  165. char b[10];
  166. //
  167. // Register the window class
  168. //
  169. Mem_Copy(a,b,10);
  170. if (!hPrevInstance)
  171. {
  172. wndclass.style = CS_HREDRAW | CS_VREDRAW ;
  173. wndclass.lpfnWndProc = WndProc ;
  174. wndclass.cbClsExtra = 0 ;
  175. wndclass.cbWndExtra = 0 ;
  176. wndclass.hInstance = hInstance ;
  177. wndclass.hIcon = LoadIcon (hInstance, IDI_APPLICATION) ;
  178. wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
  179. wndclass.hbrBackground = NULL;
  180. wndclass.lpszMenuName = NULL;
  181. wndclass.lpszClassName = NAME;
  182. RegisterClass (&wndclass) ;
  183. }
  184. //
  185. // Create our main window
  186. //
  187. hwnd = CreateWindowEx (
  188. WS_EX_TOPMOST,
  189. NAME,
  190. TITLE,
  191. WS_POPUP | WS_MAXIMIZE,
  192. 0,
  193. 0,
  194. MODE_WIDTH,
  195. MODE_HEIGHT,
  196. NULL,
  197. NULL,
  198. hInstance,
  199. NULL );
  200. ShowWindow (hwnd, nCmdShow) ;
  201. UpdateWindow (hwnd) ;
  202. SetFocus (hwnd);
  203. MainWindow=hwnd; //Save the handle to our main window
  204. // (Dangerous if Windoze can change the handle)
  205. //
  206. // Allocate space for the icons and load them
  207. //
  208. IconPointer=malloc (20000);
  209. Load_File ( "bridge3.des" , IconPointer );
  210. Invalidate_Cached_Icons();
  211. Register_Icon_Set (IconPointer,TRUE);
  212. //
  213. // Load the desert palette
  214. //
  215. Load_File ( "desert.pal" , Palette );
  216. k=0;
  217. for( j=0 ; j<768 ; j+=3 )
  218. {
  219. pe[k].peRed = Palette[j];
  220. pe[k].peGreen = Palette[j+1];
  221. pe[k].peBlue = Palette[j+2];
  222. k++;
  223. }
  224. //
  225. // Initialise global stuff required for the tests
  226. //
  227. // Force load of font
  228. FontPtr=NULL;
  229. // Set the video mode
  230. Set_Video_Mode( MainWindow , MODE_WIDTH , MODE_HEIGHT , 8 );
  231. //
  232. // Init the stuff for drawing rectangles
  233. //
  234. x1=0;
  235. y1=0;
  236. x2=319;
  237. y2=199;
  238. //
  239. // Init the stamp test variables
  240. //
  241. StampX=100;
  242. StampY=100;
  243. StampXDir=1;
  244. StampYDir=1;
  245. //
  246. // Create the GraphicBufferClass that will be the screen buffer
  247. //
  248. ScreenBuffer = new GraphicBufferClass ( MODE_WIDTH , MODE_HEIGHT , (GBC_Enum)(GBC_VIDEOMEM | GBC_VISIBLE));
  249. //
  250. // Set the palette
  251. //
  252. DirectDrawObject->CreatePalette( DDPCAPS_8BIT | DDPCAPS_ALLOW256, &pe[0] , &PalettePtr ,NULL);
  253. ScreenBuffer->Get_Graphic_Buffer()->Get_DD_Surface()->SetPalette( PalettePtr );
  254. PalettePtr->SetEntries( DDPSETPAL_VSYNC , 0 , 256 , &pe[0] );
  255. //
  256. // Set up the remap table for the Buffer_Remap test
  257. //
  258. for ( i=0 ; i<256 ; i++ ){
  259. RemapTable[i]=(char)255-i;
  260. }
  261. //
  262. // Get rid of the windows cursor
  263. //
  264. ShowCursor (FALSE);
  265. AllDone = FALSE;
  266. //
  267. // Windows message loop
  268. //
  269. while ( ! AllDone ){
  270. Test_All(); // Perform a test
  271. if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ){
  272. if( !GetMessage( &msg, NULL, 0, 0 ) ){
  273. return msg.wParam;
  274. }
  275. TranslateMessage(&msg);
  276. DispatchMessage(&msg);
  277. }
  278. }
  279. return msg.wParam;
  280. }
  281. #ifdef cuts //this is now in a seperate file
  282. /***********************************************************************************************
  283. * Set_Mode -- temporary replacement for library set mode function *
  284. * *
  285. * *
  286. * *
  287. * INPUT: int - mode width *
  288. * int - mode height *
  289. * int - bits per pixel *
  290. * *
  291. * OUTPUT: Nothing *
  292. * *
  293. * WARNINGS: None *
  294. * *
  295. * HISTORY: *
  296. * 9/27/95 1:51PM ST : Created *
  297. *=============================================================================================*/
  298. void Set_Mode ( int width , int height , int bpp )
  299. {
  300. //
  301. // Setup the direct draw system by
  302. // 1. Creating the DirectDraw object
  303. // 2. Setting the cooperative level to exclusive so we own the screen
  304. // 3. Setting the video mode
  305. //
  306. if ( DirectDrawObject == NULL ){
  307. // Create the direct draw object
  308. DirectDrawCreate ( NULL , &DirectDrawObject , NULL);
  309. // Set the cooperative level
  310. DirectDrawObject->SetCooperativeLevel ( MainWindow , DDSCL_EXCLUSIVE
  311. | DDSCL_FULLSCREEN
  312. | DDSCL_ALLOWMODEX );
  313. // Set the required display mode with 8 bits per pixel
  314. DirectDrawObject->SetDisplayMode ( width , height , bpp );
  315. }
  316. }
  317. #endif //cuts
  318. /***********************************************************************************************
  319. * WndProc -- windows message callback *
  320. * *
  321. * Pilfered from a windows example program - HELLOWIN.C *
  322. * *
  323. * *
  324. * INPUT: Standard Windoze callback parameters *
  325. * *
  326. * OUTPUT: long *
  327. * *
  328. * WARNINGS: None *
  329. * *
  330. * HISTORY: *
  331. * 9/27/95 1:39PM ST : Pilfered *
  332. *=============================================================================================*/
  333. long FAR PASCAL _export WndProc (HWND hwnd, UINT message, UINT wParam,
  334. LONG lParam)
  335. {
  336. switch (message){
  337. case WM_KEYDOWN:
  338. switch ( wParam ){
  339. case VK_SPACE:
  340. Test++;
  341. if ( Test>=MAX_TESTS ) {
  342. Test=0;
  343. }
  344. if ( BackBuffer ){
  345. delete BackBuffer;
  346. BackBuffer=NULL;
  347. }
  348. break;
  349. }
  350. break;
  351. case WM_ACTIVATEAPP:
  352. if ((BOOL)wParam) {
  353. if (ScreenBuffer) {
  354. ScreenBuffer->Get_DD_Surface()->Restore();
  355. Restore_Cached_Icons();
  356. }
  357. } else {
  358. Test++;
  359. Test--;
  360. }
  361. break;
  362. case WM_DESTROY:
  363. //
  364. // Tidy up
  365. //
  366. if ( BackBuffer ) {
  367. delete BackBuffer;
  368. }
  369. delete ScreenBuffer;
  370. Invalidate_Cached_Icons();
  371. if ( DirectDrawObject ){
  372. Reset_Video_Mode();
  373. }
  374. AllDone = TRUE;
  375. PostQuitMessage (0) ;
  376. return(0);
  377. }
  378. return DefWindowProc (hwnd, message, wParam, lParam) ;
  379. }
  380. /***********************************************************************************************
  381. * Font_Test -- test the font print member of the GBC *
  382. * *
  383. * *
  384. * *
  385. * INPUT: Nothing *
  386. * *
  387. * OUTPUT: Nothing *
  388. * *
  389. * WARNINGS: None *
  390. * *
  391. * HISTORY: *
  392. * 9/27/95 3:29PM ST : Created *
  393. *=============================================================================================*/
  394. void Font_Test ( void )
  395. {
  396. const char font_name[]={"font.fnt"};
  397. if ( !FontPtr ){
  398. FontPtr = Load_Font ( &font_name[0] );
  399. FontXSpacing=0;
  400. FontYSpacing=0;
  401. FontPrintX=0;
  402. FontPrintY=0;
  403. }
  404. if ( FontPtr ){
  405. ScreenBuffer->Print ( "Hello Windoze" , FontPrintX , FontPrintY ,255 , 0);
  406. }
  407. if ( FontPrintX<550 ){
  408. FontPrintX+=8;
  409. }
  410. if ( FontPrintY<380 ){
  411. FontPrintY+=8;
  412. }
  413. }
  414. /***********************************************************************************************
  415. * Rect_Test -- test the rectangle and line functions of the GBC *
  416. * *
  417. * *
  418. * *
  419. * INPUT: Nothing *
  420. * *
  421. * OUTPUT: Nothing *
  422. * *
  423. * WARNINGS: None *
  424. * *
  425. * HISTORY: *
  426. * 9/25/95 3:03PM ST : Created *
  427. *=============================================================================================*/
  428. void Rect_Test ( GraphicBufferClass *screen_buffer )
  429. {
  430. ScreenBuffer->Lock();
  431. screen_buffer->Draw_Rect ( x1 , y1 , x2 , y2 , 255 );
  432. if ( x1<90 ){
  433. x1+=2;
  434. }
  435. if ( y1<90 ){
  436. y1+=2;
  437. }
  438. if ( x2>230 ){
  439. x2-=2;
  440. }
  441. if ( y2>110 ){
  442. y2-=2;
  443. }
  444. ScreenBuffer->Unlock();
  445. }
  446. /***********************************************************************************************
  447. * Clear_Test -- test the clear function of the GraphicBufferClass *
  448. * *
  449. * *
  450. * *
  451. * INPUT: Nothing *
  452. * *
  453. * OUTPUT: Nothing *
  454. * *
  455. * WARNINGS: None *
  456. * *
  457. * HISTORY: *
  458. * 9/25/95 3:05PM ST : Created *
  459. *=============================================================================================*/
  460. void Clear_Test ( void )
  461. {
  462. x1=0;
  463. y1=0;
  464. x2=319;
  465. y2=199;
  466. FontPrintX=0;
  467. FontPrintY=0;
  468. ScreenBuffer->Clear ( rand()&255 );
  469. }
  470. /***********************************************************************************************
  471. * Stamp_Test -- test the Draw_Stamp member of GraphicBufferClass *
  472. * *
  473. * *
  474. * *
  475. * INPUT: Nothing *
  476. * *
  477. * OUTPUT: Nothing *
  478. * *
  479. * WARNINGS: None *
  480. * *
  481. * HISTORY: *
  482. * 9/28/95 6:02PM ST : Created *
  483. *=============================================================================================*/
  484. void Stamp_Test ( void )
  485. {
  486. int x;
  487. int y;
  488. int icon=0;
  489. //
  490. // Use stacking locks to speed things up
  491. //
  492. //ScreenBuffer->Lock();
  493. Wait_Vert_Blank();
  494. Colour_Debug(1);
  495. for ( y=0 ; y<5*24 ; y+=24 ){
  496. for ( x=0 ; x<6*24 ; x+=24 ){
  497. ScreenBuffer->Draw_Stamp( IconPointer, icon++ , x+StampX, y+StampY, NULL ,0);
  498. }
  499. }
  500. Colour_Debug(0);
  501. //ScreenBuffer->Unlock();
  502. StampX+=StampXDir;
  503. StampY+=StampYDir;
  504. if ( StampX>640-6*24 || StampX<1 ){
  505. StampXDir=-StampXDir;
  506. }
  507. if ( StampY>400-6*24 || StampY<1 ){
  508. StampYDir=-StampYDir;
  509. }
  510. }
  511. /***********************************************************************************************
  512. * Stamp_Test2 -- test the Draw_Stamp member of GraphicBufferClass (no caching) *
  513. * *
  514. * *
  515. * *
  516. * INPUT: Nothing *
  517. * *
  518. * OUTPUT: Nothing *
  519. * *
  520. * WARNINGS: None *
  521. * *
  522. * HISTORY: *
  523. * 9/28/95 6:02PM ST : Created *
  524. *=============================================================================================*/
  525. void Stamp_Test2 ( void )
  526. {
  527. int x;
  528. int y;
  529. int icon=0;
  530. //
  531. // Use stacking locks to speed things up
  532. //
  533. //ScreenBuffer->Lock();
  534. Wait_Vert_Blank();
  535. Colour_Debug(2);
  536. for ( y=0 ; y<5*24 ; y+=24 ){
  537. for ( x=0 ; x<6*24 ; x+=24 ){
  538. ScreenBuffer->Draw_Stamp( IconPointer, icon++ , x+StampX, y+StampY, NULL);
  539. }
  540. }
  541. Colour_Debug(0);
  542. //ScreenBuffer->Unlock();
  543. StampX+=StampXDir;
  544. StampY+=StampYDir;
  545. if ( StampX>640-6*24 || StampX<1 ){
  546. StampXDir=-StampXDir;
  547. }
  548. if ( StampY>400-6*24 || StampY<1 ){
  549. StampYDir=-StampYDir;
  550. }
  551. }
  552. /***********************************************************************************************
  553. * Pixel_Test -- test the GVPclass put_pixel member *
  554. * *
  555. * *
  556. * *
  557. * INPUT: Nothing *
  558. * *
  559. * OUTPUT: Nothing *
  560. * *
  561. * WARNINGS: None *
  562. * *
  563. * HISTORY: *
  564. * 9/25/95 5:29PM ST : Created *
  565. *=============================================================================================*/
  566. void Pixel_Test ( void )
  567. {
  568. ScreenBuffer->Put_Pixel ( rand() & 511 , rand() & 255 , rand () &255 );
  569. }
  570. /***********************************************************************************************
  571. * Read_Pixel_Test -- test the GVPclass Read_Pixel member *
  572. * *
  573. * *
  574. * *
  575. * INPUT: Nothing *
  576. * *
  577. * OUTPUT: Nothing *
  578. * *
  579. * WARNINGS: None *
  580. * *
  581. * HISTORY: *
  582. * 9/26/95 4:51PM ST : Created *
  583. *=============================================================================================*/
  584. void Read_Pixel_Test ( void )
  585. {
  586. int i;
  587. int colour;
  588. int pixel_x;
  589. int pixel_y;
  590. if ( !BackBuffer ) {
  591. BackBuffer = new GraphicBufferClass(640,400, GBC_VIDEOMEM );
  592. BackBuffer->Clear( 0 );
  593. ScreenBuffer->Clear ( 0 );
  594. x1=0;
  595. y1=0;
  596. x2=319;
  597. y2=199;
  598. for ( i=0 ; i<50 ; i++ ) {
  599. Rect_Test ( BackBuffer );
  600. }
  601. }
  602. //
  603. // Use the stacking lock feature to lock the surfaces once only and
  604. // then draw 10 pixels
  605. //
  606. ScreenBuffer->Lock();
  607. BackBuffer->Lock();
  608. for ( i=0 ; i<10 ; i++ ){
  609. pixel_x = rand() &511;
  610. pixel_y = rand() &255;
  611. colour=BackBuffer->Get_Pixel ( pixel_x , pixel_y );
  612. ScreenBuffer->Put_Pixel ( pixel_x , pixel_y , colour );
  613. }
  614. BackBuffer->Unlock();
  615. ScreenBuffer->Unlock();
  616. }
  617. /***********************************************************************************************
  618. * Scale_Test -- test the GVPclass scale member *
  619. * *
  620. * *
  621. * *
  622. * INPUT: Nothing *
  623. * *
  624. * OUTPUT: Nothing *
  625. * *
  626. * WARNINGS: None *
  627. * *
  628. * HISTORY: *
  629. * 9/26/95 10:27AM ST : Created *
  630. *=============================================================================================*/
  631. void Scale_Test ( void )
  632. {
  633. int i;
  634. if ( !BackBuffer ) {
  635. BackBuffer = new GraphicBufferClass(640, 400);
  636. BackBuffer->Clear( 0 );
  637. x1=0;
  638. y1=0;
  639. x2=319;
  640. y2=199;
  641. for ( i=0 ; i<50 ; i++ ) {
  642. Rect_Test ( BackBuffer );
  643. }
  644. BlitStretchX=0;
  645. BlitStretchY=0;
  646. BlitStretchXAdd=1;
  647. BlitStretchYAdd=1;
  648. }
  649. BackBuffer->Scale ( *ScreenBuffer , 0 , 0 , 10 , 10
  650. ,320 , 200 , 320+BlitStretchX , 200+BlitStretchY );
  651. BlitStretchX += BlitStretchXAdd;
  652. BlitStretchY += BlitStretchYAdd;
  653. if ( (BlitStretchX == 100) || (BlitStretchX==-100) ){
  654. BlitStretchXAdd=-BlitStretchXAdd;
  655. }
  656. if ( (BlitStretchY == 100) || (BlitStretchY==-100) ){
  657. BlitStretchYAdd=-BlitStretchYAdd;
  658. }
  659. }
  660. /***********************************************************************************************
  661. * Blit_Test1 -- test the blit member of the GraphicBufferClass *
  662. * *
  663. * Blits from video memory to video memory *
  664. * *
  665. * *
  666. * INPUT: Nothing *
  667. * *
  668. * OUTPUT: Nothing *
  669. * *
  670. * WARNINGS: None *
  671. * *
  672. * HISTORY: *
  673. * 9/25/95 5:39PM ST : Created *
  674. *=============================================================================================*/
  675. void Blit_Test1 ( void )
  676. {
  677. int i;
  678. if ( !BackBuffer ) {
  679. BackBuffer = new GraphicBufferClass(640, 400, GBC_VIDEOMEM);
  680. BackBuffer->Clear( 0 );
  681. x1=0;
  682. y1=0;
  683. x2=319;
  684. y2=199;
  685. for ( i=0 ; i<50 ; i++ ) {
  686. Rect_Test ( BackBuffer );
  687. }
  688. BlitXAdd=0;
  689. BlitXDir=1;
  690. BlitYAdd=0;
  691. BlitYDir=1;
  692. }
  693. BackBuffer->Blit ( *ScreenBuffer , 0 , 0 , BlitXAdd , BlitYAdd , 320 , 200 , (BOOL) FALSE );
  694. BlitXAdd+=BlitXDir;
  695. if ( (BlitXAdd == 0) || (BlitXAdd == 320 )){
  696. BlitXDir=-BlitXDir;
  697. }
  698. BlitYAdd+=BlitYDir;
  699. if ( (BlitYAdd == 0) || (BlitYAdd == 200 )){
  700. BlitYDir=-BlitYDir;
  701. }
  702. }
  703. /***********************************************************************************************
  704. * Blit_Test2 -- test the blit member of the GraphicBufferClass *
  705. * *
  706. * Blits from system memory to video memory *
  707. * *
  708. * *
  709. * INPUT: Nothing *
  710. * *
  711. * OUTPUT: Nothing *
  712. * *
  713. * WARNINGS: None *
  714. * *
  715. * HISTORY: *
  716. * 9/27/95 9:36AM ST : Created *
  717. *=============================================================================================*/
  718. void Blit_Test2 ( void )
  719. {
  720. int i;
  721. if ( !BackBuffer ) {
  722. BackBuffer = new GraphicBufferClass(640, 400);
  723. BackBuffer->Clear( 0 );
  724. x1=0;
  725. y1=0;
  726. x2=319;
  727. y2=199;
  728. for ( i=0 ; i<50 ; i++ ) {
  729. Rect_Test ( BackBuffer );
  730. }
  731. BlitXAdd=0;
  732. BlitXDir=1;
  733. BlitYAdd=0;
  734. BlitYDir=1;
  735. }
  736. BackBuffer->Blit ( *ScreenBuffer , 0 , 0 , BlitXAdd , BlitYAdd , 320 , 200 , (BOOL) FALSE );
  737. BlitXAdd+=BlitXDir;
  738. if ( (BlitXAdd == 0) || (BlitXAdd == 320 )){
  739. BlitXDir=-BlitXDir;
  740. }
  741. BlitYAdd+=BlitYDir;
  742. if ( (BlitYAdd == 0) || (BlitYAdd == 200 )){
  743. BlitYDir=-BlitYDir;
  744. }
  745. }
  746. /***********************************************************************************************
  747. * Fill_Rect_Test -- test the GraphicBufferClass fill rectangle member *
  748. * *
  749. * *
  750. * *
  751. * INPUT: Nothing *
  752. * *
  753. * OUTPUT: Nothing *
  754. * *
  755. * WARNINGS: None *
  756. * *
  757. * HISTORY: *
  758. * 9/26/95 5:23PM ST : Created *
  759. *=============================================================================================*/
  760. void Fill_Rect_Test ( void )
  761. {
  762. int x1;
  763. int y1;
  764. int x2;
  765. int y2;
  766. x1= rand()&511;
  767. x2= rand()&511;
  768. y1= rand()&255;
  769. y2= rand()&255;
  770. ScreenBuffer->Fill_Rect ( min ( x1,x2 ) , min ( y1,y2) , max ( x1,x2 ) , max ( y1,y2 ) , rand()&255 );
  771. }
  772. /***********************************************************************************************
  773. * Remap_Test -- test the Remap member of GraphicsBufferClass *
  774. * *
  775. * *
  776. * *
  777. * INPUT: Nothing *
  778. * *
  779. * OUTPUT: Nothing *
  780. * *
  781. * WARNINGS: None *
  782. * *
  783. * HISTORY: *
  784. * 9/26/95 6:26PM ST : Created *
  785. *=============================================================================================*/
  786. void Remap_Test ( void )
  787. {
  788. ScreenBuffer->Remap ( 0 , 0 , 640 , 400 , &RemapTable[0] );
  789. }
  790. /***********************************************************************************************
  791. * Quad_Test -- test the quad fill member of GraphicBufferClass *
  792. * *
  793. * *
  794. * *
  795. * INPUT: Nothing *
  796. * *
  797. * OUTPUT: Nothing *
  798. * *
  799. * WARNINGS: None *
  800. * *
  801. * HISTORY: *
  802. * 9/27/95 11:12AM ST : Created *
  803. *=============================================================================================*/
  804. void Quad_Test ( void )
  805. {
  806. int colour;
  807. int x0;
  808. int x1;
  809. int x2;
  810. int x3;
  811. int y0;
  812. int y1;
  813. int y2;
  814. int y3;
  815. x0 = rand() & 255;
  816. x1 = rand() & 255+320;
  817. x2 = rand() & 255+320;
  818. x3 = rand() & 255;
  819. y0 = rand() & 127;
  820. y1 = rand() & 127;
  821. y2 = rand() & 127+250;
  822. y3 = rand() & 127+250;
  823. colour= rand()&255;
  824. ScreenBuffer->Fill_Quad ( SpanBuff , x0,y0,x1,y1,x2,y2,x3,y3,colour);
  825. }
  826. /***********************************************************************************************
  827. * Copy_Test - test the To_Buffer member of GraphicsBufferClass *
  828. * *
  829. * *
  830. * *
  831. * INPUT: Nothing *
  832. * *
  833. * OUTPUT: Nothing *
  834. * *
  835. * WARNINGS: None *
  836. * *
  837. * HISTORY: *
  838. * 9/27/95 11:36AM ST : Created *
  839. *=============================================================================================*/
  840. void Copy_Test ( void )
  841. {
  842. BufferClass *buffer;
  843. char *buffer_ptr;
  844. buffer = new BufferClass (640*400);
  845. ScreenBuffer->To_Buffer(buffer);
  846. buffer_ptr = (char*)buffer->Get_Buffer();
  847. memcpy ( buffer_ptr , buffer_ptr+4 , 640*400-4 );
  848. buffer->To_Page ( *ScreenBuffer );
  849. delete buffer;
  850. }
  851. /***********************************************************************************************
  852. * Test_All -- perform tests on GraphicsBufferClass *
  853. * *
  854. * *
  855. * *
  856. * INPUT: Nothing *
  857. * *
  858. * OUTPUT: Nothing *
  859. * *
  860. * WARNINGS: None *
  861. * *
  862. * HISTORY: *
  863. * 9/25/95 2:53PM ST : Created *
  864. *=============================================================================================*/
  865. void Test_All ( void )
  866. {
  867. switch ( Test ){
  868. case 0:
  869. Clear_Test();
  870. break;
  871. case 1:
  872. Rect_Test( ScreenBuffer );
  873. break;
  874. case 2:
  875. Pixel_Test();
  876. break;
  877. case 3:
  878. Blit_Test1();
  879. break;
  880. case 4:
  881. Blit_Test2();
  882. break;
  883. case 5:
  884. Scale_Test();
  885. break;
  886. case 6:
  887. Read_Pixel_Test();
  888. break;
  889. case 7:
  890. Fill_Rect_Test();
  891. break;
  892. case 8:
  893. Remap_Test();
  894. break;
  895. case 9:
  896. Quad_Test();
  897. break;
  898. case 10:
  899. Copy_Test();
  900. break;
  901. case 11:
  902. Font_Test();
  903. break;
  904. case 12:
  905. Stamp_Test();
  906. break;
  907. case 13:
  908. Stamp_Test2();
  909. break;
  910. }
  911. }