splodger15
September 25th, 2006, 18:47
can someone help with my main.c file as i keep on getting these errors but i can't get rid of them
yaustar
September 25th, 2006, 19:29
Showing the errors without the source doesn't help.
splodger15
September 25th, 2006, 20:10
Showing the errors without the source doesn't help.
can i pm you the source thanks can someone help me with this
yaustar
September 26th, 2006, 14:26
Just post it here.
JesusXP
September 26th, 2006, 16:08
or paste the url from rafb.net/nopaste
yaustar
September 26th, 2006, 21:09
it's a source my cousin has did for me
/*
Written by splodger15
*/
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <stdlib.h>
#include <string.h>
/* Define the module info section */
PSP_MODULE_INFO("Crack Safe", 0, 1, 1);
/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
/* Define printf, just to make typing easier */
#define printf pspDebugScreenPrintf
#define REPEAT_TIME 0x40000
static unsigned long control_bef_ctl = 0;
static unsigned long control_bef_tick = 0;
void dump_threadstatus(void);
/* Exit callback */
int exit_callback(void)
{
sceKernelExitGame();
return 0;
}
/* Callback thread */
void CallbackThread(void *arg)
{
int cbid;
dump_threadstatus();
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
}
/* Dump the current thread's status */
void dump_threadstatus(void)
{
int thid;
ThreadStatus status;
int ret;
thid = sceKernelGetThreadId();
memset(&status, 0, sizeof(ThreadStatus));
status.size = sizeof(ThreadStatus);
ret = sceKernelReferThreadStatus(thid, &status);
}
/* 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;
}
/* Get Button Input */
unsigned long Read_Key(void) {
ctrl_data_t key; //Define key input variable
sceCtrlSetSamplingCycle(0); //Set up key reading
sceCtrlSetSamplingMode(1);
sceCtrlReadBufferPositive(&key, 1); //Read one key
if (key.buttons == control_bef_ctl) { //If no button has been pushed
if ((key.frame - control_bef_tick) > REPEAT_TIME) { //If the program has been stalled for longer than REPEAT_TIME
return control_bef_ctl; //Return the time
}
}
control_bef_ctl = key.buttons;
control_bef_tick = key.frame;
return control_bef_ctl; //Return the state of the keys
}
/*
This uses the last number of the lock to get the possibilities
for the other two numbers.
*/
int combos(int lastNum) {
int modulus = lastNum % 4;
int firstNum[10];
int j = 0;
int i = 0;
printf("First Number : ");
for(i=0; i<40; i++) {
if(i%4 == modulus) {
printf("%d ", i);
firstNum[j] = i;
}
}
int secondNum[10];
int key=0;
switch(modulus) {
case 0:
key = 2;
break;
case 1:
key = 3;
break;
case 2:
key = 0;
break;
case 3:
key = 1;
break;
default:
//How the Hell do you get anything other than 0-3
//By doing something%4?
//Obviously, something's wrong if this executes...
break;
}
j = 0;
printf("\n\nSecond Number: ");
for(i=0; i<40; i++) {
if(i%4 == key) {
printf("%d ", i);
secondNum[j] = i;
j++;
}
}
printf("\n\nThird Number : ");
printf("%d", lastNum);
return 0;
}
int clrscreen(int lines) {
int i=0;
for(i=0; i<(lines); i++) {
printf("\n");
}
return 0;
}
/*
Display function, basically the UI
*/
int displayIt(int theNum, int stop) {
printf("Use the Arrows to Select the Last Number in the Combination\n");
if(stop==1) {
printf("Hit [O] to Stop the Timer or Push [] for Help.\n\n");
} else {
printf("Hit [X] to Start the Timer or Push [] for Help.\n\n");
}
printf("Last Number: %d\n\n\n\n", theNum);
combos(theNum);
return 0;
}
/* Rudimentary pause function *lol* */
int pause(int iterations) {
//Count to 100,000 Iterations Times
int i=0;
for(i=0; i<iterations; i++) {
int j=0;
for(j=0; j<100000; j++) {
//------------------
}
}
return 0;
}
/* This controls and displays the timer */
int timer(int lastNum) {
time_t startTime = sceKernelLibcTime(NULL);
time_t curTime;
time_t difTime;
time_t counter=0;
unsigned long ctrl;
displayIt(lastNum, 1);
printf("\n\n\n\nElapsed Time: 0s\n");
while(1) {
ctrl = Read_Key();
if(PSP_CTRL_CIRCLE) {
clrscreen(18);
displayIt(lastNum, 0);
break;
}
curTime = sceKernelLibcTime(NULL);
difTime = curTime - startTime;
if(difTime != counter) {
clrscreen(18);
counter = difTime;
displayIt(lastNum, 1);
printf("\n\n\n\nElapsed Time: %lds\n", counter);
}
}
return 0;
}
int main(void)
{
int lastNum = 0;
unsigned long ctrl;
unsigned long ctrl2;
unsigned long ctrl3;
int goBack = 0;
pspDebugScreenInit();
SetupCallbacks();
displayIt(lastNum, 0);
while(1) {
ctrl = Read_Key();
if(PSP_CTRL_LEFT) {
/* Decrement Last Number */
if(lastNum > 0) {
lastNum--;
clrscreen(23);
displayIt(lastNum, 0);
pause(50);
}
}
if(PSP_CTRL_RIGHT) {
/* Increment Last Number */
if(lastNum < 39) {
lastNum++;
clrscreen(23);
displayIt(lastNum, 0);
pause(50);
}
}
if(PSP_CTRL_CROSS) {
/* Start Timer */
clrscreen(23);
timer(lastNum);
}
if(PSP_CTRL_SQUARE) {
/* Display Instructions */
clrscreen(23);
printf("Masterlock combinations are very predictable. They follow a\n");
printf("certain set of rules. The entire combination is reliant on \n");
printf("the last digit of the combination which can easily be \n");
printf("determined. This program takes that last digit as input and\n");
printf("gives you the possible first and second digits.\n\n");
printf("For each ending number, there are 100 possible combinations \n");
printf("(each of 10 possible first digits could match with each of \n");
printf("10 possible second digits). From here, it is up to you to \n");
printf("try the combinations and ultimately open the lock. \n\n");
printf("Push [X] to Continue to the Instructions\n");
printf("Push [O] to Return");
while(1) {
ctrl3 = Read_Key();
if(PSP_CTRL_CIRCLE) {
clrscreen(14+34);
displayIt(lastNum, 0);
goBack = 1;
break;
}
if(PSP_CTRL_CROSS) {
clrscreen(14+34);
goBack = 0;
break;
}
}
if(!goBack) {
printf("As you can see, determining the final digit is the key. In \n");
printf("order to do this, you will need to look for the sticking \n");
printf("points of the lock. There are 12 points at which the lock \n");
printf("will stick. One of these is the last digit of the \n");
printf("combination. 7 of these points are between numbers on the \n");
printf("dial, so we can toss these out. Of the remaining 5 points, \n");
printf("4 of them will have the same one's digit (ie 5, 15, 25, 35).\n");
printf("Throw these out, the last digit is the one that is NOT stuck\n");
printf("on the same one's digitas the other four. This is the number\n");
printf("that you want to enter into this program. \n\n");
printf("This program was created by Splodger15. \n");
printf("Push [O] to Continue");
while(1) {
ctrl2 = Read_Key();
if(PSP_CTRL_CIRCLE) {
clrscreen(8+34);
displayIt(lastNum, 0);
break;
}
}
}
}
}
//dump_threadstatus();
sceKernelSleepThread();
return 0;
}
Considering it wasn't written by you, you may want to ask the original author: http://www.psp-programming.com/dev-forum/viewtopic.php?p=238&sid=5ac776c4a99cc90d7dba26140b1bf414
There is a chance that the SDK you are using has different version header files and libraries to the one that Yeldarb is using hence the errors.
The first error puzzles me as the function exit_callback is supposed to have some function arguements according to psp-programming.com.
Zion
September 26th, 2006, 21:21
Also in another thread it says your trying to learn lua too.....
Learn one or the other :p
You will find it stifling learning two at once
bronxbomber92
September 26th, 2006, 22:29
Also, just for future reference, you can't have c++ code in files with the .c extension ;)
Powered by vBulletin® Version 4.2.3 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.