SCALEA.ASM 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  11. ;
  12. ; $Source: f:/miner/source/2d/rcs/scalea.asm $
  13. ; $Revision: 1.2 $
  14. ; $Author: john $
  15. ; $Date: 1994/01/12 18:02:52 $
  16. ;
  17. ; Asm inner loop for scaler.
  18. ;
  19. ; $Log: scalea.asm $
  20. ; Revision 1.2 1994/01/12 18:02:52 john
  21. ; Asm code for the scaler... first iteration here
  22. ; has compiled code that works!!
  23. ;
  24. ; Revision 1.1 1994/01/12 12:20:11 john
  25. ; Initial revision
  26. ;
  27. ;
  28. .386
  29. option oldstructs
  30. .nolist
  31. include types.inc
  32. include psmacros.inc
  33. .list
  34. assume cs:_TEXT, ds:_DATA
  35. _DATA segment dword public USE32 'DATA'
  36. rcsid db "$Id: scalea.asm 1.2 1994/01/12 18:02:52 john Exp $"
  37. align 4
  38. public _scale_trans_color
  39. public _scale_error_term
  40. public _scale_initial_pixel_count
  41. public _scale_adj_up
  42. public _scale_adj_down
  43. public _scale_final_pixel_count
  44. public _scale_ydelta_minus_1
  45. public _scale_whole_step
  46. public _scale_source_ptr
  47. public _scale_dest_ptr
  48. _scale_trans_color db ?
  49. _scale_error_term dd ?
  50. _scale_initial_pixel_count dd ?
  51. _scale_adj_up dd ?
  52. _scale_adj_down dd ?
  53. _scale_final_pixel_count dd ?
  54. _scale_ydelta_minus_1 dd ?
  55. _scale_whole_step dd ?
  56. _scale_source_ptr dd ?
  57. _scale_dest_ptr dd ?
  58. _scale_cc_jump_spot dd ?
  59. _scale_slice_length_1 dd ?
  60. _scale_slice_length_2 dd ?
  61. _DATA ends
  62. _TEXT segment dword public USE32 'CODE'
  63. PUBLIC rls_stretch_scanline_asm_
  64. rls_stretch_scanline_asm_:
  65. cld
  66. pusha
  67. mov esi, _scale_source_ptr
  68. mov edi, _scale_dest_ptr
  69. mov edx, _scale_ydelta_minus_1
  70. mov ebx, _scale_whole_step
  71. mov ah, _scale_trans_color
  72. mov ebp, _scale_error_term
  73. mov ecx, _scale_initial_pixel_count
  74. lodsb
  75. cmp al, ah
  76. je first_pixel_transparent
  77. rep stosb
  78. jmp next_pixel
  79. first_pixel_transparent:
  80. add edi, ecx
  81. jmp next_pixel
  82. skip_this_pixel: add edi, ecx
  83. dec edx
  84. jz done
  85. next_pixel: lodsb ; get next source pixel
  86. mov ecx, ebx
  87. add ebp, _scale_adj_up
  88. jle no_inc_error_term
  89. inc ecx
  90. sub ebp, _scale_adj_down
  91. no_inc_error_term:
  92. cmp al, ah
  93. je skip_this_pixel
  94. rep stosb ; write source pixel to n locations
  95. dec edx
  96. jnz next_pixel
  97. done: lodsb
  98. cmp al, ah
  99. je exit_sub
  100. mov ecx, _scale_final_pixel_count
  101. rep stosb
  102. exit_sub:
  103. popa
  104. ret
  105. PUBLIC scale_do_cc_scanline_
  106. PUBLIC rls_do_cc_setup_asm_
  107. scale_do_cc_scanline_:
  108. cld
  109. pusha
  110. mov esi, _scale_source_ptr
  111. mov edi, _scale_dest_ptr
  112. mov ah, _scale_trans_color
  113. mov ebx, _scale_slice_length_1
  114. mov edx, _scale_slice_length_2
  115. mov ecx, _scale_initial_pixel_count
  116. ; Do the first texture pixel
  117. mov ecx, _scale_initial_pixel_count
  118. lodsb
  119. cmp al, ah
  120. je @f
  121. rep stosb
  122. @@: add edi, ecx
  123. mov ecx, _scale_cc_jump_spot
  124. jmp ecx
  125. ; This is the compiled code to do the middle pixels...
  126. scale_cc_start: mov al, [esi]
  127. scale_cc_changer: mov ecx, ebx ;<==== CODE CHANGES TO EBX OR EDX !!!!!!
  128. inc esi
  129. cmp al, ah
  130. je @f
  131. rep stosb
  132. @@: add edi, ecx
  133. scale_cc_end:
  134. REPT 319
  135. mov al, [esi]
  136. mov ecx, ebx ;<==== CODE CHANGES TO EBX OR EDX !!!!!!
  137. inc esi
  138. cmp al, ah
  139. je @f
  140. rep stosb
  141. @@: add edi, ecx
  142. ENDM
  143. last_cc_instruction:
  144. mov ecx, _scale_final_pixel_count
  145. lodsb
  146. cmp al, ah
  147. je last_one_transparent
  148. rep stosb
  149. last_one_transparent:
  150. popa
  151. ret
  152. rls_do_cc_setup_asm_:
  153. pusha
  154. mov ebx, _scale_whole_step
  155. mov _scale_slice_length_1, ebx
  156. inc ebx
  157. mov _scale_slice_length_2, ebx
  158. mov ebp, _scale_error_term
  159. mov edx, _scale_ydelta_minus_1
  160. mov ebx, offset scale_cc_end
  161. sub ebx, offset scale_cc_start ; ebx = distance to next changer inst.
  162. mov eax, _scale_ydelta_minus_1
  163. imul eax, ebx ; eax = sizeof 1 iteration * numiterations.
  164. mov edi, offset last_cc_instruction
  165. sub edi, eax ; edi = address of first iteration that we need
  166. ; to jump to
  167. mov _scale_cc_jump_spot, edi
  168. mov ecx, offset scale_cc_changer
  169. sub ecx, offset scale_cc_start ; ecx = distance from start to to next changer inst.
  170. add edi, ecx
  171. next_pixel1: add ebp, _scale_adj_up
  172. jle no_inc_error_term1
  173. ; Modify code in scale_do_cc_scanline_ to write 'edx' pixels
  174. mov al, byte ptr [edi]
  175. cmp al, 08bh
  176. jne BigError
  177. mov word ptr [edi], 0CA8Bh ; 0x8BCA = mov ecx, edx
  178. add edi, ebx
  179. sub ebp, _scale_adj_down
  180. dec edx
  181. jnz next_pixel1
  182. jmp done1
  183. no_inc_error_term1: ; Modify code in scale_do_cc_scanline_ to write 'ebx' pixels
  184. mov al, byte ptr [edi]
  185. cmp al, 08bh
  186. jne BigError
  187. mov word ptr [edi], 0CB8Bh ; 0x8BCB = mov ecx, ebx
  188. add edi, ebx
  189. dec edx
  190. jnz next_pixel1
  191. done1: popa
  192. ret
  193. BigError: int 3 ; Stop, buddy!!
  194. popa
  195. ret
  196. _TEXT ends
  197. end
  198.