Right, now this isn't always necessary, and there's no need to bother doing this unless you really need to. For example if you were writing a popup TSR or something. However, most programs will just want to drop back into DOS in mode 3.
What has to be done here is to ask the graphics card how much memory it would require to save its current state. I.E. its resolution, virtual screen width, palette etc. You can actually choose what parts of the state are saved by setting bits in the CX register.
CX bit 0: Hardware state
CX bit 1: BIOS data state
CX bit 2: DAC state
CX bit 3: SuperVGA state
The BIOS replies, telling you how many blocks of 64 bytes it needs.
You must then allocate enough memory to hold the buffer.
And lastly, call the BIOS again to save the state.
All the requesting buffer sizes, saving and restoring are handled by the same function, Function 04h.
It is split up into 3 sub functions:
subfunction 00h: Request buffer size
subfunction 01h: Save state
subfunction 02h: Restore state
Right here's some pseudo code which will save the video state, and then restore it again:
AH = 4Fh ;Super VGA support AL = 04h ;Function 04h (save state) DL = 00h ;Subfunction 00h (request amount of memory needed) CX = 00001111b ;save everything please call interrupt 10h
SaveBuffer = AllocateMemory (BX * 64) bytes AH = 4Fh ;Super VGA support AL = 04h ;Function 04h (save state) DL = 01h ;Subfunction 01h (save the state) CX = 00001111b ;save everything please ES:[DI] -> SaveBuffer call interrupt 10h