improved the randomizer logic

This commit is contained in:
Luxferre
2026-01-07 09:07:35 +02:00
parent 03a7f8a230
commit 03ac94f387
2 changed files with 18 additions and 19 deletions
+17 -18
View File
@@ -11,7 +11,9 @@
#if defined(__CC65__) || defined(__Z80__)
#define RETRO_IMPL
#endif
#ifndef RETRO_IMPL
#ifdef RETRO_IMPL
#include <conio.h>
#else
#include <time.h>
#endif
@@ -21,21 +23,22 @@ char scanchar() {
return c;
}
#ifdef RETRO_IMPL
void randomize() {
int seed = 0, i, x, n = 6;
printf("\nType %d characters: ", n);
for(i=0;i<n;i++) {
x = (int) scanchar();
x ^= x << 7;
x ^= x >> 9;
x ^= x << 8;
seed ^= x;
}
srand(seed);
printf("\n");
}
#ifdef RETRO_IMPL
unsigned int entropy;
#ifdef _randomize
_randomize();
#endif
entropy = rand();
clrscr();
puts("Press any key to start...");
while(!kbhit()) entropy++;
cgetc();
srand(entropy);
#else
srand(time(NULL));
#endif
}
/* UI choices */
#define CH1 0
@@ -346,11 +349,7 @@ int game() {
/* Entry point */
int main() {
int score;
#ifdef RETRO_IMPL
randomize();
#else
srand(time(NULL));
#endif
while(1) {
print_msg("\n===============\nScoundrel--2026\n by Luxferre\n===============\n Good luck!");
score = game();