summaryrefslogtreecommitdiff
path: root/src/core/hw
diff options
context:
space:
mode:
authorGravatar bunnei2015-02-18 17:19:38 -0500
committerGravatar bunnei2015-02-18 17:19:38 -0500
commit4a48b017ca7fe8fe68dfc84d70864ef6aea6a266 (patch)
treedcd7914a3a2147790d384ce0992f70d40bce8704 /src/core/hw
parentMerge pull request #570 from purpasmart96/config_mem (diff)
parentPica/Rasterizer: Replace exit() calls with UNIMPLEMENTED(). (diff)
downloadyuzu-4a48b017ca7fe8fe68dfc84d70864ef6aea6a266.tar.gz
yuzu-4a48b017ca7fe8fe68dfc84d70864ef6aea6a266.tar.xz
yuzu-4a48b017ca7fe8fe68dfc84d70864ef6aea6a266.zip
Merge pull request #562 from neobrain/pica_progress3
More PICA200 Emulation Fixes
Diffstat (limited to 'src/core/hw')
-rw-r--r--src/core/hw/gpu.cpp41
-rw-r--r--src/core/hw/gpu.h32
2 files changed, 57 insertions, 16 deletions
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp
index aad0e5d0d..bd7d92cd1 100644
--- a/src/core/hw/gpu.cpp
+++ b/src/core/hw/gpu.cpp
@@ -67,23 +67,38 @@ inline void Write(u32 addr, const T data) {
67 switch (index) { 67 switch (index) {
68 68
69 // Memory fills are triggered once the fill value is written. 69 // Memory fills are triggered once the fill value is written.
70 // NOTE: This is not verified. 70 case GPU_REG_INDEX_WORKAROUND(memory_fill_config[0].trigger, 0x00004 + 0x3):
71 case GPU_REG_INDEX_WORKAROUND(memory_fill_config[0].value, 0x00004 + 0x3): 71 case GPU_REG_INDEX_WORKAROUND(memory_fill_config[1].trigger, 0x00008 + 0x3):
72 case GPU_REG_INDEX_WORKAROUND(memory_fill_config[1].value, 0x00008 + 0x3):
73 { 72 {
74 const bool is_second_filler = (index != GPU_REG_INDEX(memory_fill_config[0].value)); 73 const bool is_second_filler = (index != GPU_REG_INDEX(memory_fill_config[0].trigger));
75 const auto& config = g_regs.memory_fill_config[is_second_filler]; 74 auto& config = g_regs.memory_fill_config[is_second_filler];
76 75
77 // TODO: Not sure if this check should be done at GSP level instead 76 if (config.address_start && config.trigger) {
78 if (config.address_start) { 77 u8* start = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetStartAddress()));
79 // TODO: Not sure if this algorithm is correct, particularly because it doesn't use the size member at all 78 u8* end = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetEndAddress()));
80 u32* start = (u32*)Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetStartAddress())); 79
81 u32* end = (u32*)Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetEndAddress())); 80 if (config.fill_24bit) {
82 for (u32* ptr = start; ptr < end; ++ptr) 81 // fill with 24-bit values
83 *ptr = bswap32(config.value); // TODO: This is just a workaround to missing framebuffer format emulation 82 for (u8* ptr = start; ptr < end; ptr += 3) {
83 ptr[0] = config.value_24bit_b;
84 ptr[1] = config.value_24bit_g;
85 ptr[2] = config.value_24bit_r;
86 }
87 } else if (config.fill_32bit) {
88 // fill with 32-bit values
89 for (u32* ptr = (u32*)start; ptr < (u32*)end; ++ptr)
90 *ptr = config.value_32bit;
91 } else {
92 // fill with 16-bit values
93 for (u16* ptr = (u16*)start; ptr < (u16*)end; ++ptr)
94 *ptr = config.value_16bit;
95 }
84 96
85 LOG_TRACE(HW_GPU, "MemoryFill from 0x%08x to 0x%08x", config.GetStartAddress(), config.GetEndAddress()); 97 LOG_TRACE(HW_GPU, "MemoryFill from 0x%08x to 0x%08x", config.GetStartAddress(), config.GetEndAddress());
86 98
99 config.trigger = 0;
100 config.finished = 1;
101
87 if (!is_second_filler) { 102 if (!is_second_filler) {
88 GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PSC0); 103 GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PSC0);
89 } else { 104 } else {
diff --git a/src/core/hw/gpu.h b/src/core/hw/gpu.h
index 9fd694f65..df9aa0d71 100644
--- a/src/core/hw/gpu.h
+++ b/src/core/hw/gpu.h
@@ -84,9 +84,35 @@ struct Regs {
84 84
85 struct { 85 struct {
86 u32 address_start; 86 u32 address_start;
87 u32 address_end; // ? 87 u32 address_end;
88 u32 size; 88
89 u32 value; // ? 89 union {
90 u32 value_32bit;
91
92 BitField<0, 16, u32> value_16bit;
93
94 // TODO: Verify component order
95 BitField< 0, 8, u32> value_24bit_r;
96 BitField< 8, 8, u32> value_24bit_g;
97 BitField<16, 8, u32> value_24bit_b;
98 };
99
100 union {
101 u32 control;
102
103 // Setting this field to 1 triggers the memory fill.
104 // This field also acts as a status flag, and gets reset to 0 upon completion.
105 BitField<0, 1, u32> trigger;
106
107 // Set to 1 upon completion.
108 BitField<0, 1, u32> finished;
109
110 // 0: fill with 16- or 32-bit wide values; 1: fill with 24-bit wide values
111 BitField<8, 1, u32> fill_24bit;
112
113 // 0: fill with 16-bit wide values; 1: fill with 32-bit wide values
114 BitField<9, 1, u32> fill_32bit;
115 };
90 116
91 inline u32 GetStartAddress() const { 117 inline u32 GetStartAddress() const {
92 return DecodeAddressRegister(address_start); 118 return DecodeAddressRegister(address_start);