# HG changeset patch # User Mike Pavone # Date 1357666486 28800 # Node ID 8b846bcff6a24958921d8c311d808f3b5c427de2 # Parent 68af8a56ab7a995ea24b14dad0a15c92c2bf0af9 Fix rendering of sprites at the top edge of screen diff -r 68af8a56ab7a -r 8b846bcff6a2 vdp.c --- a/vdp.c Tue Jan 08 09:34:24 2013 -0800 +++ b/vdp.c Tue Jan 08 09:34:46 2013 -0800 @@ -82,26 +82,27 @@ //TODO: Read from SAT cache rather than from VRAM uint16_t sat_address = (context->regs[REG_SAT] & 0x7F) << 9; uint16_t address = context->sprite_index * 8 + sat_address; - int16_t y = ((context->vdpmem[address] & 0x3) << 8 | context->vdpmem[address+1]) - 128; + line += 128; + uint16_t y = ((context->vdpmem[address] & 0x3) << 8 | context->vdpmem[address+1]); uint8_t height = ((context->vdpmem[address+2] & 0x3) + 1) * 8; //printf("Sprite %d | y: %d, height: %d\n", context->sprite_index, y, height); if (y <= line && line < (y + height)) { //printf("Sprite %d at y: %d with height %d is on line %d\n", context->sprite_index, y, height, line); context->sprite_info_list[--(context->slot_counter)].size = context->vdpmem[address+2]; context->sprite_info_list[context->slot_counter].index = context->sprite_index; - context->sprite_info_list[context->slot_counter].y = y; + context->sprite_info_list[context->slot_counter].y = y-128; } context->sprite_index = context->vdpmem[address+3] & 0x7F; if (context->sprite_index && context->slot_counter) { address = context->sprite_index * 8 + sat_address; - y = ((context->vdpmem[address] & 0x3) << 8 | context->vdpmem[address+1]) - 128; + y = ((context->vdpmem[address] & 0x3) << 8 | context->vdpmem[address+1]); height = ((context->vdpmem[address+2] & 0x3) + 1) * 8; if (y <= line && line < (y + height)) { //printf("Sprite %d at y: %d with height %d is on line %d\n", context->sprite_index, y, height, line); context->sprite_info_list[--(context->slot_counter)].size = context->vdpmem[address+2]; context->sprite_info_list[context->slot_counter].index = context->sprite_index; - context->sprite_info_list[context->slot_counter].y = y; + context->sprite_info_list[context->slot_counter].y = y-128; } context->sprite_index = context->vdpmem[address+3] & 0x7F; }