comparison vdp.c @ 1156:b519965f6394

Clear sprite overflow flag when control port read. Fix vcounter progression in Mode 4
author Michael Pavone <pavone@retrodev.com>
date Thu, 05 Jan 2017 19:15:53 -0800
parents da6a1f156f24
children d5dda22ae6b4
comparison
equal deleted inserted replaced
1155:da6a1f156f24 1156:b519965f6394
1371 1371
1372 static void vdp_advance_line(vdp_context *context) 1372 static void vdp_advance_line(vdp_context *context)
1373 { 1373 {
1374 context->vcounter++; 1374 context->vcounter++;
1375 context->vcounter &= 0x1FF; 1375 context->vcounter &= 0x1FF;
1376 if (context->flags2 & FLAG2_REGION_PAL) { 1376 uint8_t is_mode_5 = context->regs[REG_MODE_2] & BIT_MODE_5;
1377 if (context->latched_mode & BIT_PAL) { 1377 if (is_mode_5) {
1378 if (context->vcounter == 0x10B) { 1378 if (context->flags2 & FLAG2_REGION_PAL) {
1379 context->vcounter = 0x1D2; 1379 if (context->latched_mode & BIT_PAL) {
1380 } 1380 if (context->vcounter == 0x10B) {
1381 } else if (context->vcounter == 0x103){ 1381 context->vcounter = 0x1D2;
1382 context->vcounter = 0x1CA; 1382 }
1383 } 1383 } else if (context->vcounter == 0x103){
1384 } else if (!(context->latched_mode & BIT_PAL) && context->vcounter == 0xEB) { 1384 context->vcounter = 0x1CA;
1385 context->vcounter = 0x1E5; 1385 }
1386 } else if (!(context->latched_mode & BIT_PAL) && context->vcounter == 0xEB) {
1387 context->vcounter = 0x1E5;
1388 }
1389 } else if (context->vcounter == 0xDB) {
1390 context->vcounter = 0x1D5;
1386 } 1391 }
1387 uint32_t inactive_start = (context->latched_mode & BIT_PAL ? PAL_INACTIVE_START : NTSC_INACTIVE_START); 1392 uint32_t inactive_start = (context->latched_mode & BIT_PAL ? PAL_INACTIVE_START : NTSC_INACTIVE_START);
1388 if (!(context->regs[REG_MODE_2] & BIT_MODE_5)) { 1393 if (!is_mode_5) {
1389 inactive_start = MODE4_INACTIVE_START; 1394 inactive_start = MODE4_INACTIVE_START;
1390 } 1395 }
1391 if (!headless) { 1396 if (!headless) {
1392 if (!context->vcounter && !context->output) { 1397 if (!context->vcounter && !context->output) {
1393 context->output = render_get_framebuffer(context->flags2 & FLAG2_EVEN_FIELD ? FRAMEBUFFER_EVEN : FRAMEBUFFER_ODD, &context->output_pitch); 1398 context->output = render_get_framebuffer(context->flags2 & FLAG2_EVEN_FIELD ? FRAMEBUFFER_EVEN : FRAMEBUFFER_ODD, &context->output_pitch);
2361 if (context->flags2 & FLAG2_VINT_PENDING) { 2366 if (context->flags2 & FLAG2_VINT_PENDING) {
2362 value |= 0x80; 2367 value |= 0x80;
2363 } 2368 }
2364 if (context->flags & FLAG_DOT_OFLOW) { 2369 if (context->flags & FLAG_DOT_OFLOW) {
2365 value |= 0x40; 2370 value |= 0x40;
2371 context->flags &= ~FLAG_DOT_OFLOW;
2366 } 2372 }
2367 if (context->flags2 & FLAG2_SPRITE_COLLIDE) { 2373 if (context->flags2 & FLAG2_SPRITE_COLLIDE) {
2368 value |= 0x20; 2374 value |= 0x20;
2369 context->flags2 &= ~FLAG2_SPRITE_COLLIDE; 2375 context->flags2 &= ~FLAG2_SPRITE_COLLIDE;
2370 } 2376 }