1 ;====================================================
5 ;====================================================
11 extrn videomode:WORD,xmshandle:WORD,XMSlookup:WORD
12 extrn tilenum:WORD,lasticon:WORD,firsticon:WORD
13 extrn CGAlookup:WORD,EGA1lookup:WORD,EGA2lookup:WORD,VGAlookup:WORD
23 CombTable dw CombineCGA,CombineEGA,CombineEGA,CombineVGA
24 DrawTable dw DrawTCGA,DrawTEGA1,DrawTEGA2,DrawTVGA
25 OverTable dw OverlayCGA,OverlayEGA,OverlayEGA,OverlayVGA
46 vmsize dw 128,512,2048
62 Csparse dw csp8,csp16,csp32
63 Esparse dw esp8,esp16,esp32
64 Vsparse dw vsp8,vsp16,vsp32
105 vsp16 db 16 dup(0ffh)
109 vsp32 db 32 dup(0ffh)
116 ;====================================================
118 ; Combine tiles together (background,foreground,icons)
120 ;====================================================
123 ARG tileb:WORD,tilef:WORD,tilei:WORD,tsize:WORD
136 mov [shandle],ax ;set XMS handle
140 mov ax,[CombTable+si]
145 LABEL CombineCGA PROC
150 mov ax,[csize+bx-2] ;get length of block to move
156 ; Handle the background tiles first!
159 cmp ax,8000h ;solid color?
168 mov al,[cgacolors+bx]
177 mov es,[XMSlookup] ;(LONG SEG *)
179 mov [WORD PTR soff],ax
181 mov [WORD PTR soff+2],ax
182 cmp ax,-1 ;SPARSE TILE?
185 mov ax,OFFSET tdata ;(quickie modification since "doff"
186 mov [WORD doff],ax ; should always point to "tdata1")
189 call [DWORD XMSdriver] ;move tile into tdata1
191 mov [WORD doff],ax ;ahhh....back to normal
195 ; Copy sparse tile to tdata
200 mov si,[Csparse+bx-2]
203 shr cx,1 ;for WORD copy
209 ; Handle foreground tiles
214 je @@c3 ;any masked tile?
219 mov [WORD PTR soff],ax
221 mov [WORD PTR soff+2],ax
222 cmp ax,-1 ;SPARSE MASKED TILE?
226 mov [blen],ax ;set masked tile length for XMS copy
229 call [DWORD XMSdriver] ;move tile into tdata1
231 ; now we have the masked tile in "tdata1".
232 ; time to mask it onto "tdata"
235 add si,[masklen] ;SI = masked tile's tiledata
236 mov di,OFFSET tdata ;DI = tile in "tdata"
239 mov bx,OFFSET tdata1 ;BX = mask
243 mov al,[bx] ;get mask byte
244 and [di],al ;and tdata with it
245 lodsb ;get tilem byte
246 or [di],al ;OR it onto tdata
253 ; Handle icons (foreground tiles)
258 ja @@cexit ;any icons?
265 mov [WORD PTR soff],ax
267 mov [WORD PTR soff+2],ax
270 mov [blen],ax ;set masked tile length for XMS copy
273 call [DWORD XMSdriver] ;move tile into tdata1
275 ; now we have the masked tile in "tdata1".
276 ; time to mask it onto "tdata"
279 add si,[masklen] ;SI = masked tile's tiledata
280 mov di,OFFSET tdata ;DI = tile in "tdata"
283 mov bx,OFFSET tdata1 ;BX = mask
287 mov al,[bx] ;get mask byte
288 and [di],al ;and tdata with it
289 lodsb ;get tilem byte
290 or [di],al ;OR it onto tdata
304 LABEL CombineEGA PROC
308 mov ax,[esize+bx-2] ;get length of block to move
314 ; Handle the background tiles first!
317 cmp ax,8000h ;solid color?
326 mov cx,[blen] ;plane 0
332 mov ax,[egacolors+bx]
335 mov cx,[blen] ;plane 1
341 mov ax,[egacolors+bx]
344 mov cx,[blen] ;plane 2
350 mov ax,[egacolors+bx]
353 mov cx,[blen] ;plane 3
359 mov ax,[egacolors+bx]
366 mov es,[XMSlookup] ;(LONG SEG *)
368 mov [WORD PTR soff],ax
370 mov [WORD PTR soff+2],ax
371 cmp ax,-1 ;SPARSE TILE?
374 mov ax,OFFSET tdata ;(quickie modification since "doff"
375 mov [WORD doff],ax ; should always point to "tdata1")
378 call [DWORD XMSdriver] ;move tile into tdata1
380 mov [WORD doff],ax ;ahhh....back to normal
384 ; Copy sparse tile to tdata
389 mov si,[Esparse+bx-2]
392 shr cx,1 ;for WORD copy
398 ; Handle foreground tiles
403 je @@e3 ;any masked tile?
408 mov [WORD PTR soff],ax
410 mov [WORD PTR soff+2],ax
411 cmp ax,-1 ;SPARSE MASKED TILE?
415 mov [blen],ax ;set masked tile length for XMS copy
418 call [DWORD XMSdriver] ;move tile into tdata1
420 ; now we have the masked tile in "tdata1".
421 ; time to mask it onto "tdata"
424 add si,[masklen] ;SI = masked tile's tiledata
425 mov di,OFFSET tdata ;DI = tile in "tdata"
429 mov bx,OFFSET tdata1 ;BX = mask
433 mov al,[bx] ;get mask byte
434 and [di],al ;and tdata with it
435 lodsb ;get tilem byte
436 or [di],al ;OR it onto tdata
443 jnz @@e2a0 ;do all 4 planes!
445 ; Handle icons (foreground tiles)
450 ja @@eexit ;any icons?
457 mov [WORD PTR soff],ax
459 mov [WORD PTR soff+2],ax
462 mov [blen],ax ;set masked tile length for XMS copy
465 call [DWORD XMSdriver] ;move tile into tdata1
467 ; now we have the masked tile in "tdata1".
468 ; time to mask it onto "tdata"
471 add si,[masklen] ;SI = masked tile's tiledata
472 mov di,OFFSET tdata ;DI = tile in "tdata"
476 mov bx,OFFSET tdata1 ;BX = mask
480 mov al,[bx] ;get mask byte
481 and [di],al ;and tdata with it
482 lodsb ;get tilem byte
483 or [di],al ;OR it onto tdata
490 jnz @@e3a0 ;do all 4 planes!
499 LABEL CombineVGA PROC
504 mov ax,[vsize+bx-2] ;get length of block to move
510 ; Handle the background tiles first!
513 cmp ax,8000h ;solid color?
553 mov es,[XMSlookup] ;(LONG SEG *)
555 mov [WORD PTR soff],ax
557 mov [WORD PTR soff+2],ax
558 cmp ax,-1 ;SPARSE TILE?
561 mov ax,OFFSET tdata ;(quickie modification since "doff"
562 mov [WORD doff],ax ; should always point to "tdata1")
565 call [DWORD XMSdriver] ;move tile into tdata1
567 mov [WORD doff],ax ;ahhh....back to normal
571 ; Copy sparse tile to tdata
576 mov si,[Vsparse+bx-2]
579 shr cx,1 ;for WORD copy
585 ; Handle foreground tiles
590 je @@v3 ;any masked tile?
595 mov [WORD PTR soff],ax
597 mov [WORD PTR soff+2],ax
598 cmp ax,-1 ;SPARSE MASKED TILE?
602 mov [blen],ax ;set masked tile length for XMS copy
605 call [DWORD XMSdriver] ;move tile into tdata1
607 ; now we have the masked tile in "tdata1".
608 ; time to mask it onto "tdata"
611 add si,[masklen] ;SI = masked tile's tiledata
612 mov di,OFFSET tdata ;DI = tile in "tdata"
615 mov bx,OFFSET tdata1 ;BX = mask
619 mov al,[bx] ;get mask byte
620 and [di],al ;and tdata with it
621 lodsb ;get tilem byte
622 or [di],al ;OR it onto tdata
629 ; Handle icons (foreground tiles)
634 ja @@vexit ;any icons?
641 mov [WORD PTR soff],ax
643 mov [WORD PTR soff+2],ax
646 mov [blen],ax ;set masked tile length for XMS copy
649 call [DWORD XMSdriver] ;move tile into tdata1
651 ; now we have the masked tile in "tdata1".
652 ; time to mask it onto "tdata"
655 add si,[masklen] ;SI = masked tile's tiledata
656 mov di,OFFSET tdata ;DI = tile in "tdata"
659 mov bx,OFFSET tdata1 ;BX = mask
663 mov al,[bx] ;get mask byte
664 and [di],al ;and tdata with it
665 lodsb ;get tilem byte
666 or [di],al ;OR it onto tdata
679 ;====================================================
681 ; Draw a tile in any of the video modes
682 ; NOTE: ONLY WORKS WITH TSIZE=2!
684 ;====================================================
687 ARG x:WORD,y:WORD,tsize:WORD
694 mov ah,[BYTE PTR hsize+bx-2]
700 mov dx,[DrawTable+bx]
713 add di,[CGAlookup+bx]
735 ; EGA1/2/3 TILE DRAW ROUTINES
739 mov di,[EGA1lookup+bx]
743 mov di,[EGA2lookup+bx]
745 label DoDrawEGAT proc
851 add di,[VGAlookup+bx]
868 ;////////////////////////////////////////////////////////////////////
870 ; TED5 screen scroll routines!
872 ;////////////////////////////////////////////////////////////////////
875 ARG srcx:WORD,srcy:WORD,width:WORD,height:WORD,destx:WORD,desty:WORD
894 ; Copy from sourcex to destx, right
897 mov bx,[srcy] ;source & dest are the same!
902 mov si,[ss:CGAlookup+bx]
913 ; Copy from end of sourcex to end of destx, left
917 mov bx,[srcy] ;source & dest are the same!
921 mov si,[ss:CGAlookup+bx]
938 ; Copy from end of sourcey to end of desty, up
955 mov si,[ss:CGAlookup+bx]
960 mov di,[ss:CGAlookup+bx]
969 ; Copy from sourcey to desty, down
980 mov si,[ss:CGAlookup+bx]
983 mov di,[ss:CGAlookup+bx]
1001 ARG srcx:WORD,srcy:WORD,width:WORD,height:WORD,destx:WORD,desty:WORD
1006 mov ax,GCmode OR 100h
1021 ; Copy from sourcex to destx, right
1024 mov bx,[srcy] ;source & dest are the same!
1028 cmp [ss:videomode],2
1031 mov si,[ss:EGA2lookup+bx]
1042 mov si,[ss:EGA1lookup+bx]
1053 ; Copy from end of sourcex to end of destx, left
1057 mov bx,[srcy] ;source & dest are the same!
1060 cmp [ss:videomode],2
1063 mov si,[ss:EGA2lookup+bx]
1080 mov si,[ss:EGA1lookup+bx]
1097 ; Copy from end of sourcey to end of desty, up
1100 mov ah,[BYTE height]
1109 cmp [ss:videomode],2
1116 mov si,[ss:EGA2lookup+bx]
1121 mov di,[ss:EGA2lookup+bx]
1133 mov si,[ss:EGA1lookup+bx]
1137 mov di,[ss:EGA1lookup+bx]
1148 ; Copy from sourcey to desty, down
1151 mov ah,[BYTE height]
1156 cmp [ss:videomode],2
1161 mov si,[ss:EGA2lookup+bx]
1164 mov di,[ss:EGA2lookup+bx]
1178 mov si,[ss:EGA1lookup+bx]
1182 mov di,[ss:EGA1lookup+bx]
1198 ARG srcx:WORD,srcy:WORD,width:WORD,height:WORD,destx:WORD,desty:WORD
1217 ; Copy from sourcex to destx, right
1220 mov bx,[srcy] ;source & dest are the same!
1225 mov si,[ss:VGAlookup+bx]
1236 ; Copy from end of sourcex to end of destx, left
1240 mov bx,[srcy] ;source & dest are the same!
1244 mov si,[ss:VGAlookup+bx]
1261 ; Copy from end of sourcey to end of desty, up
1264 mov ah,[BYTE height]
1278 mov si,[ss:VGAlookup+bx]
1283 mov di,[ss:VGAlookup+bx]
1292 ; Copy from sourcey to desty, down
1295 mov ah,[BYTE height]
1303 mov si,[ss:VGAlookup+bx]
1306 mov di,[ss:VGAlookup+bx]
1321 ;////////////////////////////////////////////////////////////////////
1325 ;////////////////////////////////////////////////////////////////////
1338 mov ax,[OverTable+si]
1341 LABEL OverlayCGA PROC
1345 mov si,[Csparse+bx-2]
1355 LABEL OverlayEGA PROC
1359 mov si,[Esparse+bx-2]
1369 LABEL OverlayVGA PROC
1373 mov si,[Vsparse+bx-2]