diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hle/result.h | 4 | ||||
-rw-r--r-- | src/core/hle/service/am_sys.cpp | 53 | ||||
-rw-r--r-- | src/core/hle/service/fs/fs_user.cpp | 26 | ||||
-rw-r--r-- | src/core/hw/gpu.cpp | 75 |
4 files changed, 97 insertions, 61 deletions
diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 0e391fe2d..3648a168b 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -208,11 +208,11 @@ union ResultCode { } }; -inline bool operator==(const ResultCode a, const ResultCode b) { +inline bool operator==(const ResultCode& a, const ResultCode& b) { return a.raw == b.raw; } -inline bool operator!=(const ResultCode a, const ResultCode b) { +inline bool operator!=(const ResultCode& a, const ResultCode& b) { return a.raw != b.raw; } diff --git a/src/core/hle/service/am_sys.cpp b/src/core/hle/service/am_sys.cpp index 7ab89569f..b244190a2 100644 --- a/src/core/hle/service/am_sys.cpp +++ b/src/core/hle/service/am_sys.cpp @@ -5,19 +5,56 @@ #include "core/hle/hle.h" #include "core/hle/service/am_sys.h" -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Namespace AM_SYS - namespace AM_SYS { -// Empty arrays are illegal -- commented out until an entry is added. -//const Interface::FunctionInfo FunctionTable[] = { }; +/** + * Gets the number of installed titles in the requested media type + * Inputs: + * 0: Command header (0x00010040) + * 1: Media type to load the titles from + * Outputs: + * 1: Result, 0 on success, otherwise error code + * 2: The number of titles in the requested media type + */ +static void TitleIDListGetTotal(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + u32 media_type = cmd_buff[1] & 0xFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[2] = 0; + LOG_WARNING(Service_CFG, "(STUBBED) media_type %u", media_type); +} + +/** + * Loads information about the desired number of titles from the desired media type into an array + * Inputs: + * 0: Command header (0x00020082) + * 1: The maximum number of titles to load + * 2: Media type to load the titles from + * 3: Descriptor of the output buffer pointer + * 4: Address of the output buffer + * Outputs: + * 1: Result, 0 on success, otherwise error code + * 2: The number of titles loaded from the requested media type + */ +static void GetTitleIDList(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + u32 num_titles = cmd_buff[1]; + u32 media_type = cmd_buff[2] & 0xFF; + u32 addr = cmd_buff[4]; + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[2] = 0; + LOG_WARNING(Service_CFG, "(STUBBED) Requested %u titles from media type %u", num_titles, media_type); +} -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Interface class +const Interface::FunctionInfo FunctionTable[] = { + {0x00010040, TitleIDListGetTotal, "TitleIDListGetTotal"}, + {0x00020082, GetTitleIDList, "GetTitleIDList"}, +}; Interface::Interface() { - //Register(FunctionTable); + Register(FunctionTable); } } // namespace diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 71ee4ff55..2c1302208 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -487,6 +487,15 @@ static void FormatThisUserSaveData(Service::Interface* self) { cmd_buff[1] = FormatArchive(ArchiveIdCode::SaveData).raw; } +/** + * FS_User::CreateExtSaveData service function + * Inputs: + * 0: 0x08510242 + * 1: High word of the saveid to create + * 2: Low word of the saveid to create + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ static void CreateExtSaveData(Service::Interface* self) { // TODO(Subv): Figure out the other parameters. u32* cmd_buff = Kernel::GetCommandBuffer(); @@ -496,6 +505,21 @@ static void CreateExtSaveData(Service::Interface* self) { cmd_buff[1] = CreateExtSaveData(save_high, save_low).raw; } +/** + * FS_User::CardSlotIsInserted service function. + * Inputs: + * 0: 0x08210000 + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Whether there is a game card inserted into the slot or not. + */ +static void CardSlotIsInserted(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[2] = 0; + LOG_WARNING(Service_FS, "(STUBBED) called"); +} + const FSUserInterface::FunctionInfo FunctionTable[] = { {0x000100C6, nullptr, "Dummy1"}, {0x040100C4, nullptr, "Control"}, @@ -531,7 +555,7 @@ const FSUserInterface::FunctionInfo FunctionTable[] = { {0x081E0042, nullptr, "GetNandLog"}, {0x081F0000, nullptr, "ClearSdmcLog"}, {0x08200000, nullptr, "ClearNandLog"}, - {0x08210000, nullptr, "CardSlotIsInserted"}, + {0x08210000, CardSlotIsInserted, "CardSlotIsInserted"}, {0x08220000, nullptr, "CardSlotPowerOn"}, {0x08230000, nullptr, "CardSlotPowerOff"}, {0x08240000, nullptr, "CardSlotGetCardIFPowerStatus"}, diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index 2f1a69d90..424ce2ca7 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp @@ -113,8 +113,8 @@ inline void Write(u32 addr, const T data) { { const auto& config = g_regs.display_transfer_config; if (config.trigger & 1) { - u8* source_pointer = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetPhysicalInputAddress())); - u8* dest_pointer = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetPhysicalOutputAddress())); + u8* src_pointer = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetPhysicalInputAddress())); + u8* dst_pointer = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetPhysicalOutputAddress())); unsigned horizontal_scale = (config.scale_horizontally != 0) ? 2 : 1; unsigned vertical_scale = (config.scale_vertically != 0) ? 2 : 1; @@ -125,7 +125,7 @@ inline void Write(u32 addr, const T data) { if (config.raw_copy) { // Raw copies do not perform color conversion nor tiled->linear / linear->tiled conversions // TODO(Subv): Verify if raw copies perform scaling - memcpy(dest_pointer, source_pointer, config.output_width * config.output_height * + memcpy(dst_pointer, src_pointer, config.output_width * config.output_height * GPU::Regs::BytesPerPixel(config.output_format)); LOG_TRACE(HW_GPU, "DisplayTriggerTransfer: 0x%08x bytes from 0x%08x(%ux%u)-> 0x%08x(%ux%u), flags 0x%08X, Raw copy", @@ -142,9 +142,7 @@ inline void Write(u32 addr, const T data) { // right now we're just skipping the extra pixels. for (u32 y = 0; y < output_height; ++y) { for (u32 x = 0; x < output_width; ++x) { - struct { - int r, g, b, a; - } source_color = { 0, 0, 0, 0 }; + Math::Vec4<u8> src_color = { 0, 0, 0, 0 }; u32 scaled_x = x * horizontal_scale; u32 scaled_y = y * vertical_scale; @@ -170,77 +168,54 @@ inline void Write(u32 addr, const T data) { dst_offset = (x + y * output_width) * dst_bytes_per_pixel; } + const u8* src_pixel = src_pointer + src_offset; switch (config.input_format) { case Regs::PixelFormat::RGBA8: - { - u8* srcptr = source_pointer + src_offset; - source_color.r = srcptr[3]; // red - source_color.g = srcptr[2]; // green - source_color.b = srcptr[1]; // blue - source_color.a = srcptr[0]; // alpha + src_color = Color::DecodeRGBA8(src_pixel); + break; + + case Regs::PixelFormat::RGB8: + src_color = Color::DecodeRGB8(src_pixel); + break; + + case Regs::PixelFormat::RGB565: + src_color = Color::DecodeRGB565(src_pixel); break; - } case Regs::PixelFormat::RGB5A1: - { - u16 srcval = *(u16*)(source_pointer + src_offset); - 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 + src_color = Color::DecodeRGB5A1(src_pixel); break; - } case Regs::PixelFormat::RGBA4: - { - u16 srcval = *(u16*)(source_pointer + src_offset); - 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 + src_color = Color::DecodeRGBA4(src_pixel); break; - } default: LOG_ERROR(HW_GPU, "Unknown source framebuffer format %x", config.input_format.Value()); break; } + u8* dst_pixel = dst_pointer + dst_offset; switch (config.output_format) { case Regs::PixelFormat::RGBA8: - { - u8* dstptr = dest_pointer + dst_offset; - dstptr[3] = source_color.r; - dstptr[2] = source_color.g; - dstptr[1] = source_color.b; - dstptr[0] = source_color.a; + Color::EncodeRGBA8(src_color, dst_pixel); break; - } case Regs::PixelFormat::RGB8: - { - u8* dstptr = dest_pointer + dst_offset; - dstptr[2] = source_color.r; // red - dstptr[1] = source_color.g; // green - dstptr[0] = source_color.b; // blue + Color::EncodeRGB8(src_color, dst_pixel); + break; + + case Regs::PixelFormat::RGB565: + Color::EncodeRGB565(src_color, dst_pixel); break; - } case Regs::PixelFormat::RGB5A1: - { - u16* dstptr = (u16*)(dest_pointer + dst_offset); - *dstptr = ((source_color.r >> 3) << 11) | ((source_color.g >> 3) << 6) - | ((source_color.b >> 3) << 1) | ( source_color.a >> 7); + Color::EncodeRGB5A1(src_color, dst_pixel); break; - } case Regs::PixelFormat::RGBA4: - { - u16* dstptr = (u16*)(dest_pointer + dst_offset); - *dstptr = ((source_color.r >> 4) << 12) | ((source_color.g >> 4) << 8) - | ((source_color.b >> 4) << 4) | ( source_color.a >> 4); + Color::EncodeRGBA4(src_color, dst_pixel); break; - } default: LOG_ERROR(HW_GPU, "Unknown destination framebuffer format %x", config.output_format.Value()); |