OSDN Git Service

going on vacation >.<
[proj16/16.git] / src / lib / hb / asm / c6_asm.asm
1 ; Catacomb Apocalypse Source Code\r
2 ; Copyright (C) 1993-2014 Flat Rock Software\r
3 ;\r
4 ; This program is free software; you can redistribute it and/or modify\r
5 ; it under the terms of the GNU General Public License as published by\r
6 ; the Free Software Foundation; either version 2 of the License, or\r
7 ; (at your option) any later version.\r
8 ;\r
9 ; This program is distributed in the hope that it will be useful,\r
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12 ; GNU General Public License for more details.\r
13 ;\r
14 ; You should have received a copy of the GNU General Public License along\r
15 ; with this program; if not, write to the Free Software Foundation, Inc.,\r
16 ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
17 \r
18 IDEAL\r
19 \r
20 MODEL   MEDIUM,C\r
21 \r
22 INCLUDE "ID_ASM.EQU"\r
23 \r
24 VIEWWIDTH       =       (40*8)                  ;33\r
25 GC_INDEX        =       03CEh\r
26 \r
27 DATASEG\r
28 EVEN\r
29 \r
30 ;=================== Tables filled in by DrawVWall ==========================\r
31 \r
32 ;\r
33 ; wallheight has the height (scale number) of that collumn of scaled wall\r
34 ; it is pre bounded to 1-MAXSCALE (the actuial height on screen is 2*height)\r
35 ;\r
36 wallheight      dw      VIEWWIDTH dup (?)\r
37 \r
38 ;\r
39 ; wallwidth has the pixel width (1-7) of that collumn\r
40 ;\r
41 wallwidth       dw      VIEWWIDTH dup (?)\r
42 \r
43 ;\r
44 ; wallseg has the segment of the wall picture\r
45 ;\r
46 wallseg         dw      VIEWWIDTH dup (?)\r
47 \r
48 ;\r
49 ; wallofs has the offset of the wall picture\r
50 ;\r
51 wallofs         dw      VIEWWIDTH dup (?)\r
52 \r
53 ;============================================================================\r
54 \r
55 ;\r
56 ; screenbyte is just position/8\r
57 ;\r
58 LABEL           screenbyte      WORD\r
59 pos     =       0\r
60 REPT            VIEWWIDTH\r
61                         dw      pos/8\r
62 pos     =       pos+1\r
63 ENDM\r
64 \r
65 ;\r
66 ; screenbit is (position&7)*16\r
67 ;\r
68 LABEL           screenbit       WORD\r
69 pos     =       0\r
70 REPT            VIEWWIDTH\r
71                         dw      (pos AND 7)*16\r
72 pos     =       pos+1\r
73 ENDM\r
74 \r
75 ;\r
76 ; Use offset: screenbit[]+pixwidth*2\r
77 ; acess from bitmasks-2+offset for one biased pixwidth\r
78 ; the low byte of bitmasks is for the first screen byte, the high byte\r
79 ; is the bitmask for the second screen byte (if non 0)\r
80 ;\r
81 \r
82 bitmasks        dw      0080h,00c0h,00e0h,00f0h,00f8h,00fch,00feh,00ffh\r
83                         dw      0040h,0060h,0070h,0078h,007ch,007eh,007fh,807fh\r
84                         dw      0020h,0030h,0038h,003ch,003eh,003fh,803fh,0c03fh\r
85                         dw      0010h,0018h,001ch,001eh,001fh,801fh,0c01fh,0e01fh\r
86                         dw      0008h,000ch,000eh,000fh,800fh,0c00fh,0e00fh,0f00fh\r
87                         dw      0004h,0006h,0007h,8007h,0c007h,0e007h,0f007h,0f807h\r
88                         dw      0002h,0003h,8003h,0c003h,0e003h,0f003h,0f803h,0fc03h\r
89                         dw      0001h,8001h,0c001h,0e001h,0f001h,0f801h,0fc01h,0fe01h\r
90 \r
91 \r
92 ;\r
93 ; wallscalecall is a far pointer to the start of a compiled scaler\r
94 ; The low word will never change, while the high word is set to\r
95 ; compscaledirectory[scale]\r
96 ;\r
97 wallscalecall   dd      (65*6)                  ; offset of t_compscale->code[0]\r
98 \r
99 \r
100 PUBLIC  wallheight,wallwidth,wallseg,wallofs,screenbyte,screenbit\r
101 PUBLIC  bitmasks,wallscalecall\r
102 \r
103 \r
104 EXTRN   scaledirectory:WORD                     ; array of MAXSCALE segment pointers to\r
105                                                                         ; compiled scalers\r
106 EXTRN   screenseg:WORD                          ; basically just 0xa000\r
107 EXTRN   bufferofs:WORD                          ; offset of the current work screen\r
108 EXTRN ylookup:WORD\r
109 EXTRN screenpage:WORD\r
110 \r
111 CODESEG\r
112 \r
113 ;============================================================================\r
114 ;\r
115 ; ScaleWalls\r
116 ;\r
117 ; AX    AL is scratched in bit mask setting and scaling\r
118 ; BX    table index\r
119 ; CX    pixwidth*2\r
120 ; DX    GC_INDEX\r
121 ; SI    offset into wall data to scale from, allways 0,64,128,...4032\r
122 ; DI    byte at top of screen that the collumn is contained in\r
123 ; BP    x pixel * 2, index into VIEWWIDTH wide tables\r
124 ; DS    segment of the wall data to texture map\r
125 ; ES    screenseg\r
126 ; SS    addressing DGROUP variables\r
127 ;\r
128 ;============================================================================\r
129 \r
130 PROC    ScaleWalls\r
131 PUBLIC  ScaleWalls\r
132 USES    SI,DI,BP\r
133 \r
134         xor     bp,bp                                           ; start at location 0 in the tables\r
135         mov     dx,GC_INDEX+1\r
136         mov     es,[screenseg]\r
137 \r
138 ;\r
139 ; scale one collumn of data, possibly across two bytes\r
140 ;\r
141 nextcollumn:\r
142 \r
143         mov     bx,[wallheight+bp]                      ; height of walls (1-MAXSCALE)\r
144         shl     bx,1\r
145         mov     ax,[ss:scaledirectory+bx]       ; segment of the compiled scaler\r
146         mov [WORD PTR ss:wallscalecall+2],ax\r
147 \r
148         mov     cx,[wallwidth+bp]\r
149         or      cx,cx\r
150         jnz     okwidth\r
151         mov     cx,2\r
152         jmp     next\r
153 \r
154 okwidth:\r
155         shl     cx,1\r
156         mov     ds,[wallseg+bp]\r
157         mov     si,[wallofs+bp]\r
158 \r
159         mov     di,[screenbyte+bp]                      ; byte at the top of the scaled collumn\r
160         add     di,[ss:bufferofs]                       ; offset of current page flip\r
161         mov     bx,[screenbit+bp]                       ; 0-7 << 4\r
162         add     bx,cx\r
163         mov     ax,[ss:bitmasks-2+bx]\r
164         out     dx,al                                           ; set bit mask register\r
165         call [DWORD PTR ss:wallscalecall]               ; scale the line of pixels\r
166         or      ah,ah                                           ; is there anything in the second byte?\r
167         jnz     secondbyte\r
168 ;\r
169 ; next\r
170 ;\r
171 next:\r
172         add     bp,cx\r
173         cmp     bp,VIEWWIDTH*2\r
174         jb      nextcollumn\r
175         jmp     done\r
176 \r
177 ;\r
178 ; draw a second byte for vertical strips that cross two bytes\r
179 ;\r
180 secondbyte:\r
181         mov     al,ah\r
182         inc     di                                                              ; next byte over\r
183         out     dx,al                                                   ; set bit mask register\r
184         call [DWORD PTR ss:wallscalecall]       ; scale the line of pixels\r
185 ;\r
186 ; next\r
187 ;\r
188         add     bp,cx\r
189         cmp     bp,VIEWWIDTH*2\r
190         jb      nextcollumn\r
191 \r
192 done:\r
193         mov     ax,ss\r
194         mov     ds,ax\r
195         ret\r
196 \r
197 ENDP\r
198 \r
199 ;---------------------------------------------------------------------------\r
200 ;\r
201 ; RadarBlip()\r
202 ;\r
203 ; Displays a 'blip' (1 pixel wide X 2 pixel high) on the radar at\r
204 ; an (X,Y) relative to (RADAR_X,RADAR_Y) (defined below...)\r
205 ;\r
206 ;---------------------------------------------------------------------------\r
207 \r
208 PROC    RadarBlip x:WORD, y:WORD, color:WORD\r
209 USES    SI,DI\r
210 PUBLIC  RadarBlip\r
211 \r
212         mov     ax,[screenseg]\r
213 \r
214         mov     es,ax\r
215         xor     di,di\r
216 \r
217         lea     si,[ylookup]\r
218         add     si,[y]\r
219         add     si,[y]\r
220         add     di,[si]\r
221 \r
222         mov     ax,[x]\r
223         shr     ax,1\r
224         shr     ax,1\r
225         shr     ax,1\r
226         add     di,ax\r
227 \r
228         mov     ax,[x]\r
229         and     ax,7\r
230         mov     cl,al\r
231         mov     ah,080h\r
232         shr     ah,cl\r
233         cli\r
234         mov     al,GC_BITMASK\r
235         mov     dx,GC_INDEX\r
236         out     dx,ax\r
237         sti\r
238 \r
239         mov     ax,[color]\r
240         mov     ah,[es:di]                                              ; read into latches\r
241         mov     [es:di],al                                              ; write latches / color bit\r
242 \r
243         ret\r
244 \r
245 ENDP\r
246 \r
247 END\r
248 \r