diff --git a/gr-sim/tfv/Makefile b/gr-sim/tfv/Makefile index 096f7c06..2ca3f303 100644 --- a/gr-sim/tfv/Makefile +++ b/gr-sim/tfv/Makefile @@ -106,6 +106,9 @@ tfv_map.o: tfv_map.c tfv_opener.o: tfv_opener.c ../tfv_utils.h $(CC) $(CFLAGS) -c tfv_opener.c +tfv_random.o: tfv_random.c + $(CC) $(CFLAGS) -c tfv_random.c + tfv_sprites.o: tfv_sprites.c tfv_sprites.c $(CC) $(CFLAGS) -c tfv_sprites.c @@ -132,14 +135,14 @@ tfv.o: tfv.c ../gr-sim.h tfv_backgrounds.h tfv_sprites.h tfv: tfv.o tfv_backgrounds.o tfv_battle.o tfv_credits.o tfv_dialog.o \ tfv_ending.o tfv_flying.o \ tfv_game_over.o tfv_help.o tfv_info.o tfv_map.o \ - tfv_opener.o tfv_sprites.o tfv_textentry.o \ + tfv_opener.o tfv_random.o tfv_sprites.o tfv_textentry.o \ tfv_title.o tfv_worldmap.o tfv_mapinfo.h \ $(GR_SIM) $(CC) $(LFLAGS) $(SDL_LIBS) -o tfv tfv.o \ tfv_backgrounds.o tfv_battle.o tfv_credits.o tfv_dialog.o \ tfv_ending.o tfv_flying.o \ tfv_game_over.o tfv_help.o tfv_info.o tfv_map.o \ - tfv_opener.o tfv_sprites.o tfv_textentry.o \ + tfv_opener.o tfv_random.o tfv_sprites.o tfv_textentry.o \ tfv_title.o tfv_worldmap.o \ $(GR_SIM) diff --git a/gr-sim/tfv/tfv_battle.c b/gr-sim/tfv/tfv_battle.c index 79862ccb..390c57fb 100644 --- a/gr-sim/tfv/tfv_battle.c +++ b/gr-sim/tfv/tfv_battle.c @@ -167,26 +167,6 @@ static struct enemy_type enemies[8]={ }, }; - -// http://codebase64.org/doku.php?id=base:small_fast_8-bit_prng -static int random_8(void) { - - static int seed=0x1f; - static int newseed; - - newseed=seed; // lda seed - if (newseed==0) goto doEor; // beq doEor - newseed<<=1; // asl - if (newseed==0) goto noEor; //beq noEor - // if the input was $80, skip the EOR - if (!(newseed&0x100)) goto noEor; // bcc noEor -doEor: - newseed^=0x1d; // eor #$1d -noEor: - seed=(newseed&0xff); // sta seed - return seed; -} - static int gr_put_num(int xx,int yy,int number) { int xt=xx,digit,left,hundreds; diff --git a/gr-sim/tfv/tfv_definitions.h b/gr-sim/tfv/tfv_definitions.h index 3503a351..d2e2b524 100644 --- a/gr-sim/tfv/tfv_definitions.h +++ b/gr-sim/tfv/tfv_definitions.h @@ -35,3 +35,5 @@ int world_map(void); int city_map(void); int credits(void); + +int random_8(void); diff --git a/gr-sim/tfv/tfv_random.c b/gr-sim/tfv/tfv_random.c new file mode 100644 index 00000000..11a10a17 --- /dev/null +++ b/gr-sim/tfv/tfv_random.c @@ -0,0 +1,19 @@ +// http://codebase64.org/doku.php?id=base:small_fast_8-bit_prng +int random_8(void) { + + static int seed=0x1f; + static int newseed; + + newseed=seed; // lda seed + if (newseed==0) goto doEor; // beq doEor + newseed<<=1; // asl + if (newseed==0) goto noEor; //beq noEor + // if the input was $80, skip the EOR + if (!(newseed&0x100)) goto noEor; // bcc noEor +doEor: + newseed^=0x1d; // eor #$1d +noEor: + seed=(newseed&0xff); // sta seed + return seed; +} + diff --git a/gr-sim/tfv/tfv_title.c b/gr-sim/tfv/tfv_title.c index 5828a4ec..8c1aa2fc 100644 --- a/gr-sim/tfv/tfv_title.c +++ b/gr-sim/tfv/tfv_title.c @@ -10,7 +10,7 @@ static char *title_menu[]={ "NEW GAME", - "LOAD GAME", + "LOAD GAME (DOES NOT WORK)", "CREDITS", };