/* Bone Quest — based on Brian Holman's GPL-3.0-or-later Capital Quest. */ #include #include #include #include "quiz.h" #include "ui.h" static char line[54],answer[ANSWER_SIZE]; static U8 mode,spelling_attempt; U8 phase,current_bone; static void present(void) { if(!gime_present()){gime_close();setHighSpeed(FALSE);printf("Graphics timer stopped.\n");exit(1);} } static U8 choose(const char *allowed) { U8 c;release_keys(); do{c=next_key();if(c>='a' && c<='z')c-='a'-'A';}while(!strchr(allowed,c)); return c; } static void credits(void) { phase=5;frame("CREDITS"); text(8,21,"A JOURNEY THROUGH THE SKELETON",6); text(8,42,"Skeleton: Mariana Ruiz Villarreal",7); text(8,54,"(LadyofHats), public-domain artwork.",2); text(8,70,"Wikimedia Commons:",7); text(8,82,"Human_skeleton_front_en.svg",2); text(8,99,"Adapted: labels removed, reduced, recolored;",7); text(8,110,"bone masks and enlarged details prepared.",7); text(8,129,"Font / boot: Pierre Sarrazin, public domain.",2); text(8,143,"Based on Capital Quest by Brian Holman.",7); text(8,155,"Game GPL-3.0-or-later. See assets/CREDITS.md",2); text(8,180,"SPACE: back",6);present();choose(" "); } static U8 title(void) { U8 c; do{ phase=0;frame("HUMAN ANATOMY");show_skeleton(255,0); text(112,35,"25 BONES + GROUPS",6); text(112,54,"1 MULTIPLE CHOICE",7); text(112,75,"2 TYPE THE NAME",7); text(112,101,"C CREDITS",2);text(112,117,"Q QUIT TO BASIC",2); text(112,143,"Find the yellow bone.",7); text(112,155,"Learn from each answer.",2); text(112,169,"512 KB COCO 3 / RGB",6); text(8,183,"Release keys between presses. Choose 1 or 2.",2); present();c=choose("12CQ");if(c=='C')credits(); }while(c=='C'); return c; } static void question_screen(void) { phase=1;frame(mode==1?"MULTIPLE CHOICE":"TYPE THE NAME"); sprintf(line,"Question %u/%u Score %u",(unsigned)question+1,BONE_COUNT,(unsigned)score);text(8,19,line,7); show_skeleton(current_bone,1); text(112,106,"Name the yellow bone(s).",6); text(112,118,bones[current_bone].hint,2); text(8,183,"Teal:new Purple:right Red:miss Yellow:now",2); } 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(112,132+i*11,line,7);} present();c=choose("1234")-'1';strcpy(answer,bones[options[c]].name); return options[c]==current_bone; } static void input_screen(U8 too_long) { gime_fill_rect(108,129,212,48,1);text(112,132,answer,7); text(112+strlen(answer)*6,132,"_",6); text(112,146,too_long?"Use Backspace to edit.":"Enter:submit Esc:reveal",2); text(112,159,"Backspace edits the name.",2); text(112,171,"Case / spaces ignored.",2);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) { question_screen();phase=3; text(112,134,right?"CORRECT!":"NOT THIS TIME.",right?6:5); text(112,147,bones[current_bone].name,7); text(112,162,mode==1?"Next follows automatically.":"SPACE: next question",2); present();answer_sound(right);if(mode==1)delay(90);else choose(" "); } static U8 results(void) { U8 c,i,page,start,missed=BONE_COUNT-score; for(;;){ phase=4;frame("YOUR RESULTS");show_skeleton(255,1); text(112,35,"SKELETON COMPLETE",6); sprintf(line,"%u / %u correct %u%%",(unsigned)score,BONE_COUNT,(unsigned)score*100/BONE_COUNT);text(112,55,line,7); sprintf(line,"%u spelling corrections",(unsigned)corrections);text(112,77,line,2); sprintf(line,"%u topics to revisit",(unsigned)missed);text(112,93,line,7); text(112,118,"R REVIEW MISSED BONES",6);text(112,138,"P PLAY AGAIN",7);text(112,158,"Q QUIT TO BASIC",7); text(8,183,"Every topic once. Keep learning!",2);present();c=choose("RPQ");if(c!='R')return c; page=0;start=0; for(;;){ phase=6;frame("MISSED BONES");sprintf(line,"Review page %u",(unsigned)page+1);text(8,19,line,6);i=start;c=0; while(i