TODO: RMW opcodes: dec,inc,asl,lsr,rol,ror (abs16 & abs16,x) + 65C02 trb,tsb (abs16)
| 410 | |
| 411 | // TODO: RMW opcodes: dec,inc,asl,lsr,rol,ror (abs16 & abs16,x) + 65C02 trb,tsb (abs16) |
| 412 | UINT SY6522::GetOpcodeCyclesForRead(BYTE reg) |
| 413 | { |
| 414 | UINT zpOpcodeCycles = 0, opcodeCycles = 0; |
| 415 | BYTE zpOpcode = 0, opcode = 0; // these double-up as flags to indicate validity |
| 416 | bool abs16x = false; |
| 417 | bool abs16y = false; |
| 418 | bool indx = false; |
| 419 | bool indy = false; |
| 420 | |
| 421 | const BYTE opcodeMinus3 = ReadByteFromMemory(::regs.pc - 3); |
| 422 | const BYTE opcodeMinus2 = ReadByteFromMemory(::regs.pc - 2); |
| 423 | |
| 424 | // Check 2-byte opcodes |
| 425 | if (((opcodeMinus2 & 0x0f) == 0x01) && ((opcodeMinus2 & 0x10) == 0x00)) // ora (zp,x), and (zp,x), ..., sbc (zp,x) |
| 426 | { |
| 427 | // NB. this is for read, so don't need to exclude 0x81 / sta (zp,x) |
| 428 | zpOpcodeCycles = 6; |
| 429 | zpOpcode = opcodeMinus2; |
| 430 | indx = true; |
| 431 | } |
| 432 | else if (((opcodeMinus2 & 0x0f) == 0x01) && ((opcodeMinus2 & 0x10) == 0x10)) // ora (zp),y, and (zp),y, ..., sbc (zp),y |
| 433 | { |
| 434 | // NB. this is for read, so don't need to exclude 0x91 / sta (zp),y |
| 435 | zpOpcodeCycles = 5; |
| 436 | zpOpcode = opcodeMinus2; |
| 437 | indy = true; |
| 438 | } |
| 439 | else if (((opcodeMinus2 & 0x0f) == 0x02) && ((opcodeMinus2 & 0x10) == 0x10) && GetMainCpu() == CPU_65C02) // ora (zp), and (zp), ..., sbc (zp) : 65C02-only |
| 440 | { |
| 441 | // NB. this is for read, so don't need to exclude 0x92 / sta (zp) |
| 442 | zpOpcodeCycles = 5; |
| 443 | zpOpcode = opcodeMinus2; |
| 444 | } |
| 445 | |
| 446 | // Check 3-byte opcodes |
| 447 | if ((((opcodeMinus3 & 0x0f) == 0x0D) && ((opcodeMinus3 & 0x10) == 0x00)) || // ora abs16, and abs16, ..., sbc abs16 |
| 448 | (opcodeMinus3 == 0x2C) || // bit abs16 |
| 449 | (opcodeMinus3 == 0xAC) || // ldy abs16 |
| 450 | (opcodeMinus3 == 0xAE) || // ldx abs16 |
| 451 | (opcodeMinus3 == 0xCC) || // cpy abs16 |
| 452 | (opcodeMinus3 == 0xEC)) // cpx abs16 |
| 453 | { |
| 454 | opcodeCycles = 4; |
| 455 | opcode = opcodeMinus3; |
| 456 | } |
| 457 | else if ((opcodeMinus3 == 0xBC) || // ldy abs16,x |
| 458 | ((opcodeMinus3 == 0x3C) && GetMainCpu() == CPU_65C02)) // bit abs16,x : 65C02-only |
| 459 | { |
| 460 | opcodeCycles = 4; |
| 461 | opcode = opcodeMinus3; |
| 462 | abs16x = true; |
| 463 | } |
| 464 | else if ((opcodeMinus3 == 0xBE)) // ldx abs16,y |
| 465 | { |
| 466 | opcodeCycles = 4; |
| 467 | opcode = opcodeMinus3; |
| 468 | abs16y = true; |
| 469 | } |
nothing calls this directly
no test coverage detected