shithub: npe

Download patch

ref: b503ec27fd78fcde08968ba62ef45714a5b2254e
parent: 9b9baca20eb6f5b86c460b5e7c0d3733fd5c6983
author: Jacob Moody <moody@posixcafe.org>
date: Sun Feb 12 02:12:13 EST 2023

cleanup

--- a/libnpe_sdl2/mixer.c
+++ b/libnpe_sdl2/mixer.c
@@ -88,8 +88,8 @@
 		return -1;
 	}
 	n = SDL_OpenAudioDevice(nil, 0, as, nil, 0);
-	SDL_PauseAudioDevice(2, 0);
-	
+	assert(n >= 0);
+	SDL_PauseAudioDevice(n, 0);
 	return 1;
 }
 
--- a/libnpe_sdl2/rwops.c
+++ b/libnpe_sdl2/rwops.c
@@ -225,7 +225,6 @@
 	uchar *p, *dot;
 	uchar *end;
 	size_t i;
-	vlong x;
 
 	buf = (Membuf*)o->p;
 	end = buf->memdata + buf->memn;
@@ -274,5 +273,6 @@
 static int
 memclose(struct SDL_RWops *o)
 {
+	free(o);
 	return 0;
 }
--- a/libnpe_sdl2/sdl2.c
+++ b/libnpe_sdl2/sdl2.c
@@ -450,9 +450,8 @@
 SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
 {
 	Rectangle r, r2;
-	Memimage *i, *i2;
 	SDL_Color *c;
-	Uint8 *buf, *to, *buf2;
+	Uint8 *to;
 	int j;
 
 	r = srcrect == nil ? Rect(0, 0, src->w, src->h) : Rect(srcrect->x, srcrect->y, srcrect->x+srcrect->w, srcrect->y+srcrect->h);
@@ -474,25 +473,9 @@
 		break;
 	}
 
-	switch(dst->format->format){
-	case SDL_PIXELFORMAT_ARGB8888:
-	case SDL_PIXELFORMAT_XRGB8888:
-		break;
-	case SDL_PIXELFORMAT_INDEX8:
-		to = buf2 = malloc(dst->n * 4);
-		for(j = 0; j < dst->n; j++){
-			c = dst->format->palette->colors + dst->pixels[j];
-			*to++ = c->b;
-			*to++ = c->g;
-			*to++ = c->r;
-			*to++ = c->a;
-		}
-		break;
-	}
-
-	memimagedraw(dst->i, r2, src->i, ZP, nil, ZP, S);
-
+	/* FIXME */
 	assert(dst->format->format != SDL_PIXELFORMAT_INDEX8);
+	memimagedraw(dst->i, r2, src->i, ZP, nil, ZP, S);
 	return 0;
 }