From 00ecf6e9a925f2edfe7d5a1277dc239478bcb3fb Mon Sep 17 00:00:00 2001 From: Henri Vasserman Date: Thu, 2 Dec 2021 01:01:48 +0200 Subject: [PATCH] changes --- picture.c | 16 +++++++++------- xormod.c | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/picture.c b/picture.c index b4c6587..7018999 100644 --- a/picture.c +++ b/picture.c @@ -23,17 +23,19 @@ Picture *Picture_new(SDL_Renderer *rend, return p; } -typedef uint32_t uint32_8 __attribute__ ((vector_size (8 * sizeof(uint32_t)))); +typedef uint32_t uint32_4 __attribute__ ((vector_size (4 * sizeof(uint32_t)))); void Picture_render(Picture *p, SDL_Renderer *rend) { int w = p->w, h = p->h; - uint32_8 c = p->color - (uint32_8){}; - uint32_8 y = p->y1 - (uint32_8){}; + uint32_4 c = {p->color, p->color, p->color, p->color}; + const uint32_4 y0 = { 0, 0, 0, 0 }; + const uint32_4 x0 = { 0, 1, 2, 3 }; + uint32_4 y = y0 + p->y1; for (int j = 0, r = 0; j < h; j++, y += 1) { - uint32_8 x = p->x1 + (uint32_8){0, 1, 2, 3, 4, 5, 6, 7}; - for (int i = 0; i < w; i += 8,r += 8, x += 8) { - uint32_8 z = (x ^ y) % 9; - uint32_8 f = (z==0) & c; + uint32_4 x = x0 + p->x1; + for (int i = 0; i < w; i += 4, r += 4, x += 4) { + uint32_4 z = (x ^ y) % 9; + uint32_4 f = (z==0) & c; memcpy(&p->pixels[r], (uint32_t*)&f, sizeof(f)); } } diff --git a/xormod.c b/xormod.c index 6789ace..37f7783 100644 --- a/xormod.c +++ b/xormod.c @@ -19,7 +19,7 @@ int main() { SDL_Window *window = SDL_CreateWindow("xormod", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, - ACCEL_PLATFORM | SDL_WINDOW_FULLSCREEN); + ACCEL_PLATFORM); if (window == NULL) { fprintf(stderr, "Can't open window: %s\n", SDL_GetError()); return -1;