Refactored for 320x200 - going retro after all

This commit is contained in:
Adam Greenwood-Byrne 2021-03-12 22:02:57 +00:00
parent ef1cd6d4df
commit 54b30f1684
10 changed files with 68 additions and 64 deletions

View file

@ -1,5 +1,4 @@
#include "wgt.h"
#include "wpal.h"
// ######## WGT EXAMPLES ########
@ -7,7 +6,7 @@ void wgt01()
{
vga256 (); /* Initializes WGT system */
wsetcolor (vgapal[15]);
wline (0, 0, 1919, 1079); /* Draw a line */
wline (0, 0, 319, 199); /* Draw a line */
}
void main()

View file

@ -1,5 +1,4 @@
#include "wgt.h"
#include "wpal.h"
// ######## REQUIRED FUNCTIONS ########
@ -60,17 +59,17 @@ void wgt02()
/* Put randomly coloured pixels in random screen coordinates */
do {
wsetcolor (vgapal[rand () % 256]);
x = rand () % 1920;
y = rand() % 1080;
wsetcolor (vgapal[rand () % 255]);
x = rand () % 320;
y = rand() % 200;
wputpixel (x, y);
} while (kbhit () == 0);
getch ();
wcls (vgapal[0]); /* Clear screen with color 0 */
wsetcolor (vgapal[10]); /* Now we will draw with #10 */
for (x = 0; x < 1920; x++)
for (y = 0; y < 1080; y++)
for (x = 0; x < 320; x++)
for (y = 0; y < 200; y++)
wfastputpixel (x, y); /* Fast due to no clipping checking */
getch ();
@ -79,18 +78,18 @@ void wgt02()
/* Put randomly coloured pixels in the top left corner of the screen */
for (i = 0; i < 15000; i++)
{
wsetcolor (vgapal[rand () % 256]);
x = rand () % 960;
y = rand () % 540;
wsetcolor (vgapal[rand () % 255]);
x = rand () % 160;
y = rand () % 100;
wputpixel (x, y);
}
/* Now use wgetpixel to read image off screen */
for (y = 0; y < 540; y++)
for (x = 0; x < 960; x++)
for (y = 0; y < 100; y++)
for (x = 0; x < 160; x++)
{
wsetcolor (wgetpixel (x, y));
wputpixel (x + 960, y + 540);
wputpixel (x + 160, y + 100);
}
getch ();

View file

@ -40,7 +40,7 @@ unsigned int kb = 0;
unsigned int kbhit(void) {
kb++;
return kb / 500;
return kb / 15000;
}
void getch(void) {
@ -67,9 +67,12 @@ void wgt03()
vga256 (); /* Initialize WGT system */
debugstr ("WGT Example #3"); debugcrlf(); debugcrlf();
debugstr ("This program will use the wcls routine to clear the screen"); debugcrlf();
debugstr ("using random colors as fast as it can until you press a key."); debugcrlf();
debugstr ("It will then report the highest frame rate possible on your computer."); debugcrlf(); debugcrlf(); debugcrlf();
debugstr ("This program will use the wcls routine"); debugcrlf();
debugstr ("to clear the screen using random"); debugcrlf();
debugstr ("colors as fast as it can until you"); debugcrlf();
debugstr ("press a key."); debugcrlf(); debugcrlf();
debugstr ("It will then report the highest frame"); debugcrlf();
debugstr ("rate possible on your computer."); debugcrlf(); debugcrlf(); debugcrlf();
int el = get_el();
debugstr("Exception level: "); debughex(el); debugcrlf();
@ -109,7 +112,8 @@ void wgt03()
unsigned int fps = clearcount / (timer / TIMERSPEED);
debughex(fps); debugstr("frames per second"); debugcrlf(); debugcrlf(); debugcrlf();
debugstr ("This is the highest frame rate your computer can produce for full screen\n"); debugcrlf();
debugstr ("This is the highest frame rate your"); debugcrlf();
debugstr ("computer can produce for full screen"); debugcrlf();
debugstr ("animation.");
}

View file

@ -62,7 +62,7 @@ void wgt04()
ctr = 0; /* Start counter for first primitive */
do {
wclip (0, 0, 1919, 1079); /* Clip to full screen */
wclip (0, 0, 319, 199); /* Clip to full screen */
wouttextxy (230, 0, NULL, "WGT DEMO 4"); /* Display text */
switch (ctr) /* Show primitive type */
{
@ -83,20 +83,20 @@ void wgt04()
wsetpalette (0, 255, pal);
break;
}
wclip (0, 8, 1919, 1079); /* Clip all primitives below text line */
wclip (0, 8, 319, 199); /* Clip all primitives below text line */
do {
x = rand() % 1920; /* Randomize first point - (x,y) */
y = rand() % 1080;
x2 = rand() % 1920; /* Randomize second point - (x2,y2) */
y2 = rand() % 1080;
x = rand() % 320; /* Randomize first point - (x,y) */
y = rand() % 200;
x2 = rand() % 320; /* Randomize second point - (x2,y2) */
y2 = rand() % 200;
col = rand() % 256; /* Pick a color index to use */
wsetcolor (vgapal[col]); /* Now use it */
switch (ctr) /* Perform primitive */
{
case 0 : wline (x, y, x2, y2); break;
case 1 : wfline (x, rand() % 1072 + 8, x2, rand() % 1072 + 8); break;
case 1 : wfline (x, rand() % 192 + 8, x2, rand() % 192 + 8); break;
case 2 : wrectangle (x, y, x2, y2); break;
case 3 : wbar (x, y, x2, y2); break;
case 4 : wcircle (x, y, rand() % MAX_RADIUS); break;
@ -105,7 +105,7 @@ void wgt04()
rand() % MAX_RADIUS); break;
case 7 : wfill_ellipse (x, y, rand() % MAX_RADIUS,
rand() % MAX_RADIUS); break;
case 8 : wstyleline (x, rand() % 1072 + 8, x2, rand() % 1072 + 8,
case 8 : wstyleline (x, rand() % 192 + 8, x2, rand() % 192 + 8,
rand() ); break;
case 9 : wbutt (x, y, x2, y2); break;
}

View file

@ -75,8 +75,8 @@ void wgt07()
wtexttransparent (TEXTFGBG); /* Turn foreground and background on */
do {
x = rand() % 1920;
y = rand() % 1080;
x = rand() % 320;
y = rand() % 200;
col = rand() % 256;
wtextcolor (vgapal[col]);
wouttextxy (x, y, NULL, "WordUp Graphics Toolkit");
@ -87,8 +87,8 @@ void wgt07()
wtextgrid (TEXTGRID_ON);
do {
x = rand() % 240;
y = rand() % 135;
x = rand() % 80;
y = rand() % 25;
col = rand() % 256;
wtextcolor (vgapal[col]);
wtextbackground (vgapal[rand() % 256]);

View file

@ -59,11 +59,11 @@ void wgt08()
wcls (vgapal[0]);
wsetcolor (vgapal[1]);
wcircle (960, 540, 270); /* try filling a circle */
wcircle (160, 100, 50); /* try filling a circle */
getch ();
wsetcolor (vgapal[40]);
wregionfill (960, 540);
wregionfill (160, 100);
wsetcolor (vgapal[170]);
wregionfill (0, 0);
@ -73,24 +73,24 @@ void wgt08()
for (x = 1; x < 10000; x++) /* try filling 10,000 random pixels */
{
wsetcolor (vgapal[rand() % 255]);
wputpixel (rand() % 1920, rand() % 1080);
wputpixel (rand() % 320, rand() % 200);
}
getch ();
wsetcolor (vgapal[40]);
wclip (300, 270, 1500, 810); /* fill works with clipping too! */
wregionfill (960, 540);
wclip (50, 50, 250, 150); /* fill works with clipping too! */
wregionfill (160, 100);
wsetcolor (vgapal[7]);
wclip (60, 54, 240, 216);
wregionfill (120, 108);
wclip (10, 10, 40, 40);
wregionfill (20, 20);
wsetcolor (vgapal[9]);
wclip (1560, 864, 1800, 1026);
wregionfill (1620, 918);
wclip (260, 160, 300, 190);
wregionfill (270, 170);
wsetcolor (vgapal[10]);
wclip (0, 0, 1919, 1079);
wclip (0, 0, 319, 199);
wregionfill (0, 0);
getch ();

View file

@ -61,22 +61,24 @@ void wgt09()
mem_init();
vga256 ();
for (i = 1; i < 1080; i++)
for (i = 1; i < 200; i++)
{
wsetcolor (vgapal[i % 255]);
wline (0, 0, 1919, i);
wline (1919, 1079, 0, 1079 - i);
wsetcolor (vgapal[i]);
wline (0, 0, 319, i);
wline (319, 199, 0, 199 - i);
}
screen1 = wnewblock (0, 0, 1919, 1079); /* capture the entire screen */
part1 = wnewblock (0, 0, 900, 810); /* get a part of the screen */
getch();
screen1 = wnewblock (0, 0, 319, 199); /* capture the entire screen */
part1 = wnewblock (0, 0, 150, 150); /* get a part of the screen */
/* Note that wnewblock allocates the memory for the block */
wcls (vgapal[0]);
do {
x = rand() % 1920;
y = rand() % 1080;
x = rand() % 320;
y = rand() % 200;
wputblock (x, y, part1, 0); /* put the part somewhere */
} while (!kbhit ());
@ -85,8 +87,6 @@ void wgt09()
wputblock (0, 0, screen1, 0); /* replace the mess with the */
/* original screen */
getch (); /* get the key */
wfreeblock (screen1); /* *** make sure to free the memory! */
wfreeblock (part1);
}

View file

@ -60,32 +60,32 @@ void wgt10()
mem_init();
vga256 ();
for (y = 216; y >= 4; y--)
for (y = 40; y >= 4; y--)
{
wfill_circle (y + 40, y + 10, y); /* draw a pattern */
wsetcolor (vgapal[(y % 235) + 20]);
wsetcolor (vgapal[y + 20]);
}
part1 = wnewblock (0, 0, 960, 540); /* get the circle in a block */
part1 = wnewblock (0, 0, 160, 100); /* get the circle in a block */
getch();
wcls (0);
for (x = 0; x < 1920; x++)
for (x = 0; x < 320; x++)
{
wsetcolor (vgapal[x % 255]);
wline (x, 0, x, 1079);
wline (x, 0, x, 199);
}
getch();
wputblock (960, 0, part1, 0); /* normal mode */
wputblock (160, 0, part1, 0); /* normal mode */
wflipblock (part1, 0);
wputblock (960, 540, part1, 1); /* XRAY mode */
wputblock (160, 100, part1, 1); /* XRAY mode */
wflipblock (part1, 1);
wputblock (0, 540, part1, 0); /* normal mode */
wputblock (0, 100, part1, 0); /* normal mode */
wflipblock (part1, 0);
wputblock (0, 0, part1, 1); /* XRAY mode */

View file

@ -2,7 +2,7 @@
block abuf; /* pointer to the active screen */
unsigned int currentcolor;
short tx = 0,ty = 0,bx = 1919,by = 1079; /* clipping variables */
short tx = 0,ty = 0,bx = 319,by = 199; /* clipping variables */
int curx = 0;
int cury = 0;
@ -65,10 +65,10 @@ void wcls (unsigned int col)
}
void debugstr(char *str) {
if (curx + (strlen(str) * 8) >= 1920) {
if (curx + (strlen(str) * 8) >= 320) {
curx = 0; cury += 8;
}
if (cury + 8 >= 1080) {
if (cury + 8 >= 200) {
cury = 0;
}
wtextcolor(vgapal[15]);

View file

@ -14,8 +14,10 @@ void vga256(void)
mbox[7] = MBOX_TAG_SETVIRTWH;
mbox[8] = 8;
mbox[9] = 8;
mbox[10] = 1920;
mbox[11] = 1080;
//mbox[10] = 1920;
//mbox[11] = 1080;
mbox[10] = 320;
mbox[11] = 200;
mbox[12] = MBOX_TAG_SETVIRTOFF;
mbox[13] = 8;