如何正确设置VGA寄存器以获取模式0x13(无BIOS)

时间:2019-07-03 14:52:25

标签: osdev vga

之前我问过另一个有关分配的问题:DOS allocation error when I try to run my FASM program。 我试图将自己的vga驱动程序制作到操作系统。但是当模式切换发生时,我会得到这样的信息:enter image description here

我的vga.asm代码(.BIN驱动程序)

VGA_AC_INDEX equ 0x3c0
VGA_AC_WRITE equ 0x3c0
VGA_AC_READ equ 0x3c1
VGA_MISC_WRITE equ 0x3c2
VGA_SEQ_INDEX equ 0x3c4
VGA_SEQ_DATA equ 0x3c5
VGA_DAC_READ_INDEX equ 0x3c7
VGA_DAC_WRITE_INDEX equ 0x3c8
VGA_DAC_DATA equ 0x3c9
VGA_MISC_READ equ 0x3cc
VGA_GC_INDEX equ 0x3ce
VGA_GC_DATA equ 0x3cf
VGA_CRTC_INDEX equ 0x3d4
VGA_CRTC_DATA equ 0x3d5
VGA_INSTAT_READ equ 0x3da

VGA_NUM_SEQ_REGS equ 5
VGA_NUM_CRTC_REGS equ 25
VGA_NUM_GC_REGS equ 9
VGA_NUM_AC_REGS equ 21
VGA_NUM_REGS equ (1+VGA_NUM_SEQ_REGS+VGA_NUM_CTRC_REGS+VGA_NUM_GC_REGS+VGA_NUM_AC_REGS)

GDOS_DRIVER_START:
        GDOS_SECTION_DRIVER_HEADER:
                gEntry: dw vgaEntry ;Punkt wejścia sterownika / Driver entry
                gDriverSize: dw GDOS_DRIVER_END ;Rozmiar sterownika w bajtach  / Driver size in bytes
                gDriverType: db 1 ;0x1 - Sterownik grafiki / 0x1 - Graphics driver
                gPortsData: dw vgaPorts
                gMemData: dw vgaMem
                gShared: dw vgaShared ;Lista sterowników dla których zasoby są udostępnione
                gBasicFunc: dw vgaChangeModeID
                gBasicPtrs: dw vgaPtrs
        GDOS_SECTION_DRIVER_DATA:
                vgaIDString: db 'vga-drv$',0 ;SĹ‚uĹĽy do wyszukiwania sterownika przez GDOS / It's for GDOS driver search
                vgaShared0: db 'svga-drv',0
                vgaEntry:
                        retf
                vgaPorts:
                db 0x1
                db 2 
                dw 0x3c8,0x3c9
                db 0x0
                vgaMem:
                db 0x1
                db 2
                dd 0x0000A000,0x0000BFFF
                db 0x0
                vgaShared:
                db 0x1
                dw vgaShared0
                db 0x0

                vgaPtrs:
                        dw vgaModes

                vgaModes:
                        db 0x1,16
                        dw 320,200,8
                        dw 320,240,8

               MODE0_REGS:

                       ; /* MISC */
                     db  0x63
                       ; /* SEQ */
                     db 0x03, 0x01, 0x0F, 0x00, 0x0E
                       ; /* CRTC */
                     db 0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F
                     db 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
                     db 0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3
                     db 0xFF
                        ;/* GC */
                     db 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F
                     db 0xFF
                     ;/* AC */
                     db 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
                     db 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
                     db 0x41, 0x00, 0x0F, 0x00, 0x00


                vgaFunc:
                dw vgaChangeModeID



                vgaChangeModeID: ;TEST
                        push ds

                        push cs
                        pop ds

                        mov si,MODE0_REGS
                        mov di,0

                        mov dx,VGA_MISC_WRITE
                        mov al,[si]
                        inc si
                        out dx,al

                        mov cx,VGA_NUM_SEQ_REGS
                        mov ah,0
                        loop_seq:
                        mov dx,VGA_SEQ_INDEX
                        mov al,ah
                        out dx,al
                        mov dx,VGA_SEQ_DATA
                        mov al,[si]
                        out dx,al
                        inc si
                        inc ah
                        loop loop_seq


                        mov dx,VGA_CRTC_INDEX
                        mov al,0x03
                        out dx,al

                        mov dx,VGA_CRTC_DATA
                        in al,dx
                        or al,0x80
                        out dx,al



                        mov al,0x11
                        mov dx,VGA_CRTC_INDEX
                        out dx,al

                        mov dx,VGA_CRTC_DATA
                        in al,dx
                        and al,not 0x80
                        out dx,al

                        mov cx,VGA_NUM_CRTC_REGS
                        mov ah,0
                        loop_crtc:
                        mov dx,VGA_CRTC_INDEX
                        mov al,ah
                        out dx,al
                        mov dx,VGA_CRTC_DATA
                        mov al,[si]
                        out dx,al
                        inc si
                        inc ah
                        loop loop_crtc

                        mov cx,VGA_NUM_GC_REGS
                        mov ah,0
                        loop_gc:
                        mov dx,VGA_GC_INDEX
                        mov al,ah
                        out dx,al
                        mov dx,VGA_GC_DATA
                        mov al,[si]
                        out dx,al
                        inc si
                        inc ah
                        loop loop_gc

                        mov cx,VGA_NUM_AC_REGS
                        mov ah,0
                        loop_ac:
                        mov dx,VGA_AC_INDEX
                        mov al,ah
                        out dx,al
                        mov dx,VGA_AC_WRITE
                        mov al,[si]
                        out dx,al
                        inc si
                        inc ah
                        loop loop_ac

                        mov dx,VGA_INSTAT_READ
                        in al,dx
                        mov dx,VGA_AC_INDEX
                        mov al,0x20
                        out dx,al





                        pop ds
                        retf

GDOS_DRIVER_END:

我从:https://files.osdev.org/mirrors/geezer/osd/graphics/modes.c获得代码段

请帮助我。

0 个答案:

没有答案