diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/arm/dyncom/arm_dyncom_interpreter.cpp | 19 | ||||
-rw-r--r-- | src/core/core_timing.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/kernel/thread.cpp | 5 | ||||
-rw-r--r-- | src/core/hle/result.h | 10 | ||||
-rw-r--r-- | src/core/hw/gpu.cpp | 66 | ||||
-rw-r--r-- | src/core/hw/gpu.h | 11 | ||||
-rw-r--r-- | src/core/mem_map_funcs.cpp | 18 |
7 files changed, 61 insertions, 72 deletions
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp index b691ffbc3..3b508f617 100644 --- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp +++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp @@ -4422,12 +4422,7 @@ unsigned InterpreterMainLoop(ARMul_State* state) { inst_cream->get_addr(cpu, inst_cream->inst, addr, 1); unsigned int value = Memory::Read32(addr); - if (BIT(CP15_REG(CP15_CONTROL), 22) == 1) - cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; - else { - value = ROTATE_RIGHT_32(value,(8*(addr&0x3))); - cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; - } + cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; if (BITS(inst_cream->inst, 12, 15) == 15) { // For armv5t, should enter thumb when bits[0] is non-zero. @@ -4450,12 +4445,7 @@ unsigned InterpreterMainLoop(ARMul_State* state) { inst_cream->get_addr(cpu, inst_cream->inst, addr, 1); unsigned int value = Memory::Read32(addr); - if (BIT(CP15_REG(CP15_CONTROL), 22) == 1) - cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; - else { - value = ROTATE_RIGHT_32(value,(8*(addr&0x3))); - cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; - } + cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; if (BITS(inst_cream->inst, 12, 15) == 15) { // For armv5t, should enter thumb when bits[0] is non-zero. @@ -4699,11 +4689,6 @@ unsigned InterpreterMainLoop(ARMul_State* state) { unsigned int value = Memory::Read32(addr); cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; - if (BIT(CP15_REG(CP15_CONTROL), 22) == 1) - cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; - else - cpu->Reg[BITS(inst_cream->inst, 12, 15)] = ROTATE_RIGHT_32(value,(8*(addr&0x3))) ; - if (BITS(inst_cream->inst, 12, 15) == 15) { INC_PC(sizeof(ldst_inst)); goto DISPATCH; diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index cabe2a074..6f716b1ca 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -147,7 +147,7 @@ void RestoreRegisterEvent(int event_type, const char* name, TimedCallback callba void UnregisterAllEvents() { if (first) - PanicAlert("Cannot unregister events with events pending"); + LOG_ERROR(Core_Timing, "Cannot unregister events with events pending"); event_types.clear(); } @@ -535,7 +535,7 @@ std::string GetScheduledEventsSummary() { while (event) { unsigned int t = event->type; if (t >= event_types.size()) - PanicAlert("Invalid event type"); // %i", t); + LOG_ERROR(Core_Timing, "Invalid event type"); // %i", t); const char* name = event_types[event->type].name; if (!name) name = "[unknown]"; diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index f8c834a8d..be1aed615 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -7,6 +7,7 @@ #include <vector> #include "common/common.h" +#include "common/math_util.h" #include "common/thread_queue_list.h" #include "core/arm/arm_interface.h" @@ -339,7 +340,7 @@ static void DebugThreadQueue() { ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, s32 priority, u32 arg, s32 processor_id, VAddr stack_top) { if (priority < THREADPRIO_HIGHEST || priority > THREADPRIO_LOWEST) { - s32 new_priority = CLAMP(priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST); + s32 new_priority = MathUtil::Clamp<s32>(priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST); LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d", name.c_str(), priority, new_priority); // TODO(bunnei): Clamping to a valid priority is not necessarily correct behavior... Confirm @@ -387,7 +388,7 @@ static void ClampPriority(const Thread* thread, s32* priority) { if (*priority < THREADPRIO_HIGHEST || *priority > THREADPRIO_LOWEST) { DEBUG_ASSERT_MSG(false, "Application passed an out of range priority. An error should be returned."); - s32 new_priority = CLAMP(*priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST); + s32 new_priority = MathUtil::Clamp<s32>(*priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST); LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d", thread->name.c_str(), *priority, new_priority); // TODO(bunnei): Clamping to a valid priority is not necessarily correct behavior... Confirm diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 9dbd5a914..0e391fe2d 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -4,7 +4,6 @@ #pragma once -#include <cassert> #include <cstddef> #include <type_traits> #include <utility> @@ -267,7 +266,7 @@ public: ResultVal(ResultCode error_code = ResultCode(-1)) : result_code(error_code) { - assert(error_code.IsError()); + ASSERT(error_code.IsError()); UpdateDebugPtr(); } @@ -330,7 +329,7 @@ public: */ template <typename... Args> void emplace(ResultCode success_code, Args&&... args) { - assert(success_code.IsSuccess()); + ASSERT(success_code.IsSuccess()); if (!empty()) { GetPointer()->~T(); } @@ -362,7 +361,6 @@ public: /// Asserts that the result succeeded and returns a reference to it. T& Unwrap() { - // TODO(yuriks): Should be a release assert ASSERT_MSG(Succeeded(), "Tried to Unwrap empty ResultVal"); return **this; } @@ -389,12 +387,12 @@ private: } const T* GetPointer() const { - assert(!empty()); + ASSERT(!empty()); return static_cast<const T*>(static_cast<const void*>(&storage)); } T* GetPointer() { - assert(!empty()); + ASSERT(!empty()); return static_cast<T*>(static_cast<void*>(&storage)); } }; diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index bd7d92cd1..e6022d69f 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp @@ -19,6 +19,7 @@ #include "video_core/command_processor.h" #include "video_core/video_core.h" +#include <video_core/color.h> namespace GPU { @@ -132,12 +133,31 @@ inline void Write(u32 addr, const T data) { switch (config.input_format) { case Regs::PixelFormat::RGBA8: { - // TODO: Most likely got the component order messed up. u8* srcptr = source_pointer + (x * pixel_skip + y * config.input_width) * 4; - source_color.r = srcptr[0]; // blue - source_color.g = srcptr[1]; // green - source_color.b = srcptr[2]; // red - source_color.a = srcptr[3]; // alpha + source_color.r = srcptr[3]; // red + source_color.g = srcptr[2]; // green + source_color.b = srcptr[1]; // blue + source_color.a = srcptr[0]; // alpha + break; + } + + case Regs::PixelFormat::RGB5A1: + { + u16 srcval = *(u16*)(source_pointer + x * 4 * pixel_skip + y * config.input_width * 4 * pixel_skip); + source_color.r = Color::Convert5To8((srcval >> 11) & 0x1F); // red + source_color.g = Color::Convert5To8((srcval >> 6) & 0x1F); // green + source_color.b = Color::Convert5To8((srcval >> 1) & 0x1F); // blue + source_color.a = Color::Convert1To8(srcval & 0x1); // alpha + break; + } + + case Regs::PixelFormat::RGBA4: + { + u16 srcval = *(u16*)(source_pointer + x * 4 * pixel_skip + y * config.input_width * 4 * pixel_skip); + source_color.r = Color::Convert4To8((srcval >> 12) & 0xF); // red + source_color.g = Color::Convert4To8((srcval >> 8) & 0xF); // green + source_color.b = Color::Convert4To8((srcval >> 4) & 0xF); // blue + source_color.a = Color::Convert4To8( srcval & 0xF); // alpha break; } @@ -147,24 +167,38 @@ inline void Write(u32 addr, const T data) { } switch (config.output_format) { - /*case Regs::PixelFormat::RGBA8: + case Regs::PixelFormat::RGBA8: { - // TODO: Untested - u8* dstptr = (u32*)(dest_pointer + x * 4 + y * config.output_width * 4); - dstptr[0] = source_color.r; - dstptr[1] = source_color.g; - dstptr[2] = source_color.b; - dstptr[3] = source_color.a; + u8* dstptr = dest_pointer + (x * pixel_skip + y * config.output_width) * 4; + dstptr[3] = source_color.r; + dstptr[2] = source_color.g; + dstptr[1] = source_color.b; + dstptr[0] = source_color.a; break; - }*/ + } case Regs::PixelFormat::RGB8: { - // TODO: Most likely got the component order messed up. u8* dstptr = dest_pointer + (x + y * output_width) * 3; - dstptr[0] = source_color.r; // blue + dstptr[2] = source_color.r; // red dstptr[1] = source_color.g; // green - dstptr[2] = source_color.b; // red + dstptr[0] = source_color.b; // blue + break; + } + + case Regs::PixelFormat::RGB5A1: + { + u16* dstptr = (u16*)(dest_pointer + x * 2 + y * config.output_width * 2); + *dstptr = ((source_color.r >> 3) << 11) | ((source_color.g >> 3) << 6) + | ((source_color.b >> 3) << 1) | ( source_color.a >> 7); + break; + } + + case Regs::PixelFormat::RGBA4: + { + u16* dstptr = (u16*)(dest_pointer + x * 2 + y * config.output_width * 2); + *dstptr = ((source_color.r >> 4) << 12) | ((source_color.g >> 4) << 8) + | ((source_color.b >> 4) << 4) | ( source_color.a >> 4); break; } diff --git a/src/core/hw/gpu.h b/src/core/hw/gpu.h index df9aa0d71..75f524465 100644 --- a/src/core/hw/gpu.h +++ b/src/core/hw/gpu.h @@ -34,13 +34,6 @@ namespace GPU { // MMIO region 0x1EFxxxxx struct Regs { -// helper macro to properly align structure members. -// Calling INSERT_PADDING_WORDS will add a new member variable with a name like "pad121", -// depending on the current source line to make sure variable names are unique. -#define INSERT_PADDING_WORDS_HELPER1(x, y) x ## y -#define INSERT_PADDING_WORDS_HELPER2(x, y) INSERT_PADDING_WORDS_HELPER1(x, y) -#define INSERT_PADDING_WORDS(num_words) u32 INSERT_PADDING_WORDS_HELPER2(pad, __LINE__)[(num_words)] - // helper macro to make sure the defined structures are of the expected size. #if defined(_MSC_VER) // TODO: MSVC does not support using sizeof() on non-static data members even though this @@ -238,10 +231,6 @@ struct Regs { INSERT_PADDING_WORDS(0x9c3); -#undef INSERT_PADDING_WORDS_HELPER1 -#undef INSERT_PADDING_WORDS_HELPER2 -#undef INSERT_PADDING_WORDS - static inline size_t NumIds() { return sizeof(Regs) / sizeof(u32); } diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp index 4f93c0e64..48f61db4e 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/mem_map_funcs.cpp @@ -236,30 +236,12 @@ u8 Read8(const VAddr addr) { u16 Read16(const VAddr addr) { u16_le data = 0; Read<u16_le>(data, addr); - - // Check for 16-bit unaligned memory reads... - if (addr & 1) { - // TODO(bunnei): Implement 16-bit unaligned memory reads - LOG_ERROR(HW_Memory, "16-bit unaligned memory reads are not implemented!"); - } - return (u16)data; } u32 Read32(const VAddr addr) { u32_le data = 0; Read<u32_le>(data, addr); - - // Check for 32-bit unaligned memory reads... - if (addr & 3) { - // ARM allows for unaligned memory reads, however older ARM architectures read out memory - // from unaligned addresses in a shifted way. Our ARM CPU core (SkyEye) corrects for this, - // so therefore expects the memory to be read out in this manner. - // TODO(bunnei): Determine if this is necessary - perhaps it is OK to remove this from both - // SkyEye and here? - int shift = (addr & 3) * 8; - data = (data << shift) | (data >> (32 - shift)); - } return (u32)data; } |