From aea7b692e43f9ce94dbb631c95482cfac8a98edc Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Mon, 7 Sep 2020 20:00:02 -0400 Subject: [PATCH] Got rid of a lot of windows ifdefs --- game/kernel/kboot.cpp | 12 ++++-------- game/kernel/kdsnetm.cpp | 3 --- game/kernel/kdsnetm.h | 7 ------- game/kernel/klisten.cpp | 10 +--------- game/kernel/kmachine.cpp | 6 ------ game/kernel/ksocket.cpp | 3 --- game/runtime.cpp | 15 +++------------ game/sce/deci2.cpp | 33 --------------------------------- 8 files changed, 8 insertions(+), 81 deletions(-) diff --git a/game/kernel/kboot.cpp b/game/kernel/kboot.cpp index 9f6f6de06d..1cd2cc1a13 100644 --- a/game/kernel/kboot.cpp +++ b/game/kernel/kboot.cpp @@ -5,6 +5,9 @@ */ #include +#include +#include + #include "common/common_types.h" #include "game/sce/libscf.h" #include "kboot.h" @@ -134,21 +137,14 @@ void KernelCheckAndDispatch() { // dispatch the kernel //(**kernel_dispatcher)(); call_goal(Ptr(kernel_dispatcher->value), 0, 0, 0, s7.offset, g_ee_main_mem); - // TODO-WINDOWS -#ifdef __linux__ ClearPending(); -#endif // if the listener function changed, it means the kernel ran it, so we should notify compiler. if (MasterDebug && ListenerFunction->value != old_listener) { SendAck(); } -#ifdef _WIN32 - Sleep(1000); // todo - remove this -#elif __linux__ - usleep(1000); -#endif + std::this_thread::sleep_for(std::chrono::microseconds(1000)); } } diff --git a/game/kernel/kdsnetm.cpp b/game/kernel/kdsnetm.cpp index 2d06a93160..da07a7a8bb 100644 --- a/game/kernel/kdsnetm.cpp +++ b/game/kernel/kdsnetm.cpp @@ -27,8 +27,6 @@ void kdsnetm_init_globals() { protoBlock.reset(); } -// TODO-WINDOWS -#ifdef __linux__ /*! * Register GOAL DECI2 Protocol Driver with DECI2 service * DONE, EXACT @@ -222,4 +220,3 @@ void GoalProtoStatus() { Msg(6, "gproto: got %d %d\n", protoBlock.most_recent_event, protoBlock.most_recent_param); Msg(6, "gproto: %d %d\n", protoBlock.last_receive_size, protoBlock.send_remaining); } -#endif \ No newline at end of file diff --git a/game/kernel/kdsnetm.h b/game/kernel/kdsnetm.h index 51125e0c1f..bdbef66096 100644 --- a/game/kernel/kdsnetm.h +++ b/game/kernel/kdsnetm.h @@ -51,8 +51,6 @@ extern GoalProtoBlock protoBlock; */ void kdsnetm_init_globals(); -// TODO-WINDOWS -#ifdef __linux__ /*! * Register GOAL DECI2 Protocol Driver with DECI2 service * DONE, EXACT @@ -65,8 +63,6 @@ void InitGoalProto(); */ void ShutdownGoalProto(); -#endif - /*! * Handle a DECI2 Protocol Event for the GOAL Proto. * Called by the DECI2 Protocol driver @@ -74,8 +70,6 @@ void ShutdownGoalProto(); */ void GoalProtoHandler(int event, int param, void* data); -// TODO-WINDOWS -#ifdef __linux__ /*! * Low level DECI2 send * Will block until send is complete. @@ -83,7 +77,6 @@ void GoalProtoHandler(int event, int param, void* data); * removed */ s32 SendFromBufferD(s32 p1, u64 p2, char* data, s32 size); -#endif /*! * Print GOAL Protocol status diff --git a/game/kernel/klisten.cpp b/game/kernel/klisten.cpp index 7f990bf27e..4f1d733bbe 100644 --- a/game/kernel/klisten.cpp +++ b/game/kernel/klisten.cpp @@ -71,10 +71,7 @@ void ClearPending() { Ptr msg = OutputBufArea.cast() + sizeof(GoalMessageHeader); auto size = strlen(msg.c()); // note - if size is ever greater than 2^16 this will cause an issue. - // TODO-WINDOWS -#ifdef __linux__ SendFromBuffer(msg.c(), size); -#endif clear_output(); } @@ -87,10 +84,7 @@ void ClearPending() { if (send_size > 64000) { send_size = 64000; } -// TODO-WINDOWS -#ifdef __linux__ SendFromBufferD(2, 0, msg, send_size); -#endif size -= send_size; msg += send_size; } @@ -109,11 +103,9 @@ void ClearPending() { */ void SendAck() { if (MasterDebug) { -#ifdef __linux__ SendFromBufferD(u16(ListenerMessageKind::MSG_ACK), protoBlock.msg_id, AckBufArea + sizeof(GoalMessageHeader), strlen(AckBufArea + sizeof(GoalMessageHeader))); -#endif } } @@ -161,4 +153,4 @@ void ProcessListenerMessage(Ptr msg) { break; } SendAck(); -} \ No newline at end of file +} diff --git a/game/kernel/kmachine.cpp b/game/kernel/kmachine.cpp index 4752b90b93..168619844a 100644 --- a/game/kernel/kmachine.cpp +++ b/game/kernel/kmachine.cpp @@ -329,10 +329,7 @@ int InitMachine() { // } if (MasterDebug) { // connect to GOAL compiler -// TODO-WINDOWS -#ifdef __linux__ InitGoalProto(); -#endif } printf("InitSound\n"); @@ -362,10 +359,7 @@ int ShutdownMachine() { StopIOP(); CloseListener(); ShutdownSound(); -// TODO-WINDOWS -#ifdef __linux__ ShutdownGoalProto(); -#endif Msg(6, "kernel: machine shutdown"); return 0; } diff --git a/game/kernel/ksocket.cpp b/game/kernel/ksocket.cpp index b66fc1dd7e..4eb0194017 100644 --- a/game/kernel/ksocket.cpp +++ b/game/kernel/ksocket.cpp @@ -52,8 +52,6 @@ u32 ReceiveToBuffer(char* buff) { return msg_size; } -// TODO-WINDOWS -#ifdef __linux__ /*! * Do a DECI2 send and block until it is complete. * The message type is OUTPUT @@ -62,7 +60,6 @@ u32 ReceiveToBuffer(char* buff) { s32 SendFromBuffer(char* buff, s32 size) { return SendFromBufferD(u16(ListenerMessageKind::MSG_OUTPUT), 0, buff, size); } -#endif /*! * Just prepare the Ack buffer, doesn't actually connect. diff --git a/game/runtime.cpp b/game/runtime.cpp index 379898a9a1..a35fd9f717 100644 --- a/game/runtime.cpp +++ b/game/runtime.cpp @@ -12,7 +12,9 @@ #include #endif +#include #include +#include #include "runtime.h" #include "system/SystemThread.h" @@ -45,11 +47,6 @@ u8* g_ee_main_mem = nullptr; -/*! - * TODO-WINDOWS - * runtime.cpp - Deci2Listener has been disabled for now, pending rewriting for Windows. - */ - namespace { /*! @@ -57,8 +54,6 @@ namespace { */ void deci2_runner(SystemThreadInterface& iface) { -// TODO-WINDOWS -#ifdef __linux__ // callback function so the server knows when to give up and shutdown std::function shutdown_callback = [&]() { return iface.get_want_exit(); }; @@ -89,10 +84,9 @@ void deci2_runner(SystemThreadInterface& iface) { server.run(); } else { // no connection yet. Do a sleep so we don't spam checking the listener. - usleep(50000); + std::this_thread::sleep_for(std::chrono::microseconds(50000)); } } -#endif } // EE System @@ -236,10 +230,7 @@ void exec_runtime(int argc, char** argv) { // step 1: sce library prep iop::LIBRARY_INIT(); ee::LIBRARY_INIT_sceCd(); -// TODO-WINDOWS -#ifdef __linux__ ee::LIBRARY_INIT_sceDeci2(); -#endif ee::LIBRARY_INIT_sceSif(); // step 2: system prep diff --git a/game/sce/deci2.cpp b/game/sce/deci2.cpp index 6cb5a84058..99b12cbcb3 100644 --- a/game/sce/deci2.cpp +++ b/game/sce/deci2.cpp @@ -12,14 +12,11 @@ namespace ee { namespace { -// TODO-WINDOWS -#ifdef __linux__ constexpr int MAX_DECI2_PROTOCOLS = 4; Deci2Driver protocols[MAX_DECI2_PROTOCOLS]; // info for each deci2 protocol registered int protocol_count; // number of registered protocols Deci2Driver* sending_driver; // currently sending protocol driver ::Deci2Server* server; // the server to send data to -#endif } // namespace @@ -27,8 +24,6 @@ Deci2Driver* sending_driver; // currently sending protocol drive * Initialize the library. */ void LIBRARY_INIT_sceDeci2() { -// TODO-WINDOWS -#ifdef __linux__ // reset protocols for (auto& p : protocols) { p = Deci2Driver(); @@ -36,15 +31,12 @@ void LIBRARY_INIT_sceDeci2() { protocol_count = 0; server = nullptr; sending_driver = nullptr; -#endif } /*! * Run any pending requested sends. */ void LIBRARY_sceDeci2_run_sends() { -// TODO-WINDOWS -#ifdef __linux__ for (auto& prot : protocols) { if (prot.active && prot.pending_send == 'H') { sending_driver = &prot; @@ -54,17 +46,13 @@ void LIBRARY_sceDeci2_run_sends() { (prot.handler)(DECI2_WRITEDONE, 0, prot.opt); } } -#endif } /*! * Register a Deci2Server with this library. */ void LIBRARY_sceDeci2_register(::Deci2Server* s) { -// TODO-WINDOWS -#ifdef __linux__ server = s; -#endif } /*! @@ -73,8 +61,6 @@ void LIBRARY_sceDeci2_register(::Deci2Server* s) { * I don't know why it's like this. */ s32 sceDeci2Open(u16 protocol, void* opt, void (*handler)(s32 event, s32 param, void* opt)) { -// TODO-WINDOWS -#ifdef __linux__ server->lock(); Deci2Driver drv; drv.protocol = protocol; @@ -93,20 +79,14 @@ s32 sceDeci2Open(u16 protocol, void* opt, void (*handler)(s32 event, s32 param, } return drv.id; -#elif _WIN32 - return 0; -#endif } /*! * Deactivate a DECI2 protocol by socket descriptor. */ s32 sceDeci2Close(s32 s) { -// TODO-WINDOWS -#ifdef __linux__ assert(s - 1 < protocol_count); protocols[s - 1].active = false; -#endif return 1; } @@ -114,12 +94,9 @@ s32 sceDeci2Close(s32 s) { * Start a send. */ s32 sceDeci2ReqSend(s32 s, char dest) { -// TODO-WINDOWS -#ifdef __linux__ assert(s - 1 < protocol_count); auto& proto = protocols[s - 1]; proto.pending_send = dest; -#endif return 0; } @@ -128,8 +105,6 @@ s32 sceDeci2ReqSend(s32 s, char dest) { * Returns after data is copied. */ s32 sceDeci2ExRecv(s32 s, void* buf, u16 len) { -// TODO-WINDOWS -#ifdef __linux__ assert(s - 1 < protocol_count); protocols[s - 1].recv_size = len; auto avail = protocols[s - 1].available_to_receive; @@ -140,17 +115,12 @@ s32 sceDeci2ExRecv(s32 s, void* buf, u16 len) { printf("[DECI2] Error: ExRecv %d, only %d available!\n", len, avail); return -1; } -#elif _WIN32 - return 0; -#endif } /*! * Do a send. */ s32 sceDeci2ExSend(s32 s, void* buf, u16 len) { -// TODO-WINDOWS -#ifdef __linux__ assert(s - 1 < protocol_count); if (!sending_driver) { printf("sceDeci2ExSend called at illegal time!\n"); @@ -162,8 +132,5 @@ s32 sceDeci2ExSend(s32 s, void* buf, u16 len) { server->send_data(buf, len); return len; -#elif _WIN32 - return 0; -#endif } } // namespace ee