home *** CD-ROM | disk | FTP | other *** search
/ CD/PC Actual 13 / CDA13.ISO / cdactual / demobin / share / program / Pascal / BGI256.ZIP / SBASE.INC < prev    next >
Encoding:
Text File  |  1993-04-20  |  32.4 KB  |  1,240 lines

  1. ;SBASE.INC - Copyright 1991,1992,1993 Knight Software
  2. ; History:
  3. ;  30 Nov 1992 - Adapted for protected mode operation
  4. ;                 split off of main to simplify configuration 
  5. ;  22 Dec 1992 - Changed SetWriteMode to add floodfill options.
  6. ;  17 Apr 1993 - Added animation enhancement to GetImage/GetPixel
  7. ;**********************************************************************
  8. ;
  9. ;--- INSTALL ----------------------------------------------------------
  10. ;Driver initialization and installation
  11. ;The Install function is used to prepare the driver for use. 
  12. ;
  13. ;The calls to this function allow the kernal to inquire the 
  14. ;mode information, and allow the kernal to install the mode 
  15. ;infomation.                                                
  16. ;Assume:  DS = data segment
  17. ;Entry:   AL = 00    CL = Mode number
  18. ;Return:  ES:BX = Pointer to Device Status Table
  19. ;
  20. ;Entry:      AL = 01    CL = N/A
  21. ;Return:  CX = Number of modes supported (last mode+1)
  22. ;
  23. ;Entry:      AL = 02    CL = Mode number
  24. ;Return:  ES:BX = Pointer to Mode name (Pascal type String)
  25. ;Destory: None
  26.  
  27. _install PROC    NEAR
  28.     PUSH    SI
  29.     PUSH    DI
  30.     PUSH    AX
  31.     PUSH    DX
  32.     CMP    AL,0
  33.     JNZ    @Install1     ;Install device command 
  34.     CMP    CL,MaxModes    ;if greater than Max # modes
  35.     JC    @installa    ;then force default mode
  36.     MOV    CL,DefaultMode    ;else use selected value
  37. @installa:
  38.     MOV    WORD PTR DS:[ScanLineLength],0 ;clear scan line length
  39.     MOV    DS:[ModeSelect],CL    ;save requested mode
  40.     PUSH    DS
  41.     POP    ES        ;Point ES:BX to status block
  42.     LEA    BX,StatBlock
  43.     CALL    DetectCard    ;determine what card we have
  44.     CALL    MiscInit    ;initalize misc variables
  45.     JMP    @InstallDone
  46.  
  47. @Install1:    ; Mode Query Command
  48.     CMP    AL,1
  49.     JNZ    @Install2
  50.     CMP    BYTE PTR DS:[ModeXflag],0
  51.     JNZ    @Installm
  52.     MOV    CX,DS:[NumberModes]  ;return number of modes available
  53.     JMP    @InstallDone
  54. @Installm:
  55.     MOV    CX,DS:[RetValue]     ;return alternate selected value
  56.     INC    CX             ;pre-distort the result
  57.     JMP    @InstallDone
  58.  
  59. @Install2:    ; Mode Name Command
  60.     CMP    AL,2
  61.     MOV    AH,grError     ;Bad cmd
  62.     JNZ    @Installx
  63.     CALL    GetModeName
  64.     MOV    AH,grInvalidMode ;Bad mode number
  65.     JNC    @Installx
  66.     JMP    @InstallDone
  67.  
  68. @Installx:    ; Bad Install Exit
  69.     MOV    DS:[StatBlock.stat],AH    ;save error
  70. @Installdone:
  71.     POP    DX
  72.     POP    AX
  73.     POP    DI
  74.     POP    SI
  75.     RET
  76. _install ENDP
  77.  
  78.  
  79. ;--- INIT -------------------------------------------------------------
  80. ;Initialize device for output 
  81. ;Assume:  DS = data segment
  82. ;Entry:   ES:BX points to Device Information Table 
  83. ;                        (not Device Status Table)
  84. ;Return:  N/A
  85. ;Destory: None
  86.  
  87. _init    PROC    NEAR
  88.     PUSH    AX
  89.     PUSH    CX
  90.     MOV    CH,ES:[BX]    ;get InitColor
  91.     MOV    CL,ES:[BX+1]    ;Get Init flag
  92.     CMP    CL,65H        ;if 65H don't init
  93.     JZ    @InitExit
  94.     MOV    DS:[InitColor],CH      ;save init color to use
  95.     CALL    word ptr DS:[InitDisplayProc] ;call the selected init code
  96.     JZ    @InitExit
  97.     MOV    AH,grInvalidMode  ;bad mode
  98.     MOV    DS:[StatBlock.stat],AH
  99. @InitExit:
  100.     POP    CX
  101.     POP    AX
  102.     RET
  103. _init    ENDP
  104.  
  105.  
  106. ;--- CLEAR ------------------------------------------------------------
  107. ;Clear graphics device (screen) and ready it for new output. 
  108. ;Assume:  DS = data segment
  109. ;Entry:   N/A
  110. ;Return:  N/A
  111. ;Destroy: None
  112.  
  113. _clear    PROC    NEAR
  114.     PUSH    SI
  115.     PUSH    DI
  116.     PUSH    DX
  117.     PUSH    CX
  118.     PUSH    BX
  119.     PUSH    AX
  120.     MOV    CX,0              ;Start clear at 0,0
  121.     MOV    DX,0
  122.     MOV    AX,DS:[StatBlock.BytesPerScanLine] ;Clear full width of screen
  123.     MOV    BX,DS:[StatBlock.TotalScanLines]   ;Clear full height of screen
  124.     LEA    SI,FillPattern          ;DS:SI = start of cpu memory 
  125.     LEA    DI,WriteClear         ;point DI at proc to use
  126.     CALL    DoBitMap          ;Copy cpu memory to screen
  127.     POP    AX
  128.     POP    BX
  129.     POP    CX
  130.     POP    DX
  131.     POP    DI
  132.     POP    SI
  133.     RET
  134.     RET
  135. _clear    ENDP
  136.  
  137.  
  138. ;--- POST -------------------------------------------------------------
  139. ;Post screen. This is required for devices that need to be posted.
  140. ;Since the IBM displays are always visible, there is no need to
  141. ;do anything here.
  142. ;Assume:  DS = data segment
  143. ;Entry:   N/A
  144. ;Return:  N/A
  145. ;Destory: None
  146.  
  147. _post    PROC    NEAR
  148.     RET
  149. _post    ENDP
  150.  
  151.  
  152. ;--- MOVE -------------------------------------------------------------
  153. ;Set the master Current Pointer to coordinates passed in AX, BX.
  154. ;Assume:  DS = data segment
  155. ;Entry:   AX = X  
  156. ;         BX = Y 
  157. ;Return:  N/A
  158. ;Destory: None
  159.  
  160. _move   PROC  NEAR
  161.     MOV    DS:[CPX],AX
  162.     MOV    DS:[CPY],BX
  163.     RET
  164. _move    ENDP
  165.  
  166.  
  167. ;--- DRAW -------------------------------------------------------------
  168. ;Draw a line from the master Current Pointer to the 
  169. ;coordinates passed in AX,BX.
  170. ;Assume:   DS = data segment
  171. ;Entry:    AX = X
  172. ;          BX = Y 
  173. ;Return:   N/A
  174. ;Destroys: None
  175.  
  176. _draw    PROC    NEAR
  177.     PUSH    CX
  178.     PUSH    DX
  179.     MOV    CX,DS:[CPX]
  180.     MOV    DX,DS:[CPY]
  181.     CALL    PlotLine
  182.     POP    DX
  183.     POP    CX
  184.     RET
  185. _draw    ENDP
  186.  
  187.  
  188. ;--- VECT -------------------------------------------------------------
  189. ;Draw a line between the coordinates passed in AX, BX, CX, DX.
  190. ;Assume:   DS = data segment
  191. ;Entry:    AX = X Start
  192. ;          BX = Y Start
  193. ;          CX = X End
  194. ;          DX = Y End
  195. ;Return:   N/A
  196. ;Destroys: None
  197.  
  198. _vect    PROC    NEAR
  199.     CALL    PlotLine
  200.     RET
  201. _vect    ENDP
  202.  
  203.  
  204. ; @EM --- BAR ---------------------------------------------------------
  205. ;Draw a filled rectangle with the CP as the Lower Left corner, 
  206. ;and the coordinate in AX, BX as the upper right.
  207. ;Assume:   DS = data segment
  208. ;Entry:    AX = X upper corner  
  209. ;          BX = Y upper corner
  210. ;          CX = Depth for 3D bars
  211. ;          DX = Draw Top Flag (DX<>0 = Draw Top)
  212. ;Return:   N/A
  213. ;Destroys: None
  214.  
  215. ;_bar  PROC  NEAR                        ; @@@@@@                    
  216. ;    RET                              ; this function is emulated 
  217. ;_bar    ENDP                             ; @@@@@@                    
  218.  
  219.  
  220. ;--- PATBAR -----------------------------------------------------------
  221. ;Draw a patterned box at the passed coordinates in AX, BX, CX, DX. 
  222. ;The pattern is provided by the information previously passed to 
  223. ;the set fill pattern function.
  224. ;Assume:   DS = data segment
  225. ;Entry:    AX = X1 Corner  
  226. ;          BX = Y1 Corner
  227. ;          CX = X2 Corner  
  228. ;          DX = Y2 Corner
  229. ;Return:   N/A
  230. ;Destroys: None
  231.  
  232. _patbar    PROC    NEAR
  233.     PUSH    SI
  234.     PUSH    DI
  235.     PUSH    DX
  236.     PUSH    CX
  237.     PUSH    BX
  238.     PUSH    AX
  239.     CMP    AX,CX        ;insure that start X is in CX
  240.     JNC    @PatBar1
  241.     XCHG    AX,CX
  242. @PatBar1:
  243.     CMP    BX,DX        ;insure that start Y is in DX
  244.     JNC    @PatBar2
  245.     XCHG    BX,DX
  246. @PatBar2:
  247.     SUB    AX,CX        ;put X size in AX
  248.     INC    AX
  249.     SUB    BX,DX        ;put Y size in BX
  250.     INC    BX
  251.     LEA    SI,FillPattern     ;DS:SI = start of cpu memory 
  252.     LEA    DI,WriteFillLine ;point DI at proc to use
  253.     CALL    DoBitMap     ;Copy cpu memory to screen
  254.     POP    AX
  255.     POP    BX
  256.     POP    CX
  257.     POP    DX
  258.     POP    DI
  259.     POP    SI
  260.     RET
  261. _patbar    ENDP
  262.  
  263.  
  264. ; @EM --- ARC ---------------------------------------------------------
  265. ;Draw an elliptical arc from the start angle in AX, 
  266. ;to the end angle in BX, using the the CP as the Center Point, 
  267. ;and the X and Y Radii in CX, DX. Angles are 0-360 degrees.
  268. ;Assume:  DS = data segment
  269. ;Entry:   AX = Start Angle  BX = End Angle
  270. ;         CX = X radius of arc
  271. ;         DX = Y radius of arc
  272. ;Return:  N/A
  273. ;Destory: None
  274.  
  275. ;_arc  PROC  NEAR                        ; @@@@@@                    
  276. ;    RET                              ; this function is emulated 
  277. ;_arc    ENDP                             ; @@@@@@                    
  278.  
  279.  
  280. ; @EM --- PIESLICE ----------------------------------------------------
  281. ;Draw an elliptical sector from the start angle in AX,
  282. ;to the end angle in BX, using the CP as the Center Point, 
  283. ;and the X and Y Radii in CX, DX. Angles are 0-360 degrees.
  284. ;Assume:  DS = data segment
  285. ;Entry:   AX = Start Angle  BX = End Angle
  286. ;         CX = X radius of arc
  287. ;         DX = Y radius of arc
  288. ;Return:  N/A
  289. ;Destory: None
  290.  
  291. ;_pieslice  PROC  NEAR                   ; @@@@@@                    
  292. ;    RET                              ; this function is emulated 
  293. ;_pieslice ENDP                          ; @@@@@@                    
  294.  
  295.  
  296. ; @EM --- FILLED ELLIPSE ----------------------------------------------
  297. ;Draw an ellipse using the CP as the Center Point, 
  298. ;and the X and Y radii passed in AX, BX.
  299. ;Assume:  DS = data segment
  300. ;Entry:   AX = X Radius of ellipse
  301. ;         BX = Y Radius of ellipse
  302. ;Return:  N/A
  303. ;Destory: None
  304.  
  305. ;_filled_ellipse  PROC  NEAR             ; @@@@@@                    
  306. ;    RET                              ; this function is emulated 
  307. ;_filled_ellipse ENDP                    ; @@@@@@                    
  308.  
  309.  
  310. ;--- PALETTE ---------------------------------------------------------- 
  311. ;Set a specific palette entry to a given color.
  312. ;Assume:  DS = data segment
  313. ;Entry:
  314. ; Top two bits of AX contain command code.
  315. ; 00 : set EGA color - Index in AL, Color in BL
  316. ; 01 : not used 
  317. ; 10 : set specific VGA palette - BX=red, CX=green, DX=blue, AX=index
  318. ; 11 : set EGA background color - BL=Color
  319. ;Return:  N/A
  320. ;Destory: None
  321.  
  322. _palette PROC    NEAR
  323.     AND    AH,0C0H
  324.     JZ    @Pal0    ;set color value
  325.     CMP    AH,80H
  326.     JZ    @Pal2    ;set dac color register
  327.     CMP    AH,40H    ;this function not used
  328.     JZ    @PalX
  329.     MOV    AL,0    ;set background color
  330. @Pal0:    CALL    SetEGAPal ;Go set the EGA palette
  331.     RET
  332.  
  333. @Pal2:    CALL    SetVGAPal ;Get set the VGA palette
  334. @PalX:    RET
  335.  
  336. _palette ENDP
  337.  
  338.  
  339. ;--- ALL PALETTE ------------------------------------------------------
  340. ;Load an EGA palette with a table of colors.
  341. ;Assume:  DS    = data segment
  342. ;Entry:   ES:BX = EGA Palette Table to load
  343. ;Return:  N/A
  344. ;Destory: None
  345.  
  346. _allpalette PROC  NEAR
  347.     CALL    SetFullEGAPal
  348.     RET
  349. _allpalette ENDP
  350.  
  351.  
  352. ;--- COLOR ------------------------------------------------------------
  353. ;Set the palette indexs to the specified drawing color in AL
  354. ;and the specified fill color in AH.
  355. ;Assume:  DS = data segment
  356. ;Entry:   AL = Drawing Color
  357. ;         AH = Fill color
  358. ;Return:  N/A
  359. ;Destroy: None
  360.  
  361. _color  PROC  NEAR
  362.     MOV    DS:[DrawForeColor],AL
  363.     MOV    DS:[FillForeColor],AH
  364.     RET
  365. _color    ENDP
  366.  
  367.  
  368. ;--- FILL STYLE -------------------------------------------------------
  369. ;Set the fill pattern to the specified pattern number passed in AL.
  370. ;If the pattern number is 0FFH, the pattern is define in
  371. ;a user supplied array pointed at by ES:BX.
  372. ;Assume:  DS    = data segment
  373. ;Entry:   AL    = Pattern # (0FFH for user def)
  374. ;         ES:BX = User pattern data if needed
  375. ;Return:  N/A
  376. ;Destroy: None
  377.  
  378. _fillstyle PROC    NEAR
  379.     PUSH    ES
  380.     PUSH    DI
  381.     PUSH    CX
  382.     PUSH    BX
  383.     PUSH    AX
  384.     MOV    CX,4         ;Copy four words (eight bytes)
  385.     LEA    DI,FillPattern   ;copy pattern to Fill Pattern array
  386.     CMP    AL,0FFH
  387.     JZ    @UserFill
  388.     PUSH    DS
  389.     POP    ES
  390.     MOV    AH,0    ;Adjust for table index
  391.     SHL    AX,1    ;Pattern number times eight
  392.     SHL    AX,1
  393.     SHL    AX,1
  394.     LEA    BX,FillTable
  395.     ADD    BX,AX    ;ES:BX points into table
  396. @UserFill:
  397.     MOV    AX,ES:[BX] ;Copy pattern to drawing array
  398.     MOV    DS:[DI],AX
  399.     INC    BX
  400.     INC    DI
  401.     INC    BX
  402.     INC    DI
  403.     LOOP    @UserFill
  404.     POP    AX
  405.     POP    BX
  406.     POP    CX
  407.     POP    DI
  408.     POP    ES
  409.     RET
  410. _fillstyle ENDP
  411.  
  412.  
  413. ;--- LINE STYLE -------------------------------------------------------
  414. ;Set the line style to the specified style number passed in AL.
  415. ;If the style number is > 3  then the style is define in the user 
  416. ;supplied pattern in BX. The line width to use is passed in CX. 
  417. ;Note: The calling Graph unit actually does the triple width
  418. ;      by drawing the line three times, so don't do it in here. 
  419. ;Assume:  DS = data segment
  420. ;Entry:   AL = Style # ( >3 for user def)
  421. ;         BX = User Line Pattern
  422. ;         CX = Line Width (1 or 3)
  423. ;Return:  N/A
  424. ;Destory: None
  425.  
  426. _linestyle PROC    NEAR
  427.     PUSH    DI
  428.     PUSH    BX
  429.     PUSH    AX
  430.     MOV    DS:[LineWidth],CL
  431.     CMP    AL,4
  432.     JNC    @LineStyleX
  433.     AND    AX,03H
  434.     ADD    AX,AX
  435.     LEA    DI,LinePatternTable
  436.     ADD    DI,AX
  437.     MOV    BX,DS:[DI]
  438. @LineStyleX:
  439.     MOV    DS:[LinePattern],BX
  440.     POP    AX
  441.     POP    BX
  442.     POP    DI
  443.     RET
  444. _linestyle ENDP
  445.  
  446.  
  447. ;--- TEXT STYLE -------------------------------------------------------
  448. ;Set the text attributes for font rendering
  449. ;Assume:  DS = data segment
  450. ;Entry:   AL = Font Number
  451. ;         AH = Font Path and Direction
  452. ;         BX = Desired X Character Size
  453. ;         CX = Desired Y Character Size
  454. ;Return:  BX = Actual X Character Size
  455. ;         CX = Actual Y Character Size
  456. ;Destroy: None
  457.  
  458. _textstyle PROC NEAR
  459.     PUSH    CX
  460.     PUSH    BX
  461.     PUSH    AX
  462.     MOV    DS:[FontNumber],AL
  463.     MOV    DS:[FontDir],AH
  464.     SHR    CL,1
  465.     SHR    CL,1
  466.     SHR    CL,1
  467.     JNZ    @TextStyle1
  468.     INC    CL
  469. @TextStyle1:
  470.     CMP    CL,10
  471.     JL    @TextStyle2
  472.     MOV    CL,10
  473. @TextStyle2:
  474.     MOV    DS:[FontMultX],CL
  475.  
  476.     SHR    BL,1
  477.     SHR    BL,1
  478.     SHR    BL,1
  479.     JNZ    @TextStyle3
  480.     INC    BL
  481. @TextStyle3:
  482.     CMP    BL,10
  483.     JL    @TextStyle4
  484.     MOV    BL,10
  485. @TextStyle4:
  486.     MOV    DS:[FontMultY],BL
  487.  
  488.     MOV    AL,DS:[CharSizeX]
  489.     MUL    BL
  490.     MOV    BL,AL
  491.     MOV    BH,0
  492.     MOV    DS:[FontSizeX],BL
  493.  
  494.     MOV    AL,DS:[CharSizeY]
  495.     MUL    CL
  496.     MOV    CL,AL
  497.     MOV    CH,0
  498.     MOV    DS:[FontSizeY],CL
  499.     POP    AX
  500.     POP    BX
  501.     POP    CX
  502.     RET
  503. _textstyle ENDP
  504.  
  505.  
  506. ;--- TEXT -------------------------------------------------------------
  507. ;Draw a string in the current font with the
  508. ;justification point at the CP.
  509. ;Assume:  DS    = data segment
  510. ;Entry:   ES:BX = Pointer to string
  511. ;         CX    = String Length
  512. ;Return:  N/A
  513. ;Destroy: None
  514.  
  515. _drawtext    PROC    NEAR
  516.     CALL    DrawText
  517.     RET
  518. _drawtext    ENDP
  519.  
  520.  
  521. ;--- TEXT SIZE --------------------------------------------------------
  522. ;Calculate the dimensions (in pixels) of an input text string.
  523. ;Assume:  DS    = data segment
  524. ;Entry:   ES:BX = Pointer to string
  525. ;         CX    = String Length
  526. ;Return:  BX    = Width of string
  527. ;         CX    = Height of string
  528. ;Destroy: None
  529.  
  530. _textsize PROC    NEAR
  531.     PUSH    AX
  532.     MOV    AH,0
  533.     MOV    AL,DS:[FontSizeX]
  534.     MUL    CX
  535.     MOV    BX,AX
  536.     MOV    CH,0
  537.     MOV    CL,DS:[FontSizeY]
  538.     POP    AX
  539.     RET
  540. _textsize ENDP
  541.  
  542. ;--- FLOOD FILL -------------------------------------------------------
  543. ;Do a floodfill in the current color using the specified X,Y address 
  544. ;in AX, BX as the seed point. CL contains the border color.
  545. ;Assume:  DS = data segment
  546. ;Entry:   AX = Seed X                  
  547. ;         BX = Seed Y            ;warning: this flood fill has problems   
  548. ;         CL = Border color      ;with complex floods. I still haven't  
  549. ;Return:  N/A                    ;fixed it (I'm not sure how to yet).
  550. ;Destroy: None
  551.  
  552. _floodfill PROC NEAR
  553.     MOV    DS:[CPX],AX    ;update CPxy
  554.     MOV    DS:[CPY],BX
  555.     CALL    DoFloodFill    ;(Located in SFLOOD.INC)
  556.     RET
  557. _floodfill ENDP
  558.  
  559.  
  560. ;--- GET PIXEL --------------------------------------------------------
  561. ;Read a pixel from the coordinates specified in AX, BX.
  562. ;Note: If GetPixelSwapFlag is NZ, the current drawing color will be
  563. ;drawn to the pixel location after it is read.
  564. ;If the draw color is the same as the one read, the high bit 
  565. ; is set in the return word.
  566. ;Assume:  DS = data segment
  567. ;Entry:   AX = X
  568. ;         BX = Y 
  569. ;Return:  DL = Pixel value read
  570. ;Destroy: None
  571.  
  572. _getpixel PROC NEAR
  573.     PUSH    AX
  574.     MOV    DS:[PixelX],AX
  575.     MOV    DS:[PixelY],BX
  576.     CALL    GetPixelAddress
  577.     CALL    ReadPixel          ;pixel color is returned in AL
  578.     MOV    DL,AL              ;return the original color in DL
  579.     CMP    DS:[GetPixelSwapFlag],0  ;swap pixel with current draw color?
  580.     JZ    @gpDone              ;no, so we're done
  581.     MOV    AL,DS:[DrawForeColor] ;yup, so do it to it
  582.     CMP    AL,DL              ;if same color    
  583.     JZ    @gpDone              ;no need to redraw it
  584.     CALL    DrawPixel          ;draw the intended pixel
  585. @gpDone:
  586.     POP    AX
  587.     RET
  588. _getpixel ENDP
  589.  
  590.  
  591. ;--- SET PIXEL --------------------------------------------------------
  592. ;Write a pixel to the coordinate specified in AX, BX.
  593. ;Assume:  DS = data segment
  594. ;Entry:   AX = X
  595. ;         BX = Y 
  596. ;         DL = Pixel value to write
  597. ;Return:  N/A
  598. ;Destory: None
  599.  
  600. _setpixel PROC NEAR
  601.     PUSH    AX
  602.     MOV    DS:[PixelX],AX
  603.     MOV    DS:[PixelY],BX
  604.     CALL    GetPixelAddress
  605.     MOV    AL,DL
  606.     CALL    DrawPixel    ;fore color is passed in AL
  607.     POP    AX
  608.     RET
  609. _setpixel ENDP
  610.  
  611.  
  612. ;--- BIT MAP UTILITIES ------------------------------------------------
  613. ;Return a pointer to a table of misc bit map driver utilities. 
  614. ;Assume:  DS    = data segment
  615. ;Entry:   N/A
  616. ;Return:  ES:BX = Base of table
  617. ;Destory: None
  618. ;The table is configured as follows:
  619. ;BitMapTable:      DW GOTOGRAPHIC
  620. ;           DW EXITGRAPHIC
  621. ;           DW PUTPIX
  622. ;           DW GETPIX
  623. ;           DW BITSPERPIXEL
  624. ;           DW SETPAGE
  625. ;           DW SETVISUAL
  626. ;           DW SETWRITEMODE
  627.  
  628. _bitmaputil PROC NEAR
  629.     PUSH    DS
  630.     POP    ES
  631.     LEA    BX,BitMapTable
  632.     RET
  633. _bitmaputil ENDP
  634.  
  635.  
  636. ;--- SAVE BIT MAP -----------------------------------------------------
  637. ;Save a portion of the screen to CPU memory.
  638. ;Note: If SwapBitBltFlag is NZ it is assumed that the cpu memory
  639. ;contains an image to be drawn after the current image is read.
  640. ;This function is intended for animation work. To leave the background 
  641. ;unaffected, use the foreground write functions.
  642. ;Assume:  DS        = data segment
  643. ;Entry:   ES:BX     = Pointer to CPU memory buffer
  644. ;         CX        = Start X coord of block to save
  645. ;         DX        = Start Y coord of block to save
  646. ;         ES:[BX]   = Width of block to save
  647. ;         ES:[BX+2] = Height of block to save
  648. ;Return:  Data in CPU memory buffer starting at ES:[BX+4]
  649. ;Destory: None
  650.  
  651. _savebitmap PROC NEAR
  652.     PUSH    SI
  653.     PUSH    DI
  654.     PUSH    BX
  655.     PUSH    AX
  656.     MOV    SI,BX
  657.     MOV    AX,ES:[SI]    ;[SI]= X size (width)
  658.     INC    AX        ;Save in AX
  659.     MOV    BX,ES:[SI+2]    ;[SI+2]= Y size (height)
  660.     INC    BX        ;Save in BX
  661.     ADD    SI,4        ;ES:SI = start of cpu memory 
  662.     LEA    DI,ReadBitMap   ;point DI at proc to use
  663.     CALL    DoBitMap    ;Copy screen to cpu memory
  664.     POP    AX
  665.     POP    BX
  666.     POP    DI
  667.     POP    SI
  668.     RET
  669. _savebitmap ENDP
  670.  
  671.  
  672. ;--- RESTORE BIT MAP --------------------------------------------------
  673. ;Restore a portion of the screen from CPU memory.
  674. ;Assume:  DS        = data segment
  675. ;Entry:   ES:BX     = Pointer to CPU memory buffer
  676. ;         CX        = Start X coordinate of area to restore
  677. ;         DX        = Start Y coordinate of area to restore
  678. ;         ES:[BX]   = Width of area to restore
  679. ;         ES:[BX+2] = Height of area to restore
  680. ;         ES:[BX+4] = Data to restore to screen
  681. ;         AL        = Write mode to use for restoring the area
  682. ;              (see SetWriteMode procedure for modes allowed)
  683. ;Return:  N/A
  684. ;Destory: None
  685.  
  686. _restorebitmap PROC NEAR
  687.     PUSH    SI
  688.     PUSH    DI
  689.     PUSH    BX
  690.     PUSH    AX
  691.     AND    AL,1FH        ;strip off any garbage in AL
  692.     MOV    DS:[PutImagePixelWriteMode],AL ;save the mode select
  693.     MOV    AH,0        ;index into proc pointer table
  694.     ADD    AX,AX        ;to get the proc address
  695.     LEA    SI,DrawModeTable
  696.     ADD    SI,AX
  697.     MOV    DI,DS:[SI]         ;get selected proc addr into DI
  698.     LEA    SI,PutImagePixelProc ;save selected draw mode procedure 
  699.     MOV    DS:[SI],DI         ;address in the procedure pointer
  700.  
  701.     MOV    SI,BX
  702.     MOV    AX,ES:[SI]    ;[SI]= X size (width)
  703.     INC    AX        ;Save in AX
  704.     MOV    BX,ES:[SI+2]    ;[SI+2]= Y size (height)
  705.     INC    BX        ;Save in BX
  706.     ADD    SI,4        ;ES:SI = start of cpu memory 
  707.     LEA    DI,WriteBitMap  ;point DI at proc to use
  708.     CALL    DoBitMap    ;Copy cpu memory to screen
  709.     POP    AX
  710.     POP    BX
  711.     POP    DI
  712.     POP    SI
  713.     RET
  714. _restorebitmap    ENDP
  715.  
  716.  
  717. ;--- SET CLIP ---------------------------------------------------------
  718. ;Set the clipping window to the rectangle defined by the 
  719. ;the coordinates passed in AX, BX as the upper left corner
  720. ;and CX, DX as the lower left corner.
  721. ;Note: Clipping per the BGI defintion is actually done in the
  722. ;calling graph unit. There's no real need to clip in the BGI driver.
  723. ;Assume:  DS = data segment
  724. ;Entry:   AX = Upper Left X 
  725. ;         BX = Upper Left Y 
  726. ;         CX = Lower Right X 
  727. ;         DX = Lower Right Y 
  728. ;Return:  N/A
  729. ;Destory: None
  730.  
  731. _setclip PROC NEAR
  732.     MOV    DS:[ClipX1],AX
  733.     MOV    DS:[ClipY1],BX
  734.     MOV    DS:[ClipX2],CX
  735.     MOV    DS:[ClipY2],DX
  736.     RET
  737. _setclip ENDP
  738.  
  739.  
  740. ;--- COLOR QUERY ------------------------------------------------------
  741. ;Return the color parameters of the device
  742. ;Assume:  DS = data segment
  743. ;Entry:   AL = Command for query
  744. ;Return: 
  745. ;  if AL = 0 : BX = Total colors available
  746. ;              CX = Maximum color value (BX minus one)
  747. ;  if AL = 1 : ES:BX pointer to default EGA palette 
  748. ;Destory: None
  749.  
  750. _color_query PROC NEAR
  751.     CMP    AL,0
  752.     JZ    @Query0    ;get max palette
  753.     CMP    AL,1
  754.     JZ    @Query1    ;get default palette
  755.     JMP    SHORT @QueryX    ;error
  756.  
  757. @Query0:
  758.     MOV    BH,0
  759.     MOV    BL,DS:[StatBlock.ctblf]
  760.     INC    BX
  761.     MOV    CX,BX
  762.     DEC    CX
  763.     JMP    SHORT @QueryX
  764.  
  765. @Query1:
  766.     PUSH    DS
  767.     POP    ES
  768.     LEA    BX,EgaPalette
  769. @QueryX:
  770.     RET
  771. _color_query ENDP
  772.  
  773.  
  774. ;----------------------------------------------------------------------
  775. ;35 DUP (NONE)    ; Reserved Entry Points
  776.  
  777.  
  778. ;**********************************************************************
  779. ;WARNING! The data segment (DS) is not correctly setup when BMI code
  780. ;is called. Neither is ES. All registers probably should be saved.
  781.  
  782. ;--- BMI ENTER BIT MAP MODE -------------------------------------------
  783. ;switch to pixel graphics mode
  784. ;Assume:  nothing
  785. ;Entry:   N/A
  786. ;Return:  N/A
  787. ;Destory: None
  788.  
  789. bmi_gotographic    PROC FAR
  790.     RET        ; do nothing
  791. bmi_gotographic    ENDP
  792.  
  793.  
  794. ;--- BMI EXIT BIT MAP MODE --------------------------------------------
  795. ;return to normal graphics mode
  796. ;Assume:  nothing
  797. ;Entry:   N/A
  798. ;Return:  N/A
  799. ;Destory: None
  800.  
  801. bmi_exitgraphic    PROC FAR
  802.     RET        ; do nothing
  803. bmi_exitgraphic    ENDP
  804.  
  805.  
  806. ;--- BMI SET PIXEL ----------------------------------------------------
  807. ;Fast version of Set Pixel. 
  808. ;Assume:  nothing
  809. ;Entry:   AX = X
  810. ;         BX = Y 
  811. ;         DL = Pixel value to write
  812. ;Return:  N/A
  813. ;Destory: None
  814.  
  815. bmi_putpixel    PROC FAR
  816.     PUSH    DS
  817.      IF BGIVERSION LT 3
  818.     PUSH    CS
  819.     POP    DS
  820.      ELSE
  821.     MOV    DS,CS:[ALIAS]
  822.      ENDIF
  823.     CALL    _setpixel   ;See _setpixel for more information
  824.     POP    DS 
  825.     RET            ;since we only have one setpixel version
  826. bmi_putpixel    ENDP
  827.  
  828.  
  829. ;--- BMI GET PIXEL ----------------------------------------------------
  830. ;Fast version of Get Pixel. 
  831. ;Assume:  nothing
  832. ;Entry:   AX = X
  833. ;         BX = Y 
  834. ;Return:  DL = Pixel value read
  835. ;Destory: None
  836.  
  837. bmi_getpixel    PROC FAR
  838.     PUSH    DS
  839.      IF BGIVERSION LT 3
  840.     PUSH    CS
  841.     POP    DS
  842.      ELSE
  843.     MOV    DS,CS:[ALIAS]
  844.      ENDIF
  845.     CALL    _getpixel   ;See _getpixel for more information
  846.     POP    DS 
  847.     RET            ;since we only have one getpixel version
  848. bmi_getpixel    ENDP
  849.  
  850.  
  851. ;--- BMI BITS PER PIXEL -----------------------------------------------
  852. ;Return how many bits are in a pixel
  853. ;Assume:  nothing
  854. ;Entry:   N/A
  855. ;Return:  AX = number of bits used to define a pixel
  856. ;Destory: None
  857.  
  858. bmi_bitsperpixel PROC FAR
  859.     PUSH    DS
  860.      IF BGIVERSION LT 3
  861.     PUSH    CS
  862.     POP    DS
  863.      ELSE
  864.     MOV    DS,CS:[ALIAS]
  865.      ENDIF
  866.     MOV    AL,DS:[StatBlock.PixelBits]
  867.     MOV    AH,0
  868.     POP    DS
  869.     RET
  870. bmi_bitsperpixel ENDP
  871.  
  872.  
  873. ;--- BMI SET PAGE -----------------------------------------------------
  874. ;Draw the page passed in AL
  875. ;Assume:  nothing
  876. ;Entry:   AL = Page to draw
  877. ;Return:  N/A
  878. ;Destory: None
  879.  
  880. bmi_setpage    PROC FAR
  881.     RET            ;no draw page selection being done
  882. bmi_setpage    ENDP
  883.  
  884.  
  885. ;--- BMI SET VISUAL PAGE ----------------------------------------------
  886. ;Select the visual display page passed AL
  887. ;Assume:  nothing
  888. ;Entry:   AL = Display page to select
  889. ;Return:  N/A
  890. ;Destory: None
  891.  
  892. bmi_setvisual    PROC FAR
  893.     RET            ;no visual page selection being done
  894. bmi_setvisual    ENDP
  895.  
  896.  
  897. ;--- BMI SET WRITE MODE -----------------------------------------------
  898. ;Set pixel write mode as passed in AL for the procedure group specified
  899. ;or select specific function by command.
  900. ;Assume: nothing
  901. ;Entry:  AL = Bits 5-7 = command
  902. ;             Bits 0-4 = mode/type
  903. ;
  904. ;Bits 5,6 and 7 select the command function to be performed.
  905. ;  000 = 0:(00) Line write mode
  906. ;  001 = 1:(20) Pixel write mode
  907. ;  010 = 2:(40) Fill write mode
  908. ;  011 = 3:(60) FloodFill type
  909. ;  100 = 4:(80) Text write mode
  910. ;  101 = 5:(A0)  <reserved>
  911. ;  110 = 6:(C0) GetImage write mode
  912. ;  111 = 7:(E0) Misc commands 
  913. ;
  914. ;for commands 00, 20, 40, and 80 one of the following subfunctions
  915. ;is added to the command. 
  916. ;  0= MOVE write       8= FORE MOVE write      16= BACK MOVE write     
  917. ;  1= XOR write        9= FORE XOR write       17= BACK XOR write      
  918. ;  2= OR write        10= FORE OR write        18= BACK OR write      
  919. ;  3= AND write       11= FORE AND write       19= BACK AND write     
  920. ;  4= NOT MOVE write  12= FORE NOT MOVE write  20= BACK NOT MOVE write
  921. ;  5= NOT XOR write   13= FORE NOT XOR write   21= BACK NOT XOR write 
  922. ;  6= NOT OR write    14= FORE NOT OR write    22= BACK NOT OR write  
  923. ;  7= NOT AND write   15= FORE NOT AND write   23= BACK NOT AND write 
  924. ;  24 = Set Background color to currently selected foreground color.
  925. ;  30 = Return current selected write mode on next GetMaxMode call.
  926. ;  31 = Return current background color on next GetMaxMode call.
  927. ;  25-29 = (-unused-)
  928. ;
  929. ;for command 60 (floodfill commands), one of the following subfunctions 
  930. ;is added to the command.
  931. ;  0= Border fill         8= Auto Fill         12= DelayDraw Off
  932. ;  1= Seed fill           9= Complex Fill      13= DelayDraw On
  933. ;  2-7   = (-unused-)    10= Compress Off      14= Tracer Off
  934. ;  16-30 = (-unused-)    11= Compress On       15= Tracer On
  935. ;  31 = Return currently selected floodfill option bits
  936. ;
  937. ;for command E0 (misc commands), one of the following subfunctions 
  938. ;is added to the command.
  939. ;      0 = Restore GetPixel to Read only functionality.
  940. ;      1 = Alter GetPixel to Write DrawForeColor after read.
  941. ;      2 = Restore GetImage to Read only functionality.
  942. ;      3 = Alter GetImage to exchange image between cpu and video.
  943. ;   4-23 =   (-unused-)
  944. ;     24 = Set PutImage background color to current draw color (SetColor).
  945. ;     25 = Return current selected graphics mode in next GetMaxMode call.
  946. ;     26 = Return last peak floodfill stack usage in next GetMaxMode call.
  947. ;     27 = Return last floodfill stack free space in next GetMaxMode call. 
  948. ;     28 =   (-unused-)
  949. ;     29 =   (-unused-)
  950. ;     30 = Return last used PutImage write mode in next GetMaxMode call. 
  951. ;     31 = Return current PutImage background color on next GetMaxMode call.
  952. ;note: #25 is used for reverse compatiblity to V2.0x of the BGI256 driver.
  953. ;Future versions will require the Misc command function to be used 
  954. ;(prior version did not require it (ie the top three bits were ignored).
  955. ;This version will still respond to #25, but you should use the 0E0H
  956. ;misc command tag for future compatibility.
  957. ;
  958. ;-------------
  959. ;Return:  N/A
  960. ;Destroy: None
  961.  
  962. bmi_setwritemode PROC FAR
  963.     PUSH    DS
  964.     PUSH    DX
  965.     PUSH    CX
  966.     PUSH    BX
  967.     PUSH    AX
  968.      IF BGIVERSION LT 3
  969.     PUSH    CS
  970.     POP    DS
  971.      ELSE
  972.     MOV    DS,CS:[ALIAS]
  973.      ENDIF
  974.     MOV    CX,AX        ;stuff procedure selection in CL
  975.     AND    CL,0E0H        ;strip off draw mode select
  976.     AND    AL,1FH        ;strip off proc sel info in AL
  977.  
  978.     CMP    AL,25    ;-->    ;@(note: this will go away in the future)
  979.     JZ    @Bmiswg    ;-->    ;@you will have to use misc command instead
  980.  
  981.     CMP    CL,060H
  982.     JZ    @Bmiswf        ;process fill type command
  983.     CMP    CL,0A0H    
  984.     JZ    @Bmiswx        ;currently unused so ignore this
  985.     CMP    CL,0E0H
  986.     JZ    @Bmiswg        ;process misc commands
  987.  
  988. @Bmiswa:
  989.     CMP    AL,24        ;0-23 its a write mode command so go do it
  990.     JL    @Bmiswp        ;Go set proc mode
  991.     JZ    @Bmiswb        ;24=Do Background color selection
  992.     CMP    AL,30
  993.     JL    @Bmiswx        ;25-29=unknown function
  994.     JZ    @Bmisww        ;30=ret write mode on next GetMaxMode call
  995.     JMP    @Bmiswv        ;31=ret backgnd color on next GetMaxMode call
  996.  
  997. @Bmiswg:
  998.     JMP    @Bmiswm
  999.  
  1000. @Bmiswrb:
  1001.     MOV    AH,0         ;ret byte value
  1002. @Bmiswrw:
  1003.     MOV    DS:[RetValue],AX ;ret word value
  1004.     MOV    byte ptr DS:[ModeXflag],1 ;mark that value is to be returned
  1005. @Bmiswx:
  1006.     POP    AX
  1007.     POP    BX
  1008.     POP    CX
  1009.     POP    DX
  1010.     POP    DS
  1011.     RET
  1012. bmi_setwritemode ENDP
  1013.  
  1014.  
  1015. ;--------------------------------
  1016. ;write mode command processor
  1017. @Bmiswp:
  1018.     MOV    CH,AL         ;save the mode select
  1019.     MOV    AH,0        ;index into proc pointer table
  1020.     ADD    AX,AX        ;to get the proc address
  1021.     LEA    BX,DrawModeTable
  1022.     ADD    BX,AX
  1023.     MOV    DX,DS:[BX]    ;get selected proc addr into DX
  1024.     CALL    GetWriteModeAdr
  1025.     JNZ    @Bmiswpx     ;invalid mode selection
  1026.     MOV    DS:[BX],DX   ;save selected draw mode procedure address
  1027.     MOV    BX,AX         ;in the selected group procedure pointer
  1028.     MOV    DS:[BX],CH   ;save mode select number
  1029. @Bmiswpx:
  1030.     JMP    @Bmiswx
  1031.  
  1032. ;--------------------------------
  1033. ;set background write mode 
  1034. @Bmiswb:
  1035.     CALL    GetBackColorAdr ;function 24, set background
  1036.     JNZ    @Bmiswbx    ;<-- invalid background selection
  1037.     MOV    AH,DS:[DrawForeColor]
  1038.     MOV    DS:[BX],AH    ;store the new background color
  1039. @Bmiswbx:
  1040.     JMP    @Bmiswx
  1041.  
  1042. ;--------------------------------
  1043. ;return selected write mode on next GetMaxMode call
  1044. @Bmisww:
  1045.     CALL    GetWriteModeAdr
  1046.     JNZ    @Bmiswwx    ;<-- invalid background selection
  1047.     MOV    BX,AX
  1048.     MOV    AL,DS:[BX]    ;read current selected mode
  1049.     JMP    @Bmiswrb
  1050. @Bmiswwx:
  1051.     JMP    @Bmiswx
  1052.  
  1053. ;--------------------------------
  1054. ;return selected background color on next GetMaxMode call
  1055. @Bmiswv:
  1056.     CALL    GetBackColorAdr ;function 24, set background
  1057.     JNZ    @Bmiswvx    ;<-- invalid background selection
  1058.     MOV    AL,DS:[BX]    ;get the background color
  1059.     JMP    @Bmiswrb
  1060. @Bmiswvx:
  1061.     JMP    @Bmiswx
  1062.  
  1063. ;--------------------------------
  1064. ;floodfill type command processor
  1065. @Bmiswf:
  1066.     CMP    AL,16        ;over range?
  1067.     JNC    @Bmiswf8
  1068.     MOV    CH,DS:[FloodFillType] ;get current type flags
  1069.     MOV    BL,AL        ;copy new select bit to BL
  1070.     AND    BL,01H        ;strip off control bits
  1071.     MOV    BH,0FEH        ;init bit mask
  1072.     MOV    CL,AL
  1073.     SHR    CL,1        ;seed or border fill command?
  1074.     JZ    @Bmiswf7    ;yes, go set the type bit
  1075.     CMP    AL,08H
  1076.     JL    @Bmiswfx    ;unused command
  1077.     CMP    AL,10H        ;control command?
  1078.     JGE    @Bmiswfx
  1079.     AND    CL,03H        ;strip garbage
  1080.     INC    CL        ;adjust bit position
  1081.     INC    CL
  1082. @Bmiswf7:
  1083.     ROL    BH,CL        ;move bit mask into position
  1084.     ROL    BL,CL        ;move bit flag into position
  1085.     AND    CH,BH        ;strip old bit
  1086.     OR    CH,BL        ;or in new bit
  1087.     MOV    DS:[FloodFillType],CH    ;set floodfill type
  1088.     JMP    @Bmiswfx
  1089.  
  1090. @Bmiswf8:
  1091.     CMP    AL,31        ;return floodfill option bits?
  1092.     JNZ    @Bmiswfx
  1093.     MOV    AL,DS:[FloodFillType]
  1094.     JMP    @Bmiswrb
  1095. @Bmiswfx:
  1096.     JMP    @Bmiswx
  1097.  
  1098.  
  1099. ;--------------------------------
  1100. ;misc command processor
  1101. ; 0=Restore GetPixel to Read only functionality.
  1102. ; 1=Alter GetPixel to Write DrawForeColor after read.
  1103. ; 2=Restore GetImage to Read only functionality.
  1104. ; 3=Alter GetImage to exchange image between cpu and video.
  1105. ;24=set putimage background color
  1106. ;25=ret selected graphics mode
  1107. ;26=ret xystack peak
  1108. ;27=ret xystack free
  1109. ;30=ret putimage background color
  1110. ;31=ret last used putimage write mode
  1111. @Bmiswm:
  1112.     CMP    AL,0        ;Restore GetPixel to Read only 
  1113.     JZ    @Bmiswm0
  1114.     CMP    AL,1        ;Alter GetPixel to Write after read
  1115.     JZ    @Bmiswm1
  1116.     CMP    AL,2        ;Restore GetImage to Read only 
  1117.     JZ    @Bmiswm2
  1118.     CMP    AL,3        ;Alter GetImage to xchg cpu and video
  1119.     JZ    @Bmiswm3
  1120.     CMP    AL,24        ;set putimage background color
  1121.     JZ    @Bmiswm24
  1122.     CMP    AL,25        ;ret graphics mode selection
  1123.     JZ    @Bmiswm25
  1124.     CMP    AL,26        ;ret xystack peak
  1125.     JZ    @Bmiswm26
  1126.     CMP    AL,27        ;ret xystack free
  1127.     JZ    @Bmiswm27
  1128.     CMP    AL,30        ;ret last used putimage write mode
  1129.     JZ    @Bmiswm28
  1130.     CMP    AL,31        ;ret putimage background color
  1131.     JZ    @Bmiswm29
  1132. @Bmiswmx:
  1133.     JMP    @Bmiswx        ;unknown function request
  1134.  
  1135.  
  1136. @Bmiswm0:
  1137.     MOV    byte ptr DS:[GetPixelSwapFlag],0 ;Set GetPixel: Read only
  1138.     JMP    @Bmiswmx
  1139.  
  1140. @Bmiswm1:
  1141.     MOV    byte ptr DS:[GetPixelSwapFlag],255 ;Set GetPixel: Wr after Rd
  1142.     JMP    @Bmiswmx
  1143.  
  1144. @Bmiswm2:
  1145.     MOV    byte ptr DS:[GetImageSwapFlag],0 ;Set GetImage: Read only
  1146.     JMP    @Bmiswmx
  1147.  
  1148. @Bmiswm3:
  1149.     MOV    byte ptr DS:[GetImageSwapFlag],255 ;Set GetImage: xchg cpu/vid
  1150.     JMP    @Bmiswmx
  1151.  
  1152. @Bmiswm24:
  1153.     MOV    AH,DS:[DrawForeColor]       ;update the putimage backcolor
  1154.     MOV    DS:[PutImageBackColor],AH  ;to be the current drawing color
  1155.     JMP    @Bmiswmx
  1156.  
  1157. @Bmiswm25:
  1158.     MOV    AL,DS:[ModeSelect]    ;25=return current graphics mode
  1159.     JMP    @Bmiswrb
  1160.  
  1161. @Bmiswm26:
  1162.     MOV    AX,DS:[XYStackPeak]    ;26=return xystack peak
  1163.     JMP    @Bmiswrw
  1164.  
  1165. @Bmiswm27:
  1166.     MOV    AX,DS:[XYStackFree]    ;27=return xystack free
  1167.     JMP    @Bmiswrw
  1168.  
  1169. @Bmiswm28:
  1170.     MOV    AL,DS:[PutImagePixelWriteMode] ;30=ret putimage write mode
  1171.     JMP    @Bmiswrb
  1172.  
  1173. @Bmiswm29:
  1174.     MOV    AL,DS:[PutImageBackColor] ;31=return putimage backcolor
  1175.     JMP    @Bmiswrb
  1176.  
  1177.  
  1178. ;----------------------------------------------------------------
  1179. ;return the desired write mode and write procedure addresses
  1180. ;Assume: DS = data segment
  1181. ;Enter:  CL = mode selector
  1182. ;Return: AX = write mode variable address
  1183. ;        BX = write procedure pointer
  1184. ;destroy: nothing
  1185.  
  1186. GetWriteModeAdr PROC NEAR
  1187.     LEA    AX,LinePixelWriteMode
  1188.     LEA    BX,LinePixelProc
  1189.     CMP    CL,0        ;set for line procs?
  1190.     JZ    @Bmiswdx
  1191.     LEA    AX,DrawPixelWriteMode
  1192.     LEA    BX,DrawPixelProc
  1193.     CMP    CL,20H        ;set for pixel procs?
  1194.     JZ    @Bmiswdx
  1195.     LEA    AX,FillPixelWriteMode
  1196.     LEA    BX,FillPixelProc
  1197.     CMP    CL,40H        ;set for fill procs?
  1198.     JZ    @Bmiswdx
  1199.     LEA    AX,TextPixelWriteMode
  1200.     LEA    BX,TextPixelProc
  1201.     CMP    CL,80H        ;set for text procs?
  1202.     JZ    @Bmiswdx
  1203.     LEA    AX,GetImagePixelWriteMode
  1204.     LEA    BX,GetImagePixelProc
  1205.     CMP    CL,0C0H        ;set for getimage procs?
  1206.     JZ    @Bmiswdx
  1207. @Bmiswdx:
  1208.     RET
  1209. GetWriteModeAdr ENDP
  1210.  
  1211.  
  1212. ;----------------------------------------------------------------------
  1213. ;return the desired background color variable address
  1214. ;Assume: DS = data segment
  1215. ;Enter:  CL = mode selector
  1216. ;Return: BX = write mode variable address
  1217. ;destroy: nothing
  1218.  
  1219. GetBackColorAdr PROC NEAR
  1220.     LEA    BX,DrawBackColor      ;(line back color)
  1221.     CMP    CL,00H
  1222.     JZ    @Bmiswcx
  1223.     LEA    BX,PixelBackColor
  1224.     CMP    CL,20H
  1225.     LEA    BX,FillBackColor
  1226.     CMP    CL,40H
  1227.     JZ    @Bmiswcx
  1228.     LEA    BX,TextBackColor
  1229.     CMP    CL,80H
  1230.     JZ    @Bmiswcx
  1231.     LEA    BX,GetImageBackColor
  1232.     CMP    CL,0C0H
  1233.     JZ    @Bmiswcx
  1234. @Bmiswcx:
  1235.     RET
  1236. GetBackColorAdr ENDP
  1237.  
  1238. ;-----------------------------------------------------------------------
  1239.