📄 video.inc
字号:
test al,00001000b
jnz @@90l
@@91l:
in al,dx
test al,00001000b
jz @@91l
;-----------------------------------------------------------------------------
in al,dx ;Clear flip/flop
call dummy
xor al,al
mov dl,0c0h
out dx,al ;Disable screen
call dummy
;-----------------------------------------------------------------------------
; SEQUENCER
;-----------------------------------------------------------------------------
cli
mov ax,0100h
mov dl,0c4h
out dx,ax ;Sequencer synchronous reset
call dummy
mov cx,4
call set_vga_regs ;!! AH == 01h !!
;-----------------------------------------------------------------------------
mov ax,0300h
mov dl,0c4h
out dx,ax ;Enable sequencer
call dummy
sti
;-----------------------------------------------------------------------------
; CRTC
;-----------------------------------------------------------------------------
mov dl,0d4h
mov ax,0011h
out dx,ax ;Enable write to CRT controller
call dummy
mov cl,19h
call set_vga_regs ;!! AH == 00h !!
;-----------------------------------------------------------------------------
; AC
;-----------------------------------------------------------------------------
mov dl,0dah
in al,dx ;Clear flip/flop
xor ax,ax
mov cl,15h
mov dl,0c0h
@@40:
mov al,ah ;Attribute controller registers
out dx,al ;Register number
call dummy
inc ah
lodsb
out dx,al ;Register data
call dummy
loop @@40
;-----------------------------------------------------------------------------
xor ax,ax
mov dl,0cch
out dx,al ;(03CC) <- 00
call dummy
inc ax
mov dl,0cah
out dx,al ;(03CA) <- 01
call dummy
;-----------------------------------------------------------------------------
; GC
;-----------------------------------------------------------------------------
mov dl,0ceh
mov cl,9
call set_vga_regs ;!! AH == 00h !!
;-----------------------------------------------------------------------------
; DAC
;-----------------------------------------------------------------------------
mov dl,0c8h
xor ax,ax
out dx,al
call dummy
mov cl,30h
inc dx
@@80:
lodsb
out dx,al ;DAC registers
loop @@80 ;RGB
;-----------------------------------------------------------------------------
; FEATURE
;-----------------------------------------------------------------------------
lodsb
mov dl,0dah
out dx,al
call dummy
;-----------------------------------------------------------------------------
; MISCELLANEOUS
;-----------------------------------------------------------------------------
lodsb
mov dl,0c2h
out dx,al
call dummy
;-----------------------------------------------------------------------------
; PEL MASK
;-----------------------------------------------------------------------------
lodsb
mov dl,0c6h
out dx,al
call dummy
;-----------------------------------------------------------------------------
mov dl,0dah
in al,dx
mov dl,0c0h
mov al,20h
out dx,al ;Enable screen
;-----------------------------------------------------------------------------
; BIOS variables
;-----------------------------------------------------------------------------
push es
xor ax,ax
mov es,ax
lodsw
mov [es:450h],ax
lodsw
mov [es:44ah],ax
lodsw
mov [es:485h],ax
lodsw
mov [es:484h],al
mov [es:449h],ah
pop es
ret
;=============================================================================
; set_vga_regs
;-----------------------------------------------------------------------------
set_vga_regs:
lodsb
push ax
@@30:
lodsb
xchg al,ah
out dx,ax
inc ax
mov ah,al
loop @@30
pop ax
out dx,al
ret
;=============================================================================
; save_screen
;-----------------------------------------------------------------------------
; Saves user screen and font; sets mode 03h and loads new font
;
save_screen:
cmp byte [user_screen_mode],0
je @@exit
mov byte [user_screen_mode],0
call pushr
cmp byte [video_type],1 ;1 == VGA
jne @@not_vga
;-----------------------------------------------------------------------------
; VGA
;-----------------------------------------------------------------------------
mov di,old_video_regs
call save_mode
call xchg_planes
mov si,mode_80x25
call set_mode
jmp @@quit
;-----------------------------------------------------------------------------
; EGA and older
;-----------------------------------------------------------------------------
@@not_vga:
call get_cursor
mov [old_cursor],dx
mov [old_cur_shape],cx
mov ah,0fh
int 10h
mov [old_mode_num],al
cmp al,2
je @@mode_ok
cmp al,3
je @@mode_ok
mov ax,83h
int 10h
@@mode_ok:
mov ds,[video_seg]
xor si,si
mov di,old_screen
mov cx,SCR_COLS*MAX_SCR_ROWS
cld
rep movsw
xor ax,ax
mov ds,ax
and byte [487h],7fh
mov al,[484h] ;Number of last line on the screen
cbw
sub ax,CPU_HEIGHT+2
mov [cs:dump_height],ax
@@quit:
call popr
@@exit:
ret
;=============================================================================
; restore_screen
;-----------------------------------------------------------------------------
; Restores user screen, font, and video mode
;
restore_screen:
mov byte [user_screen_mode],1
call pushr
cmp byte [video_type],1
jne @@not_vga
;-----------------------------------------------------------------------------
; VGA
;-----------------------------------------------------------------------------
call xchg_planes
mov si,old_video_regs
call set_mode
jmp @@quit
;-----------------------------------------------------------------------------
; EGA and older
;-----------------------------------------------------------------------------
@@not_vga:
mov es,[video_seg]
xor di,di
mov si,old_screen
mov cx,SCR_COLS*MAX_SCR_ROWS
cld
rep movsw
mov ah,0
mov al,[old_mode_num]
cmp al,2
je @@mode_ok
cmp al,3
je @@mode_ok
or al,80h
int 10h
@@mode_ok:
mov dx,[old_cursor]
call gotoxy
mov cx,[old_cur_shape]
call set_cursor
xor ax,ax
mov ds,ax
and byte [487h],7fh
@@quit:
call popr
ret
;=============================================================================
; save_font
;-----------------------------------------------------------------------------
save_font:
cmp byte [video_type],1
jne @@quit
push ds
push es
mov ax,1130h
mov bh,06h
int 10h
push es
pop ds
mov si,bp
mov di,font
push cs
pop es
mov cx,4096
rep movsb
mov di,old_screen
mov si,0
mov ds,[es:video_seg]
mov cx,SCR_COLS*SCR_ROWS
rep movsw
pop es
pop ds
@@quit:
ret
;
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------
mode_80x25:
;Sequencer registers
db 0
db 000h, 003h, 000h, 002h
;CRT controller registers
db 0
db 05fh, 04fh, 050h, 082h, 055h
db 081h, 0bfh, 01fh, 000h, 04fh
db 00dh, 00eh, 000h, 000h, 000h
db 000h, 09ch, 08eh, 08fh, 028h
db 01fh, 096h, 0b9h, 0a3h, 0ffh
;Attribute controller registers
db 000h, 001h, 002h, 003h, 004h, 005h, 006h, 007h
db 008h, 009h, 00ah, 00bh, 00ch, 00dh, 00eh, 00fh
db 00ch, 000h, 00fh, 008h, 000h
;Graphics controller registers
db 0
db 000h, 000h, 000h, 000h, 000h, 010h, 00eh, 000h, 0ffh
;DAC registers
db 00h, 00h, 00h ;00
db 00h, 00h, 2ah ;01
db 00h, 2ah, 00h ;02
db 00h, 2ah, 2ah ;03
db 2ah, 00h, 00h ;04
db 2ah, 00h, 2ah ;05
db 2ah, 2ah, 00h ;14
db 2ah, 2ah, 2ah ;07
db 15h, 15h, 15h ;38
db 15h, 15h, 3fh ;39
db 15h, 3fh, 15h ;3A
db 15h, 3fh, 3fh ;3B
db 3fh, 15h, 15h ;3C
db 3fh, 15h, 3fh ;3D
db 3fh, 3fh, 15h ;3E
db 3fh, 3fh, 3fh ;3F
;Feature
db 000h
;Miscelianeous
db 067h
;Pel mask
db 0ffh
;BIOS variables
word_0450h dw 0 ;Cursor position for 1st page
word_044ah dw 80 ;Screen width in columns
word_0485h dw 16 ;Lines per char
byte_0484h db 24 ;Last line number
byte_0449h db 3 ;Video mode
;
;-----------------------------------------------------------------------------
;=============================================================================
; E0F
;=============================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -