SZREGION.ASM 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 : Calculate size of an MCGA region *
  23. ;* *
  24. ;* File Name : REGIONSZ.ASM *
  25. ;* *
  26. ;* Programmer : Barry W. Green *
  27. ;* *
  28. ;* Start Date : March 1, 1995 *
  29. ;* *
  30. ;* Last Update : March 1, 1995 [BWG] *
  31. ;* *
  32. ;*-------------------------------------------------------------------------*
  33. ;* Functions: *
  34. ;* VVPC::Size_Of_Region - calculate graphic buffer region size *
  35. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  36. IDEAL
  37. P386
  38. MODEL USE32 FLAT
  39. INCLUDE ".\drawbuff.inc"
  40. INCLUDE ".\gbuffer.inc"
  41. GLOBAL Buffer_Size_Of_Region : NEAR
  42. CODESEG
  43. ;***************************************************************************
  44. ;* VVPC::Size_Of_Region - calculate buffer region size *
  45. ;* *
  46. ;* INPUT: DWORD the width of the region *
  47. ;* *
  48. ;* DWORD the height of the region *
  49. ;* *
  50. ;* OUTPUT: calculated size of the region (size = width * height) *
  51. ;* *
  52. ;* *
  53. ;* HISTORY: *
  54. ;* 03/01/1995 BWG : Created. *
  55. ;*=========================================================================*
  56. PROC Buffer_Size_Of_Region C near
  57. USES ebx,ecx,edx
  58. ARG this_object:DWORD ; this is a member function
  59. ARG region_width:DWORD ; width of region
  60. ARG region_height:DWORD ; height of region
  61. ;*===================================================================
  62. ; Get the viewport information
  63. ;*===================================================================
  64. mov ebx,[this_object] ; get a pointer to viewport
  65. xor eax,eax
  66. mov ecx,[(GraphicViewPort ebx).GVPHeight] ; ecx = height of viewport
  67. mov edx,[(GraphicViewPort ebx).GVPWidth] ; edx = width of viewport
  68. ;*===================================================================
  69. ; Verify that the width is legal
  70. ;*===================================================================
  71. mov eax,[region_width] ; find the width
  72. cmp eax,edx ; is it too wide?
  73. jb short ??wok ; if not, leave it alone
  74. mov eax,edx ; otherwise clip it
  75. ;*===================================================================
  76. ; Verify that the height is ok
  77. ;*===================================================================
  78. ??wok: mov ebx,[region_height] ; get the height
  79. cmp ebx,ecx ; is it too tall?
  80. jb ??hok ; if not, leave it alone
  81. mov ebx,ecx ; otherwise clip it
  82. ;*===================================================================
  83. ; Now multiply 'em to calculate the size of the region
  84. ;*===================================================================
  85. ??hok: mul ebx ; size = w * h
  86. ret
  87. ENDP Buffer_Size_Of_Region
  88. END