mirror of https://github.com/mgba-emu/mgba.git
Remove some ifdefed code by adding a constant for number of bytes per pixel
This commit is contained in:
parent
15ece309b7
commit
a872bd3642
|
@ -5,6 +5,12 @@
|
|||
|
||||
#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,
|
||||
|
||||
|
|
|
@ -99,11 +99,7 @@ int main(int argc, char** argv) {
|
|||
#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 @@ int main(int argc, char** argv) {
|
|||
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 @@ static void _GBASDLRunloop(struct GBAThread* context, struct SoftwareRenderer* r
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue