MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / ApplyPatch

Method ApplyPatch

pcsx2/Patch.cpp:1710–1810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1708 requires std::is_base_of_v<MemoryInterface, EEMemory> &&
1709 std::is_base_of_v<MemoryInterface, IOPMemory>
1710void Patch::ApplyPatch(const PatchCommand* p, EEMemory& ee, IOPMemory& iop, ExtendedState& state)
1711{
1712 switch (p->cpu)
1713 {
1714 case CPU_EE:
1715 {
1716 switch (p->type)
1717 {
1718 case BYTE_T:
1719 {
1720 ee.IdempotentWrite8(p->addr, static_cast<u8>(p->data));
1721 break;
1722 }
1723 case SHORT_T:
1724 {
1725 ee.IdempotentWrite16(p->addr, static_cast<u16>(p->data));
1726 break;
1727 }
1728 case WORD_T:
1729 {
1730 ee.IdempotentWrite32(p->addr, static_cast<u32>(p->data));
1731 break;
1732 }
1733 case DOUBLE_T:
1734 {
1735 ee.IdempotentWrite64(p->addr, p->data);
1736 break;
1737 }
1738 case EXTENDED_T:
1739 {
1740 handle_extended_t(p, ee, state);
1741 break;
1742 }
1743 case SHORT_BE_T:
1744 {
1745 u16 value = ByteSwap(static_cast<u16>(p->data));
1746 ee.IdempotentWrite16(p->addr, value);
1747 break;
1748 }
1749 case WORD_BE_T:
1750 {
1751 u32 value = ByteSwap(static_cast<u32>(p->data));
1752 ee.IdempotentWrite32(p->addr, value);
1753 break;
1754 }
1755 case DOUBLE_BE_T:
1756 {
1757 u64 value = ByteSwap(p->data);
1758 ee.IdempotentWrite64(p->addr, value);
1759 break;
1760 }
1761 case BYTES_T:
1762 {
1763 // We compare before writing so the rec doesn't get upset and invalidate when there's no change.
1764 ee.IdempotentWriteBytes(p->addr, p->data_ptr, static_cast<u32>(p->data));
1765 break;
1766 }
1767 default:

Callers

nothing calls this directly

Calls 7

ByteSwapFunction · 0.85
IdempotentWrite8Method · 0.80
IdempotentWrite16Method · 0.80
IdempotentWrite32Method · 0.80
IdempotentWrite64Method · 0.80
IdempotentWriteBytesMethod · 0.80
IdempotentWriteMethod · 0.80

Tested by

no test coverage detected