📄 vga_utils.asm
字号:
;****************************************************************************section .textpice_set_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 mov byte al, [ebx + ecx] out word dx, al inc dword ecx cmp dword ecx, VGA_GRAPHIC_REGISTERS jb .loop ret;****************************************************************************;* pice_set_sequencer_registers ********************************************;****************************************************************************;* ebx=> pointer to stored sequencer registers;****************************************************************************section .textpice_set_sequencer_registers: ;synchronous reset on mov dword edx, VGA_SEQUENCER_INDEX xor dword eax, eax out word dx, al mov dword edx, VGA_SEQUENCER_DATA inc dword eax out word dx, al ;write to the registers mov dword edx, VGA_SEQUENCER_INDEX out word dx, al mov dword edx, VGA_SEQUENCER_DATA mov byte al, [ebx + 1] or byte al, 020h out word dx, al mov dword ecx, 2.loop: mov dword edx, VGA_SEQUENCER_INDEX mov byte al, cl out word dx, al mov dword edx, VGA_SEQUENCER_DATA mov byte al, [ebx + ecx] out word dx, al inc dword ecx cmp dword ecx, VGA_SEQUENCER_REGISTERS jb .loop ;synchronous reset off mov dword edx, VGA_SEQUENCER_INDEX xor dword eax, eax out word dx, al mov dword edx, VGA_SEQUENCER_DATA mov byte al, 3 out word dx, al ret;****************************************************************************;* pice_set_misc_registers *************************************************;****************************************************************************;* ebx=> pointer to stored misc register;****************************************************************************section .textpice_set_misc_registers: mov dword edx, VGA_MISC_DATA_WRITE mov byte al, [ebx] out word dx, al ret;****************************************************************************;* pice_set_colormap *******************************************************;****************************************************************************;* ebx=> pointer to stored colormap;****************************************************************************section .textpice_set_colormap: xor dword ecx, ecx xor dword eax, eax mov dword edx, VGA_PEL_INDEX_WRITE out word dx, al mov dword edx, VGA_PEL_DATA.loop: mov dword eax, [ebx + 4 * ecx] rol dword eax, 16 out word dx, al rol dword eax, 8 out word dx, al rol dword eax, 8 out word dx, al inc dword ecx test byte cl, cl jnz .loop ret;****************************************************************************;* pice_screen_on **********************************************************;****************************************************************************section .textpice_screen_on: ;turn on the screen mov dword edx, VGA_SEQUENCER_INDEX mov byte al, 1 out word dx, al mov dword edx, VGA_SEQUENCER_DATA in byte al, dx and byte al, 0dfh out word dx, al ;enable video output mov dword edx, VGA_INPUT_STATUS in byte al, dx mov dword edx, VGA_ATTRIBUTE_DATA_WRITE mov byte al, 020h out word dx, al ret;****************************************************************************;* pice_select_write_plane *************************************************;****************************************************************************;* bl==> write mode;* bh==> write plane;****************************************************************************section .textpice_select_write_plane: and dword ebx, 00f03h ;enable set/reset = 0 mov dword edx, VGA_GRAPHIC_INDEX mov byte al, 1 out word dx, al mov dword edx, VGA_GRAPHIC_DATA xor dword eax, eax out word dx, al ;logical operation = none, rotate = 0 mov dword edx, VGA_GRAPHIC_INDEX mov byte al, 3 out word dx, al mov dword edx, VGA_GRAPHIC_DATA xor dword eax, eax out word dx, al ;select write mode mov dword edx, VGA_GRAPHIC_INDEX mov byte al, 5 out word dx, al mov dword edx, VGA_GRAPHIC_DATA in byte al, dx and byte al, 0fch or byte al, bl out word dx, al ;bitmask = 0ffh mov dword edx, VGA_GRAPHIC_INDEX mov byte al, 8 out word dx, al mov dword edx, VGA_GRAPHIC_DATA mov byte al, 0ffh out word dx, al ;select write plane mov dword edx, VGA_SEQUENCER_INDEX mov byte al, 2 out word dx, al mov dword edx, VGA_SEQUENCER_DATA mov byte al, bh out word dx, al ret;****************************************************************************;* pice_select_read_plane **************************************************;****************************************************************************;* bl==> read mode;* bh==> read plane;****************************************************************************section .textpice_select_read_plane: and dword ebx, 00301h shl byte bl, 3 ;select read mode mov dword edx, VGA_GRAPHIC_INDEX mov byte al, 5 out word dx, al mov dword edx, VGA_GRAPHIC_DATA in byte al, dx and byte al, 0f7h or byte al, bl out word dx, al ;select read plane mov dword edx, VGA_GRAPHIC_INDEX mov byte al, 4 out word dx, al mov dword edx, VGA_GRAPHIC_DATA mov byte al, bh out word dx, al ret;****************************************************************************;* pice_save_current_registers **********************************************;****************************************************************************section .textpice_save_current_registers: push esi push edi push ebx; call pice_save_current_charset.crt: mov dword ebx, pice_current_registers.crt call pice_get_crt_registers.attribute: mov dword ebx, pice_current_registers.attribute call pice_get_attribute_registers.graphic: mov dword ebx, pice_current_registers.graphic call pice_get_graphic_registers.sequencer: mov dword ebx, pice_current_registers.sequencer call pice_get_sequencer_registers.misc: mov dword ebx, pice_current_registers.misc call pice_get_misc_registers.colormap: mov dword ebx, pice_current_registers.colormap call pice_get_colormap pop ebx pop edi pop esi.end: ret;****************************************************************************;* pice_restore_current_registers *******************************************;****************************************************************************section .textpice_restore_current_registers: push esi push edi push ebx; call pice_restore_current_charset.misc: mov dword ebx, pice_current_registers.misc call pice_set_misc_registers.crt: mov dword ebx, pice_current_registers.crt call pice_set_crt_registers.attribute: mov dword ebx, pice_current_registers.attribute call pice_set_attribute_registers.graphic: mov dword ebx, pice_current_registers.graphic call pice_set_graphic_registers.sequencer: mov dword ebx, pice_current_registers.sequencer call pice_set_sequencer_registers.screen_on: call pice_screen_on.colormap: mov dword ebx, pice_current_registers.colormap call pice_set_colormap pop ebx pop edi pop esi.end: ret;****************************************************************************;* pice_set_mode_3_80x50*****************************************************;****************************************************************************section .textpice_set_mode_3_80x50: push esi push edi push ebx.crt: mov dword ebx, pice_mode3_80x50_registers.crt call pice_set_crt_registers.attribute: mov dword ebx, pice_mode3_80x50_registers.attribute call pice_set_attribute_registers.graphic: mov dword ebx, pice_mode3_80x50_registers.graphic call pice_set_graphic_registers.sequencer: mov dword ebx, pice_mode3_80x50_registers.sequencer call pice_set_sequencer_registers.misc: mov dword ebx, pice_mode3_80x50_registers.misc call pice_set_misc_registers.screen_on: call pice_screen_on;.colormap: mov dword ebx, pice_current_registers.colormap; call pice_set_colormap pop ebx pop edi pop esi.end: ret;****************************************************************************;* pice_set_mode_3_80x25*****************************************************;****************************************************************************section .textpice_set_mode_3_80x25: push esi push edi push ebx.crt: mov dword ebx, pice_mode3_80x25_registers.crt call pice_set_crt_registers.attribute: mov dword ebx, pice_mode3_80x25_registers.attribute call pice_set_attribute_registers.graphic: mov dword ebx, pice_mode3_80x25_registers.graphic call pice_set_graphic_registers.sequencer: mov dword ebx, pice_mode3_80x25_registers.sequencer call pice_set_sequencer_registers.misc: mov dword ebx, pice_mode3_80x25_registers.misc call pice_set_misc_registers.screen_on: call pice_screen_on;.colormap: mov dword ebx, pice_current_registers.colormap; call pice_set_colormap pop ebx pop edi pop esi.end: ret;****************************************************************************;* uninitialized data *******************************************************;****************************************************************************section .bss alignb 4pice_charset_saved: resb 040000h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -