12-18-2008, 10:40 AM
I am sure that many besides myself have noticed that a large number of homebrew elfs do not work well with PCSX2, many of them locking up immediately after booting or immediately after displaying their first splash screen or menu. One typical elf with this behaviour is uLaunchELF (aka: uLE), all recent versions of which suffer from such problems.
But today I noticed that a tutorial for memcard import/export of gamesaves used the original LaunchELF program (on which uLE was based), and when I tried this myself I found that it worked fine with PCSX2, and that roused my curiousity.
I decided to find out exactly where in the chain of developments the changes were made that causes new versions of uLE to freeze in PCSX2, and after testing some dozens of different versions I have now nailed it down.
The last uLE version that has a working main menu under PCSX2 is uLE v3.81 (also the first version to use gsKit), but this version could still freeze when opening a text file in the uLE TextEditor, and that also applies to the previous version 3.80 .
So the last uLE version that was fully working, including TextEditor functionality, was thus uLE v3.79, and whatever causes the problem must have been introduced in the changes for v3.80, though only affecting the TextEditor in that update.
My changelog for v3.80 reads as follows:
The only one of those changes that can be responsible for the problem is the addition of the EE timer functions, used for various time delays.
Inspection of the TextEditor code (contributed by Polo35 at psx-scene) shows that v3.79 used a simple count loop for delays:
But in v3.80 all such occurrencies in the TextEditor were replaced by real timer pauses, like this:
And that Timer() function is defined like this:
It seems very clear to me that the reason for the TextEditor freezing in uLE v3.80 under PCSX2 is that the timer interrupts used by the code above are not correctly implemented in the emulator as yet.
I have also verified that similar timer calls are involved in the update from v3.81 to v3.82 where the main menu of uLE froze under PCSX2. This is because a timer call was added to one of the global screen update functions of uLE v3.82, and is thus used by all menus.
So in my opinion this proves conclusively that the emulator needs an improved timer interrupt implementation, and not only to gain compatibility with homebrews that use such methods, as I am sure that various commercial games must do so too. It may be that fixing this one feature could cause many new games to gain compatibility with PCSX2.
Best regards: dlanor
But today I noticed that a tutorial for memcard import/export of gamesaves used the original LaunchELF program (on which uLE was based), and when I tried this myself I found that it worked fine with PCSX2, and that roused my curiousity.
I decided to find out exactly where in the chain of developments the changes were made that causes new versions of uLE to freeze in PCSX2, and after testing some dozens of different versions I have now nailed it down.
The last uLE version that has a working main menu under PCSX2 is uLE v3.81 (also the first version to use gsKit), but this version could still freeze when opening a text file in the uLE TextEditor, and that also applies to the previous version 3.80 .
So the last uLE version that was fully working, including TextEditor functionality, was thus uLE v3.79, and whatever causes the problem must have been introduced in the changes for v3.80, though only affecting the TextEditor in that update.
My changelog for v3.80 reads as follows:
Code:
LaunchELF v3.80 (2006.07.19)
-Changed some incorrect strings in the supplied example LAUNCHELF.CNF
-Merged JPG viewer contributed by Polo
-Merged EE timer functions contributed by Polo
-Modified paste progress calculations for better precision
Inspection of the TextEditor code (contributed by Polo35 at psx-scene) shows that v3.79 used a simple count loop for delays:
Code:
i=0;
while(i<40000000) // print operation result during 2 sec.
i++;
But in v3.80 all such occurrencies in the TextEditor were replaced by real timer pauses, like this:
Code:
WaitTime=Timer();
while(Timer()<WaitTime+1500); // print operation result during 1.5 sec.
And that Timer() function is defined like this:
Code:
// Timer Define
#define T0_COUNT ((volatile unsigned long*)0x10000000)
#define T0_MODE ((volatile unsigned long*)0x10000010)
static int TimerInterruptID = -1;
static u64 TimerInterruptCount = 0;
// Timer Interrupt
int TimerInterrupt(int a)
{
TimerInterruptCount++;
*T0_MODE |= (1 << 11);
return -1;
}
// Timer Init
void TimerInit(void)
{
*T0_MODE = 0x0000;
TimerInterruptID = AddIntcHandler(9, TimerInterrupt, 0);
EnableIntc(9);
*T0_COUNT = 0;
*T0_MODE = ( 2 << 0 )+( 1 << 7 )+( 1 << 9 );
TimerInterruptCount = 0;
}
// Timer Count
u64 Timer(void)
{
u64 ticks = (*T0_COUNT + (TimerInterruptCount << 16)) * (1000.0F / ( 147456000.0F / 256.0F ));
return ticks;
}
// Timer End
void TimerEnd(void)
{
*T0_MODE = 0x0000;
if (TimerInterruptID >= 0){
DisableIntc(9);
RemoveIntcHandler(9, TimerInterruptID);
TimerInterruptID = -1;
}
TimerInterruptCount = 0;
}
I have also verified that similar timer calls are involved in the update from v3.81 to v3.82 where the main menu of uLE froze under PCSX2. This is because a timer call was added to one of the global screen update functions of uLE v3.82, and is thus used by all menus.
So in my opinion this proves conclusively that the emulator needs an improved timer interrupt implementation, and not only to gain compatibility with homebrews that use such methods, as I am sure that various commercial games must do so too. It may be that fixing this one feature could cause many new games to gain compatibility with PCSX2.
Best regards: dlanor