📄 video.asm
字号:
mov bx,mode
cmp bx,xga_twidth ; mode number out of range?
jb whichmode0
jmp nope ; yup - fail right now.
whichmode0:
cmp mode,0 ; 80-col VGA text mode?
jne whichmode1
jmp mode_0 ; yup
whichmode1:
cmp mode,1 ; 132-col VGA text mode?
jne whichmode2
jmp nope ; Fractint doesn't use this routine
whichmode2:
mov bx,mode ; locate the table entries
add bx,mode
mov dx,xga_requir[bx] ; does our setup support this mode?
and al,dl
cmp al,dl
je whichmode3
jmp nope ; nope
whichmode3:
mov ax,13h ; switch to 320x200x256 mode
call maybeor ; maybe or AL or (for Video-7s) BL
int 10h
push ds ; reset ES==DS
pop es
mov ax,1017h ; get the DAC values
mov bx,0
mov cx,256
mov dx,offset paldata ; a safe place when switching XGA modes
int 10h
cmp xga_loaddac,0 ; save the palette?
je paskip ; (yes, if we want to fake 'loaddac')
mov si, offset paldata
mov di, offset dacbox
mov cx,768/2
rep movsw
mov xga_loaddac,0 ; reset the toggle for next time
paskip:
mov bx,769 ; adjust the palette
paloop: dec bx
mov ah,paldata[bx]
shl ah,1
shl ah,1
mov paldata[bx],ah
cmp bx,0
jne paloop
mov dx,xga_reg_base ; Palette Mask
add dx,0ah
mov ax,00064h ; (Disable the XGA palette)
out dx,ax
mov dx,xga_swidth[bx] ; collect and save the scan-line length
mov xga_xdots,dx
mov dx,xga_colors[bx] ; how many colors do we have?
mov xga_iscolors,dx ; save this
mode_3: mov dx,03c3h ; Enable VGA Address Code
mov al,1
out dx,al
mov si,offset xga_val ; point to start of values table
mov bx,mode ; use mode as an offset
model1: mov dx,xga_reg_base ; get the base pointer
mov ah,0 ; get the increment
mov al,cs:0[si]
cmp al,0ffh ; end of the table?
je model2 ; yup
add dx,ax
cmp al,0ah ; check for access type
je modsk2
mov al,cs:0[si+bx] ; get the value and OUT it
out dx,al
jmp short modsk3
modsk2: mov al,cs:1[si] ; get the value and OUT it
mov ah,cs:0[si+bx]
out dx,ax
modsk3: add si,xga_twidth ; try another table entry
jmp short model1
model2:
mov xga_isinmode,2 ; pretend we're already in graphics
call xga_clear ; clear out the memory
mov curbk,-1 ; reset the bank counter
mov dx,xga_reg_base ; set up for final loads
add dx,0ah
mov bx,mode ; how many colors do we have?
add bx,mode
cmp xga_colors[bx],0 ; "true color" mode?
jne modsk4 ; nope - skip the funny palette load
mov ax,0064h ; make invisible
out dx,ax
mov ax,8055h ; border color
out dx,ax
mov ax,0066h ; palette mode
out dx,ax
mov ax,0060h ; start at palette 0
out dx,ax
mov ax,0061h ; ""
out dx,ax
mov cx,0 ; ready to update the palette
mov al,065h ; palette update
out dx,al
inc dx ; palette data
model3: mov al,0 ; zero out the...
out dx,al ; red value
out dx,al ; and the green value
mov al,cl ; klooge up the blue value
and al,1fh ; convert to 1,2,...1f
shl al,1 ; convert to 2,4,...3e
shl al,1 ; convert to 4,8,...7c
shl al,1 ; convert to 8,16,..fd
out dx,al ; blue value
inc cx ; another palette value to go?
cmp cx,128
jb model3
dec dx ; back to normal
mov ax,0ff64h ; make the palette visible
out dx,ax
jmp ok
modsk4: mov bx, offset paldata ; reset the palette
push bx
mov xga_isinmode,2
call xga_setpalette
pop bx
jmp ok
mode_0: ; Set 80 column mode
mov dx,xga_reg_base ; Aperture Control
add dx,01h
xor al,al ; (disable the XGA 64K aperture)
out dx,al
mov dx,xga_reg_base ; Interrupt Disable
add dx,4
xor al,al
out dx,al
mov dx,xga_reg_base ; Clear Interrupts
add dx,5
mov al,0ffh
out dx,al
test xga_result,10h ; dual monitor setup?
jz mode_0a
jmp nope ; yup - don't restore as a VGA
mode_0a:
mov dx,xga_reg_base ; Palette Mask
add dx,0ah
mov ax,0ff64h ; (Enable the XGA palette)
out dx,ax
mov dx,xga_reg_base ; Enable VFB, Prepare for Reset
add dx,0ah
mov ax,1550h
out dx,ax
mov dx,xga_reg_base ; Enable VFB, reset CRTC
add dx,0ah
mov ax,1450h
out dx,ax
mov dx,xga_reg_base ; Normal Scale Factors
add dx,0ah
mov ax,0051h
out dx,ax
mov dx,xga_reg_base ; Select VGA Oscillator
add dx,0ah
mov ax,0454h
out dx,ax
mov dx,xga_reg_base ; Ext Oscillator (VGA)
add dx,0ah
mov ax,7f70h
out dx,ax
mov dx,xga_reg_base ; Ensure no Vsynch Interrupts
add dx,0ah
mov ax,202ah
out dx,ax
mov dx,xga_reg_base ; Switch to VGA Mode
;; add dx,00h
mov al,1
out dx,al
mov dx,03c3h ; Enable VGA Address Code
mov al,1
out dx,al
mov ax,1202h ; select 400 scan lines
mov bl,30h
int 10h
mov ax,0+3 ; set video mode 3
or al,xga_clearvideo ; (might supress video-clearing)
cmp xga_clearvideo,0 ; clear the video option set?
je mode_0b
mov ax,08eh ; ugly klooge: VGA graphics, no clear
mode_0b:
int 10h
jmp ok ; we're done
nope:
mov xga_isinmode,0
mov ax,0 ; return failure
ret
ok:
mov ax,mode ; remember the mode we're in
mov xga_isinmode,ax
mov ax,1 ; return OK
ret
xga_mode endp
; **************** internal Read/Write-a-dot routines ***********************
;
; These Routines all assume the following register values:
;
; AL = The Color (returned on reads, sent on writes)
; CX = The X-Location of the Pixel
; DX = The Y-Location of the Pixel
nullwrite proc near ; "do-nothing" write
ret
nullwrite endp
nullread proc near ; "do-nothing" read
mov ax,0 ; "return" black pixels
ret
nullread endp
normalwrite proc near ; generic write-a-dot routine
mov ah,12 ; write the dot (al == color)
mov bx,0 ; this page
push bp ; some BIOS's don't save this
int 10h ; do it.
pop bp ; restore the saved register
ret ; we done.
normalwrite endp
normalread proc near ; generic read-a-dot routine
mov ah,13 ; read the dot (al == color)
mov bx,0 ; this page
push bp ; some BIOS's don't save this
int 10h ; do it.
pop bp ; restore the saved register
ret ; we done.
normalread endp
mcgawrite proc near ; MCGA 320*200, 246 colors
xchg dh,dl ; bx := 256*y
mov bx,cx ; bx := x
add bx,dx ; bx := 256*y + x
shr dx,1
shr dx,1 ; dx := 64*y
add bx,dx ; bx := 320*y + x
mov es:[bx],al ; write the dot
ret ; we done.
mcgawrite endp
mcgaread proc near ; MCGA 320*200, 246 colors
xchg dh,dl ; dx := 256*y
mov bx,cx ; bx := x
add bx,dx ; bx := 256*y + x
shr dx,1
shr dx,1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -