Hi. I'm interested in making programmes for the Playstation 2. Does anyone know of any software I can use?
|
|
|
|
Would you like to get all the new info from
PSX-Scene in your email each day?
Want to learn more about the team keeping you up to date with the latest scene news?
Read about them now! Check out our Developer bios, too! | ||
|
|
Hi. I'm interested in making programmes for the Playstation 2. Does anyone know of any software I can use?
www.ps2dev.org --> PS2SDK-Source and homesite of the SDK.
www.thegshi.com --> Development&Hacking-Board. Pre-Build&compiled PS2-SDK for Win32 with instructions.
Heres another very useful site to start pS2 Programming :
http://lukasz.dk/playstation-2-programming/

If anyone would be so kind helping out:
I've started a couple of days ago, trying to get the basics of ps2 programming, so far I've managed to get along, althought I have some doubts:
1) In fontM example: Instead of ps2client, I run elf's from a USB disk, so whenever a source needs other files, other than the main ELF, I would expect it to be so simple as changing "host:file.jpg" for instance, to "mass:file.jpg". Can you tell me why I just get a scrambled screen, instead?
Anyway I got around it, converting an image in (needs to be BMP) to .c source format, with ps2 Image Studio, and including that file in the main source. This led me to other problems:
2) Looks like gsKit_init() doesn't accept any arguments, I was hopping that the main resolution would be set here, and it can't... any workarounds?
3) I haven't paid attention to it but the screen resolution seems to be about 650x525, weird numbers, but ok. But I haven't managed to make a full screen texture to correctly display if it's bigger than 320x240...
4) I'm trying to display a second texture, let's say of 128x128 (for some reason if I try to use a non 8 multiple, it does not show correctly, it appears distorted...). How should I do to ha transparencies, I mean, suppose the texture is a circle, or something like it, I want it to show only that circle, not the black pixels around it... I'd expect it to work, just checking the "Black for transparency" on ImageStudio, but all I get it the complete square...
This is probably because you didn't load the usb irx modules. Return values from the fio operations would tell you more likely.
There is more to it than the init itself. The initialization is a few lines of code. For example open-usb-loader does this (I hope Ifcaro doesn't mind):
Code:gsGlobal = gsKit_init_global(); gsGlobal->PSM = GS_PSM_CT24; gsGlobal->PSMZ = GS_PSMZ_16S; gsGlobal->ZBuffering = GS_SETTING_OFF; gsGlobal->PrimAlphaEnable = GS_SETTING_ON; dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF); // Initialize the DMAC dmaKit_chan_init(DMA_CHANNEL_GIF); dmaKit_chan_init(DMA_CHANNEL_FROMSPR); dmaKit_chan_init(DMA_CHANNEL_TOSPR); gsKit_init_screen(gsGlobal); gsKit_mode_switch(gsGlobal, GS_ONESHOT);
There was some kind of problem with maximal DMA transfer size. Try uploading the texture to VRAM first. I'm noob on this too so take it with a grain of salt though.
Distortion - not sure here. Maybe resolution dependencies - let's hear some educated response from someone else.
Transparency is probably best handled with alpha channel. Then you just have to render the image accordingly![]()
After calling gsKit_init_global, which allocates the space for the gsGlobal, you can set the Mode, Interlace, Field, Width, and Height values to whatever mode/resolution you want, and then call gsKit_init_screen which will init the mode based on what's in the gsGlobal.
For transparency and textures, it looks like gsKit really only supports generic alpha blending where the MSB of the alpha value determines to blend or not.Code:gsGlobal = gsKit_init_global(); gsGlobal->Width = 320; gsGlobal->Height = 224; gsGlobal->Mode = GS_MODE_NTSC; gsGlobal->Interlace = GS_NONINTERLACED; gsGlobal->Field = GS_FRAME; gsGlobal->PSM = GS_PSM_CT24; gsGlobal->PSMZ = GS_PSMZ_16S; gsGlobal->ZBuffering = GS_SETTING_OFF; gsGlobal->PrimAlphaEnable = GS_SETTING_ON; dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF); // Initialize the DMAC dmaKit_chan_init(DMA_CHANNEL_GIF); // All gsKit programs only use this channel gsKit_init_screen(gsGlobal); gsKit_mode_switch(gsGlobal, GS_ONESHOT);
As for the texture problem, more information is needed as to what the distortion looks like. If it looks tiled, you probably need to increase the size of the texture buffer width, gsTexture->TBW. The value is generally texture width/64.
If it's related to filtering, which can distort your texture, the primitive coordinates and texel coordinates are both 16-bit (12.4) fixed point. Jbit's made a good tutorial on how to get pixel-perfect mapping: http://www.jbit.net/ps2/gs-linear-sprite.html.
@volca and @ragnarok2040:
Thank you, I'm getting there...
I allready had the initial code, the problem with the original fontm demo was the texture itself, on at least on my system (PAL systems?) the screen gets all messed up when using resolutions bigger than 320x240, and the one on the demo is 256x256.
Including the part I wasn't including, where you set gsGlobal height, width, mode etc, I thought it should work: what I was trying to do was to use a 640x480 image. On the PCSX emulator it runs fine, even without that code, but on PS2 itself without your code, the previous situation occurs, and with it, the screen just shows part of the image, it stretches it. As my PS2 reports normally a screen width of 640x512, maybe I try to set gsGlobal to match this and give it a try.
The distortion on the images seems to be a limitation on PS2 Image Studio, that I use to convert the BMP to .c format and include on the main ELF.
If I set it up to a multiple of 8 it works just fine.
On the transparent matter, something funny happened, I managed to put it to work, with the 640x480 background image on the PCSX emulator, I mean. After altering the background to 320x240, I might had something changed and it never worked like I intended... maybe after changing the BMP's itself, the .c file (I tried replacing all the 0x00 with 0x80...). Don't know.
I'm sending the ELF so that you can get the main purpose of all this, I tried images with black background and with a white background.
Also... I was using an instruction just before the gsKit_prim_sprite_texture one that is:
gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(0,1,0,1,0), 0);
what are the GS_SETREG_ALPHA arguments, I mean what do they represent? I believe it may be part of the solution...
Once again, thank you for your help.
The ALPHA registers changes how the blending is calculated. If the gsGlobal->PABE flag is 1 when gsKit_set_primalpha is called, then the MSB of the alpha value in a color determines alpha-blending.
As for the arguments, color A, color B, alpha C, color D, and fixed alpha value (0-255)... They can be set to 0,1,2, where 0,1 are source/framebuffer colors/alpha. 2 is used for the value of zero, except for C where 2 stands for the fixed alpha value. An alpha value of 0x80 is equal to alpha value of 1.0, which probably means full transparency? I haven't really tested it though.
Edit:
Wrote this while cooking, added some fixes and the algorithm.
Code:A B C D RGB = (RGB1 - RGB2) * A>>7 + RGB3
Last edited by ragnarok2040; 10-31-2009 at 06:06 PM.
Weird. I'm still not sure if it is possible to accomplish what I had in mind using gsKit: get rid of that white border around the moving image. Sometimes it works, but I've found that it's just because the ps2 emulator (pcsx) is messed up after running too many times. I had it running, but then, after shutting it down and start it over, the image does not show at all, just like on ps2 itself. I mean, if I comment out the lines on
//gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(0,1,0,1,0), 0);
gsKit_prim_sprite_texture(gsGlobal, &jorge,x, y, 0.0f, 0.0f,x+144.0f, y+192.0f,jorge.Width, jorge.Height,2, TexCol);
//gsKit_set_primalpha(gsGlobal, GS_BLEND_BACK2FRONT, 0);
the image does not appear on screen.
Not sure if I'm missing something...
The test register actually sets up 3 tests, alpha test/destination test/depth test, which are all done in order if all 3 are enabled. If a pixel fails the first test, it doesn't pass the others. The depth test probably isn't needed for your app, so I'll explain the first two.
Here's an example that sets up a test where pixels with an alpha value of 0 will fail and no buffers are updated for failed pixels. I included available settings after the values. The AFAIL setting determines what to update with the failed pixel.
This test sets up whether the pixels destination alpha value passes. This test changes depending on storage mode. 16-bit alpha is either 0/1. 32-bit alpha requires it to be >= 0x80. Automatic pass for other modes.Code:gsGlobal->Test->ATE = 1 // enable gsGlobal->Test->ATST = 7 // not equal, (never,always,<,<=,=,>=,>,!=) gsGlobal->Test->AREF = 0x00 // comparison alpha value gsGlobal->Test->AFAIL = 0 // keep, (keep,framebuffer,zbuffer,RGBA32->RGB32)
gsKit_init_screen() sets up the alpha blending registers to 0x01 or GS_BLEND_BACK2FRONT by default, which just sets A to 1 (framebuffer). Assuming there are no random bits being set, that would set the algorithm as (destination-source)*source_alpha>>7 + source. Maybe the alpha values in your texture prevents it from drawing?Code:gsGlobal->Test->DATE = 1 // enable gsGlobal->Test->DATM = 1 // pass if 1
Also, the PrimAlpha setting in gsGlobal needs to be set with GS_SETTING_ON or GS_SETTING_OFF as that controls whether the texture colors will have an alpha value when drawing.
For the resolution setting, for PAL, you need to set the width to a factor of 2560 and the height to a multiple of 256. The lowest resolution would be 256x256 since 256 is a factor of 2560 and 256 is a multiple of 256. The display register causes this type of of complexity in order to allow more flexible drawbuffer sizes/resolutions combinations to be set.
I think that pretty much sums that up. There's more that could go wrong, when multiple queues are involved. gsKit introduces a lot of complexity into a somewhat simple system, heh.
| « Previous Thread | Next Thread » |