| 130 | } |
| 131 | |
| 132 | Render3DError Render3D::ClearFramebuffer(const GFX3D_State *renderState) |
| 133 | { |
| 134 | Render3DError error = RENDER3DERROR_NOERR; |
| 135 | |
| 136 | struct GFX3D_ClearColor |
| 137 | { |
| 138 | u8 r; |
| 139 | u8 g; |
| 140 | u8 b; |
| 141 | u8 a; |
| 142 | } clearColor; |
| 143 | |
| 144 | clearColor.r = renderState->clearColor & 0x1F; |
| 145 | clearColor.g = (renderState->clearColor >> 5) & 0x1F; |
| 146 | clearColor.b = (renderState->clearColor >> 10) & 0x1F; |
| 147 | clearColor.a = (renderState->clearColor >> 16) & 0x1F; |
| 148 | |
| 149 | const u8 clearStencil = (renderState->clearColor >> 24) & 0x3F; |
| 150 | |
| 151 | if (renderState->enableClearImage) |
| 152 | { |
| 153 | const u16 *__restrict clearColorBuffer = (u16 *__restrict)MMU.texInfo.textureSlotAddr[2]; |
| 154 | const u16 *__restrict clearDepthBuffer = (u16 *__restrict)MMU.texInfo.textureSlotAddr[3]; |
| 155 | const u16 scrollBits = T1ReadWord(MMU.ARM9_REG, 0x356); //CLRIMAGE_OFFSET |
| 156 | const u8 xScroll = scrollBits & 0xFF; |
| 157 | const u8 yScroll = (scrollBits >> 8) & 0xFF; |
| 158 | |
| 159 | error = this->UpdateClearImage(clearColorBuffer, clearDepthBuffer, clearStencil, xScroll, yScroll); |
| 160 | if (error == RENDER3DERROR_NOERR) |
| 161 | { |
| 162 | error = this->ClearUsingImage(); |
| 163 | } |
| 164 | else |
| 165 | { |
| 166 | error = this->ClearUsingValues(clearColor.r, clearColor.g, clearColor.b, clearColor.a, renderState->clearDepth, clearStencil); |
| 167 | } |
| 168 | } |
| 169 | else |
| 170 | { |
| 171 | error = this->ClearUsingValues(clearColor.r, clearColor.g, clearColor.b, clearColor.a, renderState->clearDepth, clearStencil); |
| 172 | } |
| 173 | |
| 174 | return error; |
| 175 | } |
| 176 | |
| 177 | Render3DError Render3D::ClearUsingImage() const |
| 178 | { |
no test coverage detected