macos and clang changes
parent
af5522ca01
commit
1daf59732f
2
font.c
2
font.c
|
@ -1,6 +1,6 @@
|
||||||
#include "EGA8x8.h"
|
#include "EGA8x8.h"
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
SDL_Texture *load_font(SDL_Renderer *renderer) {
|
SDL_Texture *load_font(SDL_Renderer *renderer) {
|
||||||
SDL_Surface *s = SDL_LoadBMP_RW(SDL_RWFromConstMem(font_data, font_data_len), 1);
|
SDL_Surface *s = SDL_LoadBMP_RW(SDL_RWFromConstMem(font_data, font_data_len), 1);
|
||||||
|
|
2
font.h
2
font.h
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#define RC(r, c) (c)*font_w, (r)*font_h
|
#define RC(r, c) (c)*font_w, (r)*font_h
|
||||||
|
|
||||||
|
|
22
xormod.c
22
xormod.c
|
@ -2,7 +2,7 @@
|
||||||
#include "EGA8x8.h"
|
#include "EGA8x8.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#define SWAP(a, b) ({ \
|
#define SWAP(a, b) ({ \
|
||||||
__typeof(a) tmp = (a); \
|
__typeof(a) tmp = (a); \
|
||||||
|
@ -46,21 +46,19 @@ static Picture *Picture_new(SDL_Renderer *rend,
|
||||||
return p;
|
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) {
|
static void Picture_render(Picture *p, SDL_Renderer *rend) {
|
||||||
|
uint32_8 c = p->color - (uint32_8){};
|
||||||
for (int j = p->y1, r = 0; j < p->y2; j++) {
|
uint32_8 y = 0 - (uint32_8){};
|
||||||
uint32_4 y = {j, j, j, j};
|
for (int j = p->y1, r = 0; j < p->y2; j++, y+=1) {
|
||||||
for (int i = p->x1; i < p->x2; i+=4, r+=4) {
|
uint32_8 x = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||||
uint32_4 x = {i, i + 1, i + 2, i + 3};
|
for (int i = p->x1; i < p->x2; i+=8, r+=8, x+=8) {
|
||||||
uint32_4 z = (x ^ y) % 9;
|
uint32_8 z = (x ^ y) % 9;
|
||||||
uint32_4 f = (z==0) & p->color;
|
uint32_8 f = (z==0) & c;
|
||||||
memcpy(&p->pixels[r], (uint32_t*)&f, sizeof(f));
|
memcpy(&p->pixels[r], (uint32_t*)&f, sizeof(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->texture) SDL_DestroyTexture(p->texture);
|
if (p->texture) SDL_DestroyTexture(p->texture);
|
||||||
p->texture = SDL_CreateTextureFromSurface(rend, p->surface);
|
p->texture = SDL_CreateTextureFromSurface(rend, p->surface);
|
||||||
SDL_SetTextureBlendMode(p->texture, SDL_BLENDMODE_NONE);
|
SDL_SetTextureBlendMode(p->texture, SDL_BLENDMODE_NONE);
|
||||||
|
@ -77,7 +75,7 @@ struct int2 { int x; int y; };
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
unsigned w = 1280, h = 720;
|
int w = 1280, h = 720;
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||||
fprintf(stderr, "Can't init: %s\n", SDL_GetError());
|
fprintf(stderr, "Can't init: %s\n", SDL_GetError());
|
||||||
|
|
Loading…
Reference in New Issue