Graphic display of the assembly source code save and restore the screen

Source: Internet
Author: User

In the program often want to temporarily save the graphics display way on the screen content, then the output of their own information to the screen, and then restore the original screen content, especially in the memory-resident program pop-up a window to use, but the graphics display buffer capacity is huge, in the commonly used x 25 text mode, The display buffer is only size x 2 = 4000 bytes, while the mode 13H x 256 color is the x 200 = 64000 bytes, now commonly used in high color, true color, such as x x 65535 color when 80 0 x x 2 = 960000 bytes, involving such a large data program must be complicated by the use of disk-swapping methods or the use of XMS as a buffer for data storage.

This article uses an INT 10H method that does not clear the display memory setting new display mode, so that no matter in what display mode, the buffer used in the big under 10K or so, even in 1024 x 768 x 16.7M color can be stored normally.

The application of this program is to save the screen after their own program only use text mode 3, if you want to use graphics mode, then still want to save all the display buffer. In terms of compatibility, due to the use of VESA standard features, in the current Pci/vesa display card can be normal operation, I found that the only one can not run is a period of production of the TVGA 8900/9000 card, because this card in the VESA function just appeared when production, support VESA pseudo color display mode , but does not support many other VESA functions. Let me know if you can find a way to overcome it.

Some of the interrupts used in this program are described below:

INT 10H 00H function, set display mode:

function inlet Parameter Export parameter

INT 10H 00H function

Set display mode AH = 00H

AL = mode (if bit 7 is set, the display buffer is not cleared)

INT 10H 1BH function to detect whether VGA card:

function inlet Parameter Export parameter

INT 10H 1BH function

Take VGA/MCGA function, status information AH = 1BH AL = 1BH Success (Note that the display card is VGA above)
Es:di Return status information

BX = 0000

AL <> 1BH Non-VGA/MCGA display card

Es:di point to 64-byte buffers

INT 10H 1CH function to save/restore video status:

function inlet Parameter Export parameter

The 1c00h function of INT 10H

Return state buffer capacity AX = 1c00h AL = 1CH Successful

BX = number of 64-byte blocks required

The 1c01h function of INT 10H

Save Video Status AX = 1c01h

ES:BX point to Buffer

The 1c02h function of INT 10H

Restore Video Status AX = 1c01h

CX = Status of requirements

bit 0 = Restore Video hardware status

Bit 1 = BIOS data area

Bit 2 = Color registers and DAC status

ES:BX point to buffer (saved with 1c01h function)

INT 10H 4FH function, VESA function:

function inlet Parameter Export parameter

The 4f00h function of INT 10H

Take the display card VESA information AX = 4f00h AL = 4FH Description Display card support VESA

AH = 00H Successful

AH = 01H Failed

Es:di Point buffer (256 bytes) AL <> 4FH display card does not support VESA

The 4f05h function of INT 10H

Control access to VESA display card video RAM BH = 00H Select video Memory window

DX = video Memory window address AH = 00H success

AH = 01H Failed

BH = 01H fetch video Memory window AH = 00H success

DX = video Memory window address

AH = 01H Failed

INT 33H 16h/17h function to save/restore mouse driver Status:

function inlet Parameter Export parameter

INT 33H 0015H function

Determine the need to save the mouse driver state

Space AX = 0015H BX = Required size

INT 33H 0016H function

Save Mouse Driver Status AX = 0016H

BX = buffer size (obtained in 0015H)

ES:DX point to Buffer

INT 33H 0017H function

Restore Mouse driver Status AX = 0017H

BX = buffer size (obtained in 0015H)

ES:DX point to Buffer

SOURCE program:

; by Luo Yun Bin

; http://asm.yeah.net

This subroutine is used to detect the type of display card, mouse state, etc.

, executing when the program is initialized

Some of the buffers to be used in this article, please define yourself, attention to size!

Flag db?; flag bit, bit 7 Set 1 indicates the mouse is installed

Vga_type db?; Display card type

Video_mode db?; display mode

Vga_win1 DW?; video window, staging VESA window state

Vga_win2 DW?;

Vga_win3 DW?;

...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.