Hello PSXDEV.
It is possible to make full random num. generator using something like that?
srand(time(NULL));
Found RAND/SRAND in C:/Psyq/include/RAND.H
I am not sure about "time()" in PS1...
Thanks c:
RAND and SRAND?
-
NITROYUASH Verified
- Serious PSXDEV User
- Posts: 124
- Joined: Jan 07, 2018
- I am a: Game Designer
- PlayStation Model: SCPH-5502
- Location: Russian Federation
- Contact:
-
Shadow Verified
- Admin / PSXDEV
- Posts: 2670
- Joined: Dec 31, 2012
- PlayStation Model: H2000/5502
- Discord: Shadow^PSXDEV
Yes, use random with the root counter.
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.
-
NITROYUASH Verified
- Serious PSXDEV User
- Posts: 124
- Joined: Jan 07, 2018
- I am a: Game Designer
- PlayStation Model: SCPH-5502
- Location: Russian Federation
- Contact:
Huh, something like that?
SetRCnt(RCntCNT3,0,RCntMdNOINTR); RandomTimer = (GetRCnt(RCntCNT3)); srand(RandomTimer); Random = (rand() % 8);
-
Shadow Verified
- Admin / PSXDEV
- Posts: 2670
- Joined: Dec 31, 2012
- PlayStation Model: H2000/5502
- Discord: Shadow^PSXDEV
Code: Select all
///////////////////////////////////////////////////////////
// Random Number Generator
// --------------------------------------------------------
// returns a random number that does
// not exceed the maximum parsed value
// --------------------------------------------------------
// EG: Random(5) will return either 0,1,2,3 or 4
///////////////////////////////////////////////////////////
int Random(int max)
{
srand(GetRCnt(0)); // initialise the random seed generator
return(rand()%max); // return a random number based off of 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.
-
NITROYUASH Verified
- Serious PSXDEV User
- Posts: 124
- Joined: Jan 07, 2018
- I am a: Game Designer
- PlayStation Model: SCPH-5502
- Location: Russian Federation
- Contact:
It's working. Thanks c:
Code: Select all
int SetRandomNUM(int maxnum) {
srand(GetRCnt(0));
RNum = (rand() % maxnum);
return RNum;
}
- MrQuetch
- Active PSXDEV User
- Posts: 42
- Joined: Apr 01, 2018
- I am a: Programmer and artist.
- Motto: You can accomplish anything.
- Location: United States
This is really late. But, I just recently found the 'GsGetVcount' function. That may be helpful in getting a completely random number - besides the other methods already mentioned here. The vertical retraces happen really fast, so it seems reasonable.
Who is online
Users browsing this forum: No registered users and 4 guests