So at the moment i am copying a screenbuffer (screenbuffer db 64000 DUP(0)) to the video memory (which starts at 0a0000h) to clear the screen. But i was wondering if it is better to just setup the video mode again like this:
mov ax, 13h
int 10h
which seems to clear the screen as well.
Or is there an even better way to clear the screen?
You could use STOSD with a REP prefix to clear video memory for video mode 13 (320x200x256 colors). REP STOSD will repeat STOSD by the count stored in ECX . STOSD will write each DWORD in EAX to ES:[EDI] incrementing EDI by 4 each time.
Sample code could look something like:
This code assumes you are on a 32-bit processor, but doesn't assume you are running in unreal mode.
If you are using a 16-bit processor (8086/80186/80286) you would have to use the 16-bit registers, and use REP STOSW . CX would be set to (320*200)/2 instead of (320*200)/4. The 16-bit processors don't allow for 32-bit operands so don't support STOSD.
You could easily convert this code to be an assembly language function.