comparison vdp.c @ 1338:3706b683cd48

Fix sprite rendering for negative line. Fixes remaining visual glitch in the Titancade scene of Overdrive 2
author Michael Pavone <pavone@retrodev.com>
date Mon, 01 May 2017 20:33:59 -0700
parents d092c15246a3
children 35e6a93b4586
comparison
equal deleted inserted replaced
1337:d092c15246a3 1338:3706b683cd48
553 553
554 static void scan_sprite_table(uint32_t line, vdp_context * context) 554 static void scan_sprite_table(uint32_t line, vdp_context * context)
555 { 555 {
556 if (context->sprite_index && ((uint8_t)context->slot_counter) < context->max_sprites_line) { 556 if (context->sprite_index && ((uint8_t)context->slot_counter) < context->max_sprites_line) {
557 line += 1; 557 line += 1;
558 line &= 0xFF;
559 uint16_t ymask, ymin; 558 uint16_t ymask, ymin;
560 uint8_t height_mult; 559 uint8_t height_mult;
561 if (context->double_res) { 560 if (context->double_res) {
562 line *= 2; 561 line *= 2;
563 if (context->flags2 & FLAG2_EVEN_FIELD) { 562 if (context->flags2 & FLAG2_EVEN_FIELD) {
577 context->sprite_index = 0; 576 context->sprite_index = 0;
578 return; 577 return;
579 } 578 }
580 uint16_t address = context->sprite_index * 4; 579 uint16_t address = context->sprite_index * 4;
581 line += ymin; 580 line += ymin;
581 line &= 0x1FF;
582 uint16_t y = ((context->sat_cache[address] & 0x3) << 8 | context->sat_cache[address+1]) & ymask; 582 uint16_t y = ((context->sat_cache[address] & 0x3) << 8 | context->sat_cache[address+1]) & ymask;
583 uint8_t height = ((context->sat_cache[address+2] & 0x3) + 1) * height_mult; 583 uint8_t height = ((context->sat_cache[address+2] & 0x3) + 1) * height_mult;
584 //printf("Sprite %d | y: %d, height: %d\n", context->sprite_index, y, height); 584 //printf("Sprite %d | y: %d, height: %d\n", context->sprite_index, y, height);
585 if (y <= line && line < (y + height)) { 585 if (y <= line && line < (y + height)) {
586 //printf("Sprite %d at y: %d with height %d is on line %d\n", context->sprite_index, y, height, line); 586 //printf("Sprite %d at y: %d with height %d is on line %d\n", context->sprite_index, y, height, line);
666 context->cur_slot = 0; 666 context->cur_slot = 0;
667 } 667 }
668 if (context->cur_slot < context->slot_counter) { 668 if (context->cur_slot < context->slot_counter) {
669 if (context->sprite_draws) { 669 if (context->sprite_draws) {
670 line += 1; 670 line += 1;
671 line &= 0xFF;
672 //in tiles 671 //in tiles
673 uint8_t width = ((context->sprite_info_list[context->cur_slot].size >> 2) & 0x3) + 1; 672 uint8_t width = ((context->sprite_info_list[context->cur_slot].size >> 2) & 0x3) + 1;
674 //in pixels 673 //in pixels
675 uint8_t height = ((context->sprite_info_list[context->cur_slot].size & 0x3) + 1) * 8; 674 uint8_t height = ((context->sprite_info_list[context->cur_slot].size & 0x3) + 1) * 8;
676 if (context->double_res) { 675 if (context->double_res) {
691 uint16_t att_addr = mode5_sat_address(context) + context->sprite_info_list[context->cur_slot].index * 8 + 4; 690 uint16_t att_addr = mode5_sat_address(context) + context->sprite_info_list[context->cur_slot].index * 8 + 4;
692 uint16_t tileinfo = (context->vdpmem[att_addr] << 8) | context->vdpmem[att_addr+1]; 691 uint16_t tileinfo = (context->vdpmem[att_addr] << 8) | context->vdpmem[att_addr+1];
693 uint8_t pal_priority = (tileinfo >> 9) & 0x70; 692 uint8_t pal_priority = (tileinfo >> 9) & 0x70;
694 uint8_t row; 693 uint8_t row;
695 uint16_t cache_addr = context->sprite_info_list[context->cur_slot].index * 4; 694 uint16_t cache_addr = context->sprite_info_list[context->cur_slot].index * 4;
696 int16_t y = ((context->sat_cache[cache_addr] << 8 | context->sat_cache[cache_addr+1]) & ymask) - ymin; 695 line = (line + ymin) & 0x1FF;
696 int16_t y = ((context->sat_cache[cache_addr] << 8 | context->sat_cache[cache_addr+1]) & ymask)/* - ymin*/;
697 if (tileinfo & MAP_BIT_V_FLIP) { 697 if (tileinfo & MAP_BIT_V_FLIP) {
698 row = (y + height - 1) - line; 698 row = (y + height - 1) - line;
699 } else { 699 } else {
700 row = line-y; 700 row = line-y;
701 } 701 }