# HG changeset patch # User Michael Pavone # Date 1662617969 25200 # Node ID 3888c7ed4e36967dda47b1f32de439f0b9e95160 # Parent f699f9d500b48e564f2c2adc5e7b55b0091cddd2 Fix handling of sprite indices >= 64 in H32 mode diff -r f699f9d500b4 -r 3888c7ed4e36 vdp.c --- a/vdp.c Mon Sep 05 23:48:17 2022 -0700 +++ b/vdp.c Wed Sep 07 23:19:29 2022 -0700 @@ -654,7 +654,7 @@ } context->sprite_index &= 0x7F; //TODO: Implement squirelly behavior documented by Kabuto - if (context->sprite_index >= context->max_sprites_frame) { + if (context->sprite_index >= MAX_SPRITES_FRAME) { context->sprite_index = 0; return; } @@ -673,7 +673,7 @@ if (context->sprite_index && ((uint8_t)context->slot_counter) < context->max_sprites_line) { //TODO: Implement squirelly behavior documented by Kabuto - if (context->sprite_index >= context->max_sprites_frame) { + if (context->sprite_index >= MAX_SPRITES_FRAME) { context->sprite_index = 0; return; } @@ -774,7 +774,11 @@ ymask = 0x1FF; ymin = 128; } - uint16_t att_addr = mode5_sat_address(context) + context->sprite_info_list[context->cur_slot].index * 8 + 4; + uint8_t index = context->sprite_info_list[context->cur_slot].index; + if (!(context->regs[REG_MODE_4] & BIT_H40)) { + index &= MAX_SPRITES_FRAME_H32 - 1; + } + uint16_t att_addr = mode5_sat_address(context) + index * 8 + 4; uint16_t tileinfo = (context->vdpmem[att_addr] << 8) | context->vdpmem[att_addr+1]; uint8_t pal_priority = (tileinfo >> 9) & 0x70; uint8_t row;