Homebrew elf compatibility problems with PCSX2
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:
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
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:
    while(i<40000000) // print operation result during 2 sec.

But in v3.80 all such occurrencies in the TextEditor were replaced by real timer pauses, like this:
    while(Timer()<WaitTime+1500); // print operation result during 1.5 sec.

And that Timer() function is defined like this:
// 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)
    *T0_MODE |= (1 << 11);
    return -1;
// Timer Init
void TimerInit(void)
    *T0_MODE = 0x0000;
    TimerInterruptID = AddIntcHandler(9, TimerInterrupt, 0);
    *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){
        RemoveIntcHandler(9, TimerInterruptID);
        TimerInterruptID = -1;
    TimerInterruptCount = 0;
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

Sponsored links

Wow, I didnt Even know that Elf's Were related to homebrew app's. That being said i would really like to see where this goes, dlanor you got my thumbs up
Smoke Till I Choke, High Till I die
When i Die ima be so high that ima get up and walk leaving the concrete Bare with the Chalk Outline Still there.
Yes, we recently started using homebrew to check on certain aspects of the emulation.
Its possible uLE will run again on pcsx2 Smile
(12-19-2008, 02:41 PM)rama Wrote: Yes, we recently started using homebrew to check on certain aspects of the emulation.
I'm glad to hear it, as it is also becoming rather common for homebrew programmers to test their compatibility to PCSX2, so as to be able to do some debugging in a controlled environment, instead of doing it on the physical consoles. But such tests lose some of their value whenever the emulator implementation lacks some detail crucial to the program under test, such as the timer interrupts mentioned in my previous post. Those are used quite commonly in modern homebrews (in some cases because they borrowed code from the open sources of uLE Smile).

It was even more critical in the testing of the FMCB installers recently developed. (In case you missed it, FMCB is the now dominant PS2 and PStwo softmod, booting all consoles except for the latest variant of SCPH-900xx, the ones with bios v2.30)

Quote:Its possible uLE will run again on pcsx2 Smile
I hope so, as I too would like to be able to test some features on a PC in my own development for uLE.

Testing over PS2Link is reasonably fast too, but the IOP reset needed in proper uLE testing inevitably kills PS2Link, so that a full reboot is need to relaunch it after each such test.

And for those who missed this in all the text of my previous post, I'd like to remind everyone that uLE version 3.81 and older ones are bootable as-is under PCSX2, though you need uLE version 3.79 or older to also make the TextEditor subprogram usable.

Collections of old uLE versions are available on many PS2 sites, including sksapps.com (for example) where you can find all of the versions I mentioned and more, with both binaries and source code included in each release package.

Best regards: dlanor

Users browsing this thread: 1 Guest(s)