GBUFFER.CPP 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  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 A S S O C I A T E S **
  20. ***************************************************************************
  21. * *
  22. * Project Name : Westwood 32 bit Library *
  23. * *
  24. * File Name : GBUFFER.CPP *
  25. * *
  26. * Programmer : Phil W. Gorrow *
  27. * *
  28. * Start Date : May 3, 1994 *
  29. * *
  30. * Last Update : October 9, 1995 [] *
  31. * *
  32. *-------------------------------------------------------------------------*
  33. * Functions: *
  34. * VVPC::VirtualViewPort -- Default constructor for a virtual viewport *
  35. * VVPC:~VirtualViewPortClass -- Destructor for a virtual viewport *
  36. * VVPC::Clear -- Clears a graphic page to correct color *
  37. * VBC::VideoBufferClass -- Lowlevel constructor for video buffer class *
  38. * GVPC::Change -- Changes position and size of a Graphic View Port *
  39. * VVPC::Change -- Changes position and size of a Video View Port *
  40. * Set_Logic_Page -- Sets LogicPage to new buffer *
  41. * GBC::DD_Init -- Inits a direct draw surface for a GBC *
  42. * GBC::Init -- Core function responsible for initing a GBC *
  43. * GBC::Lock -- Locks a Direct Draw Surface *
  44. * GBC::Unlock -- Unlocks a direct draw surface *
  45. * GBC::GraphicBufferClass -- Default constructor (requires explicit init)*
  46. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  47. #ifndef GBUFFER_H
  48. #include "gbuffer.h"
  49. #include "misc.h"
  50. #endif
  51. #pragma inline
  52. int TotalLocks;
  53. BOOL AllowHardwareBlitFills = TRUE;
  54. //int CacheAllowed;
  55. /*=========================================================================*/
  56. /* The following PRIVATE functions are in this file: */
  57. /*=========================================================================*/
  58. /*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
  59. /***************************************************************************
  60. * GVPC::GRAPHICVIEWPORTCLASS -- Constructor for basic view port class *
  61. * m *
  62. * INPUT: GraphicBufferClass * gbuffer - buffer to attach to *
  63. * int x - x offset into buffer *
  64. * int y - y offset into buffer *
  65. * int w - view port width in pixels *
  66. * int h - view port height in pixels *
  67. * *
  68. * OUTPUT: Constructors may not have a return value *
  69. * *
  70. * HISTORY: *
  71. * 05/09/1994 PWG : Created. *
  72. *=========================================================================*/
  73. GraphicViewPortClass::GraphicViewPortClass(GraphicBufferClass *gbuffer, int x, int y, int w, int h) :
  74. LockCount(0),
  75. GraphicBuff(NULL)
  76. {
  77. Attach(gbuffer, x, y, w, h);
  78. }
  79. /***************************************************************************
  80. * GVPC::GRAPHICVIEWPORTCLASS -- Default constructor for view port class *
  81. * *
  82. * INPUT: none *
  83. * *
  84. * OUTPUT: none *
  85. * *
  86. * HISTORY: *
  87. * 05/09/1994 PWG : Created. *
  88. *=========================================================================*/
  89. GraphicViewPortClass::GraphicViewPortClass(void)
  90. {
  91. }
  92. /***************************************************************************
  93. * GVPC::~GRAPHICVIEWPORTCLASS -- Destructor for GraphicViewPortClass *
  94. * *
  95. * INPUT: none *
  96. * *
  97. * OUTPUT: A destructor may not return a value. *
  98. * *
  99. * HISTORY: *
  100. * 05/10/1994 PWG : Created. *
  101. *=========================================================================*/
  102. GraphicViewPortClass::~GraphicViewPortClass(void)
  103. {
  104. Offset = 0;
  105. Width = 0; // Record width of Buffer
  106. Height = 0; // Record height of Buffer
  107. XAdd = 0; // Record XAdd of Buffer
  108. XPos = 0; // Record XPos of Buffer
  109. YPos = 0; // Record YPos of Buffer
  110. Pitch = 0; // Record width of Buffer
  111. IsDirectDraw = FALSE;
  112. LockCount = 0;
  113. GraphicBuff = NULL;
  114. }
  115. /***************************************************************************
  116. * GVPC::ATTACH -- Attaches a viewport to a buffer class *
  117. * *
  118. * INPUT: GraphicBufferClass *g_buff - pointer to gbuff to attach to *
  119. * int x - x position to attach to *
  120. * int y - y position to attach to *
  121. * int w - width of the view port *
  122. * int h - height of the view port *
  123. * *
  124. * OUTPUT: none *
  125. * *
  126. * HISTORY: *
  127. * 05/10/1994 PWG : Created. *
  128. *=========================================================================*/
  129. void GraphicViewPortClass::Attach(GraphicBufferClass *gbuffer, int x, int y, int w, int h)
  130. {
  131. /*======================================================================*/
  132. /* Can not attach a Graphic View Port if it is actually the physical */
  133. /* representation of a Graphic Buffer. */
  134. /*======================================================================*/
  135. if (this == Get_Graphic_Buffer()) {
  136. return;
  137. }
  138. /*======================================================================*/
  139. /* Verify that the x and y coordinates are valid and placed within the */
  140. /* physical buffer. */
  141. /*======================================================================*/
  142. if (x < 0) // you cannot place view port off
  143. x = 0; // the left edge of physical buf
  144. if (x >= gbuffer->Get_Width()) // you cannot place left edge off
  145. x = gbuffer->Get_Width() - 1; // the right edge of physical buf
  146. if (y < 0) // you cannot place view port off
  147. y = 0; // the top edge of physical buf
  148. if (y >= gbuffer->Get_Height()) // you cannot place view port off
  149. y = gbuffer->Get_Height() - 1; // bottom edge of physical buf
  150. /*======================================================================*/
  151. /* Adjust the width and height of necessary */
  152. /*======================================================================*/
  153. if (x + w > gbuffer->Get_Width()) // if the x plus width is larger
  154. w = gbuffer->Get_Width() - x; // than physical, fix width
  155. if (y + h > gbuffer->Get_Height()) // if the y plus height is larger
  156. h = gbuffer->Get_Height() - y; // than physical, fix height
  157. /*======================================================================*/
  158. /* Get a pointer to the top left edge of the buffer. */
  159. /*======================================================================*/
  160. Offset = gbuffer->Get_Offset() + ((gbuffer->Get_Width()+gbuffer->Get_Pitch()) * y) + x;
  161. /*======================================================================*/
  162. /* Copy over all of the variables that we need to store. */
  163. /*======================================================================*/
  164. XPos = x;
  165. YPos = y;
  166. XAdd = gbuffer->Get_Width() - w;
  167. Width = w;
  168. Height = h;
  169. Pitch = gbuffer->Get_Pitch();
  170. GraphicBuff = gbuffer;
  171. IsDirectDraw= gbuffer->IsDirectDraw;
  172. }
  173. /***************************************************************************
  174. * GVPC::CHANGE -- Changes position and size of a Graphic View Port *
  175. * *
  176. * INPUT: int the new x pixel position of the graphic view port *
  177. * int the new y pixel position of the graphic view port *
  178. * int the new width of the viewport in pixels *
  179. * int the new height of the viewport in pixels *
  180. * *
  181. * OUTPUT: BOOL whether the Graphic View Port could be sucessfully *
  182. * resized. *
  183. * *
  184. * WARNINGS: You may not resize a Graphic View Port which is derived *
  185. * from a Graphic View Port Buffer, *
  186. * *
  187. * HISTORY: *
  188. * 09/14/1994 SKB : Created. *
  189. *=========================================================================*/
  190. BOOL GraphicViewPortClass::Change(int x, int y, int w, int h)
  191. {
  192. /*======================================================================*/
  193. /* Can not change a Graphic View Port if it is actually the physical */
  194. /* representation of a Graphic Buffer. */
  195. /*======================================================================*/
  196. if (this == Get_Graphic_Buffer()) {
  197. return(FALSE);
  198. }
  199. /*======================================================================*/
  200. /* Since there is no allocated information, just re-attach it to the */
  201. /* existing graphic buffer as if we were creating the */
  202. /* GraphicViewPort. */
  203. /*======================================================================*/
  204. Attach(Get_Graphic_Buffer(), x, y, w, h);
  205. return(TRUE);
  206. }
  207. /***************************************************************************
  208. * GBC::DD_INIT -- Inits a direct draw surface for a GBC *
  209. * *
  210. * INPUT: none *
  211. * *
  212. * OUTPUT: none *
  213. * *
  214. * HISTORY: *
  215. * 10/09/1995 : Created. *
  216. *=========================================================================*/
  217. void GraphicBufferClass::DD_Init(GBC_Enum flags)
  218. {
  219. //
  220. // Create the direct draw surface description
  221. //
  222. memset (&VideoSurfaceDescription , 0 , sizeof ( VideoSurfaceDescription ));
  223. VideoSurfaceDescription.dwSize = sizeof( VideoSurfaceDescription );
  224. VideoSurfaceDescription.dwFlags = DDSD_CAPS;
  225. VideoSurfaceDescription.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
  226. if (!(flags & GBC_VISIBLE)) {
  227. VideoSurfaceDescription.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
  228. VideoSurfaceDescription.dwFlags |= DDSD_HEIGHT | DDSD_WIDTH;
  229. VideoSurfaceDescription.dwHeight = Height;
  230. VideoSurfaceDescription.dwWidth = Width;
  231. }
  232. //
  233. // Need to set the DDSCAPS_MODEX flag if we want a 320 wide mode
  234. //
  235. if ( Width == 320 ) {
  236. VideoSurfaceDescription.ddsCaps.dwCaps |= DDSCAPS_MODEX;
  237. }
  238. //
  239. // Call CreateSurface
  240. //
  241. DirectDrawObject->CreateSurface( &VideoSurfaceDescription , &VideoSurfacePtr , NULL);
  242. AllSurfaces.Add_DD_Surface (VideoSurfacePtr);
  243. if ( GBC_VISIBLE & flags ){
  244. PaletteSurface=VideoSurfacePtr;
  245. }
  246. Allocated = FALSE; // even if system alloced, dont flag it cuz
  247. // we dont want it freed.
  248. IsDirectDraw = TRUE; // flag it as a video surface
  249. Offset = NOT_LOCKED; // flag it as unavailable for reading or writing
  250. LockCount = 0; // surface is not locked
  251. }
  252. void GraphicBufferClass::Attach_DD_Surface (GraphicBufferClass * attach_buffer)
  253. {
  254. VideoSurfacePtr->AddAttachedSurface (attach_buffer->Get_DD_Surface());
  255. }
  256. /***************************************************************************
  257. * GBC::INIT -- Core function responsible for initing a GBC *
  258. * *
  259. * INPUT: int - the width in pixels of the GraphicBufferClass *
  260. * int - the heigh in pixels of the GraphicBufferClass *
  261. * void * - pointer to user supplied buffer (system will *
  262. * allocate space if buffer is NULL) *
  263. * long - size of the user provided buffer *
  264. * GBC_Enum - flags if this is defined as a direct draw *
  265. * surface *
  266. * *
  267. * OUTPUT: none *
  268. * *
  269. * HISTORY: *
  270. * 10/09/1995 : Created. *
  271. *=========================================================================*/
  272. void GraphicBufferClass::Init(int w, int h, void *buffer, long size, GBC_Enum flags)
  273. {
  274. Size = size; // find size of physical buffer
  275. Width = w; // Record width of Buffer
  276. Height = h; // Record height of Buffer
  277. //
  278. // If the surface we are creating is a direct draw object then
  279. // we need to do a direct draw init. Otherwise we will do
  280. // a normal alloc.
  281. //
  282. if (flags & (GBC_VIDEOMEM | GBC_VISIBLE)) {
  283. DD_Init(flags);
  284. } else {
  285. if (buffer) { // if buffer is specified
  286. Buffer = (BYTE *)buffer; // point to it and mark
  287. Allocated = FALSE; // it as user allocated
  288. } else {
  289. if (!Size) Size = w*h;
  290. Buffer = new BYTE[Size]; // otherwise allocate it and
  291. Allocated = TRUE; // mark it system alloced
  292. }
  293. Offset = (long)Buffer; // Get offset to the buffer
  294. IsDirectDraw = FALSE;
  295. }
  296. Pitch = 0; // Record width of Buffer
  297. XAdd = 0; // Record XAdd of Buffer
  298. XPos = 0; // Record XPos of Buffer
  299. YPos = 0; // Record YPos of Buffer
  300. GraphicBuff = this; // Get a pointer to our self
  301. }
  302. /***********************************************************************************************
  303. * GBC::Un_Init -- releases the video surface belonging to this gbuffer *
  304. * *
  305. * *
  306. * *
  307. * INPUT: Nothing *
  308. * *
  309. * OUTPUT: Nothing *
  310. * *
  311. * WARNINGS: None *
  312. * *
  313. * HISTORY: *
  314. * 6/6/96 12:44PM ST : Created *
  315. *=============================================================================================*/
  316. void GraphicBufferClass::Un_Init (void)
  317. {
  318. if ( IsDirectDraw ){
  319. if ( VideoSurfacePtr ){
  320. while ( LockCount ){
  321. if (VideoSurfacePtr->Unlock ( NULL ) == DDERR_SURFACELOST){
  322. if (Gbuffer_Focus_Loss_Function){
  323. Gbuffer_Focus_Loss_Function();
  324. }
  325. AllSurfaces.Restore_Surfaces();
  326. }
  327. }
  328. AllSurfaces.Remove_DD_Surface (VideoSurfacePtr);
  329. VideoSurfacePtr->Release();
  330. VideoSurfacePtr = NULL;
  331. }
  332. }
  333. }
  334. /***************************************************************************
  335. * GBC::GRAPHICBUFFERCLASS -- Default constructor (requires explicit init) *
  336. * *
  337. * INPUT: none *
  338. * *
  339. * OUTPUT: none *
  340. * *
  341. * HISTORY: *
  342. * 10/09/1995 : Created. *
  343. *=========================================================================*/
  344. GraphicBufferClass::GraphicBufferClass(void)
  345. {
  346. GraphicBuff = this; // Get a pointer to our self
  347. VideoSurfacePtr = NULL;
  348. memset(&VideoSurfaceDescription, 0, sizeof(DDSURFACEDESC));
  349. }
  350. /***************************************************************************
  351. * GBC::GRAPHICBUFFERCLASS -- Constructor for fixed size buffers *
  352. * *
  353. * INPUT: long size - size of the buffer to create *
  354. * int w - width of buffer in pixels (default = 320) *
  355. * int h - height of buffer in pixels (default = 200) *
  356. * void *buffer - a pointer to the buffer if any (optional) *
  357. * *
  358. * OUTPUT: *
  359. * *
  360. * WARNINGS: *
  361. * *
  362. * HISTORY: *
  363. * 05/13/1994 PWG : Created. *
  364. *=========================================================================*/
  365. GraphicBufferClass::GraphicBufferClass(int w, int h, void *buffer, long size)
  366. {
  367. Init(w, h, buffer, size, GBC_NONE);
  368. }
  369. /*=========================================================================*
  370. * GBC::GRAPHICBUFFERCLASS -- inline constructor for GraphicBufferClass *
  371. * *
  372. * INPUT: int w - width of buffer in pixels (default = 320) *
  373. * int h - height of buffer in pixels (default = 200) *
  374. * void *buffer - a pointer to the buffer if any (optional) *
  375. * *
  376. * OUTPUT: none *
  377. * *
  378. * HISTORY: *
  379. * 05/03/1994 PWG : Created. *
  380. *=========================================================================*/
  381. GraphicBufferClass::GraphicBufferClass(int w, int h, void *buffer)
  382. {
  383. Init(w, h, buffer, w * h, GBC_NONE);
  384. }
  385. /*====================================================================================*
  386. * GBC::GRAPHICBUFFERCLASS -- contructor for GraphicsBufferClass with special flags *
  387. * *
  388. * INPUT: int w - width of buffer in pixels (default = 320) *
  389. * int h - height of buffer in pixels (default = 200) *
  390. * void *buffer - unused *
  391. * unsigned flags - flags for creation of special buffer types *
  392. * GBC_VISIBLE - buffer is a visible screen surface *
  393. * GBC_VIDEOMEM - buffer resides in video memory *
  394. * *
  395. * OUTPUT: none *
  396. * *
  397. * HISTORY: *
  398. * 09-21-95 04:19pm ST : Created *
  399. *====================================================================================*/
  400. GraphicBufferClass::GraphicBufferClass(int w, int h, GBC_Enum flags)
  401. {
  402. Init(w, h, NULL, w * h, flags);
  403. }
  404. /*=========================================================================*
  405. * GBC::~GRAPHICBUFFERCLASS -- Destructor for the graphic buffer class *
  406. * *
  407. * INPUT: none *
  408. * *
  409. * OUTPUT: none *
  410. * *
  411. * HISTORY: *
  412. * 05/03/1994 PWG : Created. *
  413. *=========================================================================*/
  414. GraphicBufferClass::~GraphicBufferClass()
  415. {
  416. //
  417. // Release the direct draw surface if it exists
  418. //
  419. Un_Init();
  420. }
  421. /***************************************************************************
  422. * SET_LOGIC_PAGE -- Sets LogicPage to new buffer *
  423. * *
  424. * INPUT: GraphicBufferClass * the buffer we are going to set *
  425. * *
  426. * OUTPUT: GraphicBufferClass * the previous buffer type *
  427. * *
  428. * WARNINGS: *
  429. * *
  430. * HISTORY: *
  431. * 02/23/1995 PWG : Created. *
  432. *=========================================================================*/
  433. GraphicViewPortClass *Set_Logic_Page(GraphicViewPortClass *ptr)
  434. {
  435. GraphicViewPortClass *old = LogicPage;
  436. LogicPage = ptr;
  437. return(old);
  438. }
  439. /***************************************************************************
  440. * SET_LOGIC_PAGE -- Sets LogicPage to new buffer *
  441. * *
  442. * INPUT: GraphicBufferClass & the buffer we are going to set *
  443. * *
  444. * OUTPUT: GraphicBufferClass * the previous buffer type *
  445. * *
  446. * WARNINGS: *
  447. * *
  448. * HISTORY: *
  449. * 02/23/1995 PWG : Created. *
  450. *=========================================================================*/
  451. GraphicViewPortClass *Set_Logic_Page(GraphicViewPortClass &ptr)
  452. {
  453. GraphicViewPortClass *old = LogicPage;
  454. LogicPage = &ptr;
  455. return(old);
  456. }
  457. /***************************************************************************
  458. * GBC::LOCK -- Locks a Direct Draw Surface *
  459. * *
  460. * INPUT: none *
  461. * *
  462. * OUTPUT: none *
  463. * *
  464. * HISTORY: *
  465. * 10/09/1995 : Created. *
  466. * 10/09/1995 : Code stolen from Steve Tall *
  467. *=========================================================================*/
  468. extern void Colour_Debug (int call_number);
  469. extern BOOL GameInFocus;
  470. extern void Block_Mouse(GraphicBufferClass *buffer);
  471. extern void Unblock_Mouse(GraphicBufferClass *buffer);
  472. BOOL GraphicBufferClass::Lock(void)
  473. {
  474. HRESULT result;
  475. int restore_attempts=0;
  476. //
  477. // If its not a direct draw surface then the lock is always sucessful.
  478. //
  479. if (!IsDirectDraw) return(TRUE);
  480. /*
  481. ** If the video surface pointer is null then return
  482. */
  483. if (!VideoSurfacePtr) return (FALSE);
  484. /*
  485. ** If we dont have focus then return failure
  486. */
  487. if (!GameInFocus) return (FALSE);
  488. Block_Mouse(this);
  489. //
  490. // If surface is already locked then inc the lock count and return true
  491. //
  492. if (LockCount){
  493. LockCount++;
  494. Unblock_Mouse(this);
  495. return(TRUE);
  496. }
  497. //
  498. // If it isn't locked at all then we will have to request that Direct
  499. // Draw actually lock the surface.
  500. //
  501. if (VideoSurfacePtr){
  502. while (!LockCount && restore_attempts<2) {
  503. result = VideoSurfacePtr->Lock ( NULL
  504. , &(VideoSurfaceDescription)
  505. , DDLOCK_WAIT
  506. , NULL);
  507. switch (result){
  508. case DD_OK :
  509. Offset = (unsigned long)VideoSurfaceDescription.lpSurface;
  510. Pitch = VideoSurfaceDescription.lPitch;
  511. Pitch -= Width;
  512. LockCount++; // increment count so we can track if
  513. TotalLocks++; // Total number of times we have locked (for debugging)
  514. //Colour_Debug (1);
  515. Unblock_Mouse(this);
  516. return (TRUE); // we locked it multiple times.
  517. case DDERR_SURFACELOST :
  518. if (Gbuffer_Focus_Loss_Function){
  519. Gbuffer_Focus_Loss_Function();
  520. }
  521. AllSurfaces.Restore_Surfaces();
  522. restore_attempts++;
  523. break;
  524. default :
  525. Unblock_Mouse(this);
  526. return (FALSE);
  527. }
  528. }
  529. }
  530. //Colour_Debug(1);
  531. Unblock_Mouse(this);
  532. return (FALSE); //Return false because we couldnt lock or restore the surface
  533. }
  534. /***************************************************************************
  535. * GBC::UNLOCK -- Unlocks a direct draw surface *
  536. * *
  537. * INPUT: none *
  538. * *
  539. * OUTPUT: none *
  540. * *
  541. * HISTORY: *
  542. * 10/09/1995 : Created. *
  543. * 10/09/1995 : Code stolen from Steve Tall *
  544. *=========================================================================*/
  545. BOOL GraphicBufferClass::Unlock(void)
  546. {
  547. //
  548. // If there is no lock count or this is not a direct draw surface
  549. // then just return true as there is no harm done.
  550. //
  551. if (!(LockCount && IsDirectDraw)) {
  552. return(TRUE);
  553. }
  554. //
  555. // If lock count is directly equal to one then we actually need to
  556. // unlock so just give it a shot.
  557. //
  558. if (LockCount == 1 && VideoSurfacePtr) {
  559. Block_Mouse(this);
  560. if ( VideoSurfacePtr->Unlock ( NULL ) != DD_OK ){
  561. Unblock_Mouse(this);
  562. return(FALSE);
  563. } else {
  564. Offset=NOT_LOCKED;
  565. LockCount--;
  566. Unblock_Mouse(this);
  567. return(TRUE);
  568. }
  569. }
  570. //Colour_Debug (0);
  571. LockCount--;
  572. return(TRUE);
  573. }
  574. /***********************************************************************************************
  575. * GVPC::DD_Linear_Blit_To_Linear -- blit using the hardware blitter *
  576. * *
  577. * *
  578. * *
  579. * INPUT: destination vvpc *
  580. * x coord to blit from *
  581. * y coord to blit from *
  582. * x coord to blit to *
  583. * y coord to blit to *
  584. * width to blit *
  585. * height to blit *
  586. * *
  587. * OUTPUT: DD_OK if successful *
  588. * *
  589. * WARNINGS: None *
  590. * *
  591. * HISTORY: *
  592. * 09-22-95 11:05am ST : Created *
  593. *=============================================================================================*/
  594. HRESULT GraphicViewPortClass::DD_Linear_Blit_To_Linear (
  595. GraphicViewPortClass &dest
  596. , int source_x
  597. , int source_y
  598. , int dest_x
  599. , int dest_y
  600. , int width
  601. , int height
  602. , BOOL mask )
  603. {
  604. RECT source_rectangle;
  605. RECT dest_rectangle;
  606. int key_source=0;
  607. if ( mask ){
  608. key_source=DDBLT_KEYSRC;
  609. }
  610. source_rectangle.left = source_x;
  611. source_rectangle.top = source_y;
  612. source_rectangle.right = source_x+width;
  613. source_rectangle.bottom = source_y+height;
  614. dest_rectangle.left = dest_x;
  615. dest_rectangle.top = dest_y;
  616. dest_rectangle.right = dest_x+width;
  617. dest_rectangle.bottom = dest_y+height;
  618. return ( dest.GraphicBuff->Get_DD_Surface()->Blt ( &dest_rectangle,
  619. GraphicBuff->Get_DD_Surface(),
  620. &source_rectangle,
  621. key_source | DDBLT_WAIT | DDBLT_ASYNC,
  622. NULL ) );
  623. }