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
1027 PROC VWL_WaitRetrace NEAR
\r
1028 mov dx,STATUS_REGISTER_1
\r
1029 mov bx,[WORD TimeCount]
\r
1038 mov ax,[WORD TimeCount]
\r
1054 PROC VW_SetScreen crtc:WORD, pel:WORD
\r
1055 PUBLIC VW_SetScreen
\r
1059 mov dx,STATUS_REGISTER_1
\r
1062 ; wait util the CRTC just starts scaning a diplayed line to set the CRTC start
\r
1069 jz @@waitnodisplay
\r
1081 ; for some reason, my XT's EGA card doesn't like word outs to the CRTC
\r
1086 mov al,0ch ;start address high register
\r
1092 mov al,0dh ;start address low register
\r
1100 call VWL_WaitRetrace
\r
1106 ; set horizontal panning
\r
1110 mov al,ATR_PELPAN or 20h
\r
1113 mov al,[BYTE pel] ;pel pan value
\r
1119 call VWL_WaitRetrace
\r
1129 if NUMFONT+NUMFONTM
\r
1131 ;===========================================================================
\r
1133 ; GENERAL FONT DRAWING ROUTINES
\r
1135 ;===========================================================================
\r
1139 px dw ? ; proportional character drawing coordinates
\r
1141 pdrawmode db 11000b ; 8 = OR, 24 = XOR, put in GC_DATAROTATE
\r
1142 fontcolor db 15 ;0-15 mapmask value
\r
1144 PUBLIC px,py,pdrawmode,fontcolor
\r
1147 ; offsets in font structure
\r
1149 pcharheight = 0 ;lines high
\r
1150 charloc = 2 ;pointers to every character
\r
1151 charwidth = 514 ;every character's width in pixels
\r
1154 propchar dw ? ; the character number to shift
\r
1159 BUFFHEIGHT = 32 ; must be twice as high as font for masked fonts
\r
1161 databuffer db BUFFWIDTH*BUFFHEIGHT dup (?)
\r
1163 bufferwidth dw ? ; bytes with valid info / line
\r
1164 bufferheight dw ? ; number of lines currently used
\r
1169 screenspot dw ? ; where the buffer is going
\r
1171 bufferextra dw ? ; add at end of a line copy
\r
1174 PUBLIC bufferwidth,bufferheight,screenspot
\r
1178 ;======================
\r
1180 ; Macros to table shift a byte of font
\r
1182 ;======================
\r
1185 mov al,[es:bx] ; source
\r
1189 mov ax,[bp+si] ; table shift into two bytes
\r
1190 or [di],al ; or with first byte
\r
1192 mov [di],ah ; replace next byte
\r
1193 inc bx ; next source byte
\r
1196 MACRO SHIFTWITHXOR
\r
1197 mov al,[es:bx] ; source
\r
1201 mov ax,[bp+si] ; table shift into two bytes
\r
1203 and [di],al ; and with first byte
\r
1205 mov [di],ah ; replace next byte
\r
1206 inc bx ; next source byte
\r
1210 ;=======================
\r
1214 ; Pass buffer start in SI (somewhere in databuffer)
\r
1215 ; Draws the buffer to the EGA screen in the current write mode
\r
1217 ;========================
\r
1219 PROC BufferToScreen NEAR
\r
1221 mov es,[screenseg]
\r
1222 mov di,[screenspot]
\r
1224 mov bx,[bufferwidth] ;calculate offsets for end of each line
\r
1227 ret ;nothing to draw
\r
1230 mov ax,[linewidth]
\r
1232 mov [screenextra],ax
\r
1235 mov [bufferextra],ax
\r
1237 mov bx,[bufferheight] ;lines to copy
\r
1239 mov cx,[bufferwidth] ;bytes to copy
\r
1241 lodsb ;get a byte from the buffer
\r
1242 xchg [es:di],al ;load latches and store back to screen
\r
1247 add si,[bufferextra]
\r
1248 add di,[screenextra]
\r
1257 ;============================================================================
\r
1259 ; NON MASKED FONT DRAWING ROUTINES
\r
1261 ;============================================================================
\r
1267 shiftdrawtable dw 0,shift1wide,shift2wide,shift3wide,shift4wide
\r
1272 ;==================
\r
1276 ; Call with BX = character number (0-255)
\r
1277 ; Draws one character to the buffer at bufferbyte/bufferbit, and adjusts
\r
1278 ; them to the new position
\r
1280 ;==================
\r
1282 PROC ShiftPropChar NEAR
\r
1284 mov si,[fontnumber]
\r
1286 mov es,[grsegs+STARTFONT*2+si] ;segment of font to use
\r
1289 ; find character location, width, and height
\r
1291 mov si,[es:charwidth+bx]
\r
1292 and si,0ffh ;SI hold width in pixels
\r
1294 mov bx,[es:charloc+bx] ;BX holds pointer to character data
\r
1297 ; look up which shift table to use, based on bufferbit
\r
1299 mov di,[bufferbit]
\r
1301 mov bp,[shifttabletable+di] ;BP holds pointer to shift table
\r
1303 mov di,OFFSET databuffer
\r
1304 add di,[bufferbyte] ;DI holds pointer to buffer
\r
1307 ; advance position by character width
\r
1309 mov cx,[bufferbit]
\r
1310 add cx,si ;new bit position
\r
1313 mov [bufferbit],ax ;new bit position
\r
1318 add [bufferbyte],ax ;new byte position
\r
1323 shr si,1 ;bytes the character is wide
\r
1324 shl si,1 ;*2 to look up in shiftdrawtable
\r
1326 mov cx,[es:pcharheight]
\r
1328 jmp [ss:shiftdrawtable+si] ;procedure to draw this width
\r
1331 ; one byte character
\r
1338 add di,dx ; next line in buffer
\r
1343 ; two byte character
\r
1352 add di,dx ; next line in buffer
\r
1357 ; three byte character
\r
1366 add di,dx ; next line in buffer
\r
1371 ; four byte character
\r
1381 add di,dx ; next line in buffer
\r
1386 ; five byte character
\r
1396 add di,dx ; next line in buffer
\r
1404 ;============================================================================
\r
1406 ;==================
\r
1408 ; VW_DrawPropString
\r
1410 ; Draws a C string of characters at px/py and advances px
\r
1412 ; Assumes write mode 0
\r
1414 ;==================
\r
1418 PROC VW_DrawPropString string:DWORD
\r
1419 PUBLIC VW_DrawPropString
\r
1423 ; proportional spaceing, which clears the buffer ahead of it, so only
\r
1424 ; clear the first collumn
\r
1429 mov [BYTE databuffer+BUFFWIDTH*line],al
\r
1434 ; shift the characters into the buffer
\r
1439 mov [bufferbit],ax
\r
1440 mov [bufferbyte],0
\r
1442 mov ax,[WORD string]
\r
1443 mov [stringptr],ax
\r
1444 mov ax,[WORD string+2]
\r
1445 mov [stringptr+2],ax
\r
1448 mov es,[stringptr+2]
\r
1449 mov bx,[stringptr]
\r
1455 call ShiftPropChar
\r
1460 ; calculate position to draw buffer on screen
\r
1464 mov di,[ylookup+bx]
\r
1465 add di,[bufferofs]
\r
1466 add di,[panadjust]
\r
1471 shr ax,1 ;x location in bytes
\r
1473 mov [screenspot],di
\r
1478 mov ax,[bufferbyte]
\r
1491 mov al,GC_DATAROTATE
\r
1492 mov ah,[pdrawmode]
\r
1495 ; set mapmask to color
\r
1498 mov ah,[fontcolor]
\r
1501 mov ax,[bufferbyte]
\r
1502 test [bufferbit],7
\r
1504 inc ax ;so the partial byte also gets drawn
\r
1506 mov [bufferwidth],ax
\r
1507 mov si,[fontnumber]
\r
1509 mov es,[grsegs+STARTFONT*2+si]
\r
1510 mov ax,[es:pcharheight]
\r
1511 mov [bufferheight],ax
\r
1513 mov si,OFFSET databuffer
\r
1514 call BufferToScreen
\r
1518 mov ax,GC_DATAROTATE
\r
1521 ; set mapmask to all
\r
1523 mov ax,SC_MAPMASK + 15*256
\r
1533 ;============================================================================
\r
1535 ; MASKED FONT DRAWING ROUTINES
\r
1537 ;============================================================================
\r
1543 mshiftdrawtable dw 0,mshift1wide,mshift2wide,mshift3wide
\r
1548 ;==================
\r
1552 ; Call with BX = character number (0-255)
\r
1553 ; Draws one character to the buffer at bufferbyte/bufferbit, and adjusts
\r
1554 ; them to the new position
\r
1556 ;==================
\r
1558 PROC ShiftMPropChar NEAR
\r
1560 mov si,[fontnumber]
\r
1562 mov es,[grsegs+STARTFONTM*2+si] ;segment of font to use
\r
1565 ; find character location, width, and height
\r
1567 mov si,[es:charwidth+bx]
\r
1568 and si,0ffh ;SI hold width in pixels
\r
1570 mov bx,[es:charloc+bx] ;BX holds pointer to character data
\r
1573 ; look up which shift table to use, based on bufferbit
\r
1575 mov di,[bufferbit]
\r
1577 mov bp,[shifttabletable+di] ;BP holds pointer to shift table
\r
1579 mov di,OFFSET databuffer
\r
1580 add di,[bufferbyte] ;DI holds pointer to buffer
\r
1582 mov cx,[bufferbit]
\r
1583 add cx,si ;new bit position
\r
1586 mov [bufferbit],ax ;new bit position
\r
1591 add [bufferbyte],ax ;new byte position
\r
1596 shr si,1 ;bytes the character is wide
\r
1597 shl si,1 ;*2 to look up in shiftdrawtable
\r
1599 mov cx,[es:pcharheight]
\r
1601 jmp [ss:mshiftdrawtable+si] ;procedure to draw this width
\r
1604 ; one byte character
\r
1612 add di,dx ; next line in buffer
\r
1616 mov cx,[es:pcharheight]
\r
1621 add di,dx ; next line in buffer
\r
1627 ; two byte character
\r
1636 add di,dx ; next line in buffer
\r
1640 mov cx,[es:pcharheight]
\r
1646 add di,dx ; next line in buffer
\r
1652 ; three byte character
\r
1661 add di,dx ; next line in buffer
\r
1665 mov cx,[es:pcharheight]
\r
1672 add di,dx ; next line in buffer
\r
1680 ;============================================================================
\r
1682 ;==================
\r
1684 ; VW_DrawMPropString
\r
1686 ; Draws a C string of characters at px/py and advances px
\r
1688 ; Assumes write mode 0
\r
1690 ;==================
\r
1694 PROC VW_DrawMPropString string:DWORD
\r
1695 PUBLIC VW_DrawMPropString
\r
1699 ; clear out the first byte of the buffer, the rest will automatically be
\r
1700 ; cleared as characters are drawn into it
\r
1702 mov si,[fontnumber]
\r
1704 mov es,[grsegs+STARTFONTM*2+si]
\r
1705 mov dx,[es:pcharheight]
\r
1706 mov di,OFFSET databuffer
\r
1709 mov bx,BUFFWIDTH-1
\r
1714 stosb ; fill the mask part with $ff
\r
1721 stosb ; fill the data part with $0
\r
1726 ; shift the characters into the buffer
\r
1730 mov [bufferbit],ax
\r
1731 mov [bufferbyte],0
\r
1733 mov ax,[WORD string]
\r
1734 mov [stringptr],ax
\r
1735 mov ax,[WORD string+2]
\r
1736 mov [stringptr+2],ax
\r
1739 mov es,[stringptr+2]
\r
1740 mov bx,[stringptr]
\r
1746 call ShiftMPropChar
\r
1751 ; calculate position to draw buffer on screen
\r
1755 mov di,[ylookup+bx]
\r
1756 add di,[bufferofs]
\r
1757 add di,[panadjust]
\r
1762 shr ax,1 ;x location in bytes
\r
1764 mov [screenspot],di
\r
1769 mov ax,[bufferbyte]
\r
1779 mov ax,[bufferbyte]
\r
1780 test [bufferbit],7
\r
1782 inc ax ;so the partial byte also gets drawn
\r
1784 mov [bufferwidth],ax
\r
1785 mov es,[grsegs+STARTFONTM*2]
\r
1786 mov ax,[es:pcharheight]
\r
1787 mov [bufferheight],ax
\r
1789 ; set AND mode to punch out the mask
\r
1791 mov ax,GC_DATAROTATE + 8*256
\r
1794 ; set mapmask to all
\r
1796 mov ax,SC_MAPMASK + 15*256
\r
1799 mov si,OFFSET databuffer
\r
1800 call BufferToScreen
\r
1802 ; set OR mode to fill in the color
\r
1804 mov ax,GC_DATAROTATE + 16*256
\r
1807 ; set mapmask to color
\r
1810 mov ah,[fontcolor]
\r
1813 call BufferToScreen ; SI is still in the right position in buffer
\r
1817 mov ax,GC_DATAROTATE
\r
1820 ; set mapmask to all
\r
1822 mov ax,SC_MAPMASK + 15*256
\r
1830 endif ; if numfontm
\r