diff -r 05bb44f4d92f -r 125e120165aa project_files/hwc/rtl/system.c --- a/project_files/hwc/rtl/system.c Thu Dec 04 11:19:38 2014 -0500 +++ b/project_files/hwc/rtl/system.c Thu Dec 04 20:15:03 2014 +0100 @@ -296,6 +296,11 @@ } LongInt fpcrtl_random(LongInt l) { + // random(0) is undefined in docs but effectively returns 0 in free pascal + if (l == 0) { + printf("WARNING: random(0) called!"); + return 0; + } return (LongInt) (rand() / (double) RAND_MAX * l); }