Skip to content

Commit c923c70

Browse files
committed
randomize
1 parent 8e72d9a commit c923c70

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

main.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ uint8_t kb_offsets[3] = {
3636
2
3737
};
3838

39+
uint8_t seeded = 0;
3940
uint8_t kb_x = 0;
4041
uint8_t kb_y = 0;
4142
uint8_t guess_nr;
@@ -294,12 +295,19 @@ void run_fiver(void)
294295
gotogxy(2, 0);
295296
gprint("Game Boy FIVER");
296297
draw_keyboard(0, kb_vert_offset);
297-
298+
299+
while (joypad());
300+
298301
color(LTGREY, WHITE, M_NOFILL);
299302
highlight_key();
300303
while(1) {
301304
uint8_t j = joypad();
302305
if((has_random == 0) && (j != 0)) {
306+
if (! seeded) {
307+
initrand((uint16_t)LY_REG | ((uint16_t)DIV_REG << 8));
308+
seeded = 1;
309+
}
310+
303311
uint16_t r;
304312
do {
305313
r = randw() & (NUM_ANSWERS_ROUNDED_UP_POW2-1);
@@ -404,10 +412,6 @@ void run_fiver(void)
404412
}
405413

406414
void main() {
407-
uint16_t seed = LY_REG;
408-
seed |= (uint16_t)DIV_REG << 8;
409-
initrand(seed);
410-
411415
while(1) {
412416
run_fiver();
413417
}

0 commit comments

Comments
 (0)