Chapter 4. Games
Hacks 36â40: Introduction
The PSP is a gaming machine, first and foremost. The hacks collected in this chapter show you how to do a few things that Sony never intended you to do when they first released the PSP.
Play Multiplayer on the PSP with Only One UMD Disk
Share one UMD disk between multiple PSPs in an ad hoc multiplayer WiFi game.
Youâve just bought a brand new PSP and so has your best friend. You are both eager to play head-to-head, using the PSPâs wireless gaming capabilities. Unfortunately, you and your friend have differing tastes in games and, as a result, you donât have two copies of any one game between the both of you. Before you run out to rent or buy a duplicate game from your combined lists, try this little method to trick your PlayStation Portables into thinking that you have two copies of your game.
How It Works
Shortly after the North American release of the PSP, several different sites and online forums began simultaneously reporting that people could play multiplayer ad hoc games among multiple Playstation Portables using only one UMD disk. Hereâs the basic procedure:
Load up an ad hoc multiplayer game on your PSP.
Eject the UMD disk.
The PSP will ask âAre you sure you want to quit this game?â Quickly select No and hit the X button.
Hand the disk to your friend.
Your friend puts the UMD disk in her PSP, loads up the game, and connects to the ad hoc multiplayer game you started.
Now, either both PSPs will freeze (if this happens, proceed to the next set of steps) or you both will start playing.
If both PSPs froze at step 6, then itâs time to troubleshoot the swap by doing some more swapping:
Your friend ejects the UMD disk and selects not to quit the game.
You put the UMD disk back in your PSP.
You both start playing. If, yet again, both PSPs freeze at this point, return to step 1 but reverse who gets the disk. Rinse, repeat.
Unfortunately, this trick only works in certain games, and can be slightly different depending on the game you are using. Itâs mostly a matter of timing, trial, and error.
To give you an idea of how it works, Iâm going to walk you through sharing one Tony Hawkâs Underground 2 Remix UMD between two PSPs.
Sharing Tony Hawkâs Underground 2 Remix
First things first: make sure that you and your friend(s) have the WLAN switch on the bottom-left corner of your PSPs switched on. Assuming that you are playing host to the game, start up Tony Hawkâs Underground 2 Remix. Once you click through all the beginning bits and load any saved profiles you may want to use, select WiFi Play from the game menu wheel.
Next, select Host Game as you would for any normal WiFi game, and set your server settings per your liking. Then, hit the X key to begin hosting. You will have to wait while the board you selected loads in server mode.
Once it has finished loading, your character will enter Free Skate Mode. Eject your disk, choose No, and hit the X button when the PSP asks whether you want to quit the game. You will return to Free Skate Mode (see Figure 4-1). Make sure you leave the drive door open for now.
Continue free skating as your friend puts the UMD in her PSP and clicks through all the beginning bits. Your friend will select WiFi Play from the game menu wheel, choose Join Game, and select your game from the menu. Once your friendâs PSP screen reads âStatus: Joining gameâ¦,â your PSPâs screen will have an overlay reading that your friend is joining the game (see Figure 4-2) and, in all likelihood, your free skate will freeze. When this happens, have your friend eject the UMD disk and pass it back to you.
Put the UMD back in your PSP and wait until the screen begins moving again, still with the notification of your friend joining. Now, eject the UMD again and pass it quickly back to your friend. After she reinserts the UMD disk into her machine, the loading screen should appear on the second PSP, while you continue to free skate (see Figure 4-3).
If you didnât do all of these steps quickly enough, the connection will time out and you will receive a notification that your friend failed to connect. Your friendâs board will still load, however, and inform her that the connection was lost. You can both continue to free skate, or your friend can return to the gameâs WiFi screen and try the joining process again.
If you do everything quickly enough, you will both be free skating together and can begin playing. Notice in Figure 4-4, I have both PSPs running the game, connected in a WiFi game, and the tray is still open on the host machine.
Depending upon whether you simply free skate, change games, or change boards, you may have to switch several more times after this initial connection is established. You may also try to connect a third PSP by repeating the steps between the PSP hosting the game and this third PSP.
This entire process can take five minutes each time you try, so this little trick, while cool, isnât really a long-term solution for multiplayer WiFi gaming. If you like the game that you are joining in on, you may want to invest in your own copy to prevent this delayed setup process from becoming aggravating over time.
Hacking the Hack
This hack should work with various games, but there are many games that donât work this way. Although I have tried again and again, I havenât been able to get a group game of Lumines going successfully. The connection starts, but then one or the other machine times out. Maybe it needs very precise timing, or maybe it isnât possible. However, Iâve given up on it, because I figured out another trick: just because you cannot join a WiFi game using only one UMD disk doesnât mean that you cannot all share one UMD disk.
The majority of the games available for the PSP donât actively access the disk during game play (this is how this multiplayer hack works in the first place). Rather, the individual boards are loaded into the PSPâs memory and then the disk goes unused until you progress to the next level, need to save, or unlock some new cut scene. So, why not share the game among multiple PSPs?
This trick will work with most board/level-based games. Just before writing this hack, I successfully tried it with both Lumines and DarkStalkers.
Hereâs how it works:
Load up the game in your PSP and start a single-player game.
As soon as it starts, hit the Start button and pause the game.
Eject your UMD disk, select No, and hit the X button when the PSP asks whether you want to quit the game. The game will return to the pause screen.
Hand your UMD disk to your friend, so that she can load up a single-player game.
Once it loads for your friend, have her hit Start, pause the game, and eject the UMD disk, passing it on to another friend.
With Lumines, you can have a contest between all the players to see who lasts the longest. After a while, the music in the background will stop playing, but the game will continue. In Wipeout Pure, you can see who finishes the agreed-upon race first. In DarkStalkers, you can see who beats his opponent first. Think about all the different group games and tournaments you could have without the WiFi connectivity, but by sharing a single UMD disk.
The best part about this trick is that once you reach time to switch boards, usually the game just hangs, waiting for the UMD. Retrieve the disk from your friend, load up the next board, hit Pause, and then start passing the disk around. You have hours of shared gaming ahead of you. Have fun!
Play Games over the Internet
Connect your computer to the Internet, share the connection with a computer-to-computer network over wireless, and all you need is XLink Kaiâs free online gaming service to connect to players around the globe with your PSP.
One of the coolest things about playing games on the PlayStation Portable is being able to play wirelessly with your friends. Unfortunately, due to the $250 USD buy-in price of the PSP, finding a friend who has a PSP and is available to play during the same time that you are can be problematic. Since the PSPâs networked gaming feature works via 802.11b, why not hook the PSP into your home wireless network and play other eager-to-play gamers online whenever you like? Sony doesnât yet offer a solution to do this, but there is a way.
Things Needed
Hereâs what youâll need:
Your PSP.
A computer running Linux (x86, MIPS, or PPC), Windows (98/98se/ 2000/ME/XP), or Macintosh OS X (10.3 or newer) hooked into your high-speed Internet connection via Ethernet.
An 802.11b-compatible WiFi card in your computer that is also compatible with XLink Kai (a list of compatible cards can be found here: http://www.teamxlink.co.uk/forum/viewtopic.php?t=11469), or an 802. 11b-compatible router capable of running XLink Kai.
A free registered account with XLink Kai (http://www.teamxlink.co.uk) and a downloaded copy of XLink Kai Evolution for your platform.
The free Amaryllis (http://www.nullriver.com/index/products/amaryllis) from Nullriver Software, the makers of PSPWare (Amaryllis is only required if you are running Mac OS X).
The Way It Works
Your computer connects to your DSL/cable modem via the wired Ethernet connection. Your computer, running XLink Kai, routes the Internet connection coming from its Ethernet port and shares it out via your 802.11b-compatible wireless card. You create a computer-to-computer network between your computer and your PSP, and XLink Kai does all the heavy lifting of convincing your PSP that the games connecting over the Internet and streaming forth from your computer are actually only local PSPs trying to play a friendly game. The procedure described in this hack is the general setup that you will follow, no matter which platform you are using.
The XLink Kai forums have tutorials for using XLink Kai on nearly every platform out there to play PSP games wirelessly over the Internet (http://www.teamxlink.co.uk/forum/viewtopic.php?t=5649). For this hack, I will walk you through the step-by-step process of connecting via Mac OS X, which is one of the more complicated setups. If you are on one of the other platforms, for the most part, the same steps listed here will work for your platform; however, you wonât have the added step of installing and running Amaryllis in the mix. I recommend that you read through the entire hack before beginning, since taking the steps in the right order is important.
Set up your PSP
This step universally applies, no matter what type of computer you are running.
Make sure that the wireless switch on your PSP is turned off and that your PSP is also turned off. Turn on your PSP. Go to Settings â Network Settings and click the X button. Select Ad Hoc Mode and hit the X button. You will be prompted to select a channel. Choose Channel 1 and hit the X button, and then hit the X button again to save these settings.
Tip
You could leave the channel set to automatic and everything would still work, and you would most likely find yourself able to play with other people running their PSPs on other channels. However, itâs been my own experience, as well as the experience of others online, that playing via Channel 1 works better on the PSP.
Next, load the WiFi-capable game that you would like to play and switch the PSPâs wireless switch into the On position. Navigate to a point in the game where you can host a wireless network game. This will differ according to which game you choose to play, so refer to the documentation that came with your game. Once you have started hosting a game, the LED that indicates there is WiFi activity should begin actively flashing. Your PSP is waiting for others to join from the Internet. This is where your computer comes into play.
On Your Computer
Now that your PSP is eagerly awaiting other PSP players, itâs time to get your computer to make the Internet connection. Remember, your computer must be getting its Internet connection via Ethernet, since your wireless card will not be able to both receive and send the signal to both your broadband network and your PSP. Make sure that everything is running smoothly as far as the Internet goes on your computer. Assuming that it is, you need to set up a computer-to-computer or ad hoc network over WiFi between your computer and the PSP. If you are on Windows or Linux, make sure that the settings for your wireless connection are set to ad hoc. On Mac OS X, all you need to do is click on the AirPort signal icon in the menu bar, and under Computer-to-Computer Networks, you will see an oddly named computer starting with PSP_, as in Figure 4-5. This is your PSP, which is currently broadcasting, searching to host a multiplayer game. Select the PSP from the list to create a computer-to-computer network between your computer and the PSP.
Connect to XLink Kai
Now that you have established a computer-to-computer network with your PSP, itâs time to load XLink Kai.
On a PC, launch Kai, log in to your XLink Kai account, and check Kaiâs diagnostics to make sure that it is reading your PSP correctly.
On a Mac, first launch Kaid, then load Amaryllis and enter the login information to your XLink Kai account. Navigate to the consoles tab in Amaryllis and select the PSP console room (see Figure 4-6).
Now, back on the PSP, you can at this point stop attempting to host the game that you used to connect the PSP to your computer. You may now begin hosting a new game on your PSP or try to join one of the games being shared out from your computer to your PSP via Kai or Amaryllis.
Wash, Rinse, Repeat
Hereâs a quick recap of the basic steps:
Make sure that your PSP and your PSPâs WLAN switch are both turned off.
Turn on your PSP and change the network settings to Ad Hoc on Channel 1.
Load the game you want to play, switch on the WLAN switch, and begin hosting a wireless game.
On your computer, establish a computer-to-computer or ad hoc connection with the PSP.
Launch Kai or Kaid. If you are on Mac OS X, launch Amaryllis after launching Kaid.
Make sure you are successfully logged in to XLink Kai.
Stop hosting the game on your PSP.
Start hosting a new game or select a game in Kai/Amaryllis and try to join that game on your PSP.
If you are having trouble connecting, just go through these steps again, and refer to the online tutorials available via the XLink Kai forums (http://www.teamxlink.co.uk/forum/viewtopic.php?t=5649). If you switch games, you will have to close everything out and start over from the beginning, as each separate game broadcasts under a different ad hoc or computer-to-computer networked name. The people who are successfully logging in and playing are following the preceding steps to a tee, and starting over from the beginning anytime anything goes wrong.
Game Play
Once you are connected and successfully playing an opponent, one thing you will notice is that there is a noticeable difference between playing with your friend sitting across your living room and playing with your friend in Bangladesh, who you are racing in Wipeout Pure over the Internet. Although you canâwith only a modicum of workâget the connection between your PSP, your computer, and the XLink Kai network up and running, once you are connected, you will most likely have trouble connecting to games or hosting games from time to time. Keep on trying.
Wipeout Pure connected nicely for me when I was testing this hack, but while Untold Legends: Brotherhood of the Blade supports WiFi game play, I could never get it to successfully connect to any other players. I should clarify here: we were able to connect, but we couldnât see each other and, if we werenât headed in the same direction, the game froze, timed out, and we were disconnected.
Also, if you are connected and playing a game successfully, you are still going to encounter all the lag problems that you experience with any other online gaming system. The game will only run as fast as its slowest player. In Wipeout Pure, I would sometimes have a good normal race, whereas other times, as soon as the race started, I would find myself racing the ghosts of my opponents and no one would know whether they were winning or not until they finished the race. Several times, my PSP told me I was in first place, but when I jumped through the finish line, thinking Iâd won, I suddenly was confronted with the information that I had finished third.
Other Systems
Recently, an alternative to XLink Kai has shown up online; XBConnect, which used to exclusively offer Internet game play to Xbox owners, has opened up a PSP section on their service. XBConnect (http://www.xbconnect.com/) is PC-only, so if you are on a Windows machine and frustrated or dissatisfied with XLink Kai, you might want to check out XBConnect.
Whatever you go with, have fun. And if youâre online with XLink Kai searching for a quick game, look for cks3. Thatâs me, and Iâm always looking for some friendly competition.
Throw a PSP WiFi LAN Party
Use the PSPâs built-in ad hoc wireless capabilities to have an on-the-fly LAN party with your PSP-wielding friends.
The PSP is one heck of a little game system that promises sci-fi-like, wireless multiplayer gaming and 3-D graphics that rival top video game consoles. It is now possible to have a networked wireless LAN game with friends without having to carry desktop PCs, string Ethernet all over some dank basement, and worry about some loser cheating by running an aim-bot (a cheat program that automatically aims for you) and ruining the fun. Alas, one of the problems facing many PSP gamers is that not that many of their friends have invested $250 USD (as of December 2005) for a PSP of their very own.
How cool would it be to throw your own public PSP wireless LAN party? With some minor planning and fliers, you could throw the nerd gaming event of the season!
Find the Spot
First, find a good place to have the LAN party. I would suggest a cafe that serves espresso-based drinks, because they have places to sit with power outlets, and they also have drinks and restrooms. Plus, they are all over the place and not as likely to give you the bumâs rush as coffee and donut shops that prefer quick turnover to customers who linger. I bet that there is not one place in the Western world without a Starbucks or independent coffee shop less than 10 miles away. Just look for a place with parking that is centrally located around town. If you have a cybercafe or gaming center, then the location is a no-brainer.
Tip
Another idea is to have the LAN party at a local public library. As long as you ask the librarians in advance, bring headphones, and keep it calm, a library would be a great place for a PSP LANfest. They are also smoke-free, open for all ages, and they donât have elevator music pumped over the speakers like some cafes. If you open the gaming to the public, however, you might have trouble keeping things quiet, so talk to the librarian about booking a private room for the event if holding a publicly advertised game is your plan.
First of all, talk to the manager of the place youâve picked. Explain that you would like to have a small get-together of gamers who want to play PSP together. Let the manager know that you plan on ordering drinks or food, and she will most likely not have a problem with it. Give yourself about three weeks to plan before the party to get the word out. Give the manager a call a day before the party as a reminder, in case she forgot.
Getting the Word Out
Next, you need to get the word out to potential PSP gamers. Write up a brief flier with the details of what, where, when, and why (see Figure 4-7).
I would put an email address as a point of contact. Make sure to point out that this is not an official function of the cafe. Then you might print out a couple copies and ask whether you can put some up at local game stores that stock PSP games, at the cafe, and other places where you might expect to find fellow gaming candidates. You then might call the local newspaper and ask whether you can get a shout-out in the community calendar or the technology section of the paper. Who knows? They might just run a full article, if it is a slow news day.
Tip
Set up a dedicated email address, such as
PSPgame_YourCity
@gmail.com,
to coordinate your endeavors and to avoid filling your personal
email with LAN party bits and possibly spam.
Then there is this little thing called the Internet. I used to be able to endorse Meetup.com (http://www.meetup.com/), but since they are now charging monthly for meetings, it would not be worth it for a PSP party.
If you end up making your own page to promote it, make sure you submit it to the search engines. A Craigâs List (http://www.craigslist.org/) post for your town could help get the word out. PSP Meets (http://www.pspmeets.com/) is a web site that was inspired by the first version of this article that I posted on 8bit Joystick (http://8bitjoystick.com/). All you really need is just one other person to play with, but the more, the merrier.
You might plan on about three hours or so for a party, so people could play off one PSP battery charge. I would plan it on a weeknight from 6:00 p.m. to 9:00 p.m., so it would not conflict with work, school, or social life. Make a list of suggested games, and you might want to bring an extra battery pack or AC adapter, in case someone forgets to charge her PSP. This would be a great chance to see and try out new games. You might bring a whiteboard so that if you set up a tournament, you will have something to write the brackets on. You might spare some old PSOne games as a tournament prize. If you have a laptop with a USB Memory Stick Duo reader, bring it so that you can trade and transfer PSP save files [Hack #2] . A CD full of MP4 videos and MP3s for the PSP would make a pretty cool party favor. If you make a signup sheet, you could collect email addresses for future PSP LAN party announcements.
A Brief Tutorial in Wireless PSP Gaming
Putting together a tutorial on how to set up the wireless game modes of the games youâll be playing might help if some of your players have not gotten down with PSP WiFi networking. But, then again, it is not rocket science.
You should prepare a short handout that applies to all games or write this info on the whiteboard:
Make sure that you have the WLAN switch on the On position.
Make sure that you have the PSP set to Ad Hoc Mode rather than Infrastructure Mode. To set up Ad Hoc Mode, navigate to Settings â Network Settings, click the X button, choose Ad Hoc Mode, click the X button, and set to Automatic (or Ch 1, Ch 6, or Ch 11, depending upon what you all agree on). Hit the X button to save the settings.
Hacking the Hack
Since the decline of the arcade in the U.S., there has been a void of public community gaming in the same room. It could be pretty cool to get together once a month with total strangers in your community to throw the smack down on the PSP. You could meet new people, play new games, and really get the most of your PSP networking features. Some critics say that video games are a solitary pastime, but they can be a great way to meet new people and zap them over WiFi.
âJacob Metcalf
Create an Infrared Peripheral Interface
In this article, you will learn how to get a microcontroller to communicate with the PSP and how to use it to make an interface for gamepads and more. Although it wonât work with existing games out of the box, you can write your own homebrew games that use these controllers.
If youâre lucky enough to own a Sony PSP capable of running homebrew software [Hack #40] , you may have tried out some of the countless emulators and ports of older games out there already. The bad thing is that you canât play all the old games in two-player mode. Finding a solution for this was actually my motivation to start with this hack. First, it had to avoid any hardware modifications on the PSP itself, because I donât like to open such an expensive device. Since the PSP already provides infrared and USB ports, this wasnât much of a problem. Secondly, it had to be cheap. Being a student, I was looking for a cheap solution, and so I chose infrared. Aside from IR being cheaper, USB-capable controllers are hard to get.
As the interface consists of parts you can get at most electronic part distributors and doesnât require any special equipment, this project can be handled even by people with little programming and/or soldering experience.
Things Youâll Need
If you build your own power supply:
One LM7805 Voltage Regulator
One electrolytic capacitor, 10μF
Two ceramic capacitors, 100 nFm
One diode 1N4001
I also recommend downloading the ATMega8 Data Sheet (http://www.atmel.com/dyn/products/product_card.asp?part_id=2004) because it provides useful information about the microcontroller.
To create the software for the AVR, I have used AVR-GCC, which is included in the WinAVR Package (http://winavr.sourceforge.net). A programmer like the AVR-PG2 from Olimex (http://www.olimex.com) will fit your needs. You can either buy them there or build your own one easily with the schematics available for download.
You will also need the newest version of the PSPSDK (http://www.pspdev.org). If you havenât already, you have to install Cygwin (http://www.cygwin.com/) in order to run PSPSDK on Windows [Hack #47] .
Types of Gamepads
With every generation of game console, the gamepads have changed. Until the early 1990s, most gamepads consisted only of some buttons directly connected to the console. Since gamepads were designed with more and more buttons, new ways for reading out the data had to be found. Original Play-Station gamepads, for example, have a small microcontroller inside that handles all the button input, converts the analog stick data to binary values, and communicates with the console over a serial protocol.
For this project, I will use a Sega Master System gamepad, which consists of only six buttons and uses a 9-pin SUB-D connector. Figure 4-8 shows the schematic.
Tip
If your eyes are starting to glaze over right now, donât fret. You just need a crash course. Dan OâSullivan and Tom Igoeâs Physical Computing (Course Technology PTR) explains everything involved with projects such as this, from the individual components up to the power supply, to all the skills you need to breadboard up your circuits.
Setting up the AVR
Before you can start with the fun, you have to get the AVR up and running. This isnât really difficult, since you only have to connect the supply voltage and ground, and then upload your program. Being a microcontroller, the AVR doesnât need any periphery.
Power supply
If you take a look at the data sheet, you will see that the ATMega8 accepts any value between 4.5 V and 5.5 V as supply voltage. This means you could either use a battery pack as power supply or build one using an LM7805 Voltage Regulator, which will provide a more stable 5 V supply voltage. Figure 4-9 shows a basic power supply design.
If you decide to build a power supply using the 7805, the only thing you have to do is connect the input voltage, which can be any value between 8V and 35V, between the input and the ground pin. Even though it will work on its own, I strongly recommend that you connect a diode between input and pin 1, a 1μF and a 100 nF capacitor between Pin 1 and ground, and a 1 µF capacitor between output and ground.
Having built your power supply, connect the output to the VCC pin of the AVR and tie the GND and AGND pins to ground. Connect a 1 kâ¦resistor between VCC and RESET to make sure that the AVR isnât in reset mode, if no programmer is connected.
If you donât feel up to building the power supply, you can always fall back on the battery pack, or purchase a power supply that delivers 5 volts DC and use it in this project.
Now you can connect your programmer to the AVR.
Creating the Circuit
You can connect the buttons directly to the microcontroller using pull-down resistors. Pull-down resistors are necessary because each input pin of the microcontroller needs either a low or high state. If you choose the pins where you connect the buttons, you have to be careful bout which ones you can use and which you cannot. For example, the RESET pin is necessary for programming the microcontroller and should not be disabled.
I connected the gamepads to the microcontroller, as shown in Figure 4-10.
The IR diode is directly connected to an I/O pin of the microcontroller with a resistor. The resistance is lower than the one you would use for a standard LED, since the way of using pulses enables the diode to shine brighter (explained previously).
Sending Data to the PSP
Now that the AVR is set up and ready to run your programs, you can start writing the program that sends data to the PSP. To do this, you need to understand how IRDA Data Transfer works.
If you already know a bit about serial data transmission, this should be easy for you to understand, because IRDA is very similar to RS232 transmission. Each frame has a start bit and a stop bit, and the standard baud rate of the PSP is set to 9600 bps. The difference to the standard serial protocol is that bits are determined as short pulses, and the byte to send has to be inverted. Figure 4-11 illustrates this.
Usually the length of the pulses is 3/16 of the bit time. The receiver gets a clearer signal when using pulses because the output power of the diode can be higher over such a short duration. With this information, you can write a function that sends one byte of data to the PSP. First, you have to include the necessary libraries:
#include <avr/delay.h> #include <avr/io.h> #define F_CPU 1000000UL
The file delay.h provides functions for software delays, and io.h includes the I/O Port definitions. The
delay functions need the clock frequency defined as F_CPU
in Hertz in order to work. You must
write 1 MHz, since this is the default clock speed of the
ATMega8.
Next, you need to define some constants:
#define OUT_PORT PORTB #define OUT_PIN PB1 #define OUT_DDR DDRB #define DOWN_TIME 78.125 #define PULSE_TIME 18.0288
The #defines
with the prefix
OUT determine which pin of which port is used for the output of the IRDA Signal. This is the pin the IR LED
should be connected to.
Next, you need a function to send one bit. To make it more accurate, define it as inline. It checks whether the bit to send is 0 and, if so, creates a pulse by setting PB1 high for a short period of time:
__inline__ void ir_send_bit(char bit){ _delay_us(DOWN_TIME); if(!bit) { PORTB |= 0x01; } _delay_us(PULSE_TIME); PORTB &= !0x01; }
For sending a byte to the PSP, you need to call the ir_send_bit
function 10 times. First the
start bit, then a loop that sends the byte and, at the end, the stop
bit:
void ir_send_byte(char byte) { char i = 8; ir_send_bit(0); // Start-Bit while(i) { ir_send_bit(byte&0x01); byte >>= 1; i--; } ir_send_bit(1); // Stop-Bit }
Now that youâre able to send bytes over infrared, the only thing left to do is to detect button changes and send them to the PSP. In each byte you send to the PSP, a byte is used to indicate the state of the gamepad controls (see Figure 4-12).
The first thing the main function does is to set the Data Direction Registers. All pins, except the first one of PortB, will be defined as input pins. After that, an infinite loop follows, which checks whether any button states have changed:
int main(void) { DDRB = 0x01; DDRD = 0x00; DDRC = 0x00; unsigned char gp1_old, gp2_old, gp1_new, gp2_new; while(1) { gp1_new = PINC; gp2_new = PIND; if(gp1_new != gp1_old){ ir_send_byte(gp1_new); } if(gp2_new != gp2_old){ /* set the GP select bit */ ir_send_byte(gp2_new | 0b10000000); } _delay_us(10); gp1_old = gp1_new; gp2_old = gp2_new; } }
Writing the PSP Application
Now that you are able to send data to the PSP, you just have to write a little library that provides functions for decoding the data and making applications with support for external gamepads.
First, some declarations and imports are necessary:
#include <pspkernel.h> #include <pspdebug.h> #include <pspctrl.h> #include <stdlib.h> /* Define the module info section */ PSP_MODULE_INFO("IRDA Example", 0, 1, 1); #define printf pspDebugScreenPrintf #define GP_UP 0x0001 #define GP_RIGHT 0x0002 #define GP_DOWN 0x0004 #define GP_LEFT 0x0008 #define GP_1 0x0010 #define GP_2 0x0020 SceUID f; unsigned char odata = 0, ndata = 0, gamepad1, gamepad2;
Next, initialize the infrared port of the PSP. Write a function that does this work and that has to be called once the application is started. It opens a stream for reading data from the IR port:
int GP_Init() { return (f = sceIoOpen("irda0:", PSP_O_RDWR, 0)); }
Now you just need a function that the application can use for
checking the button states. As long as there is new data available,
the loop assigns it to the variables gamepad1
or gamepad2
, depending on the state of the GP
select bit:
void GP_Update() { do { odata = ndata; sceIoRead(f, &ndata, 1); if(ndata & 0b10000000) { gamepad2 = ndata; } else { gamepad1 = ndata; } } while( odata != ndata ); }
Having written all the necessary code for receiving data from the interface, you can test to see whether everything works with this simple test application. It will check for updates every frame and directly print the states on the screen:
void printStates(unsigned char data) { printf("UP : %u\n", (data&GP_UP) != 0); printf("DOWN : %u\n", (data&GP_DOWN) != 0); printf("LEFT : %u\n", (data&GP_LEFT) != 0); printf("RIGHT : %u\n", (data&GP_RIGHT) != 0); printf("1 : %u\n", (data&GP_1) != 0); printf("2 : %u\n", (data&GP_2) != 0); } int main(void) { SceCtrlData pad; pspDebugScreenInit(); printf("\nIRDA Test Application\n"); GP_Init(); while (1) { GP_Update( ); pspDebugScreenSetXY(0,3); printf("--- Gamepad 1 ---\n"); printStates(gamepad1); printf("\n--- Gamepad 2 ---\n"); printStates(gamepad2); sceCtrlReadBufferPositive(&pad, 1); // Refresh the PSP // Button States if(pad.Buttons & PSP_CTRL_CIRCLE) // If Circle is pressed⦠{ sceKernelExitGame( ); // â¦exit the Application } } }
This application provides a good base for creating your own gamepadenabled applications or implementing gamepad support into existing applications, such as emulators.
Hacking the Hack
This is a very simple hack that shows only a small example of what is possible with the PSP, a microcontroller, and infrared. You can connect virtually everything to the microcontroller, send the data to the PSP, and do whatever you want with it inside of your own homebrew applications. Atmel provides useful application notes on their site that show you, for example, how to connect a keyboard to an AVR.
âThomas Novotny
Run Homebrewed Software
One of the great things about the PSP as a gaming system is the large number of developers and hackers who flocked together to figure out ways to really trick out the system with their own homebrew applications.
If you have a PSP running Version 1.0 or 1.5 of the firmware, donât update to Version 2.0 of the firmware.
If you have a PSP running 1.51 or 1.52 of the firmware, then you might as well go ahead and upgrade to 2.0. Why? Well, all the dutiful hackers have figured out ways of running their own code on PSPs running Versions 1.0 and 1.5 of the firmware. They havenât figured out how to get around the clamps Sony slapped on Versions 1.51, 1.52, or 2.0â¦at least, not as of this writing.
Tip
If you buy a game that requires you to update to 1.51, 1.52, or 2.0, try grabbing WAB Version Changer (http://www.psphacks.net/content/view/344), which will trick the game into thinking you are running a newer version of the firmware and do so without ruining your homebrew. Keep your eyes on the WAB team too, as they are working on a downgrader to help everyone who has already updated their PSPs.
So, if youâre running Version 1.0 or 1.5 of the firmware, an entire world of programs and emulators are available to you. If youâre running Version 2.0, then you can still run browser-based JavaScript homebrew, but no native code and no emulators. Again, I think this will prove to be a âyetâ situation. There are people working right now on breaking the locks Sony has put in the way of all the homebrew. If youâre daring, you can try downgrading your firmware [Hack #11] .
Feel free to skip ahead to the section that covers your firmware. Not sure what you have? Have you already bought a PSP running Version 2.0, but want to sell it on eBay to buy one running Version 1.5 of the firmware? Read on to find out how to spot a 1.5 PSP among a stack of 2.0s.
Spot Your Firmware
Hereâs how to make sure youâre getting the PSP you really need.
Out of the box
If you have your PSP in your hands, itâs pretty easy to find out which firmware you are running. Simply navigate to Settings â System Settings, hit the X button, then scroll down to System Information and hit the X button again. An informational screen will pop up listing your PSPâs MAC address, the System Software, and your PSPâs nickname. Whatever number follows Version in the System Software row is the version of the firmware you are running.
In the box
If you donât have your PSP yet, or youâre in the market for a second one, hereâs what you need to know to try to avoid grabbing another Version 2.0. The UPC sticker on one end of the box indicates the firmware version. In Figure 4-13, there are two boxes, one without an A under 120V, indicating Version 1.5 boxed with the Spider-Man 2 UMD, and one with an A, indicating Version 1.5 of the firmware without the free UMD. If the box says something other than PSP-1001 K along the top, or it has a B or any other letter than an A underneath the 120V, then youâre dealing with 1.51, 1.52, or 2.0 firmware, and you wonât be able to run the homebrew.
Homebrew and Emulators
If you were one of the fortunate few who grabbed a Japanese PSP running Version 1.0 of the firmware, then you have a very nice homebrew machine at your fingertips. There are multiple sites online that serve as repositories for these homebrew applications, where you can download them and then transfer them to the GAMES folder inside the PSP folder on your Memory Stick. After you copy the homebrew applications and games to this folder, navigate to Games â Memory Stick on your PSP, hit the X button, and then select the homebrew game or application you want to play from the list and hit the X button again to launch it.
Tip
Keep in mind that all these homebrew apps take up space on your Memory Stick. Make sure you watch sites such as dealnews (http://www.dealnews.com) to try to get a 1GB or larger Memory Stick Duo card on the cheap.
If you, like most people who purchased their PSP in North America, have Version 1.5 of the firmware on your PSP, then things are only slightly trickier. Originally, the first workaround for running homebrew on Version 1.50 of the firmware involved something called a swaploit. For the swaploit, the EBOOT.PBP file that contains the main code for each homebrew program had to be split into two parts, placed into two identical folders inside /PSP/GAMES/ on two different Memory Sticks. You would navigate to the game on the first Memory Stick and hit the X button, then immediately after the PSP flash screen appeared, indicating that the game was launching, you had to quickly eject that first Memory Stick and replace it with the second one. If you timed everything just right, the game or homebrew application would successfully launch.
This swaploit was far from ideal, as the swapping required speed and skill and wasnât very good for the Memory Sticks involved, whichâover timeâwould develop scratches on their contacts (and could also at times be damaged or possibly lost from accidentally shooting them across the room while ejecting them to make way for the second Memory Stick).
Fortunately, another workaround was discovered that eliminated the need to swap the Memory Sticks. Again, the EBOOT.PBP file was split in two, but this time, both files were placed on the same Memory Stick inside two different folders. Each folder had the same name, with the first ending with an additional % at the end of the name. When navigating through the Memory Stick via the PSPâs Game menu, each homebrew game or application would show up next to another file called Corrupted Data. This file was merely the second folder that didnât appear launchable to the PSP.
Split your EBOOT.PBP files
Most newer homebrew apps come in both Version 1.0 EBOOT.PBP format and in split 1.50 format, but in case you run across a homebrew application that is only ready to run on Version 1.0 firmware, there are a few tools available to help you properly prepare the file for running on your PSP.
If you are running Mac OS X, you will want to grab HomebrewPSP Converter (http://ipsp.kaisakura.com/homebrew.php), which is available for free from RnSKSoftronics, the makers of iPSP. This easy-to-use application will let you select a recently downloaded EBOOT.PBP file, split the file into the necessary two parts, and automatically copy these files to a mounted PSP when you click the Transfer To PSP button (see Figure 4-14).
If youâre running Windows XP, there are several programs that will do the same thing that HomebrewPSP Converter does on OS X. PSP Homebrew 9 (http://www.pspvideo9.com/homebrew/), from the makers of PSP Video 9, is a free (although donations are welcomed by the developer, Sajeeth Cherian) Windows solution for converting and moving your homebrew applications to your PSP on a Windows box.
Tip
In most cases, you wonât need to worry about this. Most homebrew applications out there come preprepared in both firmware 1.0- and 1.5-savvy versions, so there is really not much need for converting the files anymore. I only supply the information here for the rare file that isnât pre-prepared, and to provide some of the history behind the scene.
Where to find homebrew and emulation applications
So, now that you know how to both prepare the homebrew applications and get them onto your PSP, all you need to do is to find some homebrew to play. A comprehensive list of the ever-changing landscape of homebrew for the PSP is beyond the scope of this hack. Such an endeavor would be an entire book of its own, and a book that probably shouldnât be written for a while longer, as the scene keeps popping up with new apps and sometimes daily improvements of existing applications.
In the meantime, letâs spend some time looking at some online sites where you can grab some of the latest homebrew.
At the risk of being self-promotional, Iâll first direct you to the PSP category of my blog, Sample the Web (http://www.sampletheweb.com/categories/media/psp/), where I keep track of a lot of the little PSP bits that interest me. You should also check out PSP Fanboy, a PSP blog that I write for, and PSP Hacks: The Book (http://www.psphacksthebook.com/), a site thatâas I write thisâis nothing but a placeholder online, but which I intend to populate with lots of useful links and information to enhance this book. Also, make sure you check OâReillyâs web site page for this book (http://www.oreilly.com/catalog/psphks), as weâll be providing corrections to the book from time to time.
None of these sites, however, are hosting the various homebrew applications that you want to get your hands on. There are two places that Iâve found to be the best repositories for PSP homebrew. One is PSP Updates (http://www.pspupdates.com/).
Tip
Unfortunately, for the most part, PSP Updates is hidden behind multiple pop-up- and pop-over-plagued pages that can be more than a bit frustrating at times. The content is both great and free, but if you donât like sites that continually bombard you with advertisements, you may want to consider signing up for a paid account with PSP Updates so that you can browse their files ad-free.
I like free, however, so Iâll just continually close the ad windows and click the Skip This Ad links to get to the goods, and diligently empty my browserâs cache files after Iâm done.
The other, less ad-laden site is PSP-Hacks (http://www.psp-hacks.com/), which has an easily accessible Homebrew Download section (http://www.psp-hacks.com/downloads.php#homebrew), although not as comprehensive as PSP Updatesâ selection.
Hereâs a short list of other useful PSP- and homebrew-related links:
PSPworld (http://www.pspworld.com/) |
PSP-vault (http://www.psp-vault.com/) |
PSP Garden (http://www.pspgarden.com/) |
PSP Spot (http://www.psp-spot.com/) |
PSP Hacks (http://www.psphacks.net/) |
If I donât have direct links to any of the homebrew applications I list in this hack, itâs because the developer doesnât have a web site of his own, and the file is found regularly updated on one of these sites. Wherever possible, however, I will link directly to the developerâs site.
PSP Chess
Christopher Bowron is one of the first and most diligent homebrew developers, releasing PSP Chess (http://bace.bowron.us/) and continuing to improve and update the program over time. Itâs a really nifty and well-designed chess program that I play regularly on my PSP (see Figure 4-15).
PSP Rhythm Composer and DJSP
The musically inclined amongst you will like PSP Rhythm Composer (http://www.iturzaeta.com/PSPRhythm/). This homebrew drum machine for your PSP features a 16-step sequencer, 16 drum instruments with 32 total samples, 16 drum patterns, and a song mode.
If you enjoy listening more than creating, you might prefer DJSP (visit http://www.handango.com/PlatformProductDetail.jsp?siteId=1&platformId=14&N=4294925759&productId=175143&R=175143) over the MP3 player that comes preloaded in your PSP (see Figure 4-16).
This Audio Visual MP3 player for the PSP features 10 different visual patterns that play along with your music, a 10-band equalizer that will allow you to increase the volume beyond the loudest volume allowed by the PSPâs default MP3 player, and the ability to play tracks of any file length (according to the web site, up to 2 GB, if necessary).
Games and emulators
In addition to the homebrew games such as PSP Chess and PSP Go, there are various programs copied from other games, in particular a Bejeweled clone and games such as Dr. Mario (see Figure 4-17). Perhaps one of the most popular forms of homebrew that has the largest following and has persuaded many PSP owners to diligently avoid upgrading their firmware can be found in the form of homebrew emulators that emulate the behavior of other gaming systems.
Since its initial release, the PSP has become one of the best and most versatile emulation platforms available. There are PSP emulators for the Super Nintendo, Nintendo 64, Sega Genesis, Atari Lynx, and a variety of other platforms. Thereâs even a MAME emulator for the PSP. Many of these are available bundled together in packs, such as the Kxsploit Homebrew Pack (pictured in Figure 4-18).
All of these emulators need ROMs to run. You can obtain many excellent homebrew ROMs for a variety of systems at http://www.pdroms.de/.
Browser-Based Homebrew
While Version 2.0 of the firmware prevents regular homebrew from running on the PSP, you do at least have an additional web browser (without having to do the Wipeout Pure trick) that is capable of running various JavaScript apps and web-based games, such as PSP Tetris (http://webtopsp.com) and those found at PSP Web Browser.com (http://www.pspwebbrowser.com/). Also, most of these games can be downloaded locally to your Memory Stick, so that you donât need a live Internet connection to play them.
Hacking the Hack
If you really want to hack this hack, youâre either going to want to learn to develop your own homebrew for the PSP [Hack #47] or spend some time scouring the Net for all your favorite JavaScript games that you can port to the PSP.
Get PSP Hacks now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.