mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-02-27 15:29:47 +00:00
tfv: move random number generator to own file
This commit is contained in:
parent
074bfb2e84
commit
146ce14376
@ -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)
|
||||
|
||||
|
@ -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;
|
||||
|
@ -35,3 +35,5 @@ int world_map(void);
|
||||
int city_map(void);
|
||||
|
||||
int credits(void);
|
||||
|
||||
int random_8(void);
|
||||
|
19
gr-sim/tfv/tfv_random.c
Normal file
19
gr-sim/tfv/tfv_random.c
Normal file
@ -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;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
static char *title_menu[]={
|
||||
"NEW GAME",
|
||||
"LOAD GAME",
|
||||
"LOAD GAME (DOES NOT WORK)",
|
||||
"CREDITS",
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user