aboutsummaryrefslogtreecommitdiff
path: root/src/cart.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cart.c')
-rw-r--r--src/cart.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/cart.c b/src/cart.c
index c9a8951..3e61e18 100644
--- a/src/cart.c
+++ b/src/cart.c
@@ -145,7 +145,7 @@ void pw_carts_free(struct pw_carts *carts) {
SDL_free(carts);
}
-static bool blit_image(pw_png image, SDL_Texture *texture) {
+static bool blit_image(union pw_png_pixel const *image, SDL_Texture *texture) {
SDL_Surface *surface = NULL;
if (!SDL_LockTextureToSurface(texture, NULL, &surface)) {
return false;
@@ -164,9 +164,7 @@ static bool blit_image(pw_png image, SDL_Texture *texture) {
// steganographic encoding of the cart data.
uint32_t *pixels = surface->pixels;
for (size_t i = 0; i < PW_CART_PNG_WIDTH * PW_CART_PNG_HEIGHT; i++) {
- union pw_png_pixel px;
- pw_png_pixel(image, i, &px);
-
+ union pw_png_pixel px = image[i];
px.raw &= 0xfcfcfcfc;
px.ch.a |= 0x03;
pixels[i] = px.raw;
@@ -192,9 +190,9 @@ struct pw_cart_png *pw_cart_png_init(SDL_Renderer *renderer) {
goto error;
}
- pw_png image = pw_png_load(pw_sysroot_unknown_p8_png.data,
- pw_sysroot_unknown_p8_png.size, PW_CART_PNG_WIDTH,
- PW_CART_PNG_HEIGHT);
+ union pw_png_pixel *image = pw_png_load(
+ pw_sysroot_unknown_p8_png.data, pw_sysroot_unknown_p8_png.size,
+ PW_CART_PNG_WIDTH, PW_CART_PNG_HEIGHT);
if (!image) {
goto error;
}
@@ -235,7 +233,7 @@ static bool load_cart_png(char const *path, SDL_Texture *texture,
bool result = false;
uint8_t *data = NULL;
- pw_png image = NULL;
+ union pw_png_pixel *image = NULL;
int64_t ssize = SDL_GetIOSize(png);
if (ssize < 0) {
@@ -268,9 +266,7 @@ static bool load_cart_png(char const *path, SDL_Texture *texture,
// Read steganographically encoded cart ROM.
for (size_t i = 0; i < PW_CART_ROM_SIZE; i++) {
- union pw_png_pixel px;
- pw_png_pixel(image, i, &px);
-
+ union pw_png_pixel px = image[i];
px.raw &= 0x03030303;
rom[i] = (px.ch.a << 6) | (px.ch.r << 4) | (px.ch.g << 2) | px.ch.b;
}