New Member - hi everyone! :D / help drawing a primitive

Post a topic about yourself to let others know your skills, hobbies, etc.
Post Reply
User avatar
ViLXDRYAD
Curious PSXDEV User
Curious PSXDEV User
Posts: 19
Joined: May 3rd, 2018, 1:17 pm
I am a: Avocado lover
IRC: ViLXDRYAD
Motto: FR E SH A VOCA DO
PlayStation Model: SCPH1001
Want to Find: a good time! :D
Looking to: help/write psy-q examples

New Member - hi everyone! :D / help drawing a primitive

Post by ViLXDRYAD » May 9th, 2018, 2:49 pm

Hi! i'm glad to see an active ps1 development community nowadays, also with so nice members! = D

been coding on psy-q for the past two weeks and it's very fun so far!

i got lost at how to draw a primitive by using an order table, can't really understand how the process is like; i've coded some stuff in C & OpenGL as well as a demo prod for pc, and so far i can tell the concept is way more abstract lol i'd really appreciate a hint on how to draw a primitive if possible :D

aside that, i can't wait to get involved in this community, seems like a really warm family, i look forward to have fun together! x3

User avatar
Shadow
Admin / PSXDEV
Admin / PSXDEV
Posts: 2405
Joined: December 31st, 2012, 5:37 pm
PlayStation Model: H2000/5502

Re: New Member - hi everyone! :D / help drawing a primitive

Post by Shadow » May 10th, 2018, 12:04 am

Code: Select all

POLY_F4 pf4;

void DrawSolidTri(short x1, short y1, short x2, short y2, short x3, short y3, int r, int g, int b, int ot)
{
	// draw a solid triangle and fill it with rgb colour
	// EG: DrawSolidTri(200,0, 170,30, 230,30, 255,0,255, 0);
	// check the Psy-Q documentation for the coordinates!

	SetPolyF3(&pf3);							// initialise the primitive
	setRGB0(&pf3, r, g, b);						// set the fill colour (RGB)
	setXY3(&pf3, x1,y1, x2,y2, x3,y3);			// draw 3 lines (3 sets of x/y co-ords)
	DrawPrim(&pf3);								// copy shape to frame buffer
	//DrawPrim(&pf3);							// copy shape to frame buffer
	GsSortPoly(&pf3, &WorldOrderingTable1[CurrentBuffer], ot); // put the polygon into the order table
}


void DrawTransTri(short x1, short y1, short x2, short y2, short x3, short y3, int r, int g, int b, int ot)
{
	// draw a transparent triangle
	// the transparency 'colour' is calculated from the fgnd & bgns pixels.
	// EG: DrawTransTri(50,0, 70,60, 130,60, 255,0,255, 0);

	SetPolyF3(&pf3);							// initialize primitive
	setRGB0(&pf3, r, g, b);						// set the foreground fill colour
	setSemiTrans(&pf3, 1);						// semi-transparency; 0=off; 1=on
	setXY3(&pf3, x1,y1, x2,y2, x3,y3);			// draw 4 lines (4 sets of x/y co-ords)
	//DrawPrim(&pf3);							// copy shape to frame buffer
	GsSortPoly(&pf3, &WorldOrderingTable1[CurrentBuffer], ot); // put the polygon into the order table
}
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
ViLXDRYAD
Curious PSXDEV User
Curious PSXDEV User
Posts: 19
Joined: May 3rd, 2018, 1:17 pm
I am a: Avocado lover
IRC: ViLXDRYAD
Motto: FR E SH A VOCA DO
PlayStation Model: SCPH1001
Want to Find: a good time! :D
Looking to: help/write psy-q examples

Re: New Member - hi everyone! :D / help drawing a primitive

Post by ViLXDRYAD » May 10th, 2018, 2:19 am

Hii, Shadow! = D first of all thanks for your help! x3

i modified a bit the code for it to work with the order table name i had (i'm using the hello world tutorial from here: http://www.psxdev.net/help/psyq_hello_world.html as a base for this so it is easier to read)

Code: Select all

GsSortPoly(&pf3, &myOT[CurrentBuffer], ot); // put the polygon into the order table
also modified POLY_F4 pf4; to POLY_F3 pf3; and compiled just fine :D

BUT when i try to draw the triangle on the main function, the triangle gets displayed for one frame and i get a Bad Opcode error on NO$PSX, i tried to draw it using this:

Code: Select all

DrawSolidTri(0, 0, 200, 200, 0, 300, 4, 255, 4, 0);
and this is how it looks like:
Image

this is the full code:
https://pastebin.com/BW8QStPZ

may i ask what i am doing wrong? :C thaanks a lot, beforehand! x3

User avatar
Shadow
Admin / PSXDEV
Admin / PSXDEV
Posts: 2405
Joined: December 31st, 2012, 5:37 pm
PlayStation Model: H2000/5502

Re: New Member - hi everyone! :D / help drawing a primitive

Post by Shadow » May 10th, 2018, 2:26 am

Are you compiling with code optimisation enabled? If so, disable it.
Otherwise, it could be a bug in NO$PSX, so maybe just disable warnings.
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
ViLXDRYAD
Curious PSXDEV User
Curious PSXDEV User
Posts: 19
Joined: May 3rd, 2018, 1:17 pm
I am a: Avocado lover
IRC: ViLXDRYAD
Motto: FR E SH A VOCA DO
PlayStation Model: SCPH1001
Want to Find: a good time! :D
Looking to: help/write psy-q examples

Re: New Member - hi everyone! :D / help drawing a primitive

Post by ViLXDRYAD » May 10th, 2018, 4:12 am

thanks for your reply! :D

@code optimization enabled: i didn't knew about that; may i ask where i can disable it? = 3 i use Windows 98 SE for deving so working on NO$PSX is way more efficient than moving the exe to a newer OS to test in PCSXR :C

@a bug in NO$PSX: i went and wrote a test to see if it ran correctly on PCSXR and turns out the same exe that pops that error in NO$PSX (also tried disabling the warnings and the screen just freezes) runs as intended there:
Image

(here's the source code: https://pastebin.com/hqkyXBMp also has comments)

hopefully it is that code optimization option, otherwise it is odd since NO$PSX runs the other psy-q examples using primitives D:

User avatar
Shadow
Admin / PSXDEV
Admin / PSXDEV
Posts: 2405
Joined: December 31st, 2012, 5:37 pm
PlayStation Model: H2000/5502

Re: New Member - hi everyone! :D / help drawing a primitive

Post by Shadow » May 11th, 2018, 3:28 am

The code optimisation is in the makefile. It's the "-O" parameter followed by level 1, 2 or 3. EG: "-O3" for level 3 optimisation.
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
Greg
Serious PSXDEV User
Serious PSXDEV User
Posts: 101
Joined: September 9th, 2013, 1:27 am
PlayStation Model: SCPH-7501
Location: Port-au-Prince, HAITI

Re: New Member - hi everyone! :D / help drawing a primitive

Post by Greg » May 11th, 2018, 11:23 am

Change #define PACKETMAX 50 to #define PACKETMAX 500
1 x SCPH-7501, 2 x SCPH-7001, 2 x SCPH-5501
1 x Pro Action Replay with "Dual Rom Mod", ROM 1: Caetla, ROM 2: UNIROM
1 x Xplorer V2 with Caetla
1 x GameShark V2.1
1 x GameShark Pro V3.0
1 x CommLinkUSB
1 x XLinkUSB

User avatar
ViLXDRYAD
Curious PSXDEV User
Curious PSXDEV User
Posts: 19
Joined: May 3rd, 2018, 1:17 pm
I am a: Avocado lover
IRC: ViLXDRYAD
Motto: FR E SH A VOCA DO
PlayStation Model: SCPH1001
Want to Find: a good time! :D
Looking to: help/write psy-q examples

Re: New Member - hi everyone! :D / help drawing a primitive

Post by ViLXDRYAD » May 11th, 2018, 12:08 pm

thaanks for your replies! :D

@ code optimisation option in makefile: i tried erasing the -O3 in it, and still the same error :c also tried with -O1 and -O2, though thanks for this hint! i didn't knew code optimisation was a thing before! x3

@ changing #define PACKETMAX 50 to #define PACKETMAX 500: YES! this did it! +O+ it ran beautifully on NO$PSX after that! :D

thaanks you so much, Greg and Shadow for all your great help! i really appreciate it! x3 gonna make sure i put you into the greets of what i'm working into = p, it wouldn't be possible without you! = D

User avatar
Shadow
Admin / PSXDEV
Admin / PSXDEV
Posts: 2405
Joined: December 31st, 2012, 5:37 pm
PlayStation Model: H2000/5502

Re: New Member - hi everyone! :D / help drawing a primitive

Post by Shadow » May 11th, 2018, 4:28 pm

Greg wrote:
May 11th, 2018, 11:23 am
Change #define PACKETMAX 50 to #define PACKETMAX 500
Ah, that would also help a bit. I forgot that the 'Hello World' code was optimised for the absolute minimum ;)
Nice thinking Greg :)
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.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests