Page 1 of 1

Taking screenshots with ps2link

Posted: Mon May 04, 2009 8:27 am
by Maximus32
I'm currently working on an application much like InLink. Becouse it's built using Qt it should run on Windows, Linux, Mac and more. One feature I really missed in InLink was the ability to make screenshots, so I modified ps2link to be able to save a screenshot (using the ps2sdk function ps2_screenshot_file).

I have a small problem though, I can't figure out how the display is setup, becouse it seems like the GS registers are write-only. So taking a screenshot becomes a little tricky becouse you need to manually specify: base-addr, width, height and bit-depth.

My questions:
- Would anyone be interested in an InLink replacement?
- Is a screenshot feature like this interesting for someone?
- What other features would you like?

Re: Taking screenshots with ps2link

Posted: Mon May 04, 2009 9:38 pm
by cosmito
- Is a screenshot feature like this interesting for someone?
Would it be possible to take a screenshot at any time? That would be nice.
- What other features would you like?
If you're modifying ps2link, please update the PAL/NTSC detection method to work with recent consoles. Check for detect_signal in recent gsKit sources.
You may also replace the ugly debug font. See http://forums.ps2dev.org/viewtopic.php?t=11663

---edited---

bah, the PAL/NTSC detection should be made at debug lib not at ps2link itself... My mistake.

BTW: Nice work with brickOS. Seems promising.

Posted: Mon May 04, 2009 10:47 pm
by Maximus32
Would it be possible to take a screenshot at any time? That would be nice.
Yes, I've already made a few screenshots and they look great! But keep in mind that you need to manually specify where in GS memory to make the screenshot. So if an application uses double buffering and continuesly swaps the render-buffer with the display-buffer, only half of the screenshots will be from the display-buffer.
If you're modifying ps2link
I would like to add the screenshot feature, but who is currently maintaining ps2link?

Posted: Mon May 04, 2009 10:51 pm
by cosmito
Maximus32 wrote:I would like to add the screenshot feature, but who is currently maintaining ps2link?
As far I know the current policy is to make a patch and post it over "forums.ps2dev.org Forum Index -> Patch Submissions". Some mod there will hopefully apply it.

Posted: Tue May 05, 2009 5:15 am
by LionX
you could make some common default rez and also add custom.

eg:
640x448
320x240
.....
.....
Set Manually

Posted: Tue May 05, 2009 7:31 am
by Maximus32
@LionX: Good idea, I'll see what I can do.

As for the current status:
I found out taking screenshots when there is movement produces a mess. This is becouse the screenshot is taken and transferred line-by-line, while the application is still running in a different thread. To solve this I have to suspend all application threads, and resume them after the screenshot is taken.

I already have this working, but a lot of the applications I tested chash when suspending/resuming the threads.
The screenshot code is also very buggy: 16bit mode does not work at all, and a lot of applications/resolutions result in a crash. So perhaps I need to rewrite that part.

Anyway, here's some proof of the screenshots:

ps2dev tutorial 2a: (Looks good)
Image

ps2dev tutorial 2b: (The text was moving, so it looks messed up!)
Image

ps2dev tutorial 2d: (Captured the FRONT and BACK buffer at the same time)
Image

All these images use double scan, so they should probably be stretched to make them look right.

Posted: Tue May 05, 2009 12:03 pm
by LionX
i could be wrong but i think the apps that crash is using a path to the GS other than path3(ee->gif->gs). or could be dma crash.

Posted: Sat May 09, 2009 8:35 am
by Maximus32
I've uploaded a complete demo package. With it you should be able to make, and save your own screenshots. You can also suspend/resume the running application. Becouse it is all very experimental and a lot of applications do not work, I included a simple demo (ps2dev tutorial 2c) that does work, so give it a try, and let me know what you think.

[download] ~5MB

@LionX: The method used to make the screenshot differs from the one in the sony ps2linux manuals. So I think it crashes becouse registers are not setup/restored properly.

Posted: Sat May 09, 2009 8:40 am
by LBGSHI
Wow, that's awesome :)

I'll test it out later.

Posted: Tue May 12, 2009 3:45 am
by misfire
Good work.

Could you also add screenshot support to ps2client (for Linux people)?

Posted: Tue May 12, 2009 7:46 am
by Maximus32
Could you also add screenshot support to ps2client (for Linux people)?
The graphical interface will also be available "for Linux people". But if I have everything working properly I'll try to add screenshot support to ps2link as well.

Status update:
The screenshot code from the debug library wasn't working for me becouse it coused a lot of ps2 crashes. I found the graph_vram_read function in the graph library to be very usefull, though I had to modify it to be able to capture line-by-line. As a result, a lot more applications work now, including ps2link itself.
16bit screenshots are also working now (turns out there are 2 16bit modes, and I was only using one).
I also removed the conversion to 32bit (on the ps2 side). Making 16bit screenshots twice as fast, and 24bit screenshots 1.5x faster.

ConsoleLink, capturing ps2link:
Image

Full-HD - 1920x1080, 16bit, dithering (click to enlarge):
Image