From 88e258e68533b227af9c6cb7434b497e6a9eb6f1 Mon Sep 17 00:00:00 2001 From: Adam Greenwood-Byrne Date: Sat, 17 Apr 2021 21:24:59 +0100 Subject: [PATCH] Added template to samples directory for ease of development --- part12-wgt/samples/template.c | 57 +++++++++++++++++++++++++++++++++++ part12-wgt/samples/wgt36.c | 4 --- 2 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 part12-wgt/samples/template.c diff --git a/part12-wgt/samples/template.c b/part12-wgt/samples/template.c new file mode 100644 index 0000000..f4be7dc --- /dev/null +++ b/part12-wgt/samples/template.c @@ -0,0 +1,57 @@ +#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 wgt37() +{ + set_clock_rate(get_max_clock()); + mem_init(); + vga256 (); /* Initialize graphics mode */ + + start_core2(minit); // Start the comms engine (core 2) + while (!comms_up); // Wait for comms up + + mdeinit (); /* Deinitialize the mouse handler */ +} + +void main() +{ + wgt37(); + while (1); +} diff --git a/part12-wgt/samples/wgt36.c b/part12-wgt/samples/wgt36.c index 8072e63..4f75225 100644 --- a/part12-wgt/samples/wgt36.c +++ b/part12-wgt/samples/wgt36.c @@ -38,10 +38,6 @@ void getch(void) { // ######## WGT EXAMPLES ######## -#define NUM_IN 5 /* number of random points */ -#define NUM_OUT 30 /* number of points of bezier curve */ -/* Fewer points will make more chunky line */ - int ox, oy; /* old mouse coordinates */ int i;