Mercurial > repos > blastem
comparison vdp.c @ 180:8b846bcff6a2
Fix rendering of sprites at the top edge of screen
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 08 Jan 2013 09:34:46 -0800 |
parents | 6b593ea0ed90 |
children | 806c3b7a6f2a |
comparison
equal
deleted
inserted
replaced
179:68af8a56ab7a | 180:8b846bcff6a2 |
---|---|
80 return; | 80 return; |
81 } | 81 } |
82 //TODO: Read from SAT cache rather than from VRAM | 82 //TODO: Read from SAT cache rather than from VRAM |
83 uint16_t sat_address = (context->regs[REG_SAT] & 0x7F) << 9; | 83 uint16_t sat_address = (context->regs[REG_SAT] & 0x7F) << 9; |
84 uint16_t address = context->sprite_index * 8 + sat_address; | 84 uint16_t address = context->sprite_index * 8 + sat_address; |
85 int16_t y = ((context->vdpmem[address] & 0x3) << 8 | context->vdpmem[address+1]) - 128; | 85 line += 128; |
86 uint16_t y = ((context->vdpmem[address] & 0x3) << 8 | context->vdpmem[address+1]); | |
86 uint8_t height = ((context->vdpmem[address+2] & 0x3) + 1) * 8; | 87 uint8_t height = ((context->vdpmem[address+2] & 0x3) + 1) * 8; |
87 //printf("Sprite %d | y: %d, height: %d\n", context->sprite_index, y, height); | 88 //printf("Sprite %d | y: %d, height: %d\n", context->sprite_index, y, height); |
88 if (y <= line && line < (y + height)) { | 89 if (y <= line && line < (y + height)) { |
89 //printf("Sprite %d at y: %d with height %d is on line %d\n", context->sprite_index, y, height, line); | 90 //printf("Sprite %d at y: %d with height %d is on line %d\n", context->sprite_index, y, height, line); |
90 context->sprite_info_list[--(context->slot_counter)].size = context->vdpmem[address+2]; | 91 context->sprite_info_list[--(context->slot_counter)].size = context->vdpmem[address+2]; |
91 context->sprite_info_list[context->slot_counter].index = context->sprite_index; | 92 context->sprite_info_list[context->slot_counter].index = context->sprite_index; |
92 context->sprite_info_list[context->slot_counter].y = y; | 93 context->sprite_info_list[context->slot_counter].y = y-128; |
93 } | 94 } |
94 context->sprite_index = context->vdpmem[address+3] & 0x7F; | 95 context->sprite_index = context->vdpmem[address+3] & 0x7F; |
95 if (context->sprite_index && context->slot_counter) | 96 if (context->sprite_index && context->slot_counter) |
96 { | 97 { |
97 address = context->sprite_index * 8 + sat_address; | 98 address = context->sprite_index * 8 + sat_address; |
98 y = ((context->vdpmem[address] & 0x3) << 8 | context->vdpmem[address+1]) - 128; | 99 y = ((context->vdpmem[address] & 0x3) << 8 | context->vdpmem[address+1]); |
99 height = ((context->vdpmem[address+2] & 0x3) + 1) * 8; | 100 height = ((context->vdpmem[address+2] & 0x3) + 1) * 8; |
100 if (y <= line && line < (y + height)) { | 101 if (y <= line && line < (y + height)) { |
101 //printf("Sprite %d at y: %d with height %d is on line %d\n", context->sprite_index, y, height, line); | 102 //printf("Sprite %d at y: %d with height %d is on line %d\n", context->sprite_index, y, height, line); |
102 context->sprite_info_list[--(context->slot_counter)].size = context->vdpmem[address+2]; | 103 context->sprite_info_list[--(context->slot_counter)].size = context->vdpmem[address+2]; |
103 context->sprite_info_list[context->slot_counter].index = context->sprite_index; | 104 context->sprite_info_list[context->slot_counter].index = context->sprite_index; |
104 context->sprite_info_list[context->slot_counter].y = y; | 105 context->sprite_info_list[context->slot_counter].y = y-128; |
105 } | 106 } |
106 context->sprite_index = context->vdpmem[address+3] & 0x7F; | 107 context->sprite_index = context->vdpmem[address+3] & 0x7F; |
107 } | 108 } |
108 } | 109 } |
109 } | 110 } |