i am trying to make a homebrew application that you have to guess the capitals of all 50 states.
this is my source code
#include <String.h>
#include <Stdlib.h>
#include <Stdio.h>
#include <Time.h>
PSP_MODULE_INFO("States", 0, 1, 1);
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
char State[50][255] = {"Alabama",
"Alaska",
"Arizona",
"Arkansas",
"California",
"Colorado",
"Connecticut",
"Delaware",
"Florida",
"Georgia",
"Hawaii",
"Idaho",
"Illinois",
"Indiana",
"Iowa",
"Kansas",
"Kentucky",
"Louisiana",
"Maine",
"Maryland",
"Massachusetts",
"Michigan",
"Minnesota",
"Mississippi",
"Missouri",
"Montana",
"Nebraska",
"Nevada",
"New Hampshire",
"New Jersey",
"New Mexico",
"New York",
"North Carolina",
"North Dakota",
"Ohio",
"Oklahoma",
"Oregon",
"Pennsylvania",
"Rhode Island",
"South Carolina",
"South Dakota",
"Tennessee",
"Texas",
"Utah",
"Vermont",
"Virginia",
"Washington",
"West Virginia",
"Wisconsin",
"Wyoming"};
char Capital[50][255] = {"Montgomery",
"Juneau",
"Phoenix",
"Little Rock",
"Sacramento",
"Denver",
"Hartford",
"Dover",
"Tallahassee",
"Atlanta",
"Honolulu",
"Boise",
"Springfield",
"Indianapolis",
"Des Moines",
"Topeka",
"Frankfort",
"Baton Rouge",
"Augusta",
"Annapolis",
"Boston",
"Lansing",
"St. Paul",
"Jackson",
"Jefferson City",
"Helena",
"Lincoln",
"Carson City",
"Concord",
"Trenton",
"Santa Fe",
"Albany",
"Raleigh",
"Bismarck",
"Columbus",
"Oklahoma City",
"Salem",
"Harrisburg",
"Providence",
"Columbia",
"Pierre",
"Nashville",
"Austin",
"Salt Lake City",
"Montpelier",
"Richmond",
"Olympia",
"Charleston",
"Madison",
"Cheyenne"};
int main() {
pspDebugScreenInit();
SetupCallbacks();
srand(time(0));
int NumCorrect = 0;
int NumIncorrect = 0;
while(true)
{
int RandNum = rand() % 49;
if(!strlen(State[RandNum]))
{
while(!strlen(State[RandNum]))
{
RandNum = rand() % 49;
}
}
char Answer[255];
char Buffer[255];
sprintf(Buffer, "What is the capital of %s?", State[RandNum]);
puts(Buffer);
gets(Answer);
if(!strcmp(Answer, Capital[RandNum]))
{
NumCorrect ++;
if(NumCorrect == 50)
{
puts("You guessed all 50 state capitals!\n"
"You win!!! (-:");
system("pause");
exit(EXIT_SUCCESS);
}
strcpy(State[RandNum], "");
strcpy(Capital[RandNum], "");
printf("%s, was correct! Excellent Job!\n", Answer);
}
else
{
NumIncorrect ++;
if(NumIncorrect == 3)
{
puts("You got three (3) answers incorrect.\n"
"You lose!!! )-:");
system("pause");
exit(EXIT_SUCCESS);
}
printf("%s, was incorrect. The correct answer was %s.\n", Answer, Capital[RandNum]);
}
printf("Your score is:\n"
"Correct : %i\n"
"Incorrect : %i\n\n", NumCorrect, NumIncorrect);
system("pause");
system("cls");
}
system("pause");
return(0);
}
i am actually porting it to the psp
i have the files for the danzeff keyboard could someone explain to me how i would use the keyboard with this program
thank you i nadvance
danzeff keyboard help
-
- Posts: 3
- Joined: Thu Sep 27, 2007 6:41 am
plz help
can someone plz just tell me how to use the danzeff keyboard
Impatient much. None of those system calls will work because they are dependent on an MS-DOS environment. system should never be used unless you really know what you are doing, and even then you probably shouldn't be using it. I don't think you even can use it on the PSP, but I have not tried.
I don't know how to use the danzeff keyboard library, though, so I can't help on that. I'd imagine it should be pretty easy to figure out if you look at the header file.
E] Wow, I just looked a little deeper at that...wow, so much wrong. None of those stdout functions will output anything because you don't have an stdout handler installed (nor should you need to given what you're doing). Also, header names are not capitalized. This is CASE SENSITIVE on a Unix environment (like Cygwin), and also, something%49 will return a value between 0 and 48...not what you're looking for. And that's just scratching the surface of the problems.
I don't know how to use the danzeff keyboard library, though, so I can't help on that. I'd imagine it should be pretty easy to figure out if you look at the header file.
E] Wow, I just looked a little deeper at that...wow, so much wrong. None of those stdout functions will output anything because you don't have an stdout handler installed (nor should you need to given what you're doing). Also, header names are not capitalized. This is CASE SENSITIVE on a Unix environment (like Cygwin), and also, something%49 will return a value between 0 and 48...not what you're looking for. And that's just scratching the surface of the problems.
-
- Posts: 86
- Joined: Thu Aug 17, 2006 3:27 am
Re: plz help
It looks like you have a lot to learn about programming on the PSP. Look at the SDK samples and other apps that use danzeff.qwerty6523 wrote:can someone plz just tell me how to use the danzeff keyboard
Cloudy
:)