VPUTPIX.ASM 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 : Clear the Full Mcga Screen *
  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. ;* GVPC::Put_Pixel -- Puts a pixel on a graphic viewport *
  35. ;* VIVPC::Put_Pixel -- Puts a pixel on a virtual viewport *
  36. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  37. IDEAL
  38. P386
  39. MODEL USE32 FLAT
  40. LOCALS ??
  41. INCLUDE "svgaprim.inc"
  42. INCLUDE "gbuffer.inc"
  43. CODESEG
  44. ;***************************************************************************
  45. ;* VIVPC::PUT_PIXEL -- Puts a pixel on a video viewport *
  46. ;* *
  47. ;* INPUT: WORD the x position for the pixel relative to the upper *
  48. ;* left corner of the viewport *
  49. ;* WORD the y pos for the pixel relative to the upper left *
  50. ;* corner of the viewport *
  51. ;* UBYTE the color of the pixel to write *
  52. ;* *
  53. ;* OUTPUT: none *
  54. ;* *
  55. ;* WARNING: If pixel is to be placed outside of the viewport then *
  56. ;* this routine will abort. *
  57. ;* *
  58. ;* HISTORY: *
  59. ;* 06/08/1994 PWG : Created. *
  60. ;*=========================================================================*
  61. PROC Vesa_Put_Pixel C near
  62. USES eax,ebx,ecx,edx,edi,esi
  63. ARG this:DWORD ; this is a member function
  64. ARG x_pixel:DWORD ; x position of pixel to set
  65. ARG y_pixel:DWORD ; y position of pixel to set
  66. ARG color:BYTE ; what color should we clear to
  67. ;*===================================================================
  68. ; Get the viewport information and put bytes per row in ecx
  69. ;*===================================================================
  70. mov ebx,[this] ; get a pointer to viewport
  71. mov edi,[(VideoViewPort ebx).VIVPOffset] ; get the correct offset
  72. mov ecx,[(VideoViewPort ebx).VIVPHeight] ; edx = height of viewport
  73. mov edx,[(VideoViewPort ebx).VIVPWidth] ; ecx = width of viewport
  74. ;*===================================================================
  75. ; Verify that the X pixel offset if legal
  76. ;*===================================================================
  77. mov eax,[x_pixel] ; find the x position
  78. cmp eax,edx ; is it out of bounds
  79. jae short ??exit ; if so then get out
  80. add edi,eax ; otherwise add in offset
  81. ;*===================================================================
  82. ; Verify that the Y pixel offset if legal
  83. ;*===================================================================
  84. mov eax,[y_pixel] ; get the y position
  85. cmp eax,ecx ; is it out of bounds
  86. jae ??exit ; if so then get out
  87. add edx,[(VideoViewPort ebx).VIVPXAdd] ; otherwise find bytes per row
  88. mul edx ; offset = bytes per row * y
  89. add edi,eax ; add it into the offset
  90. ;*===================================================================
  91. ;* Figure out what bank we are in and set it, then adjust the
  92. ;* offset.
  93. ;*===================================================================
  94. call Vesa_Asm_Set_Win
  95. ;*===================================================================
  96. ; Write the pixel to the screen
  97. ;*===================================================================
  98. mov al,[color] ; read in color value
  99. mov [edi],al ; write it to the screen
  100. ??exit:
  101. ret
  102. ENDP Vesa_Put_Pixel
  103. END