INTERPAL.ASM 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 I N C **
  20. ;**********************************************************************************************
  21. ;* *
  22. ;* Project Name : VQA Viewer *
  23. ;* *
  24. ;* File Name : INTERPAL.ASM *
  25. ;* *
  26. ;* Programmer : Steve Tall *
  27. ;* *
  28. ;* Start Date : December 15th, 1995 *
  29. ;* *
  30. ;* Last Update : December 22nd, 1995 [ST] *
  31. ;* *
  32. ;*--------------------------------------------------------------------------------------------*
  33. ;* Functions: *
  34. ;* *
  35. ;* Asm_Interpolate -- interpolate a 320x200 buffer to a 640x400 screen *
  36. ;* *
  37. ;* *
  38. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  39. IDEAL
  40. P386
  41. MODEL USE32 FLAT
  42. segment mycode page public use32 'code' ; Need stricter segment alignment
  43. global C Asm_Interpolate:near
  44. global C Palette_Interpolation_Table:byte
  45. ;*********************************************************************************************
  46. ;* Asm_Interpolate -- interpolate a 320x200 buffer to a 640x400 screen *
  47. ;* *
  48. ;* INPUT: ptr to source buffer (320x200 image) *
  49. ;* ptr to dest buffer (640x400) *
  50. ;* height of source buffer *
  51. ;* width f source buffer *
  52. ;* width of dest buffer *
  53. ;* *
  54. ;* *
  55. ;* OUTPUT: none *
  56. ;* *
  57. ;* Warnings: *
  58. ;* *
  59. ;* HISTORY: *
  60. ;* 12/15/95 ST : Created. *
  61. ;*===========================================================================================*
  62. PROC Asm_Interpolate C near
  63. ARG src_ptr:dword
  64. ARG dest_ptr:dword
  65. ARG source_height:dword
  66. ARG source_width:dword
  67. ARG dest_width:dword
  68. LOCAL old_dest:dword
  69. LOCAL width_counter:dword
  70. pushad
  71. mov eax,[dest_ptr]
  72. mov [old_dest],eax
  73. mov esi,[src_ptr]
  74. ??each_line_loop:
  75. mov [width_counter],0
  76. mov ecx,[source_width]
  77. sub ecx,2
  78. shr ecx,1
  79. mov edi,[old_dest]
  80. jmp ??interpolate_loop
  81. align 32
  82. ;
  83. ; convert 2 pixels of source into 4 pixels of destination
  84. ; so we can write to video memory with dwords
  85. ;
  86. ??interpolate_loop:
  87. mov eax,[esi]
  88. lea esi,[esi+2]
  89. mov edx,eax
  90. mov ebx,eax
  91. and edx,65535
  92. ror ebx,8
  93. mov bl,[edx+Palette_Interpolation_Table]
  94. mov bh,ah
  95. and eax,000ffff00h
  96. ror ebx,8
  97. ;1st 3 pixels now in ebx
  98. shr eax,8
  99. mov bh,[eax+Palette_Interpolation_Table]
  100. ror ebx,16
  101. mov [edi],ebx
  102. add edi,4
  103. dec ecx
  104. jnz ??interpolate_loop
  105. ; do the last three pixels and a blank on the end of a row
  106. xor eax,eax
  107. mov ax,[esi]
  108. mov [edi],al
  109. inc edi
  110. lea esi,[esi+2]
  111. mov al,[eax+Palette_Interpolation_Table]
  112. mov [edi],al
  113. inc edi
  114. mov [edi],ah
  115. inc edi
  116. mov [byte edi],0
  117. mov edi,[dest_width]
  118. add [old_dest],edi
  119. dec [source_height]
  120. jnz ??each_line_loop
  121. popad
  122. ret
  123. endp Asm_Interpolate
  124. ends mycode
  125. end