diff --git a/project/jni/application/pachi/src/definitions.h b/project/jni/application/pachi/src/definitions.h index fad3dbe5f..3ecf68c06 100644 --- a/project/jni/application/pachi/src/definitions.h +++ b/project/jni/application/pachi/src/definitions.h @@ -46,12 +46,12 @@ float alphade; #define arrow_up 3 #define arrow_down 4 -int namechar; +int namechar=0; int gameover=0; // --- Scores related char playername[]=" "; -char scorename[10][10]; +char scorename[10][11]; int scorestage[10]; int scoretime[10]; int scoredif[10]; diff --git a/project/jni/application/pachi/src/file.h b/project/jni/application/pachi/src/file.h index 62d8d525f..d2e3cab67 100644 --- a/project/jni/application/pachi/src/file.h +++ b/project/jni/application/pachi/src/file.h @@ -90,6 +90,8 @@ void stop_music() } } +void save_hiscoredata(); + void load_hiscoredata() { background=LoadT8(DATADIR"/Tgfx/gameover.T8"); @@ -97,24 +99,43 @@ void load_hiscoredata() LoadT(&scorefont1,DATADIR"/fonts/font16d.T"); FILE *file = fopen(SCOREDIR"/data/scores.dat","rb"); - for(int a=0; a < 10; a++) + if( file == NULL ) { - for(int b=0; b < 10; b++) - { - scorename[a][b]=getc(file); - } - scorestage[a]=getc(file); - int lobyte,hibyte,vhibyte; - hibyte=getc(file); - lobyte=getc(file); - scoretime[a]=(hibyte*256)+lobyte; - scoredif[a]=getc(file); - vhibyte=getc(file); - hibyte=getc(file); - lobyte=getc(file); - scorescore[a]=(vhibyte*65536)+(hibyte*256)+lobyte; + for(int a=0; a < 10; a++) + { + for(int b=0; b < 10; b++) + { + scorename[a][b]=0; + } + scorestage[a]=0; + scoretime[a]=0; + scoredif[a]=0; + scorescore[a]=0; + } + save_hiscoredata(); + } + else + { + for(int a=0; a < 10; a++) + { + for(int b=0; b < 10; b++) + { + scorename[a][b]=getc(file); + } + scorename[a][10] = 0; + scorestage[a]=getc(file); + int lobyte,hibyte,vhibyte; + hibyte=getc(file); + lobyte=getc(file); + scoretime[a]=(hibyte*256)+lobyte; + scoredif[a]=getc(file); + vhibyte=getc(file); + hibyte=getc(file); + lobyte=getc(file); + scorescore[a]=(vhibyte*65536)+(hibyte*256)+lobyte; + } + fclose(file); } - fclose(file); } void unload_hiscoredata() { @@ -124,7 +145,7 @@ void unload_hiscoredata() } void save_hiscoredata() { - FILE *file = fopen(SCOREDIR"/data/scores.dat","rb+"); + FILE *file = fopen(SCOREDIR"/data/scores.dat","wb"); for(int a=0;a<10;a++) { @@ -136,14 +157,14 @@ void save_hiscoredata() int lobyte,hibyte,vhibyte; hibyte=int(scoretime[a]/256); - lobyte=int(scoretime[a]-(hibyte+256)); + lobyte=int(scoretime[a]-(hibyte*256)); putc(hibyte,file); putc(lobyte,file); putc(scoredif[a],file); vhibyte=int(scorescore[a]/65536); - hibyte=int((scorescore[a] - (scorescore[a]/65536))/256); + hibyte=int((scorescore[a] - (vhibyte*256))/256); lobyte=int(scorescore[a] - (vhibyte*65536 + hibyte*256)); putc(vhibyte,file); diff --git a/project/jni/application/pachi/src/game.h b/project/jni/application/pachi/src/game.h index 6723a42b8..2af1283ea 100644 --- a/project/jni/application/pachi/src/game.h +++ b/project/jni/application/pachi/src/game.h @@ -264,8 +264,8 @@ double delta_time(void) curtime=SDL_GetTicks(); imove=(curtime-lasttime)/1000.0; lasttime=curtime; - if(imove>.2) - imove=0.01; + if(imove>0.2) + imove=0.2; return imove; } diff --git a/project/jni/application/pachi/src/gameover.h b/project/jni/application/pachi/src/gameover.h index d80b2fa46..800af216a 100644 --- a/project/jni/application/pachi/src/gameover.h +++ b/project/jni/application/pachi/src/gameover.h @@ -18,6 +18,8 @@ void show_hiscores() { + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format,0,0,0)); + SDL_BlitSurface(background,NULL,screen,NULL); SDL_SetColorKey(scorefont,SDL_SRCCOLORKEY,SDL_MapRGB(scorefont->format,0,0,0)); SDL_SetColorKey(scorefont1,SDL_SRCCOLORKEY,SDL_MapRGB(scorefont1->format,0,0,0)); SDL_SetColorKey(scorefont1,SDL_SRCCOLORKEY,SDL_MapRGB(scorefont1->format,0,0,0)); @@ -100,6 +102,8 @@ void do_gameover() box.x=273;box.y=223;box.w=254;box.h=46; while(inputloop==1) { + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format,0,0,0)); + SDL_BlitSurface(background,NULL,screen,NULL); hiscore_events(); SDL_FillRect(screen,&box,SDL_MapRGB(screen->format,0,0,0)); print_text(scorefont1,screen,16,16,box.x+10,box.y+5,"ENTER YOUR NAME"); diff --git a/project/jni/application/pachi/src/input.h b/project/jni/application/pachi/src/input.h index 363ae8e48..b44122f7c 100644 --- a/project/jni/application/pachi/src/input.h +++ b/project/jni/application/pachi/src/input.h @@ -52,17 +52,50 @@ void hiscore_events() { case SDL_KEYDOWN: { + if(event.key.keysym.sym == SDLK_UP) + { + playername[namechar]--; + if(playername[namechar]<='A' || playername[namechar]>='Z') + playername[namechar]='A'; + } + else + if(event.key.keysym.sym == SDLK_DOWN) + { + playername[namechar]++; + if(playername[namechar]<='A' || playername[namechar]>='Z') + playername[namechar]='Z'; + } + else + if(event.key.keysym.sym == SDLK_RIGHT) + { + if(playername[namechar]<='A' || playername[namechar]>='Z') + playername[namechar]='A'; + namechar++; + if(namechar > 9) + namechar=9; + } + else + if(event.key.keysym.sym == SDLK_LEFT) + { + playername[namechar]=' '; + namechar--; + if(namechar < 0) + namechar=0; + } + else if(event.key.keysym.sym>41) { playername[namechar] = event.key.keysym.sym; if(playername[namechar]>=97 && playername[namechar]<=122) playername[namechar]=event.key.keysym.sym-32; + if(playername[namechar]<='A' || playername[namechar]>='Z') + playername[namechar]='A'; if(namechar < 9) namechar++; } else { - if(event.key.keysym.sym==SDLK_RETURN || event.key.keysym.sym == SDLK_ESCAPE) + if(event.key.keysym.sym==SDLK_RETURN || event.key.keysym.sym == SDLK_ESCAPE || event.key.keysym.sym == SDLK_SPACE) inputloop=0; if(event.key.keysym.sym==SDLK_BACKSPACE) { @@ -176,17 +209,50 @@ void code_events() { case SDL_KEYDOWN: { + if(event.key.keysym.sym == SDLK_UP) + { + code[codechar]--; + if(code[codechar]<='A' || code[codechar]>='Z') + code[codechar]='A'; + } + else + if(event.key.keysym.sym == SDLK_DOWN) + { + code[codechar]++; + if(code[codechar]<='A' || code[codechar]>='Z') + code[codechar]='Z'; + } + else + if(event.key.keysym.sym == SDLK_RIGHT) + { + if(code[codechar]<='A' || code[codechar]>='Z') + code[codechar]='A'; + codechar++; + if(codechar > 3) + codechar=3; + } + else + if(event.key.keysym.sym == SDLK_LEFT) + { + code[codechar]='.'; + codechar--; + if(codechar < 0) + codechar=0; + } + else if(event.key.keysym.sym>41) { code[codechar] = event.key.keysym.sym; if(code[codechar]>=97 && code[codechar]<=122) code[codechar]=event.key.keysym.sym-32; + if(code[codechar]<='A' || code[codechar]>='Z') + code[codechar]='A'; if(codechar < 3) codechar++; } else { - if(event.key.keysym.sym== SDLK_RETURN || event.key.keysym.sym == SDLK_ESCAPE) + if(event.key.keysym.sym== SDLK_RETURN || event.key.keysym.sym == SDLK_ESCAPE || event.key.keysym.sym == SDLK_SPACE) inputloop=0; if(event.key.keysym.sym== SDLK_BACKSPACE) { diff --git a/project/jni/application/pachi/src/menu.h b/project/jni/application/pachi/src/menu.h index bfd53a0b6..1aa2f77fc 100644 --- a/project/jni/application/pachi/src/menu.h +++ b/project/jni/application/pachi/src/menu.h @@ -19,25 +19,30 @@ void do_code() { Mix_Volume(3,100); - SDL_Rect coderect; - coderect.x=300; - coderect.y=232; - coderect.w=200; - coderect.h=50; - SDL_FillRect(screen, &coderect, SDL_MapRGB(screen->format,255,255,255)); - coderect.x=303; - coderect.y=235; - coderect.w=194; - coderect.h=44; - SDL_FillRect(screen, &coderect, SDL_MapRGB(screen->format,0,0,0)); codechar=0; inputloop=1; // SDL_SetColorKey(menufont1,0,SDL_MapRGB(menufont1->format,0,255,0)); while(inputloop==1) { + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format,0,0,0)); + SDL_Rect coderect; + coderect.x=300; + coderect.y=232; + coderect.w=200; + coderect.h=60; + SDL_FillRect(screen, &coderect, SDL_MapRGB(screen->format,255,255,255)); + coderect.x=303; + coderect.y=235; + coderect.w=194; + coderect.h=54; + SDL_FillRect(screen, &coderect, SDL_MapRGB(screen->format,0,0,0)); code_events(); print_text(menufont1, screen, 32, 32, 336, 241, "%s",code); - SDL_UpdateRect(screen, 300, 232, 200, 50); + char cursor[]=" "; + cursor[codechar]='.'; + print_text(menufont1, screen, 32, 32, 336, 254, "%s",cursor); + //SDL_UpdateRect(screen, 300, 232, 200, 50); + SDL_Flip(screen); } // SDL_SetColorKey(menufont1,SDL_SRCCOLORKEY,SDL_MapRGB(menufont1->format,0,255,0)); diff --git a/project/jni/application/pachi/src/output.h b/project/jni/application/pachi/src/output.h index 689847409..98b269910 100644 --- a/project/jni/application/pachi/src/output.h +++ b/project/jni/application/pachi/src/output.h @@ -89,7 +89,7 @@ void print_credits() SDL_SetAlpha(creditsbuffer, SDL_SRCALPHA, 255); SDL_BlitSurface(creditsbuffer, &cbuffer, creditsbuffer1, &cbuffer1); SDL_BlitSurface(creditsbuffer1, &cbuffer1, creditsbuffer, &cbuffer1); - SDL_BlitSurface(background, &bgpos, screen, &bgpos); + SDL_BlitSurface(background, NULL, screen, NULL); //SDL_BlitSurface(background, &bgpos, screen, &bgpos); SDL_SetColorKey(creditsbuffer, SDL_SRCCOLORKEY, SDL_MapRGB(creditsbuffer->format, 0, 255, 0)); SDL_SetAlpha(creditsbuffer, SDL_SRCALPHA, 128); SDL_BlitSurface(creditsbuffer, &cbuffer1, screen, &creditspos); diff --git a/project/jni/application/pachi/src/stages.h b/project/jni/application/pachi/src/stages.h index 91b2fa3a3..3571233e2 100644 --- a/project/jni/application/pachi/src/stages.h +++ b/project/jni/application/pachi/src/stages.h @@ -76,13 +76,13 @@ void init_stages () mstage[12].music=DATADIR"/music/stage3.s3m.ogg"; mstage[12].objects=17; mstage[12].time=140; - mstage[12].code="TWR1"; + mstage[12].code="TWRF"; mstage[13].title=" THE TWO TOWERS "; mstage[13].music=DATADIR"/music/stage3.s3m.ogg"; mstage[13].objects=26; mstage[13].time=200; - mstage[13].code="2TWR"; + mstage[13].code="STWR"; mstage[14].title=" THE SECRET PLACE "; mstage[14].music=DATADIR"/music/stage3.s3m.ogg";