all repos — mgba @ a872bd36421a63b70f6d428dc1886b73ceb607ec

mGBA Game Boy Advance Emulator

Remove some ifdefed code by adding a constant for number of bytes per pixel
Jeffrey Pfau jeffrey@endrift.com
Sat, 26 Jul 2014 13:28:44 -0700
commit

a872bd36421a63b70f6d428dc1886b73ceb607ec

parent

15ece309b7b5ddf6e113db82f1a84bcaa6fc85a9

2 files changed, 9 insertions(+), 15 deletions(-)

jump to
M src/gba/gba-video.hsrc/gba/gba-video.h

@@ -5,6 +5,12 @@ #include "common.h"

#include "gba-memory.h" +#ifdef COLOR_16_BIT +#define BYTES_PER_PIXEL 2 +#else +#define BYTES_PER_PIXEL 4 +#endif + enum { VIDEO_CYCLES_PER_PIXEL = 4,
M src/platform/sdl/sw-main.csrc/platform/sdl/sw-main.c

@@ -99,11 +99,7 @@ renderer.tex = SDL_CreateTexture(renderer.sdlRenderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS);

#endif SDL_LockTexture(renderer.tex, 0, &renderer.d.outputBuffer, &renderer.d.outputBufferStride); -#ifdef COLOR_16_BIT - renderer.d.outputBufferStride /= 2; -#else - renderer.d.outputBufferStride /= 4; -#endif + renderer.d.outputBufferStride /= BYTES_PER_PIXEL; #else SDL_Surface* surface = SDL_GetVideoSurface(); SDL_LockSurface(surface);

@@ -117,11 +113,7 @@ #else

renderer.d.outputBufferStride = surface->pitch / 4; #endif } else { -#ifdef COLOR_16_BIT - renderer.d.outputBuffer = malloc(240 * 160 * 2); -#else - renderer.d.outputBuffer = malloc(240 * 160 * 4); -#endif + renderer.d.outputBuffer = malloc(240 * 160 * BYTES_PER_PIXEL); renderer.d.outputBufferStride = 240; } #endif

@@ -173,11 +165,7 @@ SDL_UnlockTexture(renderer->tex);

SDL_RenderCopy(renderer->sdlRenderer, renderer->tex, 0, 0); SDL_RenderPresent(renderer->sdlRenderer); SDL_LockTexture(renderer->tex, 0, &renderer->d.outputBuffer, &renderer->d.outputBufferStride); -#ifdef COLOR_16_BIT - renderer->d.outputBufferStride /= 2; -#else - renderer->d.outputBufferStride /= 4; -#endif + renderer->d.outputBufferStride /= BYTES_PER_PIXEL; #else switch (renderer->ratio) { #if defined(__ARM_NEON) && COLOR_16_BIT