• Steam recently changed the default privacy settings for all users. This may impact tracking. Ensure your profile has the correct settings by following the guide on our forums.

The Help Thread

angelsniper45

New Member
This thread will be for all developers, C and C++, and Java, for those who have experience in it.

This was x3's idea, im just carrying it out.

So post ONLY help with your development projects in this thread and we will get back to you as soon as we can.
 

Alex

Active Member
So let me have the first question answered,
when using:

printTextScreen(50,20,"random text", colour);

do you have to use flipscreen or is it just like printf plus the colour indication and co-ordinates?
 

Roe

Well-Known Member
So let me have the first question answered,
when using:

printTextScreen(50,20,"random text", colour);

do you have to use flipscreen or is it just like printf plus the colour indication and co-ordinates?
You need to use flipscreen as it writes to the draw buffer.

Edit: Fixed the title, now it says "Help", instead of "Hep". I've also stickied the thread :)
 

Alex

Active Member
so say if i want to print multiple text, ie


printTextScreen(50,20,"doing something", colour);
printTextScreen(50,20,"done", colour);

do i need to flip the screen once or after each printTextScreen?
 

angelsniper45

New Member
yes because if you flip the screen everytime, wont you just get a bunch of flashing and not actual text?

like

printf
flipscreen()
printf
flipscreen()

wouldnt that create some flashing effect?
 

Roe

Well-Known Member
I guess it could be described as a flashing effect... It's because pspDebugScreenPrintf defaults to drawing to the start of vram so it only draws on one of the buffers set up in graphics.c. Which means when the flipScreen swaps buffers, it's swapping between a black debug screen and the other buffer.

Again with an explanation that I'm not sure is explained to well...
 

angelsniper45

New Member
ok. i thought it would be using both buffers

so its really only needed once in text based programs?
 

XsavioR

Member
Midi firmware.

I am having trouble with C syntax. I program in ASM.

This is part of a midi controller usb 2.0 firmware im writing.


I am trying to define an output buffer. The maximum size of which will be 44 bytes.
These 44 bytes, are made up of 4 byte sections. 11 in total.

One of these bytes , the last, will change.

For instance.....

Code:
                char INPacket[] = { 0x0B, 0xB0, 0x00, 0x69 };

Is how i did it for one button. Now on a button the last byte will be 0x00 or 0x69, on or off.

Then the others are nearly identical only the last byte can be 0 - 127, and the second bytes will progress up, to signify controll 1 , 2 , 3, etc.

I plan to read the Pots possition and put the result into the 4 bytes for that controll, repeat for all 11 controlls, and then send all at once.

Ok so how do i define a buffer that will hold 11 messages, and then lable each section to the button.

ie

inbuffer[44] sw1,sw2,sw3,sw4,nob1,nob2,nob3,slide1,slide2,slide3,slide4,

Then after scanning all of them, do this,
Code:
char INPacket[] = inbuffer[]
                    //make sure that the last transfer isn't busy by checking the handle 
                    if(!USBHandleBusy(USBGenericInHandle))
                    {
                    //Send the data contained in the INPacket[] array out on
                    //  endpoint USBGEN_EP_NUM
                    USBGenericInHandle = USBGenWrite(USBGEN_EP_NUM,(BYTE*)&INPacket[0],4);
 

Roe

Well-Known Member
Hey XsavioR! I'm not entirely sure if I understand what you are trying to do but if I understand correctly, you could create a two dimensional array to hold the 11 messages at 4 bytes each like so:
Code:
char buffer[11][4] = {
	{0,0,0,0},
	{1,1,1,1},
	// ...
	{10,10,10,10}
};
Hope it helps.
 

XsavioR

Member
Thought i would post the proper solution. This is the C routine for proccessio , on a usb 2.0 midi controller firmware i just completed. Gonna post it when its 100 % done. but heres a snippet. Currently working on making the two hardware inputs use different software channles.

Code:
void ProcessIO(void)
{   
    //Blink the LEDs according to the USB device status
    if(blinkStatusValid)
    {
        BlinkUSBStatus();
    }

                     
ReadPOT();
if (ADRESH != old_pot)
   {
   // Reference material                          : http://www.midi.org/techspecs/midimessages.php
   // Section                                     : Table 1: MIDI 1.0 Specification Message Summary 
   INPacket._byte[0] = 0x0B;                     // Cable Number is the upper nibble , Index Number is the lower nibble
   INPacket._byte[1] = 0xB0;                     // midi Control Change 1011nnnn (nnnn = 0-15 MIDI Channel Number 1-16)
   INPacket._byte[2] = 0x00;                     // (ccccccc) is the controller number (0-119).
       old_pot = ADRESH;                 // try to limit output to new possition only    
       STATUSbits.C = 0;                 // Clear Status C bit , shift threw carry will zero MSB
       _asm RRCF    ADRESH,1,0 _endasm   // Shift ADRESH threw carry (zeros MSB)
   INPacket._byte[3] =ADRESH;                     // MIDI controll Value (0-127)
   new_input = 1;                        // Call TX
   }                                     // end if new pot

if(Switch2IsPressed() == TRUE)
  {
    switch (state2)
        {
        case on:
            {
            // Reference material                 : http://www.midi.org/techspecs/midimessages.php
            // Section                            : Table 1: MIDI 1.0 Specification Message Summary     
            INPacket._byte[5] = 0x0B;             // Cable Number is the upper nibble , Index Number is the lower nibble
            INPacket._byte[6] = 0xB0;             // midi Control Change 1011nnnn (nnnn = 0-15 MIDI Channel Number 1-16)
            INPacket._byte[7] = 0x77;             // (ccccccc) is the controller number (0-119).
            INPacket._byte[8] = 0x69;             // MIDI control Value for BOOL type inputs. on (0-127, BOOL ON =64 )
            state2 = off;                       // Set case for next round
            new_input = 1;                    // NEW data to be sent
            mLED_3_On();                     // Toggle led 3 for Visual feed back
            break;
            }
        
        case off:
            {
            // Reference material                 : http://www.midi.org/techspecs/midimessages.php
            // Section                            : Table 1: MIDI 1.0 Specification Message Summary  
            INPacket._byte[5] = 0x0B;             // Cable Number is the upper nibble , Index Number is the lower nibble
            INPacket._byte[6] = 0xB0;             // midi Control Change 1011nnnn (nnnn = 0-15 MIDI Channel Number 1-16)
            INPacket._byte[7] = 0x77;             // (ccccccc) is the controller number (0-119).
            INPacket._byte[8] = 0x00;             // MIDI control Value for BOOL type inputs. OFF (0-127, BOOL OFF =63 we use 0 to allow button to control a nob)
            state2 = on;                       // Set case for next round
            new_input = 1;                   // NEW data to be sent
            mLED_3_Off();                   // Toggle led 3 for Visual feed back
            break; 
            }
        }
  }              

if (new_input == 1)                       //Is there new data ? 
            {
            // User Application USB tasks
            if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) return;
            //make sure that the last transfer isn't busy by checking the handle
                if(!USBHandleBusy(USBGenericInHandle))
                {
                //Send the data contained in the INPacket[] array out on
                //endpoint USBGEN_EP_NUM
                new_input = 0;            //NEW data sent
                USBGenericInHandle = USBGenWrite(USBGEN_EP_NUM,(BYTE*)&INPacket,4);
                }

            }
}//end ProcessIO
 

angelsniper45

New Member
so what excactly is this firmware for? I understand that its a USB firmware, but whats the handle going to be? psp? or is it just a general firmware?

it would help to know what your doing first off...lol
 

XsavioR

Member
Oh lol sorry i tried to be vauge to begin with as to not complicate the answers I got.

I design Hardware.

Start with a microcontroller. build circuitry , Write code to run it... Usually I have used low level options , from BASIC to ASSEMBLY. Ive been forced to learn C and it is less time consuming to write. So the option to just move over to it is more appealing. The thing is if i explain this b4 asking you guys for help I get some rather creative answers that usually dont work. Usually being as vauge as i can be.... leads to vauge syntaxish answers which is exactly what i need.

The rules for my programming are basic C syntax, plus a 200 page manual. So now to answer the other half.

Its a usb MIDI controller for music production with programs such as Reason Cubase etc. Ive been building MIDI controllers to learn various things.

PS it is indeed possible to design usb devices, with limited functionality, That connect to the psp usb port.....
Restrictions:
Must get hands on usb psp device to procure some 0's and 1's it uses
Must design device within specifications of original device.
Bottom line:
We can make devices... if we use the ID's associated to the original device, and you can only do this using functions the original device had. SO if they made a gps , we can make a gps, if they made a camera we can make a camera..... if they had a button on the gps or camera we can make a button. we could then in therory make a usb external controller. using the api already present to read a button press on the gps or camera.

The psp is an otg host. That means its a usb device that can indeed act as a host to devices it was specifically programmed to use. Manipulation of what HAS been released can indeed be used to make new previously unavailable in the usa devices at home. And with some effort,,, even unique devices. Though its leaps and bounds beyond my ability on my own, it is possible to code the psp to accept new devices. We're talking about writing drivers basically. It would take the best programmers in the scene. TBH the serial port on the psp1k is PWNAGE. But the removal of the serial/audio jack with the 2k left no option but to utilize the otg host capability to increase functionality.
 

angelsniper45

New Member
Oh ok, so this is a bottom up build.

I thought you were just modifying a piece a software or whatever.

Well im not really one for toting with usbs because they do what I need , but when you define multiple paths like you were saying, I believe roe-ur-boat is correct. :)
 

XsavioR

Member
Yeah it is what I plan to do with the final code, Im trying so far to keep all the code as easy to read as possible. To be self intuitive for a user to pick up and understand how to manipulate it to send unique messages.

Thanks roe btw i think i failed to say so b4 , my bad bud.
 

Alex

Active Member
Renaming A File In Flash

Alright, im trying to rename a file in the flash. im in VSH mode (0x800) and i am assigning the flash.

heres my code.
Code:
sceIoRename("flash0:/vsh/module/vshmain.prx", "flash0:/vsh/module/vshmain_real.prx");

its not working though. im trying to make a lockdown installer and renaming the files is the only part that fails.
 

Roe

Well-Known Member
Are you sure you assigned flash correctly? Show me how you do it and I'll see what I can do.
 

Alex

Active Member
okie dokie :p

Code:
if (pad.Buttons & PSP_CTRL_CROSS) {
		SceUID check;
	printf("Searching for vshamin.prx...\n");
	check = sceIoOpen("./vshmain.prx", PSP_O_RDONLY, 0777);
	if (check < 0) {
	Wait;
		printf ("Error: Cannot Find vshmain.prx\n");
	}
	else {
	Wait;
		printf("vshmain.prx found\n");
		printf(" - Assigning flash0....\n ");                       
                        if (sceIoUnassign("flash0:") < 0)
                        printf("Cannot Un-Assign flash0:");
                        if (sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0) < 0) {
                                             printf("Error Assigning flash0 in write mode"); }
                        printf("- Flash Assigned\n");
sceIoRename("flash0:/vsh/module/vshmain.prx", "flash0:/vsh/module/vshmain_real.prx");
break:}


thats just the snippet or the loop its in
 
Top