diff --git a/src/common/log.h b/src/common/log.h index 8b39b03a1..4d35e2c8f 100644 --- a/src/common/log.h +++ b/src/common/log.h @@ -64,6 +64,7 @@ enum LOG_TYPE { HW, TIME, NETPLAY, + USER_INPUT, NUMBER_OF_LOGS // Must be last }; diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp index 146472888..17ca9b08b 100644 --- a/src/common/log_manager.cpp +++ b/src/common/log_manager.cpp @@ -73,6 +73,7 @@ LogManager::LogManager() m_Log[LogTypes::ACTIONREPLAY] = new LogContainer("ActionReplay", "ActionReplay"); m_Log[LogTypes::MEMCARD_MANAGER] = new LogContainer("MemCard Manager", "MemCard Manager"); m_Log[LogTypes::NETPLAY] = new LogContainer("NETPLAY", "Netplay"); + m_Log[LogTypes::USER_INPUT] = new LogContainer("USER_INPUT", "User Input"); m_fileLog = new FileLogListener(File::GetUserPath(F_MAINLOG_IDX).c_str()); m_consoleLog = new ConsoleListener(); diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj index f271d336e..2f964bc9e 100644 --- a/src/core/core.vcxproj +++ b/src/core/core.vcxproj @@ -180,6 +180,7 @@ + @@ -229,6 +230,7 @@ + diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters index b6c1d5b93..f56264b50 100644 --- a/src/core/core.vcxproj.filters +++ b/src/core/core.vcxproj.filters @@ -165,6 +165,9 @@ arm\interpreter + + hw + @@ -295,6 +298,9 @@ hle\kernel + + hw + diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h index 801865d49..fa690ef92 100644 --- a/src/core/hle/function_wrappers.h +++ b/src/core/hle/function_wrappers.h @@ -743,3 +743,10 @@ template void WrapI_VVUUS64() { int retval = func(Memory::GetPointer(PARAM(0)), Memory::GetPointer(PARAM(1)), PARAM(2), PARAM(3), PARAM(4)); RETURN(retval); } + + +//64 bit wrappers + +template void WrapU64_V() { + RETURN(func()); +} \ No newline at end of file diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 90c05cb74..094e003c4 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -226,6 +226,10 @@ Result CreateEvent(void* _event, u32 reset_type) { return 0; } +u64 GetSystemTick(void) { + return Core::g_sys_core->GetTicks(); +} + const HLE::FunctionDef SVC_Table[] = { {0x00, NULL, "Unknown"}, {0x01, WrapI_VUUUUU, "ControlMemory"}, @@ -267,7 +271,7 @@ const HLE::FunctionDef SVC_Table[] = { {0x25, WrapI_VVUUS64, "WaitSynchronizationN"}, {0x26, NULL, "SignalAndWait"}, {0x27, NULL, "DuplicateHandle"}, - {0x28, NULL, "GetSystemTick"}, + { 0x28, WrapU64_V, "GetSystemTick" }, {0x29, NULL, "GetHandleInfo"}, {0x2A, NULL, "GetSystemInfo"}, {0x2B, NULL, "GetProcessInfo"}, diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp index 85669ae7f..9b4fcf0cb 100644 --- a/src/core/hw/hw.cpp +++ b/src/core/hw/hw.cpp @@ -8,6 +8,8 @@ #include "core/hw/hw.h" #include "core/hw/lcd.h" #include "core/hw/ndma.h" +#include "core/hw/user_input.h" + namespace HW { @@ -89,12 +91,14 @@ template void Write(u32 addr, const u8 data); void Update() { LCD::Update(); NDMA::Update(); + USER_INPUT::Update(); } /// Initialize hardware void Init() { LCD::Init(); NDMA::Init(); + USER_INPUT::Init(); NOTICE_LOG(HW, "initialized OK"); } diff --git a/src/core/hw/user_input.cpp b/src/core/hw/user_input.cpp new file mode 100644 index 000000000..eee52d096 --- /dev/null +++ b/src/core/hw/user_input.cpp @@ -0,0 +1,46 @@ +#include "user_input.h" + + +namespace USER_INPUT { + + template + inline void Read(T &var, const u32 addr) { + ERROR_LOG(USER_INPUT, "unknown Read%d @ 0x%08X", sizeof(var) * 8, addr); + } + + template + inline void Write(u32 addr, const T data) { + ERROR_LOG(NDMA, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr); + } + + // Explicitly instantiate template functions because we aren't defining this in the header: + + template void Read(u64 &var, const u32 addr); + template void Read(u32 &var, const u32 addr); + template void Read(u16 &var, const u32 addr); + template void Read(u8 &var, const u32 addr); + + template void Write(u32 addr, const u64 data); + template void Write(u32 addr, const u32 data); + template void Write(u32 addr, const u16 data); + template void Write(u32 addr, const u8 data); + + void setButtonReg(u32 buttonData) { + Write(PADDR_BUTTONS, buttonData); + } + + /// Update hardware + void Update() { + } + + /// Initialize hardware + void Init() { + NOTICE_LOG(USER_INPUT, "initialized OK"); + } + + /// Shutdown hardware + void Shutdown() { + NOTICE_LOG(USER_INPUT, "shutdown OK"); + } + +} \ No newline at end of file diff --git a/src/core/hw/user_input.h b/src/core/hw/user_input.h new file mode 100644 index 000000000..f89f9dc85 --- /dev/null +++ b/src/core/hw/user_input.h @@ -0,0 +1,52 @@ +#pragma once + +#include "common/common_types.h" + + +namespace USER_INPUT { + struct Registers { + u32 buttons; + //u32 pad1; etc... + }; + + extern Registers g_regs; + + enum { + + PAD_A = (1 << 0), + PAD_B = (1 << 1), + PAD_SELECT = (1 << 2), + PAD_START = (1 << 3), + PAD_RIGHT = (1 << 4), + PAD_LEFT = (1 << 5), + PAD_UP = (1 << 6), + PAD_DOWN = (1 << 7), + PAD_R = (1 << 8), + PAD_L = (1 << 9), + PAD_X = (1 << 10), + PAD_Y = (1 << 11), + + PADDR_BUTTONS = 0x1000001c, //TODO: it works using the shared mem mapping with all homebrew tested, however the wiki states 0x10146000 as the paddr + }; + + + enum { + REG_BUTTONS = 0x1EC46000 //does not work due to confusion between shared mem and hardware IO + }; + + template + inline void Read(T &var, const u32 addr); + + template + inline void Write(u32 addr, const T data); + + /// Update hardware + void Update(); + + /// Initialize hardware + void Init(); + + /// Shutdown hardware + void Shutdown(); +} +