diff --git a/font.c b/font.c index 24695a2..f4f250d 100644 --- a/font.c +++ b/font.c @@ -1,6 +1,6 @@ #include "EGA8x8.h" -#include +#include SDL_Texture *load_font(SDL_Renderer *renderer) { SDL_Surface *s = SDL_LoadBMP_RW(SDL_RWFromConstMem(font_data, font_data_len), 1); diff --git a/font.h b/font.h index e175ba9..cadee9a 100644 --- a/font.h +++ b/font.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #define RC(r, c) (c)*font_w, (r)*font_h diff --git a/xormod.c b/xormod.c index a91d6d7..c892431 100644 --- a/xormod.c +++ b/xormod.c @@ -2,7 +2,7 @@ #include "EGA8x8.h" #include -#include +#include #define SWAP(a, b) ({ \ __typeof(a) tmp = (a); \ @@ -46,21 +46,19 @@ static Picture *Picture_new(SDL_Renderer *rend, return p; } -typedef uint32_t uint32_4 __attribute__ ((vector_size (4 * sizeof(uint32_t)))); +typedef uint32_t uint32_8 __attribute__ ((vector_size (8 * sizeof(uint32_t)))); static void Picture_render(Picture *p, SDL_Renderer *rend) { - - for (int j = p->y1, r = 0; j < p->y2; j++) { - uint32_4 y = {j, j, j, j}; - for (int i = p->x1; i < p->x2; i+=4, r+=4) { - uint32_4 x = {i, i + 1, i + 2, i + 3}; - uint32_4 z = (x ^ y) % 9; - uint32_4 f = (z==0) & p->color; + uint32_8 c = p->color - (uint32_8){}; + uint32_8 y = 0 - (uint32_8){}; + for (int j = p->y1, r = 0; j < p->y2; j++, y+=1) { + uint32_8 x = {0, 1, 2, 3, 4, 5, 6, 7}; + for (int i = p->x1; i < p->x2; i+=8, r+=8, x+=8) { + uint32_8 z = (x ^ y) % 9; + uint32_8 f = (z==0) & c; memcpy(&p->pixels[r], (uint32_t*)&f, sizeof(f)); } - } - if (p->texture) SDL_DestroyTexture(p->texture); p->texture = SDL_CreateTextureFromSurface(rend, p->surface); SDL_SetTextureBlendMode(p->texture, SDL_BLENDMODE_NONE); @@ -77,7 +75,7 @@ struct int2 { int x; int y; }; int main() { - unsigned w = 1280, h = 720; + int w = 1280, h = 720; if (SDL_Init(SDL_INIT_VIDEO) != 0) { fprintf(stderr, "Can't init: %s\n", SDL_GetError());