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

📄 tvmpc.asm

📁 X86 GX1 BOOTLOAD代码 ,支持WINCE操作系统!
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;**************************************************************************
;*
;*  TVMPC.ASM
;*
;*  Copyright (c) 1998-1999 National Semiconductor Corporation.
;*  All Rights Reserved.
;*
;*  Function:
;*    GEODE_SCxxxx TV-out interface
;*
;*  Revision: 5 $
;*
;**************************************************************************
	.486P

	INCLUDE DEF.INC
	INCLUDE MACROS.INC
	INCLUDE PORT80.INC
	INCLUDE MPC.inc
	INCLUDE NSSIO.inc
	INCLUDE OPTIONS.inc
	INCLUDE strings.inc
	INCLUDE BDCFG.INC
	INCLUDE	nvramtok.inc


_TEXT SEGMENT PUBLIC use16 'CODE'

	assume 	DS:NOTHING,ES:NOTHING
PUBLIC	TV_Init
PUBLIC  Geode_Video_Interface
EXTERN	CpuMemRegReadStack:NEAR
EXTERN	CpuMemRegWriteStack:NEAR
;;;;EXTERN	GetNVRAMValue:near
;;;;EXTERN	SetNVRAMValue:near

;EXTERN  Return_DDC2_Status:NEAR
;EXTERN  Return_DDC2_Information:NEAR

GEODE_TVOUT_ID	EQU	1

REG32	STRUCT
	Reg_index	WORD	?
	AND_val		DWORD	?
	OR_val		DWORD	?
REG32	ENDS

VIDEO_TIMINGS STRUCT
	fpResolution	BYTE	?
	fpControl	BYTE	?
	fpDither	BYTE	?
	fpClockFreq	BYTE	?
	fpHtotal	BYTE	?
	fpVtotal	BYTE	?
	fpHsyncStart	BYTE	?
	fpHsyncEnd	BYTE	?
	fpVsyncStart	BYTE	?
	fpVsyncEnd	BYTE	?
	crtHsyncStart	BYTE	?
	crtHsyncEnd	BYTE	?
	crtVsyncStart	BYTE	?
	crtVsyncEnd	BYTE	?
VIDEO_TIMINGS ENDS

;TV_ATTRIBUTES STRUCT
;	Format	BYTE	?
;	Mode		BYTE	?
;	Output	BYTE	?
;	HPosition	BYTE	?
;	VPosition	BYTE	?
;TV_ATTRIBUTES ENDS

TVOUT_REG	MACRO Reg_index, AND_val, OR_val
	REG32	<Reg_index, AND_val, OR_val>
ENDM

END_OF_REGTBL	MACRO
	DW	0FFFFh
ENDM

;               NTSC
; ====================================
; TV Sampling pixel clock	: 13.5MHz
; Vertical refresh Rate		: 60Hz
; Total Horizontal pixels	: 858
; Active Pixels in a Line	: 720
; Lines per frame			: 525
; Active Lines per Frame	: 480
NTSC_Common:
	; Horizontal Display start is 108
	; # of pixels per line is 857
	TVOUT_REG	GEODE_TVOUT_HORIZONTAL_TIMING,	0FFF0FFFh, 006c0359h
	; Horizontal Sync End is 856
	; Horizontal Sync Start is 848
	TVOUT_REG	GEODE_TVOUT_HORIZONTAL_SYNC,	0FFF0FFFh, 03580350h
	; Vertical Sync Start is 0
	; Vertical Sync End is 1
	; Vertical Display Start Skew is 1
	; Vertical Display End Skew is 1
	TVOUT_REG	GEODE_TVOUT_VERTICAL_SYNC,	0FFFFF3FFh, 05001000h
	; Horizontal display end is 911
	; # of lines per field is 240
	TVOUT_REG	GEODE_TVOUT_DISPLAY_LINE_END,	0FFF01FFh, 038F00F0h
	; HSYNC generated in the Encoder module
	; The interval between resets is the next odd field
	; Take 1/4 of skipped line
	TVOUT_REG	GEODE_TVOUT_HORIZONTAL_CTRL,	0FF000000h, 10000000h
	; Add the IRE offset, NTSC color encoding, 525 lines/60Hz,
	; VPHASE is 525, HPHASE is 858
	; Enable FrameRef
	; Reset Sub Carrier every two lines
	TVOUT_REG	GEODE_ENCODER_CTRL1,		0FFCFFFFFh, 0A2E01000h
	; COMPOSITE OR S-VIDEO
	TVOUT_REG	GEODE_ENCODER_CTRL2,		0BFFCFFFFh, 009ff000F9h
	; Subcarrier Frequency is 3.579545MHz
	TVOUT_REG	GEODE_ENCODER_SUBCARRIER_FREQ,	0FFFFFFFFh, 21F12000h
	; VSTART is 3, HSTART is 113
 	TVOUT_REG	GEODE_ENCODER_DISPLAY_POSITION,	01FF03FFh, 00030071h
	; Display size: HEIGHT is 239, WIDTH is 719
	TVOUT_REG	GEODE_ENCODER_DISPLAY_SIZE,	01FF03FFh, 00EF02CFh
        ; DAC control register: Adjusts the internal voltage reference
	TVOUT_REG	GEODE_ENCODER_DAC_CTRL,		 000000FFh, 00000005h
END_OF_REGTBL		

;          NTSC 640x480
; ====================================
; CRT Resolution			: 640x480
; NTSC Resolution			: 720x480
; Pixel Clock				: 25MHz (40ns)
; 
; Horzontal Down Scaling	: Disable
; Vertical Down Scaling		: Disable
; Horizontal Up Scaling		: 9/8
; Vertical Up Scaling		: Disable
;
; 2 CRT Lines = 1 TV Line
; 1 CRT Line = 858*74*(1/2) = 31746ns
; # of pixels/Line = 31746/40 = 793 (792)
NTSC_640:
	; Enable Horizontal up scaling 9/8, the Vdown pattern is 8 bits
	; Enable Horizontal interpolation
	; Disable Horizontal downsacle: 0 out of 1, when m is 0
	TVOUT_REG	GEODE_TVOUT_HORIZONTAL_CTRL,	003F33FFh, 00221700h
	; Disable vertical down scaling, take all lines
	TVOUT_REG	GEODE_TVOUT_VERTICAL_DOWN_SCALE,0FFFFFFFFh, 0FFFFFFFFh
	; The total number of pixels per line: 793 (792)
;	TVOUT_REG	GEODE_TVOUT_HORIZONTAL_TIMING,	 000007FFh, 00000318h
END_OF_REGTBL		


;       NTSC 800x600
; ====================================
; CRT Resolution			: 800x600
; NTSC Resolution			: 720x480
; Pixel Clock				: 40MHz (25ns)
; 
; Horzontal Down Scaling	: 9/10
; Vertical Down Scaling		: 4/5
; Horizontal Up Scaling		: Disable
; Vertical Up Scaling		: Disable
;
; 10 CRT Lines = 4 TV Lines
; 1 CRT Line = 858*74*(4/10) = 25396.8ns
; # of pixels/Line = 25396.8/25 = 1015 (1016)
NTSC_800:
	; Enable horizontal down scaling: type B, 1 out of 9+1,
	; the Vdown pattern is 5 bits
	TVOUT_REG	GEODE_TVOUT_HORIZONTAL_CTRL,	001F33FFh, 00051109h
	; The vertical down scaling is 4/5.
	TVOUT_REG	GEODE_TVOUT_VERTICAL_DOWN_SCALE,0FFFFFFFFh, 0000000Fh
	; The total number of pixels per line: 1015 (1016)
	TVOUT_REG	GEODE_TVOUT_HORIZONTAL_TIMING,	000007FFh, 000003F8h
END_OF_REGTBL

;               PAL
; ====================================
; TV Sampling pixel clock	: 13.5MHz
; Vertical refresh Rate		: 50Hz
; Total Horizontal pixels	: 864
; Active Pixels in a Line	: 720
; Lines per frame			: 625
; Active Lines per Frame	: 576
PAL_Common:
		; Horizontal Display start is 168
		; # of pixels per line is 864
		TVOUT_REG	GEODE_TVOUT_HORIZONTAL_TIMING,	0FFF0FFFh, 009A035Fh
		; Horizontal Sync End is 862
		; Horizontal Sync Start is 854
		TVOUT_REG	GEODE_TVOUT_HORIZONTAL_SYNC,		0FFF0FFFh, 035E0356h
		; Vertical Sync Start is 513
		; Vertical Sync End is 0
		; Vertical Display Start Skew is 2 (reset value)
		; Vertical Display End Skew is 1 (reset value)
		TVOUT_REG	GEODE_TVOUT_VERTICAL_SYNC,		0FFFFF3FFh, 05002001h

		; Horizontal display end is 720+168
		; # of lines per field is 288
		TVOUT_REG	GEODE_TVOUT_DISPLAY_LINE_END,		0FFF01FFh, 036a00f0h
		; HSYNC generated in the Encoder module
		; The interval between resets is once every odd field
		; Take 1/8 of skipped line
		TVOUT_REG	GEODE_TVOUT_HORIZONTAL_CTRL,		 0FF000000h, 10000000h
		; Don't add the IRE offset, PAL color encoding, 625 lines/50Hz,
		; VPHASE is 625, HPHASE is 864, SCRESET is every 4 frames
		TVOUT_REG	GEODE_ENCODER_CTRL1,				 0FFCFFFFFh, 0B120C800h
                ; COMPOSITE OR S-VIDEO
		TVOUT_REG	GEODE_ENCODER_CTRL2,				 0BFFCFFFFh, 000E000d9h
		; Subcarrier Frequency is 4.43361875MHz
		TVOUT_REG	GEODE_ENCODER_SUBCARRIER_FREQ,	0FFFFFFFFh, 2A098ACBh
		; Display position: VSTART is 22, HSTART is 123
		TVOUT_REG	GEODE_ENCODER_DISPLAY_POSITION,	 01FF03FFh, 0016007Bh
		; Display size: HEIGHT is 288, WIDTH is 719
		TVOUT_REG	GEODE_ENCODER_DISPLAY_SIZE,		 01FF03FFh, 011F02CFh
                ; DAC control register: Adjusts the internal voltage reference
		TVOUT_REG	GEODE_ENCODER_DAC_CTRL,		 000000FFh, 00000005h

END_OF_REGTBL		

;          PAL 640x480
; ====================================
; CRT Resolution			: 640x480
; PAL Resolution			: 720x576
; Pixel Clock				: 25MHz (40ns)
; 
; Horzontal Down Scaling	: Disable
; Vertical Down Scaling		: Disable
; Horizontal Up Scaling		: 9/8
; Vertical Up Scaling		: 6/5
;
; 10 CRT Lines = 6 TV Lines
; 1 CRT Line = 864*74*(6/10) = 38361ns
; # of pixels/Line = 38361/40 = 959 (960)
PAL_640:
	; Enable horizontal up scaling 9/8, the Vdown pattern is 2 bits
	TVOUT_REG	GEODE_TVOUT_HORIZONTAL_CTRL,	003F33FFh, 00222100h
	; Disable vertical down scaling, take all lines
	TVOUT_REG	GEODE_TVOUT_VERTICAL_DOWN_SCALE,0FFFFFFFFh, 0FFFFFFFFh
	; The total number of pixels per line: 959 (960)
	TVOUT_REG	GEODE_TVOUT_HORIZONTAL_TIMING,	000007FFh, 0000035Fh
END_OF_REGTBL		

;          PAL 800x600
; ====================================
; CRT Resolution			: 800x600
; PAL Resolution			: 720x576
; Pixel Clock				: 40MHz (25ns)
; 
; Horzontal Down Scaling	: 9/10
; Vertical Down Scaling		: 24/25
; Horizontal Up Scaling		: Disable
; Vertical Up Scaling		: Disable
;
; 25 CRT Lines = 12 TV Lines
; 1 CRT Line = 864*74*(12/25) = 30689.28ns
; # of pixels/Line = 30689.28/25 = 1227 (1228)
PAL_800:
	; Disable horizontal down scaling, the Vdown pattern is 25 bits
	TVOUT_REG	GEODE_TVOUT_HORIZONTAL_CTRL,	001F33FFh, 00223109h
	; Enable vertical down scaling, take 24 bits of 25
	TVOUT_REG	GEODE_TVOUT_VERTICAL_DOWN_SCALE,0FFFFFFFFh, 00001FFFh
	; The total number of pixels per line: 1227 (1228)
	TVOUT_REG	GEODE_TVOUT_HORIZONTAL_TIMING,	000007FFh, 000004CCh
END_OF_REGTBL		

Bhargava_D_NTSC:
		TVOUT_REG	GEODE_TVOUT_HORIZONTAL_TIMING,	0FFF0FFFh, 007A0359h
		; Set vertical down scaling, take all lines
		TVOUT_REG	GEODE_TVOUT_VERTICAL_DOWN_SCALE,	0FFFFFFFFh, 39800000h		
	
		TVOUT_REG	GEODE_TVOUT_HORIZONTAL_CTRL,		0FFFFFFFFh, 10021500h

		TVOUT_REG	GEODE_TVOUT_DISPLAY_LINE_END,		0FFF01FFh, 039A00F0h
END_OF_REGTBL

Bhargava_D_PAL:
		; Set vertical down scaling, take all lines
		TVOUT_REG	GEODE_TVOUT_VERTICAL_DOWN_SCALE,	0FFFFFFFFh, 3b000000h		
		TVOUT_REG	GEODE_TVOUT_HORIZONTAL_TIMING,		0FFF0FFFh,  0096035fh
END_OF_REGTBL

; The table of all NTSC modes
NTSC_modes:
	DW	NTSC_640
	DW	NTSC_800

; The table of all PAL modes
PAL_modes:
	DW	PAL_640
	DW	PAL_800

S_VIDEO:
		; Analog outputs provide Y, Cb and Cr signals,
		; Chrominance Lowpass filter is 1.3MHz
		TVOUT_REG	GEODE_ENCODER_CTRL2,	000030000h, 00020000h
END_OF_REGTBL

COMPOSITE:
		; Analog outputs provide Y, C and CVBS signals,
		; Chrominance Lowpass filter is bypassed
		; Chrominance bypass
		; Luminance bypass
		; Low Water Mark for Cb is 15
		TVOUT_REG	GEODE_ENCODER_CTRL2,	000030000h, 00030000h
END_OF_REGTBL

NTSC_Timings:
; 640x480 NTSC	vsa 1  52    53?   54	55   56	  57	58   59	   5a	  5b	5c    5d    5e	  5f
;		vsa 2  52             54/55  56	  57	58   59	   5a	  5b	5c    5d    5e	  5f
;                      res  ctl   dith clk  htot  vtot fhsst fhsed fvsst fvsed chsst chsed cvsst cvsed
IF VSA eq 1
        VIDEO_TIMINGS <20h, 011h, 000h, 51, 013h, 02Dh, 002h, 00Eh, 00Ah, 00Ch, 002h, 00Eh, 00Ah, 00Ch >
; 800x600 NTSC
        VIDEO_TIMINGS <21h, 011h, 000h, 78, 01Eh, 01eh, 005h, 015h, 00ch, 00fh, 005h, 015h, 00eh, 011h > 
ELSE
; VSA II
        VIDEO_TIMINGS <10h, 000h, 24, 080h, 013h, 02dh, 002h, 00Eh, 00Ah, 00Ch, 002h, 00Eh, 00Ah, 00Ch >
; 800x600 NTSC
        VIDEO_TIMINGS <11h, 000h, 39, 000h, 01Eh, 01eh, 005h, 015h, 00ch, 00fh, 005h, 015h, 00eh, 011h > 
ENDIF

PAL_Timings:
IF VSA eq 1
; 640x480 PAL
        VIDEO_TIMINGS <20h, 051h, 000h, 55, 01Ch, 091h, 006h, 00Dh, 050h, 052h, 006h, 00Dh, 050h, 052h >
; 800x600 PAL
        VIDEO_TIMINGS <20h, 051h, 000h, 54, 01Ch, 091h, 006h, 00Dh, 050h, 052h, 006h, 00Dh, 050h, 052h >
ELSE
; VSA-II
; 640x480 PAL
        VIDEO_TIMINGS <20h, 000h, 27, 000h, 01ch, 091h, 006h, 00Dh, 050h, 052h, 006h, 00dh, 050h, 052h >
; 800x600 PAL
        VIDEO_TIMINGS <21h, 000h, 29, 080h, 012h, 019h, 004h, 00ch, 00ch, 013h, 001h, 00Ah, 012h, 015h >
;        VIDEO_TIMINGS <21h, 000h, 29, 080h, 01ch, 091h, 006h, 00Dh, 050h, 052h, 006h, 00Dh, 050h, 052h >
ENDIF

TV_Routines:
	DW	OFFSET Query_TV_Encoder		; CH = 0
	DW	OFFSET Get_TV_Format		; CH = 1
	DW	OFFSET Set_TV_Format		; CH = 2
	DW	OFFSET Get_TV_Mode		; CH = 3
	DW	OFFSET Set_TV_Mode			; CH = 4
	DW	OFFSET Get_TV_Output		; CH = 5
	DW	OFFSET Set_TV_Output		; CH = 6
	DW	OFFSET Get_TV_Position		; CH = 7
	DW	OFFSET Set_TV_Position		; CH = 8
	DW	OFFSET Bad_Function			; CH = 9
	DW	OFFSET Bad_Function			; CH = A
	DW	OFFSET Bad_Function			; CH = B
	DW	OFFSET Bad_Function			; CH = C
	DW	OFFSET Bad_Function			; CH = D
	DW	OFFSET Bad_Function			; CH = E
	DW	OFFSET Bad_Function			; CH = F
;	DW	OFFSET Return_DDC2_Status	; CH = 10h
;	DW	OFFSET Return_DDC2_Information	; CH = 11h
MAX_FUNC EQU ($-TV_Routines)/2

;**************************************************************************
;*
;*	TV_Init
;*
;*	Configure TVOUT by CMOS setting
;*	  Set TV output mode
;*	  Set TV positions
;*	  Set TV format and resolution (the resolution is 640x480)
;*
;*	Entry:
;*	  None
;*
;*	Exit:
;*	  None
;*
;*	Destroys:
;*;*	Processing:
;*
;**************************************************************************
TV_Init PROC NEAR
	pushad
	call	Disable_Encoder
	
	; Check if TV out should be enabled
;;;;	mov	cx,TOKEN_TV_OUTPUT
;;;;	call	GetNVRAMValue
	mov	al, DEFAULT_TV_OUTPUT
	cmp	al,TVALUE_TV_OUTPUT_NONE	
	je 	TVctrl_exit		; not enabled
	
	call	Get_TV_Output
	call	Set_TV_Output

	; Set TV Format: NTSC or PAL
	call	Get_TV_Format
	call	Set_TV_Format
	; Set 640x480 resolution for BIOS
	call	Get_TV_Mode
	call	Set_TV_Mode
	
	call	Get_TV_Position
	call	Set_TV_Position
	
	mov	eax, 04h
	mov	ebx, 0E0h
	call	SetVideoReg
	
TVctrl_exit:
	popad
	ret
TV_Init ENDP

;**************************************************************************
;*
;*      Geode_Video_Interface
;*
;*	Main entry to TV control functions, INT 15h extension
;*
;*	Entry:
;*	  BX=4358
;*	  CH=Function #
;*	  DX=Function data
;*
;*	Exit:
;*		Fail=Carry Flag is set
;*		Success=Carry Flag is clear
;*
;*	Destroys:
;*
;**************************************************************************
Geode_Video_Interface PROC NEAR
	cmp	ch, MAX_FUNC
	jae	short Bad_Function

	mov	bl, ch
	xor	bh, bh
	add	bx, bx
	jmp	word ptr cs:[TV_Routines + bx]
Geode_Video_Interface ENDP

;**************************************************************************
;*
;*	Bad_Function
;*
;*	Entry:
;*	Exit:
;*	Destroys:
;*
;**************************************************************************
Bad_Function PROC NEAR
	stc
	ret
Bad_Function ENDP

;**************************************************************************
;*
;*	Query_TV_Encoder
;*
;*	Entry:
;*	  CH = 00
;*
;*	Exit:
;*	  DX = 00 - Encoder disabled
;*	     = 01 - GEODE_ TV out
;*
;*	Destroys:
;*
;**************************************************************************
Query_TV_Encoder	PROC NEAR
	; if TV out disabled, report no connected TV
;;;;	mov	cx,TOKEN_TV_OUTPUT
;;;;	call	GetNVRAMValue
	mov	dx, GEODE_TVOUT_ID	; Assume the TV is enabled
	mov	al, DEFAULT_TV_OUTPUT
	cmp	al,TVALUE_TV_OUTPUT_NONE	
	jne	query_tv_done
	xor	dx, dx			; No TV
query_tv_done:
	clc
	ret
Query_TV_Encoder	ENDP

Get_TV_Format	PROC NEAR
;;;;	mov	cx,TOKEN_TV_FORMAT
;;;;	call	GetNVRAMValue
	mov	al, DEFAULT_TV_FORMAT
	inc	al			; 1 or 2
	mov	dl,al
	xor	dh,dh	

⌨️ 快捷键说明

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