Multi-threading in PSX

General Programming help in C, C++ or ASM, Compiling / Debugging, and R3000A Central Processing Unit (CPU) information
Post Reply
Xavi92
C Programming Expert
C Programming Expert
Posts: 122
Joined: October 6th, 2012, 12:53 am

Multi-threading in PSX

Post by Xavi92 » October 5th, 2016, 5:47 am

Hello there,

I was looking at Nocash PSX documentation and I noticed about the use of multi-threading in PSX games. I certainly know what multi-threading is and what advantages and disadvantages it brings, but... are there any known PSX commercial/homebrew game or app out there which actually made use of this?

Also, I was feeling curious about implementing some kind of multi-threading support on PSXSDK libs for some interesting purposes.

Infrid
What is PSXDEV?
What is PSXDEV?
Posts: 2
Joined: September 5th, 2017, 1:05 am

Re: Multi-threading in PSX

Post by Infrid » September 5th, 2017, 5:29 pm

for example you can run the game in a thread while you pay the audio track in another thread. Load assets while you playing a level for the next one, etc etc.

User avatar
LameGuy64
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 381
Joined: April 10th, 2013, 3:47 pm
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

Re: Multi-threading in PSX

Post by LameGuy64 » September 6th, 2017, 1:09 pm

If I remember correctly, multi-threading on the PSX works kinda similar to how multi-threading works on modern platforms. You basically create a thread but you must switch to the thread you created with ChangeTh() in your main loop or a mini loop that switches between all the threads you've created.

I haven't tried multi-threading on the PSX much myself so I'm not sure what advantages it would bring as most of the stuff to perform things like playing streaming music in the background or executing a musical sequence is all done by the hardware or can be done with interrupts. It might be useful for doing things like animated loading screens or routines that need to be run in the background but are too complex to be run on interrupts.

If you want to see how multi-threading is done with the PsyQ or Programmer's Tool SDKs, look at the THREAD example included with the development kits.
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

Xavi92
C Programming Expert
C Programming Expert
Posts: 122
Joined: October 6th, 2012, 12:53 am

Re: Multi-threading in PSX

Post by Xavi92 » January 21st, 2018, 12:45 pm

Sorry for reviving this, but I didn't realize this topic actually got responses.
In the case of animated loading screens, that's pretty much what my video game "Airport" is actually doing. Despite not creating a thread on its own, I'm abusing VBlank ISR so that, during loading screens, sprites are being sent to the GPU while the main loop is handling file data.
Not the most polite solution, but pretty quick to set up and works. However, it looks like fopen() doesn't like being interrupted, so the ISR must take this into account. Same thing when GPU is busy or a DMA transfer is being made.

User avatar
MysticLord
Curious PSXDEV User
Curious PSXDEV User
Posts: 11
Joined: August 9th, 2017, 3:06 am

Re: Multi-threading in PSX

Post by MysticLord » March 17th, 2018, 7:48 am

I believe Glain et al. documented some stuff on multithreading at the FFHacktics wiki.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests