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.
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.
Edited by nes6502, 22 June 2006 - 02:07 PM.