/* Bone Quest — based on Brian Holman's GPL-3.0-or-later Capital Quest. */ #include #include #include "graphics.h" #include "geometry.h" #include "quiz.h" #include "ui.h" static char line[54],answer[ANSWER_SIZE]; static U8 mode,spelling_attempt; U8 phase,current_bone; void quit_game(void) { release_keys();close_input();gfx_close();geometry_close();setHighSpeed(FALSE); printf("Thanks for playing Bone Quest!\n");exit(0); } static void present(void) { if(geometry_failed || !gfx_present()){gfx_close();geometry_close();setHighSpeed(FALSE);printf("Graphics or artwork stopped.\n");exit(1);} } static U8 choose(const char *allowed,U8 ready_phase) { U8 c;phase=7;release_keys();phase=ready_phase; do{c=next_key();if(c>='a' && c<='z')c-='a'-'A';}while(!strchr(allowed,c)); return c; } static void credits(void) { phase=7;frame("CREDITS"); text(16,21,"A JOURNEY THROUGH THE SKELETON",2); text(16,42,"Skeleton: Mariana Ruiz Villarreal",1); text(16,54,"(LadyofHats), public-domain artwork.",1); text(16,70,"Wikimedia Commons:",1); text(16,82,"Human_skeleton_front_en.svg",1); text(16,99,"Adapted: labels removed, reduced, recolored;",1); text(16,110,"bone masks and enlarged details prepared.",1); text(16,129,"Font / boot: Pierre Sarrazin, public domain.",1); text(16,143,"Based on Capital Quest by Brian Holman.",1); text(16,155,"Game GPL-3.0-or-later. See assets/CREDITS.md",1); text(16,212,"SPACE: back Q/Esc/Break: quit",2);present();choose(" ",5); } static U8 title(void) { U8 c; do{ phase=7;frame("HUMAN ANATOMY");show_skeleton(255,0); text(224,35,"28 STRUCTURES",2); text(224,54,"1 MULTIPLE CHOICE",1); text(224,75,"2 TYPE THE NAME",1); text(224,101,"C CREDITS",1);text(224,117,"Q QUIT TO BASIC",1); text(224,143,"Find the yellow part.",1); text(224,155,"Learn from each answer.",1); text(224,169,"512 KB COCO 3 / RGB",2); text(16,216,"1/2: start Q/Esc/Break: quit",1); present();c=choose("12CQ",0);if(c=='C')credits(); }while(c=='C'); return c; } static void question_screen(void) { phase=7;frame(mode==1?"MULTIPLE CHOICE":"TYPE THE NAME"); sprintf(line,"Question %u/%u Score %u",(unsigned)question+1,BONE_COUNT,(unsigned)score);text(16,19,line,1); show_skeleton(current_bone,1); text(224,140,"Name the yellow structure.",2); text(224,153,bones[current_bone].hint,1); text(16,216,"Yellow:current Red:missed Q/Esc/Break:quit",1); } static U8 multiple_choice(void) { U8 i,c;quiz_options(current_bone);question_screen(); for(i=0;i<4;++i){sprintf(line,"%u %s",(unsigned)i+1,bones[options[i]].name);text(224,168+i*11,line,1);} present();c=choose("1234",1)-'1';strcpy(answer,bones[options[c]].name); return options[c]==current_bone; } static void input_screen(U8 too_long) { gfx_fill_rect(216,166,424,48,0);text(224,168,answer,1); text(224+strlen(answer)*12,168,"_",2); text(224,183,too_long?"Use Backspace to edit.":"Enter:submit Q/Esc:quit",1); text(224,196,"Blank Enter: show answer.",1); text(224,208,"Backspace edits; case ignored.",1);present(); } static void input_edit(U8 old_n,U8 new_n) { U8 p,first=old_n='a' && c<='z')||(c>='A' && c<='Z')||c==' '||c=='.'||c=='-'){ /* 33 visible characters fit beside the full-body overview. */ if(n<33){old_n=n;answer[n++]=c;answer[n]=0;input_edit(old_n,n);} else{input_screen(1);input_screen(1);} } } } static void answer_sound(U8 right) { setHighSpeed(FALSE);if(right){sound(170,2);sound(210,3);}else{sound(100,3);sound(60,4);}setHighSpeed(TRUE); } static void feedback(U8 right) { gfx_copy_front();gfx_fill_rect(216,166,424,48,0);phase=3; text(224,170,right?"CORRECT!":"NOT THIS TIME.",right?2:3); text(224,183,bones[current_bone].name,1); text(224,201,mode==1?"Next follows automatically.":"SPACE: next question",1); present();answer_sound(right);if(mode==1)pause_or_quit(90);else choose(" ",3); } static U8 results(void) { U8 c,i,page,start,missed=BONE_COUNT-score; for(;;){ phase=7;frame("YOUR RESULTS");show_skeleton(255,1); text(224,35,"SKELETON COMPLETE",2); sprintf(line,"%u / %u correct %u%%",(unsigned)score,BONE_COUNT,(unsigned)score*100/BONE_COUNT);text(224,55,line,1); sprintf(line,"%u spelling corrections",(unsigned)corrections);text(224,77,line,1); sprintf(line,"%u topics to revisit",(unsigned)missed);text(224,93,line,1); text(224,118,"R REVIEW MISSED TOPICS",2);text(224,138,"P PLAY AGAIN",1);text(224,158,"Q QUIT TO BASIC",1); text(16,216,"Every topic once. Q/Esc/Break: quit",1);present();c=choose("RPQ",4);if(c!='R')return c; page=0;start=0; for(;;){ phase=7;frame("MISSED TOPICS");sprintf(line,"Review page %u",(unsigned)page+1);text(16,19,line,2);i=start;c=0; while(i