📄 lltext.asm
字号:
TITLE LLTEXT - text screen mode support
;***
;LLTEXT - text screen mode support
;
; Copyright <C> 1986, Microsoft Corporation
;
;Purpose:
; Support for text screen modes (BIOS 0,1,2,3,7).
; Note that this module module contains support
; code for all adapters capable of handling these
; screen modes and also attempts to compensate for
; the subtle differences in their treatment.
;
; This module sets hooks in the mode-independent
; modules to routines here for mode-dependent
; graphics support. See the mode-independent
; modules for more precise descriptions of the
; purposes and interfaces of these routines.
;
; The following table summarizes the information for
; the modes and configurations covered:
;
; C | A B
; O | B T I
; L | I T P T
; O A M | O R A C S
; S R D O | S I C G H / P
; C B A N | B O E A P P L
; R U C R P I | M U L X Y S R A I A
; E R O O T T | O T O R R I B G X N
; E S L W E O | D E R E E Z O E E E
; N T S S R R | E S S S S E X S L S
; -- - -- -- - -- | -- --- ---- --- --- --- ---- --- - -
; 0 0 40 25 C x | 0 16 N/A 320 200 2 8x8 8
; 0 x 40 25 m x | " " " 320 400 " 8x16 "
; 0 0 40 25 E C | " " 16 320 200 " 8x8 "
; 0 x 40 25 E E | " " 64 320 350 " 8x14 "
; 0 x 40 25 V x | " " " 360 400 " 9x16 "
; 0 x 40 43 E E | " " " 320 350 4 8x8 " (4 pgs w/64K)
; 0 x 40 43 V x | " " " 320 350 " 8x8 "
; 0 x 40 50 V x | " " " 320 400 8 8x8 4
; 0 1 40 25 C x | 1 " N/A 320 200 2 8x8 8
; 0 1 40 25 E C | " " 16 320 200 " 8x8 "
; 0 0 80 25 C x | 2 " N/A 640 200 4 8x8 4
; 0 x 80 25 m x | " " " 640 400 " 8x16 8
; 0 0 80 25 E C | " " 16 640 200 " 8x8 " (4 pgs w/64K)
; 0 x 80 25 E E | " " 64 640 350 " 8x14 " (4 pgs w/64K)
; 0 x 80 25 V x | " " " 720 400 " 9x16 "
; 0 x 80 43 E E | " " " 640 350 8 8x8 4 (2 pgs w/64K)
; 0 x 80 43 V x | " " " 640 350 " 8x8 "
; 0 x 80 50 V x | " " " 640 400 " 8x8 "
; 0 1 80 25 C x | 3 " N/A 640 200 4 8x8 "
; 0 1 80 25 E C | " " 16 640 200 " 8x8 8 (4 pgs w/64K)
; 0 x 80 25 M M | 7 " 3 720 350 " 9x14 1
; 0 x 80 25 E M | " " " 720 350 " 9x14 8 (4 pgs w/64K)
; 0 x 80 25 V x | " " " 720 400 " 9x16 "
; 0 x 80 43 E M | " " " 720 350 8 8x8 4 (2 pgs w/64K)
; 0 x 80 43 V x | " " " 720 350 " 8x8 "
; 0 x 80 50 V x | " " " 720 400 " 8x8 "
;
;******************************************************************************
INCLUDE switch.inc ;feature switches
INCLUDE rmacros.inc
USESEG _BSS
USESEG _DATA
USESEG GR_TEXT
USESEG CN_TEXT
INCLUDE seg.inc
INCLUDE ibmunv.inc
INCLUDE llgrp.inc ; Constant definitions
INCLUDE grmac.inc ;ModeData macros
INCLUDE oscalls.inc ;Dos 5 structures
sBegin _DATA
externW b$UsrCsrTyp
externB b$InsCsrStop
sEnd _DATA
sBegin _BSS
;
; ***************************************************************************
; External variables
; ***************************************************************************
;
externB b$BiosMode
externW b$ModeBurst
externW b$CurPages
externB b$ScreenMode
externB b$ScrWidth
externD b$InitPalette
externB b$MaxAttr
externB b$MaxColor
globalW b$PageTable,,8 ;Offset to start of each video page
externB b$OrgBiosMode
externB b$Monitor
externB b$Adapter
externW b$VideoMem
externB b$PageSize
externB b$MaxPage
externB b$ScrHeight
externB b$ForeColor
externW b$FBColors
externB b$CharColor
externW b$CurrPSize
externB b$NullColor
externW b$DSP
externW b$CURSOR
externW b$CSRTYP
;
; ***************************************************************************
; Local variables
; ***************************************************************************
;
externB b$BorderColor ;border color (overscan)
sEnd _BSS
sBegin CN_TEXT
externNP B$USRCSR
sEnd CN_TEXT
assumes CS,GR_TEXT
sBegin GR_TEXT
externNP B$InitModeData
externNP B$GetParm
externNP B$EgaPalReset
externNP B$EgaPalResetB
externNP B$EgaPalPut
externNP B$EgaPalPutB
externNP B$EgaPalTrans
externNP B$EgaPalSet
externNP b$ColorPalette
externNP b$EnhPalette
;
; PAGE SIZES for each screen dimension possibility:
;
; These are calculated here as the BIOS initializes them (for the 25-line
; cases), or as it calculates them (for the 43/50-line cases). The added
; "slop" separates the pages and apparently eases scrolling troubles
; while increasing our troubles.
;
; NOTE: 4 pages of 80x50 is 8100H bytes, 100H over the 8000H max for the
; memory map, but 100H is the 256 byte slop between pages, so its OK.
; BUT, 8 pages of 40x50 is 8500H which is more than the slop will
; allow so we cut the supported pages in half to 4 in the code.
; (40x50 could actually support 7 pages, but 4 is a nicer number??)
;
P40x25 EQU ((40*25*2+255) AND (NOT 255)) SHR 4 ;0800H bytes
P80x25 EQU ((80*25*2+255) AND (NOT 255)) SHR 4 ;1000H bytes
P40x43 EQU (40*43*2+256) SHR 4 ;0E70H bytes
P80x43 EQU (80*43*2+256) SHR 4 ;1BE0H bytes
P40x50 EQU (40*50*2+256) SHR 4 ;10A0H bytes [4]
P80x50 EQU (80*50*2+256) SHR 4 ;2040H bytes [4]
;===========================================================================
mModeData Mode0Data
;
; SCREEN 0, BIOS modes 0 & 1
;
; Mode-dependent data follows to initialize the the "b$ModeData" table
; in LLCGRP.
;
;===========================================================================
mScreenMode 0
mBiosMode 0 ;BIOS mode and burst may be adjusted later
mBurst 0
mScrWidth 40
mScrHeight 25
mHorzRes 320
mVertRes 200
mVideoBase 0B800H
mMaxAttr 15
mMaxColor 63
mPageSize 2 ;page size in K
mCurrPSize P40x25 ;page size in paragraphs (1 plane)
mMaxPage 7
mNullColor 7
mForeColor 7
mBackColor 0
mEgaWrMd 0
mInitPalette b$ColorPalette ;moved to LLXGASUP for sharing
mInitVgaPal b$VgaPalette ;use regular VGA palette
mAlphaDim AlphaDim0
mSetMode SetMode
mSetPages SetPages
mPalReset B$EgaPalReset
mPalPut B$EgaPalPut
mPalTrans B$EgaPalTrans
mPalSet B$EgaPalSet
mSetColor SetColor
mEnd ,TextDataLen
;===========================================================================
;===========================================================================
mModeData Mode2Data
;
; SCREEN 0, BIOS modes 2 & 3
;
; Mode-dependent data follows to initialize the the "b$ModeData" table
; in LLCGRP.
;
;===========================================================================
mScreenMode 0
mBiosMode 2 ;BIOS mode and burst may be adjusted later
mBurst 0
mScrWidth 80
mScrHeight 25
mHorzRes 640
mVertRes 200
mVideoBase 0B800H
mMaxAttr 15
mMaxColor 63
mPageSize 4 ;page size in K
mCurrPSize P80x25 ;page size in paragraphs (1 plane)
mMaxPage 3
mNullColor 7
mForeColor 7
mBackColor 0
mEgaWrMd 0
mInitPalette b$ColorPalette ;moved to LLXGASUP for sharing
mInitVgaPal b$VgaPalette ;use regular VGA palette
mAlphaDim AlphaDim2
mSetMode SetMode
mSetPages SetPages
mPalReset B$EgaPalReset
mPalPut B$EgaPalPut
mPalTrans B$EgaPalTrans
mPalSet B$EgaPalSet
mSetColor SetColor
mEnd ,TextDataLen
;===========================================================================
;===========================================================================
mModeData Mode7Data
;
; SCREEN 0, BIOS mode 7
;
; Mode-dependent data follows to initialize the the "b$ModeData" table
; in LLCGRP.
;
;===========================================================================
mScreenMode 0
mBiosMode 7
mBurst 0
mScrWidth 80
mScrHeight 25
mHorzRes 720
mVertRes 350
mVideoBase 0B000H
mMaxAttr 15
mMaxColor 2
mPageSize 4 ;page size in K
mCurrPSize P80x25 ;page size in paragraphs (1 plane)
mMaxPage 0
mNullColor 7
mForeColor 7
mBackColor 0
mEgaWrMd 0
mInitPalette MonoPalette
mInitVgaPal 0 ;not applicable
mAlphaDim AlphaDim7
mSetMode SetMode
mSetPages SetPages
mPalReset B$EgaPalResetB
mPalPut B$EgaPalPutB
mPalTrans PalTrans7
mPalSet B$EgaPalSet
mSetColor SetColor
mEnd ,TextDataLen
;===========================================================================
;
; MonoPalette - used to initialize the EGA palette for SCREEN 0,
; BIOS mode 7, for a Mono Display.
;
labelB MonoPalette ;EGA palette for Mono Display, mode 7
DB 0 ;black
DB 7 DUP (001000B) ;video
DB 0 ;black
DB 7 DUP (011000B) ;intensified
;***
; B$Screen0
;
;Purpose:
; Establish all relevent mode dependent data values and function
; vectors for BASIC screen mode 0.
; NOTE: No actual change in screen mode occurs until SetMode is called!
;Entry:
; AL = screen mode (0)
; AH = burst (0 or 1)
; CL = alpha columns
;Exit:
; PSW.C = set indicates error
;Uses:
; per conv.
;Exceptions:
;******************************************************************************
cProc B$Screen0,<PUBLIC,NEAR>
cBegin
mov bx,GR_TEXTOFFSET Mode7Data
mov al,7 ;assume mono mode
test b$Monitor,Monochrome ;is this a monochrome monitor?
jnz Scr7 ;go if so
cmp b$Monitor,AnalogMono ; VGA working only in MONO modes?
je Scr7 ; go if so
and al,b$OrgBiosMode;get entry bios mode and mask down to 3 bits
cmp al,7 ;if AL=7 then entry mode was 7 or F (both mono)
je Scr7 ;branch if entry mode was mono. use mode 7
xor al,al ;mode base = 0
mov bx,GR_TEXTOFFSET Mode0Data
cmp cl,40 ;40 columns?
je Got40 ;go if so w/mode base = 0
mov bx,GR_TEXTOFFSET Mode2Data
mov al,2 ;mode base = 2
Got40:
add al,ah ;new BIOS mode = 0/2 if no burst
; 1/3 if burst
Scr7:
mov cx,TextDataLen
push ax
call B$InitModeData ;initialize table data
pop ax
mov b$ModeBurst,ax ;save new mode and burst
test b$Adapter,CGA + MDPA + HGC ;CGA or MDPA or HGC adapters?
jnz SkipPage ;go if so
mov ah,7 ;8 (max=7) pages for EGA/VGA/MCGA w/25 lines
test b$Adapter,EGA ; EGA adapter?
jz MaxPg ; brif not, 8 pages is right
cmp b$VideoMem,64 ; only 64K EGA?
ja MaxPg ; go if more, 8 pages is right
cmp al,1 ;BIOS mode 0 or 1? (40 columns)
jbe MaxPg ;go if so, 8 pages is right
shr ah,1 ;limit to 4 pages (max=3) if 64K EGA & 80x25
MaxPg:
mov b$MaxPage,ah ;save corrected max page value
test b$Monitor,StdColor ;std color monitor?
jz SkipPage ;go if not
mov b$MaxColor,15 ;it can only handle 16 colors
SkipPage:
cmp al,7 ;BIOS mode 7?
jz ScrExit ;if mono, don't setup enhanced palette
test b$Monitor,AnalogColor + AnalogMono + EnhColor
;enhanced or analog monitor?
jz ScrExit ;go if not
;set up enhanced palette for >= enhanced color monitor
mov WORD PTR b$InitPalette,GR_TEXTOFFSET b$EnhPalette
ScrExit:
mov al,b$ForeColor ;set character color for text mode
mov b$CharColor,al
mov b$DSP,770H ;text mode function key attributes
clc ;indicate no error
cEnd
;***
; AlphaDim0
;
;Purpose:
; Validate the proposed text dimensions for 40 column Screen mode 0
; and set up several screen-dependent variables if dimensions are OK.
;Entry:
; BH = number of lines
; BL = number of columns
;Exit:
; If dimensions ok
; PSW.C reset
; AL = -1
; b$MaxPage, b$BiosMode, b$VideoMem, b$CurrPSize,
; and b$ScrHeight set appropriately.
; Else (error)
; PSW.C set
;Uses:
; per conv.
;Exceptions:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -