Implement HFlip for 256 color partial tiles (fixes #39)

This commit is contained in:
Jeffrey Pfau 2014-08-31 04:19:13 -07:00
parent 610982fdcf
commit 8a6254cc73
1 changed files with 65 additions and 25 deletions

View File

@ -976,16 +976,16 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
} }
#define DRAW_BACKGROUND_MODE_0_TILE_SUFFIX_256(BLEND, OBJWIN) \ #define DRAW_BACKGROUND_MODE_0_TILE_SUFFIX_256(BLEND, OBJWIN) \
/* TODO: hflip */ \
charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) >> 2) + (localY << 1); \ charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) >> 2) + (localY << 1); \
int end2 = end - 4; \ int end2 = end - 4; \
if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
int shift = inX & 0x3; \ int shift = inX & 0x3; \
if (end2 > 0) { \ if (end2 > outX) { \
tileData = ((uint32_t*) vram)[charBase]; \ tileData = ((uint32_t*) vram)[charBase]; \
tileData >>= 8 * shift; \ tileData >>= 8 * shift; \
shift = 0; \ shift = 0; \
for (; outX < end2; ++outX) { \ for (; outX < end2; ++outX) { \
uint32_t* pixel = &renderer->row[outX]; \ pixel = &renderer->row[outX]; \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
} \ } \
} \ } \
@ -993,19 +993,38 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
tileData = ((uint32_t*) vram)[charBase + 1]; \ tileData = ((uint32_t*) vram)[charBase + 1]; \
tileData >>= 8 * shift; \ tileData >>= 8 * shift; \
for (; outX < end; ++outX) { \ for (; outX < end; ++outX) { \
uint32_t* pixel = &renderer->row[outX]; \ pixel = &renderer->row[outX]; \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
} \
} else { \
int start = outX; \
outX = end - 1; \
if (end2 > start) { \
tileData = ((uint32_t*) vram)[charBase]; \
for (; outX >= end2; --outX) { \
pixel = &renderer->row[outX]; \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
} \
++charBase; \
} \
\
tileData = ((uint32_t*) vram)[charBase]; \
for (; outX >= renderer->start; --outX) { \
pixel = &renderer->row[outX]; \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
} \
outX = end; \
} }
#define DRAW_BACKGROUND_MODE_0_TILE_PREFIX_256(BLEND, OBJWIN) \ #define DRAW_BACKGROUND_MODE_0_TILE_PREFIX_256(BLEND, OBJWIN) \
/* TODO: hflip */ \
charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) >> 2) + (localY << 1); \ charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) >> 2) + (localY << 1); \
outX = renderer->end - 8 + end; \ outX = renderer->end - 8 + end; \
int end2 = 4 - end; \ int end2 = 4 - end; \
if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
if (end2 > 0) { \ if (end2 > 0) { \
tileData = ((uint32_t*) vram)[charBase]; \ tileData = ((uint32_t*) vram)[charBase]; \
for (; outX < renderer->end - end2; ++outX) { \ for (; outX < renderer->end - end2; ++outX) { \
uint32_t* pixel = &renderer->row[outX]; \ pixel = &renderer->row[outX]; \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
} \ } \
++charBase; \ ++charBase; \
@ -1013,8 +1032,29 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
\ \
tileData = ((uint32_t*) vram)[charBase]; \ tileData = ((uint32_t*) vram)[charBase]; \
for (; outX < renderer->end; ++outX) { \ for (; outX < renderer->end; ++outX) { \
uint32_t* pixel = &renderer->row[outX]; \ pixel = &renderer->row[outX]; \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
} \
} else { \
int shift = end & 0x3; \
int start = outX; \
outX = renderer->end - 1; \
if (end2 > 0) { \
tileData = ((uint32_t*) vram)[charBase]; \
tileData >>= 8 * shift; \
for (; outX >= start + 4; --outX) { \
pixel = &renderer->row[outX]; \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
} \
shift = 0; \
} \
\
tileData = ((uint32_t*) vram)[charBase + 1]; \
tileData >>= 8 * shift; \
for (; outX >= start; --outX) { \
pixel = &renderer->row[outX]; \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
} \
} }
#define DRAW_BACKGROUND_MODE_0_TILES_256(BLEND, OBJWIN) \ #define DRAW_BACKGROUND_MODE_0_TILES_256(BLEND, OBJWIN) \