Newbie wanting help
Newbie wanting help
OK, so I've been making my game, slowly, and it works OK, but I do have a few questions.
#1. How would I make it so I can have more than one place to draw graphics from? I'm using TIM tool and am having success in adding new images to it, but I figure sometime soon, the CLUT will be all filled up. Is there a way to switch or add a CLUT so I can have more images? How would I do so in the code?
#2. How do I display text? Any font will do. I tried printf and no text showed up.
If you want to look at my code, you can find it here:
http://www.atari2600land.com/jackandthebeanstalk/
#1. How would I make it so I can have more than one place to draw graphics from? I'm using TIM tool and am having success in adding new images to it, but I figure sometime soon, the CLUT will be all filled up. Is there a way to switch or add a CLUT so I can have more images? How would I do so in the code?
#2. How do I display text? Any font will do. I tried printf and no text showed up.
If you want to look at my code, you can find it here:
http://www.atari2600land.com/jackandthebeanstalk/
Jack and the Beanstalk:
http://www.atari2600land.com/jackandthebeanstalk
http://www.atari2600land.com/jackandthebeanstalk
-
Shendo Verified
- C Programming Expert
- Posts: 250
- Joined: Mar 21, 2012
- I am a: Programmer
- Motto: Never settle
- PlayStation Model: SCPH-7502
- Discord: ShendoXT
- Location: Croatia, EU
You can place CLUT anywhere in the VRAM. I'm not sure I understand when you say that it will all be filled up...
As for displaying text you can use FntPrint() function. printf is for debug only and is usually used on serial port..
However I encurage you to write your own text displaying routine because FntPrint is pretty limited.
As for displaying text you can use FntPrint() function. printf is for debug only and is usually used on serial port..
However I encurage you to write your own text displaying routine because FntPrint is pretty limited.
Dev console: SCPH-7502, FreePSXBoot, CH340 serial cable.
OK, so suppose I have an image starting at 0,0. So how would I make it read a different image at 0,0? Or would you just have different CLUTs? I will try FntPrint() first and see how that works.
Jack and the Beanstalk:
http://www.atari2600land.com/jackandthebeanstalk
http://www.atari2600land.com/jackandthebeanstalk
-
Shendo Verified
- C Programming Expert
- Posts: 250
- Joined: Mar 21, 2012
- I am a: Programmer
- Motto: Never settle
- PlayStation Model: SCPH-7502
- Discord: ShendoXT
- Location: Croatia, EU
First I would suggest to just go with 16 bit images to avoid using CLUTs.
Once you manage that then start using palletized images.
You should upload image to VRAM outside of your display buffer (usually 320,0 should suffice) and then make a sprite out of it. After that set up a game loop and draw that sprite each frame.
Once you manage that then start using palletized images.
You should upload image to VRAM outside of your display buffer (usually 320,0 should suffice) and then make a sprite out of it. After that set up a game loop and draw that sprite each frame.
Dev console: SCPH-7502, FreePSXBoot, CH340 serial cable.
OK, so when I go into TimTool to make a new image, I select 16 bit colors. So does that mean I haven't been using CLUTs at all and so I could put the sprite at any position?
Jack and the Beanstalk:
http://www.atari2600land.com/jackandthebeanstalk
http://www.atari2600land.com/jackandthebeanstalk
-
Administrator Verified
- Admin / PSXDEV
- Posts: 2691
- Joined: Dec 31, 2012
- I am a: Shadow
- PlayStation Model: H2000/5502
16-bit TIM's don't use CLUT's. You don't need to worry about it if they are 16-bits (just like Shendo said).
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.
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.
I have a tree sprite. I want multiple copies of the tree sprite scattered various places, like a pattern. How would I do this? The pattern of the trees would change once you clear the screen.
Jack and the Beanstalk:
http://www.atari2600land.com/jackandthebeanstalk
http://www.atari2600land.com/jackandthebeanstalk
-
Administrator Verified
- Admin / PSXDEV
- Posts: 2691
- Joined: Dec 31, 2012
- I am a: Shadow
- PlayStation Model: H2000/5502
If you want them in a pattern, then you should use a predefined array for the TIM's X and Y position on the screen.
I'm confused by your second line " The pattern of the trees would change once you clear the screen.". It contradicts your first argument stating it's not random. If it's not random, then an array will work. Otherwise, you will need to use the random function within Psy-Q. Additional logic will be required to ensure that you do not get trees overlapping and being placed too close to one another.
I'm confused by your second line " The pattern of the trees would change once you clear the screen.". It contradicts your first argument stating it's not random. If it's not random, then an array will work. Otherwise, you will need to use the random function within Psy-Q. Additional logic will be required to ensure that you do not get trees overlapping and being placed too close to one another.
Code: Select all
int Random(int max) { return (rand()%max); }
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.
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.
Well, I would want the trees in specific various places, not randomly, like to create a maze of trees that the player must navigate through.
Jack and the Beanstalk:
http://www.atari2600land.com/jackandthebeanstalk
http://www.atari2600land.com/jackandthebeanstalk
-
Administrator Verified
- Admin / PSXDEV
- Posts: 2691
- Joined: Dec 31, 2012
- I am a: Shadow
- PlayStation Model: H2000/5502
Ah, well a hardcoded array will suffice nicely then 

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.
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.
But before I attempt to do that, a new problem popped up. It seems that moving Jack left or up glitches up all the sprites until he gets to near the top. I don't know what's causing this.
You do not have the required permissions to view the files attached to this post.
Jack and the Beanstalk:
http://www.atari2600land.com/jackandthebeanstalk
http://www.atari2600land.com/jackandthebeanstalk
-
Administrator Verified
- Admin / PSXDEV
- Posts: 2691
- Joined: Dec 31, 2012
- I am a: Shadow
- PlayStation Model: H2000/5502
Looks like you're overwriting something.
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.
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.
Or you got something wrong when you tried to scroll-down the screen when moving-up?
Using a VRAM Viewer that can display the whole 1024x512 pixel video memory (=not just the display area) might help you to figure out what's going on.
Using a VRAM Viewer that can display the whole 1024x512 pixel video memory (=not just the display area) might help you to figure out what's going on.
I fixed that problem I was having. Seems like I was calling something when I wasn't supposed to be.
About arrays, then, I have been using the sample code for displaying a picture. Would I be able to shorten the code a lot when I put it in one? Here's the code I am using to display one tree:
About arrays, then, I have been using the sample code for displaying a picture. Would I be able to shorten the code a lot when I put it in one? Here's the code I am using to display one tree:
Code: Select all
RECT rect; // RECT structure
GsIMAGE tim_data; // holds tim graphic info
// put data from the raw binary header file into rect
GsGetTimInfo((u_long *)(treetoruninto+4),&tim_data);
// load the image into the frame buffer
rect.x = tim_data.px; // tim start X coord
rect.y = tim_data.py; // tim start Y coord
rect.w = tim_data.pw; // data width
rect.h = tim_data.ph; // data height
// load the tim data into the frame buffer
LoadImage(&rect, tim_data.pixel);
// load the CLUT into the frame buffer
rect.x = tim_data.cx; // x pos in frame buffer
rect.y = tim_data.cy; // y pos in frame buffer
rect.w = tim_data.cw; // width of CLUT
rect.h = tim_data.ch; // height of CLUT
// load data into frame buffer (DMA from DRAM to VRAM)
LoadImage(&rect, tim_data.clut);
// initialise sprite
treea.attribute=0x2000000; // 16 bit CLUT, all options off (0x1 = 8-bit, 0x2 = 16-bit)
treea.x = treeax; // draw at x coord 0
treea.y = treeay; // draw at y coord 0
treea.w = 15; // width of sprite
treea.h = 42; // height of sprite
// texture mode (0 4-bit, 1 8-bit, 2 16-bit), semi-transparency rate, texture x, texture y in the framebuffer
treea.tpage=GetTPage(2, 1, 896, 0);
treea.r = 128; // RGB Data
treea.g = 128;
treea.b = 128;
treea.u=0; // position within timfile for sprite
treea.v=0;
treea.cx = tim_data.cx; // CLUT location x coord
treea.cy = tim_data.cy; // CLUT location y coord
treea.r=treea.g=treea.b=128; // normal luminosity
treea.mx = 0; // rotation x coord
treea.my = 0; // rotation y coord
treea.scalex = ONE; // scale x coord (ONE = 100%)
treea.scaley = ONE; // scale y coord (ONE = 100%)
treea.rotate = 0; // degrees to rotate
Jack and the Beanstalk:
http://www.atari2600land.com/jackandthebeanstalk
http://www.atari2600land.com/jackandthebeanstalk
I learned about arrays, I think I learned how to understand them, but what I don't understand is how to make multiple copies(in this case, trees), out of the same image. As a test, I did an array from 0-4 and I only got one tree to display at the last array point. What do I do?
int treesxscreen1 [5] = { 30, 70, 140, 170, 230 };
int treesxscreen1 [5] = { 30, 70, 140, 170, 230 };
Jack and the Beanstalk:
http://www.atari2600land.com/jackandthebeanstalk
http://www.atari2600land.com/jackandthebeanstalk
-
Administrator Verified
- Admin / PSXDEV
- Posts: 2691
- Joined: Dec 31, 2012
- I am a: Shadow
- PlayStation Model: H2000/5502
You need to tell the function to use treesxscreen1 but increment through the array of 1 to 5.
At the moment, you have, but it's using the last integer in the array (230) which would be 5.
At the moment, you have, but it's using the last integer in the array (230) which would be 5.
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.
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.
Well, even if I do this, it still displays one tree:
Code: Select all
treea.x = treesxscreen1[0]; // draw at x coord 0
treea.y = treesxscreen1[0]; // draw at y coord 0
treea.x = treesxscreen1[1]; // draw at x coord 0
treea.y = treesxscreen1[1];
treea.x = treesxscreen1[2]; // draw at x coord 0
treea.y = treesxscreen1[2]; // draw at y coord 0
treea.x = treesxscreen1[3]; // draw at x coord 0
treea.y = treesxscreen1[3];
treea.x = treesxscreen1[4]; // draw at x coord 0
treea.y = treesxscreen1[4]; // draw at y coord 0
Jack and the Beanstalk:
http://www.atari2600land.com/jackandthebeanstalk
http://www.atari2600land.com/jackandthebeanstalk
-
Administrator Verified
- Admin / PSXDEV
- Posts: 2691
- Joined: Dec 31, 2012
- I am a: Shadow
- PlayStation Model: H2000/5502
Of course it will 
It's setting them, yes, but it's doing them in order so the variable is being overwritten.
So, the last one will be the one set (treea.x = treesxscreen1[4]; treea.y = treesxscreen1[4]
You need to do looping/routine logic. Something like this (note, this is just a crude example!):

It's setting them, yes, but it's doing them in order so the variable is being overwritten.
So, the last one will be the one set (treea.x = treesxscreen1[4]; treea.y = treesxscreen1[4]

You need to do looping/routine logic. Something like this (note, this is just a crude example!):
Code: Select all
for(;;)
{
// if the tree is off the screen, update the position
if (treea.x < 0) { treea.x = treesxscreen1[0]; treea.y = treesxscreen1[0]; }
if (treea.x == 100) { treea.x = treesxscreen1[1]; treea.y = treesxscreen1[1]; }
// and so on...
}
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.
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.
If I try to do any for statement beginning with for(;;) the game freezes.
Jack and the Beanstalk:
http://www.atari2600land.com/jackandthebeanstalk
http://www.atari2600land.com/jackandthebeanstalk
OK, I understand why now.
Jack and the Beanstalk:
http://www.atari2600land.com/jackandthebeanstalk
http://www.atari2600land.com/jackandthebeanstalk
Who is online
Users browsing this forum: No registered users and 6 guests