diff --git a/src/common/console_listener.cpp b/src/common/console_listener.cpp
index b5f32d1bd..db48abbf6 100644
--- a/src/common/console_listener.cpp
+++ b/src/common/console_listener.cpp
@@ -259,14 +259,17 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text)
switch (Level)
{
+ case OS_LEVEL: // light yellow
+ Color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
+ break;
case NOTICE_LEVEL: // light green
Color = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
break;
case ERROR_LEVEL: // light red
Color = FOREGROUND_RED | FOREGROUND_INTENSITY;
break;
- case WARNING_LEVEL: // light yellow
- Color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
+ case WARNING_LEVEL: // light purple
+ Color = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY;
break;
case INFO_LEVEL: // cyan
Color = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY;
@@ -278,15 +281,8 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text)
Color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
break;
}
- if (strlen(Text) > 10)
- {
- // First 10 chars white
- SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
- WriteConsole(hConsole, Text, 10, &cCharsWritten, NULL);
- Text += 10;
- }
SetConsoleTextAttribute(hConsole, Color);
- WriteConsole(hConsole, Text, (DWORD)strlen(Text), &cCharsWritten, NULL);
+ printf(Text);
#else
char ColorAttr[16] = "";
char ResetAttr[16] = "";
diff --git a/src/common/log.h b/src/common/log.h
index 8b39b03a1..2543b51a8 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -7,11 +7,14 @@
#define LOGGING
-#define NOTICE_LEVEL 1 // VERY important information that is NOT errors. Like startup and OSReports.
-#define ERROR_LEVEL 2 // Critical errors
-#define WARNING_LEVEL 3 // Something is suspicious.
-#define INFO_LEVEL 4 // General information.
-#define DEBUG_LEVEL 5 // Detailed debugging - might make things slow.
+enum {
+ OS_LEVEL, // Printed by the emulated operating system
+ NOTICE_LEVEL, // VERY important information that is NOT errors. Like startup and OSReports.
+ ERROR_LEVEL, // Critical errors
+ WARNING_LEVEL, // Something is suspicious.
+ INFO_LEVEL, // General information.
+ DEBUG_LEVEL, // Detailed debugging - might make things slow.
+};
namespace LogTypes
{
@@ -70,6 +73,7 @@ enum LOG_TYPE {
// FIXME: should this be removed?
enum LOG_LEVELS {
+ LOS = OS_LEVEL,
LNOTICE = NOTICE_LEVEL,
LERROR = ERROR_LEVEL,
LWARNING = WARNING_LEVEL,
@@ -82,8 +86,8 @@ enum LOG_LEVELS {
} // namespace
-void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type,
- const char *file, int line, const char *fmt, ...)
+void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int line,
+ const char* function, const char* fmt, ...)
#ifdef __GNUC__
__attribute__((format(printf, 5, 6)))
#endif
@@ -97,16 +101,19 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type,
#endif // loglevel
#endif // logging
-#ifdef GEKKO
-#define GENERIC_LOG(t, v, ...)
-#else
+#ifdef _WIN32
+#ifndef __func__
+#define __func__ __FUNCTION__
+#endif
+#endif
+
// Let the compiler optimize this out
#define GENERIC_LOG(t, v, ...) { \
if (v <= MAX_LOGLEVEL) \
- GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \
+ GenericLog(v, t, __FILE__, __LINE__, __func__, __VA_ARGS__); \
}
-#endif
+#define OS_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LOS, __VA_ARGS__) } while (0)
#define ERROR_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } while (0)
#define WARN_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) } while (0)
#define NOTICE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } while (0)
diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp
index 146472888..d026fca56 100644
--- a/src/common/log_manager.cpp
+++ b/src/common/log_manager.cpp
@@ -10,14 +10,16 @@
#include "common/thread.h"
#include "common/file_util.h"
-void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
- const char *file, int line, const char* fmt, ...)
+void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line,
+ const char* function, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
- if (LogManager::GetInstance())
+
+ if (LogManager::GetInstance()) {
LogManager::GetInstance()->Log(level, type,
- file, line, fmt, args);
+ file, line, function, fmt, args);
+ }
va_end(args);
}
@@ -88,6 +90,8 @@ LogManager::LogManager()
m_Log[i]->AddListener(m_debuggerLog);
#endif
}
+
+ m_consoleLog->Open();
}
LogManager::~LogManager()
@@ -107,8 +111,8 @@ LogManager::~LogManager()
delete m_debuggerLog;
}
-void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
- const char *file, int line, const char *format, va_list args)
+void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file,
+ int line, const char* function, const char *fmt, va_list args)
{
char temp[MAX_MSGLEN];
char msg[MAX_MSGLEN * 2];
@@ -117,17 +121,15 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners())
return;
- CharArrayFromFormatV(temp, MAX_MSGLEN, format, args);
+ CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args);
- static const char level_to_char[7] = "-NEWID";
- sprintf(msg, "%s %s:%u %c[%s]: %s\n",
- Common::Timer::GetTimeFormatted().c_str(),
- file, line, level_to_char[(int)level],
- log->GetShortName(), temp);
+ static const char level_to_char[7] = "ONEWID";
+ sprintf(msg, "%s %s:%u %c[%s] %s: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line,
+ level_to_char[(int)level], log->GetShortName(), function, temp);
+
#ifdef ANDROID
Host_SysMessage(msg);
#endif
- printf(msg); // TODO(ShizZy): RemoveMe when I no longer need this
log->Trigger(level, msg);
}
diff --git a/src/common/log_manager.h b/src/common/log_manager.h
index 580860b4d..3e238dfa7 100644
--- a/src/common/log_manager.h
+++ b/src/common/log_manager.h
@@ -99,8 +99,8 @@ public:
static u32 GetMaxLevel() { return MAX_LOGLEVEL; }
- void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
- const char *file, int line, const char *fmt, va_list args);
+ void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line,
+ const char* function, const char *fmt, va_list args);
void SetLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level)
{
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 4086b415b..5d5cfcf1f 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -34,12 +34,14 @@ set(SRCS core.cpp
hle/config_mem.cpp
hle/coprocessor.cpp
hle/svc.cpp
+ hle/kernel/event.cpp
hle/kernel/kernel.cpp
hle/kernel/mutex.cpp
hle/kernel/thread.cpp
hle/service/apt.cpp
hle/service/gsp.cpp
hle/service/hid.cpp
+ hle/service/ndm.cpp
hle/service/service.cpp
hle/service/srv.cpp
hw/hw.cpp
diff --git a/src/core/arm/interpreter/armemu.cpp b/src/core/arm/interpreter/armemu.cpp
index e5dc7bd44..1e22cda9d 100644
--- a/src/core/arm/interpreter/armemu.cpp
+++ b/src/core/arm/interpreter/armemu.cpp
@@ -4533,23 +4533,7 @@ ARMul_Emulate26 (ARMul_State * state)
case 0xfd:
case 0xfe:
case 0xff:
- if (instr == ARMul_ABORTWORD
- && state->AbortAddr == pc) {
- /* A prefetch abort. */
- XScale_set_fsr_far (state,
- ARMul_CP15_R5_MMU_EXCPT,
- pc);
- ARMul_Abort (state,
- ARMul_PrefetchAbortV);
- break;
- }
- //sky_pref_t* pref = get_skyeye_pref();
- //if(pref->user_mode_sim){
- // ARMul_OSHandleSWI (state, BITS (0, 23));
- // break;
- //}
HLE::CallSVC(instr);
- ARMul_Abort (state, ARMul_SWIV);
break;
}
}
diff --git a/src/core/core.cpp b/src/core/core.cpp
index f88bcd704..070f92ed5 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -9,6 +9,7 @@
#include "core/core.h"
#include "core/mem_map.h"
#include "core/hw/hw.h"
+#include "core/hw/lcd.h"
#include "core/arm/disassembler/arm_disasm.h"
#include "core/arm/interpreter/arm_interpreter.h"
@@ -23,7 +24,7 @@ ARM_Interface* g_sys_core = NULL; ///< ARM11 system (OS) core
/// Run the core CPU loop
void RunLoop() {
for (;;){
- g_app_core->Run(100);
+ g_app_core->Run(LCD::kFrameTicks / 2);
HW::Update();
Kernel::Reschedule();
}
@@ -31,9 +32,17 @@ void RunLoop() {
/// Step the CPU one instruction
void SingleStep() {
+ static int ticks = 0;
+
g_app_core->Step();
- HW::Update();
- Kernel::Reschedule();
+
+ if (ticks >= LCD::kFrameTicks / 2) {
+ HW::Update();
+ Kernel::Reschedule();
+ ticks = 0;
+ } else {
+ ticks++;
+ }
}
/// Halt the core
diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj
index f271d336e..6fec75d79 100644
--- a/src/core/core.vcxproj
+++ b/src/core/core.vcxproj
@@ -168,12 +168,14 @@
+
+
@@ -217,12 +219,14 @@
+
+
diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters
index b6c1d5b93..8e5966d73 100644
--- a/src/core/core.vcxproj.filters
+++ b/src/core/core.vcxproj.filters
@@ -165,6 +165,12 @@
arm\interpreter
+
+ hle\kernel
+
+
+ hle\service
+
@@ -295,6 +301,12 @@
hle\kernel
+
+ hle\kernel
+
+
+ hle\service
+
diff --git a/src/core/hle/config_mem.cpp b/src/core/hle/config_mem.cpp
index 48aa878cc..8c898b265 100644
--- a/src/core/hle/config_mem.cpp
+++ b/src/core/hle/config_mem.cpp
@@ -55,7 +55,7 @@ inline void Read(T &var, const u32 addr) {
break;
default:
- ERROR_LOG(HLE, "unknown ConfigMem::Read%d @ 0x%08X", sizeof(var) * 8, addr);
+ ERROR_LOG(HLE, "unknown addr=0x%08X", addr);
}
}
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h
index 801865d49..cfe5da74b 100644
--- a/src/core/hle/function_wrappers.h
+++ b/src/core/hle/function_wrappers.h
@@ -627,6 +627,10 @@ template void WrapV_C() {
func(Memory::GetCharPointer(PARAM(0)));
}
+template void WrapV_S64() {
+ func(((s64)PARAM(1) << 32) | PARAM(0));
+}
+
template void WrapV_CI() {
func(Memory::GetCharPointer(PARAM(0)), PARAM(1));
}
@@ -735,11 +739,17 @@ template void WrapI_VUUUUU(){
}
template void WrapI_US64() {
- int retval = func(PARAM(0), PARAM64(1));
+ int retval = func(PARAM(0), (((u64)PARAM(3) << 32) | PARAM(2)));
RETURN(retval);
}
template void WrapI_VVUUS64() {
- int retval = func(Memory::GetPointer(PARAM(0)), Memory::GetPointer(PARAM(1)), PARAM(2), PARAM(3), PARAM(4));
+ int retval = func(Memory::GetPointer(PARAM(5)), Memory::GetPointer(PARAM(1)), PARAM(2), PARAM(3), (((u64)PARAM(4) << 32) | PARAM(0)));
+ RETURN(retval);
+}
+
+// TODO(bunne): Is this correct? Probably not
+template void WrapI_UUUUS64() {
+ int retval = func(PARAM(5), PARAM(1), PARAM(2), PARAM(3), (((u64)PARAM(4) << 32) | PARAM(0)));
RETURN(retval);
}
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp
index 080c36abf..f703da44e 100644
--- a/src/core/hle/hle.cpp
+++ b/src/core/hle/hle.cpp
@@ -18,7 +18,7 @@ static std::vector g_module_db;
const FunctionDef* GetSVCInfo(u32 opcode) {
u32 func_num = opcode & 0xFFFFFF; // 8 bits
if (func_num > 0xFF) {
- ERROR_LOG(HLE,"Unknown SVC: 0x%02X", func_num);
+ ERROR_LOG(HLE,"unknown svc=0x%02X", func_num);
return NULL;
}
return &g_module_db[0].func_table[func_num];
@@ -33,7 +33,7 @@ void CallSVC(u32 opcode) {
if (info->func) {
info->func();
} else {
- ERROR_LOG(HLE, "Unimplemented SVC function %s(..)", info->name.c_str());
+ ERROR_LOG(HLE, "unimplemented SVC function %s(..)", info->name.c_str());
}
}
@@ -43,7 +43,7 @@ void EatCycles(u32 cycles) {
void ReSchedule(const char *reason) {
#ifdef _DEBUG
- _dbg_assert_msg_(HLE, reason != 0 && strlen(reason) < 256, "ReSchedule: Invalid or too long reason.");
+ _dbg_assert_msg_(HLE, reason != 0 && strlen(reason) < 256, "Reschedule: Invalid or too long reason.");
#endif
// TODO: ImplementMe
}
diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h
index c075147c3..c31e273b5 100644
--- a/src/core/hle/hle.h
+++ b/src/core/hle/hle.h
@@ -10,7 +10,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
#define PARAM(n) Core::g_app_core->GetReg(n)
-#define PARAM64(n) (Core::g_app_core->GetReg(n) | ((u64)Core::g_app_core->GetReg(n + 1) << 32))
#define RETURN(n) Core::g_app_core->SetReg(0, n)
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp
new file mode 100644
index 000000000..e84d0b49e
--- /dev/null
+++ b/src/core/hle/kernel/event.cpp
@@ -0,0 +1,126 @@
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#include