summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/citra_qt/bootmanager.cpp2
-rw-r--r--src/citra_qt/debugger/disassembler.cpp2
-rw-r--r--src/citra_qt/main.cpp5
-rw-r--r--src/citra_qt/main.h2
-rw-r--r--src/core/arm/dyncom/arm_dyncom_interpreter.cpp43
-rw-r--r--src/core/hle/applets/applet.cpp9
-rw-r--r--src/core/hle/applets/applet.h3
-rw-r--r--src/core/hle/service/am/am.cpp3
-rw-r--r--src/core/hle/service/am/am_net.cpp3
-rw-r--r--src/core/hle/service/apt/apt.cpp53
-rw-r--r--src/core/hle/service/apt/apt.h30
-rw-r--r--src/core/hle/service/apt/apt_a.cpp1
-rw-r--r--src/core/hle/service/apt/apt_s.cpp4
-rw-r--r--src/core/hle/service/apt/apt_u.cpp2
-rw-r--r--src/core/hle/service/ldr_ro.cpp6
-rw-r--r--src/core/hle/service/soc_u.cpp10
-rw-r--r--src/core/hw/y2r.cpp1
-rw-r--r--src/video_core/command_processor.cpp80
-rw-r--r--src/video_core/vertex_shader.cpp6
20 files changed, 186 insertions, 81 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e945a6679..a02b85da3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,7 +48,7 @@ else()
48 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "" FORCE) 48 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "" FORCE)
49 49
50 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG" CACHE STRING "" FORCE) 50 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG" CACHE STRING "" FORCE)
51 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG" CACHE STRING "" FORCE) 51 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE)
52endif() 52endif()
53 53
54add_definitions(-DSINGLETHREADED) 54add_definitions(-DSINGLETHREADED)
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index b12bd858b..a96fbea5f 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -94,7 +94,7 @@ private:
94}; 94};
95 95
96GRenderWindow::GRenderWindow(QWidget* parent, EmuThread* emu_thread) : 96GRenderWindow::GRenderWindow(QWidget* parent, EmuThread* emu_thread) :
97 QWidget(parent), emu_thread(emu_thread), keyboard_id(0) { 97 QWidget(parent), keyboard_id(0), emu_thread(emu_thread) {
98 98
99 std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); 99 std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc);
100 setWindowTitle(QString::fromStdString(window_title)); 100 setWindowTitle(QString::fromStdString(window_title));
diff --git a/src/citra_qt/debugger/disassembler.cpp b/src/citra_qt/debugger/disassembler.cpp
index 1e5ef5299..d3629bbf6 100644
--- a/src/citra_qt/debugger/disassembler.cpp
+++ b/src/citra_qt/debugger/disassembler.cpp
@@ -159,7 +159,7 @@ void DisassemblerModel::SetNextInstruction(unsigned int address) {
159} 159}
160 160
161DisassemblerWidget::DisassemblerWidget(QWidget* parent, EmuThread* emu_thread) : 161DisassemblerWidget::DisassemblerWidget(QWidget* parent, EmuThread* emu_thread) :
162 QDockWidget(parent), emu_thread(emu_thread), base_addr(0) { 162 QDockWidget(parent), base_addr(0), emu_thread(emu_thread) {
163 163
164 disasm_ui.setupUi(this); 164 disasm_ui.setupUi(this);
165 165
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 2746de779..e93e8ebb8 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -207,7 +207,7 @@ void GMainWindow::OnDisplayTitleBars(bool show)
207 } 207 }
208} 208}
209 209
210void GMainWindow::BootGame(std::string filename) { 210void GMainWindow::BootGame(const std::string& filename) {
211 LOG_INFO(Frontend, "Citra starting...\n"); 211 LOG_INFO(Frontend, "Citra starting...\n");
212 212
213 // Initialize the core emulation 213 // Initialize the core emulation
@@ -263,6 +263,7 @@ void GMainWindow::ShutdownGame() {
263 263
264 // Update the GUI 264 // Update the GUI
265 ui.action_Start->setEnabled(false); 265 ui.action_Start->setEnabled(false);
266 ui.action_Start->setText(tr("Start"));
266 ui.action_Pause->setEnabled(false); 267 ui.action_Pause->setEnabled(false);
267 ui.action_Stop->setEnabled(false); 268 ui.action_Stop->setEnabled(false);
268 render_window->hide(); 269 render_window->hide();
@@ -291,6 +292,8 @@ void GMainWindow::OnStartGame()
291 emu_thread->SetRunning(true); 292 emu_thread->SetRunning(true);
292 293
293 ui.action_Start->setEnabled(false); 294 ui.action_Start->setEnabled(false);
295 ui.action_Start->setText(tr("Continue"));
296
294 ui.action_Pause->setEnabled(true); 297 ui.action_Pause->setEnabled(true);
295 ui.action_Stop->setEnabled(true); 298 ui.action_Stop->setEnabled(true);
296} 299}
diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h
index 242b08c39..9fe9e0c9c 100644
--- a/src/citra_qt/main.h
+++ b/src/citra_qt/main.h
@@ -55,7 +55,7 @@ signals:
55 void EmulationStopping(); 55 void EmulationStopping();
56 56
57private: 57private:
58 void BootGame(std::string filename); 58 void BootGame(const std::string& filename);
59 void ShutdownGame(); 59 void ShutdownGame();
60 60
61 void closeEvent(QCloseEvent* event) override; 61 void closeEvent(QCloseEvent* event) override;
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
index d022546ed..bb0cbb4dc 100644
--- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
+++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
@@ -3886,7 +3886,6 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
3886#endif 3886#endif
3887 arm_inst* inst_base; 3887 arm_inst* inst_base;
3888 unsigned int addr; 3888 unsigned int addr;
3889 unsigned int phys_addr;
3890 unsigned int num_instrs = 0; 3889 unsigned int num_instrs = 0;
3891 3890
3892 int ptr; 3891 int ptr;
@@ -3905,8 +3904,6 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
3905 else 3904 else
3906 cpu->Reg[15] &= 0xfffffffc; 3905 cpu->Reg[15] &= 0xfffffffc;
3907 3906
3908 phys_addr = cpu->Reg[15];
3909
3910 // Find the cached instruction cream, otherwise translate it... 3907 // Find the cached instruction cream, otherwise translate it...
3911 auto itr = cpu->instruction_cache.find(cpu->Reg[15]); 3908 auto itr = cpu->instruction_cache.find(cpu->Reg[15]);
3912 if (itr != cpu->instruction_cache.end()) { 3909 if (itr != cpu->instruction_cache.end()) {
@@ -3924,9 +3921,13 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
3924 if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) { 3921 if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) {
3925 adc_inst* const inst_cream = (adc_inst*)inst_base->component; 3922 adc_inst* const inst_cream = (adc_inst*)inst_base->component;
3926 3923
3924 u32 rn_val = RN;
3925 if (inst_cream->Rn == 15)
3926 rn_val += 2 * cpu->GetInstructionSize();
3927
3927 bool carry; 3928 bool carry;
3928 bool overflow; 3929 bool overflow;
3929 RD = AddWithCarry(RN, SHIFTER_OPERAND, cpu->CFlag, &carry, &overflow); 3930 RD = AddWithCarry(rn_val, SHIFTER_OPERAND, cpu->CFlag, &carry, &overflow);
3930 3931
3931 if (inst_cream->S && (inst_cream->Rd == 15)) { 3932 if (inst_cream->S && (inst_cream->Rd == 15)) {
3932 if (CurrentModeHasSPSR) { 3933 if (CurrentModeHasSPSR) {
@@ -3987,11 +3988,17 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
3987 } 3988 }
3988 AND_INST: 3989 AND_INST:
3989 { 3990 {
3990 and_inst *inst_cream = (and_inst *)inst_base->component; 3991 if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) {
3991 if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) { 3992 and_inst* const inst_cream = (and_inst*)inst_base->component;
3993
3992 u32 lop = RN; 3994 u32 lop = RN;
3993 u32 rop = SHIFTER_OPERAND; 3995 u32 rop = SHIFTER_OPERAND;
3996
3997 if (inst_cream->Rn == 15)
3998 lop += 2 * cpu->GetInstructionSize();
3999
3994 RD = lop & rop; 4000 RD = lop & rop;
4001
3995 if (inst_cream->S && (inst_cream->Rd == 15)) { 4002 if (inst_cream->S && (inst_cream->Rd == 15)) {
3996 if (CurrentModeHasSPSR) { 4003 if (CurrentModeHasSPSR) {
3997 cpu->Cpsr = cpu->Spsr_copy; 4004 cpu->Cpsr = cpu->Spsr_copy;
@@ -4164,9 +4171,13 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4164 if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) { 4171 if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) {
4165 cmn_inst* const inst_cream = (cmn_inst*)inst_base->component; 4172 cmn_inst* const inst_cream = (cmn_inst*)inst_base->component;
4166 4173
4174 u32 rn_val = RN;
4175 if (inst_cream->Rn == 15)
4176 rn_val += 2 * cpu->GetInstructionSize();
4177
4167 bool carry; 4178 bool carry;
4168 bool overflow; 4179 bool overflow;
4169 u32 result = AddWithCarry(RN, SHIFTER_OPERAND, 0, &carry, &overflow); 4180 u32 result = AddWithCarry(rn_val, SHIFTER_OPERAND, 0, &carry, &overflow);
4170 4181
4171 UPDATE_NFLAG(result); 4182 UPDATE_NFLAG(result);
4172 UPDATE_ZFLAG(result); 4183 UPDATE_ZFLAG(result);
@@ -4905,6 +4916,10 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4905 4916
4906 u32 lop = RN; 4917 u32 lop = RN;
4907 u32 rop = SHIFTER_OPERAND; 4918 u32 rop = SHIFTER_OPERAND;
4919
4920 if (inst_cream->Rn == 15)
4921 lop += 2 * cpu->GetInstructionSize();
4922
4908 RD = lop | rop; 4923 RD = lop | rop;
4909 4924
4910 if (inst_cream->S && (inst_cream->Rd == 15)) { 4925 if (inst_cream->S && (inst_cream->Rd == 15)) {
@@ -5195,9 +5210,13 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5195 if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) { 5210 if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) {
5196 rsc_inst* const inst_cream = (rsc_inst*)inst_base->component; 5211 rsc_inst* const inst_cream = (rsc_inst*)inst_base->component;
5197 5212
5213 u32 rn_val = RN;
5214 if (inst_cream->Rn == 15)
5215 rn_val += 2 * cpu->GetInstructionSize();
5216
5198 bool carry; 5217 bool carry;
5199 bool overflow; 5218 bool overflow;
5200 RD = AddWithCarry(~RN, SHIFTER_OPERAND, cpu->CFlag, &carry, &overflow); 5219 RD = AddWithCarry(~rn_val, SHIFTER_OPERAND, cpu->CFlag, &carry, &overflow);
5201 5220
5202 if (inst_cream->S && (inst_cream->Rd == 15)) { 5221 if (inst_cream->S && (inst_cream->Rd == 15)) {
5203 if (CurrentModeHasSPSR) { 5222 if (CurrentModeHasSPSR) {
@@ -5335,9 +5354,13 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5335 if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) { 5354 if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) {
5336 sbc_inst* const inst_cream = (sbc_inst*)inst_base->component; 5355 sbc_inst* const inst_cream = (sbc_inst*)inst_base->component;
5337 5356
5357 u32 rn_val = RN;
5358 if (inst_cream->Rn == 15)
5359 rn_val += 2 * cpu->GetInstructionSize();
5360
5338 bool carry; 5361 bool carry;
5339 bool overflow; 5362 bool overflow;
5340 RD = AddWithCarry(RN, ~SHIFTER_OPERAND, cpu->CFlag, &carry, &overflow); 5363 RD = AddWithCarry(rn_val, ~SHIFTER_OPERAND, cpu->CFlag, &carry, &overflow);
5341 5364
5342 if (inst_cream->S && (inst_cream->Rd == 15)) { 5365 if (inst_cream->S && (inst_cream->Rd == 15)) {
5343 if (CurrentModeHasSPSR) { 5366 if (CurrentModeHasSPSR) {
@@ -6171,7 +6194,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6171 6194
6172 u32 rn_val = RN; 6195 u32 rn_val = RN;
6173 if (inst_cream->Rn == 15) 6196 if (inst_cream->Rn == 15)
6174 rn_val += 8; 6197 rn_val += 2 * cpu->GetInstructionSize();
6175 6198
6176 bool carry; 6199 bool carry;
6177 bool overflow; 6200 bool overflow;
diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp
index 826f6cbb6..bc2a1829e 100644
--- a/src/core/hle/applets/applet.cpp
+++ b/src/core/hle/applets/applet.cpp
@@ -89,12 +89,21 @@ ResultCode Applet::Start(const Service::APT::AppletStartupParameter& parameter)
89 return result; 89 return result;
90} 90}
91 91
92bool IsLibraryAppletRunning() {
93 // Check the applets map for instances of any applet
94 for (auto itr = applets.begin(); itr != applets.end(); ++itr)
95 if (itr->second != nullptr)
96 return true;
97 return false;
98}
99
92void Init() { 100void Init() {
93 // Register the applet update callback 101 // Register the applet update callback
94 applet_update_event = CoreTiming::RegisterEvent("HLE Applet Update Event", AppletUpdateEvent); 102 applet_update_event = CoreTiming::RegisterEvent("HLE Applet Update Event", AppletUpdateEvent);
95} 103}
96 104
97void Shutdown() { 105void Shutdown() {
106 CoreTiming::RemoveEvent(applet_update_event);
98} 107}
99 108
100} 109}
diff --git a/src/core/hle/applets/applet.h b/src/core/hle/applets/applet.h
index b235d0b8a..af442f81d 100644
--- a/src/core/hle/applets/applet.h
+++ b/src/core/hle/applets/applet.h
@@ -67,6 +67,9 @@ protected:
67 Service::APT::AppletId id; ///< Id of this Applet 67 Service::APT::AppletId id; ///< Id of this Applet
68}; 68};
69 69
70/// Returns whether a library applet is currently running
71bool IsLibraryAppletRunning();
72
70/// Initializes the HLE applets 73/// Initializes the HLE applets
71void Init(); 74void Init();
72 75
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 7332478fb..7ae4859a7 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -5,6 +5,7 @@
5#include "common/logging/log.h" 5#include "common/logging/log.h"
6 6
7#include "core/hle/service/service.h" 7#include "core/hle/service/service.h"
8#include "core/hle/service/am/am.h"
8#include "core/hle/service/am/am_app.h" 9#include "core/hle/service/am/am_app.h"
9#include "core/hle/service/am/am_net.h" 10#include "core/hle/service/am/am_net.h"
10#include "core/hle/service/am/am_sys.h" 11#include "core/hle/service/am/am_sys.h"
@@ -35,7 +36,7 @@ void GetTitleIDList(Service::Interface* self) {
35 cmd_buff[1] = RESULT_SUCCESS.raw; 36 cmd_buff[1] = RESULT_SUCCESS.raw;
36 cmd_buff[2] = 0; 37 cmd_buff[2] = 0;
37 38
38 LOG_WARNING(Service_AM, "(STUBBED) Requested %u titles from media type %u", num_titles, media_type); 39 LOG_WARNING(Service_AM, "(STUBBED) Requested %u titles from media type %u. Address=0x%08X", num_titles, media_type, addr);
39} 40}
40 41
41void GetNumContentInfos(Service::Interface* self) { 42void GetNumContentInfos(Service::Interface* self) {
diff --git a/src/core/hle/service/am/am_net.cpp b/src/core/hle/service/am/am_net.cpp
index b1af0e9d8..aa391f3b2 100644
--- a/src/core/hle/service/am/am_net.cpp
+++ b/src/core/hle/service/am/am_net.cpp
@@ -28,7 +28,8 @@ const Interface::FunctionInfo FunctionTable[] = {
28 {0x08130000, nullptr, "GetTotalContents"}, 28 {0x08130000, nullptr, "GetTotalContents"},
29 {0x08140042, nullptr, "GetContentIndexes"}, 29 {0x08140042, nullptr, "GetContentIndexes"},
30 {0x08150044, nullptr, "GetContentsInfo"}, 30 {0x08150044, nullptr, "GetContentsInfo"},
31 {0x08190108, nullptr, "Unknown"}, 31 {0x08180042, nullptr, "GetCTCert"},
32 {0x08190108, nullptr, "SetCertificates"},
32 {0x081B00C2, nullptr, "InstallTitlesFinish"}, 33 {0x081B00C2, nullptr, "InstallTitlesFinish"},
33}; 34};
34 35
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp
index 7b6ab4ce0..35402341b 100644
--- a/src/core/hle/service/apt/apt.cpp
+++ b/src/core/hle/service/apt/apt.cpp
@@ -101,18 +101,19 @@ void NotifyToWait(Service::Interface* self) {
101 101
102void GetLockHandle(Service::Interface* self) { 102void GetLockHandle(Service::Interface* self) {
103 u32* cmd_buff = Kernel::GetCommandBuffer(); 103 u32* cmd_buff = Kernel::GetCommandBuffer();
104 u32 flags = cmd_buff[1]; // TODO(bunnei): Figure out the purpose of the flag field 104 // Bits [0:2] are the applet type (System, Library, etc)
105 // Bit 5 tells the application that there's a pending APT parameter,
106 // this will cause the app to wait until parameter_event is signaled.
107 u32 applet_attributes = cmd_buff[1];
105 108
106 cmd_buff[1] = RESULT_SUCCESS.raw; // No error 109 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
107 110
108 // Not sure what these parameters are used for, but retail apps check that they are 0 after 111 cmd_buff[2] = applet_attributes; // Applet Attributes, this value is passed to Enable.
109 // GetLockHandle has been called. 112 cmd_buff[3] = 0; // Least significant bit = power button state
110 cmd_buff[2] = 0; // Applet Attributes, this value is passed to Enable. 113 cmd_buff[4] = IPC::CopyHandleDesc();
111 cmd_buff[3] = 0;
112 cmd_buff[4] = 0;
113
114 cmd_buff[5] = Kernel::g_handle_table.Create(lock).MoveFrom(); 114 cmd_buff[5] = Kernel::g_handle_table.Create(lock).MoveFrom();
115 LOG_TRACE(Service_APT, "called handle=0x%08X", cmd_buff[5]); 115
116 LOG_WARNING(Service_APT, "(STUBBED) called handle=0x%08X applet_attributes=0x%08X", cmd_buff[5], applet_attributes);
116} 117}
117 118
118void Enable(Service::Interface* self) { 119void Enable(Service::Interface* self) {
@@ -139,13 +140,16 @@ void IsRegistered(Service::Interface* self) {
139 u32* cmd_buff = Kernel::GetCommandBuffer(); 140 u32* cmd_buff = Kernel::GetCommandBuffer();
140 u32 app_id = cmd_buff[1]; 141 u32 app_id = cmd_buff[1];
141 cmd_buff[1] = RESULT_SUCCESS.raw; // No error 142 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
142 /// TODO(Subv): It is currently unknown what this value (0x400) means, 143
143 /// but i believe it is used as a global "LibraryApplet" id, to verify if there's 144 // TODO(Subv): An application is considered "registered" if it has already called APT::Enable
144 /// any LibApplet currently running. This is not verified. 145 // handle this properly once we implement multiprocess support.
145 if (app_id != 0x400) 146 cmd_buff[2] = 0; // Set to not registered by default
147
148 if (app_id == static_cast<u32>(AppletId::AnyLibraryApplet)) {
149 cmd_buff[2] = HLE::Applets::IsLibraryAppletRunning() ? 1 : 0;
150 } else if (auto applet = HLE::Applets::Applet::Get(static_cast<AppletId>(app_id))) {
146 cmd_buff[2] = 1; // Set to registered 151 cmd_buff[2] = 1; // Set to registered
147 else 152 }
148 cmd_buff[2] = 0; // Set to not registered
149 LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id); 153 LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id);
150} 154}
151 155
@@ -330,7 +334,26 @@ void GetAppCpuTimeLimit(Service::Interface* self) {
330void PrepareToStartLibraryApplet(Service::Interface* self) { 334void PrepareToStartLibraryApplet(Service::Interface* self) {
331 u32* cmd_buff = Kernel::GetCommandBuffer(); 335 u32* cmd_buff = Kernel::GetCommandBuffer();
332 AppletId applet_id = static_cast<AppletId>(cmd_buff[1]); 336 AppletId applet_id = static_cast<AppletId>(cmd_buff[1]);
333 cmd_buff[1] = HLE::Applets::Applet::Create(applet_id).raw; 337 auto applet = HLE::Applets::Applet::Get(applet_id);
338 if (applet) {
339 LOG_WARNING(Service_APT, "applet has already been started id=%08X", applet_id);
340 cmd_buff[1] = RESULT_SUCCESS.raw;
341 } else {
342 cmd_buff[1] = HLE::Applets::Applet::Create(applet_id).raw;
343 }
344 LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id);
345}
346
347void PreloadLibraryApplet(Service::Interface* self) {
348 u32* cmd_buff = Kernel::GetCommandBuffer();
349 AppletId applet_id = static_cast<AppletId>(cmd_buff[1]);
350 auto applet = HLE::Applets::Applet::Get(applet_id);
351 if (applet) {
352 LOG_WARNING(Service_APT, "applet has already been started id=%08X", applet_id);
353 cmd_buff[1] = RESULT_SUCCESS.raw;
354 } else {
355 cmd_buff[1] = HLE::Applets::Applet::Create(applet_id).raw;
356 }
334 LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id); 357 LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id);
335} 358}
336 359
diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h
index 72972d05b..4a72b6b5c 100644
--- a/src/core/hle/service/apt/apt.h
+++ b/src/core/hle/service/apt/apt.h
@@ -62,6 +62,7 @@ enum class AppletId : u32 {
62 Extrapad = 0x208, 62 Extrapad = 0x208,
63 Memolib = 0x209, 63 Memolib = 0x209,
64 Application = 0x300, 64 Application = 0x300,
65 AnyLibraryApplet = 0x400,
65 SoftwareKeyboard2 = 0x401, 66 SoftwareKeyboard2 = 0x401,
66}; 67};
67 68
@@ -96,8 +97,26 @@ void GetSharedFont(Service::Interface* self);
96 */ 97 */
97void NotifyToWait(Service::Interface* self); 98void NotifyToWait(Service::Interface* self);
98 99
100/**
101 * APT::GetLockHandle service function
102 * Inputs:
103 * 1 : Applet attributes
104 * Outputs:
105 * 1 : Result of function, 0 on success, otherwise error code
106 * 2 : Applet attributes
107 * 3 : Power button state
108 * 4 : IPC handle descriptor
109 * 5 : APT mutex handle
110 */
99void GetLockHandle(Service::Interface* self); 111void GetLockHandle(Service::Interface* self);
100 112
113/**
114 * APT::Enable service function
115 * Inputs:
116 * 1 : Applet attributes
117 * Outputs:
118 * 1 : Result of function, 0 on success, otherwise error code
119 */
101void Enable(Service::Interface* self); 120void Enable(Service::Interface* self);
102 121
103/** 122/**
@@ -284,6 +303,17 @@ void GetAppCpuTimeLimit(Service::Interface* self);
284void PrepareToStartLibraryApplet(Service::Interface* self); 303void PrepareToStartLibraryApplet(Service::Interface* self);
285 304
286/** 305/**
306 * APT::PreloadLibraryApplet service function
307 * Inputs:
308 * 0 : Command header [0x00160040]
309 * 1 : Id of the applet to start
310 * Outputs:
311 * 0 : Return header
312 * 1 : Result of function, 0 on success, otherwise error code
313 */
314void PreloadLibraryApplet(Service::Interface* self);
315
316/**
287 * APT::StartLibraryApplet service function 317 * APT::StartLibraryApplet service function
288 * Inputs: 318 * Inputs:
289 * 0 : Command header [0x001E0084] 319 * 0 : Command header [0x001E0084]
diff --git a/src/core/hle/service/apt/apt_a.cpp b/src/core/hle/service/apt/apt_a.cpp
index 88de339f9..22800c56f 100644
--- a/src/core/hle/service/apt/apt_a.cpp
+++ b/src/core/hle/service/apt/apt_a.cpp
@@ -21,6 +21,7 @@ const Interface::FunctionInfo FunctionTable[] = {
21 {0x000D0080, ReceiveParameter, "ReceiveParameter"}, 21 {0x000D0080, ReceiveParameter, "ReceiveParameter"},
22 {0x000E0080, GlanceParameter, "GlanceParameter"}, 22 {0x000E0080, GlanceParameter, "GlanceParameter"},
23 {0x000F0100, CancelParameter, "CancelParameter"}, 23 {0x000F0100, CancelParameter, "CancelParameter"},
24 {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
24 {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"}, 25 {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
25 {0x001E0084, StartLibraryApplet, "StartLibraryApplet"}, 26 {0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
26 {0x003B0040, nullptr, "CancelLibraryApplet?"}, 27 {0x003B0040, nullptr, "CancelLibraryApplet?"},
diff --git a/src/core/hle/service/apt/apt_s.cpp b/src/core/hle/service/apt/apt_s.cpp
index 396d1f04a..3ac6ff94f 100644
--- a/src/core/hle/service/apt/apt_s.cpp
+++ b/src/core/hle/service/apt/apt_s.cpp
@@ -32,9 +32,9 @@ const Interface::FunctionInfo FunctionTable[] = {
32 {0x00130000, nullptr, "GetPreparationState"}, 32 {0x00130000, nullptr, "GetPreparationState"},
33 {0x00140040, nullptr, "SetPreparationState"}, 33 {0x00140040, nullptr, "SetPreparationState"},
34 {0x00150140, nullptr, "PrepareToStartApplication"}, 34 {0x00150140, nullptr, "PrepareToStartApplication"},
35 {0x00160040, nullptr, "PreloadLibraryApplet"}, 35 {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
36 {0x00170040, nullptr, "FinishPreloadingLibraryApplet"}, 36 {0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
37 {0x00180040, nullptr, "PrepareToStartLibraryApplet"}, 37 {0x00180040, PrepareToStartLibraryApplet,"PrepareToStartLibraryApplet"},
38 {0x00190040, nullptr, "PrepareToStartSystemApplet"}, 38 {0x00190040, nullptr, "PrepareToStartSystemApplet"},
39 {0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"}, 39 {0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"},
40 {0x001B00C4, nullptr, "StartApplication"}, 40 {0x001B00C4, nullptr, "StartApplication"},
diff --git a/src/core/hle/service/apt/apt_u.cpp b/src/core/hle/service/apt/apt_u.cpp
index b724cd72b..146bfd595 100644
--- a/src/core/hle/service/apt/apt_u.cpp
+++ b/src/core/hle/service/apt/apt_u.cpp
@@ -33,7 +33,7 @@ const Interface::FunctionInfo FunctionTable[] = {
33 {0x00130000, nullptr, "GetPreparationState"}, 33 {0x00130000, nullptr, "GetPreparationState"},
34 {0x00140040, nullptr, "SetPreparationState"}, 34 {0x00140040, nullptr, "SetPreparationState"},
35 {0x00150140, nullptr, "PrepareToStartApplication"}, 35 {0x00150140, nullptr, "PrepareToStartApplication"},
36 {0x00160040, nullptr, "PreloadLibraryApplet"}, 36 {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
37 {0x00170040, nullptr, "FinishPreloadingLibraryApplet"}, 37 {0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
38 {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"}, 38 {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
39 {0x00190040, nullptr, "PrepareToStartSystemApplet"}, 39 {0x00190040, nullptr, "PrepareToStartSystemApplet"},
diff --git a/src/core/hle/service/ldr_ro.cpp b/src/core/hle/service/ldr_ro.cpp
index 155b97f69..f84ce4d72 100644
--- a/src/core/hle/service/ldr_ro.cpp
+++ b/src/core/hle/service/ldr_ro.cpp
@@ -40,7 +40,8 @@ static void Initialize(Service::Interface* self) {
40 40
41 cmd_buff[1] = RESULT_SUCCESS.raw; // No error 41 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
42 42
43 LOG_WARNING(Service_LDR, "(STUBBED) called"); 43 LOG_WARNING(Service_LDR, "(STUBBED) called. crs_buffer_ptr=0x%08X, crs_size=0x%08X, address=0x%08X, value=0x%08X, process=0x%08X",
44 crs_buffer_ptr, crs_size, address, value, process);
44} 45}
45 46
46/** 47/**
@@ -69,7 +70,8 @@ static void LoadCRR(Service::Interface* self) {
69 70
70 cmd_buff[1] = RESULT_SUCCESS.raw; // No error 71 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
71 72
72 LOG_WARNING(Service_LDR, "(STUBBED) called"); 73 LOG_WARNING(Service_LDR, "(STUBBED) called. crs_buffer_ptr=0x%08X, crs_size=0x%08X, value=0x%08X, process=0x%08X",
74 crs_buffer_ptr, crs_size, value, process);
73} 75}
74 76
75const Interface::FunctionInfo FunctionTable[] = { 77const Interface::FunctionInfo FunctionTable[] = {
diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cpp
index d0e166fdf..d768a3fc7 100644
--- a/src/core/hle/service/soc_u.cpp
+++ b/src/core/hle/service/soc_u.cpp
@@ -481,11 +481,17 @@ static void GetHostId(Service::Interface* self) {
481 481
482 char name[128]; 482 char name[128];
483 gethostname(name, sizeof(name)); 483 gethostname(name, sizeof(name));
484 hostent* host = gethostbyname(name); 484 addrinfo hints = {};
485 in_addr* addr = reinterpret_cast<in_addr*>(host->h_addr); 485 addrinfo* res;
486
487 hints.ai_family = AF_INET;
488 getaddrinfo(name, NULL, &hints, &res);
489 sockaddr_in* sock_addr = reinterpret_cast<sockaddr_in*>(res->ai_addr);
490 in_addr* addr = &sock_addr->sin_addr;
486 491
487 cmd_buffer[2] = addr->s_addr; 492 cmd_buffer[2] = addr->s_addr;
488 cmd_buffer[1] = 0; 493 cmd_buffer[1] = 0;
494 freeaddrinfo(res);
489} 495}
490 496
491static void Close(Service::Interface* self) { 497static void Close(Service::Interface* self) {
diff --git a/src/core/hw/y2r.cpp b/src/core/hw/y2r.cpp
index f80e26ecd..082a4db82 100644
--- a/src/core/hw/y2r.cpp
+++ b/src/core/hw/y2r.cpp
@@ -14,6 +14,7 @@
14#include "common/vector_math.h" 14#include "common/vector_math.h"
15 15
16#include "core/hle/service/y2r_u.h" 16#include "core/hle/service/y2r_u.h"
17#include "core/hw/y2r.h"
17#include "core/memory.h" 18#include "core/memory.h"
18 19
19namespace HW { 20namespace HW {
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp
index ef9584abd..36c3b9947 100644
--- a/src/video_core/command_processor.cpp
+++ b/src/video_core/command_processor.cpp
@@ -221,57 +221,53 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
221 // Initialize data for the current vertex 221 // Initialize data for the current vertex
222 VertexShader::InputVertex input; 222 VertexShader::InputVertex input;
223 223
224 // Load a debugging token to check whether this gets loaded by the running
225 // application or not.
226 static const float24 debug_token = float24::FromRawFloat24(0x00abcdef);
227 input.attr[0].w = debug_token;
228
229 for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) { 224 for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) {
230 // Load the default attribute if we're configured to do so, this data will be overwritten by the loader data if it's set 225 if (vertex_attribute_elements[i] != 0) {
231 if (attribute_config.IsDefaultAttribute(i)) { 226 // Default attribute values set if array elements have < 4 components. This
227 // is *not* carried over from the default attribute settings even if they're
228 // enabled for this attribute.
229 static const float24 zero = float24::FromFloat32(0.0f);
230 static const float24 one = float24::FromFloat32(1.0f);
231 input.attr[i] = Math::Vec4<float24>(zero, zero, zero, one);
232
233 // Load per-vertex data from the loader arrays
234 for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) {
235 u32 source_addr = vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i];
236 const u8* srcdata = Memory::GetPhysicalPointer(source_addr);
237
238 if (g_debug_context && Pica::g_debug_context->recorder) {
239 memory_accesses.AddAccess(source_addr,
240 (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::FLOAT) ? 4
241 : (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? 2 : 1);
242 }
243
244 const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata :
245 (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::UBYTE) ? *(u8*)srcdata :
246 (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? *(s16*)srcdata :
247 *(float*)srcdata;
248
249 input.attr[i][comp] = float24::FromFloat32(srcval);
250 LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08lx + 0x%04lx: %f",
251 comp, i, vertex, index,
252 attribute_config.GetPhysicalBaseAddress(),
253 vertex_attribute_sources[i] - base_address,
254 vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i],
255 input.attr[i][comp].ToFloat32());
256 }
257 } else if (attribute_config.IsDefaultAttribute(i)) {
258 // Load the default attribute if we're configured to do so
232 input.attr[i] = g_state.vs.default_attributes[i]; 259 input.attr[i] = g_state.vs.default_attributes[i];
233 LOG_TRACE(HW_GPU, "Loaded default attribute %x for vertex %x (index %x): (%f, %f, %f, %f)", 260 LOG_TRACE(HW_GPU, "Loaded default attribute %x for vertex %x (index %x): (%f, %f, %f, %f)",
234 i, vertex, index, 261 i, vertex, index,
235 input.attr[i][0].ToFloat32(), input.attr[i][1].ToFloat32(), 262 input.attr[i][0].ToFloat32(), input.attr[i][1].ToFloat32(),
236 input.attr[i][2].ToFloat32(), input.attr[i][3].ToFloat32()); 263 input.attr[i][2].ToFloat32(), input.attr[i][3].ToFloat32());
237 } 264 } else {
238 265 // TODO(yuriks): In this case, no data gets loaded and the vertex remains
239 // Load per-vertex data from the loader arrays 266 // with the last value it had. This isn't currently maintained
240 for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) { 267 // as global state, however, and so won't work in Cita yet.
241 u32 source_addr = vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i];
242 const u8* srcdata = Memory::GetPhysicalPointer(source_addr);
243
244 if (g_debug_context && Pica::g_debug_context->recorder) {
245 memory_accesses.AddAccess(source_addr,
246 (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::FLOAT) ? 4
247 : (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? 2 : 1);
248 }
249
250 const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata :
251 (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::UBYTE) ? *(u8*)srcdata :
252 (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? *(s16*)srcdata :
253 *(float*)srcdata;
254
255 input.attr[i][comp] = float24::FromFloat32(srcval);
256 LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08lx + 0x%04lx: %f",
257 comp, i, vertex, index,
258 attribute_config.GetPhysicalBaseAddress(),
259 vertex_attribute_sources[i] - base_address,
260 vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i],
261 input.attr[i][comp].ToFloat32());
262 } 268 }
263 } 269 }
264 270
265 // HACK: Some games do not initialize the vertex position's w component. This leads
266 // to critical issues since it messes up perspective division. As a
267 // workaround, we force the fourth component to 1.0 if we find this to be the
268 // case.
269 // To do this, we additionally have to assume that the first input attribute
270 // is the vertex position, since there's no information about this other than
271 // the empiric observation that this is usually the case.
272 if (input.attr[0].w == debug_token)
273 input.attr[0].w = float24::FromFloat32(1.0);
274
275 if (g_debug_context) 271 if (g_debug_context)
276 g_debug_context->OnEvent(DebugContext::Event::VertexLoaded, (void*)&input); 272 g_debug_context->OnEvent(DebugContext::Event::VertexLoaded, (void*)&input);
277 273
diff --git a/src/video_core/vertex_shader.cpp b/src/video_core/vertex_shader.cpp
index 960ae5779..5f66f3455 100644
--- a/src/video_core/vertex_shader.cpp
+++ b/src/video_core/vertex_shader.cpp
@@ -609,6 +609,12 @@ OutputVertex RunShader(const InputVertex& input, int num_attributes, const Regs:
609 } 609 }
610 } 610 }
611 611
612 // The hardware takes the absolute and saturates vertex colors like this, *before* doing interpolation
613 for (int i = 0; i < 4; ++i) {
614 ret.color[i] = float24::FromFloat32(
615 std::fmin(std::fabs(ret.color[i].ToFloat32()), 1.0f));
616 }
617
612 LOG_TRACE(Render_Software, "Output vertex: pos (%.2f, %.2f, %.2f, %.2f), col(%.2f, %.2f, %.2f, %.2f), tc0(%.2f, %.2f)", 618 LOG_TRACE(Render_Software, "Output vertex: pos (%.2f, %.2f, %.2f, %.2f), col(%.2f, %.2f, %.2f, %.2f), tc0(%.2f, %.2f)",
613 ret.pos.x.ToFloat32(), ret.pos.y.ToFloat32(), ret.pos.z.ToFloat32(), ret.pos.w.ToFloat32(), 619 ret.pos.x.ToFloat32(), ret.pos.y.ToFloat32(), ret.pos.z.ToFloat32(), ret.pos.w.ToFloat32(),
614 ret.color.x.ToFloat32(), ret.color.y.ToFloat32(), ret.color.z.ToFloat32(), ret.color.w.ToFloat32(), 620 ret.color.x.ToFloat32(), ret.color.y.ToFloat32(), ret.color.z.ToFloat32(), ret.color.w.ToFloat32(),