PS3 MAPI Dynarec Lib

I have Cobra 8.3 in my PS3 an i think it will not very easy get Manba ....
For who has new Mamba with changes made by @aldostools , there is pico core for RetraoArchCE:
https://github.com/crystalct/crystalct.github.io/raw/main/tmp/picodrive_libretro_ps3.SELF
let me know if it works....
Mamba is easy to install and make it start from boot.

1. Install boot_mamba.pkg
2. Disable Cobra
3. Reboot

Enable Cobra again to disable Mamba

It should work with CFW 4.84 and later.

If you have issues with Mamba, go to recovery menu and exit. The boot files installed by boot_mamba.pkg will be deleted.
 
Mamba is easy to install and make it start from boot.

1. Install boot_mamba.pkg
2. Disable Cobra
3. Reboot

Enable Cobra again to disable Mamba

It should work with CFW 4.84 and later.

If you have issues with Mamba, go to recovery menu and exit. The boot files installed by boot_mamba.pkg will be deleted.
It doesn't work for me.... (i restarted my ps with recovery menu). I have latest CFW 4.89 Evilnat Cobra [CEX]
 
It doesn't work for me.... (i restarted my ps with recovery menu). I have latest CFW 4.89 Evilnat Cobra [CEX]

if you restarted with recover menu, the configuration made by the pkg is deleted.

You can try to install mamba payload manually:
1- Copy mamba_489C.bin to root of /dev_hdd0
2- Open notepad and add this line: /dev_hdd0/mamba_489C.bin
3- Save the file as boot_plugins_kernel_nocobra.txt and upload it to root of /dev_hdd0
4- Disable Cobra payload and reboot

The system should boot with mamba instead of Cobra.

Another alternative is update the payload in IRISMAN and launch it to load Mamba if Cobra is disabled
 
@Crystal Some changes were needed to support Sony sdk due to the abi using 32bit pointers. The modifications to support it can be found in my latest commit

https://github.com/OsirizX/picodrive/commit/95e134eff9232a726e24a4c6652615135606403a
Due to nasty discussions with other developers, on Retroarch there is no longer refers to __CELLOS_LV2__
Now code for PS3 is under __PS3__ (old SDK) and/or __PSL1GHT__ (psl1ght, of course).
I think you refer __PS3__ thinking to psl1ght..... right?
 
Yes... look at https://github.com/libretro/RetroArch/blob/master/libretro-common/include/defines/ps3_defines.h
When you include ps3_defines.h is because you are compiling for PS3 system, then if you are under PSL1GHT you have to define __PSL1GHT__, otherwise you are compiling with the old sony, but __PS3__ must be defined always.
It is not uncommon to find this definition:
Code:
#if defined(__PS3__) && !defined(__PSL1GHT__)
on libretro cores.
In the end, RetroArchCE is compiled from the official sources, because they are kept clean and tidy :biggrin:
 
if you restarted with recover menu, the configuration made by the pkg is deleted.

You can try to install mamba payload manually:
1- Copy mamba_489C.bin to root of /dev_hdd0
2- Open notepad and add this line: /dev_hdd0/mamba_489C.bin
3- Save the file as boot_plugins_kernel_nocobra.txt and upload it to root of /dev_hdd0
4- Disable Cobra payload and reboot

The system should boot with mamba instead of Cobra.

Another alternative is update the payload in IRISMAN and launch it to load Mamba if Cobra is disabled
Now /dev_hdd0/mamba_489C.bin and and boot_plugins_kernel_nocobra.txt are ok, but disabling Cobra, after reboot, WebMan games disappear and i can only Install webMan Mod 1.47.42 that renable Cobra.
without install webMan Mod after disabling Cobra, MAPi arent present.
Is there an hidden menu for Mamba?
 
@OsirisX this is amazing. The few I talked to said with the Cell being 64-bit architecture with 32-bit pointers would make it tough but felt using the Wii dynarec would be the "easiest" approach. But thank you so much & do you take donations?
 
Now /dev_hdd0/mamba_489C.bin and and boot_plugins_kernel_nocobra.txt are ok, but disabling Cobra, after reboot, WebMan games disappear and i can only Install webMan Mod 1.47.42 that renable Cobra.
without install webMan Mod after disabling Cobra, MAPi arent present.
Is there an hidden menu for Mamba?

To load plugins while Cobra is disabled, you need to add them to /dev_hdd0/boot_plugins_nocobra.txt
It doesn't matter if Mamba is loaded or not, the plugin will be loaded. If Mamba is not loaded, you won't mount games or call ps3mapi commands.

For wMM, you need to add the following path to boot_plugins_nocobra.txt
/dev_hdd0/plugins/webftp_server.sprx
 
Last edited:
Here is the new pico compiled with latest changes by @OsirisX: https://github.com/crystalct/crystalct.github.io/raw/main/tmp/picodrive_libretro_ps3.SELF
It's for RetroArchCE. Who has latest Mamba installed could try it.... maybe @aldostools ? :encouragement:

Tested with Cobra 8.3 on 4.89 Evilnat
- Genesis rom played normally
- 32X rom (Doom) caused black screen

Tested with Mamba 8.4 on 4.89 Evilnat (including latest changes by OsirisX)
- Genesis rom (not tested, should work fine)
- 32X rom (Doom) played @ 49-50fps
- 32X rom (Virtua Fighter) played @ 49-50fps with heavy graphical bugs / gitches
 
Tested with Cobra 8.3 on 4.89 Evilnat
- Genesis rom played normally
- 32X rom (Doom) caused black screen

Tested with Mamba 8.4 on 4.89 Evilnat (including latest changes by OsirisX)
- Genesis rom (not tested, should work fine)
- 32X rom (Doom) played @ 49-50fps
- 32X rom (Virtua Fighter) played @ 49-50fps with heavy graphical bugs / gitches
Now Dynarec for Pico Core is @aldostools CERTIFIED!!! :biggrin:
It's very cool!!!
Now in my opinion, I will have to create an additional Pico core, for those who have the PS3 with the appropriate Mamba or Cobra, so they can download and use it directly from RetroArchCE.
 
Last edited:
Now Dynarec for Pico Core is @aldostools CERTIFIED!!! :biggrin:
It's very cool!!!
Now in my opinion, I will have to create an additional Pico core, for those who have the PS3 with the appropriate Mamba or Cobra, so they can download and use it directly from RetroArchCE.
I think it is better to test if the payload supports dynarec, instead of have more cores.
 
I think it is better to test if the payload supports dynarec, instead of have more cores.
Unfortunately Retroarch works in a way that leaves it up to the cores to adapt to different systems. Pico core should have an option to disable/enable dynarec, but it isn't there. To have dynarec you have to compile pico core in a different way.
 
Building on @TheRouLetteBoi's page_allocate additions in Mamba/Cobra, I've also added support for page freeing which fixes the issue where program crashes on exit. Any program that uses page_allocate will need to keep track of a page_table which is the kernel page address to user process page address mapping. See below code example of its usage that's based off of TheRouLetteBoi's and Crystal's example.

Code:
#include <sys/process.h>
#include <ps3mapi_ps3_lib.h>

#define KB(n) (1024*n)
#define MB(n) (1048576*n)

char fret5[32] = {0xfb, 0xe1, 0xff, 0xf8, 0xf8, 0x21, 0xff, 0xc1, 0x7c, 0x3f, 0x0b, 0x78, 0x39, 0x20, 0x00, 0x05,
          0x7d, 0x23, 0x4b, 0x78, 0x38, 0x3f, 0x00, 0x40, 0xeb, 0xe1, 0xff, 0xf8, 0x4e, 0x80, 0x00, 0x20};

uint64_t page_table[2];

int main(int argc, char *argv[]) {

  int ret = ps3mapi_page_allocate(sysProcessGetPid(), KB(650), PAGE_SIZE_AUTO, 0x2F, 1, page_table);

  // After ps3mapi_page_allocate return
  // page_table[0] holds program page_address mapping
  // page_table[1] holds kernel page_address allocation

  if (ret != 0)
  {
    printf("failed to allocate page\n");
    return;
  }

  memcpy(page_table[0], fret5, sizeof(char)*32);
  int(*func)() = (int (*)())&page_table[0];
  int result = func();
  printf("fret5 result: %d\n", result);

  ps3mapi_process_page_free(sysProcessGetPid(), 0x2F, page_table);

  return 0;
}

With some minor modifications to Retroarch's picodrive, I was able to get dynarec working which significantly sped up performance for 32x and Sega CD.

Star Wars Arcade runs at full speed no problem :)
GvpwT3x.png


Source code for these changes can be found below. Note that you will need the Mamba payload changes to get it to run after compiling.

https://github.com/OsirizX/Mamba/tree/page_table
https://github.com/OsirizX/ps3mapi-lib/tree/page_free
https://github.com/OsirizX/picodrive/tree/ps3_dynarec

credits: @TheRouLetteBoi, @Crystal, @bucanero
@aldostools could you make that changes to PS3HEN in your repository?
I tried adding that script, but the compilation error:

ps3mapi_core.c: In function 'ps3mapi_process_page_allocate':
ps3mapi_core.c: 199: warning: passing argument 3 of 'page_allocate_auto' make integer from pointer without a cast
ps3mapi_core.c: 199: error: too few arguments to function 'page_allocate_auto'

Note: has changed u64 to uint64_t

Thanks.
 
Unfortunately Retroarch works in a way that leaves it up to the cores to adapt to different systems. Pico core should have an option to disable/enable dynarec, but it isn't there. To have dynarec you have to compile pico core in a different way.
My assertion was wrong, i found that option. It's enabled by default and it is visible only if it starts a 32x game. I will compile Pico with default "disabled". :encouragement:
 
Back
Top