surf16.s 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. //
  16. // surf16.s
  17. // x86 assembly-language 16 bpp surface block drawing code.
  18. //
  19. #include "asm_i386.h"
  20. #include "quakeasm.h"
  21. #include "asm_draw.h"
  22. #if id386
  23. //----------------------------------------------------------------------
  24. // Surface block drawer
  25. //----------------------------------------------------------------------
  26. .data
  27. k: .long 0
  28. loopentry: .long 0
  29. .align 4
  30. blockjumptable16:
  31. .long LEnter2_16
  32. .long LEnter4_16
  33. .long 0, LEnter8_16
  34. .long 0, 0, 0, LEnter16_16
  35. .text
  36. .align 4
  37. .globl C(R_Surf16Start)
  38. C(R_Surf16Start):
  39. .align 4
  40. .globl C(R_DrawSurfaceBlock16)
  41. C(R_DrawSurfaceBlock16):
  42. pushl %ebp // preserve caller's stack frame
  43. pushl %edi
  44. pushl %esi // preserve register variables
  45. pushl %ebx
  46. movl C(blocksize),%eax
  47. movl C(prowdestbase),%edi
  48. movl C(pbasesource),%esi
  49. movl C(sourcesstep),%ebx
  50. movl blockjumptable16-4(,%eax,2),%ecx
  51. movl %eax,k
  52. movl %ecx,loopentry
  53. movl C(lightleft),%edx
  54. movl C(lightright),%ebp
  55. Lblockloop16:
  56. subl %edx,%ebp
  57. movb C(blockdivshift),%cl
  58. sarl %cl,%ebp
  59. jns Lp1_16
  60. testl C(blockdivmask),%ebp
  61. jz Lp1_16
  62. incl %ebp
  63. Lp1_16:
  64. subl %eax,%eax
  65. subl %ecx,%ecx // high words must be 0 in loop for addressing
  66. jmp *loopentry
  67. .align 4
  68. #include "block16.h"
  69. movl C(pbasesource),%esi
  70. movl C(lightleft),%edx
  71. movl C(lightright),%ebp
  72. movl C(sourcetstep),%eax
  73. movl C(lightrightstep),%ecx
  74. movl C(prowdestbase),%edi
  75. addl %eax,%esi
  76. addl %ecx,%ebp
  77. movl C(lightleftstep),%eax
  78. movl C(surfrowbytes),%ecx
  79. addl %eax,%edx
  80. addl %ecx,%edi
  81. movl %esi,C(pbasesource)
  82. movl %ebp,C(lightright)
  83. movl k,%eax
  84. movl %edx,C(lightleft)
  85. decl %eax
  86. movl %edi,C(prowdestbase)
  87. movl %eax,k
  88. jnz Lblockloop16
  89. popl %ebx // restore register variables
  90. popl %esi
  91. popl %edi
  92. popl %ebp // restore the caller's stack frame
  93. ret
  94. .globl C(R_Surf16End)
  95. C(R_Surf16End):
  96. //----------------------------------------------------------------------
  97. // Code patching routines
  98. //----------------------------------------------------------------------
  99. .data
  100. .align 4
  101. LPatchTable16:
  102. .long LBPatch0-4
  103. .long LBPatch1-4
  104. .long LBPatch2-4
  105. .long LBPatch3-4
  106. .long LBPatch4-4
  107. .long LBPatch5-4
  108. .long LBPatch6-4
  109. .long LBPatch7-4
  110. .long LBPatch8-4
  111. .long LBPatch9-4
  112. .long LBPatch10-4
  113. .long LBPatch11-4
  114. .long LBPatch12-4
  115. .long LBPatch13-4
  116. .long LBPatch14-4
  117. .long LBPatch15-4
  118. .text
  119. .align 4
  120. .globl C(R_Surf16Patch)
  121. C(R_Surf16Patch):
  122. pushl %ebx
  123. movl C(colormap),%eax
  124. movl $LPatchTable16,%ebx
  125. movl $16,%ecx
  126. LPatchLoop16:
  127. movl (%ebx),%edx
  128. addl $4,%ebx
  129. movl %eax,(%edx)
  130. decl %ecx
  131. jnz LPatchLoop16
  132. popl %ebx
  133. ret
  134. #endif // id386