mirror of
https://github.com/isometimes/rpi4-osdev
synced 2024-11-25 03:30:39 +00:00
Added samples/wgt15.c and samples/wgt16.c
This commit is contained in:
parent
74e4fb6f87
commit
1147917580
2 changed files with 168 additions and 0 deletions
83
part12-wgt/samples/wgt15.c
Normal file
83
part12-wgt/samples/wgt15.c
Normal file
|
@ -0,0 +1,83 @@
|
|||
#include "include/wgt.h"
|
||||
#include "include/mem.h"
|
||||
#include "include/multicore.h"
|
||||
|
||||
// ######## REQUIRED FUNCTIONS ########
|
||||
|
||||
unsigned long state0 = 1000;
|
||||
unsigned long state1 = 2000;
|
||||
|
||||
unsigned long rand(void)
|
||||
{
|
||||
unsigned long s1 = state0;
|
||||
unsigned long s0 = state1;
|
||||
|
||||
state0 = s0;
|
||||
s1 ^= s1 << 23;
|
||||
s1 ^= s1 >> 17;
|
||||
s1 ^= s0;
|
||||
s1 ^= s0 >> 26;
|
||||
state1 = s1;
|
||||
|
||||
return state0 + state1;
|
||||
}
|
||||
|
||||
// ######## STUB FUNCTIONS ########
|
||||
|
||||
unsigned int kb = 0;
|
||||
|
||||
unsigned int kbhit(void) {
|
||||
kb++;
|
||||
return kb / 500;
|
||||
}
|
||||
|
||||
void getch(void) {
|
||||
wait_msec(0x500000);
|
||||
kb = 0;
|
||||
}
|
||||
|
||||
// ######## WGT EXAMPLES ########
|
||||
|
||||
void wgt15()
|
||||
{
|
||||
short y;
|
||||
block screen1;
|
||||
|
||||
set_clock_rate(get_max_clock());
|
||||
mem_init();
|
||||
vga256 (); /* Initializes WGT system */
|
||||
|
||||
start_core2(minit); // Start the comms engine (core 2)
|
||||
while (!comms_up); // Wait for comms up
|
||||
|
||||
screen1 = wnewblock (0, 0, 119, 129);
|
||||
/* Virtual screens can now be any size, as long as they fit within one
|
||||
segment (64k) */
|
||||
|
||||
wtextcolor (vgapal[15]);
|
||||
wouttextxy (0, 0, NULL, "Click the mouse button in a few seconds");
|
||||
wsetscreen (screen1); /* sets to screen1 */
|
||||
|
||||
for (y = 0; y < 200; y++)
|
||||
{
|
||||
wsetcolor (vgapal[y]);
|
||||
wline (0, 0, 319, y); /* draw something on another screen */
|
||||
wline (319, 199, 0, y);
|
||||
}
|
||||
|
||||
while (!but); // wait for a mouse press
|
||||
|
||||
/* now use putblock to show what happened on the other screen */
|
||||
|
||||
wnormscreen (); /* make the putblock go onto the default screen */
|
||||
wputblock (0, 10, screen1, 0);
|
||||
|
||||
wfreeblock (screen1);
|
||||
/* remember to free that memory (64004 bytes for a screen) */
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
wgt15();
|
||||
while (1);
|
||||
}
|
85
part12-wgt/samples/wgt16.c
Normal file
85
part12-wgt/samples/wgt16.c
Normal file
|
@ -0,0 +1,85 @@
|
|||
#include "include/wgt.h"
|
||||
#include "include/mem.h"
|
||||
#include "include/multicore.h"
|
||||
|
||||
// ######## REQUIRED FUNCTIONS ########
|
||||
|
||||
unsigned long state0 = 1000;
|
||||
unsigned long state1 = 2000;
|
||||
|
||||
unsigned long rand(void)
|
||||
{
|
||||
unsigned long s1 = state0;
|
||||
unsigned long s0 = state1;
|
||||
|
||||
state0 = s0;
|
||||
s1 ^= s1 << 23;
|
||||
s1 ^= s1 >> 17;
|
||||
s1 ^= s0;
|
||||
s1 ^= s0 >> 26;
|
||||
state1 = s1;
|
||||
|
||||
return state0 + state1;
|
||||
}
|
||||
|
||||
// ######## STUB FUNCTIONS ########
|
||||
|
||||
unsigned int kb = 0;
|
||||
|
||||
unsigned int kbhit(void) {
|
||||
kb++;
|
||||
return kb / 500;
|
||||
}
|
||||
|
||||
void getch(void) {
|
||||
wait_msec(0x500000);
|
||||
kb = 0;
|
||||
}
|
||||
|
||||
// ######## WGT EXAMPLES ########
|
||||
|
||||
void wgt16()
|
||||
{
|
||||
short y, tempx, tempy;
|
||||
block screen1;
|
||||
|
||||
set_clock_rate(get_max_clock());
|
||||
mem_init();
|
||||
vga256 (); /* Initializes WGT system */
|
||||
|
||||
start_core2(minit); // Start the comms engine (core 2)
|
||||
while (!comms_up); // Wait for comms up
|
||||
|
||||
screen1 = wnewblock (0, 0, 319, 199);
|
||||
|
||||
wsetscreen (screen1); /* sets to screen1 */
|
||||
for (y = 0; y < 200; y++)
|
||||
{
|
||||
wsetcolor (vgapal[y]);
|
||||
wfline (0, 0, 319, y); /* draw something on another screen */
|
||||
wfline (319, 199, 0, y);
|
||||
}
|
||||
|
||||
wnormscreen (); /* make the putblock go onto the default screen */
|
||||
|
||||
do {
|
||||
tempx = mx;
|
||||
tempy = my;
|
||||
wcopyscreen (tempx, tempy, tempx + 19, tempy + 19, screen1,
|
||||
tempx, tempy, NULL);
|
||||
/* this means copy a square 20*20 from screen1 to the same spot
|
||||
on the default screen. Move the mouse around and watch the black
|
||||
wipe away as screen1 copies over. */
|
||||
|
||||
/* NULL means the default screen. */
|
||||
} while (!but);
|
||||
|
||||
mdeinit (); /* Deinitialize the mouse handler */
|
||||
wfreeblock (screen1);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
wgt16();
|
||||
while (1);
|
||||
}
|
Loading…
Reference in a new issue