Add a way to avoid IOP reset
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
diff --git a/docs/README-ps2.md b/docs/README-ps2.md
index c61647b..3a0724f 100644
--- a/docs/README-ps2.md
+++ b/docs/README-ps2.md
@@ -16,6 +16,22 @@ cmake --build build
cmake --install build
```
+## Notes
+If you trying to debug a SDL app through [ps2client](https://github.com/ps2dev/ps2client) you need to avoid the IOP reset, otherwise you will lose the conection with your computer.
+So to avoid the reset of the IOP CPU, you need to call to the macro `SDL_PS2_SKIP_IOP_RESET();`.
+It could be something similar as:
+```c
+.....
+
+SDL_PS2_SKIP_IOP_RESET();
+
+int main(int argc, char *argv[])
+{
+.....
+```
+For a release binary is recommendable to reset the IOP always.
+
+Remember to do a clean compilation everytime you enable or disable the `SDL_PS2_SKIP_IOP_RESET` otherwise the change won't be reflected.
## Getting PS2 Dev
[Installing PS2 Dev](https://github.com/ps2dev/ps2dev)
@@ -28,7 +44,4 @@ cmake --install build
## To Do
- PS2 Screen Keyboard
- Dialogs
-- Audio
-- Video
-- Controllers
- Others
\ No newline at end of file
diff --git a/include/SDL_main.h b/include/SDL_main.h
index 1af74e9..8b26708 100644
--- a/include/SDL_main.h
+++ b/include/SDL_main.h
@@ -104,6 +104,10 @@
#elif defined(__PS2__)
#define SDL_MAIN_AVAILABLE
+#define SDL_PS2_SKIP_IOP_RESET() \
+ void reset_IOP(); \
+ void reset_IOP() {}
+
#endif
#endif /* SDL_MAIN_HANDLED */
diff --git a/src/main/ps2/SDL_ps2_main.c b/src/main/ps2/SDL_ps2_main.c
index 0d97ed3..b8631f1 100644
--- a/src/main/ps2/SDL_ps2_main.c
+++ b/src/main/ps2/SDL_ps2_main.c
@@ -19,23 +19,25 @@
#include <sbv_patches.h>
#include <ps2_fileXio_driver.h>
#include <ps2_memcard_driver.h>
+#include <ps2_usb_driver.h>
#ifdef main
#undef main
#endif
-static void prepare_IOP()
-{
+__attribute__((weak))
+void reset_IOP() {
SifInitRpc(0);
- // #if !defined(DEBUG) || defined(BUILD_FOR_PCSX2)
- /* Comment this line if you don't wanna debug the output */
while(!SifIopReset(NULL, 0)){};
- // #endif
-
while(!SifIopSync()){};
- SifInitRpc(0);
- sbv_patch_enable_lmb();
- sbv_patch_disable_prefix_check();
+}
+
+static void prepare_IOP()
+{
+ reset_IOP();
+ SifInitRpc(0);
+ sbv_patch_enable_lmb();
+ sbv_patch_disable_prefix_check();
}
static void init_drivers() {
@@ -52,18 +54,17 @@ static void deinit_drivers() {
static void waitUntilDeviceIsReady(char *path)
{
- struct stat buffer;
- int ret = -1;
- int retries = 50;
-
- while(ret != 0 && retries > 0)
- {
- ret = stat(path, &buffer);
- /* Wait untill the device is ready */
- nopdelay();
-
- retries--;
- }
+ struct stat buffer;
+ int ret = -1;
+ int retries = 50;
+
+ while(ret != 0 && retries > 0) {
+ ret = stat(path, &buffer);
+ /* Wait untill the device is ready */
+ nopdelay();
+
+ retries--;
+ }
}
int main(int argc, char *argv[])
@@ -84,6 +85,6 @@ int main(int argc, char *argv[])
return res;
}
-#endif /* _EE */
+#endif /* _PS2 */
/* vi: set ts=4 sw=4 expandtab: */