main
Henri Vasserman 2021-12-02 01:01:48 +02:00
parent c0676f8845
commit 00ecf6e9a9
2 changed files with 10 additions and 8 deletions

View File

@ -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));
}
}

View File

@ -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;