Complete Bone Quest high-resolution anatomy quiz

This commit is contained in:
Brian Holman committed 2026-11-11 23:43:09 -07:00
1 parent 3cc37be5fb
commit 2ceb44a48c
62 files changed
+3204 -1301

No files matched your search

+73 -68
View File
@@ -1,98 +1,103 @@
/* Bone Quest — based on Brian Holman's GPL-3.0-or-later Capital Quest. */
#include <cmoc.h>
#include <coco.h>
#include <vcc/gime.h>
#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(!gime_present()){gime_close();setHighSpeed(FALSE);printf("Graphics timer stopped.\n");exit(1);}
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)
static U8 choose(const char *allowed,U8 ready_phase)
{
U8 c;release_keys();
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=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(" ");
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=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();
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=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);
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(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);
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(112,132+i*11,line,7);}
present();c=choose("1234")-'1';strcpy(answer,bones[options[c]].name);
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)
{
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();
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<new_n?old_n:new_n;
for(p=0;p<2;++p){gime_fill_rect(112+(unsigned)first*6,132,12,8,1);text(112+(unsigned)first*6,132,answer+first,7);text(112+(unsigned)new_n*6,132,"_",6);present();}
for(p=0;p<2;++p){gfx_fill_rect(224+(unsigned)first*12,168,24,8,0);text(224+(unsigned)first*12,168,answer+first,1);text(224+(unsigned)new_n*12,168,"_",2);present();}
}
static U8 typed_answer(void)
{
U8 c,n=0,result,old_n;answer[0]=0;spelling_attempt=0;
question_screen();input_screen(0);question_screen();input_screen(0);release_keys();
question_screen();input_screen(0);gfx_copy_front();release_keys();phase=1;
for(;;){
c=next_key();release_keys();
if(c==3 || c==27){strcpy(answer,"[revealed]");return 0;}
if(c==8 || c==127){old_n=n;if(n)answer[--n]=0;input_edit(old_n,n);}
else if(c==13 || c==10){
result=classify(current_bone,answer);if(result==2)return 1;if(result==0)return 0;
question_screen();phase=2;
text(112,133,"That looks close.",6);text(112,144,"Check your spelling.",7);
text(112,158,"R:retry V:reveal",7);text(112,171,"No point awarded yet.",2);
present();c=choose("RV");if(c=='V')return 0;spelling_attempt=1;
question_screen();input_screen(0);question_screen();input_screen(0);release_keys();
gfx_copy_front();gfx_fill_rect(216,166,424,48,0);phase=2;
text(224,169,"That looks close.",2);text(224,181,"Check your spelling.",1);
text(224,196,"R:retry V:reveal",1);text(224,208,"No point awarded yet.",1);
present();c=choose("RV",2);if(c=='V')return 0;spelling_attempt=1;
gfx_copy_front();input_screen(0);gfx_copy_front();release_keys();phase=1;
}else if((c>='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);}
@@ -106,46 +111,46 @@ static void answer_sound(U8 right)
}
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(" ");
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=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;
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=6;frame("MISSED BONES");sprintf(line,"Review page %u",(unsigned)page+1);text(8,19,line,6);i=start;c=0;
phase=7;frame("MISSED TOPICS");sprintf(line,"Review page %u",(unsigned)page+1);text(16,19,line,2);i=start;c=0;
while(i<BONE_COUNT && c<3){
if(!correct[order[i]]){
text(8,39+c*43,bones[order[i]].name,6);
sprintf(line,"You: %s",responses[order[i]][0]?(const char *)responses[order[i]]:"[blank]");text(8,50+c*43,line,7);
sprintf(line,"Answer: %s",bones[order[i]].name);text(8,61+c*43,line,2);++c;
text(16,39+c*43,bones[order[i]].name,2);
sprintf(line,"You: %s",responses[order[i]][0]?(const char *)responses[order[i]]:"[blank]");text(16,50+c*43,line,1);
sprintf(line,"Answer: %s",bones[order[i]].name);text(16,61+c*43,line,1);++c;
}++i;
}
while(i<BONE_COUNT && correct[order[i]])++i;
if(!missed)text(8,60,"A perfect skeleton! No missed bones.",7);
text(8,180,i<BONE_COUNT?"N NEXT PAGE B BACK TO RESULTS":"B BACK TO RESULTS",6);present();c=choose(i<BONE_COUNT?"NB":"B");if(c=='B')break;start=i;++page;
if(!missed)text(16,60,"A perfect skeleton! No missed topics.",1);
text(16,212,i<BONE_COUNT?"N NEXT B BACK Q/Esc/Break QUIT":"B BACK Q/Esc/Break QUIT",2);present();c=choose(i<BONE_COUNT?"NB":"B",6);if(c=='B')break;start=i;++page;
}
}
}
int main(void)
{
U8 c,right;unsigned seed;
if(!gime_open()){printf("Requires 512 KB CoCo 3 in BASIC.\n");return 1;}
if(!gfx_open()){printf("Requires 512 KB CoCo 3 in BASIC.\n");return 1;}
gfx_set_palette(0,0);gfx_set_palette(1,63);gfx_set_palette(2,54);gfx_set_palette(3,36);
if(!geometry_open()){gfx_close();printf("Cannot load BONES.DAT from drive 0.\n");return 1;}
setHighSpeed(TRUE);
gime_set_palette(0,1);gime_set_palette(1,3);gime_set_palette(2,56);gime_set_palette(3,28);
gime_set_palette(4,14);gime_set_palette(5,39);gime_set_palette(6,54);gime_set_palette(7,63);
for(;;){
c=title();if(c=='Q')break;mode=c-'0';seed=entropy^getTimer();
#ifdef TEST_SEED
@@ -155,5 +160,5 @@ int main(void)
for(question=0;question<BONE_COUNT;++question){current_bone=order[question];spelling_attempt=0;right=mode==1?multiple_choice():typed_answer();quiz_record(current_bone,answer,right,spelling_attempt);feedback(right);}
if(results()=='Q')break;
}
release_keys();close_input();gime_close();setHighSpeed(FALSE);printf("Thanks for playing Bone Quest!\n");return 0;
quit_game();return 0;
}