From c6a026846a000360715f4d6ad41e60c54d3ac5b6 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Sun, 11 Jan 2026 14:57:44 +0200 Subject: [PATCH] fixed some delays --- nes/eznes.h | 21 +++++++++++++++++++++ nes/nescoundrel.c | 21 +++------------------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/nes/eznes.h b/nes/eznes.h index 42d32f9..d79301a 100644 --- a/nes/eznes.h +++ b/nes/eznes.h @@ -175,5 +175,26 @@ void wait_for_start_rand() { srand(entropy); } +/* Generic helper methods */ + +/* Array shuffle method */ +void shuffle(s8 *array, u16 n) { + u16 i, j, t; + if(n > 1) { + for(i=n-1;i>0;i--) { + j = (u16) (rand()%(i+1)); + t = array[j]; + array[j] = array[i]; + array[i] = t; + } + } +} + +/* Delay by n cycles */ +void delay_cycles(u16 n) { + u16 i; + for(i=0;i 1) { - for(i=n-1;i>0;i--) { - j = (u16) (rand()%(i+1)); - t = array[j]; - array[j] = array[i]; - array[i] = t; - } - } -} - /* Room item handling methods */ s16 handle_monster(s16 val) {