2D Rotation (libgs or gsKit, etc)?

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
Spectre
Posts: 6
Joined: Fri Aug 07, 2009 12:03 pm
Location: The third dimension with two-dimensional thoughts

2D Rotation (libgs or gsKit, etc)?

Post by Spectre »

In terms of simplicity, which library would be best to use for 2D sprite rotation/animation? I've seen the awesome power of properly coded libgs applications, but can't find anything in regards to rotation... Which leads me to believe that sequentially rotated image frames would have to be preloaded into vram to get the job done. Too wasteful for my tastes, yet still functional enough to help me get by.

From what I've gathered in studying gsKit, I'd have to use textured quads for 2D sprites (much like OpenGL or DirectX8+), using gsKit_prim_sprite_texture & gsKit_prim_quad_texture_3d. I'm not too knowledgeable on using 3D math for simple 2D projections... but for rotations, I'm assuming it'd be as simple as spinning the 2D primitive from it's central origin (along the Z axis)?

Is there something I'm missing? What's the best way to get the job done?
ps2devman
Posts: 259
Joined: Mon Oct 09, 2006 3:56 pm

Post by ps2devman »

You can start with initial fantasy 3D engine.
Since you can provide your 3DS mesh and a texture, you can
easily just draw a textured square in space at a constant Z
(example supplies a textured fighter or a textured biplane)

http://minilgos.perso.sfr.fr/ps2_initial_fantasy.zip

(it uses the professional game devs method : full speed dma transferts
there is a bit of gskit just for a few text and line drawing and inits)
Fakeuser
Posts: 13
Joined: Sat Sep 01, 2007 4:18 am

Post by Fakeuser »

Hi,ps2devman,Wonderful example!Thank you!
Where can i get following examples mentioned in readme.txt?
url seems broken.

http://home.tele2.fr/~fr-51785/ps2_qbert.zip (2D sprites)
http://home.tele2.fr/~fr-51785/ps2_pong.zip (wiimote)
http://home.tele2.fr/~fr-51785/ps2_afl_pktdrv.zip (packet driver)
User avatar
ifcaro
Posts: 23
Joined: Sun Oct 19, 2008 4:11 am

Post by ifcaro »

ps2devman wrote:You can start with initial fantasy 3D engine.
Since you can provide your 3DS mesh and a texture, you can
easily just draw a textured square in space at a constant Z
(example supplies a textured fighter or a textured biplane)

http://minilgos.perso.sfr.fr/ps2_initial_fantasy.zip

(it uses the professional game devs method : full speed dma transferts
there is a bit of gskit just for a few text and line drawing and inits)
I compiled it but only reset my ps2 :S

EDIT: I added this in system.c and now works :D

Code: Select all

    gsGlobal->Mode = GS_MODE_NTSC;
    gsGlobal->Interlace = GS_INTERLACED;
    gsGlobal->Field = GS_FIELD;
    gsGlobal->Width = 640;
    gsGlobal->Height = 448;
ps2devman
Posts: 259
Joined: Mon Oct 09, 2006 3:56 pm

Post by ps2devman »

Thank you all for trying and fixing.

I had to change my ISP (my ISP got actually bought by another one)
replace http://home.tele2.fr/~fr-51785 with the new path and you
will find other files
Spectre
Posts: 6
Joined: Fri Aug 07, 2009 12:03 pm
Location: The third dimension with two-dimensional thoughts

Post by Spectre »

Umm...
ps2devman wrote:Thank you all for trying and fixing.

I had to change my ISP (my ISP got actually bought by another one)
replace http://home.tele2.fr/~fr-51785 with the new path and you
will find other files
http://minilgos.perso.sfr.fr/ps2_gasp_vcl.zip
http://minilgos.perso.sfr.fr/ps2_qbert.zip (2D sprites)
http://minilgos.perso.sfr.fr/ps2_pong.zip (wiimote)
http://minilgos.perso.sfr.fr/ps2_afl_pktdrv.zip (packet driver)

PS: Thanks, ps2devman! Very clean & informational stuff, there.
Spectre
Posts: 6
Joined: Fri Aug 07, 2009 12:03 pm
Location: The third dimension with two-dimensional thoughts

Bug

Post by Spectre »

In ./ps2_initial_fantasy/main.c:

Code: Select all

	*&#40;p++&#41;=	&#40;&#40;th&3&#41;<<30&#41;|
			&#40;tw<<26&#41;|
			&#40;texture->PSM<<20&#41;|
			&#40;texture->TBW<<14&#41;|
			&#40;texture->Vram>>8&#41;;
MINGW32 wrote:main.c: In function `init_vu1':
main.c:174: structure has no member named `TBW'
make: *** [main.o] Error 1
... Seems ../gsKit/gsInit.h doesn't have 'TBW' defined in the GSTEXTURE struct.
My gsKit version is an unedited v0.2 (and compiles just fine), if that helps.
User avatar
ifcaro
Posts: 23
Joined: Sun Oct 19, 2008 4:11 am

Re: Bug

Post by ifcaro »

Spectre wrote:In ./ps2_initial_fantasy/main.c:

Code: Select all

	*&#40;p++&#41;=	&#40;&#40;th&3&#41;<<30&#41;|
			&#40;tw<<26&#41;|
			&#40;texture->PSM<<20&#41;|
			&#40;texture->TBW<<14&#41;|
			&#40;texture->Vram>>8&#41;;
MINGW32 wrote:main.c: In function `init_vu1':
main.c:174: structure has no member named `TBW'
make: *** [main.o] Error 1
... Seems ../gsKit/gsInit.h doesn't have 'TBW' defined in the GSTEXTURE struct.
My gsKit version is an unedited v0.2 (and compiles just fine), if that helps.
I have compiled the latest code from svn and it has worked. But sometimes I get the error "ERROR: Not enough VRAM for this allocation!" when trying to make pal mode or for some reason I dont know :S
ps2devman
Posts: 259
Joined: Mon Oct 09, 2006 3:56 pm

Post by ps2devman »

dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
D_CTRL_STD_OFF, D_CTRL_RCYC_8);

...to:

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);

in system.c

(it's a note I took from other users posting fixes as well)
User avatar
ifcaro
Posts: 23
Joined: Sun Oct 19, 2008 4:11 am

Post by ifcaro »

ps2devman wrote:dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
D_CTRL_STD_OFF, D_CTRL_RCYC_8);

...to:

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);

in system.c

(it's a note I took from other users posting fixes as well)
Thanks Ps2devman but I already had it changed.

The problem was that when loading the texture, did not have enough VRAM.

I solved by disabling DoubleBuffering, I dont know if this will change something.

PS: Here is the file vu.c edited to eliminate warnings when compiling.
Post Reply