]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/hb/c3_sca_a.asm
[16_ca needs huge amounts of work and I should remember what needs to be done soon...
[16.git] / src / lib / hb / c3_sca_a.asm
diff --git a/src/lib/hb/c3_sca_a.asm b/src/lib/hb/c3_sca_a.asm
new file mode 100755 (executable)
index 0000000..58a8737
--- /dev/null
@@ -0,0 +1,153 @@
+; Catacomb 3-D Source Code\r
+; Copyright (C) 1993-2014 Flat Rock Software\r
+;\r
+; This program is free software; you can redistribute it and/or modify\r
+; it under the terms of the GNU General Public License as published by\r
+; the Free Software Foundation; either version 2 of the License, or\r
+; (at your option) any later version.\r
+;\r
+; This program is distributed in the hope that it will be useful,\r
+; but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+; GNU General Public License for more details.\r
+;\r
+; You should have received a copy of the GNU General Public License along\r
+; with this program; if not, write to the Free Software Foundation, Inc.,\r
+; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
+\r
+IDEAL\r
+MODEL  MEDIUM,C\r
+\r
+include "ID_ASM.EQU"\r
+\r
+;===========================================================================\r
+;\r
+;                    SCALING GRAPHICS\r
+;\r
+;===========================================================================\r
+\r
+\r
+\r
+MACRO  MAKELAB NUM\r
+\r
+lab&NUM:\r
+\r
+ENDM\r
+\r
+MACRO  MAKEREF NUM\r
+\r
+dw OFFSET lab&NUM\r
+\r
+ENDM\r
+\r
+\r
+;=========================================================================\r
+\r
+MAXSCALES equ 256\r
+\r
+       DATASEG\r
+\r
+EXTRN  screenseg:WORD\r
+EXTRN  linewidth:WORD\r
+\r
+LABEL endtable WORD\r
+labcount = 0\r
+REPT MAXSCALES\r
+MAKEREF %labcount\r
+labcount = labcount + 1\r
+ENDM\r
+\r
+\r
+       CODESEG\r
+\r
+;==================================================\r
+;\r
+; void scaleline (int scale, unsigned picseg, unsigned maskseg,\r
+;                 unsigned screen, unsigned width)\r
+;\r
+;==================================================\r
+\r
+PROC   ScaleLine pixels:word, scaleptr:dword, picptr:dword, screen:word\r
+USES   si,di\r
+PUBLIC ScaleLine\r
+\r
+;\r
+; modify doline procedure for proper width\r
+;\r
+       mov     bx,[pixels]\r
+       cmp     bx,MAXSCALES\r
+       jbe     @@scaleok\r
+       mov     bx,MAXSCALES\r
+@@scaleok:\r
+       shl     bx,1\r
+       mov     bx,[endtable+bx]\r
+       push    [cs:bx]                 ;save the code that will be modified over\r
+       mov     [WORD cs:bx],0d18eh     ;mov ss,cx\r
+       push    [cs:bx+2]               ;save the code that will be modified over\r
+       mov     [WORD cs:bx+2],90c3h    ;ret / nop\r
+       push    bx\r
+\r
+       mov     dx,[linewidth]\r
+\r
+       mov     di,[WORD screen]\r
+       mov     es,[screenseg]\r
+\r
+       mov     si,[WORD scaleptr]\r
+       mov     ds,[WORD scaleptr+2]\r
+\r
+       mov     bx,[WORD picptr]\r
+       mov     ax,[WORD picptr+2]      ;will be moved into ss after call\r
+\r
+       mov     bp,bx\r
+\r
+       cli\r
+       call    doline\r
+       sti\r
+;\r
+; restore doline to regular state\r
+;\r
+       pop     bx              ;address of modified code\r
+       pop     [cs:bx+2]\r
+       pop     [cs:bx]\r
+\r
+       mov     ax,ss\r
+       mov     ds,ax\r
+       ret\r
+\r
+;================\r
+;\r
+; doline\r
+;\r
+; Big unwound scaling routine\r
+;\r
+; ds:si = scale table\r
+; ss:bx = pic data\r
+; es:di = screen location\r
+;\r
+;================\r
+\r
+doline:\r
+\r
+       mov     cx,ss\r
+       mov     ss,ax           ;can't call a routine with ss used...\r
+\r
+labcount = 0\r
+\r
+REPT MAXSCALES\r
+\r
+MAKELAB %labcount\r
+labcount = labcount + 1\r
+\r
+       lodsb                   ; get scaled pixel number\r
+       xlat    [ss:bx]         ; look it up in the picture\r
+       xchg    [es:di],al      ; load latches and write pixel to screen\r
+       add     di,dx           ; down to next line\r
+\r
+ENDM\r
+\r
+       mov     ss,cx\r
+       ret\r
+\r
+ENDP\r
+\r
+END
\ No newline at end of file