GETPIX.ASM 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 : GraphicViewPortClass *
  23. ;* *
  24. ;* File Name : GETPIXEL.ASM *
  25. ;* *
  26. ;* Programmer : Phil Gorrow *
  27. ;* *
  28. ;* Start Date : June 7, 1994 *
  29. ;* *
  30. ;* Last Update : June 7, 1994 [PWG] *
  31. ;* *
  32. ;*-------------------------------------------------------------------------*
  33. ;* Functions: *
  34. ;* VVPC::Buffer_Get_Pixel -- get the colour of a pixel at given coords *
  35. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  36. IDEAL
  37. P386
  38. MODEL USE32 FLAT
  39. INCLUDE ".\drawbuff.inc"
  40. INCLUDE ".\gbuffer.inc"
  41. CODESEG
  42. ;***************************************************************************
  43. ;* VVPC::GET_PIXEL -- Gets a pixel from the current view port *
  44. ;* *
  45. ;* INPUT: WORD the x pixel on the screen. *
  46. ;* WORD the y pixel on the screen. *
  47. ;* *
  48. ;* OUTPUT: UBYTE the pixel at the specified location *
  49. ;* *
  50. ;* WARNING: If pixel is to be placed outside of the viewport then *
  51. ;* this routine will abort. *
  52. ;* *
  53. ;* HISTORY: *
  54. ;* 06/07/1994 PWG : Created. *
  55. ;*=========================================================================*
  56. PROC Buffer_Get_Pixel C near
  57. USES ebx,ecx,edx,edi
  58. ARG this_object:DWORD ; this is a member function
  59. ARG x_pixel:DWORD ; x position of pixel to set
  60. ARG y_pixel:DWORD ; y position of pixel to set
  61. ;*===================================================================
  62. ; Get the viewport information and put bytes per row in ecx
  63. ;*===================================================================
  64. mov ebx,[this_object] ; get a pointer to viewport
  65. xor eax,eax
  66. mov edi,[(GraphicViewPort ebx).GVPOffset] ; get the correct offset
  67. mov ecx,[(GraphicViewPort ebx).GVPHeight] ; edx = height of viewport
  68. mov edx,[(GraphicViewPort ebx).GVPWidth] ; ecx = width of viewport
  69. ;*===================================================================
  70. ; Verify that the X pixel offset if legal
  71. ;*===================================================================
  72. mov eax,[x_pixel] ; find the x position
  73. cmp eax,edx ; is it out of bounds
  74. jae short ??exit ; if so then get out
  75. add edi,eax ; otherwise add in offset
  76. ;*===================================================================
  77. ; Verify that the Y pixel offset if legal
  78. ;*===================================================================
  79. mov eax,[y_pixel] ; get the y position
  80. cmp eax,ecx ; is it out of bounds
  81. jae ??exit ; if so then get out
  82. add edx,[(GraphicViewPort ebx).GVPXAdd] ; otherwise find bytes per row
  83. add edx,[(GraphicViewPort ebx).GVPPitch] ; otherwise find bytes per row
  84. mul edx ; offset = bytes per row * y
  85. add edi,eax ; add it into the offset
  86. ;*===================================================================
  87. ; Write the pixel to the screen
  88. ;*===================================================================
  89. xor eax,eax ; clear the word
  90. mov al,[edi] ; read in the pixel
  91. ??exit:
  92. ret
  93. ENDP Buffer_Get_Pixel
  94. END