#include <vga.h>
void main()
{
int x=1,dx=1;
int y=1,dy=1;
int c=0;
/* get vgalib to init itself */
vga_init();
vga_setmode(G320x200x256);
/* If you like asm (who doesn't? :)) you can set the palette
with 0x3c8 & 0x3c9. It works ok for me, but it is probably
better to use the library so it knows the current state of the
vga card. This goes for all the other vga ports too. */
for(c=0;c<256;c++)
vga_setpalette(c,c>>2,c>>3,c>>4);
while(!vga_getkey()) {
c++;
if(x==0 || x==319) dx*=-1;
if(y==0 || y==199) dy*=-1;
x+=dx;
y+=dy;
/* graph_mem is a pointer which is mmapped to video mem */
graph_mem[320*y+x]=c;
}
/* I don't tell svgalib to switch to text mode before I exit since
it messes up my console. However, letting svgalib switch to
text mode by quitting works well. weird. */
/* vga_setmode(TEXT) */
return;
} |