| 570 | } |
| 571 | |
| 572 | UINT SY6522::GetOpcodeCycles(BYTE reg, UINT zpOpcodeCycles, UINT opcodeCycles, |
| 573 | BYTE zpOpcode, BYTE opcode, |
| 574 | bool abs16x, bool abs16y, bool indx, bool indy) |
| 575 | { |
| 576 | WORD zpAddr16 = 0, addr16 = 0; |
| 577 | |
| 578 | if (zpOpcode) |
| 579 | { |
| 580 | if (IsZeroPageFloatingBus()) |
| 581 | return 0; |
| 582 | |
| 583 | BYTE zp = ReadByteFromMemory(::regs.pc - 1); |
| 584 | if (indx) zp += ::regs.x; |
| 585 | zpAddr16 = (ReadByteFromMemory(zp) | (ReadByteFromMemory((zp + 1) & 0xff) << 8)); |
| 586 | if (indy) zpAddr16 += ::regs.y; |
| 587 | } |
| 588 | |
| 589 | if (opcode) |
| 590 | { |
| 591 | addr16 = ReadByteFromMemory(::regs.pc - 2) | (ReadByteFromMemory(::regs.pc - 1) << 8); |
| 592 | if (abs16y) addr16 += ::regs.y; |
| 593 | if (abs16x) addr16 += ::regs.x; |
| 594 | } |
| 595 | |
| 596 | // Check we've reverse looked-up the 6502 opcode correctly |
| 597 | const bool isZpAddrValid = (zpAddr16 & 0xF80F) == (0xC000 + reg); |
| 598 | const bool isAbs16AddrValid = (addr16 & 0xF80F) == (0xC000 + reg); |
| 599 | |
| 600 | if ( (isZpAddrValid && isAbs16AddrValid) |
| 601 | || (!isZpAddrValid && !isAbs16AddrValid) ) |
| 602 | { |
| 603 | _ASSERT(0); |
| 604 | return 0; |
| 605 | } |
| 606 | |
| 607 | return isZpAddrValid ? zpOpcodeCycles : opcodeCycles; |
| 608 | } |
| 609 | |
| 610 | //============================================================================= |
| 611 |
nothing calls this directly
no test coverage detected