SCALEA.ASM 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. ; THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  2. ; SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  3. ; END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  4. ; ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  5. ; IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  6. ; SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  7. ; FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  8. ; CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  9. ; AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  10. ; COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  11. .386
  12. option oldstructs
  13. .nolist
  14. include pstypes.inc
  15. include psmacros.inc
  16. .list
  17. assume cs:_TEXT, ds:_DATA
  18. _DATA segment dword public USE32 'DATA'
  19. rcsid db "$Id: scalea.asm 1.3 1995/12/21 14:30:02 matt Exp $"
  20. align 4
  21. public _scale_trans_color
  22. public _scale_error_term
  23. public _scale_initial_pixel_count
  24. public _scale_adj_up
  25. public _scale_adj_down
  26. public _scale_final_pixel_count
  27. public _scale_ydelta_minus_1
  28. public _scale_whole_step
  29. public _scale_source_ptr
  30. public _scale_dest_ptr
  31. _scale_trans_color db ?
  32. _scale_error_term dd ?
  33. _scale_initial_pixel_count dd ?
  34. _scale_adj_up dd ?
  35. _scale_adj_down dd ?
  36. _scale_final_pixel_count dd ?
  37. _scale_ydelta_minus_1 dd ?
  38. _scale_whole_step dd ?
  39. _scale_source_ptr dd ?
  40. _scale_dest_ptr dd ?
  41. _scale_cc_jump_spot dd ?
  42. _scale_slice_length_1 dd ?
  43. _scale_slice_length_2 dd ?
  44. _DATA ends
  45. _TEXT segment dword public USE32 'CODE'
  46. PUBLIC rls_stretch_scanline_asm_
  47. rls_stretch_scanline_asm_:
  48. cld
  49. pusha
  50. mov esi, _scale_source_ptr
  51. mov edi, _scale_dest_ptr
  52. mov edx, _scale_ydelta_minus_1
  53. mov ebx, _scale_whole_step
  54. mov ah, _scale_trans_color
  55. mov ebp, _scale_error_term
  56. mov ecx, _scale_initial_pixel_count
  57. lodsb
  58. cmp al, ah
  59. je first_pixel_transparent
  60. rep stosb
  61. jmp next_pixel
  62. first_pixel_transparent:
  63. add edi, ecx
  64. jmp next_pixel
  65. skip_this_pixel: add edi, ecx
  66. dec edx
  67. jz done
  68. next_pixel: lodsb ; get next source pixel
  69. mov ecx, ebx
  70. add ebp, _scale_adj_up
  71. jle no_inc_error_term
  72. inc ecx
  73. sub ebp, _scale_adj_down
  74. no_inc_error_term:
  75. cmp al, ah
  76. je skip_this_pixel
  77. rep stosb ; write source pixel to n locations
  78. dec edx
  79. jnz next_pixel
  80. done: lodsb
  81. cmp al, ah
  82. je exit_sub
  83. mov ecx, _scale_final_pixel_count
  84. rep stosb
  85. exit_sub:
  86. popa
  87. ret
  88. PUBLIC scale_do_cc_scanline_
  89. PUBLIC rls_do_cc_setup_asm_
  90. scale_do_cc_scanline_:
  91. cld
  92. pusha
  93. mov esi, _scale_source_ptr
  94. mov edi, _scale_dest_ptr
  95. mov ah, _scale_trans_color
  96. mov ebx, _scale_slice_length_1
  97. mov edx, _scale_slice_length_2
  98. mov ecx, _scale_initial_pixel_count
  99. ; Do the first texture pixel
  100. mov ecx, _scale_initial_pixel_count
  101. lodsb
  102. cmp al, ah
  103. je @f
  104. rep stosb
  105. @@: add edi, ecx
  106. mov ecx, _scale_cc_jump_spot
  107. jmp ecx
  108. ; This is the compiled code to do the middle pixels...
  109. scale_cc_start: mov al, [esi]
  110. scale_cc_changer: mov ecx, ebx ;<==== CODE CHANGES TO EBX OR EDX !!!!!!
  111. inc esi
  112. cmp al, ah
  113. je @f
  114. rep stosb
  115. @@: add edi, ecx
  116. scale_cc_end:
  117. REPT 319
  118. mov al, [esi]
  119. mov ecx, ebx ;<==== CODE CHANGES TO EBX OR EDX !!!!!!
  120. inc esi
  121. cmp al, ah
  122. je @f
  123. rep stosb
  124. @@: add edi, ecx
  125. ENDM
  126. last_cc_instruction:
  127. mov ecx, _scale_final_pixel_count
  128. lodsb
  129. cmp al, ah
  130. je last_one_transparent
  131. rep stosb
  132. last_one_transparent:
  133. popa
  134. ret
  135. rls_do_cc_setup_asm_:
  136. pusha
  137. mov ebx, _scale_whole_step
  138. mov _scale_slice_length_1, ebx
  139. inc ebx
  140. mov _scale_slice_length_2, ebx
  141. mov ebp, _scale_error_term
  142. mov edx, _scale_ydelta_minus_1
  143. mov ebx, offset scale_cc_end
  144. sub ebx, offset scale_cc_start ; ebx = distance to next changer inst.
  145. mov eax, _scale_ydelta_minus_1
  146. imul eax, ebx ; eax = sizeof 1 iteration * numiterations.
  147. mov edi, offset last_cc_instruction
  148. sub edi, eax ; edi = address of first iteration that we need
  149. ; to jump to
  150. mov _scale_cc_jump_spot, edi
  151. mov ecx, offset scale_cc_changer
  152. sub ecx, offset scale_cc_start ; ecx = distance from start to to next changer inst.
  153. add edi, ecx
  154. next_pixel1: add ebp, _scale_adj_up
  155. jle no_inc_error_term1
  156. ; Modify code in scale_do_cc_scanline_ to write 'edx' pixels
  157. mov al, byte ptr [edi]
  158. cmp al, 08bh
  159. jne BigError
  160. mov word ptr [edi], 0CA8Bh ; 0x8BCA = mov ecx, edx
  161. add edi, ebx
  162. sub ebp, _scale_adj_down
  163. dec edx
  164. jnz next_pixel1
  165. jmp done1
  166. no_inc_error_term1: ; Modify code in scale_do_cc_scanline_ to write 'ebx' pixels
  167. mov al, byte ptr [edi]
  168. cmp al, 08bh
  169. jne BigError
  170. mov word ptr [edi], 0CB8Bh ; 0x8BCB = mov ecx, ebx
  171. add edi, ebx
  172. dec edx
  173. jnz next_pixel1
  174. done1: popa
  175. ret
  176. BigError: int 3 ; Stop, buddy!!
  177. popa
  178. ret
  179. _TEXT ends
  180. end