ega.inc
来自「Dos6.0」· INC 代码 · 共 1,775 行 · 第 1/4 页
INC
1,775 行
; writes that occur when an out dx,ax is executed to an 8-bit device (such as
; the EGA). Furthermore, Video-7 reports problems running on Olivetti/AT&T
; machines with this opcode due to a "byte reversal problem". Therefore, it
; has been implemented has a macro expansion.
;
OutWord macro NoInts,DestroyAX,DestroyDX
ifb <NoInts>
pushf ; Save interrupt flag state
cli
endif ; ifb <NoInts>
out dx,al
IOdelay
inc dx
xchg al,ah
out dx,al
ifb <NoInts>
popf ; Restore interrupt flag state
endif ; ifb <NoInts>
ifb <DestroyDX>
dec dx
endif ; ifb <DestroyDX>
ifb <DestroyAX>
xchg al,ah
endif ; ifb <DestroyAX>
endm
;
; Since IBM has documented that the VGA does NOT support 16-bit I/O to
; the Attribute Controller, we abide by this restriction (even though it
; would appear to work on certain models.) Also, if ax is passed for the
; scratch argument, it is assumed ax need not be preserved. -JTP
;
OutWordAttr macro scratch,NoInts
ifb <NoInts>
pushf ; Save interrupt flag state
cli
endif ; ifb <NoInts>
InitFlipFlop
mov dl,AttCtrlAddrReg AND 0FFh ; Restore AttrAddr
out dx,al
IOdelay
ifidn <scratch>,<ax>
mov al,ah
else ; NOT idn <scratch>,<ax>
xchg al,ah
endif ; NOT idn <scratch>,<ax>
out dx,al
ifb <NoInts>
popf ; Restore interrupt flag state
endif ; ifb <NoInts>
ifdif <scratch>,<ax>
xchg al,ah
endif ; dif <scratch>,<ax>
endm
comment \ Not currently used
InByteAttr macro NoInts
ifb <NoInts>
pushf ; Save interrupt flag state
cli
endif ; ifb <NoInts>
InitFlipFlop
IOdelay
mov dl,AttCtrlAddrReg AND 0FFh ; Restore AttrAddr
out dx,al ; Tell 3C0 which index
IOdelay
inc dx
in al,dx ; 3C1 returns reg data
IOdelay
dec dx
out dx,al ; Restore flip-flop state
ifb <NoInts>
popf ; Restore interrupt flag state
endif ; ifb <NoInts>
endm
\
;
; Since initialization of the Attribute Controller flip-flop is so common,
; it appears here as a macro. It assumes dh = 03, ds = cs, and that al can
; be trashed.
;
InitFlipFlop macro NoSaveAX
ifndef NoSaveAX
PUSH AX ; Save environment
endif ; NoSaveAX
mov dl,byte ptr [PortTable][5 * SIZE PortRec].prPortAddr
in al,dx
ifndef NoSaveAX
POP AX ; Restore environment
endif ; NoSaveAX
endm
;
; This is also a common operation that appears here as a macro, with the
; same assumptions as above. If dx is passed for the scratch register, it
; is assumed dx need not be preserved; otherwise the scratch register will be
; used to preserve dx. -JTP
;
WaitRetrace macro scratch
local t1
ifnb <scratch>
ifdif <scratch>,<dx>
mov scratch,dx
endif ; dif <scratch>,<dx>
endif ; nb <scratch>
mov dl,byte ptr [PortTable][5 * SIZE PortRec].prPortAddr
t1:
in al,dx ; Read status reg
test al,08h ; Vert retrace bit on?
jz t1 ; Not yet
cli ; Disable interrupts asap
ifnb <scratch>
ifdif <scratch>,<dx>
mov dx,scratch
endif ; dif <scratch>,<ax>
endif ; nb <scratch>
endm
EGAChooseMonoColorDisplay macro
mov bx,offset PortTable
mov byte ptr code:[bx][0].prPortAddr,al
add al,6
mov byte ptr code:[bx][5 * SIZE PortRec].prPortAddr,al
endm
IFDEF OS2
comment \ Not currently used
PRINT macro message ; OS/2 Device drivers need to
local t1, t2 ; refrain from using Int 21h
ifnb <message>
mov si,offset message ; DS:SI -> Message to display
endif ; ifnb <message>
jmp short t2
t1:
mov ah,14
int 10h
t2:
lodsb
or al,al
jnz t1
endm
\
ELSE ; NOT OS2
QueuePrint macro message
mov bx,[pPrintQueue] ; Get current pointer into PrintQueue
ifb <message>
mov [PrintQueue][bx],dx ; Save message pointer
else ; NOT ifb <message>
mov [PrintQueue][bx],offset message ; Save message pointer
endif ; NOT ifb <message>
add [pPrintQueue],2 ; Move to next spot in PrintQueue
endm
PRINT MACRO message
mov ah,9 ; Command code to print string
ifnb <message>
mov dx,offset message ; DS:DX -> Message to display
endif ; ifnb <message>
int 21h ; Let DOS print the message for us
ENDM
UpperCase MACRO char
local UpperCaseDone
cmp char,'a' ; Is it in range?
jb UpperCaseDone ; No - skip
cmp char,'z' ; Is it in range?
ja UpperCaseDone ; No - skip
and char,NOT 20h ; Convert to upper case
UpperCaseDone:
ENDM
VGAChooseMonoColorDisplay macro
local DisplayCheckDone
mov bx,offset PortTable
MOV BYTE PTR code:[bx][0].PRPortAddr,0D4H
MOV BYTE PTR code:[bx][5 * SIZE PortRec].PRPortAddr,0DAH
MOV AH,12H ; Command code to get EGA information
MOV BL,10H ; Command code to get EGA information
INT 10H ; Find out if currently mono or color
OR BH,BH ; Is it color
JZ DisplayCheckDone ; Yes - skip
mov bx,offset PortTable
MOV BYTE PTR code:[bx][0].PRPortAddr,0B4H
MOV BYTE PTR code:[bx][5 * SIZE PortRec].PRPortAddr,0BAH
DisplayCheckDone:
endm
ENDIF ; NOT OS2
;
; S T R U C T U R E S
;
subttl Structure definitions
page
;
; UserRegs is used by various context functions to access the original
; regs placed on the stack by the Int10Routine. If you change the stack
; format, BE SURE TO UPDATE this structure!
;
UserRegs struc
userBP dw ? ; Offset of user's bp
userRTN dw ? ; Return address for near CALL
userDS dw ? ; Offset of user's ds
userSI dw ? ; Offset of user's si
userAX dw ? ; Offset of user's ax
UserRegs ends
FontInfo struc ; See GetFontInfo for details
fibank0 db ?
fibank1 db ?
fibank2 db ?
fibank3 db ?
FontInfo ends
SetRec struc ; Used in read/write set calls
srPortNum dw ? ; Register id
srPtr db ? ; Register index
srData db ? ; Register data
SetRec ends
PortRec struc
prPortAddr dw ? ; IO port address (can change)
prCurrTable dw ? ; Current shadow map table
prDefTable dw ? ; Default shadow map table
prNumRegs db ? ; Number of data regs
prModFlag db ? ; Modified since last "rev def"
PortRec ends
IFNDEF OS2
Win386_Startup_Info_Struc STRUC
SIS_Version db 3, 0
SIS_Next_Dev_Ptr dd ?
SIS_Virt_Dev_File_Ptr dd 0
SIS_Reference_Data dd ?
SIS_Instance_Data_Off_Ptr dw ?
SIS_Instance_Data_Seg_Ptr dw ?
Win386_Startup_Info_Struc ENDS
Instance_Item_Struc STRUC
IIS_Off_Ptr dw ?
IIS_Seg_Ptr dw ?
IIS_Size dw ?
Instance_Item_Struc ENDS
ENDIF ; NOT OS2
;
; The following structures are device driver definitions
;
IFDEF SYS
REQUEST_HEADER STRUC
RHLength DB ?
UnitCode DB ?
CommandCode DB ?
Status DW ?
Reserved DB 8 DUP (?)
REQUEST_HEADER ENDS
INIT_STRUCT STRUC
REQ_HEADER DB SIZE REQUEST_HEADER DUP (?)
NumberOfUnits DB ?
pEndResidentProgramCode DD ?
pBPB DD ?
DriveNumber DB ?
INIT_STRUCT ENDS
ENDIF ; SYS
;
; S E G M E N T S
;
;*****************************************************************************
; Here we set up a segment in vram. We mark a byte for storage of the
; hardware latches during the SaveState and RestoreState routines.
;
; Non-visible EGA/VGA memory usage:
;
; EGA.SYS latch save area byte is first byte after visible memory
; Mouse latch save area byte is next byte
; Cursor save area comes next
; Screen buffer for area under the cursor comes next
;
egamem segment at 0a000h
egamem ends
subttl Data segment definitions for BIOS data
page
INTVEC segment at 0000h
org 10h * 4
IV_VIDEO LABEL DWORD
IV_VIDEO_OFF dw ? ; Video vector
IV_VIDEO_SEG dw ? ; Video vector
.ERRNZ ($ - IV_VIDEO) - 4 ; Keep the vector together
ifndef OS2
ORG 4 * 2FH
IV_MULTIPLEX LABEL DWORD ; Multiplex interrupt
IV_MULTIPLEX_OFF DW ?
IV_MULTIPLEX_SEG DW ?
.ERRNZ ($ - IV_MULTIPLEX) - 4 ; Keep vector together
endif ; NOT OS2
org 400h + 010h
EquipFlag dw ?
org 400h + 049h
CrtMode db ?
CrtCols dw ?
CrtLen dw ?
CrtStart dw ?
CursorPosn dw 8 dup (?)
CursorMode dw ?
ActivePage db ?
Addr6845 dw ?
CrtModeSet db ?
CrtPalette db ?
org 400h + 084h
Rows db ?
Points dw ?
Info db ?
Info3 db ?
org 400h + 0A8h
lpSavePtr label dword
oSavePtr dw ?
sSavePtr dw ?
.ERRNZ ($ - lpSavePtr) - 4 ; Keep the vector together
INTVEC ends
;
; E N T R Y P O I N T
;
IFDEF SYS
org 0000h ; Header for device driver model
main:
pNextDevice dd -1
Attribute dw 8000h
pDevStrategy dw DevStrategy
pDevInterrupt dw DevInterrupt
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?