TEST.BAK 39 KB

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