Mail Archives: djgpp/1997/02/04/16:34:14
dgraf AT midcoast DOT com wrote:
: Just looking for 4 functions in inline asm. Can someone enlighten me?
: 1 init mode 13h
: 2 plot a pixel
: 3 a screaming-fast copy (like stosw)
: 4 init textmode 3
One thing to remember; DJGPP works in protected mode, so it's usually
faster to do all your graphics in a virtual screen in extended memory
then blit it to the screen once per frame. On this assumption, I'd
write your functions thusly (in C, because there's no point in using
asm for this stuff).
1)
void SetVGA(){
union REGS r;
r.x.ax = 0x0013;
int86(0x10, &r, &r);
}
2) Just plot the pixels to your virtual screen with
inline void Putpixel(int x, int y, char Col){
vaddr[x + y*SCREENX] = Col;
}
(gcc will optimise multiplication by 320 into some bizarre load
instruction, so this is pretty fast).
3) To copy to dos memory (eg the screen), use the dosmemput()
library function. Otherwise, use memcpy (which inlines to
rep stosd anyway, I think).
4)
void SetText(){
union REGS r;
r.x.ax = 0x0003;
int86(0x10, &r, &r);
}
I don't know whether this is the absolute fastest you can do, but
it's pretty good. Good luck,
-Edwin
- Raw text -