Easiest way to make a Sprite?

Graphic based area of development (Graphics Processing Unit), including the Geometry Transform Engine (GTE), TIM, STR (MDEC), etc.
Post Reply
User avatar
MihaiGamerXD
Active PSXDEV User
Active PSXDEV User
Posts: 38
Joined: Mar 09, 2019
I am a: Programmer
PlayStation Model: SCPH-1001

Easiest way to make a Sprite?

Post by MihaiGamerXD » July 27th, 2019, 9:41 am

Hello, I'm new at making sprites, and I really don't know how to make them.
Tried to follow the examples, and didn't worked.
Is there a easy way to make sprites?
Here's the source code, so you can help me:
src.zip
You do not have the required permissions to view the files attached to this post.

User avatar
Shadow
Verified
Admin / PSXDEV
Admin / PSXDEV
Posts: 2670
Joined: Dec 31, 2012
PlayStation Model: H2000/5502
Discord: Shadow^PSXDEV

Post by Shadow » July 29th, 2019, 1:11 am

There's plenty of examples on the site/forums from various users which you can use to make the PSX render a sprite.
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

Jaeger_109G6
What is PSXDEV?
What is PSXDEV?
Posts: 2
Joined: Jul 27, 2019

Post by Jaeger_109G6 » July 30th, 2019, 1:31 am

Yeah, even I managed to come up with simple ones using resources from that forum, that says a lot :lol: on a more serious note, are there tutorials for background scenes? I'm working on a shoot'em up game that features toys in shops, houses, beaches etc, and as much as I can find resources for sand and pebbles, I don't find what I need to recreate something like the inside of these houses in Larnaca :lol:

User avatar
MihaiGamerXD
Active PSXDEV User
Active PSXDEV User
Posts: 38
Joined: Mar 09, 2019
I am a: Programmer
PlayStation Model: SCPH-1001

Post by MihaiGamerXD » August 6th, 2019, 11:48 pm

Alright, finally found out how to make a sprite, I made a ball, But I want my sprite, and I don't know how to get the address of the CLUT!
I have a 16-bit TIM, and as I know, that it doesn't use CLUT, and I tried to load the sprite WITHOUT CLUT, cuz I don't know the address of the clut, and doesn't work! What should I do?
I also tried with BIN2H, but doesn't give me the CLUT address, only the image address!

User avatar
Shadow
Verified
Admin / PSXDEV
Admin / PSXDEV
Posts: 2670
Joined: Dec 31, 2012
PlayStation Model: H2000/5502
Discord: Shadow^PSXDEV

Post by Shadow » August 8th, 2019, 12:08 pm

The CLUT is contained within the TIM file itself. I can't remember the format of a TIM exactly (it's been a while since I last checked it), but if I recall, there is a header, the CLUT and then the image data itself.

There are heaps of Sony examples on how to use 4-bit or 8-bit TIM images.

EDIT: Ah, here it is http://www.psxdev.net/forum/viewtopic.php?f=51&t=109
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

User avatar
MihaiGamerXD
Active PSXDEV User
Active PSXDEV User
Posts: 38
Joined: Mar 09, 2019
I am a: Programmer
PlayStation Model: SCPH-1001

Post by MihaiGamerXD » August 10th, 2019, 12:26 am

Shadow wrote: August 8th, 2019, 12:08 pm There are heaps of Sony examples on how to use 4-bit or 8-bit TIM images.
Yeah... I searched everywhere, the examples as you say, but didn't find it!
And I only found the examples that uses "libgs", and I didn't used it, and I'm not 100% sure if there's a difference between "libgpu" (The one I used it) and "libgs".
And please let me know how to get the CLUT address, like anyone did.

Yagotzirck
Verified
Extreme PSXDEV User
Extreme PSXDEV User
Posts: 131
Joined: Jul 17, 2013

Post by Yagotzirck » August 10th, 2019, 9:17 am

It's not quite clear if you mean the CLUT address as in the x/y coordinates on VRAM, or the address inside the TIM file itself.
Assuming the latter, it really requires 1st grade algebra to figure it out...

Image

You have 8 bytes for the header and 12 bytes for CLUT-related info, therefore if the TIM file is either 4 or 8 bpp(that is, if it has a palette) and your TIM file is declared as an unsigned char array inside your code and called e.g. TIMfile, the CLUT address is (TIMfile + 20) (or &TIMfile[20], both syntaxes are equivalent).
You can find more detailed info about the TIM file format on the psyq cd, DEVREFS/FF.PDF, page 54.

Just out of curiosity, how much experience do you have in C?

User avatar
LameGuy64
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 388
Joined: Apr 10, 2013
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

Post by LameGuy64 » August 10th, 2019, 3:00 pm

If you want to do a scrolling background, you'll also have to look into drawing tilemaps on the PS1. Basically, you're going to put together a tile sheet, then composite them together with a tilemap editor like Tiled (think that's the name of the open source tile map editor), and finally write a conversion tool that converts the XML file Tiled produces into a byte by byte array of tile numbers, so you can use the data much more easily on the PS1.
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.

User avatar
MihaiGamerXD
Active PSXDEV User
Active PSXDEV User
Posts: 38
Joined: Mar 09, 2019
I am a: Programmer
PlayStation Model: SCPH-1001

Post by MihaiGamerXD » August 11th, 2019, 1:07 am

Yagotzirck wrote: August 10th, 2019, 9:17 am It's not quite clear if you mean the CLUT address as in the x/y coordinates on VRAM, or the address inside the TIM file itself.
No, you don't know what is CLUT address, the CLUT address is like this:
► Show Spoiler
LameGuy64 wrote: August 10th, 2019, 3:00 pm If you want to do a scrolling background, you'll also have to look into drawing tilemaps on the PS1.
No, I'm not doing a scrolling background, just a sprite, remember... Just a SPRITE.

Yagotzirck
Verified
Extreme PSXDEV User
Extreme PSXDEV User
Posts: 131
Joined: Jul 17, 2013

Post by Yagotzirck » August 11th, 2019, 2:30 am

MihaiGamerXD wrote: August 11th, 2019, 1:07 am
Yagotzirck wrote: August 10th, 2019, 9:17 am It's not quite clear if you mean the CLUT address as in the x/y coordinates on VRAM, or the address inside the TIM file itself.
No, you don't know what is CLUT address, the CLUT address is like this:
[...]
No, no and NO; what you posted is an array definition containing a collection of CLUTs for 4bpp images/sprites, not a "CLUT address" :roll:
If you have a paletted TIM file converted with BIN2H you can access the CLUT in precisely the same way I described in my previous post.

Now I don't mean to patronize you nor to sound like a dick, but grab a good C book, read it front to back doing all the exercises at the end of each chapter and then you can come back and attempt PSX programming in a proper way, because it's obvious you're lacking the basics at this point.
It might not be particularly fun, but like someone said a while ago:
He who loves practice without theory is like the sailor who boards ship without a rudder and compass and never knows where he may cast.

User avatar
MihaiGamerXD
Active PSXDEV User
Active PSXDEV User
Posts: 38
Joined: Mar 09, 2019
I am a: Programmer
PlayStation Model: SCPH-1001

Post by MihaiGamerXD » August 11th, 2019, 4:05 am

Yagotzirck wrote: August 11th, 2019, 2:30 am No, no and NO; what you posted is an array definition containing a collection of CLUTs for 4bpp images/sprites, not a "CLUT address" :roll:
Oh sorry, I didn't know what is that mean, and that's what I think is, but... How can I get the CLUT array? (Is that fine?) After converting a 16-bit TIM with BIN2H, it doesn't show me the CLUT array in the header file, only the image array. Even converting an 8-bit TIM, the same problem! :(
Yagotzirck wrote: August 11th, 2019, 2:30 am If you have a paletted TIM file converted with BIN2H you can access the CLUT in precisely the same way I described in my previous post.
Yes, but how? I can't understand nothing in that image. :shrug
Yagotzirck wrote: August 11th, 2019, 2:30 am Now I don't mean to patronize you nor to sound like a dick, but grab a good C book, read it front to back doing all the exercises at the end of each chapter and then you can come back and attempt PSX programming in a proper way, because it's obvious you're lacking the basics at this point.
It might not be particularly fun, but like someone said a while ago:
He who loves practice without theory is like the sailor who boards ship without a rudder and compass and never knows where he may cast.
I already know programming, what are you talking about? :|
It's so hard to get the CLUT array! Or if I'm wrong and it's easy, then show me how can I get the CLUT array.

Yagotzirck
Verified
Extreme PSXDEV User
Extreme PSXDEV User
Posts: 131
Joined: Jul 17, 2013

Post by Yagotzirck » August 11th, 2019, 4:46 am

MihaiGamerXD wrote: August 11th, 2019, 4:05 am I already know programming, what are you talking about? :|
Your posts regarding such basic issues would say otherwise, but I'll give you the benefit of the doubt :D
Oh sorry, I didn't know what is that mean, and that's what I think is, but... How can I get the CLUT array? (Is that fine?)
I'll repeat it one more time: if the image is 4bpp or 8bpp the CLUT's offset is 20 bytes from the beginning of the file.
So, if your TIM array is called TIMfile, all you have to do is

Code: Select all

unsigned short *TIMfileCLUT = (unsigned short*)(TIMfile + 20);
I declared it as unsigned short* since that's the size of the CLUT entries, but I don't think it should make a difference depending on what you want to use it for.
After converting a 16-bit TIM with BIN2H, it doesn't show me the CLUT array in the header file, only the image array. Even converting an 8-bit TIM, the same problem! :(
First off, a 16bpp TIM doesn't have a CLUT since it's pretty much a high color image.
Anyway I don't think you understand how BIN2H works - all it does is picking a file and converting it to an array of bytes in hex format for use inside C programs, it won't separate the various fields inside the file because it doesn't know anything about the internal file structure.
What you're seeing in that array isn't image data, it's header fields, CLUT and image data all mixed together, it's up to YOU to give it some sense by creating structures/variables/arrays that point to the respective offsets.
I already told you how to access the CLUT, I'll let you figure the other fields' offsets out on your own as an exercise ;) (Hint: use the image I posted in this thread as a reference)

User avatar
LameGuy64
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 388
Joined: Apr 10, 2013
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

Post by LameGuy64 » August 11th, 2019, 11:36 am

MihaiGamerXD wrote: August 11th, 2019, 1:07 am No, I'm not doing a scrolling background, just a sprite, remember... Just a SPRITE.
Ah, I wasn't paying enough attention... My bad.

Judging by what I've sifted through your code so far, it appears you're mixing libgpu and libgs stuff, but your main.c does not appear to be initializing libgs. Your timlib.c has code to not only load the TIM to VRAM but also to prepare a GsSPRITE struct which should be a matter of using GsSortSprite() to sort it to a Gs_OT. Using libgs and GsSPRITEs is the easiest way to draw a sprite. I recommend you start out with code from the hello world example in this forum, which from what I remember initializes libgs.

If you want to know mow about how graphics are done on the PS1 (without using libgs, which is preferable as it provides less overhead) you may want to check out my PS1 Tutorial Series which you can find in this page of my website. Its currently a work in progress but what is implemented covers essential things about ordering tables and primitive buffers.

Use annoyingmous on both username and password to access the SVN repository. I chose SVN because its easier to update it that way.
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.

User avatar
MihaiGamerXD
Active PSXDEV User
Active PSXDEV User
Posts: 38
Joined: Mar 09, 2019
I am a: Programmer
PlayStation Model: SCPH-1001

Post by MihaiGamerXD » December 20th, 2019, 2:32 am

LameGuy64 wrote: August 11th, 2019, 11:36 am Ah, I wasn't paying enough attention... My bad.

Judging by what I've sifted through your code so far, it appears you're mixing libgpu and libgs stuff, but your main.c does not appear to be initializing libgs. Your timlib.c has code to not only load the TIM to VRAM but also to prepare a GsSPRITE struct which should be a matter of using GsSortSprite() to sort it to a Gs_OT. Using libgs and GsSPRITEs is the easiest way to draw a sprite. I recommend you start out with code from the hello world example in this forum, which from what I remember initializes libgs.

If you want to know mow about how graphics are done on the PS1 (without using libgs, which is preferable as it provides less overhead) you may want to check out my PS1 Tutorial Series which you can find in this page of my website. Its currently a work in progress but what is implemented covers essential things about ordering tables and primitive buffers.

Use annoyingmous on both username and password to access the SVN repository. I chose SVN because its easier to update it that way.
I already found out how to make a sprite!
The easiest way is to Get Texture page into VRAM, and then sort a sprite from that texture.
Same as libgs.h. Thanks for helping me, and this is what I did!
Sprites with image.bmp
Those fonts ("Space Planes", "New Game" and "Help") are the sprites, and the background image is directly loaded into VRAM (on the screen) without sorting a sprite.
I hope I can get back to work in 3D models.
And if my english is bad, then sorry.
You do not have the required permissions to view the files attached to this post.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests