diff options
author | Tony Wasserka <NeoBrainX@gmail.com> | 2014-07-11 19:29:12 +0200 |
---|---|---|
committer | Tony Wasserka <NeoBrainX@gmail.com> | 2014-07-23 00:33:08 +0200 |
commit | 9d618d0b705e3b8de5594512a555f469631e274b (patch) | |
tree | d70ba534e0221bf2445c89dec9a8464060ce5766 /src | |
parent | GPU: Initialize GPU registers to some sensible default state. (diff) | |
download | yuzu-9d618d0b705e3b8de5594512a555f469631e274b.tar yuzu-9d618d0b705e3b8de5594512a555f469631e274b.tar.gz yuzu-9d618d0b705e3b8de5594512a555f469631e274b.tar.bz2 yuzu-9d618d0b705e3b8de5594512a555f469631e274b.tar.lz yuzu-9d618d0b705e3b8de5594512a555f469631e274b.tar.xz yuzu-9d618d0b705e3b8de5594512a555f469631e274b.tar.zst yuzu-9d618d0b705e3b8de5594512a555f469631e274b.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hw/gpu.cpp | 29 | ||||
-rw-r--r-- | src/core/hw/gpu.h | 4 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index 0ee6b7c3b..49fc574bc 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp @@ -53,10 +53,10 @@ void SetFramebufferLocation(const FramebufferLocation mode) { * Gets the location of the framebuffers * @return Location of framebuffers as FramebufferLocation enum */ -const FramebufferLocation GetFramebufferLocation() { - if ((g_regs.framebuffer_top_right_1 & ~Memory::VRAM_MASK) == Memory::VRAM_PADDR) { +FramebufferLocation GetFramebufferLocation(u32 address) { + if ((address & ~Memory::VRAM_MASK) == Memory::VRAM_PADDR) { return FRAMEBUFFER_LOCATION_VRAM; - } else if ((g_regs.framebuffer_top_right_1 & ~Memory::FCRAM_MASK) == Memory::FCRAM_PADDR) { + } else if ((address & ~Memory::FCRAM_MASK) == Memory::FCRAM_PADDR) { return FRAMEBUFFER_LOCATION_FCRAM; } else { ERROR_LOG(GPU, "unknown framebuffer location!"); @@ -64,21 +64,26 @@ const FramebufferLocation GetFramebufferLocation() { return FRAMEBUFFER_LOCATION_UNKNOWN; } +u32 GetFramebufferAddr(const u32 address) { + switch (GetFramebufferLocation(address)) { + case FRAMEBUFFER_LOCATION_FCRAM: + return Memory::VirtualAddressFromPhysical_FCRAM(address); + case FRAMEBUFFER_LOCATION_VRAM: + return Memory::VirtualAddressFromPhysical_VRAM(address); + default: + ERROR_LOG(GPU, "unknown framebuffer location"); + } + return 0; +} + /** * Gets a read-only pointer to a framebuffer in memory * @param address Physical address of framebuffer * @return Returns const pointer to raw framebuffer */ const u8* GetFramebufferPointer(const u32 address) { - switch (GetFramebufferLocation()) { - case FRAMEBUFFER_LOCATION_FCRAM: - return (const u8*)Memory::GetPointer(Memory::VirtualAddressFromPhysical_FCRAM(address)); - case FRAMEBUFFER_LOCATION_VRAM: - return (const u8*)Memory::GetPointer(Memory::VirtualAddressFromPhysical_VRAM(address)); - default: - ERROR_LOG(GPU, "unknown framebuffer location"); - } - return NULL; + u32 addr = GetFramebufferAddr(address); + return (addr != 0) ? Memory::GetPointer(addr) : nullptr; } template <typename T> diff --git a/src/core/hw/gpu.h b/src/core/hw/gpu.h index 47d7fcb26..b66cf4a37 100644 --- a/src/core/hw/gpu.h +++ b/src/core/hw/gpu.h @@ -219,10 +219,12 @@ void SetFramebufferLocation(const FramebufferLocation mode); */ const u8* GetFramebufferPointer(const u32 address); +u32 GetFramebufferAddr(const u32 address); + /** * Gets the location of the framebuffers */ -const FramebufferLocation GetFramebufferLocation(); +FramebufferLocation GetFramebufferLocation(u32 address); template <typename T> inline void Read(T &var, const u32 addr); |