summaryrefslogtreecommitdiff
path: root/src/screen.c
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-02-03 14:36:26 -0500
committerFreya Murphy <freya@freyacat.org>2024-02-03 14:41:52 -0500
commit8e74123683072deed9ecd29e76037a16a47e3295 (patch)
tree2a4d6394688ed23b9360ff87c8d9861ab40da01d /src/screen.c
parentrefactor exception panic (diff)
downloadcorn-8e74123683072deed9ecd29e76037a16a47e3295.tar.gz
corn-8e74123683072deed9ecd29e76037a16a47e3295.tar.bz2
corn-8e74123683072deed9ecd29e76037a16a47e3295.zip
alloc on write paging, -O3 compile works, 'volatile' is the story of my life
Diffstat (limited to 'src/screen.c')
-rw-r--r--src/screen.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/screen.c b/src/screen.c
index 6f682ae..609797c 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -20,7 +20,7 @@ struct hsv {
uint16_t v;
};
-static uint32_t *buffer = NULL;
+static volatile uint32_t *buffer = NULL;
static uint32_t width, height;
static uint8_t bit_depth;
@@ -39,7 +39,12 @@ static float fabs(float f) {
return f > 0 ? f : -f;
}
-static struct rgb htor(struct hsv hsv) {
+static struct rgb gethsv(uint16_t a, uint16_t xp, uint16_t yp) {
+ struct hsv hsv = {
+ .h = a,
+ .s = xp * 100.0 / width,
+ .v = (height - yp) * 100.0 / height,
+ };
struct rgb rgb;
float s = hsv.s / 100.0;
float v = hsv.v / 100.0;
@@ -69,14 +74,16 @@ static struct rgb htor(struct hsv hsv) {
return rgb;
}
-static struct rgb get_color(uint16_t a, uint16_t x, uint16_t y) {
- struct hsv hsv = {
- .h = a,
- .s = x * 100.0 / width,
- .v = y * 100.0 / height,
- };
- return htor(hsv);
-}
+//static struct rgb getsrgb(uint16_t x, uint16_t y) {
+// struct rgb color;// = get_color(angle, x, height - y);
+// double _x = (double) x / width;
+// double _y = (double) y / height;
+// double _z = (2 - _x - _y) / 2;
+// color.r = _x * 255;
+// color.g = _y * 255;
+// color.b = _z * 255;
+// return color;
+//}
void screen_init(void) {
angle = 0;
@@ -89,7 +96,7 @@ void screen_init(void) {
void screen_redraw(void) {
for (uint16_t y = 0; y < height; y++) {
for (uint16_t x = 0; x < width; x++) {
- struct rgb color = get_color(angle, x, height - y);
+ struct rgb color = gethsv(angle, x, y);
set_pixel(color, x, y);
}
}