Editorial changes in parse_poke

This commit is contained in:
fabio.olimpieri 2012-08-23 09:29:44 +00:00
parent 4426bfde5f
commit d8367e488f

View File

@ -1137,45 +1137,45 @@ void do_poke_sdl() {
int parse_poke (const char *filename) int parse_poke (const char *filename)
{ {
static unsigned char old_poke[MAX_TRAINER][MAX_POKE]; //Max 19 Pokes per trainer and max 50 trainer static unsigned char old_poke[MAX_TRAINER][MAX_POKE]; //Max 19 Pokes per trainer and max 50 trainer
FILE* fpoke; FILE* fpoke;
unsigned char title[128], flag, newfile, restore, old_mport1; unsigned char title[128], flag, newfile, restore, old_mport1;
int bank, address, value, original_value, ritorno,y,k, trainer, poke; int bank, address, value, original_value, ritorno,y,k, trainer, poke;
SDL_Rect src, banner; SDL_Rect src, banner;
src.x=0; src.x=0;
src.y=30/RATIO; src.y=30/RATIO;
src.w=FULL_DISPLAY_X; src.w=FULL_DISPLAY_X;
src.h=FULL_DISPLAY_Y-60/RATIO; src.h=FULL_DISPLAY_Y-60/RATIO;
banner.x=0; banner.x=0;
banner.y=30/RATIO; banner.y=30/RATIO;
banner.w=FULL_DISPLAY_X; banner.w=FULL_DISPLAY_X;
banner.h=20/RATIO; banner.h=20/RATIO;
y=60/RATIO; y=60/RATIO;
if (strcmp(ordenador.last_selected_poke_file,filename)) newfile=1; else newfile=0; if (strcmp(ordenador.last_selected_poke_file,filename)) newfile=1; else newfile=0;
trainer=0; trainer=0;
fpoke = fopen(filename,"r"); fpoke = fopen(filename,"r");
if (fpoke==NULL) if (fpoke==NULL)
{ {
msgInfo("Can not access the file",3000,NULL); msgInfo("Can not access the file",3000,NULL);
return (0); return (0);
} }
clean_screen(); clean_screen();
SDL_FillRect(screen, &src, SDL_MapRGB(screen->format, 0xff, 0xff, 0xff)); SDL_FillRect(screen, &src, SDL_MapRGB(screen->format, 0xff, 0xff, 0xff));
print_font(screen, 0x0, 0x0, 0x0,0, 30/RATIO, "Press 1 to deselect, 2 to select", 16); print_font(screen, 0x0, 0x0, 0x0,0, 30/RATIO, "Press 1 to deselect, 2 to select", 16);
ritorno=0; ritorno=0;
do do
{ {
if (trainer==MAX_TRAINER) {ritorno=2;break;} if (trainer==MAX_TRAINER) {ritorno=2;break;}
poke=1; poke=1;
@ -1225,7 +1225,7 @@ do
fscanf(fpoke, "%1s %d %d %d %d", &flag, &bank, &address, &value, &original_value); fscanf(fpoke, "%1s %d %d %d %d", &flag, &bank, &address, &value, &original_value);
if (((flag!='M')&&(flag!='Z'))||(bank>8)||(bank<0)||(address>0xFFFF)||(address<0x4000)||(value>256)||(value<0)||(original_value>255)||(original_value<0)) {ritorno=1;break;} if (((flag!='M')&&(flag!='Z'))||(bank>8)||(bank<0)||(address>0xFFFF)||(address<0x4000)||(value>256)||(value<0)||(original_value>255)||(original_value<0)) {ritorno=1;break;}
if (feof(fpoke)) {ritorno=1;break;} if (feof(fpoke)) {ritorno=1;break;}
if ((!(bank&0x8))&&((ordenador.mode128k==1)||(ordenador.mode128k==2)||(ordenador.mode128k==4))) //+3? if ((!(bank&0x8))&&(ordenador.mode128k)) //128k,+2,+3,SP
{ {
old_mport1 = ordenador.mport1; old_mport1 = ordenador.mport1;
ordenador.mport1 = (unsigned char) (bank&0x7); ordenador.mport1 = (unsigned char) (bank&0x7);
@ -1237,7 +1237,7 @@ do
{if (original_value) old_poke[trainer][poke]=(unsigned char) original_value; else old_poke[trainer][poke]= Z80free_Rd_fake ((word) address);} {if (original_value) old_poke[trainer][poke]=(unsigned char) original_value; else old_poke[trainer][poke]= Z80free_Rd_fake ((word) address);}
if (restore) value = (int) old_poke[trainer][poke]; if (restore) value = (int) old_poke[trainer][poke];
} }
//if ((value == 256) && (k & KEY_SELECT)) {value = choice_value(); Z80free_Wr_fake ((word)address, (unsigned char) value);} TODO
if (((value < 256) && (k & KEY_SELECT))||(restore)) Z80free_Wr_fake ((word)address, (unsigned char) value); if (((value < 256) && (k & KEY_SELECT))||(restore)) Z80free_Wr_fake ((word)address, (unsigned char) value);
ordenador.mport1 = old_mport1; ordenador.mport1 = old_mport1;
set_memory_pointers (); // set the pointers set_memory_pointers (); // set the pointers
@ -1250,10 +1250,10 @@ do
{if (original_value) old_poke[trainer][poke]=(unsigned char) original_value; else old_poke[trainer][poke]= Z80free_Rd_fake ((word) address);} {if (original_value) old_poke[trainer][poke]=(unsigned char) original_value; else old_poke[trainer][poke]= Z80free_Rd_fake ((word) address);}
if (restore) value = (int) old_poke[trainer][poke]; if (restore) value = (int) old_poke[trainer][poke];
} }
//if ((value == 256) && (k & KEY_SELECT)) {value = choice_value(); Z80free_Wr_fake ((word)address, (unsigned char) value);} TODO
if (((value < 256) && (k & KEY_SELECT))||(restore)) Z80free_Wr_fake ((word)address, (unsigned char) value); if (((value < 256) && (k & KEY_SELECT))||(restore)) Z80free_Wr_fake ((word)address, (unsigned char) value);
} }
poke++; poke++;
} }
while (flag!='Z'); while (flag!='Z');
@ -1261,17 +1261,17 @@ do
if (!fgets(title,128,fpoke)) {ritorno=1;break;} //line feed reading if (!fgets(title,128,fpoke)) {ritorno=1;break;} //line feed reading
} }
while (ritorno==0); while (ritorno==0);
k=0; k=0;
while (!(k & KEY_ESCAPE)&&(ritorno==0)) while (!(k & KEY_ESCAPE)&&(ritorno==0))
{k = menu_wait_key_press();} {k = menu_wait_key_press();}
fclose(fpoke); fclose(fpoke);
if (ritorno==0) strcpy(ordenador.last_selected_poke_file,filename); if (ritorno==0) strcpy(ordenador.last_selected_poke_file,filename);
return (ritorno); return (ritorno);
} }
void load_poke_file() void load_poke_file()