diff options
author | Mike Pavone <pavone@retrodev.com> | 2012-12-08 11:59:50 -0800 |
---|---|---|
committer | Mike Pavone <pavone@retrodev.com> | 2012-12-08 11:59:50 -0800 |
commit | 17736ec74de418c1910da591e17cc944aa49df19 (patch) | |
tree | 782a246c4829fdbd4759885821d45fd75b781cd1 | |
parent | f7feb99641142f99520f0aec9705a2a3d121d207 (diff) |
Sprites fixed, working on bg planes
-rw-r--r-- | vdp.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -63,7 +63,7 @@ void scan_sprite_table(uint32_t line, vdp_context * context) 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); + //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; @@ -75,7 +75,7 @@ void scan_sprite_table(uint32_t line, vdp_context * context) y = ((context->vdpmem[address] & 0x3) << 8 | context->vdpmem[address+1]) - 128; 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); + //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; @@ -103,13 +103,15 @@ void read_sprite_x(uint32_t line, vdp_context * context) } else { row = line-context->sprite_info_list[context->cur_slot].y; } - uint16_t address = ((tileinfo & 0x7FF) << 5) + (row & 0x7) * 4 + (row & 0x18) * width * 4; + //uint16_t address = ((tileinfo & 0x7FF) << 5) + (row & 0x7) * 4 + (row & 0x18) * width * 4; + uint16_t address = ((tileinfo & 0x7FF) << 5) + row * 4; int16_t x = ((context->vdpmem[att_addr+ 2] & 0x3) << 8) | context->vdpmem[att_addr + 3]; if (x) { x -= 128; - 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, --context->sprite_draws, address += 32, x += 8) { - context->sprite_draw_list[context->sprite_draws].address = address; + int16_t base_x = x; + //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, --context->sprite_draws, x += 8) { + context->sprite_draw_list[context->sprite_draws].address = address + ((x-base_x) / 8) * 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; @@ -172,11 +174,11 @@ void read_map_scroll(uint16_t column, uint32_t line, uint32_t scroll_reg, uint16 v_mul = 256; break; } - uint16_t hscroll = (hscroll_val + (column-1) * 8) & hscroll_mask; + uint16_t hscroll = (hscroll_val + (column-2) * 8) & hscroll_mask; uint16_t offset = address + ((vscroll * v_mul + hscroll/4) & 0x1FFF); //printf("A | line: %d, col: %d, x: %d, hs_mask %X, v_mul: %d, scr reg: %X, tbl addr: %X\n", line, column, hscroll, hscroll_mask, v_mul, context->regs[REG_SCROLL], offset); context->col_1 = (context->vdpmem[offset] << 8) | context->vdpmem[offset+1]; - hscroll = (hscroll_val + column * 8) & hscroll_mask; + hscroll = (hscroll_val + (column-1) * 8) & hscroll_mask; offset = address + ((vscroll * v_mul + hscroll/4) & 0x1FFF); context->col_2 = (context->vdpmem[offset] << 8) | context->vdpmem[offset+1]; } |