PUTPIX.ASM 5.0 KB

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