improved the randomizer logic
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
PROJNAME=scoundrel
|
PROJNAME=scoundrel
|
||||||
CFILES=scoundrel.c
|
CFILES=scoundrel.c
|
||||||
PBTDIR=platform-build-tools
|
PBTDIR=platform-build-tools
|
||||||
CCBUILD=cl65 --standard c89 -O -Os
|
CCBUILD=cl65 -O -Os
|
||||||
Z80BUILD=zcc
|
Z80BUILD=zcc
|
||||||
BUILDDIR=build
|
BUILDDIR=build
|
||||||
|
|
||||||
|
|||||||
+17
-18
@@ -11,7 +11,9 @@
|
|||||||
#if defined(__CC65__) || defined(__Z80__)
|
#if defined(__CC65__) || defined(__Z80__)
|
||||||
#define RETRO_IMPL
|
#define RETRO_IMPL
|
||||||
#endif
|
#endif
|
||||||
#ifndef RETRO_IMPL
|
#ifdef RETRO_IMPL
|
||||||
|
#include <conio.h>
|
||||||
|
#else
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -21,21 +23,22 @@ char scanchar() {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RETRO_IMPL
|
|
||||||
void randomize() {
|
void randomize() {
|
||||||
int seed = 0, i, x, n = 6;
|
#ifdef RETRO_IMPL
|
||||||
printf("\nType %d characters: ", n);
|
unsigned int entropy;
|
||||||
for(i=0;i<n;i++) {
|
#ifdef _randomize
|
||||||
x = (int) scanchar();
|
_randomize();
|
||||||
x ^= x << 7;
|
|
||||||
x ^= x >> 9;
|
|
||||||
x ^= x << 8;
|
|
||||||
seed ^= x;
|
|
||||||
}
|
|
||||||
srand(seed);
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
entropy = rand();
|
||||||
|
clrscr();
|
||||||
|
puts("Press any key to start...");
|
||||||
|
while(!kbhit()) entropy++;
|
||||||
|
cgetc();
|
||||||
|
srand(entropy);
|
||||||
|
#else
|
||||||
|
srand(time(NULL));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* UI choices */
|
/* UI choices */
|
||||||
#define CH1 0
|
#define CH1 0
|
||||||
@@ -346,11 +349,7 @@ int game() {
|
|||||||
/* Entry point */
|
/* Entry point */
|
||||||
int main() {
|
int main() {
|
||||||
int score;
|
int score;
|
||||||
#ifdef RETRO_IMPL
|
|
||||||
randomize();
|
randomize();
|
||||||
#else
|
|
||||||
srand(time(NULL));
|
|
||||||
#endif
|
|
||||||
while(1) {
|
while(1) {
|
||||||
print_msg("\n===============\nScoundrel--2026\n by Luxferre\n===============\n Good luck!");
|
print_msg("\n===============\nScoundrel--2026\n by Luxferre\n===============\n Good luck!");
|
||||||
score = game();
|
score = game();
|
||||||
|
|||||||
Reference in New Issue
Block a user