Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Mar 2010
    Posts
    207
    Points
    395
         User Info     Contact     Gamer ID
    Join Date
    Mar 2010
    Posts
    207
    Points
    395

    Default Using Debug Screen In PRX

    This example will show you how to use the debug screen in a PRX. So you can make in game cheat devices and whatnot.

    Code:
    // crt0_prx.c
    #include <pspkernel.h>
    #include <pspdisplay_kernel.h>
    #include <pspctrl_kernel.h>
    #include <pspctrl.h>
    PSP_MODULE_INFO ("ExamplePRX", 0x3008, 1, 2);
    PSP_MAIN_THREAD_ATTR (0);
    PSP_HEAP_SIZE_KB (-128);
    SceUID thid;
    void *vpVideoRam = NULL;
    SceCtrlData pad;
    int module_start (SceSize args, void *argp) __attribute__ ((alias ("_start")));
    int module_stop (SceSize args, void *argp) __attribute__ ((alias ("_stop")));
    void ShowDebugScreen ();
    int mainThread ()
    {
        sceCtrlSetSamplingCycle (0);
        sceCtrlSetSamplingMode (PSP_CTRL_MODE_ANALOG);
        // Wait for the kernel library to load, some functions are needed from it, and our psp will crash if we can't access them.
        while (!sceKernelFindModuleByName ("sceKernelLibrary"))
        {
            sceKernelDelayThread (150000);
        }
        pspDebugScreenInitEx (0x44000000, 0, 0);
        unsigned int uiAddress = 0;
        unsigned int uiBufferWidth = 0;
        unsigned int uiPixelFormat = 0;
        unsigned int uiSync = 0;
        while (1)
        {
            // Print the display message
            if (!vpVideoRam)
            {
                sceDisplayGetFrameBufferInternal (0, &uiAddress, &uiBufferWidth, &uiPixelFormat, &uiSync);
                if (uiAddress)
                {
                    vpVideoRam = (void*) (0xA0000000 | uiAddress);
                }
                else
                {
                    sceDisplayGetMode (&uiPixelFormat, &uiBufferWidth, &uiBufferWidth);
                    pspDebugScreenSetColorMode (uiPixelFormat);
                    pspDebugScreenSetXY (0, 0);
                    pspDebugScreenSetTextColor (0xFF0000FF);
                    pspDebugScreenPuts ("Double Tap The Home Button, Then Press Screen.");
                }
                sceKernelDelayThread (1);
                // Reset the loop
                continue;
            }
            // Get the button input
            sceCtrlPeekBufferPositive (&pad, 1);
            // Check for if the menu was opened
            if (pad.Buttons & PSP_CTRL_SCREEN)
            {
                ShowDebugScreen ();
            }
            sceKernelDelayThread (1);
        }
        return 0;
    }
    int _start (SceSize args, void *argp)
    {
        thid = sceKernelCreateThread ("OurThread", &mainThread, 0x18, 0x1000, 0, NULL);
        if (thid >= 0)
        {
            sceKernelStartThread (thid, 0, NULL);
        }
        return 0;
    }
    int _stop (SceSize args, void *argp)
    {
        sceKernelTerminateThread (thid);
        return 0;
    }
    void ShowDebugScreen ()
    {
        // Disable the game's button input
        sceCtrlSetButtonMasks (0xFFFF, 1);
        sceCtrlSetButtonMasks (0x10000, 2);
        // Create and set up the debug screen
        sceDisplaySetFrameBufferInternal (0, vpVideoRam, 512, 0, 1);
        pspDebugScreenInitEx (vpVideoRam, 0, 0);
        // This while loop will keep us in the debug screen
        while (1)
        {
            // Get button input again
            sceCtrlPeekBufferPositive (&pad, 1);
            // If we press circle then break from the while loop
            if (pad.Buttons & PSP_CTRL_CIRCLE)
            {
                break;
            }
            // If we press home then enable the game's button input again, then return from the function
            // I do this and not break from the loop because the sceDisplaySetFramBufferInternal will close the home button screen
            if (pad.Buttons & PSP_CTRL_HOME)
            {
                sceCtrlSetButtonMasks (0x10000, 0);
                sceCtrlSetButtonMasks (0xFFFF, 0);
                return;
            }
            // You can now use the debug screen here, just as you would for homebrew.
        }
        // Close the debug screen
        sceDisplaySetFrameBufferInternal (0, 0, 512, 0, 1);
        // Enable the game's button input
        sceCtrlSetButtonMasks (0x10000, 0);
        sceCtrlSetButtonMasks (0xFFFF, 0);
        return;
    }
    Code:
    // crt0_prx.h
    #ifndef CRT0_H
    #define CRT0_H
    #include <pspkernel.h>
    #include <pspdisplay.h>
    #include <pspctrl.h>
    #include <pspumd.h>
    #include <stdio.h>
    #include <stdlib.h>
    #endif
    Code:
    // exports.c
    #include <pspmoduleexport.h>
    #define NULL ((void *) 0)
    void extern module_start;
    void extern module_stop;
    void extern module_info;
    static const unsigned int __syslib_exports [6] __attribute__ ((section (".rodata.sceResident"))) =
    {
        0xD632ACDB, 0xCEE8593C, 0xF01D73A7,
        (unsigned int) &module_start, (unsigned int) &module_stop, (unsigned int) &module_info,
    };
    const struct _PspLibraryEntry __library_exports [1] __attribute__ ((section (".lib.ent"), used)) =
    {
        {
            NULL,
            0x0000, 0x8000,
            4, 1, 2,
            &__syslib_exports
        },
    };
    Code:
    # makefile
    TARGET = ExamplePRXByLeetGamer
    OBJS = crt0_prx.o exports.o
    BUILD_PRX = 1
    PSP_FW_VERSION = 150
    PRX_EXPORTS = exports.exp
    USE_KERNEL_LIBS = 1
    USE_KERNEL_LIBC = 1
    INCDIR =
    CFLAGS = -O2 -G0 -w -msingle-float -g
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)
    LIBDIR =
    LIBS = -lpspchnnlsv -lpsputility -lpspdebug -lpspge_driver -lpspwlan -lpspumd -lpsppower -lpspwlan -lpspnet -lpsprtc -lpsphprm
    LDFLAGS = -nostdlib  -nodefaultlibs -g
    PSPSDK=$(shell psp-config --pspsdk-path)
    include $(PSPSDK)/lib/build.mak
    Double tap home then press screen to open the menu.
    Press O or home to close it.

    0 Not allowed! Not allowed!
    AIM & Skype: iLeetGamerX

    Youtube: http://www.youtube.com/user/CurlyBraceProduction

  2. #2
    Robot Universe Owner
    Creator of DarkFrost
    demon450's Avatar
    Join Date
    Apr 2010
    Location
    New York
    Posts
    2,714
    Points
    6,203
         User Info     Contact     Gamer ID
    Join Date
    Apr 2010
    Location
    New York
    Posts
    2,714
    Points
    6,203
    Gamer IDs

    Gamertag: Medius450 PSN ID: Medius1337

    Contact info:

    Youtube Channel: http://www.youtube.com/user/Roceso1337

    Default

    i remember when you were learning how to install it im so proud of you :groar:

    0 Not allowed! Not allowed!
    Check out Darkfrost
    Check out Robot Universe






  3. #3
    PSP Coder Mr_Waffle's Avatar
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    182
    Points
    391
         User Info     Contact     Gamer ID
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    182
    Points
    391
    Gamer IDs

    PSN ID: Mr_Waffle

    Default

    Quote Originally Posted by demon450 View Post
    i remember when you were learning how to install it im so proud of you :groar:
    !

    Anyway, any chance on some smexxy screenies?

    0 Not allowed! Not allowed!

  4. #4
    Member
    Join Date
    Mar 2010
    Posts
    207
    Points
    395
         User Info     Contact     Gamer ID
    Join Date
    Mar 2010
    Posts
    207
    Points
    395

    Default

    lol demon

    Quote Originally Posted by Mr_Waffle View Post
    !

    Anyway, any chance on some smexxy screenies?
    It is a black screen =/

    0 Not allowed! Not allowed!

  5. #5
    Robot Universe Owner
    Creator of DarkFrost
    demon450's Avatar
    Join Date
    Apr 2010
    Location
    New York
    Posts
    2,714
    Points
    6,203
         User Info     Contact     Gamer ID
    Join Date
    Apr 2010
    Location
    New York
    Posts
    2,714
    Points
    6,203
    Gamer IDs

    Gamertag: Medius450 PSN ID: Medius1337

    Contact info:

    Youtube Channel: http://www.youtube.com/user/Roceso1337

    Default

    so. i like my screenies.
    and also heres a link for you leet
    www.demongen.org/pspsdk

    ---------- Post added at 06:46 AM ---------- Previous post was at 06:46 AM ----------

    so. i like my screenies.
    and also heres a link for you leet
    www.demongen.org/pspsdk

    0 Not allowed! Not allowed!
    Check out Darkfrost
    Check out Robot Universe






Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -10. The time now is 04:08 PM.
Powered by vBulletin®
Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.