Very Simple Guide To Xbox App/emulator Porting |
|
|
| nes6502 |
Jun 22 2006, 02:00 PM
|

X-S Freak
    
Group: Members
Posts: 1799
Joined: 29-October 04
Member No.: 161612

|
The reason I wrote this guide was to explain the process of porting a game or an emulator to the Xbox. You don’t have to be a coding master. All you need is the tools to build an Xbox application, basic knowledge of C (and or C++), and some determination. I am not the authority on the subject, but I have ported an emulator to the Xbox, and I am writing from this experience. This is a VERY high level view. But the framework is here.
Why am I writing this and posting it in the emulators forum? I realize that many emulator users read this forum and might want their favorite application/game/emulator ported to the Xbox. In reality, the only way it may ever get ported is if they do it themselves. I have wanted ZSNES on the Xbox (native port) since I started using the Xbox, and I realised that the only way it was going to happen was if I did it myself. So I did. I had never ported anything to the Xbox (or any console) before and I am not an expert coder. With determination I was able to do it, and i think it turned out well. So if you want your favorite app/emulator/game on the Xbox, instead of waiting for a day that may never come, people might want to try and do it themselves. This is a basic guide for those people that don't know where to begin.
Tools:
1) XDK 2) Visual Studio 2003. NET 3) You do not need a debug XBOX (even though it is helpful). Without one, you will be burning CD’s every time you want to test a change.
Step 1) Decide what you want to port. For this example I will talk about ZSNES. ZSNES is written in C and Assembly. I’m pretty familiar with C and not very familiar with Assembly.
Step 2) Download the source code. It’s easiest if you can compile it on Windows first. After following the instructions, I was able to compile the windows version of ZSNES.
Step 3) Create a new Xbox application workspace in VS 2003. Add all the C/C++ files to the project. If there are assembly files (like in ZSNES), just add the “obj” files for the ASM ones generated from Step 2 to the project.
Step 4) Compile the Xbox project. This is where the fun starts. There will be lots of compile errors because the PC version is likely using code, functions, libraries that are not supported on the Xbox. For example, ZSNES uses DirectDraw code to draw the screen. There is no DirectDraw support on the Xbox, so I had to learn how to do the same thing with Direct3D. Basically: how to set the color of each pixel on the screen. Once I replaced all the DirectDraw code, that entire group of errors went away.
Another example is the input. ZSNES assumes there is a mouse used. I commented out all the code that used a mouse because there isn’t one on the Xbox. Another example is the keyboard. Since there is no Xbox keyboard, I replaced all the keyboard code with Xbox controller code. ZSNES still thinks there is a keyboard attached and checks to see if any buttons are pressed. I just monitor buttons on the Xbox controller, and when one is pressed, I tell ZSNES that one of the keyboard keys was pressed.
Step 5) Compile again. Now continue replacing code that gives errors with code that doesn’t.
Step 6) Repeat Step 5 until all errors are gone. Once all the errors are fixed, VS will generate an “xbe” file that can be run on the Xbox.
A great starting point is the Genadrive source code. It is easy to read and easy to compile. Try compiling it and running it on the Xbox. Then study what it is doing to draw pixels on the screen, read the controller, read files in a directory for the ROM browser, etc.. In fact I used this as my base for ZsnexBox and basically built around it, added to it, etc...This is the only thing I’ve ported to the Xbox and I am not a coding expert. You don’t have to be. If you have a basic understanding of C, the tools needed to compile the application, and the willingness to learn things you need (like basic Direct3D), then there is nothing stopping you from porting anything you want.
This post has been edited by nes6502: Jun 22 2006, 02:07 PM
|
|
|
|
| |
| wizzel |
Jun 23 2006, 12:12 AM
|
X-S Enthusiast
Group: Members
Posts: 25
Joined: 24-May 06
From: Germany
Member No.: 283489
Xbox Version: v1.6
360 version: unknown

|
...and i thought i was a nOOb. Now all i know is that i must be a super-duper multi-nOOb. It reminds me of coding my first CGA-emulator for the HGC Graphics Card on the PC way back in the early 80s.  Especially the "until all errors are gone"-part. Anyway, nice (interesting) guide, nes!  Keep on rocking! This post has been edited by wizzel: Jun 23 2006, 12:17 AM
|
|
|
|
| |
| GogoAckman |
Jun 23 2006, 04:51 PM
|

X-S Expert
  
Group: Members
Posts: 520
Joined: 21-April 04
From: Brussels
Member No.: 115468
Xbox Version: v1.4
360 version: none

|
QUOTE Many people probably get turned off by xbox porting since it seems like a huge task, when they could probably get it done with some determination and help on the big problems. True, but you should first thank xport, lantus and tmaul for their efforts in the first place, it is easy now to take a code from their emus and implant it to another code. There s a lack in the scene, help between devs, I am always open to help someone and asked for devs to help me but there seems to be a competitions between devs and that s not serving the goal achievement. Remember, that simple way can be the hardest too  .
|
|
|
|
| |
| manlol |
Jun 24 2006, 10:52 AM
|
X-S Enthusiast
Group: Members
Posts: 9
Joined: 4-December 05
Member No.: 261687

|
Thanks for the excellent guide nes, two questions: 1. I'm not able to get a copy of VS2003, will MS Visual C++ 6.0 Standard Edition suffice? 2. Will it be difficult to port a game which uses the Allegro library? I've always wanted to play Liquid War on my xbox.
|
|
|
|
| |
| nes6502 |
Jun 24 2006, 02:15 PM
|

X-S Freak
    
Group: Members
Posts: 1799
Joined: 29-October 04
Member No.: 161612

|
QUOTE(manlol @ Jun 24 2006, 10:59 AM)  Thanks for the excellent guide nes, two questions: 1. I'm not able to get a copy of VS2003, will MS Visual C++ 6.0 Standard Edition suffice? 2. Will it be difficult to port a game which uses the Allegro library? I've always wanted to play Liquid War on my xbox. Only VS 2003 .NET will work easilly. I'm sure it's possible to use 2005 and 6.0 but I don't know how to configure them to build the xbe. 6.0 should work depending on which version of the XDK you have (versions before 5993. But the easiest way is to use XDK 5993 with VS 2003 .NET. For Allegro, you'll have to rewrite all the graphics code in Direct3D. So it won't be any harder than anything else that doesn't allready use Direct3D (like OpenGl, DirectDraw, etc) This post has been edited by nes6502: Jun 24 2006, 02:19 PM
|
|
|
|
| |
|