1 ; Reconstructed Commander Keen 4-6 Source Code
\r
2 ; Copyright (C) 2021 K1n9_Duk3
\r
4 ; This file is primarily based on:
\r
5 ; Catacomb 3-D Source Code
\r
6 ; Copyright (C) 1993-2014 Flat Rock Software
\r
8 ; This program is free software; you can redistribute it and/or modify
\r
9 ; it under the terms of the GNU General Public License as published by
\r
10 ; the Free Software Foundation; either version 2 of the License, or
\r
11 ; (at your option) any later version.
\r
13 ; This program is distributed in the hope that it will be useful,
\r
14 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
16 ; GNU General Public License for more details.
\r
18 ; You should have received a copy of the GNU General Public License along
\r
19 ; with this program; if not, write to the Free Software Foundation, Inc.,
\r
20 ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
22 ;=================================
\r
24 ; EGA view manager routines
\r
26 ;=================================
\r
28 ;============================================================================
\r
30 ; All EGA drawing routines that write out words need to have alternate forms
\r
31 ; for starting on even and odd addresses, because writing a word at segment
\r
32 ; offset 0xffff causes an exception! To work around this, write a single
\r
33 ; byte out to make the address even, so it wraps cleanly at the end.
\r
35 ; All of these routines assume read/write mode 0, and will allways return
\r
37 ; The direction flag should be clear
\r
38 ; readmap/writemask is left in an undefined state
\r
40 ;============================================================================
\r
43 ;============================================================================
\r
45 ; VW_Plot (int x,y,color)
\r
47 ;============================================================================
\r
51 plotpixels db 128,64,32,16,8,4,2,1
\r
55 PROC VW_Plot x:WORD, y:WORD, color:WORD
\r
62 mov ax,SC_MAPMASK+15*256
\r
66 mov ax,GC_MODE+2*256 ;write mode 2
\r
78 add di,ax ; di = byte on screen
\r
81 mov ah,[plotpixels+bx]
\r
82 mov al,GC_BITMASK ;mask off other pixels
\r
86 xchg bl,[es:di] ; load latches and write pixel
\r
89 mov ah,0ffh ;no bit mask
\r
91 mov ax,GC_MODE+0*256 ;write mode 0
\r
99 ;============================================================================
\r
101 ; VW_Vlin (int yl,yh,x,color)
\r
103 ;============================================================================
\r
105 PROC VW_Vlin yl:WORD, yh:WORD, x:WORD, color:WORD
\r
112 mov ax,SC_MAPMASK+15*256
\r
116 mov ax,GC_MODE+2*256 ;write mode 2
\r
122 add di,[ylookup+bx]
\r
128 add di,ax ; di = byte on screen
\r
131 mov ah,[plotpixels+bx]
\r
132 mov al,GC_BITMASK ;mask off other pixels
\r
137 inc cx ;number of pixels to plot
\r
139 mov bh,[BYTE color]
\r
144 xchg bl,[es:di] ; load latches and write pixel
\r
150 mov ah,0ffh ;no bit mask
\r
152 mov ax,GC_MODE+0*256 ;write mode 0
\r
160 ;============================================================================
\r
163 ;===================
\r
167 ; xcoord in bytes (8 pixels), ycoord in pixels
\r
168 ; All Tile8s are in one grseg, so an offset is calculated inside it
\r
170 ;===================
\r
172 PROC VW_DrawTile8 xcoord:WORD, ycoord:WORD, tile:WORD
\r
173 PUBLIC VW_DrawTile8
\r
182 add di,[ylookup+bx]
\r
183 mov [ss:screendest],di ;screen destination
\r
195 mov ds,[grsegs+STARTTILE8*2] ; segment for all tile8s
\r
197 mov cx,4 ;planes to draw
\r
198 mov ah,0001b ;map mask
\r
209 shl ah,1 ;shift plane mask over for next plane
\r
211 mov di,[ss:screendest] ;start at same place in all planes
\r
222 mov ds,ax ;restore turbo's data segment
\r
229 ;============================================================================
\r
233 ; Draws a masked block shape to the screen. bufferofs is NOT accounted for.
\r
234 ; The mask comes first, then four planes of data.
\r
236 ;============================================================================
\r
243 maskroutines dw mask0,mask0,mask1E,mask1E,mask2E,mask2O,mask3E,mask3O
\r
244 dw mask4E,mask4O,mask5E,mask5O,mask6E,mask6O
\r
245 dw mask7E,mask7O,mask8E,mask8O,mask9E,mask9O
\r
253 PROC VW_MaskBlock segm:WORD, ofs:WORD, dest:WORD, wide:WORD, height:WORD, planesize:WORD
\r
254 PUBLIC VW_MaskBlock
\r
259 mov [BYTE planemask],1
\r
260 mov [BYTE planenum],0
\r
265 mov [linedelta],dx ;amount to add after drawing each line
\r
267 mov bx,[planesize] ; si+bx = data location
\r
269 cmp di,UNWOUNDMASKS
\r
270 jbe @@unwoundroutine
\r
271 mov [routinetouse],OFFSET generalmask
\r
272 jmp NEAR @@startloop
\r
276 ; use the unwound routines
\r
283 rcl di,1 ;shift a 1 in if destination is odd
\r
284 shl di,1 ;to index into a word width table
\r
285 mov ax,[maskroutines+di] ;call the right routine
\r
286 mov [routinetouse],ax
\r
294 mov ah,[ss:planemask]
\r
298 mov ah,[ss:planenum]
\r
301 mov si,[ofs] ;start back at the top of the mask
\r
302 mov di,[dest] ;start at same place in all planes
\r
303 mov cx,[height] ;scan lines to draw
\r
304 mov dx,[ss:linedelta]
\r
306 jmp [ss:routinetouse] ;draw one plane
\r
307 planereturn: ;routine jmps back here
\r
309 add bx,[ss:planesize] ;start of mask = start of next plane
\r
312 shl [ss:planemask],1 ;shift plane mask over for next plane
\r
313 cmp [ss:planemask],10000b ;done all four planes?
\r
319 ret ;width of 0 = no drawing
\r
323 ; General purpose masked block drawing. This could be optimised into
\r
324 ; four routines to use words, but few play loop sprites should be this big!
\r
341 add di,[ss:linedelta]
\r
348 ; Horizontally unwound routines to draw certain masked blocks faster
\r
366 MACRO SPRITELOOP addr
\r
517 ;============================================================================
\r
521 ; Draws a masked block shape to the screen. bufferofs is NOT accounted for.
\r
522 ; The mask comes first, then four planes of data.
\r
524 ;============================================================================
\r
526 PROC VW_InverseMask segm:WORD, ofs:WORD, dest:WORD, wide:WORD, height:WORD
\r
527 PUBLIC VW_InverseMask
\r
531 mov ax,SC_MAPMASK+15*256
\r
534 mov ax,GC_DATAROTATE+16*256 ;set function = OR
\r
537 mov es, [screenseg]
\r
539 mov dx, [linewidth]
\r
558 mov ax,GC_DATAROTATE+0*256 ;set function = no change
\r
562 mov ds,ax ;restore turbo's data segment
\r
568 ;============================================================================
\r
570 ; VW_ScreenToScreen
\r
572 ; Basic block copy routine. Copies one block of screen memory to another,
\r
573 ; using write mode 1 (sets it and returns with write mode 0). bufferofs is
\r
574 ; NOT accounted for.
\r
576 ;============================================================================
\r
578 PROC VW_ScreenToScreen source:WORD, dest:WORD, wide:WORD, height:WORD
\r
579 PUBLIC VW_ScreenToScreen
\r
586 mov ax,SC_MAPMASK+15*256
\r
589 mov ax,GC_MODE+1*256
\r
602 mov di,[dest] ;start at same place in all planes
\r
603 mov dx,[height] ;scan lines to draw
\r
616 mov ax,GC_MODE+0*256
\r
620 mov ds,ax ;restore turbo's data segment
\r
627 ;============================================================================
\r
631 ; Basic block drawing routine. Takes a block shape at segment pointer source
\r
632 ; with four planes of width by height data, and draws it to dest in the
\r
633 ; virtual screen, based on linewidth. bufferofs is NOT accounted for.
\r
634 ; There are four drawing routines to provide the best optimized code while
\r
635 ; accounting for odd segment wrappings due to the floating screens.
\r
637 ;============================================================================
\r
641 memtoscreentable dw eventoeven,eventoodd,oddtoeven,oddtoodd
\r
646 PROC VW_MemToScreen source:WORD, dest:WORD, wide:WORD, height:WORD
\r
647 PUBLIC VW_MemToScreen
\r
658 xor si,si ;block is segment aligned
\r
661 shr [wide],1 ;change wide to words, and see if carry is set
\r
662 rcl di,1 ;1 if wide is odd
\r
665 rcl di,1 ;shift a 1 in if destination is odd
\r
666 shl di,1 ;to index into a word width table
\r
667 mov ax,SC_MAPMASK+0001b*256 ;map mask for plane 0
\r
668 jmp [ss:memtoscreentable+di] ;call the right routine
\r
672 ; Copy an even width block to an even video address
\r
680 mov di,[dest] ;start at same place in all planes
\r
681 mov dx,[height] ;scan lines to draw
\r
692 shl ah,1 ;shift plane mask over for next plane
\r
693 cmp ah,10000b ;done all four planes?
\r
697 mov ds,ax ;restore turbo's data segment
\r
703 ; Copy an odd width block to an even video address
\r
711 mov di,[dest] ;start at same place in all planes
\r
712 mov dx,[height] ;scan lines to draw
\r
717 movsb ;copy the last byte
\r
724 shl ah,1 ;shift plane mask over for next plane
\r
725 cmp ah,10000b ;done all four planes?
\r
729 mov ds,ax ;restore turbo's data segment
\r
735 ; Copy an even width block to an odd video address
\r
740 dec [wide] ;one word has to be handled seperately
\r
745 mov di,[dest] ;start at same place in all planes
\r
746 mov dx,[height] ;scan lines to draw
\r
759 shl ah,1 ;shift plane mask over for next plane
\r
760 cmp ah,10000b ;done all four planes?
\r
764 mov ds,ax ;restore turbo's data segment
\r
770 ; Copy an odd width block to an odd video address
\r
778 mov di,[dest] ;start at same place in all planes
\r
779 mov dx,[height] ;scan lines to draw
\r
791 shl ah,1 ;shift plane mask over for next plane
\r
792 cmp ah,10000b ;done all four planes?
\r
796 mov ds,ax ;restore turbo's data segment
\r
803 ;===========================================================================
\r
807 ; Copies a block of video memory to main memory, in order from planes 0-3.
\r
808 ; This could be optimized along the lines of VW_MemToScreen to take advantage
\r
809 ; of word copies, but this is an infrequently called routine.
\r
811 ;===========================================================================
\r
813 PROC VW_ScreenToMem source:WORD, dest:WORD, wide:WORD, height:WORD
\r
814 PUBLIC VW_ScreenToMem
\r
824 mov ax,GC_READMAP ;read map for plane 0
\r
832 mov si,[source] ;start at same place in all planes
\r
833 mov dx,[height] ;scan lines to draw
\r
845 cmp ah,4 ;done all four planes?
\r
849 mov ds,ax ;restore turbo's data segment
\r
856 ;============================================================================
\r
858 ; VWL_UpdateScreenBlocks
\r
860 ; Scans through the update matrix and copies any areas that have changed
\r
861 ; to the visable screen, then zeros the update array
\r
863 ;============================================================================
\r
867 ; AX 0/1 for scasb, temp for segment register transfers
\r
868 ; BX width for block copies
\r
870 ; DX line width deltas
\r
871 ; SI source for copies
\r
872 ; DI scas dest / movsb dest
\r
873 ; BP pointer to end of bufferblocks
\r
875 PROC VWL_UpdateScreenBlocks
\r
876 PUBLIC VWL_UpdateScreenBlocks
\r
879 jmp SHORT @@realstart
\r
882 ; all tiles have been scanned
\r
884 mov dx,GC_INDEX ; restore write mode 0
\r
885 mov ax,GC_MODE+0*256
\r
888 xor ax,ax ; clear out the update matrix
\r
889 mov cx,UPDATEWIDE*UPDATEHIGH/2
\r
898 mov ax,SC_MAPMASK+15*256
\r
901 mov ax,GC_MODE+1*256
\r
904 mov di,[updateptr] ; start of floating update screen
\r
906 add bp,UPDATEWIDE*UPDATEHIGH+1 ; when di = bp, all tiles have been scanned
\r
909 mov cx,-1 ; definately scan the entire thing
\r
912 ; scan for a 1 in the update list, meaning a tile needs to be copied
\r
913 ; from the master screen to the current screen
\r
916 pop di ; place to continue scaning from
\r
918 mov es,ax ; search in the data segment
\r
931 ; copy a single tile
\r
935 inc di ; we know the next tile is nothing
\r
936 push di ; save off the spot being scanned
\r
939 mov di,[blockstarts-4+di] ; start of tile location on screen
\r
942 add di,[displayofs]
\r
963 ; more than one tile in a row needs to be updated, so do it as a group
\r
968 mov dx,di ; hold starting position + 1 in dx
\r
969 inc di ; we know the next tile also gets updated
\r
970 repe scasb ; see how many more in a row
\r
971 push di ; save off the spot being scanned
\r
974 sub bx,dx ; number of tiles in a row
\r
975 shl bx,1 ; number of bytes / row
\r
977 mov di,dx ; lookup position of start tile
\r
980 mov di,[blockstarts-2+di] ; start of tile location
\r
983 add di,[displayofs]
\r
986 sub dx,bx ; offset to next line on screen
\r
1001 dec cx ; was 0 from last rep movsb, now $ffff for scasb
\r
1007 ;===========================================================================
\r
1009 ; MISC EGA ROUTINES
\r
1011 ;===========================================================================
\r
1013 ;=================
\r
1017 ;=================
\r
1021 EXTRN TimeCount :DWORD
\r
1028 mov dx,STATUS_REGISTER_1
\r
1029 mov bx,[WORD TimeCount]
\r
1035 cmp [WORD TimeCount],bx
\r
1076 PROC VW_SetScreen crtc:WORD, pel:WORD
\r
1077 PUBLIC VW_SetScreen
\r
1083 ; for some reason, my XT's EGA card doesn't like word outs to the CRTC
\r
1088 mov al,0ch ;start address high register
\r
1094 mov al,0dh ;start address low register
\r
1103 ; set horizontal panning
\r
1107 mov al,ATR_PELPAN or 20h
\r
1110 mov al,[BYTE pel] ;pel pan value
\r
1121 if NUMFONT+NUMFONTM
\r
1123 ;===========================================================================
\r
1125 ; GENERAL FONT DRAWING ROUTINES
\r
1127 ;===========================================================================
\r
1131 px dw ? ; proportional character drawing coordinates
\r
1133 pdrawmode db 11000b ; 8 = OR, 24 = XOR, put in GC_DATAROTATE
\r
1134 fontcolor db 15 ;0-15 mapmask value
\r
1136 PUBLIC px,py,pdrawmode,fontcolor
\r
1139 ; offsets in font structure
\r
1141 pcharheight = 0 ;lines high
\r
1142 charloc = 2 ;pointers to every character
\r
1143 charwidth = 514 ;every character's width in pixels
\r
1146 propchar dw ? ; the character number to shift
\r
1151 BUFFHEIGHT = 32 ; must be twice as high as font for masked fonts
\r
1153 databuffer db BUFFWIDTH*BUFFHEIGHT dup (?)
\r
1155 bufferwidth dw ? ; bytes with valid info / line
\r
1156 bufferheight dw ? ; number of lines currently used
\r
1161 screenspot dw ? ; where the buffer is going
\r
1163 bufferextra dw ? ; add at end of a line copy
\r
1166 PUBLIC bufferwidth,bufferheight,screenspot
\r
1170 ;======================
\r
1172 ; Macros to table shift a byte of font
\r
1174 ;======================
\r
1177 mov al,[es:bx] ; source
\r
1181 mov ax,[bp+si] ; table shift into two bytes
\r
1182 or [di],al ; or with first byte
\r
1184 mov [di],ah ; replace next byte
\r
1185 inc bx ; next source byte
\r
1188 MACRO SHIFTWITHXOR
\r
1189 mov al,[es:bx] ; source
\r
1193 mov ax,[bp+si] ; table shift into two bytes
\r
1195 and [di],al ; and with first byte
\r
1197 mov [di],ah ; replace next byte
\r
1198 inc bx ; next source byte
\r
1202 ;=======================
\r
1206 ; Pass buffer start in SI (somewhere in databuffer)
\r
1207 ; Draws the buffer to the EGA screen in the current write mode
\r
1209 ;========================
\r
1211 PROC BufferToScreen NEAR
\r
1213 mov es,[screenseg]
\r
1214 mov di,[screenspot]
\r
1216 mov bx,[bufferwidth] ;calculate offsets for end of each line
\r
1219 ret ;nothing to draw
\r
1222 mov ax,[linewidth]
\r
1224 mov [screenextra],ax
\r
1227 mov [bufferextra],ax
\r
1229 mov bx,[bufferheight] ;lines to copy
\r
1231 mov cx,[bufferwidth] ;bytes to copy
\r
1233 lodsb ;get a byte from the buffer
\r
1234 xchg [es:di],al ;load latches and store back to screen
\r
1239 add si,[bufferextra]
\r
1240 add di,[screenextra]
\r
1249 ;============================================================================
\r
1251 ; NON MASKED FONT DRAWING ROUTINES
\r
1253 ;============================================================================
\r
1259 shiftdrawtable dw 0,shift1wide,shift2wide,shift3wide,shift4wide
\r
1264 ;==================
\r
1268 ; Call with BX = character number (0-255)
\r
1269 ; Draws one character to the buffer at bufferbyte/bufferbit, and adjusts
\r
1270 ; them to the new position
\r
1272 ;==================
\r
1274 PROC ShiftPropChar NEAR
\r
1276 mov si,[fontnumber]
\r
1278 mov es,[grsegs+STARTFONT*2+si] ;segment of font to use
\r
1281 ; find character location, width, and height
\r
1283 mov si,[es:charwidth+bx]
\r
1284 and si,0ffh ;SI hold width in pixels
\r
1286 mov bx,[es:charloc+bx] ;BX holds pointer to character data
\r
1289 ; look up which shift table to use, based on bufferbit
\r
1291 mov di,[bufferbit]
\r
1293 mov bp,[shifttabletable+di] ;BP holds pointer to shift table
\r
1295 mov di,OFFSET databuffer
\r
1296 add di,[bufferbyte] ;DI holds pointer to buffer
\r
1299 ; advance position by character width
\r
1301 mov cx,[bufferbit]
\r
1302 add cx,si ;new bit position
\r
1305 mov [bufferbit],ax ;new bit position
\r
1310 add [bufferbyte],ax ;new byte position
\r
1315 shr si,1 ;bytes the character is wide
\r
1316 shl si,1 ;*2 to look up in shiftdrawtable
\r
1318 mov cx,[es:pcharheight]
\r
1320 jmp [ss:shiftdrawtable+si] ;procedure to draw this width
\r
1323 ; one byte character
\r
1330 add di,dx ; next line in buffer
\r
1335 ; two byte character
\r
1344 add di,dx ; next line in buffer
\r
1349 ; three byte character
\r
1358 add di,dx ; next line in buffer
\r
1363 ; four byte character
\r
1373 add di,dx ; next line in buffer
\r
1378 ; five byte character
\r
1388 add di,dx ; next line in buffer
\r
1396 ;============================================================================
\r
1398 ;==================
\r
1400 ; VW_DrawPropString
\r
1402 ; Draws a C string of characters at px/py and advances px
\r
1404 ; Assumes write mode 0
\r
1406 ;==================
\r
1410 PROC VW_DrawPropString string:DWORD
\r
1411 PUBLIC VW_DrawPropString
\r
1415 ; proportional spaceing, which clears the buffer ahead of it, so only
\r
1416 ; clear the first collumn
\r
1421 mov [BYTE databuffer+BUFFWIDTH*line],al
\r
1426 ; shift the characters into the buffer
\r
1431 mov [bufferbit],ax
\r
1432 mov [bufferbyte],0
\r
1434 mov ax,[WORD string]
\r
1435 mov [stringptr],ax
\r
1436 mov ax,[WORD string+2]
\r
1437 mov [stringptr+2],ax
\r
1440 mov es,[stringptr+2]
\r
1441 mov bx,[stringptr]
\r
1447 call ShiftPropChar
\r
1452 ; calculate position to draw buffer on screen
\r
1456 mov di,[ylookup+bx]
\r
1457 add di,[bufferofs]
\r
1458 add di,[panadjust]
\r
1463 shr ax,1 ;x location in bytes
\r
1465 mov [screenspot],di
\r
1470 mov ax,[bufferbyte]
\r
1483 mov al,GC_DATAROTATE
\r
1484 mov ah,[pdrawmode]
\r
1487 ; set mapmask to color
\r
1490 mov ah,[fontcolor]
\r
1493 mov ax,[bufferbyte]
\r
1494 test [bufferbit],7
\r
1496 inc ax ;so the partial byte also gets drawn
\r
1498 mov [bufferwidth],ax
\r
1499 mov si,[fontnumber]
\r
1501 mov es,[grsegs+STARTFONT*2+si]
\r
1502 mov ax,[es:pcharheight]
\r
1503 mov [bufferheight],ax
\r
1505 mov si,OFFSET databuffer
\r
1506 call BufferToScreen
\r
1510 mov ax,GC_DATAROTATE
\r
1513 ; set mapmask to all
\r
1515 mov ax,SC_MAPMASK + 15*256
\r
1525 ;============================================================================
\r
1527 ; MASKED FONT DRAWING ROUTINES
\r
1529 ;============================================================================
\r
1535 mshiftdrawtable dw 0,mshift1wide,mshift2wide,mshift3wide
\r
1540 ;==================
\r
1544 ; Call with BX = character number (0-255)
\r
1545 ; Draws one character to the buffer at bufferbyte/bufferbit, and adjusts
\r
1546 ; them to the new position
\r
1548 ;==================
\r
1550 PROC ShiftMPropChar NEAR
\r
1552 mov si,[fontnumber]
\r
1554 mov es,[grsegs+STARTFONTM*2+si] ;segment of font to use
\r
1557 ; find character location, width, and height
\r
1559 mov si,[es:charwidth+bx]
\r
1560 and si,0ffh ;SI hold width in pixels
\r
1562 mov bx,[es:charloc+bx] ;BX holds pointer to character data
\r
1565 ; look up which shift table to use, based on bufferbit
\r
1567 mov di,[bufferbit]
\r
1569 mov bp,[shifttabletable+di] ;BP holds pointer to shift table
\r
1571 mov di,OFFSET databuffer
\r
1572 add di,[bufferbyte] ;DI holds pointer to buffer
\r
1574 mov cx,[bufferbit]
\r
1575 add cx,si ;new bit position
\r
1578 mov [bufferbit],ax ;new bit position
\r
1583 add [bufferbyte],ax ;new byte position
\r
1588 shr si,1 ;bytes the character is wide
\r
1589 shl si,1 ;*2 to look up in shiftdrawtable
\r
1591 mov cx,[es:pcharheight]
\r
1593 jmp [ss:mshiftdrawtable+si] ;procedure to draw this width
\r
1596 ; one byte character
\r
1604 add di,dx ; next line in buffer
\r
1608 mov cx,[es:pcharheight]
\r
1613 add di,dx ; next line in buffer
\r
1619 ; two byte character
\r
1628 add di,dx ; next line in buffer
\r
1632 mov cx,[es:pcharheight]
\r
1638 add di,dx ; next line in buffer
\r
1644 ; three byte character
\r
1653 add di,dx ; next line in buffer
\r
1657 mov cx,[es:pcharheight]
\r
1664 add di,dx ; next line in buffer
\r
1672 ;============================================================================
\r
1674 ;==================
\r
1676 ; VW_DrawMPropString
\r
1678 ; Draws a C string of characters at px/py and advances px
\r
1680 ; Assumes write mode 0
\r
1682 ;==================
\r
1686 PROC VW_DrawMPropString string:DWORD
\r
1687 PUBLIC VW_DrawMPropString
\r
1691 ; clear out the first byte of the buffer, the rest will automatically be
\r
1692 ; cleared as characters are drawn into it
\r
1694 mov si,[fontnumber]
\r
1696 mov es,[grsegs+STARTFONTM*2+si]
\r
1697 mov dx,[es:pcharheight]
\r
1698 mov di,OFFSET databuffer
\r
1701 mov bx,BUFFWIDTH-1
\r
1706 stosb ; fill the mask part with $ff
\r
1713 stosb ; fill the data part with $0
\r
1718 ; shift the characters into the buffer
\r
1722 mov [bufferbit],ax
\r
1723 mov [bufferbyte],0
\r
1725 mov ax,[WORD string]
\r
1726 mov [stringptr],ax
\r
1727 mov ax,[WORD string+2]
\r
1728 mov [stringptr+2],ax
\r
1731 mov es,[stringptr+2]
\r
1732 mov bx,[stringptr]
\r
1738 call ShiftMPropChar
\r
1743 ; calculate position to draw buffer on screen
\r
1747 mov di,[ylookup+bx]
\r
1748 add di,[bufferofs]
\r
1749 add di,[panadjust]
\r
1754 shr ax,1 ;x location in bytes
\r
1756 mov [screenspot],di
\r
1761 mov ax,[bufferbyte]
\r
1771 mov ax,[bufferbyte]
\r
1772 test [bufferbit],7
\r
1774 inc ax ;so the partial byte also gets drawn
\r
1776 mov [bufferwidth],ax
\r
1777 mov es,[grsegs+STARTFONTM*2]
\r
1778 mov ax,[es:pcharheight]
\r
1779 mov [bufferheight],ax
\r
1781 ; set AND mode to punch out the mask
\r
1783 mov ax,GC_DATAROTATE + 8*256
\r
1786 ; set mapmask to all
\r
1788 mov ax,SC_MAPMASK + 15*256
\r
1791 mov si,OFFSET databuffer
\r
1792 call BufferToScreen
\r
1794 ; set OR mode to fill in the color
\r
1796 mov ax,GC_DATAROTATE + 16*256
\r
1799 ; set mapmask to color
\r
1802 mov ah,[fontcolor]
\r
1805 call BufferToScreen ; SI is still in the right position in buffer
\r
1809 mov ax,GC_DATAROTATE
\r
1812 ; set mapmask to all
\r
1814 mov ax,SC_MAPMASK + 15*256
\r
1822 endif ; if numfontm
\r