Technically that's assigning not defining, but yeah, that's what he's talking about.
Printable View
Technically that's assigning not defining, but yeah, that's what he's talking about.
I know this is in the simon code, but I cant decipher it all.
How can you make the code wait a while before displaying anymore.
Code:int main(void)
while (1){
if (area==0){
printf("Press circle to go left or press cross to go right.\n");
if (pad.Buttons & PSP_CTRL_CIRCLE) {
status=1;}
if (pad.Buttons & PSP_CTRL_CROSS){
status=2;}
}
/* Here is where I want to be able to pause the program
* Such as a timer, when the timer gets to a certain point it moves on
* if this code was complete the person would automatically go to 6 or 4 imediatly
* I tried disecting Simon's source code to find my answer, but it was too complicated.
* The pause would either happen before the code goes to next area or inside the area, im assuming
*/
if (area==1){
printf("Press circle to go left or press cross to go right.\n");
if (pad.Buttons & PSP_CTRL_CIRCLE) {
status=3;}
if (pad.Buttons & PSP_CTRL_CROSS){
status=4;}
}
if (area==2){
printf("Press circle to go left or press cross to go right.\n");
if (pad.Buttons & PSP_CTRL_CIRCLE) {
status=5;}
if (pad.Buttons & PSP_CTRL_CROSS){
status=6;}
}
}
sceKernelExitGame();
return 0;
}
I've tried a few tutorials for building the keychain. All the folders appear to have been made in the correct places...
Here's what happens though... my computer just restarts about 1 hour into the process. I've tried it in Windows XP after formatting/reinstalling and using cygwin. I've also tried it in slackware 10.1 with the same result... WTF? :Argh:
How do you print a pixel, draw a line and use the psp's keyboard for input?
ok great tutorials...
after checking out a lot of code, i managed to make my own app...
dont worry its got no errors and dont need help right now...
its basically an app with which you can use your psp as a remote control and control your tv/etc...
right now, i have made an app which controls only a lg tv...
as i get used to coding big programs, ill make an app which will control multiple things...
i had uploaded the file, but it seems it isnt hosted there...
in any case, i was going to make my own site to host my apps and source code, so its here:
http://www.freewebs.com/pspbrew/
ill shorten the url later... for now, if you want to check it out go ahead...
and btw, heres the source code for my app...
the compiled eboots for 1.0 and 1.5 are availabe at my site...Code:
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* main.c - LG Remote Control by cyanide...
*
* Copyright (c) 2005 Marcus R. Brown <[email protected]>
* Copyright (c) 2005 James Forshaw <[email protected]>
* Copyright (c) 2005 John Kelley <[email protected]>
* Copyright (c) 2005 Matthew H <[email protected]>
*
* Modified the SIRCS example to use my own equipment...
* by cyanide.... mail me at [email protected] for any questions...
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspsircs.h>
#include <stdlib.h>
#include <string.h>
/* Define the module info section */
PSP_MODULE_INFO("LGREM", 0, 1, 1);
/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
#define printf pspDebugScreenPrintf
/* rather than passing the data later, i just defined these addresses right now so
* that it would be easy to change them later if i wanted to include/replace the addresses
* of different equipment...
*/
#define SIRCS_ADDR_DVD 0x20DF
#define SIRCS_CMD_MUTE 0x906F
#define SIRCS_CMD_POWER 0x10EF
#define SIRCS_CMD_VIDEO 0xD02F
#define SIRCS_CMD_DISPLAY 0x020
#define SIRCS_CMD_CHUP 0x00FF
#define SIRCS_CMD_CHDN 0x807F
#define SIRCS_CMD_VLUP 0x40BF
#define SIRCS_CMD_VLDN 0xC03F
void send_code(int type, int dev, int cmd)
{
struct sircs_data sd;
int ret;
int count = 20; // this seems like a good number
sd.type = type;
sd.cmd = cmd & 0x7f;
sd.dev = dev & 0x1fff;
ret = sceSircsSend(&sd, count);
if (ret < 0)
{
printf ("sceSircsSend returned %d\n", ret);
}
}
/* 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)
{
SceCtrlData pad;
u32 buttonsold = 0;
int sirc_bits = 20; // # of bits in code, choose from 12, 15 or 20
SetupCallbacks();
pspDebugScreenInit();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);
printf(" cyanide's LG TV Remote Control Program... \n");
printf(" mail me at [email protected] \n\n\n");
printf(" List of Operations: \n\n\n");
printf("Switch On / Off TV : Press X \n\n");
printf("TV / Video Mode : Press Square\n\n");
printf("Mute / Unmute Sound: Press Circle\n\n");
// printf("Toggle Display : Press Triangle\n\n\n\n");
// Commented the above line because my LG TV did not use this function...
printf(" Channel / Volume Controls \n\n\n");
printf("Channel Up : Up Button\n\n");
printf("Channel Down : Down Button\n\n");
printf("Volume Increase : Right Button\n\n");
printf("Volume Decrease : Left Button\n\n\n");
printf("Press Start to show guide again\n\n");
do {
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons != buttonsold)
{
//Main TV Controls
if (pad.Buttons & PSP_CTRL_CIRCLE)
{
printf ("Muting Sound\n");
send_code(sirc_bits, SIRCS_ADDR_DVD, SIRCS_CMD_MUTE);
}
if (pad.Buttons & PSP_CTRL_CROSS)
{
printf ("Turning Power On/Off\n");
send_code(sirc_bits, SIRCS_ADDR_DVD, SIRCS_CMD_POWER);
}
if (pad.Buttons & PSP_CTRL_SQUARE)
{
printf ("Switching TV/Video Mode\n");
send_code(sirc_bits, SIRCS_ADDR_DVD, SIRCS_CMD_VIDEO);
}
if (pad.Buttons & PSP_CTRL_TRIANGLE)
{
printf ("Display Toggle\n");
send_code(sirc_bits, SIRCS_ADDR_DVD, SIRCS_CMD_DISPLAY);
}
//Volume and Channel Controls
if (pad.Buttons & PSP_CTRL_RIGHT)
{
printf("Increase Volume\n");
send_code(sirc_bits, SIRCS_ADDR_DVD, SIRCS_CMD_VLUP);
}
if (pad.Buttons & PSP_CTRL_DOWN)
{
printf("Channel Down\n");
send_code(sirc_bits, SIRCS_ADDR_DVD, SIRCS_CMD_CHDN);
}
if (pad.Buttons & PSP_CTRL_LEFT)
{
printf("Decrease Volume\n");
send_code(sirc_bits, SIRCS_ADDR_DVD, SIRCS_CMD_VLDN);
}
if (pad.Buttons & PSP_CTRL_UP)
{
printf("Channel Up\n");
send_code(sirc_bits, SIRCS_ADDR_DVD, SIRCS_CMD_CHUP);
}
//Start Button Press
if (pad.Buttons & PSP_CTRL_START)
{
pspDebugScreenInit();
printf(" cyanide's LG TV Remote Control Program... \n");
printf(" mail me at [email protected] \n\n\n");
printf(" List of Operations: \n\n\n");
printf("Switch On / Off TV : Press X \n\n");
printf("TV / Video Mode : Press Square\n\n");
printf("Mute / Unmute Sound: Press Circle\n\n");
// printf("Toggle Display : Press Triangle\n\n\n\n");
// Commented the above line because my LG TV did not use this function...
printf(" Channel / Volume Controls \n\n\n");
printf("Channel Up : Up Button\n\n");
printf("Channel Down : Down Button\n\n");
printf("Volume Increase : Right Button\n\n");
printf("Volume Decrease : Left Button\n\n\n");
printf("Press Start to show guide again\n\n");
}
buttonsold = pad.Buttons;
}
sceDisplayWaitVblankStart();
} while (1);
return 0;
}
and if you want me to make this kind of app for your tv, etc, mail me the exact model no of your remote and tv,etc...
and btw, heres my makefile
thanks...Code:TARGET = LGREM
OBJS = main.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lpspsircs
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = LG Remote
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Thank You for these FAQS they kick some major booty haha
i have complied the "helloworld" program and got the EBOOT,when i put it into
the emulator directory and then start the emulator,the emulator window closed quickly(maybe 2 seconds later),and the directory i got a file "sterr.txt":
contents:
load C:\cygwin\home\powerise\p roject\EBOOT.PBP
PBP format
psppath:(null)
9fffc00
illegal address
PC = 00000000
00000000 00000000 00000000 00000000
7fffffff 00000001 09fffc00 00040000
80000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
77d48816 09fffbf0 00000000 00000000
anybody can resolved it!
in face,sometimes another "sterr.txt" file also be created by the emulator,contents blow:
libpng error: Not a PNG file
Fatal signal: Segmentation Fault (SDL Parachute Deployed)
Emulater.... Doyoumean compiler?Zitat:
Zitat von NewMoreOne
I think he means a psp emulator on the computer.Zitat:
Zitat von Twenty 2
yes,emulator is a psp emulator that running on pc,it's name 'pspe',anybody know the reason?
It's probably a problem with the emulator.Zitat:
Zitat von NewMoreOne
but now,it's this emulator can't be found on the internet.does anyone konws another emulator of psp for pc? and anybody had running "helloworld",successful.i f you do,paste a screen shot please.i want know what it should be show.
Hey guys; I found an awesome C tutorial if you're looking to learn;
http://computer.howstuffworks.com/c.htm
It goes as far as dynamic data structures using pointers (which, I belive I read somewhere, you really need to use when coding for the PSP, from the tiny bit I know, most every program makes good use of pointers).
The code in the tutorial can be compiled using Cgywn as set up in the (awesome) first tutorial.
To compile code form the tutorial without a makefile:
From Command.com for windows:
gcc -o programname.exe sourcefile.c
From inside Cgywn for linux:
gcc -o programname.exe sourcefile.c
I hope that helps out some fellow newbies :-)
Now can someone please help me out? I've been finding the samples included with the SDK really hard to follow! I had a look in blit and my brain exploded (even after stripping out the undeeded extras like the FPS counter).
How does one just blit a bitmap? It seems similar to Lua in that you write to a buffer then flip (sceGuSwapBuffers();)
And this line:
Seems to be actual draw-the-picture line; but where do I find out what these arguements are? Also, the script generates the image itself, which is scary. Can we read a bitmap or a PNG or something?Code:sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_4444|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices);
========
Further noobish code disassembely, to prove that I am trying!
So we create an array of (static unsigned) shorts with the array size the number of pixels we want:
Then we have this:Code:static unsigned short __attribute__((aligned(16))) pixels[512*272];
So, we create an unsigned short in the free store called row and give it the memory address of the pixels[] element? I don't understand!Code:for (y = 0; y < 272; ++y)
{
unsigned short* row = &pixels[y * 512];
for (x = 0; x < 480; ++x)
{
row[x] = x * y;
}
}
========
Anyways, you can see I'm new. Maybe we can see a Tutorial Part 4? :-) I hope the HowStuffWorks tut helps some people out, it's nice and easy to follow.
Don't try to use PSPE; it's extremely outdated and won't work with any code newer than when the PSPDev Beta 1.0 came out (June). You really need to test directly on the PSP.
yeah, plus its slower :p
The tutorials are good and all, but I am looking for documentation on the hardware.
I have already programmed for stuff like gameboy advance in c, but im looking for documentation on things like the interrupts etc. etc. and if you can use built in decoders for image and sound files. Where can I get information about this?
I have done everything in the tutorials but cant get the EBOOT to run. I get:
The game could not be started. (80020001). On my psp.
I dont get any errors or warnings when making the eboot. I am running 1.5 on my PSP if that makes a difference.
ermm never mind i had a kxploit problem
Can Lua Be ported to C++?.
i want to change the background screen to red using "pspdebug.h"
do i use this
void pspDebugScreenSetBackColo r(u32 color);
or is there another way to do this using any other hedder?
also how can i find the u32 color for red or for any other color.
hope you can help.
Look around, there are some simple functions that will go from RGB to u32.
And yes, that function should work.
//THE RGB FUNCTION NEEDS TO BE AT THE TOP
//THEN DO THIS FOR RED:
RGB(255, 0, 0);
thanks
pspDebugScreenSetBackColo r();
Dose not work it only colours in the line that text is on. not the whole screen.
i looking for a function to color the full screen.
its ok i put this line after the function
pspDebugScreenSetBackColo r(000255000255);
pspDebugScreenClear();
This fills the whole screen for me.
Is there a way to access the psp internal memoy in realtime (while connected to usb) so that when you download a demo game from "gameshare" you can access the eboot from the internal memory and download it?
Also, since the psp searches for a game to demo when you choose "gameshare" is there a way to create an html or internet link to set downloadable demo's to or figure out what the psp is looking for when you select "gameshare". ie; web address, etc.
Thanx!!
If this was the wrong post, sorry.
You could probably dump the memory but it would be pretty difficult to do it with gameshare unless you somehow got it to run while your app was still running. I think someone did find a way to run homebrew and the os at the same time... but I forget how they do it.
Maybe on 2.0 you could... not sure though (2.0 exploit runs code at the same time as the OS is going)
Hey everyone! I started trying to learn PSP yesterday (amazing how similar it seems to Java) and I hit a snag trying to make my own version of the menu program someone posted a while back. Here is my code:
The errors I get are:PHP-Code:// My Third PSP Application - Menu
/* This program was created by Ross B. Leland on 10/07/2005.
It is a basic menu. */
#include <pspdebug.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <stdlib.h>
PSP_MODULE_INFO("Menu Test", 0, 1, 1);
#define printf pspDebugScreenPrintf
//Defines buttons
#define up PSP_CTRL_UP
#define down PSP_CTRL_DOWN
#define left PSP_CTRL_LEFT
#define right PSP_CTRL_RIGHT
#define cross PSP_CTRL_CROSS
#define triangle PSP_CTRL_TRIANGLE
#define square PSP_CTRL_SQUARE
#define circle PSP_CTRL_CIRCLE
#define XMAX 32
#define YMAX 67
void dump_threadstatus(void);
int done = 0;
/* 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 to 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;
}
// Start of the menu command
int goToMenu(int opt) {
//Define variables
pspDebugScreenSetXY(25, 1);
printf("The Poking Game");
//Menu Selections
if (opt == 1) {
printf(" >-Start Poking\n");
}
else {
printf(" --Start Poking\n");
}
if (opt == 2) {
printf(" >-Stop Poking\n");
}
else {
printf(" --Stop Poking\n");
}
if (opt == 3) {
printf(" >-Leave the Arena\n");
}
else {
printf(" --Leave the Arena\n");
}
return opt;
}
//Main Code
int main(void) {
//Define Variables
int counter = 0;
int i = 0;
int z = 0;
int Mx = 0;
SceCtrlData pad;
pspDebugScreenInit();
SetupCallbacks();
sceCtrlSetSamplingCycle(0 );
goToMenu(1);
int held = 0;
while(!z) {
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons) {
if (held == 0) {
held = 1;
if (pad.Buttons & up) {
if (Mx == 1) {
Mx = goToMenu(3);
}
else {
Mx = goToMenu(Mx - 1);
}
}
if (pad.Buttons & down) {
if (Mx == 3) {
Mx = goToMenu(1);
}
else {
Mx = goToMenu(Mx + 1);
}
}
if (pad.Buttons & cross) {
if (Mx == 1) {
if (pad.Buttons & circle) {
printf("You pressed Circle!");
}
}
if (Mx == 2) {
if (pad.Buttons & square) {
printf("You pressed Square!");
}
}
if (Mx == 3) {
sceKernelExitGame();
return 0;
}
}
}
}
//Prints counter
pspDebugScreenSetXY(30,20 );
printf(" Pokes: %i", counter);
counter++;
for(i=0;i<5;i++) {
sceDisplayWaitVblankStart();
}
else {
held = 0;
}
}
Help would be greatly appreciated. Thanks. ^^Code:main.c:39: error: syntax error before 'args'
main.c: In function 'main':
main.c:162: error: syntax error before 'else'
main.c:165:3: warning: no newline at end of file
make: *** [main.o] Error 1
I believe it's SceSize, coming from a Java background you should know that functions (or methods in Java ;)) are case sensitive :PCode:Scesize args
Ack!!! I can't believe I didn't notice that! *smacks forehead* I fixed the code and now I am down to this error:Zitat:
Zitat von Yeldarb
Code:main.c: In function 'main':
main.c:162: error: syntax error before 'else'
main.c:165:3: warning: no newline at end of file
make: *** [main.o] Error 1
Umm, well... you can't have an else after a for loop...?
And just insert a newline at the end of the file to get rid of the warning; it's not a big deal, just a thing with ANSI Compliant code (I think). It will work fine without the new line at the end of the code, but it's good practice to put it there anyway.
Well I redid my code a bit (moved the ELSE to where it's supposed to go) and I am still getting the same error. My new code is:
PHP-Code:// My Third PSP Application - Menu
/* This program was created by Ross B. Leland on 10/07/2005.
It is a basic menu. */
#include <pspdebug.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <stdlib.h>
PSP_MODULE_INFO("Menu Test", 0, 1, 1);
#define printf pspDebugScreenPrintf
//Defines buttons
#define up PSP_CTRL_UP
#define down PSP_CTRL_DOWN
#define left PSP_CTRL_LEFT
#define right PSP_CTRL_RIGHT
#define cross PSP_CTRL_CROSS
#define triangle PSP_CTRL_TRIANGLE
#define square PSP_CTRL_SQUARE
#define circle PSP_CTRL_CIRCLE
#define XMAX 32
#define YMAX 67
void dump_threadstatus(void);
int done = 0;
/* 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 to 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;
}
// Start of the menu command
int goToMenu(int opt) {
//Define variables
pspDebugScreenSetXY(25, 1);
printf("The Poking Game");
//Menu Selections
if (opt == 1) {
printf(" >-Start Poking\n");
}
else {
printf(" --Start Poking\n");
}
if (opt == 2) {
printf(" >-Stop Poking\n");
}
else {
printf(" --Stop Poking\n");
}
if (opt == 3) {
printf(" >-Leave the Arena\n");
}
else {
printf(" --Leave the Arena\n");
}
return opt;
}
//Main Code
int main(void) {
//Define Variables
int counter = 0;
int i = 0;
int z = 0;
int Mx = 0;
SceCtrlData pad;
pspDebugScreenInit();
SetupCallbacks();
sceCtrlSetSamplingCycle(0 );
goToMenu(1);
int held = 0;
while(!z) {
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons) {
if (held == 0) {
held = 1;
if (pad.Buttons & up) {
if (Mx == 1) {
Mx = goToMenu(3);
}
else {
Mx = goToMenu(Mx - 1);
}
}
if (pad.Buttons & down) {
if (Mx == 3) {
Mx = goToMenu(1);
}
else {
Mx = goToMenu(Mx + 1);
}
}
if (pad.Buttons & cross) {
if (Mx == 1) {
if (pad.Buttons & circle) {
printf("You pressed Circle!");
}
}
if (Mx == 2) {
if (pad.Buttons & square) {
printf("You pressed Square!");
}
}
if (Mx == 3) {
sceKernelExitGame();
return 0;
}
}
else {
held = 0;
}
}
}
//Prints counter
pspDebugScreenSetXY(30,20 );
printf(" Pokes: %i", counter);
counter++;
for(i=0;i<5;i++) {
sceDisplayWaitVblankStart();
}
}
And what error is that?
Zitat:
Zitat von Yeldarb
Code:main.c: In function 'main':
main.c:164: error: syntax error at end of input
make: *** [main.o] Error 1
Doesn't look like you ever closed your main function, try putting another } at the end of all of the code.
I guess I should indent a lot more. ^^ Thanks for your help!Zitat:
Zitat von Yeldarb
Any time :)
This is kind of off topic from the general ' i have an error in my code':
How much space on my computer should I save for the install of all the req programs? Im in china, and the computer I have is very crappy and my roomate has 1-2 gigs of music and I cant do anything about it. I finally got to the point in lesson 1 where it took '3 hours' with your computer, and about halfway of it patching files it stopped because I had no disk space.
Will it begin patching where it left off or will i need to exec toolchain.sh again from the beginning?
Mine says
Size on Disk: 502 MB
But that includes all of my source and compiled programs as well, so probably a little less than that is required.
According to the error given to me in cygwin, my code is not causing the problem. It is my makefile... It tells me in the error to define PSPSDK as PSPSDK=$(shell psp-config --pspsdk-path). But this has already been done? What is it that the make file is not understanding? I even copied the build.mak to the /lib folder. And that didnt solve the problem. And yes, I did set up everything on how it is in Lesson 1. Can somone please help? For further referense the makefile error code is 15.
Well I noticed during the toolchain setup process it took up at least 1.5GB but went back down to under or just about 600MB.Zitat:
Zitat von Sir Crx