C5_SCA_A.ASM 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. ; Catacomb Armageddon Source Code
  2. ; Copyright (C) 1993-2014 Flat Rock Software
  3. ;
  4. ; This program is free software; you can redistribute it and/or modify
  5. ; it under the terms of the GNU General Public License as published by
  6. ; the Free Software Foundation; either version 2 of the License, or
  7. ; (at your option) any later version.
  8. ;
  9. ; This program is distributed in the hope that it will be useful,
  10. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ; GNU General Public License for more details.
  13. ;
  14. ; You should have received a copy of the GNU General Public License along
  15. ; with this program; if not, write to the Free Software Foundation, Inc.,
  16. ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. IDEAL
  18. MODEL MEDIUM,C
  19. include "ID_ASM.EQU"
  20. ;===========================================================================
  21. ;
  22. ; SCALING GRAPHICS
  23. ;
  24. ;===========================================================================
  25. MACRO MAKELAB NUM
  26. lab&NUM:
  27. ENDM
  28. MACRO MAKEREF NUM
  29. dw OFFSET lab&NUM
  30. ENDM
  31. ;=========================================================================
  32. MAXSCALES equ 256
  33. DATASEG
  34. EXTRN screenseg:WORD
  35. EXTRN linewidth:WORD
  36. LABEL endtable WORD
  37. labcount = 0
  38. REPT MAXSCALES
  39. MAKEREF %labcount
  40. labcount = labcount + 1
  41. ENDM
  42. CODESEG
  43. ;==================================================
  44. ;
  45. ; void scaleline (int scale, unsigned picseg, unsigned maskseg,
  46. ; unsigned screen, unsigned width)
  47. ;
  48. ;==================================================
  49. PROC ScaleLine pixels:word, scaleptr:dword, picptr:dword, screen:word
  50. USES si,di
  51. PUBLIC ScaleLine
  52. ;
  53. ; modify doline procedure for proper width
  54. ;
  55. mov bx,[pixels]
  56. cmp bx,MAXSCALES
  57. jbe @@scaleok
  58. mov bx,MAXSCALES
  59. @@scaleok:
  60. shl bx,1
  61. mov bx,[endtable+bx]
  62. push [cs:bx] ;save the code that will be modified over
  63. mov [WORD cs:bx],0d18eh ;mov ss,cx
  64. push [cs:bx+2] ;save the code that will be modified over
  65. mov [WORD cs:bx+2],90c3h ;ret / nop
  66. push bx
  67. mov dx,[linewidth]
  68. mov di,[WORD screen]
  69. mov es,[screenseg]
  70. mov si,[WORD scaleptr]
  71. mov ds,[WORD scaleptr+2]
  72. mov bx,[WORD picptr]
  73. mov ax,[WORD picptr+2] ;will be moved into ss after call
  74. mov bp,bx
  75. cli
  76. call doline
  77. sti
  78. ;
  79. ; restore doline to regular state
  80. ;
  81. pop bx ;address of modified code
  82. pop [cs:bx+2]
  83. pop [cs:bx]
  84. mov ax,ss
  85. mov ds,ax
  86. ret
  87. ;================
  88. ;
  89. ; doline
  90. ;
  91. ; Big unwound scaling routine
  92. ;
  93. ; ds:si = scale table
  94. ; ss:bx = pic data
  95. ; es:di = screen location
  96. ;
  97. ;================
  98. doline:
  99. mov cx,ss
  100. mov ss,ax ;can't call a routine with ss used...
  101. labcount = 0
  102. REPT MAXSCALES
  103. MAKELAB %labcount
  104. labcount = labcount + 1
  105. lodsb ; get scaled pixel number
  106. xlat [ss:bx] ; look it up in the picture
  107. xchg [es:di],al ; load latches and write pixel to screen
  108. add di,dx ; down to next line
  109. ENDM
  110. mov ss,cx
  111. ret
  112. ENDP
  113. END