Can someone look at this code

Developer
Apr 28, 2014 at 12:00 AM
Edited Apr 28, 2014 at 5:30 AM
Hello Everyone,

I found that adding 2 // at psxBios_firstfile() { // 42 at the DeliverEvent(0x11, 0x2); and v0 = _dir; after
bufile(1); and bufile(2); in psxbios.c seems to fix some of the HLE-bios loading memory cards.
void psxBios_firstfile() { // 42
    struct DIRENTRY *dir = (struct DIRENTRY *)Ra1;
    u32 _dir = a1;
    char *ptr;
    int i;

#ifdef PSXBIOS_LOG
    PSXBIOS_LOG("psxBios_%s: %s\n", biosB0n[0x42], Ra0);
#endif

    v0 = 0;

    strcpy(ffile, Ra0);
    pfile = ffile+5;
    nfile = 1;
    if (!strncmp(Ra0, "bu00", 4)) {
        bufile(1);
                v0 = _dir;
    } else if (!strncmp(Ra0, "bu10", 4)) {
        bufile(2);
                v0 = _dir;
    }

    // firstfile() calls _card_read() internally, so deliver it's event
    // DeliverEvent(0x11, 0x2);

    pc0 = ra;
}
Here is a list of games that this fix seems to make the memory card loading with the HLE-Bios work.

Battle Tanks Global Assualt
Capcom Vs SNK Pro
Dark Stalkers
Fatal Fury Wild Ambibtion
Fear Effect
Gaunlet Legends
Gex Enter The Gecko
Gundam Battle Assualt
Legacy Of Kain Soul Reaver
Legend Of Dragoon
Syphon Filter 3
Rayman 2

Can someone look at this code and make sure it works well with pcsxr because i'm not a coder.
Apr 29, 2014 at 4:15 AM
Good job if it works.
Developer
Apr 29, 2014 at 4:30 AM
Edited Apr 29, 2014 at 4:32 AM
Hello Flower100,

It works for me. It fixes a lot a games that were not loading the save but some games like
parasite eve 1 & 2 still don't load. I hope someone can update pcsxr with it soon. :)
Coordinator
Apr 29, 2014 at 6:57 AM
Edited Apr 29, 2014 at 7:14 AM
this does not look correct for me (never returns NULL even if no filename matches) which may cause eg. incorrect slot being loaded from from memcard.

need to investigate further (I would suspect that it's a case-sensitivity issue, although I don't have access to PSX games to test for now).
Developer
Apr 29, 2014 at 1:32 PM
Edited Apr 29, 2014 at 1:39 PM
Hello weimingzhi,

This is what is shown on the terminal with Parasite Eve 1 and 2. The only other game that i know that memory card does not work is Ridge Racer Type 4 but there is nothing shown in the terminal.

Parasite Eve 2 when trying to load memory card (does not work unless you have a parasite eve 2 save in the memory card then it will allow you to save and load.)
  • 2 : BAS = BASLUS-01042* + BASCUS-94491drgn0000 (match=0)
  • 3 : BAS = BASLUS-01042* + BASCUS-94491drgn0001 (match=0)
  • 4 : BAS = BASLUS-01042* + BASCUS-94425SP2RR (match=0)
  • 5 : BASLUS` = BASLUS-01042* + BASLUSP00797RR4_GAME (match=0)
===============================================================
Parasite Eve 1 when trying to load memory card (does not work)

2 : BASLUS-006620000000A = * + BASLUS-006620000000A (match=1)
  • 3 : BASLUS-00745 = * + BASLUS-00745 (match=1)
  • 4 : BASLUS-006620000000A = * + BASLUS-006620000000A (match=1)
  • 5 : BASLUSP00797RR4_GAME = * + BASLUSP00797RR4_GAME (match=1)
  • open BASLUS-006620000000A
  • read 1: 100,80 (BASLUS-006620000000A)
  • read 1: 180,80 (BASLUS-006620000000A)
When trying to save
  • 2 : BASLUSP00797RR4_GAME = * + BASLUSP00797RR4_GAME (match=1)
  • 3 : BASCUS-94451BAA9ACB8 = * + BASCUS-94451BAA9ACB8 (match=1)
  • 4 : = * + (match=1)
  • 5 : BASCUS-94451settings = * + BASCUS-94451settings (match=1)
  • 6 : BASLUS-01476 = * + BASLUS-01476 (match=1)
  • 2 : BASLUS` = BASLUS-01042* + BASLUSP00797RR4_GAME (match=0)
  • 3 : BASLUS` = BASLUS-01042* + BASCUS-94451BAA9ACB8 (match=0)
  • 4 : BASLUS` = BASLUS-01042* + (match=0)
  • 5 : BASLUS` = BASLUS-01042* + BASCUS-94451settings (match=0)
  • 6 : BASLUS-01ý€ = BASLUS-01042* + BASLUS-01476 (match=0)
Coordinator
Apr 30, 2014 at 4:58 PM
Edited Apr 30, 2014 at 5:09 PM
from my test real BIOS does not deliver the event after calling firstfile()/nextfile() though. (ie. commenting out the "DeliverEvent" line may be correct).
still though, real BIOS does return NULL if firstfile() does not manage to find a matching filename in memcard.

http://postimg.org/image/k9d5wlyyn/

still need to test this with the games mentioned above.
Developer
Apr 30, 2014 at 8:08 PM
Edited Apr 30, 2014 at 8:10 PM
Hello weimingzhi,

Another game that you may want to look at is Legacy of Kain Blood Omen. For some reason it deletes 1 block on both memory cards when saving the game. Here is the output.
  • openC Q
    • delete BASLUS-00027LOKaygsu
    • openC Q
    • delete BASLUS-00027LOK
    • openC Q
    • open BASLUS-00027LOKaygsu
    • write 1: 0,2000
BTW: You will need the fix i did if your using the dfaudio plugin. (At least on linux).
Developer
May 1, 2014 at 3:01 AM
Edited May 1, 2014 at 9:49 PM
Hello weimingzhi,

Without the

v0 = _dir ;

Alot of the games i mentioned will not boot or load memory card.
Coordinator
May 2, 2014 at 5:38 PM
Capcom Vs SNK Pro:

wait for flag at 8007d530 in an infinite loop after calling firstfile(). The flag is set in event handler.
if firstfile() does not return NULL, the game will call card_read() which delivers the event -> call the event handler -> set the flag -> exit the infinite loop.

with real BIOS firstfile() returns NULL as well, however the event handler was still called for some reason. Need more investigation.
Developer
May 2, 2014 at 7:50 PM
Hello weimingzhi,

I think you made a mistake with your last patch else if (strcmp(Ra0, "bu01:") shouldn't it be "bu10".

Also i have a question is that case 'i': case 'u' suppose to be case 'i': case 'I': ?
Developer
May 3, 2014 at 7:00 AM
Edited May 3, 2014 at 7:18 AM
Fri at 6:50 PM

Hello weimingzhi,

I just found out that if the memory cards do not have a save in them some game hang while booting up. These games hang if the is no save on the memory card.

Capcom vs SNK Pro
Dalkstalkers 3
Dino Crisis 2

However once you have a save in the memory card then these games boot.
Developer
May 3, 2014 at 10:34 PM
Hello

Hello weimingzhi,

Could this be causing a infinite loop?


void psxBios_atoi() { // 0x10
s32 n = 0, f = 0;
char *p = (char *)Ra0;

for (;;p++) {
Coordinator
May 4, 2014 at 3:23 AM
I think you made a mistake with your last patch else if (strcmp(Ra0, "bu01:") shouldn't it be "bu10".
you are right, fixed.
thanks ;)

Could this be causing a infinite loop?
the infinite loop is in the game code, not the emulator.
Developer
May 4, 2014 at 11:25 AM
Hello weimingzhi,

Your welcome. :)
Developer
May 5, 2014 at 10:40 PM
Edited May 6, 2014 at 8:39 PM
Hello Everyone,

Ok i think i have something here. In line 1884 I changed the - 1 to - 0

dir->name[sizeof(dir->name) - 0] = '\0'; \

with the value 0 it reads at block 1 and writes at block 1 for Legacy of kain Blood Omen. Good Save.

with the value 1 it reads at block 2 but writes at block 1 for Legacy of kain Blood Omen. Bad Corrupt Save.

Can someone check this and add it to pcsxr?
Developer
Jun 29, 2014 at 8:25 PM
Edited Jun 29, 2014 at 8:25 PM
Hello Weimingzhi,


I believe Final Fantasy 8 and Ridge Racer Type 4 are not open the memory cards with the HLE-Bios.
In Final Fantasy 8 you can see that the continue button does not light up as if there are no memory
cards.