From 239a0690e1e5a5e00b02019f75f7afc283275b99 Mon Sep 17 00:00:00 2001 From: Adam Greenwood-Byrne Date: Fri, 19 Mar 2021 19:59:27 +0000 Subject: [PATCH] Added wbezier.c, wspoly.c - exercised by examples/wgt33.c, fixed memory alignment issue with lib/mem.c --- part12-wgt/examples/wgt33.c | 99 +++++++++++++++++++++++++++++++++++ part12-wgt/lib/mem.c | 7 ++- part12-wgt/wbezier.c | 59 +++++++++++++++++++++ part12-wgt/wgt.h | 16 ++++++ part12-wgt/winitply.c | 41 +++++++++++++++ part12-wgt/wspoly.c | 100 ++++++++++++++++++++++++++++++++++++ 6 files changed, 320 insertions(+), 2 deletions(-) create mode 100644 part12-wgt/examples/wgt33.c create mode 100644 part12-wgt/wbezier.c create mode 100644 part12-wgt/winitply.c create mode 100644 part12-wgt/wspoly.c diff --git a/part12-wgt/examples/wgt33.c b/part12-wgt/examples/wgt33.c new file mode 100644 index 0000000..3c1b6c0 --- /dev/null +++ b/part12-wgt/examples/wgt33.c @@ -0,0 +1,99 @@ +#include "wgt.h" +#include "include/mem.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; +} + +void wait_msec(unsigned int n) +{ + register unsigned long f, t, r; + + // Get the current counter frequency + asm volatile ("mrs %0, cntfrq_el0" : "=r"(f)); + // Read the current counter + asm volatile ("mrs %0, cntpct_el0" : "=r"(t)); + // Calculate expire value for counter + t+=((f/1000)*n)/1000; + do{asm volatile ("mrs %0, cntpct_el0" : "=r"(r));}while(r