summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2012-12-08 21:39:01 -0800
committerMike Pavone <pavone@retrodev.com>2012-12-08 21:39:01 -0800
commit665afdb4db4b7ebbf302d116109af5cd87bc8188 (patch)
tree8e65b73834e67a047fa543d4e97c08e55ef0e221
parent9376413057ac0feede60a215abfde072e07d7570 (diff)
Fix horizontal sprite mirroring
-rw-r--r--vdp.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/vdp.c b/vdp.c
index 5ee2de2..05ff9f8 100644
--- a/vdp.c
+++ b/vdp.c
@@ -112,10 +112,17 @@ void read_sprite_x(uint32_t line, vdp_context * context)
if (x) {
x -= 128;
int16_t base_x = x;
+ int16_t dir;
+ if (tileinfo & MAP_BIT_H_FLIP) {
+ x += (width-1) * 8;
+ dir = -8;
+ } else {
+ dir = 8;
+ }
//printf("Sprite %d | x: %d, y: %d, width: %d, height: %d, pal_priority: %X, row: %d, tile addr: %X\n", context->sprite_info_list[context->cur_slot].index, x, context->sprite_info_list[context->cur_slot].y, width, height, pal_priority, row, address);
- for (;width && context->sprite_draws; --width, x += 8) {
+ for (int16_t i=0; i < width && context->sprite_draws; i++, x += dir) {
--context->sprite_draws;
- context->sprite_draw_list[context->sprite_draws].address = address + ((x-base_x) / 8) * height * 4;
+ context->sprite_draw_list[context->sprite_draws].address = address + i * height * 4;
context->sprite_draw_list[context->sprite_draws].x_pos = x;
context->sprite_draw_list[context->sprite_draws].pal_priority = pal_priority;
context->sprite_draw_list[context->sprite_draws].h_flip = (tileinfo & MAP_BIT_H_FLIP) ? 1 : 0;