From 03ac94f3875bd81c1806da4fa4c7b9f13fb33010 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Wed, 7 Jan 2026 09:07:35 +0200 Subject: [PATCH] improved the randomizer logic --- c/Makefile | 2 +- c/scoundrel.c | 35 +++++++++++++++++------------------ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/c/Makefile b/c/Makefile index 754a916..65ed628 100644 --- a/c/Makefile +++ b/c/Makefile @@ -3,7 +3,7 @@ PROJNAME=scoundrel CFILES=scoundrel.c PBTDIR=platform-build-tools -CCBUILD=cl65 --standard c89 -O -Os +CCBUILD=cl65 -O -Os Z80BUILD=zcc BUILDDIR=build diff --git a/c/scoundrel.c b/c/scoundrel.c index 0d56d3a..8a3628a 100644 --- a/c/scoundrel.c +++ b/c/scoundrel.c @@ -11,7 +11,9 @@ #if defined(__CC65__) || defined(__Z80__) #define RETRO_IMPL #endif -#ifndef RETRO_IMPL +#ifdef RETRO_IMPL +#include +#else #include #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> 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();