#127595 - Lotti - Thu May 03, 2007 1:59 pm
here is the code!
0 compile errors or warnings
when i run this rom with no$gba i've got: "the rom-image has crashed"
when i run this on nds i got black screens.
this is the code:
_________________
http://lottisden.blogspot.com/
0 compile errors or warnings
when i run this rom with no$gba i've got: "the rom-image has crashed"
when i run this on nds i got black screens.
this is the code:
Code: |
// Includes #include <PA9.h> // Include for PA_Lib #include <fat.h> typedef struct { char question[512]; char A[512]; char B[512]; char C[512]; char D[512]; u8 answer; u8 done; } entry; // Function: main() int main(int argc, char ** argv) { u8 fatok=0; u16 totdomande=0; entry domande[100]; PA_Init(); // Initializes PA_Lib PA_InitVBL(); // Initializes a standard VBL PA_InitText(1, 0); // Initialise the text system on the top screen PA_InitText(0, 0); // Initialise the text system on the bottom screen PA_WaitForVBL(); PA_OutputText(0,7,11,"Welcome to WWTBAFM!"); PA_OutputText(1, 0, 0, "Initializing Fat..."); if (!fatInitDefault()) //Initialise fat library { PA_OutputText(1, 0, 1, "Fat Error"); PA_OutputText(1, 0, 2, "Do you have patched this rom"); PA_OutputText(1, 0, 3, "with the correct DLDI driver?"); } else {PA_OutputText(1, 0, 1, "Fat OK!"); fatok=1;} if (fatok) { char filename[] = "/WWTBAFM/questions.txt"; FILE* file = fopen (filename, "r"); if(file==NULL) PA_OutputText(1,0,2,"Unable to open %s", filename); else { PA_OutputText(1,0,2,"Opening %s", filename); PA_OutputText(1,0,3,"Loading from file"); char c[512]; while(!feof(file)) { //crashing part fgets(domande[totdomande].question, 512, file); fgets(domande[totdomande].A, 512, file); fgets(domande[totdomande].B, 512, file); fgets(domande[totdomande].C, 512, file); fgets(domande[totdomande].D, 512, file); fgets(c, 512, file); domande[totdomande].answer=c[0]-48; domande[totdomande].done=0; totdomande++; //end crashing part } fclose(file); PA_OutputText(1,0,4,"Load Complete!"); PA_OutputText(1,0,5,"Press Start to begin"); PA_WaitFor(Pad.Newpress.Start); u8 i,j,givenanswer; u16 correctanswers=0; for (i=0;i<totdomande;i++) { PA_InitText(1, 0); // Initialise the text system on the top screen PA_InitText(0, 0); // Initialise the text system on the bottom screen PA_OutputText(0,1,22,"Correct Answers: %03d", correctanswers); do {j=PA_RandMax(totdomande);} while (domande[j].done==1); PA_OutputText(1,0,1,"Question N.%03d", i); PA_BoxText(1, 2, 3, 29, 21, domande[j].question, (29 - 2)*(21 - 3)); PA_OutputText(0,1,2, "A) %s", domande[j].A); PA_OutputText(0,1,4, "B) %s", domande[j].B); PA_OutputText(0,1,6, "X) %s", domande[j].C); PA_OutputText(0,1,8, "Y) %s", domande[j].D); givenanswer=0; while (givenanswer==0) { if (Pad.Newpress.A) givenanswer=1; else if (Pad.Newpress.B) givenanswer=2; else if (Pad.Newpress.X) givenanswer=3; else if (Pad.Newpress.Y) givenanswer=4; else givenanswer=0; } domande[j].done=1; if (givenanswer==domande[j].answer) correctanswers++; } } } // Infinite loop to keep the program running while (1) { PA_WaitForVBL(); } return 0; } // End of main() |
_________________
http://lottisden.blogspot.com/