summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorskidau <skidau@gmail.com>2012-03-25 21:35:57 +1100
committerskidau <skidau@gmail.com>2012-03-25 21:35:57 +1100
commitf30aebf8d7bac892d08ef5585c2e858cf6d3f50b (patch)
tree55eebf16082e38532322dc1dc5e7ac46fd66423d /Source/Core/VideoCommon
parentfa2b4cd8fca058a830c24095fe04872257cd4909 (diff)
Added a check for TMEM overflows while preloading textures. Thanks to NeoBrainX for the tip.
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/Src/BPMemory.h2
-rw-r--r--Source/Core/VideoCommon/Src/BPStructs.cpp18
2 files changed, 11 insertions, 9 deletions
diff --git a/Source/Core/VideoCommon/Src/BPMemory.h b/Source/Core/VideoCommon/Src/BPMemory.h
index 0bb2bf9013..de5c616f0f 100644
--- a/Source/Core/VideoCommon/Src/BPMemory.h
+++ b/Source/Core/VideoCommon/Src/BPMemory.h
@@ -62,7 +62,7 @@
#define BPMEM_COPYFILTER1 0x54
#define BPMEM_CLEARBBOX1 0x55
#define BPMEM_CLEARBBOX2 0x56
-#define BPMEM_UNKOWN_57 0x57
+#define BPMEM_UNKNOWN_57 0x57
#define BPMEM_REVBITS 0x58
#define BPMEM_SCISSOROFFSET 0x59
#define BPMEM_PRELOAD_ADDR 0x60
diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp
index 01b09e351b..d59523e117 100644
--- a/Source/Core/VideoCommon/Src/BPStructs.cpp
+++ b/Source/Core/VideoCommon/Src/BPStructs.cpp
@@ -463,8 +463,8 @@ void BPWritten(const BPCmd& bp)
case BPMEM_REVBITS: // Always set to 0x0F when GX_InitRevBits() is called.
break;
- case BPMEM_UNKOWN_57: // Sunshine alternates this register between values 0x000 and 0xAAA
- DEBUG_LOG(VIDEO, "Uknown BP Reg 0x57: %08x", bp.newvalue);
+ case BPMEM_UNKNOWN_57: // Sunshine alternates this register between values 0x000 and 0xAAA
+ DEBUG_LOG(VIDEO, "Unknown BP Reg 0x57: %08x", bp.newvalue);
break;
case BPMEM_PRELOAD_ADDR:
@@ -476,16 +476,18 @@ void BPWritten(const BPCmd& bp)
// if this is different from 0, manual TMEM management is used.
if (bp.newvalue != 0)
{
+ // NOTE(neobrain): Apparently tmemodd doesn't affect hardware behavior at all (libogc uses it just as a buffer and switches its contents with tmemeven whenever this is called)
BPS_TmemConfig& tmem_cfg = bpmem.tmem_config;
u8* ram_ptr = Memory::GetPointer(tmem_cfg.preload_addr << 5);
- u32 tmem_addr = 0;
+ u32 tmem_addr = tmem_cfg.preload_tmem_even * TMEM_LINE_SIZE;
+ u32 size = tmem_cfg.preload_tile_info.count * 32;
- if (bp.newvalue >> 16)
- tmem_addr = tmem_cfg.preload_tmem_odd * TMEM_LINE_SIZE;
- else
- tmem_addr = tmem_cfg.preload_tmem_even * TMEM_LINE_SIZE;
+ // Check if the game has overflowed TMEM, and copy up to the limit.
+ // Paper Mario does this when entering the Great Boogly Tree (Chap 2)
+ // TODO: Does this wrap?
+ if ((tmem_addr + size) > TMEM_SIZE)
+ size = TMEM_SIZE - tmem_addr;
- u32 size = tmem_cfg.preload_tile_info.count * 32;
memcpy(texMem + tmem_addr, ram_ptr, size);
}
break;