Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simple tester program for vga.h

0 views
Skip to first unread message

ericmatteson...@hotmail.com

unread,
Oct 20, 2006, 5:18:11 PM10/20/06
to
Simple tester program for vga.h
testsq.c is a simple example program that shows how
the zackvga.h and wgslater.c files are used to implement
vga.h and tests the header zackvga.h */
// beginning of testsq.c
// this testsq.c was written by Eric Matteson
// copyright 2006 by Eric Matteson
// permission is granted to copy this testsq.c source code
// and to publish it on the Internet and to use it
// at least for non profit use
#include "zackvga.h"
// zackvga.h has to be used because vga.h is missing
// from most modern Linuxes in October 2006
void vga_drawrect(int adrulx,int adruly,int adrwid,int adrhgt)
{
int adro,adri;
adro=0;
while(adro < adrhgt)
{
adri=0;
while(adri < adrwid)
{
vga_drawpixel((adrulx + adri),(adruly + adro));
// vga_drawpixel(int x,int y) draws the internal color value
// to point (x,y)
adri = adri + 1;
}
adro=adro+1;
}
}
int simpkey()
{
int kur;
kur=0;
while(kur == 0)
{
kur = vga_getkey();
// vga_getkey() returns 0 if no key has been pressed
}
return kur;
}
int sqhexdig(int rawasc)
{
int rehexdig;
rehexdig=29;
if((rawasc >= 48)&&(rawasc <= 57))rehexdig=rawasc-48;
if((rawasc >= 65)&&(rawasc <= 70))rehexdig=rawasc-55;
if((rawasc >= 97)&&(rawasc <= 103))rehexdig=rawasc-87;
return rehexdig;
}
int zackmain(int tesqi,char** tesqcc)
// zackmain(int,char**) is used instead of main
// when zackvga.h is used
{
int tempmode,selkey;
int sqctr;
int sqeight[8];
sqctr=0;
while(sqctr < 8)
{
sqeight[sqctr]=0;
sqctr=sqctr+1;
}
vga_init();
// vga_int() initializes imporatant variables in wgslater.c
// called by zackvga.h
tempmode=vga_getcurrentmode();
// will be getting a 0 if starting with text screen
vga_setmode(G640x480x16);
// vga_setmode(int mode_number) opens up
// a XWindow jennifer in wgslater.c
// the two modes G640x480x16 and G640x480x2
// are supported
vga_setcolor(12);
// vga_setcolor(int atmost15) sets the internal
// color variable.
vga_drawrect(16,16,32,32);
vga_setcolor(10);
vga_drawrect(48,16,32,32);
vga_setcolor(9);
vga_drawrect(80,16,32,32);
selkey=0;
while((selkey >= 0)&&(selkey <= 15))
{
selkey=sqhexdig(simpkey());
if((selkey >= 0)&&(selkey <= 15))
{
vga_setcolor(selkey);
vga_drawrect(248,280,32,32);
sqctr=0;
while(sqctr < 7)
{
sqeight[sqctr]=sqeight[sqctr+1];
sqctr=sqctr+1;
}
sqeight[7]=selkey;
vga_setcolor(15);
vga_drawline((sqeight[0] * 16)+sqeight[1],
(sqeight[2] * 16)+sqeight[3],
(sqeight[4] * 16)+sqeight[5],
(sqeight[6] * 16)+sqeight[7]);
// vga_drawline(xfrom,yfrom,xto,yto) draws a line
}
}
vga_setmode(tempmode);
// vga_setmode(0) would return to text screen
// on real vga.h
return 0;
}
// end of testsq.c
/* after end of programming

0 new messages