fix offsets

main
Henri Vasserman 2021-04-11 21:22:11 +03:00
parent 9d5ce88926
commit 28afef0324
1 changed files with 5 additions and 4 deletions

View File

@ -51,11 +51,12 @@ static Picture *Picture_new(SDL_Renderer *rend,
typedef uint32_t uint32_8 __attribute__ ((vector_size (8 * sizeof(uint32_t)))); typedef uint32_t uint32_8 __attribute__ ((vector_size (8 * sizeof(uint32_t))));
static void Picture_render(Picture *p, SDL_Renderer *rend) { static void Picture_render(Picture *p, SDL_Renderer *rend) {
int w = p->w, h = p->h;
uint32_8 c = p->color - (uint32_8){}; uint32_8 c = p->color - (uint32_8){};
uint32_8 y = 0 - (uint32_8){}; uint32_8 y = p->y1 - (uint32_8){};
for (int j = p->y1, r = 0; j < p->y2; j++, y+=1) { for (int j = 0, r = 0; j < h; j++, y += 1) {
uint32_8 x = {0, 1, 2, 3, 4, 5, 6, 7}; uint32_8 x = p->x1 + (uint32_8){0, 1, 2, 3, 4, 5, 6, 7};
for (int i = p->x1; i < p->x2; i+=8, r+=8, x+=8) { for (int i = 0; i < w; i += 8,r += 8, x += 8) {
uint32_8 z = (x ^ y) % 9; uint32_8 z = (x ^ y) % 9;
uint32_8 f = (z==0) & c; uint32_8 f = (z==0) & c;
memcpy(&p->pixels[r], (uint32_t*)&f, sizeof(f)); memcpy(&p->pixels[r], (uint32_t*)&f, sizeof(f));