comparison vdp.c @ 699:d8a1fdec68fc

Fix frame counter increment and VINT cycle time calculation
author Michael Pavone <pavone@retrodev.com>
date Mon, 11 May 2015 20:30:35 -0700
parents 7f96bd1cb1be
children ce4046476abc
comparison
equal deleted inserted replaced
698:0a86e81fa87d 699:d8a1fdec68fc
1454 context->slot_counter = MAX_SPRITES_LINE_H32; 1454 context->slot_counter = MAX_SPRITES_LINE_H32;
1455 } 1455 }
1456 } 1456 }
1457 if (is_h40 && slot == LINE_CHANGE_H40 || !is_h40 && slot == LINE_CHANGE_H32) { 1457 if (is_h40 && slot == LINE_CHANGE_H40 || !is_h40 && slot == LINE_CHANGE_H32) {
1458 if (line >= inactive_start) { 1458 if (line >= inactive_start) {
1459 if (line == (inactive_start + 8)) {
1460 context->frame++;
1461 }
1462 context->hint_counter = context->regs[REG_HINT]; 1459 context->hint_counter = context->regs[REG_HINT];
1463 } else if (context->hint_counter) { 1460 } else if (context->hint_counter) {
1464 context->hint_counter--; 1461 context->hint_counter--;
1465 } else { 1462 } else {
1466 context->flags2 |= FLAG2_HINT_PENDING; 1463 context->flags2 |= FLAG2_HINT_PENDING;
1522 context->hslot++; 1519 context->hslot++;
1523 context->hslot &= 0xFF; 1520 context->hslot &= 0xFF;
1524 if (is_h40) { 1521 if (is_h40) {
1525 if (context->hslot == LINE_CHANGE_H40) { 1522 if (context->hslot == LINE_CHANGE_H40) {
1526 context->vcounter++; 1523 context->vcounter++;
1524 if (context->vcounter == (inactive_start + 8)) {
1525 context->frame++;
1526 }
1527 } else if (context->hslot == 183) { 1527 } else if (context->hslot == 183) {
1528 context->hslot = 229; 1528 context->hslot = 229;
1529 } 1529 }
1530 } else { 1530 } else {
1531 if (context->hslot == LINE_CHANGE_H32) { 1531 if (context->hslot == LINE_CHANGE_H32) {
1532 context->vcounter++; 1532 context->vcounter++;
1533 if (context->vcounter == (inactive_start + 8)) {
1534 context->frame++;
1535 }
1533 } else if (context->hslot == 148) { 1536 } else if (context->hslot == 148) {
1534 context->hslot = 233; 1537 context->hslot = 233;
1535 } 1538 }
1536 } 1539 }
1537 1540
1955 uint32_t vdp_next_vint_z80(vdp_context * context) 1958 uint32_t vdp_next_vint_z80(vdp_context * context)
1956 { 1959 {
1957 uint32_t inactive_start = context->latched_mode & BIT_PAL ? PAL_INACTIVE_START : NTSC_INACTIVE_START; 1960 uint32_t inactive_start = context->latched_mode & BIT_PAL ? PAL_INACTIVE_START : NTSC_INACTIVE_START;
1958 if (context->vcounter == inactive_start) { 1961 if (context->vcounter == inactive_start) {
1959 if (context->regs[REG_MODE_4] & BIT_H40) { 1962 if (context->regs[REG_MODE_4] & BIT_H40) {
1960 if (context->hslot >= HBLANK_START_H40) { 1963 if (context->hslot >= LINE_CHANGE_H40) {
1961 if (context->hslot < 183) { 1964 if (context->hslot < 183) {
1962 return context->cycles + (VINT_SLOT_H40 + 183 - context->hslot + 256 - 229) * MCLKS_SLOT_H40; 1965 return context->cycles + (VINT_SLOT_H40 + 183 - context->hslot + 256 - 229) * MCLKS_SLOT_H40;
1963 } else { 1966 } else {
1964 return context->cycles + (VINT_SLOT_H40 + 256 - context->hslot) * MCLKS_SLOT_H40; 1967 return context->cycles + (VINT_SLOT_H40 + 256 - context->hslot) * MCLKS_SLOT_H40;
1965 } 1968 }
1966 } else if (context->hslot < VINT_SLOT_H40) { 1969 } else if (context->hslot < VINT_SLOT_H40) {
1967 return context->cycles + (VINT_SLOT_H40 - context->hslot) * MCLKS_SLOT_H40; 1970 return context->cycles + (VINT_SLOT_H40 - context->hslot) * MCLKS_SLOT_H40;
1968 } 1971 }
1969 } else { 1972 } else {
1970 if (context->hslot >= HBLANK_START_H32) { 1973 if (context->hslot >= LINE_CHANGE_H32) {
1971 if (context->hslot < 148) { 1974 if (context->hslot < 148) {
1972 return context->cycles + (VINT_SLOT_H32 + 148 - context->hslot + 256 - 233) * MCLKS_SLOT_H32; 1975 return context->cycles + (VINT_SLOT_H32 + 148 - context->hslot + 256 - 233) * MCLKS_SLOT_H32;
1973 } else { 1976 } else {
1974 return context->cycles + (VINT_SLOT_H32 + 256 - context->hslot) * MCLKS_SLOT_H32; 1977 return context->cycles + (VINT_SLOT_H32 + 256 - context->hslot) * MCLKS_SLOT_H32;
1975 } 1978 }
1978 } 1981 }
1979 } 1982 }
1980 } 1983 }
1981 int32_t cycles_to_vint = vdp_cycles_to_line(context, inactive_start); 1984 int32_t cycles_to_vint = vdp_cycles_to_line(context, inactive_start);
1982 if (context->regs[REG_MODE_4] & BIT_H40) { 1985 if (context->regs[REG_MODE_4] & BIT_H40) {
1983 cycles_to_vint += (VINT_SLOT_H40 + 183 - HBLANK_START_H40 + 256 - 229) * MCLKS_SLOT_H40; 1986 cycles_to_vint += (VINT_SLOT_H40 + 183 - LINE_CHANGE_H40 + 256 - 229) * MCLKS_SLOT_H40;
1984 } else { 1987 } else {
1985 cycles_to_vint += (VINT_SLOT_H32 + 148 - HBLANK_START_H32 + 256 - 233) * MCLKS_SLOT_H32; 1988 cycles_to_vint += (VINT_SLOT_H32 + 148 - LINE_CHANGE_H32 + 256 - 233) * MCLKS_SLOT_H32;
1986 } 1989 }
1987 return context->cycles + cycles_to_vint; 1990 return context->cycles + cycles_to_vint;
1988 } 1991 }
1989 1992
1990 void vdp_int_ack(vdp_context * context, uint16_t int_num) 1993 void vdp_int_ack(vdp_context * context, uint16_t int_num)