mirror of
https://github.com/isometimes/rpi4-osdev
synced 2024-11-22 10:10:45 +00:00
Refactored for 320x200 - going retro after all
This commit is contained in:
parent
ef1cd6d4df
commit
54b30f1684
10 changed files with 68 additions and 64 deletions
|
@ -1,5 +1,4 @@
|
||||||
#include "wgt.h"
|
#include "wgt.h"
|
||||||
#include "wpal.h"
|
|
||||||
|
|
||||||
// ######## WGT EXAMPLES ########
|
// ######## WGT EXAMPLES ########
|
||||||
|
|
||||||
|
@ -7,7 +6,7 @@ void wgt01()
|
||||||
{
|
{
|
||||||
vga256 (); /* Initializes WGT system */
|
vga256 (); /* Initializes WGT system */
|
||||||
wsetcolor (vgapal[15]);
|
wsetcolor (vgapal[15]);
|
||||||
wline (0, 0, 1919, 1079); /* Draw a line */
|
wline (0, 0, 319, 199); /* Draw a line */
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "wgt.h"
|
#include "wgt.h"
|
||||||
#include "wpal.h"
|
|
||||||
|
|
||||||
// ######## REQUIRED FUNCTIONS ########
|
// ######## REQUIRED FUNCTIONS ########
|
||||||
|
|
||||||
|
@ -60,17 +59,17 @@ void wgt02()
|
||||||
|
|
||||||
/* Put randomly coloured pixels in random screen coordinates */
|
/* Put randomly coloured pixels in random screen coordinates */
|
||||||
do {
|
do {
|
||||||
wsetcolor (vgapal[rand () % 256]);
|
wsetcolor (vgapal[rand () % 255]);
|
||||||
x = rand () % 1920;
|
x = rand () % 320;
|
||||||
y = rand() % 1080;
|
y = rand() % 200;
|
||||||
wputpixel (x, y);
|
wputpixel (x, y);
|
||||||
} while (kbhit () == 0);
|
} while (kbhit () == 0);
|
||||||
getch ();
|
getch ();
|
||||||
|
|
||||||
wcls (vgapal[0]); /* Clear screen with color 0 */
|
wcls (vgapal[0]); /* Clear screen with color 0 */
|
||||||
wsetcolor (vgapal[10]); /* Now we will draw with #10 */
|
wsetcolor (vgapal[10]); /* Now we will draw with #10 */
|
||||||
for (x = 0; x < 1920; x++)
|
for (x = 0; x < 320; x++)
|
||||||
for (y = 0; y < 1080; y++)
|
for (y = 0; y < 200; y++)
|
||||||
wfastputpixel (x, y); /* Fast due to no clipping checking */
|
wfastputpixel (x, y); /* Fast due to no clipping checking */
|
||||||
|
|
||||||
getch ();
|
getch ();
|
||||||
|
@ -79,18 +78,18 @@ void wgt02()
|
||||||
/* Put randomly coloured pixels in the top left corner of the screen */
|
/* Put randomly coloured pixels in the top left corner of the screen */
|
||||||
for (i = 0; i < 15000; i++)
|
for (i = 0; i < 15000; i++)
|
||||||
{
|
{
|
||||||
wsetcolor (vgapal[rand () % 256]);
|
wsetcolor (vgapal[rand () % 255]);
|
||||||
x = rand () % 960;
|
x = rand () % 160;
|
||||||
y = rand () % 540;
|
y = rand () % 100;
|
||||||
wputpixel (x, y);
|
wputpixel (x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now use wgetpixel to read image off screen */
|
/* Now use wgetpixel to read image off screen */
|
||||||
for (y = 0; y < 540; y++)
|
for (y = 0; y < 100; y++)
|
||||||
for (x = 0; x < 960; x++)
|
for (x = 0; x < 160; x++)
|
||||||
{
|
{
|
||||||
wsetcolor (wgetpixel (x, y));
|
wsetcolor (wgetpixel (x, y));
|
||||||
wputpixel (x + 960, y + 540);
|
wputpixel (x + 160, y + 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
getch ();
|
getch ();
|
||||||
|
|
|
@ -40,7 +40,7 @@ unsigned int kb = 0;
|
||||||
|
|
||||||
unsigned int kbhit(void) {
|
unsigned int kbhit(void) {
|
||||||
kb++;
|
kb++;
|
||||||
return kb / 500;
|
return kb / 15000;
|
||||||
}
|
}
|
||||||
|
|
||||||
void getch(void) {
|
void getch(void) {
|
||||||
|
@ -67,9 +67,12 @@ void wgt03()
|
||||||
vga256 (); /* Initialize WGT system */
|
vga256 (); /* Initialize WGT system */
|
||||||
|
|
||||||
debugstr ("WGT Example #3"); debugcrlf(); debugcrlf();
|
debugstr ("WGT Example #3"); debugcrlf(); debugcrlf();
|
||||||
debugstr ("This program will use the wcls routine to clear the screen"); debugcrlf();
|
debugstr ("This program will use the wcls routine"); debugcrlf();
|
||||||
debugstr ("using random colors as fast as it can until you press a key."); debugcrlf();
|
debugstr ("to clear the screen using random"); debugcrlf();
|
||||||
debugstr ("It will then report the highest frame rate possible on your computer."); debugcrlf(); debugcrlf(); 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();
|
int el = get_el();
|
||||||
debugstr("Exception level: "); debughex(el); debugcrlf();
|
debugstr("Exception level: "); debughex(el); debugcrlf();
|
||||||
|
@ -109,7 +112,8 @@ void wgt03()
|
||||||
unsigned int fps = clearcount / (timer / TIMERSPEED);
|
unsigned int fps = clearcount / (timer / TIMERSPEED);
|
||||||
debughex(fps); debugstr("frames per second"); debugcrlf(); debugcrlf(); debugcrlf();
|
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.");
|
debugstr ("animation.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ void wgt04()
|
||||||
ctr = 0; /* Start counter for first primitive */
|
ctr = 0; /* Start counter for first primitive */
|
||||||
|
|
||||||
do {
|
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 */
|
wouttextxy (230, 0, NULL, "WGT DEMO 4"); /* Display text */
|
||||||
switch (ctr) /* Show primitive type */
|
switch (ctr) /* Show primitive type */
|
||||||
{
|
{
|
||||||
|
@ -83,20 +83,20 @@ void wgt04()
|
||||||
wsetpalette (0, 255, pal);
|
wsetpalette (0, 255, pal);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wclip (0, 8, 1919, 1079); /* Clip all primitives below text line */
|
wclip (0, 8, 319, 199); /* Clip all primitives below text line */
|
||||||
|
|
||||||
do {
|
do {
|
||||||
x = rand() % 1920; /* Randomize first point - (x,y) */
|
x = rand() % 320; /* Randomize first point - (x,y) */
|
||||||
y = rand() % 1080;
|
y = rand() % 200;
|
||||||
x2 = rand() % 1920; /* Randomize second point - (x2,y2) */
|
x2 = rand() % 320; /* Randomize second point - (x2,y2) */
|
||||||
y2 = rand() % 1080;
|
y2 = rand() % 200;
|
||||||
col = rand() % 256; /* Pick a color index to use */
|
col = rand() % 256; /* Pick a color index to use */
|
||||||
wsetcolor (vgapal[col]); /* Now use it */
|
wsetcolor (vgapal[col]); /* Now use it */
|
||||||
|
|
||||||
switch (ctr) /* Perform primitive */
|
switch (ctr) /* Perform primitive */
|
||||||
{
|
{
|
||||||
case 0 : wline (x, y, x2, y2); break;
|
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 2 : wrectangle (x, y, x2, y2); break;
|
||||||
case 3 : wbar (x, y, x2, y2); break;
|
case 3 : wbar (x, y, x2, y2); break;
|
||||||
case 4 : wcircle (x, y, rand() % MAX_RADIUS); break;
|
case 4 : wcircle (x, y, rand() % MAX_RADIUS); break;
|
||||||
|
@ -105,7 +105,7 @@ void wgt04()
|
||||||
rand() % MAX_RADIUS); break;
|
rand() % MAX_RADIUS); break;
|
||||||
case 7 : wfill_ellipse (x, y, rand() % MAX_RADIUS,
|
case 7 : wfill_ellipse (x, y, rand() % MAX_RADIUS,
|
||||||
rand() % MAX_RADIUS); break;
|
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;
|
rand() ); break;
|
||||||
case 9 : wbutt (x, y, x2, y2); break;
|
case 9 : wbutt (x, y, x2, y2); break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,8 +75,8 @@ void wgt07()
|
||||||
wtexttransparent (TEXTFGBG); /* Turn foreground and background on */
|
wtexttransparent (TEXTFGBG); /* Turn foreground and background on */
|
||||||
|
|
||||||
do {
|
do {
|
||||||
x = rand() % 1920;
|
x = rand() % 320;
|
||||||
y = rand() % 1080;
|
y = rand() % 200;
|
||||||
col = rand() % 256;
|
col = rand() % 256;
|
||||||
wtextcolor (vgapal[col]);
|
wtextcolor (vgapal[col]);
|
||||||
wouttextxy (x, y, NULL, "WordUp Graphics Toolkit");
|
wouttextxy (x, y, NULL, "WordUp Graphics Toolkit");
|
||||||
|
@ -87,8 +87,8 @@ void wgt07()
|
||||||
wtextgrid (TEXTGRID_ON);
|
wtextgrid (TEXTGRID_ON);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
x = rand() % 240;
|
x = rand() % 80;
|
||||||
y = rand() % 135;
|
y = rand() % 25;
|
||||||
col = rand() % 256;
|
col = rand() % 256;
|
||||||
wtextcolor (vgapal[col]);
|
wtextcolor (vgapal[col]);
|
||||||
wtextbackground (vgapal[rand() % 256]);
|
wtextbackground (vgapal[rand() % 256]);
|
||||||
|
|
|
@ -59,11 +59,11 @@ void wgt08()
|
||||||
wcls (vgapal[0]);
|
wcls (vgapal[0]);
|
||||||
|
|
||||||
wsetcolor (vgapal[1]);
|
wsetcolor (vgapal[1]);
|
||||||
wcircle (960, 540, 270); /* try filling a circle */
|
wcircle (160, 100, 50); /* try filling a circle */
|
||||||
getch ();
|
getch ();
|
||||||
|
|
||||||
wsetcolor (vgapal[40]);
|
wsetcolor (vgapal[40]);
|
||||||
wregionfill (960, 540);
|
wregionfill (160, 100);
|
||||||
wsetcolor (vgapal[170]);
|
wsetcolor (vgapal[170]);
|
||||||
wregionfill (0, 0);
|
wregionfill (0, 0);
|
||||||
|
|
||||||
|
@ -73,24 +73,24 @@ void wgt08()
|
||||||
for (x = 1; x < 10000; x++) /* try filling 10,000 random pixels */
|
for (x = 1; x < 10000; x++) /* try filling 10,000 random pixels */
|
||||||
{
|
{
|
||||||
wsetcolor (vgapal[rand() % 255]);
|
wsetcolor (vgapal[rand() % 255]);
|
||||||
wputpixel (rand() % 1920, rand() % 1080);
|
wputpixel (rand() % 320, rand() % 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
getch ();
|
getch ();
|
||||||
wsetcolor (vgapal[40]);
|
wsetcolor (vgapal[40]);
|
||||||
wclip (300, 270, 1500, 810); /* fill works with clipping too! */
|
wclip (50, 50, 250, 150); /* fill works with clipping too! */
|
||||||
wregionfill (960, 540);
|
wregionfill (160, 100);
|
||||||
|
|
||||||
wsetcolor (vgapal[7]);
|
wsetcolor (vgapal[7]);
|
||||||
wclip (60, 54, 240, 216);
|
wclip (10, 10, 40, 40);
|
||||||
wregionfill (120, 108);
|
wregionfill (20, 20);
|
||||||
|
|
||||||
wsetcolor (vgapal[9]);
|
wsetcolor (vgapal[9]);
|
||||||
wclip (1560, 864, 1800, 1026);
|
wclip (260, 160, 300, 190);
|
||||||
wregionfill (1620, 918);
|
wregionfill (270, 170);
|
||||||
|
|
||||||
wsetcolor (vgapal[10]);
|
wsetcolor (vgapal[10]);
|
||||||
wclip (0, 0, 1919, 1079);
|
wclip (0, 0, 319, 199);
|
||||||
wregionfill (0, 0);
|
wregionfill (0, 0);
|
||||||
|
|
||||||
getch ();
|
getch ();
|
||||||
|
|
|
@ -61,22 +61,24 @@ void wgt09()
|
||||||
mem_init();
|
mem_init();
|
||||||
vga256 ();
|
vga256 ();
|
||||||
|
|
||||||
for (i = 1; i < 1080; i++)
|
for (i = 1; i < 200; i++)
|
||||||
{
|
{
|
||||||
wsetcolor (vgapal[i % 255]);
|
wsetcolor (vgapal[i]);
|
||||||
wline (0, 0, 1919, i);
|
wline (0, 0, 319, i);
|
||||||
wline (1919, 1079, 0, 1079 - i);
|
wline (319, 199, 0, 199 - i);
|
||||||
}
|
}
|
||||||
|
|
||||||
screen1 = wnewblock (0, 0, 1919, 1079); /* capture the entire screen */
|
getch();
|
||||||
part1 = wnewblock (0, 0, 900, 810); /* get a part of the screen */
|
|
||||||
|
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 */
|
/* Note that wnewblock allocates the memory for the block */
|
||||||
|
|
||||||
wcls (vgapal[0]);
|
wcls (vgapal[0]);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
x = rand() % 1920;
|
x = rand() % 320;
|
||||||
y = rand() % 1080;
|
y = rand() % 200;
|
||||||
wputblock (x, y, part1, 0); /* put the part somewhere */
|
wputblock (x, y, part1, 0); /* put the part somewhere */
|
||||||
} while (!kbhit ());
|
} while (!kbhit ());
|
||||||
|
|
||||||
|
@ -85,8 +87,6 @@ void wgt09()
|
||||||
wputblock (0, 0, screen1, 0); /* replace the mess with the */
|
wputblock (0, 0, screen1, 0); /* replace the mess with the */
|
||||||
/* original screen */
|
/* original screen */
|
||||||
|
|
||||||
getch (); /* get the key */
|
|
||||||
|
|
||||||
wfreeblock (screen1); /* *** make sure to free the memory! */
|
wfreeblock (screen1); /* *** make sure to free the memory! */
|
||||||
wfreeblock (part1);
|
wfreeblock (part1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,32 +60,32 @@ void wgt10()
|
||||||
mem_init();
|
mem_init();
|
||||||
vga256 ();
|
vga256 ();
|
||||||
|
|
||||||
for (y = 216; y >= 4; y--)
|
for (y = 40; y >= 4; y--)
|
||||||
{
|
{
|
||||||
wfill_circle (y + 40, y + 10, y); /* draw a pattern */
|
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();
|
getch();
|
||||||
|
|
||||||
wcls (0);
|
wcls (0);
|
||||||
|
|
||||||
for (x = 0; x < 1920; x++)
|
for (x = 0; x < 320; x++)
|
||||||
{
|
{
|
||||||
wsetcolor (vgapal[x % 255]);
|
wsetcolor (vgapal[x % 255]);
|
||||||
wline (x, 0, x, 1079);
|
wline (x, 0, x, 199);
|
||||||
}
|
}
|
||||||
|
|
||||||
getch();
|
getch();
|
||||||
|
|
||||||
wputblock (960, 0, part1, 0); /* normal mode */
|
wputblock (160, 0, part1, 0); /* normal mode */
|
||||||
wflipblock (part1, 0);
|
wflipblock (part1, 0);
|
||||||
|
|
||||||
wputblock (960, 540, part1, 1); /* XRAY mode */
|
wputblock (160, 100, part1, 1); /* XRAY mode */
|
||||||
wflipblock (part1, 1);
|
wflipblock (part1, 1);
|
||||||
|
|
||||||
wputblock (0, 540, part1, 0); /* normal mode */
|
wputblock (0, 100, part1, 0); /* normal mode */
|
||||||
wflipblock (part1, 0);
|
wflipblock (part1, 0);
|
||||||
|
|
||||||
wputblock (0, 0, part1, 1); /* XRAY mode */
|
wputblock (0, 0, part1, 1); /* XRAY mode */
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
block abuf; /* pointer to the active screen */
|
block abuf; /* pointer to the active screen */
|
||||||
unsigned int currentcolor;
|
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 curx = 0;
|
||||||
int cury = 0;
|
int cury = 0;
|
||||||
|
@ -65,10 +65,10 @@ void wcls (unsigned int col)
|
||||||
}
|
}
|
||||||
|
|
||||||
void debugstr(char *str) {
|
void debugstr(char *str) {
|
||||||
if (curx + (strlen(str) * 8) >= 1920) {
|
if (curx + (strlen(str) * 8) >= 320) {
|
||||||
curx = 0; cury += 8;
|
curx = 0; cury += 8;
|
||||||
}
|
}
|
||||||
if (cury + 8 >= 1080) {
|
if (cury + 8 >= 200) {
|
||||||
cury = 0;
|
cury = 0;
|
||||||
}
|
}
|
||||||
wtextcolor(vgapal[15]);
|
wtextcolor(vgapal[15]);
|
||||||
|
|
|
@ -14,8 +14,10 @@ void vga256(void)
|
||||||
mbox[7] = MBOX_TAG_SETVIRTWH;
|
mbox[7] = MBOX_TAG_SETVIRTWH;
|
||||||
mbox[8] = 8;
|
mbox[8] = 8;
|
||||||
mbox[9] = 8;
|
mbox[9] = 8;
|
||||||
mbox[10] = 1920;
|
//mbox[10] = 1920;
|
||||||
mbox[11] = 1080;
|
//mbox[11] = 1080;
|
||||||
|
mbox[10] = 320;
|
||||||
|
mbox[11] = 200;
|
||||||
|
|
||||||
mbox[12] = MBOX_TAG_SETVIRTOFF;
|
mbox[12] = MBOX_TAG_SETVIRTOFF;
|
||||||
mbox[13] = 8;
|
mbox[13] = 8;
|
||||||
|
|
Loading…
Reference in a new issue