Short question: are there dynamic arrays in C (not ++)? I mean can I declare an array like "myType myName[]" and later on add items like "myName[0] = 1; myName[1] = 2;" ?
Printable View
Short question: are there dynamic arrays in C (not ++)? I mean can I declare an array like "myType myName[]" and later on add items like "myName[0] = 1; myName[1] = 2;" ?
No, unfortunately not. You have to do them yourself, or use a static array that holds the maximum number of elements you want to put into that array. Creating a dynamic array is not very hard though (using malloc/realloc).Zitat:
Zitat von Lukeson
Thank you. What library do I need for malloc/realloc? Is there a <stdlib.h> in PSPSDK? And is that the correct way of using them:
type name = malloc(ArraySize);
array = realloc(array, NewSize);
?
Yes, there is a stdlib.h, but you just need to include <malloc.h>, nothing more. And yes, that's the correct syntax to use.Zitat:
Zitat von Lukeson
Hm, I' getting errors:
Error:Code:typedef struct
{
Image* iconHigh;
Image* iconLow;
char label[16];
int x,y;
int imgOffsetX;
} MenuItem;
typedef struct
{
Image* iconHigh;
Image* iconLow;
char label[16];
int x,y;
int imgOffsetX;
MenuItem subMenu[2];
} MainMenuItem;
MainMenuItem mainMenu[5];
mainMenu[0].subMenu = realloc(mainMenu[0].subMenu, 5); // Line 139
Zitat:
main.c: In function 'main':
main.c:139: error: incompatible types in assignment
subMenu has to be a pointer if you want to malloc it (e.g. you can't allocate a struct/array with a static size).
I was hoping someone here would know:(. I guess I'll try pspdev. If you find a way to do this PSP-Maniac, please let me know.Zitat:
Zitat von PSP-Maniac
how do you port this (cout to printf)
i tested this , but it only prints text and dont execute x*yZitat:
cout<<"schrijf 2 getallen voor te vermenigvuldigen: ";
cin>>x>>y;
cin.ignore();
cout<<"het produkt van de 2 getallen is ";
cout<<x*y<<"\n";
Zitat:
printf("schrijf 2 getallen voor te vermenigvuldigen: ",x,y);
printf("\n");
printf("het produkt van de 2 getallen is ",x*y);
I don't quite get it. I tried various kinds of combinations between pointers and arrays. Eg.Zitat:
Zitat von homer
But this doesn't only look wierd, it really don't works. Can you give me an example of how to declare an array in the mainMenuStruct later on set its size / how to create an array of MainMenuItems with SubmenuArrays of different sizes in it ?Code:typedef struct
{
Image* iconHigh;
Image* iconLow;
char label[16];
int x,y;
int imgOffsetX;
MenuItem subMenu;
MenuItem *pSubMenu;
} MainMenuItem;
MainMenuItem mainMenu[5];
mainMenu[0].pSubMenu = &mainMenu[0].subMenu;
mainMenu[0].subMenu = realloc(mainMenu[0].pSubMenu, 5);
Here:
You then use it like this (example code):Code:typedef struct
{
Image* iconHigh;
Image* iconLow;
char label[16];
int x,y;
int imgOffsetX;
} MenuItem;
typedef struct
{
Image* iconHigh;
Image* iconLow;
char label[16];
int x,y;
int imgOffsetX;
MenuItem *subMenu;
} MainMenuItem;
MainMenuItem mainMenu[5];
//Allocation (should be in a function)
mainMenu[0].subMenu =(MenuItem *)malloc(5);
To reallocate it you simply do thisCode:strcpy(mainMenu[0].subMenu[0].label, "Test0");
mainMenu[0].subMenu[0].x = 0;
mainMenu[0].subMenu[0].y = 0;
Code:mainMenu[0].subMenu = (MenuItem *)realloc(mainMenu[0].subMenu, 6*sizeof(MenuItem));
Well I decided to left LUA for C...
So now I'm looking for a function that detects the color of a pixel (screen:pixel(x,y) in LUA) what's it in C??? Tx!
Thank you Homer!Zitat:
Zitat von homer
if youre using the graphics lib you can useZitat:
Zitat von Maxime
Code:getPixelScreen(int x, int y)
I don't wanna go on you guy's nerves, but I'm having a wierd error; Same code as aboveThe problem is that the picture's all messed up:Code:typedef struct
{
Image* iconHigh;
Image* iconLow;
char label[16];
int x,y;
int imgOffsetX;
} MenuItem;
typedef struct
{
Image* iconHigh;
Image* iconLow;
char label[16];
int x,y;
int imgOffsetX;
int maxMenuItems;
MenuItem *subMenu;
} MainMenuItem;
MainMenuItem mainMenu[5];
mainMenu[0].subMenu =(MenuItem *)malloc(5);
mainMenu[0].subMenu[0].iconHigh = loadImage("./img/mainmenu/s_eq_high.png");
while(1)
{
if (mainMenu[0].subMenu[0].iconHigh) {
blitAlphaImageToScreen(0 ,0 ,32 , 32, mainMenu[0].subMenu[0].iconHigh, 0, 0);
}
}
You probably put the wrong width and height values. You should do
Code:blitAlphaImageToScreen(0 ,0 mainMenu[0].subMenu[0].iconHigh->imageWidth, mainMenu[0].subMenu[0].iconHigh->imageHeight, mainMenu[0].subMenu[0].iconHigh, 0, 0);
No, the width and height are definitely correct. Including the image directly (using a var Image *tmp for loadImage()) it works just fine
I am trying to hook some firmware functions (in a devhook prx) so that I can draw my menu on the screen whenever the sceDisplayWaitVblankStart function is called so that everything is ALWAYS drawn on top of the current frame and I won't get flickering. I am also trying to hook the audio output functions (sample code below) to add a boost function like in PMP Mod AVC, except this would boost all output. I have tested the code for finding the offsets for the NIDS that I need to patch, and it does find the correct ones, but there is something wrong with either my patched functions or the actual patching of the functions. As soon as a sound is played the PSP freezes, indicating that the right NIDS are patched but that something causes it to freeze. In my original code I would patch the sound functions whenever I chose to in my menu, and in that way I found out that it patches the functions but whenever I would press a button on the D-pad to trigger the sound it would freeze. Can someone help me figure out what is wrong with my code? Below is a stripped down version of my code that simply patches the functions when it loads.
Code:#include <pspkernel.h>
#include <pspsdk.h>
#include <pspctrl.h>
#include <string.h>
PSP_MODULE_INFO("Api Hook", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
#define J_OPCODE 0x08000000
#define NOP 0x00000000
typedef int (*SCE_AUDIO_OUTPUT)(int channel, int vol, void *buf);
typedef int (*SCE_AUDIO_OUTPUT_PANNED)(int channel, int leftvol, int rightvol, void *buf);
SCE_AUDIO_OUTPUT sceAudioOutput_Real, sceAudioOutputBlocking_Real;
SCE_AUDIO_OUTPUT_PANNED sceAudioOutputPanned_Real, sceAudioOutputPannedBlocking_Real;
void* libsFindExportAddrByNid(SceModule *pMod, u32 nid)
{
struct SceLibraryEntryTable *entry;
u32 *addr = NULL;
void *entTab;
int entLen;
if(pMod != NULL)
{
int i = 0;
entTab = pMod->ent_top;
entLen = pMod->ent_size;
while(i < entLen)
{
int count;
int total;
unsigned int *vars;
entry = (struct SceLibraryEntryTable *) (entTab + i);
total = entry->stubcount + entry->vstubcount;
vars = entry->entrytable;
if(entry->stubcount > 0)
{
for(count = 0; count < entry->stubcount; count++)
{
if(vars[count] == nid)
{
return vars[count+total];
}
}
}
i += (entry->len * 4);
}
}
else
{
return 0;
}
return 0;
}
int sceAudioOutput_patched(int channel, int vol, void *buf)
{
return sceAudioOutput_Real(channel, 0, buf);;
}
int sceAudioOutputBlocking_patched(int channel, int vol, void *buf)
{
return sceAudioOutputBlocking_Real(channel, 0, buf);
}
int sceAudioOutputPanned_patched(int channel, int leftvol, int rightvol, void *buf)
{
return sceAudioOutputPanned_Real(channel, 0, 0, buf);
}
int sceAudioOutputPannedBlocking_patched(int channel, int leftvol, int rightvol, void *buf)
{
return sceAudioOutputPannedBlocking_Real(channel, 0, 0, buf);
}
//Keep our module running
int main_thread(SceSize args, void *argp) {
while(!sceKernelFindModuleByName("sceKernelLibrary"))
sceKernelDelayThread(100000);
sceKernelDelayThread(1000000);
while(1)
{
sceKernelDelayThread(20000);
}
return 0;
}
int module_start(SceSize args, void *argp) __attribute__((alias("_start")));
int _start(SceSize args, void *argp)
{
int thread_count = 0, counter = 0;
SceModule *mod_tmp, *audiomod;
SceUID thread_temp[100];
//Get a list of modules from running threads.
//For some reason I couldn't get a list of modules directly, maybe a problem with devhook?
sceKernelGetThreadmanIdList(SCE_KERNEL_TMID_Thread, thread_temp, 100, &thread_count);
for(counter=0; counter < thread_count; counter++)
{
SceKernelThreadInfo info;
info.size = sizeof(SceKernelThreadInfo);
sceKernelReferThreadStatus(thread_temp[counter], &info);
mod_tmp = sceKernelFindModuleByAddress((u32)info.entry);
//Find audio module based off of name, doesn't seem to work when I use the exact name =/
if(mod_tmp->modname[3] == 'A' && mod_tmp->modname[5] == 'd')
{
audiomod = mod_tmp;
}
}
u32 offset;
offset = (u32)libsFindExportAddrByNid(audiomod, 0x8C1009B2);
sceAudioOutput_Real = (SCE_AUDIO_OUTPUT)_lw(offset);
_sw((u32)sceAudioOutput_patched, offset);
offset = (u32)libsFindExportAddrByNid(audiomod, 0x136CAF51);
sceAudioOutputBlocking_Real = (SCE_AUDIO_OUTPUT)_lw(offset);
_sw((u32)sceAudioOutputBlocking_patched, offset);
offset = (u32)libsFindExportAddrByNid(audiomod, 0xE2D56B2D);
sceAudioOutputPanned_Real = (SCE_AUDIO_OUTPUT_PANNED)_lw(offset);
_sw((u32)sceAudioOutputPanned_patched, offset);
offset = (u32)libsFindExportAddrByNid(audiomod, 0x13F592BC);
sceAudioOutputPannedBlocking_Real = (SCE_AUDIO_OUTPUT_PANNED)_lw(offset);
_sw((u32)sceAudioOutputPannedBlocking_patched, offset);
sceKernelDcacheWritebackAll();
sceKernelCreateThread("hook_main_thread", main_thread, 100, 0x1000, 0, NULL);
return 0;
}
Zitat:
Zitat von Maxime
if you want to check how to use lua functions in C, check the LUA player soure code. it has everything
That problem is, thanks to СУ&am solved now :)Zitat:
Zitat von Lukeson
So I got time to come back to the transparency Issue.
It neither has a return value, nor does it affect the Image-pointer, so how do you use it? (sorry, I still am a noob)Zitat:
Zitat von homer
Zitat:
Zitat von Lukeson
Looks like it affects it to me mate.Code:*databuf = (*databuf & 0x00ffffff) | ((A(*databuf)-(A(*databuf)-alpha))<<24);
Follow the function through logically - it's pretty easy to understand.
What are you trying to achieve exactly? I feel there will be an easier and faster way to execute it. The above function will be quite slow.
-= Double Post =-
I can't believe I missed this the first time around. If you look at my function you will see that you only have to supply the filename and none of the other arguments.Zitat:
Zitat von Grimfate126
Just do:
Code:IMG_Screenshot("myImage.png");
Yeah ok. I already wanted to edit my post. I used it but it turns my partially transparent PNGs into transparent squares :S. What I want to do is fade out the images of my mainmenu... .Zitat:
Zitat von Insomniac197
Faster way, draw a quad over the top that's black (or whatever color you want to fade out to) and covers the entire screen and then alter the alpha value of the color.
Something like this:
Where CSVertex is:Code://////////////////////////////////////////////////////////////////////
// Name: FadeScreen
// Purpose: Fades the screen in/out (white)
// Returns: NONE
// Usage: Pass a value from 0.0f increasing to 1.0f to fade in,
// 1.0f decreasing to 0.0f to fade out
//////////////////////////////////////////////////////////////////////
void FadeScreen(const float FadeInAlphaValue)
{
guStart();
sceGuDisable(GU_TEXTURE_2D);
CSVertex* vertices = (CSVertex*) sceGuGetMemory(2 * sizeof(CSVertex));
vertices[0].color = GU_COLOR(1.0f, 1.0f, 1.0f, FadeInAlphaValue);
vertices[0].x = 0;
vertices[0].y = 0;
vertices[0].z = 0;
vertices[1].color = GU_COLOR(1.0f, 1.0f, 1.0f, FadeInAlphaValue);
vertices[1].x = 480;
vertices[1].y = 272;
vertices[1].z = 0;
sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices);
sceGuEnable(GU_TEXTURE_2D);
sceGuFinish();
sceGuSync(0, 0);
}
You can of course alter the function to take your own arguments - but this one is hard set to white.Code:typedef struct
{
unsigned int color;
short x, y, z;
} CSVertex;
Sometimes you have to change the alpha value without making a fade effect though...Zitat:
Zitat von Insomniac197
I believe this should save the transparency that's already there:
Code:void SetAlphaImage(Image * image, unsigned int alpha)
{
int size;
Color *databuf;
if(!image->data)
return;
if(alpha>255) alpha = 255;
if(alpha<0) alpha = 0;
size = image->textureWidth * image->textureHeight;
databuf = image->data;
for(i = 0; i <= size; i++)
{
*databuf = (*databuf & 0x00ffffff) | ((A(*databuf)-(A(*databuf)-alpha))<<24);
databuf++;
}
}
Uhm, I compared this with the old version and I don't actually see a difference.
My recent Problem: (sorry for so many code)
Code:/* ------------------------------------- ARRAY PART 1 ------------------------------------- */
mainMenu[0].subMenu =(MenuItem *)malloc(5 * sizeof(MenuItem));
mainMenu[0].subMenu[0].iconHigh = loadImage("./img/mainmenu/s_eq_high.png");
mainMenu[0].subMenu[0].iconLow = loadImage("./img/mainmenu/s_eq_low.png");
mainMenu[0].subMenu[0].imgOffsetX = 5;
mainMenu[0].subMenu[0].lblOffsetX = -3;
sprintf(mainMenu[0].subMenu[0].label, "EQUALIZER");
mainMenu[0].subMenu[1].iconHigh = loadImage("./img/mainmenu/s_repeat_high.png");
mainMenu[0].subMenu[1].iconLow = loadImage("./img/mainmenu/s_repeat_low.png");
mainMenu[0].subMenu[1].imgOffsetX = 5;
mainMenu[0].subMenu[1].lblOffsetX = 0;
sprintf(mainMenu[0].subMenu[1].label, "REPEAT");
// [other menuitems]
/* ------------------------------------- ARRAY PART 2 ------------------------------------- */
mainMenu[1].subMenu =(MenuItem *)malloc(1 * sizeof(MenuItem));
mainMenu[1].subMenu[0].iconHigh = loadImage("./img/mainmenu/gen_high.png");
mainMenu[1].subMenu[0].iconLow = loadImage("./img/mainmenu/gen_low.png");
mainMenu[1].subMenu[0].imgOffsetX = 5;
mainMenu[1].subMenu[0].lblOffsetX = 0;
sprintf(mainMenu[1].subMenu[0].label, "ARTISTS");
mainMenu[1].activeMenuItem = 0;
/* ------------------------------------------------------------------------- */
/* Functions */
/* ------------------------------------------------------------------------- */
/* -------------------------------- Draw icon with text below it ------------------- */
void drawSubMenuItem(int selMM, int selSM, int x, int y, int high)
{
if(high == 1) {
if(mainMenu[selMM].subMenu[selSM].iconHigh) {
blitAlphaImageToScreen(0 ,0 ,32 , 32, mainMenu[selMM].subMenu[selSM].iconHigh, x+mainMenu[selMM].subMenu[selSM].imgOffsetX, y);
}
printTextScreen(x+mainMenu[selMM].subMenu[selSM].lblOffsetX, y+36, mainMenu[selMM].subMenu[selSM].label, highlightColor);
} else if(high == 0) {
if(mainMenu[selMM].subMenu[selSM].iconLow) {
blitAlphaImageToScreen(0 ,0 ,32 , 32, mainMenu[selMM].subMenu[selSM].iconLow, x+mainMenu[selMM].subMenu[selSM].imgOffsetX, y);
}
printTextScreen(x+mainMenu[selMM].subMenu[selSM].lblOffsetX, y+36, mainMenu[selMM].subMenu[selSM].label, dimmedColor);
}
}
/*-------------------- Draw vertical Menu of an XMB -------------------------------*/
void drawSubMenu(selComponent)
{
int i, y;
for(i=0; i<=sizeof(mainMenu[selComponent].subMenu); i++)
{
if(i < mainMenu[selComponent].activeMenuItem)
{
y = 60 - (mainMenu[selComponent].activeMenuItem-i) * subDistance;
drawSubMenuItem(selComponent, i, subOffsetX, y, 0);
} else if(i == mainMenu[selComponent].activeMenuItem) {
drawSubMenuItem(selComponent, i, subOffsetX, 100, 1);
} else if(i > mainMenu[selComponent].activeMenuItem) {
y = 100 + (i-mainMenu[selComponent].activeMenuItem) * subDistance;;
drawSubMenuItem(selComponent, i, subOffsetX, y, 0);
}
}
}
// In my mainloop
drawSubMenu(0); // using the first array works
drawSubMenu(1); // Freezes the PSP on startup
When I call drawSubMenu with 0 as a parameter everything works fine. Using 1, which means using the 2nd part of the Array, the PSP freezes
-= Double Post =-
Added Comments.
when i try to use the danzeff OSK , it gives tons of erroros
here is my main.cCode:$ make kxploit
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o main.o mai
n.c
In file included from danzeff.h:15,
from main.c:5:
pspctrl_emu.h:4:21: error: SDL/SDL.h: No such file or directory
In file included from danzeff.h:15,
from main.c:5:
pspctrl_emu.h:23: error: nested redefinition of 'enum PspCtrlButtons'
pspctrl_emu.h:23: error: redeclaration of 'enum PspCtrlButtons'
pspctrl_emu.h:25: error: redeclaration of enumerator 'PSP_CTRL_SELECT'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:37: error: previous definition of 'P
SP_CTRL_SELECT' was here
pspctrl_emu.h:27: error: redeclaration of enumerator 'PSP_CTRL_START'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:39: error: previous definition of 'P
SP_CTRL_START' was here
pspctrl_emu.h:29: error: redeclaration of enumerator 'PSP_CTRL_UP'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:41: error: previous definition of 'P
SP_CTRL_UP' was here
pspctrl_emu.h:31: error: redeclaration of enumerator 'PSP_CTRL_RIGHT'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:43: error: previous definition of 'P
SP_CTRL_RIGHT' was here
pspctrl_emu.h:33: error: redeclaration of enumerator 'PSP_CTRL_DOWN'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:45: error: previous definition of 'P
SP_CTRL_DOWN' was here
pspctrl_emu.h:35: error: redeclaration of enumerator 'PSP_CTRL_LEFT'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:47: error: previous definition of 'P
SP_CTRL_LEFT' was here
pspctrl_emu.h:37: error: redeclaration of enumerator 'PSP_CTRL_LTRIGGER'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:49: error: previous definition of 'P
SP_CTRL_LTRIGGER' was here
pspctrl_emu.h:39: error: redeclaration of enumerator 'PSP_CTRL_RTRIGGER'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:51: error: previous definition of 'P
SP_CTRL_RTRIGGER' was here
pspctrl_emu.h:41: error: redeclaration of enumerator 'PSP_CTRL_TRIANGLE'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:53: error: previous definition of 'P
SP_CTRL_TRIANGLE' was here
pspctrl_emu.h:43: error: redeclaration of enumerator 'PSP_CTRL_CIRCLE'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:55: error: previous definition of 'P
SP_CTRL_CIRCLE' was here
pspctrl_emu.h:45: error: redeclaration of enumerator 'PSP_CTRL_CROSS'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:57: error: previous definition of 'P
SP_CTRL_CROSS' was here
pspctrl_emu.h:47: error: redeclaration of enumerator 'PSP_CTRL_SQUARE'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:59: error: previous definition of 'P
SP_CTRL_SQUARE' was here
pspctrl_emu.h:49: error: redeclaration of enumerator 'PSP_CTRL_HOME'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:61: error: previous definition of 'P
SP_CTRL_HOME' was here
pspctrl_emu.h:51: error: redeclaration of enumerator 'PSP_CTRL_HOLD'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:63: error: previous definition of 'P
SP_CTRL_HOLD' was here
pspctrl_emu.h:53: error: redeclaration of enumerator 'PSP_CTRL_NOTE'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:65: error: previous definition of 'P
SP_CTRL_NOTE' was here
pspctrl_emu.h:57: error: redefinition of 'struct SceCtrlData'
pspctrl_emu.h:68: error: redefinition of typedef 'SceCtrlData'
/usr/local/pspdev/psp/sdk/include/pspctrl.h:103: error: previous declaration of
'SceCtrlData' was here
pspctrl_emu.h:70: error: syntax error before '*' token
In file included from main.c:5:
danzeff.h:58:27: error: SDL/SDL_image.h: No such file or directory
In file included from main.c:5:
danzeff.h:60: error: syntax error before '*' token
en here is the makefileCode:#include <math.h>//rekenmachine
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>//controls
#include "danzeff.h"
#define printf pspDebugScreenPrintf
PSP_MODULE_INFO("calculator",0,0,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;
}
int y = 0;
int x =0;
int input;
void vermenigvuldigen();
void delen ();
void optellen();
void aftrekken();
SceCtrlData pad;
int main()
{
pspDebugScreenInit();
SetupCallbacks();
menu();
}
inline void menu()
{
danzeff_load();
danzeff_render();
while(1){
sceCtrlReadBufferPositive(&pad,1);
if(pad.Buttons & PSP_CTRL_START){
break;
}
}
printf( " ______ _______ _ ______ \n");
printf( " | ____| | ___ | | | | ____| v0.01 Beta test \n");
printf( " | | | | | | | | | | by roel \n");
printf( " | |____ | --- | | |____ | |____ (HALLO007)\n");
printf( " |______| |__| |__| |______| |______| -=[RP]=- Productions \n\n\n");
printf("druk start om het keyboard te openen\n");
printf("1.vermenigvuldig\n");
printf("2.delen\n");
printf("3.optellen\n");
printf("4.aftrekken\n");
printf("selectie: %d" , input);
printf("druk op [X] om de selectie te activeren");
while(1){
sceCtrlReadBufferPositive(&pad,1);
if(pad.Buttons & PSP_CTRL_CROSS) {
switch (input) {
case 1:
printf("test");
case 2:
printf("test");
case 3:
printf("test");
case 4:
printf("test");
default:
printf("error , probeer opnieuw");
menu();
}
}
}
}
inline void vermenigvuldigen ()
{
pspDebugScreenClear();//clear de screen
printf( " ______ _______ _ ______ \n");
printf( " | ____| | ___ | | | | ____| v0.01 Beta test \n");
printf( " | | | | | | | | | | by roel \n");
printf( " | |____ | --- | | |____ | |____ (HALLO007)\n");
printf( " |______| |__| |__| |______| |______| -=[RP]=- Productions \n");
printf("schrijf 2 getallen voor te vermenigvuldigen: \n");
printf("de waarde van het eerste getal : %d \n" , x);
printf("druk[X] om te bevestigen\n");
while(1) {
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_CROSS) {
printf("de waarde van het tweede getal : %d\n" , y);
printf("druk [X] om te vermenigvuldigen\n");
}
}
}
[/code]Code:TARGET = calculator
OBJS = main.o danzeff.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = calculator
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
There's a readme that comes with danzeff OSK.
Read it.
You need to choose within danzeff whether to use GU or SDL.
that's the point i dont understand the readme:(
i want the use the SDL_Joystick
but dont know how do change it
You need SDL installed to be able to use it...
I think the default for danzeff is SDL.
Problem solvedZitat:
Zitat von Lukeson
Glad to hear it.
hay i was wondering if any one can help give me a code to check if a file exists then load it and have it tell me when it exits i look all over but i couldnt find any.
could just do:Zitat:
Zitat von zmathue
file = fopen("./file.txt", "r");
if(file==NULL) { //file dosn't exist
} else {
//file exists
}
To check if a file exists you simply doZitat:
Zitat von zmathue
Not sure what you mean by the "exit" part though.Code://Open the file, change file path to the file you wish to check. rb indicates that it opens in read-binary mode.
FILE * file = fopen("file path", "rb");
//If file==0 (same as !file) the file doesn't exist
if(!file) { printf("file does not exist"); return 0; }
//Close the open file
fclose(file);
return 1;
what i ment was when the app i loaded exits out of itself that i want it to tell my program that it exited and do something
Oh, in that case. Just add this to your main (preferbly where you intialize the app)
And then add thisCode:int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
Code:/* Exit callback */
int exit_callback() {
//Add stuff here
sceKernelExitGame();
return 0;
}
actualy I mean when i load the app that i checked if it exists when that app exits then i want it to do something.Zitat:
Zitat von homer
whats the screen brightness button code
(the one beside note)
PSP_CTRL_SCREEN = 0x400000Zitat:
Zitat von Sousanator
It can only be read in kernel mode.
Can it be modified?
Zitat:
Zitat von Nutterbutter
that depends.. what do you mean by modified?? like changing the value?? i guess.. ask slasher. ;)