📄 vga_utils.asm
字号:
;******************************************************************************;*;* Copyright (c) 2003 Gerhard W. Gruber;*;* PROJECT: pICE;* $Source: /cvsroot/pice/pice/module/vga_utils.asm,v $;* $Revision: 1.2 $;* $Date: 2004/02/17 23:07:37 $;* $Author: lightweave $;* $Name: $;*;* $Log: vga_utils.asm,v $;* Revision 1.2 2004/02/17 23:07:37 lightweave;*;* Improved the DEBUG facillity and replaced the configuration handler with a;* new code which now can read MS Windows INI style files. See CHANGES.txt for;* more details.;* Also added a macro which prevents compiling for kernels before 2.4.19.;*;*;*****************************************************************************;/*++;;Copyright (c) 1998-2001 Klaus P. Gerlicher;;Module Name:;; vga_utils.asm;;Abstract:;; assembler function for directly programming standard VGA;;Environment:;; LINUX 2.2.X; Kernel mode only;;Author: ;; Klaus P. Gerlicher;;Revision History:;; 30-Oct-2001: created;;Copyright notice:;; This file may be distributed under the terms of the GNU Public License.;;--*/global pice_save_current_registersglobal pice_restore_current_registersglobal pice_set_mode_3_80x50global pice_set_mode_3_80x25;****************************************************************************;* some assign's ************************************************************;****************************************************************************%assign VGA_CRT_REGISTERS 24%assign VGA_ATTRIBUTE_REGISTERS 21%assign VGA_GRAPHIC_REGISTERS 9%assign VGA_SEQUENCER_REGISTERS 5%assign VGA_MISC_REGISTERS 1%assign VGA_IO_BASE 03c0h%assign VGA_IO_SIZE 020h%assign VGA_ATTRIBUTE_INDEX 03c0h%assign VGA_ATTRIBUTE_DATA_WRITE 03c0h%assign VGA_ATTRIBUTE_DATA_READ 03c1h%assign VGA_MISC_DATA_WRITE 03c2h%assign VGA_SEQUENCER_INDEX 03c4h%assign VGA_SEQUENCER_DATA 03c5h%assign VGA_PEL_MASK 03c6h%assign VGA_PEL_INDEX_READ 03c7h%assign VGA_PEL_INDEX_WRITE 03c8h%assign VGA_PEL_DATA 03c9h%assign VGA_MISC_DATA_READ 03cch%assign VGA_GRAPHIC_INDEX 03ceh%assign VGA_GRAPHIC_DATA 03cfh%assign VGA_CRT_INDEX 03d4h%assign VGA_CRT_DATA 03d5h%assign VGA_INPUT_STATUS 03dahsection .datapice_mode3_80x50_registers:; offsets 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18.crt: db 0x5f,0x4f,0x50,0x82,0x55,0x80,0xbf,0x1f,0x00,0x67,0x06,0x07,0x00,0x00,0x00,0x00,0x9c,0x8f,0x8f,0x28,0x1f,0x96,0xb9,0xa3,0xff.attribute db 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x08,0x00,0x0f,0x00,0x00 .graphic: db 0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,0xff.sequencer: db 0x03,0x00,0x03,0x00,0x02 ; 9 bits per char;.sequencer: db 0x03,0x01,0x03,0x00,0x02 ; 8 bits per char.misc: db 0x67pice_mode3_80x25_registers:; offsets 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18.crt: db 0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,0x00,0x4f,0x0d,0x0e,0x00,0x00,0x30,0xe8,0x9c,0x0e,0x8f,0x28,0x1f,0x96,0xb9,0xa3.attribute db 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x0c,0x00,0x0f,0x08,0x00.graphic: db 0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,0xff.sequencer: db 0x03,0x00,0x03,0x00,0x02.misc: db 0x67section .bsspice_current_registers:.crt: resb VGA_CRT_REGISTERS.attribute: resb VGA_ATTRIBUTE_REGISTERS.graphic: resb VGA_GRAPHIC_REGISTERS.sequencer: resb VGA_SEQUENCER_REGISTERS.misc: resb VGA_MISC_REGISTERS align 4.colormap: resd 256;****************************************************************************;* pice_save_current_charset ************************************************;****************************************************************************section .textpice_address dd 0xc00a0000pice_save_current_charset: xor dword ebx, ebx call pice_select_read_plane mov dword ecx, 04000h mov dword esi, [pice_address] mov dword edi, pice_charset_saved cld rep movsd mov dword ebx, 00100h call pice_select_read_plane mov dword ecx, 04000h mov dword esi, [pice_address] mov dword edi, (pice_charset_saved + 010000h) cld rep movsd mov dword ebx, 00200h call pice_select_read_plane mov dword ecx, 04000h mov dword esi, [pice_address] mov dword edi, (pice_charset_saved + 020000h) cld rep movsd mov dword ebx, 00300h call pice_select_read_plane mov dword ecx, 04000h mov dword esi, [pice_address] mov dword edi, (pice_charset_saved + 030000h) cld rep movsd.end: ret;****************************************************************************;* pice_restore_current_charset ****************************************************;****************************************************************************section .textpice_restore_current_charset: mov dword ebx, 00100h call pice_select_write_plane mov dword ecx, 04000h mov dword esi, pice_charset_saved mov dword edi, [pice_address] cld rep movsd mov dword ebx, 00200h call pice_select_write_plane mov dword ecx, 04000h mov dword esi, (pice_charset_saved + 010000h) mov dword edi, [pice_address] cld rep movsd mov dword ebx, 00400h call pice_select_write_plane mov dword ecx, 04000h mov dword esi, (pice_charset_saved + 020000h) mov dword edi, [pice_address] cld rep movsd mov dword ebx, 00800h call pice_select_write_plane mov dword ecx, 04000h mov dword esi, (pice_charset_saved + 030000h) mov dword edi, [pice_address] cld rep movsd.end: ret;****************************************************************************;* pice_get_crt_registers **************************************************;****************************************************************************;* ebx=> pointer where to store crt registers;****************************************************************************section .textpice_get_crt_registers: xor dword ecx, ecx.loop: mov dword edx, VGA_CRT_INDEX mov byte al, cl out word dx, al mov dword edx, VGA_CRT_DATA in byte al, dx mov byte [ebx + ecx], al inc dword ecx cmp dword ecx, VGA_CRT_REGISTERS jb .loop ret;****************************************************************************;* pice_get_attribute_registers ********************************************;****************************************************************************;* ebx=> pointer where to store attribute registers;****************************************************************************section .textpice_get_attribute_registers: xor dword ecx, ecx.loop: mov dword edx, VGA_INPUT_STATUS in byte al, dx mov dword edx, VGA_ATTRIBUTE_INDEX mov byte al, cl out word dx, al mov dword edx, VGA_ATTRIBUTE_DATA_READ in byte al, dx mov byte [ebx + ecx], al inc dword ecx cmp dword ecx, VGA_ATTRIBUTE_REGISTERS jb .loop ret;****************************************************************************;* pice_get_graphic_registers **********************************************;****************************************************************************;* ebx=> pointer where to store graphics registers;****************************************************************************section .textpice_get_graphic_registers: xor dword ecx, ecx.loop: mov dword edx, VGA_GRAPHIC_INDEX mov byte al, cl out word dx, al mov dword edx, VGA_GRAPHIC_DATA in byte al, dx mov byte [ebx + ecx], al inc dword ecx cmp dword ecx, VGA_GRAPHIC_REGISTERS jb .loop ret;****************************************************************************;* pice_get_sequencer_registers ********************************************;****************************************************************************;* ebx=> pointer where to store sequencer registers;****************************************************************************section .textpice_get_sequencer_registers: xor dword ecx, ecx.loop: mov dword edx, VGA_SEQUENCER_INDEX mov byte al, cl out word dx, al mov dword edx, VGA_SEQUENCER_DATA in byte al, dx mov byte [ebx + ecx], al inc dword ecx cmp dword ecx, VGA_SEQUENCER_REGISTERS jb .loop ret;****************************************************************************;* pice_get_misc_registers *************************************************;****************************************************************************;* ebx=> pointer where to store misc register;****************************************************************************section .textpice_get_misc_registers: mov dword edx, VGA_MISC_DATA_READ in byte al, dx mov byte [ebx], al ret;****************************************************************************;* pice_get_colormap *******************************************************;****************************************************************************;* ebx=> pointer where to store colormap;****************************************************************************section .textpice_get_colormap: xor dword ecx, ecx xor dword eax, eax mov dword edx, VGA_PEL_INDEX_READ out word dx, al mov dword edx, VGA_PEL_DATA.loop: in byte al, dx shl dword eax, 8 in byte al, dx shl dword eax, 8 in byte al, dx mov dword [ebx + 4 * ecx], eax inc dword ecx test byte cl, cl jnz .loop ret;****************************************************************************;* pice_set_crt_registers **************************************************;****************************************************************************;* ebx=> pointer to stored crt registers;****************************************************************************section .textpice_set_crt_registers: ;deprotect CRT registers 0 - 7 mov dword edx, VGA_CRT_INDEX mov byte al, 011h out word dx, al mov dword edx, VGA_CRT_DATA in byte al, dx and byte al, 07fh out word dx, al ;write to the registers xor dword ecx, ecx.loop: mov dword edx, VGA_CRT_INDEX mov byte al, cl out word dx, al mov dword edx, VGA_CRT_DATA mov byte al, [ebx + ecx] out word dx, al inc dword ecx cmp dword ecx, VGA_CRT_REGISTERS jb .loop ret;****************************************************************************;* pice_set_attribute_registers ********************************************;****************************************************************************;* ebx=> pointer to stored attibute registers;****************************************************************************section .textpice_set_attribute_registers: xor dword ecx, ecx.loop: mov dword edx, VGA_INPUT_STATUS in byte al, dx mov dword edx, VGA_ATTRIBUTE_INDEX mov byte al, cl out word dx, al mov dword edx, VGA_ATTRIBUTE_DATA_WRITE mov byte al, [ebx + ecx] out word dx, al inc dword ecx cmp dword ecx, VGA_ATTRIBUTE_REGISTERS jb .loop ret;****************************************************************************;* pice_set_graphic_registers **********************************************;****************************************************************************;* ebx=> pointer to stored graphic registers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -