⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 llvga.asm

📁 [随书类]Dos6.0源代码
💻 ASM
📖 第 1 页 / 共 3 页
字号:
	DB	10H, 08H, 0AH
	DB	10H, 08H, 08H
	DB	10H, 0AH, 08H
	DB	10H, 0CH, 08H
	DB	10H, 0EH, 08H
	DB	10H, 10H, 08H
	DB	0EH, 10H, 08H
	DB	0CH, 10H, 08H
	DB	0AH, 10H, 08H
	DB	08H, 10H, 08H
	DB	08H, 10H, 0AH
	DB	08H, 10H, 0CH
	DB	08H, 10H, 0EH
	DB	08H, 10H, 10H
	DB	08H, 0EH, 10H
	DB	08H, 0CH, 10H
	DB	08H, 0AH, 10H
	DB	0BH, 0BH, 10H
	DB	0CH, 0BH, 10H
	DB	0DH, 0BH, 10H
	DB	0FH, 0BH, 10H
	DB	10H, 0BH, 10H
	DB	10H, 0BH, 0FH
	DB	10H, 0BH, 0DH
	DB	10H, 0BH, 0CH
	DB	10H, 0BH, 0BH
	DB	10H, 0CH, 0BH
	DB	10H, 0DH, 0BH
	DB	10H, 0FH, 0BH
	DB	10H, 10H, 0BH
	DB	0FH, 10H, 0BH
	DB	0DH, 10H, 0BH
	DB	0CH, 10H, 0BH
	DB	0BH, 10H, 0BH
	DB	0BH, 10H, 0CH
	DB	0BH, 10H, 0DH
	DB	0BH, 10H, 0FH
	DB	0BH, 10H, 10H
	DB	0BH, 0FH, 10H
	DB	0BH, 0DH, 10H
	DB	0BH, 0CH, 10H
	DB	00H, 00H, 00H
	DB	00H, 00H, 00H
	DB	00H, 00H, 00H
	DB	00H, 00H, 00H
	DB	00H, 00H, 00H
	DB	00H, 00H, 00H
	DB	00H, 00H, 00H
	DB	00H, 00H, 00H

labelNP <PUBLIC,B$VGAUSED>	

;***
; B$Screen11
;
;Purpose:
;	Establish all relevent mode dependent data values and function
;	vectors for BASIC screen mode 11.
;Entry:
;	AL = screen mode (11)
;	AH = burst (0 or 1)
;	CL = alpha columns
;Exit:
;	PSW.C = set indicates error
;Uses:
;	per conv.
;Exceptions:
;******************************************************************************
cProc	B$Screen11,<PUBLIC,NEAR>
cBegin
	MOV	BX,GR_TEXTOFFSET Mode11Data  ;mode-specific data
	TEST	b$Monitor,AnalogColor ;must be analog supporting color
	JZ	ScrErr		;exit w/error if not
	TEST	[b$VGAmodesH],VGAmode11h ; hardware supports BIOS mode 11h? 
	JZ	ScrErr		; exit w/error if not
	;set up variables for shared CGA/HGC line code
	mov	b$UpSub,80	;subtract 80 to move up a line
	mov	b$DnSub,-80	;subtract -80 (add 80) to move down a line
	mov	b$UpDnAdd,0	;no correction necessary
	JMP	SHORT ScrCommon ;common routine
cEnd	<nogen>

;***
; B$Screen12
;
;Purpose:
;	Establish all relevent mode dependent data values and function
;	vectors for BASIC screen mode 12.
;Entry:
;	AL = screen mode (12)
;	AH = burst (0 or 1)
;	CL = alpha columns
;Exit:
;	PSW.C = set indicates error
;Uses:
;	per conv.
;Exceptions:
;******************************************************************************
cProc	B$Screen12,<PUBLIC,NEAR>
cBegin
	MOV	BX,GR_TEXTOFFSET Mode12Data  ;mode-specific data
	TEST	b$Monitor,AnalogColor ;must be analog supporting color
	JZ	ScrErr		;exit w/error if not
;	TEST	b$Adapter,VGA	;must be VGA
	TEST	[b$VGAmodesH],VGAmode12h ; hardware supports BIOS mode 12h? 
	JZ	ScrErr		;exit w/error if not
ScrCommon:
	MOV	CX,GraphDataLen 
	CALL	B$InitModeData ;initialize table data
	CLC			;indicate no error
cEnd

;*** 
; B$Screen13
;
;Purpose:
;	Establish all relevent mode dependent data values and function
;	vectors for BASIC screen mode 13.
;Entry:
;	AL = screen mode (13)
;	AH = burst (0 or 1)
;	CL = alpha columns
;Exit:
;	PSW.C = set indicates error
;Uses:
;	per conv.
;Exceptions:
;******************************************************************************
cProc	B$Screen13,<PUBLIC,NEAR>
cBegin
	MOV	BX,GR_TEXTOFFSET Mode13Data  ;mode-specific data
	TEST	b$Monitor,AnalogColor ;must be analog supporting color
	JZ	ScrErr		; exit w/error if not
	TEST	[b$VGAmodesH],VGAmode13h ; hardware supports BIOS mode 13h? 
	JNZ	ScrCommon	;out through common exit if ok
SCrErr:
	STC			;signal error and exit
cEnd

;***
; AlphaDim_11_12
;
;Purpose:
;	Validate the proposed text dimensions for Screen 11 or Screen 12.
;	  If 80x30 or 80x60 is requested, this mode satisfies the request
;	  else suggest screen mode 0.
;Entry:
;	BH = number of lines
;	BL = number of columns
;Exit:
;	AL = -1 if this mode satisfies the request, otherwise
;		AL is suggested screen mode to invoke for desired dimensions
;	b$ScrHeight set to value in BH if this mode satisfies request
;Uses:
;	per conv.
;Exceptions:
;******************************************************************************
DbPub	AlphaDim_11_12
cProc	AlphaDim_11_12,<NEAR>
cBegin
	MOV	AL,-1		;flag request satisfied (maybe)
	CMP	BX,80+30*256	;80x30?
	JE	ADimSet 	;exit if so, standard stuff
	CMP	BX,80+60*256	;80x60?
	JE	ADimSet 	;exit if so, standard stuff
	XOR	AL,AL		;flag request for screen 0
	JMP	SHORT ADimOk	;  and exit
cEnd	<nogen>

;***
; AlphaDim_13
;
;Purpose:
;	Validate the proposed text dimensions for Screen 13.
;	If 40x25 is requested, this mode satisfies the request
;	else suggest screen mode 0.
;Entry:
;	BH = number of lines
;	BL = number of columns
;Exit:
;	AL = -1 if this mode satisfies the request, otherwise
;		AL is suggested screen mode to invoke for desired dimensions
;	b$ScrHeight set to value in BH if this mode satisfies request
;Uses:
;	per conv.
;Exceptions:
;******************************************************************************
DbPub	AlphaDim_13
cProc	AlphaDim_13,<NEAR>
cBegin
	MOV	AL,-1		;flag request satisfied (maybe)
	CMP	BX,40+25*256	;40x25?
	JE	ADimSet 	;exit if so, standard stuff
	XOR	AL,AL		;flag request for screen 0
	JMP	SHORT ADimOk	;  and exit

ADimSet:
	mov	b$ScrHeight,bh ;set alpha rows
ADimOk:
	clc			;no error
cEnd

;***
; SetMode
;
;Purpose:
;	Set VGA screen mode according to the characteristics established
;	by previous call to B$Screenx and b$AlphaDim.  Set 8x8 character
;	font if new mode is to be 60 lines.
;Entry:
;	b$BiosMode is mode to set
;	b$ScrHeight is number of lines
;Exit:
;	None
;Uses:
;	per conv.
;Exceptions:
;******************************************************************************
cProc	SetMode,<NEAR>
cBegin
	MOV	AL,b$BiosMode	;set BIOS mode
	SCNIO	vSetMode
	CMP	b$ScrHeight,60 ;60 lines?
	JNE	NormalHeight
	MOV	DL,60		; char gen call wants # of lines in DL
	MOV	AX,1123H	;character generator request
	XOR	BL,BL		;  to load 8x8 font
	SCNIO			;  which gets 60 lines
NormalHeight:
	MOV	DX,b$CURSOR	; Get current cursor position
	MOV	BYTE PTR b$CSRTYP,-1	; invalidate present cursor type so
				; it will get changed
	CALL	B$USRCSR	; display user cursor
cEnd

;***
; SetPages
;
;Purpose:
;	Set the current active and visual pages and video segment for
;	Screen modes 11, 12, and 13.
;Entry:
;	AL = active page (will always be 0 for these modes)
;	AH = visual page (will always be 0 for these modes)
;Exit:
;	b$CurPages set to new active and visual pages
;	b$SegC set to video segment
;Uses:
;	per conv.
;Exceptions:
;******************************************************************************
cProc	SetPages,<NEAR>
cBegin
DbAssertRel	AX,E,0,GR_TEXT,<Non-zero page requested in VGA SetPages (LLVGA)>
	mov	b$CurPages,ax	;save page numbers
	mov	ax,b$VideoBase ;set video segment
	mov	b$SegC,ax
cEnd

;***
; SetColor
;Purpose:
;	Process the color statement for Bios mode 12h-13h (BASIC Screen
;	modes 12-13).  Syntax for Screen 12-13 color statement is as follows:
;
;		COLOR	[foreground]
;
;	where "foreground" is the attribute to be used for the foreground
;
;Entry:
;	parameter list
;Exit:
;	PSW.C set error, reset if Ok.
;	b$ForeColor is set to foreground attribute
;	b$ForeMapped is set to foreground attribute mapped to internal value
;
;Uses
;	per conv.
;Exceptions:
;***************************************************************************
cProc	SetColor,<NEAR>
cBegin
DbAssertRelB	b$ForeColor,E,b$ForeMapped,GR_TEXT,<b$ForeColor NE b$ForeMapped in SetColor (LLVGA)>
	cCall	B$GetParm	;AL=foreground parameter
	MOV	BH,b$ForeColor ;use old values as default
	JZ	GotFore 	;go if none supplied
	CMP	AL,b$MaxAttr	;legal attribute?
	JA	ColorError	;branch if out of range
	MOV	BH,AL		;attribute to BH
GotFore:
	MOV	b$ForeColor,BH ;save foreground values
	MOV	b$ForeMapped,BH
	CLC			;indicate no error
	JCXZ	SetColDun	;if we got all params, thats true
ColorError:
	STC			;otherwise set error
SetColDun:
cEnd

;***
; PalReset_13
;
;Purpose:
;	Reset the PALETTE to the initial, default colors for Screen 13.
;Entry:
;	None
;Exit:
;	None
;Uses:
;	per conv.
;Exceptions:
;	exits through B$VgaPalReset common exit
;******************************************************************************
DbPub	PalReset_13
cProc	PalReset_13,<NEAR>,<ES>
cBegin
	push	cs
	pop	es
	mov	cx,256		;set 256 color palette registers
	jmp	short PalResetCommon
cEnd	<nogen>

;***
; B$VgaPalReset
;
;Purpose:
;	Reset the PALETTE to the initial, default colors for Screen 11
;	or Screen 12.  If EGA palette is supported, initialize it to
;	be map directly to the VGA DAC so it is transparent to the user.
;Entry:
;	None
;Exit:
;	None
;Uses:
;	per conv.
;Exceptions:
;******************************************************************************
cProc	B$VgaPalReset,<NEAR>,<ES>  
cBegin
	push	cs
	pop	es
	cmp	b$EgaPalSup,0	;support for EGA PALETTE?
	jz	NoEgaPal	;go if not
	mov	al,10H		;sub-function 10H, set VGA palette entry
	mov	bx,16		;VGA palette index to be used for overscan
	xor	dx,dx		;clear color to black
	xor	cx,cx		
	SCNIO	vSetEgaPalette	;set the overscan register in VGA palette
	;if there is an EGA palette we need to make it transparent
	mov	dx,GR_TEXTOFFSET Mode11Palette
	cmp	[b$biosMode], 11h ;[16] correct bios mode for this table?
	je	PalOk		;[16] brif so
	mov	dx, GR_TEXTOFFSET Mode12Palette ;[16] else use Mode 12 table
PalOk:

	mov	al,2		;BIOS sub-function - set all palette registers
				;and the overscan register (for border color)
	SCNIO	vSetEgaPalette	;set the palette
NoEgaPal:
	mov	cx,16		;set 16 color palette registers
PalResetCommon:
	xor	bx,bx		;starting at register 0
	mov	dx,GR_TEXTOFFSET b$VgaPalette
	mov	al,12H		;BIOS sub-function - set block of VGA DAC
				;palette registers
	SCNIO	vSetEgaPalette	;set the palette
cEnd

;***
; B$VgaPalPut
;
;Purpose:
;	Change palette entry for VGA modes with translation/verification.
;	A color value of -1 indicates that the associated palette entry
;	is not to be modified.
;Entry:
;	AX = color
;	BL = attribute
;Exit:
;	PSW.C reset indicates successful operation
;		set indicates PALETTE function call error
;Uses:
;	per conv.
;Exceptions:
;******************************************************************************
cProc	B$VgaPalPut,<NEAR>	
cBegin
	cmp	ax,-1		;lo word of color == -1?
	jne	PalPut1 	;go if not, can't ignore
	cmp	dx,ax		;hi word too?
	je	PalPutExit	;exit if color == -1
PalPut1:
	call	[b$PalTrans]	;translate to external form
	jc	PalPutExit	;exit if invalid w/error
	mov	bh,dh		;bx=attribute (bh=0)
	xchg	dh,al		;dh=red
	xchg	ch,ah		;ch=green
	xchg	cl,dl		;cl=blue
	mov	al,10H		;subfunction "Set Individual Color Register"
				;  for VGA DAC color palette
	SCNIO	vSetEgaPalette	;set VGA palette entry
	clc			;no error
PalPutExit:
cEnd

;***
; B$VgaPalTrans11/PalTrans_12/PalTrans_13
;
;Purpose:
;	Verify that user supplied attribute value and color value are
;	within the legal range for Screen 12 or Screen 13, depending
;	on entry point.
;	An attribute translation is required for mode 11.
;	It somehow always maps the 1-bit pixel to palette index 0FH
;	(which is bright-white on the VGA palette).  Thus to change the
;	color for attribute 1 we must manipulate entry 0FH of the VGA
;	palette.
;	NOTE: B$VgaPalTrans11 is also used by mode 6 (SCREEN 2) in QCG
;	      with an MCGA.
;Entry:
;	DX:AX = user supplied color value
;	BL    = user supplied attribute value
;Exit:
;	PSW.C set if illegal value, reset if Ok
;	DX:AX = unchanged
;	BL    = unchanged
;Uses:
;	per conv.
;Exceptions:
;******************************************************************************

cProc	B$VgaPalTrans11,<PUBLIC,NEAR>
cBegin
	cmp	bl,1		;is legal attribute ?
	ja	PalTrErr	;error return
	neg	bl		;leave 0 alone
	and	bl,0Fh		;0=0 1=0F
	jmp	short PalTrExit
cEnd	<nogen>

DbPub	PalTrans_12
DbPub	PalTrans_13
cProc	PalTrans_12,<NEAR>
cBegin
	cmp	bl,15		;is legal attribute ?
	ja	PalTrErr	;error return

labelNP PalTrans_13		;any byte value for mode 13 is OK!!

PalTrExit:
	test	dx,0FFC0H	;only lo 6 bits of color hi word allowed
	jnz	PalTrErr	;error return
	test	ax,0C0C0H	;only lo 6 bits of bytes in lo word allowed
	jnz	PalTrErr	;error return
	clc			;no error
	ret
PalTrErr:
	stc			;indicate error
cEnd

;***
; PalSet
;
;Purpose:
;	Set the entire VGA palette for Screens 11/12/13 from an array where
;	an element value of -1 indicates the entry should be left alone.  All
;	entries are verified before any are set.
;
;	This routine doesn't really do any of the work; it just verifies that
;	the specified array is of I4 (long integers) and then passes off to
;	B$EgaPalSet which does the actual palette setting.
;Entry:
;	AX    = size of array in elements
;	ES:SI = address of array
;	CX    = size of each array element in bytes (2 or 4)
;Exit:
;	PSW.C set if array is not I4
;Uses:
;	per conv.
;Exceptions:
;******************************************************************************
DbPub	PalSet
cProc	PalSet,<NEAR>
cBegin
	cmp	cx,4		;must be array of I4 (long) words
	jne	PalTrErr	;exit if not w/error
	jmp	B$EgaPalSet	;B$EgaPalSet uses b$PalTrans and b$PalPut
				;  for generality and works for us too
cEnd	<nogen>


;NOTE: b$MaskC should be set to 0FFH and left there!!!

;***
; MapXYC_13
;
;Purpose:
;	Map given X and Y coordinates to the graphics cursor for Screen 13.
;Entry:
;	CX = X coordinate
;	DX = Y coordinate
;Exit:
;	b$OffC, b$MaskC updated
;Uses:
;	per conv.
;Exceptions:
;******************************************************************************
DbPub	MapXYC_13
cProc	MapXYC_13,<NEAR>
cBegin
	mov	ax,cx		;save x
	mov	bx,dx		;multiply y by 320 to compute row displacement
	shl	dx,1		;dx=2*Y
	shl	dx,1		;dx=4*Y
	add	dx,bx		;dx=5*Y
	mov	cl,6		
	shl	dx,cl		;dx=5*Y*64=320*Y
	add	ax,dx		;add x byte offset to y row address
	mov	b$OffC,ax	;save byte offset

	;NOTE:	b$MaskC should be set to 0FFH and left there for mode 13!!!
	;	But, some higher level code uses it for generality.

	mov	b$MaskC,0FFH
cEnd

;***
; SetAttr_13
;
;Purpose:
;	Set current attribute to user-supplied value for Screen 13.
;	No error checking needs to be done because the input value is
;	a byte and the legal range for Screen 13 is 0-255.
;Entry:
;	AL = attribute to set
;Exit:
;	b$AttrC set to user-supplied attribute
;Uses:
;	per conv
;Exceptions:
;******************************************************************************
DbPub	SetAttr_13
cProc	SetAttr_13,<NEAR>
cBegin
	mov	b$AttrC,al
	clc			;exit no error
cEnd

;NOTE:	LeftC, ChkUpC, UpC, ChkDownC, DownC, SetAttr use EGA
;NOTE:	SetColor use VGA

;***
; ReadC_13
;
;Purpose:
;	Return the attribute of the pixel defined by the current
;	graphics cursor.
;Entry:
;	b$AddrC specifies pixel to read
;Exit:
;	AL = attribute of pixel
;Uses:
;	per conv.
;Exceptions:
;******************************************************************************
DbPub	ReadC_13
cProc	ReadC_13,<NEAR>,<DS>
cBegin
	lds	bx,b$AddrC	;get memory address of cursor
	mov	al,[bx] 	;return with attribute in [al]
cEnd

;***
; SetC_13
;
;Purpose:
;	Set the pixel defined by the current graphics cursor to the
;	current attribute.
;Entry:
;	b$AddrC specifies pixel to set
;	b$AttrC = attribute to use
;Exit:
;	None
;Uses:
;	per conv.
;Exceptions:
;******************************************************************************
DbPub	SetC_13
cProc	SetC_13,<NEAR>,<DS>
cBegin
	mov	al,b$AttrC	;[al] = attribute
	lds	bx,b$AddrC	;[BX] = cursor offset, [DS] = segment
	mov	[bx],al 	;set color value
cEnd

;***
; SetPixC_13
;
;Purpose:
;	Set the pixel defined by the current graphics cursor to the

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -