Page 1 of 1

Easiest way to make a Sprite?

Posted: July 27th, 2019, 9:41 am
by MihaiGamerXD
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

Re: Easiest way to make a Sprite?

Posted: July 29th, 2019, 1:11 am
by Shadow
There's plenty of examples on the site/forums from various users which you can use to make the PSX render a sprite.

Re: Easiest way to make a Sprite?

Posted: July 30th, 2019, 1:31 am
by Jaeger_109G6
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:

Re: Easiest way to make a Sprite?

Posted: August 6th, 2019, 11:48 pm
by MihaiGamerXD
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!

Re: Easiest way to make a Sprite?

Posted: August 8th, 2019, 12:08 pm
by Shadow
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

Re: Easiest way to make a Sprite?

Posted: August 10th, 2019, 12:26 am
by MihaiGamerXD
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.

Re: Easiest way to make a Sprite?

Posted: August 10th, 2019, 9:17 am
by Yagotzirck
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?

Re: Easiest way to make a Sprite?

Posted: August 10th, 2019, 3:00 pm
by LameGuy64
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.

Re: Easiest way to make a Sprite?

Posted: August 11th, 2019, 1:07 am
by MihaiGamerXD
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.

Re: Easiest way to make a Sprite?

Posted: August 11th, 2019, 2:30 am
by Yagotzirck
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.

Re: Easiest way to make a Sprite?

Posted: August 11th, 2019, 4:05 am
by MihaiGamerXD
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.

Re: Easiest way to make a Sprite?

Posted: August 11th, 2019, 4:46 am
by Yagotzirck
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)

Re: Easiest way to make a Sprite?

Posted: August 11th, 2019, 11:36 am
by LameGuy64
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.

Re: Easiest way to make a Sprite?

Posted: December 20th, 2019, 2:32 am
by MihaiGamerXD
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.