summaryrefslogtreecommitdiff
path: root/src/video_core/debug_utils
diff options
context:
space:
mode:
authorGravatar bunnei2015-01-01 20:54:45 -0500
committerGravatar bunnei2015-01-01 20:54:45 -0500
commit7c8f6ca0511b35c8a56dce466df01f6364728581 (patch)
treebd1fa3b50c090786dd0f91669702ebf010d2a900 /src/video_core/debug_utils
parentMerge pull request #379 from lioncash/sh (diff)
parentPica/Rasterizer: Remove some redundant casts. (diff)
downloadyuzu-7c8f6ca0511b35c8a56dce466df01f6364728581.tar.gz
yuzu-7c8f6ca0511b35c8a56dce466df01f6364728581.tar.xz
yuzu-7c8f6ca0511b35c8a56dce466df01f6364728581.zip
Merge pull request #358 from neobrain/pica_progress2
pica_progress followups
Diffstat (limited to 'src/video_core/debug_utils')
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp48
1 files changed, 19 insertions, 29 deletions
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp
index 5921185a6..a494465b9 100644
--- a/src/video_core/debug_utils/debug_utils.cpp
+++ b/src/video_core/debug_utils/debug_utils.cpp
@@ -19,6 +19,7 @@
19#include "common/log.h" 19#include "common/log.h"
20#include "common/file_util.h" 20#include "common/file_util.h"
21 21
22#include "video_core/color.h"
22#include "video_core/math.h" 23#include "video_core/math.h"
23#include "video_core/pica.h" 24#include "video_core/pica.h"
24 25
@@ -359,29 +360,26 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture
359 u8 g = ((source_ptr) >> 6) & 0x1F; 360 u8 g = ((source_ptr) >> 6) & 0x1F;
360 u8 b = (source_ptr >> 1) & 0x1F; 361 u8 b = (source_ptr >> 1) & 0x1F;
361 u8 a = source_ptr & 1; 362 u8 a = source_ptr & 1;
362 return Math::MakeVec<u8>((r << 3) | (r >> 2), (g << 3) | (g >> 2), (b << 3) | (b >> 2), disable_alpha ? 255 : (a * 255)); 363 return Math::MakeVec<u8>(Color::Convert5To8(r), Color::Convert5To8(g),
364 Color::Convert5To8(b), disable_alpha ? 255 : Color::Convert1To8(a));
363 } 365 }
364 366
365 case Regs::TextureFormat::RGB565: 367 case Regs::TextureFormat::RGB565:
366 { 368 {
367 const u16 source_ptr = *(const u16*)(source + offset * 2); 369 const u16 source_ptr = *(const u16*)(source + offset * 2);
368 u8 r = (source_ptr >> 11) & 0x1F; 370 u8 r = Color::Convert5To8((source_ptr >> 11) & 0x1F);
369 u8 g = ((source_ptr) >> 5) & 0x3F; 371 u8 g = Color::Convert6To8(((source_ptr) >> 5) & 0x3F);
370 u8 b = (source_ptr) & 0x1F; 372 u8 b = Color::Convert5To8((source_ptr) & 0x1F);
371 return Math::MakeVec<u8>((r << 3) | (r >> 2), (g << 2) | (g >> 4), (b << 3) | (b >> 2), 255); 373 return Math::MakeVec<u8>(r, g, b, 255);
372 } 374 }
373 375
374 case Regs::TextureFormat::RGBA4: 376 case Regs::TextureFormat::RGBA4:
375 { 377 {
376 const u8* source_ptr = source + offset * 2; 378 const u8* source_ptr = source + offset * 2;
377 u8 r = source_ptr[1] >> 4; 379 u8 r = Color::Convert4To8(source_ptr[1] >> 4);
378 u8 g = source_ptr[1] & 0xFF; 380 u8 g = Color::Convert4To8(source_ptr[1] & 0xF);
379 u8 b = source_ptr[0] >> 4; 381 u8 b = Color::Convert4To8(source_ptr[0] >> 4);
380 u8 a = source_ptr[0] & 0xFF; 382 u8 a = Color::Convert4To8(source_ptr[0] & 0xF);
381 r = (r << 4) | r;
382 g = (g << 4) | g;
383 b = (b << 4) | b;
384 a = (a << 4) | a;
385 return { r, g, b, disable_alpha ? (u8)255 : a }; 383 return { r, g, b, disable_alpha ? (u8)255 : a };
386 } 384 }
387 385
@@ -389,13 +387,11 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture
389 { 387 {
390 const u8* source_ptr = source + offset * 2; 388 const u8* source_ptr = source + offset * 2;
391 389
392 // TODO: component order not verified
393
394 if (disable_alpha) { 390 if (disable_alpha) {
395 // Show intensity as red, alpha as green 391 // Show intensity as red, alpha as green
396 return { source_ptr[0], source_ptr[1], 0, 255 }; 392 return { source_ptr[1], source_ptr[0], 0, 255 };
397 } else { 393 } else {
398 return { source_ptr[0], source_ptr[0], source_ptr[0], source_ptr[1]}; 394 return { source_ptr[1], source_ptr[1], source_ptr[1], source_ptr[0]};
399 } 395 }
400 } 396 }
401 397
@@ -418,14 +414,10 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture
418 414
419 case Regs::TextureFormat::IA4: 415 case Regs::TextureFormat::IA4:
420 { 416 {
421 const u8* source_ptr = source + offset / 2; 417 const u8* source_ptr = source + offset;
422
423 // TODO: component order not verified
424 418
425 u8 i = (*source_ptr) & 0xF; 419 u8 i = Color::Convert4To8(((*source_ptr) & 0xF0) >> 4);
426 u8 a = ((*source_ptr) & 0xF0) >> 4; 420 u8 a = Color::Convert4To8((*source_ptr) & 0xF);
427 a |= a << 4;
428 i |= i << 4;
429 421
430 if (disable_alpha) { 422 if (disable_alpha) {
431 // Show intensity as red, alpha as green 423 // Show intensity as red, alpha as green
@@ -439,15 +431,13 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture
439 { 431 {
440 const u8* source_ptr = source + offset / 2; 432 const u8* source_ptr = source + offset / 2;
441 433
442 // TODO: component order not verified
443
444 u8 a = (coarse_x % 2) ? ((*source_ptr)&0xF) : (((*source_ptr) & 0xF0) >> 4); 434 u8 a = (coarse_x % 2) ? ((*source_ptr)&0xF) : (((*source_ptr) & 0xF0) >> 4);
445 a |= a << 4; 435 a = Color::Convert4To8(a);
446 436
447 if (disable_alpha) { 437 if (disable_alpha) {
448 return { *source_ptr, *source_ptr, *source_ptr, 255 }; 438 return { a, a, a, 255 };
449 } else { 439 } else {
450 return { 0, 0, 0, *source_ptr }; 440 return { 0, 0, 0, a };
451 } 441 }
452 } 442 }
453 443