--- /dev/null
+; Catacomb Apocalypse 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
+\r
+MODEL MEDIUM,C\r
+\r
+INCLUDE "ID_ASM.EQU"\r
+\r
+VIEWWIDTH = (40*8) ;33\r
+GC_INDEX = 03CEh\r
+\r
+DATASEG\r
+EVEN\r
+\r
+;=================== Tables filled in by DrawVWall ==========================\r
+\r
+;\r
+; wallheight has the height (scale number) of that collumn of scaled wall\r
+; it is pre bounded to 1-MAXSCALE (the actuial height on screen is 2*height)\r
+;\r
+wallheight dw VIEWWIDTH dup (?)\r
+\r
+;\r
+; wallwidth has the pixel width (1-7) of that collumn\r
+;\r
+wallwidth dw VIEWWIDTH dup (?)\r
+\r
+;\r
+; wallseg has the segment of the wall picture\r
+;\r
+wallseg dw VIEWWIDTH dup (?)\r
+\r
+;\r
+; wallofs has the offset of the wall picture\r
+;\r
+wallofs dw VIEWWIDTH dup (?)\r
+\r
+;============================================================================\r
+\r
+;\r
+; screenbyte is just position/8\r
+;\r
+LABEL screenbyte WORD\r
+pos = 0\r
+REPT VIEWWIDTH\r
+ dw pos/8\r
+pos = pos+1\r
+ENDM\r
+\r
+;\r
+; screenbit is (position&7)*16\r
+;\r
+LABEL screenbit WORD\r
+pos = 0\r
+REPT VIEWWIDTH\r
+ dw (pos AND 7)*16\r
+pos = pos+1\r
+ENDM\r
+\r
+;\r
+; Use offset: screenbit[]+pixwidth*2\r
+; acess from bitmasks-2+offset for one biased pixwidth\r
+; the low byte of bitmasks is for the first screen byte, the high byte\r
+; is the bitmask for the second screen byte (if non 0)\r
+;\r
+\r
+bitmasks dw 0080h,00c0h,00e0h,00f0h,00f8h,00fch,00feh,00ffh\r
+ dw 0040h,0060h,0070h,0078h,007ch,007eh,007fh,807fh\r
+ dw 0020h,0030h,0038h,003ch,003eh,003fh,803fh,0c03fh\r
+ dw 0010h,0018h,001ch,001eh,001fh,801fh,0c01fh,0e01fh\r
+ dw 0008h,000ch,000eh,000fh,800fh,0c00fh,0e00fh,0f00fh\r
+ dw 0004h,0006h,0007h,8007h,0c007h,0e007h,0f007h,0f807h\r
+ dw 0002h,0003h,8003h,0c003h,0e003h,0f003h,0f803h,0fc03h\r
+ dw 0001h,8001h,0c001h,0e001h,0f001h,0f801h,0fc01h,0fe01h\r
+\r
+\r
+;\r
+; wallscalecall is a far pointer to the start of a compiled scaler\r
+; The low word will never change, while the high word is set to\r
+; compscaledirectory[scale]\r
+;\r
+wallscalecall dd (65*6) ; offset of t_compscale->code[0]\r
+\r
+\r
+PUBLIC wallheight,wallwidth,wallseg,wallofs,screenbyte,screenbit\r
+PUBLIC bitmasks,wallscalecall\r
+\r
+\r
+EXTRN scaledirectory:WORD ; array of MAXSCALE segment pointers to\r
+ ; compiled scalers\r
+EXTRN screenseg:WORD ; basically just 0xa000\r
+EXTRN bufferofs:WORD ; offset of the current work screen\r
+EXTRN ylookup:WORD\r
+EXTRN screenpage:WORD\r
+\r
+CODESEG\r
+\r
+;============================================================================\r
+;\r
+; ScaleWalls\r
+;\r
+; AX AL is scratched in bit mask setting and scaling\r
+; BX table index\r
+; CX pixwidth*2\r
+; DX GC_INDEX\r
+; SI offset into wall data to scale from, allways 0,64,128,...4032\r
+; DI byte at top of screen that the collumn is contained in\r
+; BP x pixel * 2, index into VIEWWIDTH wide tables\r
+; DS segment of the wall data to texture map\r
+; ES screenseg\r
+; SS addressing DGROUP variables\r
+;\r
+;============================================================================\r
+\r
+PROC ScaleWalls\r
+PUBLIC ScaleWalls\r
+USES SI,DI,BP\r
+\r
+ xor bp,bp ; start at location 0 in the tables\r
+ mov dx,GC_INDEX+1\r
+ mov es,[screenseg]\r
+\r
+;\r
+; scale one collumn of data, possibly across two bytes\r
+;\r
+nextcollumn:\r
+\r
+ mov bx,[wallheight+bp] ; height of walls (1-MAXSCALE)\r
+ shl bx,1\r
+ mov ax,[ss:scaledirectory+bx] ; segment of the compiled scaler\r
+ mov [WORD PTR ss:wallscalecall+2],ax\r
+\r
+ mov cx,[wallwidth+bp]\r
+ or cx,cx\r
+ jnz okwidth\r
+ mov cx,2\r
+ jmp next\r
+\r
+okwidth:\r
+ shl cx,1\r
+ mov ds,[wallseg+bp]\r
+ mov si,[wallofs+bp]\r
+\r
+ mov di,[screenbyte+bp] ; byte at the top of the scaled collumn\r
+ add di,[ss:bufferofs] ; offset of current page flip\r
+ mov bx,[screenbit+bp] ; 0-7 << 4\r
+ add bx,cx\r
+ mov ax,[ss:bitmasks-2+bx]\r
+ out dx,al ; set bit mask register\r
+ call [DWORD PTR ss:wallscalecall] ; scale the line of pixels\r
+ or ah,ah ; is there anything in the second byte?\r
+ jnz secondbyte\r
+;\r
+; next\r
+;\r
+next:\r
+ add bp,cx\r
+ cmp bp,VIEWWIDTH*2\r
+ jb nextcollumn\r
+ jmp done\r
+\r
+;\r
+; draw a second byte for vertical strips that cross two bytes\r
+;\r
+secondbyte:\r
+ mov al,ah\r
+ inc di ; next byte over\r
+ out dx,al ; set bit mask register\r
+ call [DWORD PTR ss:wallscalecall] ; scale the line of pixels\r
+;\r
+; next\r
+;\r
+ add bp,cx\r
+ cmp bp,VIEWWIDTH*2\r
+ jb nextcollumn\r
+\r
+done:\r
+ mov ax,ss\r
+ mov ds,ax\r
+ ret\r
+\r
+ENDP\r
+\r
+;---------------------------------------------------------------------------\r
+;\r
+; RadarBlip()\r
+;\r
+; Displays a 'blip' (1 pixel wide X 2 pixel high) on the radar at\r
+; an (X,Y) relative to (RADAR_X,RADAR_Y) (defined below...)\r
+;\r
+;---------------------------------------------------------------------------\r
+\r
+PROC RadarBlip x:WORD, y:WORD, color:WORD\r
+USES SI,DI\r
+PUBLIC RadarBlip\r
+\r
+ mov ax,[screenseg]\r
+\r
+ mov es,ax\r
+ xor di,di\r
+\r
+ lea si,[ylookup]\r
+ add si,[y]\r
+ add si,[y]\r
+ add di,[si]\r
+\r
+ mov ax,[x]\r
+ shr ax,1\r
+ shr ax,1\r
+ shr ax,1\r
+ add di,ax\r
+\r
+ mov ax,[x]\r
+ and ax,7\r
+ mov cl,al\r
+ mov ah,080h\r
+ shr ah,cl\r
+ cli\r
+ mov al,GC_BITMASK\r
+ mov dx,GC_INDEX\r
+ out dx,ax\r
+ sti\r
+\r
+ mov ax,[color]\r
+ mov ah,[es:di] ; read into latches\r
+ mov [es:di],al ; write latches / color bit\r
+\r
+ ret\r
+\r
+ENDP\r
+\r
+END\r
+\r