Seite 34 von 340 ErsteErste ... 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 84 134 ... LetzteLetzte
Zeige Ergebnis 991 bis 1.020 von 10174

C/C++ Programming Help Thread

This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; ah ok srry i can't help...

  
  1. #991
    QJ Gamer Blue
    Points: 4.073, Level: 40
    Level completed: 62%, Points required for next Level: 77
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Canada
    Beiträge
    70
    Points
    4.073
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    ah ok srry i can't help



  2. #992
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Twin891
    ah ok srry i can't help

    its k. ill figure some other way
    --------------------------------------------------------------------------------------

  3. #993
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    As Twin891 already mentioned, the saveImage() functions from graphics.c is a good start.

    I use this function to save as a PNG.

    Code:
    void IMG_Screenshot(const char* filename)
    {
    	u32* data = (u32*)0x04000000;
            png_structp png_ptr;
    	png_infop info_ptr;
    	FILE* fp;
    	int i, x, y;
    	u8* line;
    	
    	if ((fp = fopen(filename, "wb")) == NULL) return;
    	png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
    	if (!png_ptr) return;
    	info_ptr = png_create_info_struct(png_ptr);
    	if (!info_ptr) {
    		png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
    		return;
    	}
    	png_init_io(png_ptr, fp);
    	png_set_IHDR(png_ptr, info_ptr, 480, 272, 8,
    		PNG_COLOR_TYPE_RGB,
    		PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
    	png_write_info(png_ptr, info_ptr);
    	line = (u8*) malloc(480 * 3);
    	for (y = 0; y < 272; y++) {
    		for (i = 0, x = 0; x < 480; x++) {
    			u32 color = data[x + y * 512];
    			u8 r = color & 0xff;
    			u8 g = (color >> 8) & 0xff;
    			u8 b = (color >> 16) & 0xff;
    			line[i++] = r;
    			line[i++] = g;
    			line[i++] = b;
    		}
    		png_write_row(png_ptr, line);
    	}
    	free(line);
    	png_write_end(png_ptr, info_ptr);
    	png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
    	fclose(fp);
    }

    Check out my homebrew & C tutorials at http://insomniac.0x89.org/
    Coder formerly known as Insomniac197

    tshirtz: what is irshell ??
    Atarian_: it's where people who work for the IRS go when they die

  4. #994
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Insomniac197
    As Twin891 already mentioned, the saveImage() functions from graphics.c is a good start.

    I use this function to save as a PNG.

    Code:
    void IMG_Screenshot(const char* filename)
    {
    	u32* data = (u32*)0x04000000;
            png_structp png_ptr;
    	png_infop info_ptr;
    	FILE* fp;
    	int i, x, y;
    	u8* line;
    	
    	if ((fp = fopen(filename, "wb")) == NULL) return;
    	png_ptr = png_create_write_struct(PNG
    _LIBPNG_VER_STRING, NULL, NULL, NULL);
    	if (!png_ptr) return;
    	info_ptr = png_create_info_struct(png_ptr);
    	if (!info_ptr) {
    		png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
    		return;
    	}
    	png_init_io(png_ptr, fp);
    	png_set_IHDR(png_ptr, info_ptr, 480, 272, 8,
    		PNG_COLOR_TYPE_RGB,
    		PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
    	png_write_info(png_ptr, info_ptr);
    	line = (u8*) malloc(480 * 3);
    	for (y = 0; y < 272; y++) {
    		for (i = 0, x = 0; x < 480; x++) {
    			u32 color = data[x + y * 512];
    			u8 r = color & 0xff;
    			u8 g = (color >> 8) & 0xff;
    			u8 b = (color >> 16) & 0xff;
    			line[i++] = r;
    			line[i++] = g;
    			line[i++] = b;
    		}
    		png_write_row(png_ptr, line);
    	}
    	free(line);
    	png_write_end(png_ptr, info_ptr);
    	png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
    	fclose(fp);
    }

    well, i tried this:
    Code:
    void Controls() {
    //read pad//
    	if (pad.Buttons & PSP_CTRL_SELECT) {
    		saveImage("test1.png", getVramDisplayBuffer(), 480, 272, 480, 1);
    	}
    }
    but when i try to compile it, it gives an error:

    Code:
    undefined reference to 'getVramDisplayBuffer()'
    undefined reference to saveImage(const char*, unsigned int*, int, int, int, int);
    how can i solve that?
    --------------------------------------------------------------------------------------

  5. #995
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    If you are using the graphics.c then you will need to #include graphics.h in your code, as well as add graphics.o and framebuffer.o to the OBJS in your makefile.

    Check out my homebrew & C tutorials at http://insomniac.0x89.org/
    Coder formerly known as Insomniac197

    tshirtz: what is irshell ??
    Atarian_: it's where people who work for the IRS go when they die

  6. #996
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    where can i find a keyboard in c/c++ exemple

    because i can find them only in lua:Argh:

  7. #997
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Insomniac197
    If you are using the graphics.c then you will need to #include graphics.h in your code, as well as add graphics.o and framebuffer.o to the OBJS in your makefile.

    i did that, and it still gives the same errors. help
    --------------------------------------------------------------------------------------

  8. #998
    QJ Gamer Blue
    Points: 4.464, Level: 42
    Level completed: 57%, Points required for next Level: 86
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Beiträge
    146
    Points
    4.464
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    I am trying to execute another eboot from within my eboot. I read about sceKernelLoadExec, but that didn't work. I read somewhere that the eboot needed to be kxploited. When I enter 'make', it gives me a single eboot.pbp. I assume this is not kxploited and is meant for 1.0 (which works fine with custom firmware). 'Make Kxploit' causes it not to show up in the list. If I execute it from irshell, it won't load.

    Currently, here is my test source code:
    Code:
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <pspdisplay.h>
    #include <pspctrl.h>
    #include <psploadexec.h>
    
    //I know I have a lot of #include, but I'm leaving them for later
    
    PSP_MODULE_INFO("Ebooy", 0x1000, 0, 1);
    #define printf pspDebugScreenPrintf /* 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 main (void) {
    	pspDebugScreenInit();
    	SetupCallbacks();
    	printf("Loading Eboot...\n");
    	sceKernelLoadExec("ms0:/PSP/GAME/hello/EBOOT.PBP", NULL);
    	printf("Eboot loaded\n");
    	return 0;
    }
    It is meant to execute the hello world app in the hello folder. This app isn't kxploited. When I run it, it gets past the printf statement, and then crashse (sends me back to the xmb).

    Please don't tell me to search. I've read every thread in this forum (as well as stuff found on google and ps2dev.org) that has anything to do with it. I think my problem has something to do with the hello world eboot (even though it runs fine by itself).

    Thanks in advance.

  9. #999
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    A kxploited eboot is basically an eboot without the param.sfo. I believe the sceKernelLoadExec file needs to be kxploited, or possibly in elf format I haven't really used it that much, so I'm not 100% sure.


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  10. #1000
    QJ Gamer Blue
    Points: 5.768, Level: 49
    Level completed: 9%, Points required for next Level: 182
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    457
    Points
    5.768
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Cheater
    I am trying to execute another eboot from within my eboot. I read about sceKernelLoadExec, but that didn't work. I read somewhere that the eboot needed to be kxploited. When I enter 'make', it gives me a single eboot.pbp. I assume this is not kxploited and is meant for 1.0 (which works fine with custom firmware). 'Make Kxploit' causes it not to show up in the list. If I execute it from irshell, it won't load.

    Currently, here is my test source code:
    Code:
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <pspdisplay.h>
    #include <pspctrl.h>
    #include <psploadexec.h>
     
    //I know I have a lot of #include, but I'm leaving them for later
     
    PSP_MODULE_INFO("Ebooy", 0x1000, 0, 1);
    #define printf pspDebugScreenPrintf /* 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 main (void) {
        pspDebugScreenInit();
        SetupCallbacks();
        printf("Loading Eboot...\n");
        sceKernelLoadExec("ms0:/PSP/GAME/hello/EBOOT.PBP", NULL);
        printf("Eboot loaded\n");
        return 0;
    }
    It is meant to execute the hello world app in the hello folder. This app isn't kxploited. When I run it, it gets past the printf statement, and then crashse (sends me back to the xmb).

    Please don't tell me to search. I've read every thread in this forum (as well as stuff found on google and ps2dev.org) that has anything to do with it. I think my problem has something to do with the hello world eboot (even though it runs fine by itself).

    Thanks in advance.
    ive had the same prob when i tried to make a mini shell and i asked every person and schearched every thread and i didnt find anything but you could try asking at pspdev.org (:

  11. #1001
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    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;" ?

  12. #1002
    QJ Gamer Silver
    Points: 14.087, Level: 77
    Level completed: 10%, Points required for next Level: 363
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Germany
    Beiträge
    926
    Points
    14.087
    Level
    77
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Lukeson
    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).
    Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
    Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
    Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
    Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.

  13. #1003
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    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);

    ?

  14. #1004
    QJ Gamer Silver
    Points: 14.087, Level: 77
    Level completed: 10%, Points required for next Level: 363
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Germany
    Beiträge
    926
    Points
    14.087
    Level
    77
    Downloads
    0
    Uploads
    0

    Standard

    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.
    Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
    Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
    Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
    Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.

  15. #1005
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Hm, I' getting errors:

    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
    Error:
    main.c: In function 'main':
    main.c:139: error: incompatible types in assignment

  16. #1006
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    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).


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  17. #1007
    QJ Gamer Blue
    Points: 4.464, Level: 42
    Level completed: 57%, Points required for next Level: 86
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Beiträge
    146
    Points
    4.464
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von PSP-Maniac
    ive had the same prob when i tried to make a mini shell and i asked every person and schearched every thread and i didnt find anything but you could try asking at pspdev.org (:
    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.

  18. #1008
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    how do you port this (cout to printf)
    cout<<"schrijf 2 getallen voor te vermenigvuldigen: ";
    cin>>x>>y;
    cin.ignore();
    cout<<"het produkt van de 2 getallen is ";
    cout<<x*y<<"\n";
    i tested this , but it only prints text and dont execute x*y
    printf("schrijf 2 getallen voor te vermenigvuldigen: ",x,y);
    printf("\n");


    printf("het produkt van de 2 getallen is ",x*y);

  19. #1009
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von homer
    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 don't quite get it. I tried various kinds of combinations between pointers and arrays. Eg.

    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);
    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 ?

  20. #1010
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    Here:
    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);
    You then use it like this (example code):
    Code:
    strcpy(mainMenu[0].subMenu[0].label, "Test0");
    mainMenu[0].subMenu[0].x = 0;
    mainMenu[0].subMenu[0].y = 0;
    To reallocate it you simply do this
    Code:
    mainMenu[0].subMenu = (MenuItem *)realloc(mainMenu[0].subMenu, 6*sizeof(MenuItem));


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  21. #1011
    QJ Gamer Blue
    Points: 7.538, Level: 57
    Level completed: 94%, Points required for next Level: 12
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    France
    Beiträge
    239
    Points
    7.538
    Level
    57
    Downloads
    0
    Uploads
    0

    Standard

    Well I decided to left LUA for C...
    So now I'm looking for a function that detects the color of a pixel (screenixel(x,y) in LUA) what's it in C??? Tx!

  22. #1012
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von homer
    Here:
    [ CODE ]

    You then use it like this (example code):
    [ CODE ]

    To reallocate it you simply do this
    [ CODE ]
    Thank you Homer!

  23. #1013
    Developer
    Points: 5.359, Level: 47
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Norway
    Beiträge
    384
    Points
    5.359
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Maxime
    Well I decided to left LUA for C...
    So now I'm looking for a function that detects the color of a pixel (screenixel(x,y) in LUA) what's it in C??? Tx!
    if youre using the graphics lib you can use
    Code:
    getPixelScreen(int x, int y)


  24. #1014
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    I don't wanna go on you guy's nerves, but I'm having a wierd error; Same code as above
    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);
            }
        }
    The problem is that the picture's all messed up:
    Miniaturansicht angehängter Grafiken Miniaturansicht angehängter Grafiken C/C++ Programming Help Thread-img_0575.jpg  

  25. #1015
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    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);


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  26. #1016
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    No, the width and height are definitely correct. Including the image directly (using a var Image *tmp for loadImage()) it works just fine

  27. #1017
    Points: 3.885, Level: 39
    Level completed: 57%, Points required for next Level: 65
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    6
    Points
    3.885
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    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;
    }

  28. #1018
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Maxime
    Well I decided to left LUA for C...
    So now I'm looking for a function that detects the color of a pixel (screenixel(x,y) in LUA) what's it in C??? Tx!

    if you want to check how to use lua functions in C, check the LUA player soure code. it has everything
    --------------------------------------------------------------------------------------

  29. #1019
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Lukeson
    I don't wanna go on you guy's nerves, but I'm having a wierd error; Same code as above
    [ code ]
    The problem is that the picture's all messed up
    That problem is, thanks to СУ&am solved now :)

    So I got time to come back to the transparency Issue.

    Zitat Zitat von homer
    Well, I use this to set the alpha value of images:
    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++;
    	}
    }
    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)

  30. #1020
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    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)
    Code:
    *databuf = (*databuf & 0x00ffffff) | ((A(*databuf)-(A(*databuf)-alpha))<<24);
    Looks like it affects it to me mate.

    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 =-
    Zitat Zitat von Grimfate126
    well, i tried this:
    Code:
    void Controls() {
    //read pad//
    	if (pad.Buttons & PSP_CTRL_SELECT) {
    		saveImage("test1.png", getVramDisplayBuffer(), 480, 272, 480, 1);
    	}
    }
    but when i try to compile it, it gives an error:

    Code:
    undefined reference to 'getVramDisplayBuffer()'
    undefined reference to saveImage(const char*, unsigned int*, int, int, int, int);
    how can i solve that?
    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.

    Just do:
    Code:
    IMG_Screenshot("myImage.png");
    Geändert von Insomniac197 (09-28-2006 um 04:22 AM Uhr) Grund: Automerged Doublepost

    Check out my homebrew & C tutorials at http://insomniac.0x89.org/
    Coder formerly known as Insomniac197

    tshirtz: what is irshell ??
    Atarian_: it's where people who work for the IRS go when they die


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 09:15 PM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .