MATRIXSUCKS: I have edited your post drizzle in order to put all three episodes in one place, therefore making the information more condense and easier to find.
Episode 2: Attack of teh n00bs
Welcome back! In the last episode we went through and installed cygwin and the psp devkit. Now that we got these shiny new tools, you’re anxious to make your own games, right? Hold on there little buddy, we gotta walk before we can run. In this episode, I’m going to explain some of the basics of programming in general, and also get you acquainted with C/C++. Alright, let’s do this, LEEEERRROOYYYY…err…ahem…well that was embarrassing…
Let’s start with some history. A computer processor is basically millions/billions of switches in a little chip. These are controlled using binary (1(on) and 0(off)) to perform calculations. It is not necessary that you know binary, that’s what people made programming languages are for. The first to be developed, due to the high probability of human error and the enormous pain in the ass of having to work with binary, was assembly language. It’s very primitive, but simple. As programs became more and more complex (and also to save time and headache), other programming languages were spawned.
C was originally developed by these guys that wanted to be able to create platform independent operating systems (meaning it could work on a pc/mac/any other hardware), so the created a language with standardized syntax that could be compiled and ran on different hardware platforms. This spawned *nix operating systems, which can be compiled to run on virtually any platform. C++ is an improvement on C, adding in the ability to create object-oriented programs (we’ll discuss that another day) as well as a few other improvements. C++ is one of the most widely used programs for end-user applications in the market, largely because there’s not much of a limit to what you can do with it.
C/C++ is a compiled language. This means that you type out the source code, run it through a compiler/linker which converts it to machine language, and creates an binary executable file. In windows, this would be a exe file, on your psp, it’s an elf/prx file (which is eventually transformed into an EBOOT.PBP file). There are different compilers for different systems, and this is how it builds your code so that it will work on that specific system. There are other types of languages. Java for instance, is an interpreted language, which is translated to machine language every time you run it, rather than having a binary executable.
Ok, now lets get down to the anatomy of a C program. Here is the most basic example I could think of, the legendary hello world
That wasn’t so bad, was it? Now let’s dissect this bad boy…Code:#include <stdio.h> int main() { printf("Hello World! C is teh pwnzorz!!!1!one!\n"); return 0; }
This is called an include, for obvious reasons, lol. What this does is it accesses the header file stdio.h. A header file contains information for functions that you use in your program. These are basically just to make your life easier, as you won’t have to recode a function every time you want to use it. Stdio.h has information for the printf() function, which I will explain in a few seconds. Say, for instance, you wanted to find the square root of a number. The function for that is sqrt(number), but the sqrt() function is located in Math.h, so you better include it at the beginning of your code, or else you’ll have a mess come compiling time.Code:#include <stdio.h>
This is a function, the main() function to be exact. Every program you make is going to have to have a main() function. A function encloses code that does something. Each function has a type. This type depends on the type of value that the function returns. I suppose this would be a good time to talk about types of values and variables. There are many types of values that you can use in C/C++. Some common ones are int (integer-whole numbers in case you didn’t know), char (character-a single letter, number, or symbol), string (a string of characters), double (a decimal), float (a floating point decimal), and void (nothing, well, actually a null character, but let’s just say nothing for now).Code:int main() {
A variable is just like a variable in algebra. It’s just a container for a value. You must declare the variable by doing something like int x; (note the semicolon. You have to put a semicolon after every statement in a function). To give x a value, all you gotta do is say x=2;, that’s it. Anyways, back to functions. The most common types used for the main() function are void and int. You’ll usually want to use int, you’ll find out why when we get to the end. We’ve spent enough time here, let’s move on.
This calls the printf() function. This function’s located in the stdio.h header file, and it contains the information to make the machine print out a string in the console. You need to give printf() something called an argument, which it then prints to the screen, in this case "Hello World! C is teh pwnzorz!!!1!one!\n" (note the quotes, it’s a string, so it has to be placed in quotes. Also, the \n means “new line”, basically the same as hitting enter). Moving on…Code:printf("Hello World! C is teh pwnzorz!!!1!one!\n");
Ok, I promised I’d tell you why you normally want to use int for the type of main(), and I’m a man of my word, so here it is. Every function has to return something (even void, which returns a null value, which stands for nothing. Confusing, I know, but think of it as kinda like the concept of zero). If you were using void, you’d just type return; here. But the reason it’s a good idea to use int is because if you return 0;, then it tells you the program terminated successfully, and if you return 1; it means your program failed. It’s just cleaner that way. Oh yeah, and you have to add a bracket at the end to signify the end of your function. That’s it! Now you would compile the code and then execute the binary that is produced. If you were compiling for a windows machine under visual studio or something like that, you would get something like this:Code:return 0; }
I know it was long winded, but I hope that this episode was enough to help get even the most n00bliest of n00bs comfortable with what we’re doing before moving on to the psp. In the next episode, we’ll look at setting up a project in cygwin, and “porting”, if you can call it that, the above example so that we can compile it and run it on a psp! Hopefully this is a useful resource for people. See you next time, same bat-time, same bat-place.


. 
. ok, so now you should have a cygwin shortcut on your desktop, double click on it and a command console should pop up. Yay! You now have linux in windows! Ok, now you’ll need to download the pspsdk (the kit for compiling your code into an eboot). Next, go to






so basicly u can run an emulater on ur cp?????-????????? 