TODO: RMW opcodes: dec,inc,asl,lsr,rol,ror (abs16 & abs16,x) + 65C02 trb,tsb (abs16)
| 496 | |
| 497 | // TODO: RMW opcodes: dec,inc,asl,lsr,rol,ror (abs16 & abs16,x) + 65C02 trb,tsb (abs16) |
| 498 | UINT SY6522::GetOpcodeCyclesForWrite(BYTE reg) |
| 499 | { |
| 500 | UINT zpOpcodeCycles = 0, opcodeCycles = 0; |
| 501 | BYTE zpOpcode = 0, opcode = 0; // these double-up as flags to indicate validity |
| 502 | bool abs16x = false; |
| 503 | bool abs16y = false; |
| 504 | bool indx = false; |
| 505 | bool indy = false; |
| 506 | |
| 507 | const BYTE opcodeMinus3 = ReadByteFromMemory(::regs.pc - 3); |
| 508 | const BYTE opcodeMinus2 = ReadByteFromMemory(::regs.pc - 2); |
| 509 | |
| 510 | // Check 2-byte opcodes |
| 511 | if (opcodeMinus2 == 0x81) // sta (zp,x) |
| 512 | { |
| 513 | zpOpcodeCycles = 6; |
| 514 | zpOpcode = opcodeMinus2; |
| 515 | indx = true; |
| 516 | } |
| 517 | else if (opcodeMinus2 == 0x91) // sta (zp),y |
| 518 | { // Eg. FT demos: OMT, PLS |
| 519 | zpOpcodeCycles = 6; |
| 520 | zpOpcode = opcodeMinus2; |
| 521 | indy = true; |
| 522 | } |
| 523 | else if (opcodeMinus2 == 0x92 && GetMainCpu() == CPU_65C02) // sta (zp) : 65C02-only |
| 524 | { |
| 525 | zpOpcodeCycles = 5; |
| 526 | zpOpcode = opcodeMinus2; |
| 527 | } |
| 528 | |
| 529 | // Check 3-byte opcodes |
| 530 | if ((opcodeMinus3 == 0x8C) || // sty abs16 |
| 531 | (opcodeMinus3 == 0x8D) || // sta abs16 |
| 532 | (opcodeMinus3 == 0x8E)) // stx abs16 |
| 533 | { // Eg. FT demos: CHIP, MADEF, MAD2 |
| 534 | opcodeCycles = 4; |
| 535 | opcode = opcodeMinus3; |
| 536 | } |
| 537 | else if (opcodeMinus3 == 0x99) // sta abs16,y |
| 538 | { |
| 539 | opcodeCycles = 5; |
| 540 | opcode = opcodeMinus3; |
| 541 | abs16y = true; |
| 542 | } |
| 543 | else if (opcodeMinus3 == 0x9D) // sta abs16,x |
| 544 | { // Eg. Paleotronic microTracker demo |
| 545 | opcodeCycles = 5; |
| 546 | opcode = opcodeMinus3; |
| 547 | abs16x = true; |
| 548 | } |
| 549 | else if (opcodeMinus3 == 0x9C && GetMainCpu() == CPU_65C02) // stz abs16 : 65C02-only |
| 550 | { |
| 551 | opcodeCycles = 4; |
| 552 | opcode = opcodeMinus3; |
| 553 | } |
| 554 | else if (opcodeMinus3 == 0x9E && GetMainCpu() == CPU_65C02) // stz abs16,x : 65C02-only |
| 555 | { |
nothing calls this directly
no test coverage detected