;SCCSID = @(#)bvfcb.inc 6.3 91/08/18
; ****************************************************************************
; *                                                                          *
; *                       IBM/Microsoft Confidential                         *
; *                                                                          *
; *                 Copyright (c) IBM Corporation  1987, 1990                *
; *                 Copyright (c) Microsoft Corp.  1987, 1990                *
; *                           All Rights Reserved                            *
; *                                                                          *
; ****************************************************************************
;STJFMT,,16                             ;Formatting parms for STJFMT

bvscb           STRUC                   ;BVS Control Block Entry
bvs_flags       dw      0               ;Flags used by BVS
bvs_devtype     dw      0               ;Device type flags
bvs_bvssize     dw      0               ;Size of BVSCB
bvs_lvbsize     dw      0               ;Size of LVB
bvs_fontsize    dw      0               ;Size of User Font
bvs_fontpels    dw      0               ;Size of User Font Char Box
bvs_physport    dw      003D4h          ;Video index port address
bvs_ActiveCP    dw      0               ;current active code page ;@S2
bvs_ttycell     db      ' '             ;Cell for WrtTTY scrolling (w/next)
bvs_scrattr     db      007h            ;Screen attribute byte
bvs_scratch     dw      0               ;Scratch area for output operation
; The order of the remaining fields must not change
; Cursor position data
bvs_cursorrow   dw      0               ;Current cursor row
bvs_cursorcol   dw      0               ;Current cursor column
; Cursor Data substructure
bvs_cursorstart dw      6               ;Current cursor start line
bvs_cursorend   dw      7               ;Current cursor end line
bvs_cursorwidth dw      1               ;Current cursor width
bvs_cursorattr  dw      0               ;Current cursor attribute
; Mode Data substructure
bvs_mdlen       dw      34              ;Length of mode data
bvs_type        db      1               ;Type for Mode
bvs_colors      db      0               ;Colors for Mode
bvs_cols        dw      80              ;Number of screen columns for text
bvs_rows        dw      25              ;Number of screen rows for text
bvs_gcols       dw      640             ;Number of screen columns for graphics
bvs_grows       dw      200             ;Number of screen rows for graphics
bvs_attrformat  db      0               ;Attribute format
bvs_attrbytes   db      1               ;Number of attribute bytes      ;B715487
bvs_physaddrl   dw      8000h           ;Physical offset of video buffer ;@@A
bvs_physaddrh   dw      000Bh           ;Physical segment of video buffer ;@@A
bvs_length      dw      0FA0h           ;Length of video buffer (low) ;@@A
bvs_lenhigh     dw      0000h           ;Length of video buffer (high) ;@@A
bvs_fullbufsz   dd      0               ;Full buffer save size
bvs_partbufsz   dd      0               ;Partial buffer save size
bvs_extdata     dd      0               ;Extended mode data address
bvs_modepels    dw      0808h           ;Character columns + 256*rows
; End of substructures
;
;  The following fields must not be separated:
;
bvs_reqmode     db      12 dup (0)      ;Requested mode values & buffers ;@S2
                db      4 dup (0)       ;Do not separate these three lines
bvs_oldmode     db      ((size bvs_reqmode)-2) dup (0) ;Old mode data ;@S2
;
;  The following fields support palette setting:
;
bvs_palregsoff  db      40h,0DAh,52h,0C0h ;String to set palette regs
bvs_palregs     db      0,1,2,3,4,5,14h,7,38h,39h,3Ah,3Bh,3Ch,3Dh,3Eh,3Fh
bvs_modectrl    db      8               ;Mode Control Register
bvs_border      db      0               ;Border color
bvs_palregson   db      81h,020h,0C0h,0 ;Trailer to Re-enable palette regs
bvscb           ENDS

bvs_readbufsize equ     (bvs_oldmode-bvs_reqmode)/2 ;Size of scratch area ;@S2
bvs_readbuf1    equ     bvs_reqmode     ;Scratch area for Int 10h testing ;@S2
bvs_readbuf2    equ     bvs_reqmode+bvs_readbufsize ;@S2

; BVS flags

bvs_f_fntload   equ     0001h           ;Font loading required ;@S2
bvs_f_retrace   equ     0002h           ;Retrace checking required flag ;@S2
bvs_f_reqint10h equ     0004h           ;Int 10h required ;@S2

cga_f_blink     equ     20h             ;Enable blinking for CGA
ega_f_blink     equ     08h             ;Enable blinking for EGA

;Display Configuration Flags

mpaflag         equ     00001h          ;MPA found
cgaflag         equ     00002h          ;CGA found
egmflag         equ     00004h          ;EGA with MONO found
egcflag         equ     00008h          ;EGA with CD found
egaflag         equ     00010h          ;EGA with ECD found
vgpflag         equ     00020h          ;VGA with PDP found ;@@Z
vgmflag         equ     00040h          ;VGA with Mono Display found ;@@Z
vgcflag         equ     00080h          ;VGA with Color Display found ;@@Z
xgmflag         equ     00100h          ;Extended VGA with 8503 ;@@Z
xgcflag         equ     00200h          ;Extended VGA with 8512/3 ;@@Z
xgaflag         equ     00400h          ;Extended VGA with 8514 ;@@Z
xg1flag         equ     00800h          ;Extended VGA with Type 11 ;@@Z;D184
xg2flag         equ     01000h          ;Extended VGA with Type 12 ;@@Z;D184
xgaflag0        equ     02000h          ;XGA with Type 12               ;XGA
xgaflag1        equ     02100h          ;XGA with 8503                  ;XGA
xgaflag2        equ     02200h          ;XGA with 8512/3                ;XGA
xgaflag3        equ     02400h          ;XGA with 8514                  ;XGA
xgaflag4        equ     02800h          ;XGA with Type 11               ;XGA
mouflag         equ     04000h          ;Mouse in system
aioflag         equ     08000h          ;Alternate I/O system

;B717917 fldflag         equ     01FFCh          ;Font Loadable device ;@@Z;@S27
fldflag         equ     03FFCh          ;Font Loadable device ;@@Z;@S27
vgaflags        equ     vgpflag+vgmflag+vgcflag+xgmflag+xgcflag+xgaflag+xg1flag+xg2flag ;@@Z;D184
xgaflags        equ     02000h                                          ;XGA

bvscommon       STRUC                   ;BVS Common Data Segment
cmn_bvscbsize   dw      0               ;Size of the BVSCB
cmn_ActiveCP    dw      0               ;current active code page

cmn_devtypes    dw      0               ;Device types found
cmn_devmemsz    dw      0,0             ;Device memory size

;ROM Font information, order is important
cmn_fontbuf     dw      00000h,0000Ah,02000h ;Font area in video buffer
cmn_font8x8     dw      0FA6Eh,0000Fh,00400h ;8x8 font table in ROM
cmn_font8x14    dw      00000h,00000h,00000h ;8x14 font table in ROM
cmn_font8x16    dw      00000h,00000h,00000h ;8x16 font table in ROM
cmn_font9x14    dw      00000h,00000h,00000h ;9x14 font exception list ROM
cmn_font9x16    dw      00000h,00000h,00000h ;9x16 font exception list ROM
bvscommon       ENDS

cmn_fontcnt     equ     6               ;# of font selectors

cursordata      STRUC                   ;Cursor data structure
cursor_start    dw      ?               ;Current cursor start line
cursor_end      dw      ?               ;Current cursor end line
cursor_width    dw      ?               ;Current cursor width
cursor_attr     dw      ?               ;Current cursor attribute
cursordata      ENDS

physdata        STRUC                   ;PhysBuf Control Block
pd_bufaddrl     dw      ?               ;Low word of buffer address
pd_bufaddrh     dw      ?               ;High word of buffer address
pd_buflenl      dw      ?               ;Low word of buffer length
pd_buflenh      dw      ?               ;High word of buffer length
pd_prisel       dw      ?               ;Primary buffer selector
pd_secsel       dw      ?               ;Secondary buffer selector
physdata        ENDS

ppbvscb         STRUC                   ;BVS Per Process data
ppbvs_bvssel    dw      0               ;BVSCBsg Selector
ppbvs_lvbsel    dw      0               ;LVBsg Selector
ppbvs_gdtsel    dw      0               ;DOS Info GDT Selector
ppbvs_ldtsel    dw      0               ;DOS Info LDT Selector
ppbvs_popsel    dw      0               ;Popup Buffer Selector
ppbvs_fntselv   dw      0               ;Video Font selector    **
ppbvs_fntsel8   dw      0               ;8x8  ROM Font selector ** keep
ppbvs_fntsel14  dw      0               ;8x14 ROM Font selector ** these
ppbvs_fntsel16  dw      0               ;8x16 ROM Font selector ** together
ppbvs_fntsel94  dw      0               ;9x14 ROM Font selector **
ppbvs_fntsel96  dw      0               ;9x16 ROM Font selector **
ppbvs_level     dw      0               ;Level of Recursion
ppbvs_sgnum     dw      0               ;Screen group number
ppbvs_srflen    dw      0               ;Length return area for BVSSRF
ppbvs_retlen    dw      0               ;Length return area
ppbvs_scrhandle dw      0               ;Alternate handle for SCR DD
ppbvs_prthandle dw      0               ;Handle for print requests
; All previous fields set back to 0 after DynLink initialization
ppbvs_pvbsel    dw      0               ;PVB Selector
ppbvs_biosel    dw      0               ;BIOS Selector
ppbvs_physaddrl dw      0               ;Physical offset of video buffer
ppbvs_physaddrh dw      0               ;Physical segment of video buffer
ppbvs_length    dw      0               ;Length of video buffer
ppbvs_lenhigh   dw      0               ;Length of video buffer
ppbvs_flags     db      0               ;Per Process flags
ppbvscb         ENDS

ppbvs_curfont   equ     ppbvs_sgnum     ;Current Font Ptr Offset
ppbvs_maxfont   equ     ppbvs_srflen    ;Maximum Font Ptr Offset

realdata        STRUC                   ;Real Mode data area (based at 40:0)
                db      00010h dup (?)
real_equipflag  dw      ?               ;Bios Equipment Flag
                db      00037h dup (?)
real_crtmode    db      ?               ;Bios Video Mode
real_crtcols    dw      ?               ;Bios Video Columns
real_crtlen     dw      ?               ;Bios Video Length
real_crtstart   dw      ?               ;Bios Video Start Address
real_cursorposn dw      8 dup (?)       ;Bios Cursor Positions
real_cursormode dw      ?               ;Bios Cursor Mode
real_activepage db      ?               ;Bios Active Video Page
real_addr6845   dw      ?               ;Bios Video Port Address
real_crtmodeset db      ?               ;Bios Video Mode Control Register
real_crtpalette db      ?               ;Bios Palette
                db      0001Dh dup (?)
real_rows       db      ?               ;Bios Video Rows
real_points     dw      ?               ;Bios Video Font Pels
real_info       db      ?               ;Bios EGA Info Byte
real_info3      db      ?               ;Bios EGA Info3 Byte
                db      0001Fh dup (?)
real_saveptr    dd      ?               ;Bios Video Save Area Pointer
realdata        ENDS

real_f_cgaemu   equ     01h             ;INFO byte, CGA emulation flag

romfont         struc                   ;ROM Font Info entry
                dw      ?
rf_fontptrl     dw      ?               ;Low word of font ptr
rf_fontptrh     dw      ?               ;High word of font ptr
                dw      ?
rf_charcols     db      ?               ;Pel columns in character
rf_charrows     db      ?               ;Pel rows in character
rf_partfont     db      ?               ;Partial font indicator
rf_basefont     db      ?               ;Base font identifier
romfont         ends

stackframe      STRUC                   ;Parameter Stack Area
regfl           dw      ?               ;Reg FL save area
reges           dw      ?               ;Reg ES save area
regds           dw      ?               ;Reg DS save area
regdi           dw      ?               ;Reg DI save area
regsi           dw      ?               ;Reg SI save area
regbp           dw      ?               ;Reg BP save area
regspworkarea   dw      ?               ;Reg SP save area
regbx           dw      ?               ;Reg BX save area
regdx           dw      ?               ;Reg DX save area
regcx           dw      ?               ;Reg CX save area
regax           dw      ?               ;Reg AX save area
vioroutip       dw      ?               ;VIOROUT return offset
vioroutcs       dw      ?               ;VIOROUT return selector
vioroutds       dw      ?               ;VIOROUT data selector
vioip           dw      ?               ;VIOxxx return offset
viofunc         dw      ?               ;VIOxxx Function code
userip          dw      ?               ;User return offset
usercs          dw      ?               ;User return segment
viohandle       dw      ?               ;Vio Device Handle
parmn           dw      ?               ;Nth parameter
parmnm1         dw      ?               ;(N-1)st parameter
parmnm2         dw      ?               ;(N-2)nd parameter
parmnm3         dw      ?               ;(N-3)rd parameter
parmnm4         dw      ?               ;(N-4)th parameter
parmnm5         dw      ?               ;(N-5)th parameter
parmnm6         dw      ?               ;(N-6)th parameter
parmnm7         dw      ?               ;(N-7)th parameter
parmnm8         dw      ?               ;(N-8)th parameter
parmnm9         dw      ?               ;(N-9)th parameter
stackframe      ENDS

screengroupdata STRUC
sgd_bvssel      dw      ?               ;BVSCB selector
sgd_lvbsel      dw      ?               ;LVB selector
sgd_lvbsize     dw      ?               ;LVB size
sgd_fontsel     dw      ?               ;User FONT selector
sgd_fontsize    dw      ?               ;User FONT size
sgd_fontcols    db      ?               ;User FONT columns
sgd_fontrows    db      ?               ;User FONT rows
screengroupdata ENDS

videoports      STRUC                   ;Generic Video Port Equates
vp_hchartotal   db      ?               ;Horizontal Characters Total
vp_hchardspl    db      ?               ;Horizontal Characters Displayed
vp_hsyncpos     db      ?               ;Horizontal Sync Position
vp_hsyncwidth   db      ?               ;Horizontal Sync Width
vp_vchartotal   db      ?               ;Vertical Characters Total
vp_vtotaladj    db      ?               ;Vertical Total Adjustment
vp_vchardspl    db      ?               ;Vertical Characters Displayed
vp_vsyncpos     db      ?               ;Vertical Sync Position
vp_interlace    db      ?               ;Interlace Mode
vp_maxscanline  db      ?               ;Maximum Scan Line
vp_cursorstart  db      ?               ;Starting Cursor Scan Line
vp_cursorend    db      ?               ;Ending Cursor Scan Line
vp_startaddrh   db      ?               ;Starting Address (High)
vp_startaddrl   db      ?               ;Starting Address (Low)
vp_cursoraddrh  db      ?               ;Cursor Address (High)
vp_cursoraddrl  db      ?               ;Cursor Address (Low)
videoports      ENDS

;Table of Update Subroutines
;   Index <= MvWCSDS ===> Source uses LVB/PVB
;   Index >= MvWCSDS ===> Destination uses LVB/PVB

MvBSSA          equ     0               ;Move Bytes and Skip Src Attrs
MvWCSDR         equ     2               ;Move Words from Src to Dest for Read
MvWCSDS         equ     4               ;Move Words from Src to Dest for Scroll
MvWCSDW         equ     6               ;Move Words from Src to Dest for Write
MvBSDA          equ     8               ;Move Bytes and Skip Dest Attrs
MvBWCA          equ     10              ;Move Bytes with Constant Attr
StBCSD          equ     12              ;Store Bytes and from SI to ES:DI
StWCSD          equ     14              ;Store Words from SI to ES:DI

popall          macro                   ;Identical function to popa
                pop     di
                pop     si
                pop     bp
                pop     ax
                pop     bx
                pop     dx
                pop     cx
                pop     ax
                endm

pushall         macro                   ;Does not save original SP, unlike pusha
                push    ax
                push    cx
                push    dx
                push    bx
                push    sp
                push    bp
                push    si
                push    di
                endm

pushi           macro   item            ;Destroys AX, unlike push immed
                mov     ax,item
                push    ax
                endm

enterb          macro   count           ;ENTER does not handle levels
                push    bp
                mov     bp,sp
                sub     sp,count
                endm

leaveb          macro                   ;LEAVE
                mov     sp,bp
                pop     bp
                endm

break           macro                   ;Dummy macro to avoid DOSMACS.INC
                endm

IODelay macro                                                   ;B720995
        jmp     short $+2                                       ;B720995
endm                                                            ;B720995

;Equates used by Bvs?etMode routines    ;@@A

modedata        STRUC                   ;Mode data structure
mode_datalen    dw      34              ;Length of mode data (=34)
mode_type       db      0               ;Type for Mode
mode_colors     db      0               ;Colors for Mode
mode_cols       dw      0               ;Number of screen columns for text
mode_rows       dw      0               ;Number of screen rows for text
mode_gcols      dw      0               ;Number of screen columns for graphics
mode_grows      dw      0               ;Number of screen rows for graphics
modedata        ENDS

modedataext     STRUC                   ;Mode data structure
mext_datalen    dw      34              ;Length of mode data (=34)
mext_type       db      0               ;Type for Mode
mext_colors     db      0               ;Colors for Mode
mext_cols       dw      0               ;Number of screen columns for text
mext_rows       dw      0               ;Number of screen rows for text
mext_gcols      dw      0               ;Number of screen columns for graphics
mext_grows      dw      0               ;Number of screen rows for graphics
mode_attrformat db      0               ;Attribute format
mode_attrbytes  db      0               ;Number of attribute bytes
mode_bufaddr    dd      0               ;Address of video buffer
mode_bufsize    dd      0               ;Size of video buffer
mode_fullbufsz  dd      0               ;Full buffer save size
mode_partbufsz  dd      0               ;Partial buffer save size
mode_extdata    dd      0               ;Extended mode data address
modedataext     ENDS

;Mode type flags

mode_f_color    equ     001h            ;Color display flag
mode_f_graphics equ     002h            ;Graphics flag
mode_f_uncolor  equ     004h            ;Suppress color
mode_f_afmode   equ     008h            ;Advanced Function mode

;Equates used by BvsGetConfig routine   ;@@A

configdata      struc
cf_length       dw      40              ;Length of control block (=40)
cf_adapter      dw      0               ;Adapter type
cf_display      dw      0               ;Display type
cf_memory       dd      0               ;Memory on adapter
cf_confignum    dw      0               ;Configuration number
cf_version      dw      0               ;VDH version number
cf_flags        dw      0               ;Flags
cf_envsize      dd      0               ;Environment Buffer size
cf_fullsize     dd      0               ;Full save size
cf_partsize     dd      0               ;Partial save size
cf_adapteroff   dw      0               ;Offset to emulated adapters
cf_displayoff   dw      0               ;Offset to emulated displays
;Following fields are in default location only
cf_lemadapterdata  dw      0            ;Length of emulated adapter data (words) @BB7
cf_emadapters      dw      0            ;Emulated adapters
cf_lemdisplaydata  dw      0            ;Length of emulated display data (words) @BB7
cf_emdisplays      dw      0            ;Emulated displays
configdata      ends


;DMQS data structure                                           ;@V2.1JLO01
DMQSDataS          STRUC                                       ;@V2.1JLO01
next_DMQS_offset   dw      0                                   ;@V2.1JLO01
slot_number        db      0                                   ;@V2.1JLO01
level_id           dw      0                                   ;@V2.1JLO01
vendor_id          dd      0                                   ;@V2.1JLO01
io_reg_base        dw      0                                   ;@V2.1JLO01
mmio_regs          dw      0                                   ;@V2.1JLO01
one_meg_aperture   dw      0                                   ;@V2.1JLO01
four_meg_aperture  dw      0                                   ;@V2.1JLO01
vram_base          dw      0                                   ;@V2.1JLO01
monitor_id         dw      0                                   ;@V2.1JLO01
vram_size          db      0                                   ;@V2.1JLO01
DMQSDataS          ENDS                                        ;@V2.1JLO01
                                                               ;@V2.1JLO01
SIZEOFDMQSDataS    equ     22                                  ;@V2.1JLO01
                                                               ;@V2.1JLO01
;Display Composite ID returned through monitor_id              ;@V2.1JLO01
COMP_ID_9515       equ     0F9FFh       ; 1024x768 - 75 hz     ;@V2.1JLO01
COMP_ID_9517       equ     099F0h       ; 1024x768 - 72 hz     ;@V2.1JLO01
COMP_ID_9518       equ     0F9F0h       ;  640x480 - 75 hz     ;@V2.1JLO01
                                                               ;@V2.1JLO01

;@@Z  = 07/17/88 STJ, Add flags for other VGA types
;P1118=08/28/88 THG, Don't call INT 10h routines if IBM compatibile
;@@A  = 12/14/88 STJ, Add new fields to mode and config data, P3156
;D184 = 04/10/89 STJ, Identify other 8514 displays, B701002
;@S2  = 04/13/89 STJ, Improve the handling of Int 10h writes, B701002
;@BB7 = 05/09/89 WKB, Restructure config data structure, B702184
;@S27 = 08/31/89 STJ, XG1 and XG2 need to be marked as font loadable B707929
;@XGA = 08/21/90 WKB, Support XGA in 3xBox, B715181
;B715487 = 08/24/90 WKB, Change default attrbytes to 1, B715487
;B717917 = 11/27/90 WKB, Fix bug in mode, B717917
;B720995 = 08/03/91 WKB, Validate h/w for 132 col requests, (rollover B725471)
;@V2.1JLO01 01/19/94 76799 : Get DMQS Composite Monitor ID via XGA.SYS DevIoctl
