Skip to content

Instantly share code, notes, and snippets.

@Subv
Created February 25, 2015 00:07
Show Gist options
  • Save Subv/335b9d69f554a9110e8e to your computer and use it in GitHub Desktop.
Save Subv/335b9d69f554a9110e8e to your computer and use it in GitHub Desktop.
diff --git a/externals/boost b/externals/boost
--- a/externals/boost
+++ b/externals/boost
@@ -1 +1 @@
-Subproject commit 728a4d7d1c8b28355544ae829df9c4b5f28373c5
+Subproject commit 728a4d7d1c8b28355544ae829df9c4b5f28373c5-dirty
diff --git a/externals/nihstro b/externals/nihstro
--- a/externals/nihstro
+++ b/externals/nihstro
@@ -1 +1 @@
-Subproject commit 0a8b4d221425f13e24a3cef9b02edc3221bab211
+Subproject commit 0a8b4d221425f13e24a3cef9b02edc3221bab211-dirty
diff --git a/src/core/hle/service/am_sys.cpp b/src/core/hle/service/am_sys.cpp
index 7ab8956..d07288f 100644
--- a/src/core/hle/service/am_sys.cpp
+++ b/src/core/hle/service/am_sys.cpp
@@ -10,14 +10,36 @@
namespace AM_SYS {
-// Empty arrays are illegal -- commented out until an entry is added.
-//const Interface::FunctionInfo FunctionTable[] = { };
+static void TitleIDListGetTotal(Service::Interface* self) {
+ u32* cmd_buff = Kernel::GetCommandBuffer();
+ u32 media_type = cmd_buff[1];
+
+ cmd_buff[1] = RESULT_SUCCESS.raw;
+ cmd_buff[2] = 0;
+ LOG_WARNING(Service_CFG, "Loading title list for media type %u", 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];
+ u32 addr = cmd_buff[4];
+
+ cmd_buff[1] = RESULT_SUCCESS.raw;
+ cmd_buff[2] = 0;
+ LOG_WARNING(Service_CFG, "Loading %u titles into array for media type %u", num_titles, media_type);
+}
+
+const Interface::FunctionInfo FunctionTable[] = {
+ {0x00010040, TitleIDListGetTotal, "TitleIDListGetTotal"},
+ {0x00020082, GetTitleIDList, "GetTitleIDList"},
+};
////////////////////////////////////////////////////////////////////////////////////////////////////
// Interface class
Interface::Interface() {
- //Register(FunctionTable);
+ Register(FunctionTable);
}
} // namespace
diff --git a/src/core/hle/service/apt_s.cpp b/src/core/hle/service/apt_s.cpp
index 6863354..dbb7f8c 100644
--- a/src/core/hle/service/apt_s.cpp
+++ b/src/core/hle/service/apt_s.cpp
@@ -26,6 +26,7 @@ namespace APT_U {
extern void AppletUtility(Service::Interface* self);
extern void GlanceParameter(Service::Interface* self);
extern void ReceiveParameter(Service::Interface* self);
+ extern void IsRegistered(Service::Interface* self);
}
namespace APT_S {
@@ -39,7 +40,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x00060040, nullptr, "GetAppletInfo"},
{0x00070000, nullptr, "GetLastSignaledAppletId"},
{0x00080000, nullptr, "CountRegisteredApplet"},
- {0x00090040, nullptr, "IsRegistered"},
+ {0x00090040, APT_U::IsRegistered, "IsRegistered"},
{0x000A0040, nullptr, "GetAttribute"},
{0x000B0040, APT_U::InquireNotification, "InquireNotification"},
{0x000C0104, nullptr, "SendParameter"},
diff --git a/src/core/hle/service/apt_u.cpp b/src/core/hle/service/apt_u.cpp
index 2d605a7..d6b72a2 100644
--- a/src/core/hle/service/apt_u.cpp
+++ b/src/core/hle/service/apt_u.cpp
@@ -160,11 +160,13 @@ void GetAppletManInfo(Service::Interface* self) {
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Output, 0 = not registered, 1 = registered.
*/
-static void IsRegistered(Service::Interface* self) {
+void IsRegistered(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 app_id = cmd_buff[1];
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- cmd_buff[2] = 1; // Set to registered
+ static int res = 1;
+ cmd_buff[2] = res; // Set to registered
+ res = 0;
LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id);
}
diff --git a/src/core/hle/service/cfg/cfg_s.cpp b/src/core/hle/service/cfg/cfg_s.cpp
index d80aeae..1e7a4ad 100644
--- a/src/core/hle/service/cfg/cfg_s.cpp
+++ b/src/core/hle/service/cfg/cfg_s.cpp
@@ -9,6 +9,12 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace CFG_S
+namespace CFG_U {
+ void SecureInfoGetRegion(Service::Interface*);
+ void GetSystemModel(Service::Interface*);
+ void GenHashConsoleUnique(Service::Interface*);
+}
+
namespace CFG_S {
/**
@@ -75,13 +81,15 @@ static void UpdateConfigNANDSavegame(Service::Interface* self) {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
- {0x00020000, nullptr, "SecureInfoGetRegion"},
+ {0x00020000, CFG_U::SecureInfoGetRegion, "SecureInfoGetRegion"},
+ {0x00030040, CFG_U::GenHashConsoleUnique, "GenHashConsoleUnique"},
{0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
{0x04020082, nullptr, "SetConfigInfoBlk4"},
{0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
{0x04040042, nullptr, "GetLocalFriendCodeSeedData"},
{0x04050000, nullptr, "GetLocalFriendCodeSeed"},
- {0x04060000, nullptr, "SecureInfoGetRegion"},
+ {0x04060000, CFG_U::SecureInfoGetRegion, "SecureInfoGetRegion"},
+ {0x00050000, CFG_U::GetSystemModel, "GetSystemModel"},
{0x04070000, nullptr, "SecureInfoGetByte101"},
{0x04080042, nullptr, "SecureInfoGetSerialNo"},
{0x04090000, nullptr, "UpdateConfigBlk00040003"},
diff --git a/src/core/hle/service/cfg/cfg_u.cpp b/src/core/hle/service/cfg/cfg_u.cpp
index a65da90..1856e32 100644
--- a/src/core/hle/service/cfg/cfg_u.cpp
+++ b/src/core/hle/service/cfg/cfg_u.cpp
@@ -137,7 +137,7 @@ static void GetConfigInfoBlk2(Service::Interface* self) {
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Region value loaded from SecureInfo offset 0x100
*/
-static void SecureInfoGetRegion(Service::Interface* self) {
+void SecureInfoGetRegion(Service::Interface* self) {
u32* cmd_buffer = Kernel::GetCommandBuffer();
cmd_buffer[1] = RESULT_SUCCESS.raw; // No Error
@@ -154,7 +154,7 @@ static void SecureInfoGetRegion(Service::Interface* self) {
* 2 : Hash/"ID" lower word
* 3 : Hash/"ID" upper word
*/
-static void GenHashConsoleUnique(Service::Interface* self) {
+void GenHashConsoleUnique(Service::Interface* self) {
u32* cmd_buffer = Kernel::GetCommandBuffer();
u32 app_id_salt = cmd_buffer[1];
@@ -195,7 +195,7 @@ static void GetRegionCanadaUSA(Service::Interface* self) {
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Model of the console
*/
-static void GetSystemModel(Service::Interface* self) {
+void GetSystemModel(Service::Interface* self) {
u32* cmd_buffer = Kernel::GetCommandBuffer();
u32 data;
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp
index 71ee4ff..24d61d1 100644
--- a/src/core/hle/service/fs/fs_user.cpp
+++ b/src/core/hle/service/fs/fs_user.cpp
@@ -496,6 +496,14 @@ static void CreateExtSaveData(Service::Interface* self) {
cmd_buff[1] = CreateExtSaveData(save_high, save_low).raw;
}
+static void CardSlotIsInserted(Service::Interface* self) {
+ u32* cmd_buff = Kernel::GetCommandBuffer();
+ cmd_buff[1] = RESULT_SUCCESS.raw;
+ cmd_buff[2] = 0;
+ cmd_buff[3] = 0;
+ cmd_buff[4] = 0;
+}
+
const FSUserInterface::FunctionInfo FunctionTable[] = {
{0x000100C6, nullptr, "Dummy1"},
{0x040100C4, nullptr, "Control"},
@@ -531,7 +539,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/hle/service/nim_aoc.cpp b/src/core/hle/service/nim_aoc.cpp
index 7a6aea9..a5e43d2 100644
--- a/src/core/hle/service/nim_aoc.cpp
+++ b/src/core/hle/service/nim_aoc.cpp
@@ -28,3 +28,24 @@ Interface::Interface() {
}
} // namespace
+
+namespace NIM_U {
+
+ const Interface::FunctionInfo FunctionTable[] = {
+ { 0x00030042, nullptr, "SetApplicationId" },
+ { 0x00040042, nullptr, "SetTin" },
+ { 0x000902D0, nullptr, "ListContentSetsEx" },
+ { 0x00180000, nullptr, "GetBalance" },
+ { 0x001D0000, nullptr, "GetCustomerSupportCode" },
+ { 0x00210000, nullptr, "Initialize" },
+ { 0x00240282, nullptr, "CalculateContentsRequiredSize" },
+ { 0x00250000, nullptr, "RefreshServerTime" },
+ };
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ // Interface class
+
+ Interface::Interface() {
+ Register(FunctionTable);
+ }
+
+} // namespace
\ No newline at end of file
diff --git a/src/core/hle/service/nim_aoc.h b/src/core/hle/service/nim_aoc.h
index aeb71ee..3f6f2af 100644
--- a/src/core/hle/service/nim_aoc.h
+++ b/src/core/hle/service/nim_aoc.h
@@ -21,3 +21,16 @@ public:
};
} // namespace
+
+namespace NIM_U {
+
+ class Interface : public Service::Interface {
+ public:
+ Interface();
+
+ std::string GetPortName() const override {
+ return "nim:u";
+ }
+ };
+
+} // namespace
diff --git a/src/core/hle/service/ptm_sysm.cpp b/src/core/hle/service/ptm_sysm.cpp
index 96ef2dc..5c8722e 100644
--- a/src/core/hle/service/ptm_sysm.cpp
+++ b/src/core/hle/service/ptm_sysm.cpp
@@ -12,6 +12,13 @@
namespace PTM_SYSM {
+void IsLegacyPowerOff(Service::Interface* self) {
+ u32* cmd_buff = Kernel::GetCommandBuffer();
+ cmd_buff[1] = RESULT_SUCCESS.raw;
+ cmd_buff[2] = 0;
+ cmd_buff[3] = 0;
+}
+
const Interface::FunctionInfo FunctionTable[] = {
{0x040100C0, nullptr, "SetRtcAlarmEx"},
{0x04020042, nullptr, "ReplySleepQuery"},
@@ -37,7 +44,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x080C0080, nullptr, "SetUserTime"},
{0x080D0000, nullptr, "InvalidateSystemTime"},
{0x080E0140, nullptr, "NotifyPlayEvent"},
- {0x080F0000, nullptr, "IsLegacyPowerOff"},
+ {0x080F0000, IsLegacyPowerOff, "IsLegacyPowerOff"},
{0x08100000, nullptr, "ClearLegacyPowerOff"},
{0x08110000, nullptr, "GetShellStatus"},
{0x08120000, nullptr, "IsShutdownByBatteryEmpty"},
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 5dce806..1c652c4 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -107,6 +107,7 @@ void Init() {
AddService(new NEWS_S::Interface);
AddService(new NEWS_U::Interface);
AddService(new NIM_AOC::Interface);
+ AddService(new NIM_U::Interface);
AddService(new NS_S::Interface);
AddService(new NWM_UDS::Interface);
AddService(new PM_APP::Interface);
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp
index e6022d6..3a1db16 100644
--- a/src/core/hw/gpu.cpp
+++ b/src/core/hw/gpu.cpp
@@ -143,7 +143,7 @@ inline void Write(u32 addr, const T data) {
case Regs::PixelFormat::RGB5A1:
{
- u16 srcval = *(u16*)(source_pointer + x * 4 * pixel_skip + y * config.input_width * 4 * pixel_skip);
+ u16 srcval = *(u16*)(source_pointer + x * 2 * pixel_skip + y * config.input_width * 2 * 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
@@ -153,7 +153,7 @@ inline void Write(u32 addr, const T data) {
case Regs::PixelFormat::RGBA4:
{
- u16 srcval = *(u16*)(source_pointer + x * 4 * pixel_skip + y * config.input_width * 4 * pixel_skip);
+ u16 srcval = *(u16*)(source_pointer + x * 2 * pixel_skip + y * config.input_width * 2 * 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
diff --git a/src/video_core/clipper.cpp b/src/video_core/clipper.cpp
index ba3876a..233e79e 100644
--- a/src/video_core/clipper.cpp
+++ b/src/video_core/clipper.cpp
@@ -161,6 +161,7 @@ void ProcessTriangle(OutputVertex &v0, OutputVertex &v1, OutputVertex &v2) {
vtx2.screenpos.x.ToFloat32(), vtx2.screenpos.y.ToFloat32(), vtx2.screenpos.z.ToFloat32());
Rasterizer::ProcessTriangle(vtx0, vtx1, vtx2);
+ Rasterizer::ProcessTriangle(vtx2, vtx1, vtx0);
}
}
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp
index 0beb72e..514d415 100644
--- a/src/video_core/debug_utils/debug_utils.cpp
+++ b/src/video_core/debug_utils/debug_utils.cpp
@@ -434,6 +434,16 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture
}
}
+ case Regs::TextureFormat::I4:
+ {
+ const u8* source_ptr = source + offset / 2 + i / 2;
+
+ u8 a = (coarse_x % 2) ? ((*source_ptr) & 0xF) : (((*source_ptr) & 0xF0) >> 4);
+ a = Color::Convert4To8(a);
+
+ return{ a, a, a, 255 };
+ }
+
case Regs::TextureFormat::A4:
{
const u8* source_ptr = source + offset / 2 + i / 2;
diff --git a/src/video_core/pica.h b/src/video_core/pica.h
index d03b811..9cb2df9 100644
--- a/src/video_core/pica.h
+++ b/src/video_core/pica.h
@@ -112,6 +112,7 @@ struct Regs {
struct TextureConfig {
enum WrapMode : u32 {
ClampToEdge = 0,
+ ClampToBorder = 1,
Repeat = 2,
MirroredRepeat = 3,
};
@@ -153,7 +154,7 @@ struct Regs {
I8 = 7,
A8 = 8,
IA4 = 9,
-
+ I4 = 10,
A4 = 11,
ETC1 = 12, // compressed
ETC1A4 = 13, // compressed
@@ -218,12 +219,13 @@ struct Regs {
enum class Source : u32 {
PrimaryColor = 0x0,
PrimaryFragmentColor = 0x1,
-
+ Unknown = 0x2,
Texture0 = 0x3,
Texture1 = 0x4,
Texture2 = 0x5,
Texture3 = 0x6,
// 0x7-0xc = primary color??
+ PreviousBuffer = 0xd,
Constant = 0xe,
Previous = 0xf,
};
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp
index 17f8f70..ec3776e 100644
--- a/src/video_core/rasterizer.cpp
+++ b/src/video_core/rasterizer.cpp
@@ -270,10 +270,11 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0,
static auto GetWrappedTexCoord = [](Regs::TextureConfig::WrapMode mode, int val, unsigned size) {
switch (mode) {
case Regs::TextureConfig::ClampToEdge:
+ case Regs::TextureConfig::ClampToBorder:
val = std::max(val, 0);
val = std::min(val, (int)size - 1);
return val;
-
+
case Regs::TextureConfig::Repeat:
return (int)((unsigned)val % size);
@@ -326,6 +327,9 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0,
case Source::PrimaryFragmentColor:
return primary_color;
+ case Source::Unknown:
+ return{};
+
case Source::Texture0:
return texture_color[0];
@@ -335,6 +339,9 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0,
case Source::Texture2:
return texture_color[2];
+ case Source::PreviousBuffer:
+ return combiner_output;
+
case Source::Constant:
return {tev_stage.const_r, tev_stage.const_g, tev_stage.const_b, tev_stage.const_a};
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index 2726951..f357b5c 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -262,6 +262,7 @@ void RendererOpenGL::DrawScreens() {
DrawSingleScreenRotated(textures[0], top_x, 0,
(float)VideoCore::kScreenTopWidth, (float)VideoCore::kScreenTopHeight);
+ glFlush();
DrawSingleScreenRotated(textures[1], bottom_x, (float)VideoCore::kScreenTopHeight,
(float)VideoCore::kScreenBottomWidth, (float)VideoCore::kScreenBottomHeight);
diff --git a/src/video_core/vertex_shader.cpp b/src/video_core/vertex_shader.cpp
index bc8c004..cc2a862 100644
--- a/src/video_core/vertex_shader.cpp
+++ b/src/video_core/vertex_shader.cpp
@@ -163,9 +163,12 @@ static void ProcessShaderCode(VertexShaderState& state) {
// For now, we just abort in this situation.
ASSERT_MSG(!is_inverted, "Bad condition...");
- const int address_offset = (instr.common.address_register_index == 0)
+ int address_offset = (instr.common.address_register_index == 0)
? 0 : state.address_registers[instr.common.address_register_index - 1];
+ if (address_offset > 95 || address_offset < -95)
+ address_offset = 0;
+
const float24* src1_ = LookupSourceRegister(instr.common.GetSrc1(is_inverted) + address_offset);
const float24* src2_ = LookupSourceRegister(instr.common.GetSrc2(is_inverted));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment