This commit is contained in:
condret 2024-10-06 02:34:09 +02:00
parent eda42fb4d9
commit 5a29912796
2 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,10 @@
LDFLAGS = $(shell pkg-config --libs sdl2 r_util r_io)
CFLAGS = -Wall -I include/ $(shell pkg-config --cflags sdl2 r_util r_io)
all: sdl/pixbuf.o io/timers.o
sdl/pixbuf.o:
gcc -c sdl/pixbuf.c -o sdl/pixbuf.o $(CFLAGS)
io/timers.o:
gcc -c io/timers.c -o io/timers.o $(CFLAGS)

View File

@ -19,7 +19,7 @@ GBPixBuf *gb_pix_buf_new (SDL_Renderer *renderer, ut16 w, ut16 h) {
}
pb->texture = SDL_CreateTexture (renderer, SDL_PIXELFORMAT_ARGB32,
SDL_TEXTUREACCESS_TARGET, w, h);
if (!texture) {
if (!pb->texture) {
free (pb->buf);
free (pb);
return NULL;
@ -46,7 +46,7 @@ void gb_pix_buf_set_pixel (GBPixBuf *pb, ut16 x, ut16 y, ut8 pixval) {
const ut32 bytepos = bitpos >> 3;
const ut32 shl = bitpos & 0x6;
pixval = pixval & 0x3;
const ut8 mask = ~(0x3 << shl)
const ut8 mask = ~(0x3 << shl);
pb->buf[bytepos] = (pb->buf[bytepos] & mask) | (pixval << shl);
SDL_Texture *target = SDL_GetRenderTarget (pb->renderer);
SDL_SetRenderTarget (pb->renderer, pb->texture);