11/08/2006

2nd CtrlP0okm.bin sample

 
 
Download-Link #1: 2nd.CtrlP0okm.sample.src.zip

when press LTRIGGER it will auto press Buttons CIRCLE & CROSS
2nd.CtrlP0okm.bin sample

main.c

// auto press Buttons CIRCLE & CROSS sample

/*
pad_data :
    unsigned int     TimeStamp; // The current read frame.
    unsigned int     Buttons;   // Bit mask containing zero or more of ::PspCtrlButtons.
    unsigned char    Lx;        // Analogue stick, X axis.
    unsigned char    Ly;        // Analogue stick, Y axis.
    unsigned char    Rsrv[6];   // Reserved.

Buttons :
    PSP_CTRL_SELECT   = 0x00000001,    // Select button.
    PSP_CTRL_START    = 0x00000008,    // Start button.
    PSP_CTRL_UP       = 0x00000010,    // Up D-Pad button.
    PSP_CTRL_RIGHT    = 0x00000020,    // Right D-Pad button.
    PSP_CTRL_DOWN     = 0x00000040,    // Down D-Pad button.
    PSP_CTRL_LEFT     = 0x00000080,    // Left D-Pad button.
    PSP_CTRL_LTRIGGER = 0x00000100,    // Left trigger.
    PSP_CTRL_RTRIGGER = 0x00000200,    // Right trigger.
    PSP_CTRL_TRIANGLE = 0x00001000,    // Triangle button.
    PSP_CTRL_CIRCLE   = 0x00002000,    // Circle button.
    PSP_CTRL_CROSS    = 0x00004000,    // Cross button.
    PSP_CTRL_SQUARE   = 0x00008000,    // Square button.
    PSP_CTRL_HOME     = 0x00010000,    // Home button.
    PSP_CTRL_HOLD     = 0x00020000,    // Hold button.
    PSP_CTRL_WLAN_UP  = 0x00040000,    // Wlan switch up.
    PSP_CTRL_REMOTE   = 0x00080000,    // Remote hold position.
    PSP_CTRL_VOLUP    = 0x00100000,    // Volume up button.
    PSP_CTRL_VOLDOWN  = 0x00200000,    // Volume down button.
    PSP_CTRL_SCREEN   = 0x00400000,    // Screen button.
    PSP_CTRL_NOTE     = 0x00800000,    // Music Note button.
    PSP_CTRL_DISC     = 0x01000000,    // Disc present.
    PSP_CTRL_MS       = 0x02000000,    // Memory stick present.

mode :
    sceCtrlPeekBufferPositive = 0x0
    sceCtrlPeekBufferNegative = 0x1
    sceCtrlReadBufferPositive = 0x2
    sceCtrlReadBufferNegative = 0x3

Buff :
    Buff[0] Reserved
    Buff[1] *pad_data
    Buff[2] count
    Buff[3] mode
    Buff[4-63] for CtrlP0okm.bin use
*/
#include <pspctrl.h>

int _start(int *pad_data, int count, int mode, int ret_data, int *Buff)
{
    if (pad_data[1] & PSP_CTRL_LTRIGGER)
        Buff[4] = 0;

    if (Buff[4] < 4)
    {
        unsigned int Buttons = pad_data[1];
        unsigned int temp = pad_data[0] & 0x00110000;
        if (temp == 0x00000000)
        {
            Buttons = Buttons | PSP_CTRL_CROSS;
            Buff[5] = 1;
        }
        if (temp == 0x00110000)
        {
            Buttons = Buttons | PSP_CTRL_CIRCLE;
            Buff[6] = 1;
        }
        pad_data[1] = Buttons;

        if ((Buff[5] == 1)&&(Buff[6] == 1))
        {
            Buff[4]++;
            Buff[5] = 0;
            Buff[6] = 0;
        }
    }

    return ret_data;
}


Makefile



PSPDEV=/usr/local/pspdev/bin
INCLUDES=-I $(PSPDEV)/../psp/sdk/include


all:    main.bin

main.bin:
    $(PSPDEV)/psp-gcc $(INCLUDES) -W -Wall -G0 -fno-pic -mno-abicalls -w -S main.c -o main.s
    $(PSPDEV)/psp-as main.s -o main.o
    $(PSPDEV)/psp-ld -T psp20bin.x main.o -o main.elf
    $(PSPDEV)/psp-objcopy -O binary main.elf CtrlP0okm.bin


psp20bin.x

OUTPUT_FORMAT("elf32-littlemips")
OUTPUT_ARCH(mips)

ENTRY(_start)

SECTIONS
{
  . = 0x00000000;
  .text.start : {
    *(.text.start)
  }
  .text : {
    *(.text)
  }
  .rodata : {
    *(.rodata)
  }
  .data : {
    *(.data)
  }
  .bss : {
    *(.bss)
  }
}

3 Comments:

At 11/09/2006 04:25:00 am, Blogger kluster said...

Excellent work 0okm, would it be possible to switch the analog controls with the d-pad controls with this script?

If so perhaps you could give an example of how you would set that up.

Thanks for all your hard work and dedication to the PSP scene.

 
At 11/09/2006 08:04:00 am, Blogger 0okm said...

>> kluster
THX :)

hook the d-Pad with AnalogStick
3rd.CtrlP0okm.bin sample

 
At 11/09/2006 07:28:00 pm, Blogger Moca said...

woah. Nice job 0okm. I like the idea to switch analog with d-pad. It is interesting. I like what you are doing with this. Keep up the great work.

 

Post a Comment

<< Home