ega.inc
来自「Dos6.0」· INC 代码 · 共 1,775 行 · 第 1/4 页
INC
1,775 行
; color. The problem is that we need
; to do the BIOS set mode call before
; we call our SetMode routine in order
; to correctly determine if we have
; monochrome or color (which affects
; the value of the CRT controller port
; address).
;
; 04/14/88 2.05 Tom Hensel Fixed VGA shadow register map
; initialization by reading values
; directly from the port registers
; rather than relying on the "magical"
; BIOS register mode init table.
;
; 04/22/88 2.06 Tom Hensel ChangeRegs didn't handle color/mono
; properly for VGA
;
; 06/27/88 2.07 Marc Pawliger Added save/restore ega latches on
; Beta 2 a save/restore context call. Latches
; are stored in all planes at offset
; 9600H plus an added offset used by the
; mouse driver for its internal data.
; 9600 is just past the memory used by
; the VGA at highest resolution.
;
; 07/06/88 2.07 Marc Pawliger OK, OK. The 9600H scheme didn't work.
; Beta 3 So in the true pioneering spirit, the
; memory at A000:CBEA was chosen since
; it's right in the middle of free vram.
; It ain't scientific, but it works.
;
; 07/13/88 2.07 Marc Pawliger Well, so much for pioneering. We now
; Beta 4 use 7FFF for storage in all but the
; high-res VGA modes, when FFFF is used.
; These work for all EGA modes, including
; mode FH and 10H on a 64K EGA.
;
; 08/02/88 2.07 Tom Hensel Bad video mode value for INT 10H
; Beta 5 VGA initialization fixed
; Bug fix for EGA latch code in
; RestoreContext.
;
; 08/31/88 2.07 Tom Hensel DX register was being destroyed in
; Beta 6 SaveContext routine. Fix stack
; problems in RestoreContext.
;
; 09/06/88 2.07 Tom Hensel Don't let EGA latch code change EGA
; Beta 7 state in SaveContext routine.
;
; 09/14/88 2.07 Tom Hensel Choose a different latch location
; Beta 8 based on video mode.
;
; 09/15/88 2.07 Tom Hensel Some more non visible video memory work
; Beta 9
;
; 10/19/88 2.07 Tom Hensel General Cleanup for efficiency
; Beta 10 Added better method (although DOS
; version dependent) to error exit
; from Init with least amount of
; resident code for sys driver.
;
; 11/01/88 2.07 Tom Hensel General Cleanup for efficiency
; Beta 11 Added ability to unload .COM version
; Side effect is new INT 2FH handler
; Added 80286 instructions for OS/2
;
; 11/02/88 2.07 Tom Hensel Fix register corruption bug in
; Beta 12 DownloadFont from last beta
; Added CX='TH' input to acknowledge
; use of VGA specific color select
; register in Define Defaults call.
;
; 11/03/88 2.07 Tom Hensel Efficiency
; Beta 13
;
; 11/06/88 2.07 Tom Hensel No messages for OS/2
; Beta 14
;
; 11/19/88 2.07 Tom Hensel Added ChooseMonoColorDisplay macro
; Beta 15 to fix bug reported for OS/2 with
; a Video Seven V-RAM VEGA VGA card
; version 1.04. My guess is that the
; INT 10H to find out color/mono
; caused the problem.
;
; 11/20/88 2.07 Tom Hensel Last fix broke DOS version
; Beta 16
;
; 01/19/89 2.08 Tom Hensel Fix warning message
; Beta 1
;
; 01/25/89 2.08 Tom Hensel True blue IBM VGA cards don't
; Beta 2 handle read/write for the Attribute
; Controller Registers (thus violating
; their own spec), so we have to
; initialize these like we do the EGA
; (by reaching into a hardcoded BIOS
; location, yuck!)
;
; SetMode for VGA handled incorrectly.
; Was doing it twice, with a bogus
; video mode the second time.
;
; 02/09/89 2.09 Tom Hensel Added queue for message pointers
; Needed since VGA does a set mode
; near the end, so we need to queue
; up the messages and display them
; on the cleared screen (and avoid
; having the messages wiped out)
;
; 06/20/89 2.10 Tom Hensel Efficiency
; Beta 1
;
; 06/28/89 2.10 Tom Hensel Bug fix for open file handles
; Beta 2
;
; 07/19/89 2.10 Tom Hensel Efficiency
; Beta 3
;
; 08/08/89 2.10 Tom Hensel Fix stack bugs in ContextInfo and
; Beta 4 GetContextSize caused by efficiency
;
; 08/08/89 2.10 Tom Hensel Fix problem with FontBank for VGA
; Beta 5
;
; 08/14/89 2.10 Tom Hensel Efficiency
; Beta 6
;
; 08/15/89 2.10 Tom Hensel Handle IBM kludge correctly
; Beta 7
;
; 08/16/89 2.10 Tom Hensel Beef up IOdelay usage (machines are
; Beta 8 getting faster these days)
;
; 09/21/89 2.10 Tom Hensel Handle interrupt flag state better
; Beta 9
;
; 11/07/89 2.10 Tom Hensel Initialize biosinfo3 earlier since
; Beta 10 ChangeRegs needs it
;
; 11/16/89 2.10 Tom Hensel Fix bug in WriteChar and bug in
; Beta 11 Int10Routine reported by amitc
;
; 11/30/89 2.10 Tom Hensel Still some problems with noclear bit
; Beta 12
;
; 12/01/89 2.10 Tom Hensel Added ReadVGARegs routine
; Beta 13
;
; 12/04/89 2.10 Tom Hensel Fix label problem from Beta 13
; Beta 14
;
; 12/05/89 2.10 Tom Hensel Better method of passing AL
; Beta 15 to ChangeRegs. Fix biosmode problem
; Boundary check in GetLatchLocation
;
; 12/20/89 2.10 Tom Hensel Fix bad initialization of Attr regs
; Beta 16
;
; 1/3/90 2.10 Tom Hensel Another try to fix Beta 16 problem
; Beta 17
;
; 1/29/90 2.10 Ken Robertson Enable interrupts whenever possible
; Beta 18 during ReadVGARegs.
;
; 4/5/90 2.11 Ken Robertson Disable interrupts during register
; Beta 1 write routines.
;
; 6/4/90 2.11 Tom Hensel Add INT 2FH instance code for Win 3.0
; Beta 2
;
; 6/13/90 2.11 Tom Hensel Efficiency
; Beta 3
;
; 7/16/90 2.11 Tom Hensel Fix INT 2FH instance code for Win 3.0
; Beta 4
;
; 7/27/90 2.11 Tom Hensel Move Int10Routine into PSP for .COM
; Beta 5 for space efficiency
;
; 7/31/90 2.11 Tom Hensel Efficiency
; Beta 6
;
; 8/07/90 2.11 Tom Hensel Efficiency
; Beta 7
;
; 8/14/90 2.11 Tom Hensel Created CallTableNeeded flag and
; Beta 8 turn it off for OS/2
;
; 9/06/90 2.11 Tom Hensel Efficiency. Better IODelay method
; Beta 9
;
;*****************************************************************************
;
; NOTE: When updating version numbers: comment out the BETA line if the build
; is for a non-beta version
;
;*****************************************************************************
CODE segment word public 'CODE'
assume cs:CODE, ds:nothing, es:nothing, ss:nothing
;
; E Q U A T E S
;
;/*---------------------------------------------------------------------*/
;/* Mouse Driver and Mouse Utility version number file, VERSNUMS.INC */
;/* */
;/* This file can be included both in C and assembly language source */
;/* files. It defines in decimal the values for the major, minor, */
;/* and beta version numbers. To create a release version, comment */
;/* out the line with BetaVers using ;/* for the comment delimeter. */
;/* */
;/* NOTE: The Major and Beta numbers are in decimal, the tens digit of */
;/* the Minor number is in the high byte, ones digit in the low byte. */
;/* */
;/* Thus version 7.43.65 is written as: */
;/* */
;/* MajVersion = 7; */
;/* MinVersion = 43; */
;/* BetaVersion = 65; */
;/* */
;/*---------------------------------------------------------------------*/
MajVersion = 2;
MinVersion = 11;
BetaVersion = 9;
MajVerCharTens equ <(MajVersion / 10) + "0">
MajVerCharOnes equ <(MajVersion MOD 10) + "0">
MinVerCharTens equ <(MinVersion / 10) + "0">
MinVerCharOnes equ <(MinVersion MOD 10) + "0">
ifdef BetaVersion
BetaVerCharTens equ <(BetaVersion / 10) + "0">
BetaVerCharOnes equ <(BetaVersion MOD 10) + "0">
endif ; BetaVersion
FALSE EQU 0
TRUE EQU (NOT FALSE)
IF1 ; Pass 1 of the assembler
IFDEF OS2
%out Assembling as driver for OS/2
IFNDEF SYS
SYS equ OS2 ; OS2 implies SYS driver model
ENDIF ; NOT SYS
ELSE ; NOT OS2
IFDEF SYS
%out Assembling as driver for DOS
ELSE ; NOT SYS
%out Assembling as COM file for DOS
ENDIF ; NOT SYS
ENDIF ; NOT OS2
%out Pass 1
ELSE ; Pass 2 of the assembler
%out Pass 2
ENDIF ; Pass 2 of the assembler
PrintQueueSize equ 7 ; Never need more than 7 messages
; queued up at any given time
; (Actually, could probably get by
; on 5, but burn a couple because
; of the way the QUEUEPRINT macro
; works. Also safer, and only used
; at init time).
CR equ 13 ; ASCII code for carriage return
LF equ 10 ; ASCII code for line feed
subttl Equate definitions for EGA/VGA i/o ports
page
EGA_BASE equ 300h
SEQ_ADDR equ 0C4h ; Sequencer addr register
SEQ_DATA equ 0C5h ; Sequencer data register
SEQ_MAP_MASK equ 02H ; Write plane enable mask
MM_ALL equ 00001111b ; Enable all planes
GRAF_CONT equ 0CEh ; Port for graphics controller
GRAF_ADDR equ 0CEh ; Controller addr register
GRAF_DATA_ROT equ 03H ; Graphics rotate register
DR_SET equ 0h ; Unmodified passthrough
GRAF_MODE_REG equ 05h
MR_SET equ 01h ; Writethrough mode
GRAF_MISC_REG EQU 6h ; Graphics misc register
NumGraphicsRegs EQU 9h
GRAF_BIT_MASK equ 08h ; Bit mask register
NumSeqRegs EQU 5h ; Note BIOS only has data for 4
SeqClMReg EQU 1h
CRTCAddr EQU 3D4h ; Will change to 003B4 if mono
NumCRTCRegs EQU 19h
AttCtrlAddrReg EQU 3C0h
NumAttrRegs EQU 15h ; Note extra one for VGA
PaletteAddressSource EQU 00100000b
MiscAddr EQU 3C2h
MiscOutputRegR EQU 3CCH
FeatureCtrlReg EQU 3CAH
FeatAddr EQU 3DAh ; Will change to 003BA if mono
Gr1PosAddr EQU 3CCh
Gr2PosAddr EQU 3CAh
NumPtrData EQU 4 ; Number of chips using indices
ReadRegNum EQU 0F0H
WriteRegNum EQU 0F1H
InquireDriverNum EQU 0FAH
EGAShadowStart EQU 0F0H
EGAShadowEnd EQU 0FAH
ifdef OS2
CallTableNeeded EQU false ; TRUE if int 10h call table needed
; (Because > 1 routine supported)
else ; NOT OS2
CallTableNeeded EQU true ; TRUE if int 10h call table needed
; (Because > 1 routine supported)
endif ; NOT OS2
;
; Non visible EGA/VGA memory layout
;
; Basic Interpreter gets first two bytes for current use (reserved space)
; Basic Interpreter gets next two bytes for future use (reserved space)
; EGA.SYS latch save area byte (reserved space)
; Mouse latch save area byte (reserved space)
; Remaining reserved space
; Cursor save area
; Buffer for screen under the cursor
;
NonVisibleStartOff_D EQU (320 / 8) * 200
NonVisibleStartOff_E EQU (640 / 8) * 200
NonVisibleStartOff_F_10 EQU (640 / 8) * 350
NonVisibleStartOff_11 EQU (640 / 8) * 480
NonVisibleStartOff_12 EQU (640 / 8) * 480
NonVisibleStartOff_13 EQU (320 / 8) * 200 * 8 ; * 8 because of 256 colors
EGALatchOff_D EQU NonVisibleStartOff_D + 4
EGALatchOff_E EQU NonVisibleStartOff_E + 4
EGALatchOff_F_10 EQU NonVisibleStartOff_F_10 + 4
EGALatchOff_11 EQU NonVisibleStartOff_11 + 4
EGALatchOff_12 EQU NonVisibleStartOff_12 + 4
EGALatchOff_13 EQU NonVisibleStartOff_13 + 4
;
; The following equates are device driver definitions
;
IFDEF SYS
B$DONE EQU 0000000100000000B
;B$BUSY EQU 0000001000000000B
B$ERROR EQU 1000000000000000B
B$UnknownUnit EQU 1
B$DNR EQU 2
B$UnknownCommand EQU 3
B$GeneralFailure EQU 0CH
MAX_FUNCTION EQU 16 ; Maximum function number
; (Output Until Busy function)
ENDIF ; SYS
IFNDEF OS2
ifndef sys
GetCodeLength EQU 7 ; Return length of resident code
GetINT2F EQU 8 ; Return original vector function code
GetINT10 EQU 9 ; Return original vector function code
Int2FPatternCom EQU 'AH' ; Choose my sister's initials
; to identify us
OpIntRoutineLength = 0EAh ; Size of Int10Routine
if CallTableNeeded
OpIntRoutineLength = OpIntRoutineLength + 37h
endif ; CallTableNeeded
OrgStartOfData equ 5CH + OpIntRoutineLength ; Location to start data at
; This is because of relocation into
; PSP of Int10Routine
endif ; NOT sys
GetInstalledState EQU 0 ; Return installed state function code
GetVersionNumber EQU 6 ; Return version number
MyInt2FNumber EQU 0BCH ; An arbitrary choice
MinValidNumber EQU 80H ; DOS gets 00 - 7F (AH)
MaxValidFunction EQU 0F7H ; DOS gets F8 - FF (AL)
Int2FPatternSys EQU 'TV' ; Choose Tina Vandersteel's initials to
; identify us (Who's Tina Vandersteel?
; Tina is Ann's sister.
; Who's Ann Vandersteel?
; Think beautiful blonde California
; type and you'll be on the right
; track, but that's another story...)
ENDIF ; NOT OS2
;
; M A C R O S
;
subttl Macro definitions
page
IOdelay macro
call HandleIODelay
endm
DoVersion macro
if MajVerCharTens - "0"
db MajVerCharTens
endif ; MajVerCharTens - "0"
db MajVerCharOnes
db '.'
db MinVerCharTens, MinVerCharOnes
ifdef BetaVersion
db '.'
db BetaVerCharTens, BetaVerCharOnes
endif ; BetaVersion
endm
;
; It has been found that some systems cannot handle the rapid back-to-back io
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?