Jump to content


Photo

Very Simple Guide To Xbox App/emulator Porting


  • Please log in to reply
26 replies to this topic

#1 nes6502

nes6502

    X-S Freak

  • Members
  • PipPipPipPipPip
  • 1,799 posts

Posted 22 June 2006 - 02:00 PM

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.

Edited by nes6502, 22 June 2006 - 02:07 PM.


#2 wizzel

wizzel

    X-S Enthusiast

  • Members
  • 25 posts
  • Location:Germany
  • Interests:Comps, XBOX, Emulation, Ports & Pinball
  • Xbox Version:v1.6
  • 360 version:unknown

Posted 23 June 2006 - 12:12 AM

...and i thought i was a nOOb.
Now all i know is that i must be a super-duper multi-nOOb. ph34r.gif

It reminds me of coding my first CGA-emulator for the HGC Graphics Card
on the PC way back in the early 80s. laugh.gif

Especially the "until all errors are gone"-part. biggrin.gif

Anyway, nice (interesting) guide, nes! happy.gif
Keep on rocking!

Edited by wizzel, 23 June 2006 - 12:17 AM.


#3 Albino

Albino

    X-S Expert

  • Members
  • PipPipPip
  • 739 posts
  • Location:West Yorkshire, UK
  • Xbox Version:v1.0

Posted 23 June 2006 - 12:52 AM

I've always fancied a go at something and when I get some free time, I may have a crack at mame with a newer core, these old ones and running clrmamepro do my nut in. No doubt I will fail misserbly but I've gotta have something to do instead of my degree when I go to uni in september. I like the "repeat step 5 until all errors are gone" it reminds me of disassembling and recompiling my acpi under linux.

#4 nes6502

nes6502

    X-S Freak

  • Members
  • PipPipPipPipPip
  • 1,799 posts

Posted 23 June 2006 - 01:05 AM

Yes. Step 6 is the hard one. In fact I gave up many times when doing ZsnexBox. I was overwhelmed by the code. I thought there was no way I could pull it off. Especially since it's all assembly. But the reality is, I didn't have to change much of anything in the assembly. I just had to replace the video and input code (and change the sound code a bit).

In fact, many of the errors in the "Step 6 Loop" were easy to fix. I just commented the code out. This is whey there is no ZSNES movie support, no ZSNES png support, or jma support.

I havn't figured out how to "fix" those errors yet.

ZSNES was not considered (I don't think) by many as an "easy" port. It was my first port and I pulled it off. So I don't want pople to get bogged down with the complexity of the source material. You won't have to change or even understand 99% of it.

If they can use Direct3D to set a pixel color, play a streaming wav with DirectSound, and have an intro level C or C++ skill level, they can port anything (with enough determination).

Edited by nes6502, 23 June 2006 - 01:11 AM.


#5 Diontae18

Diontae18

    X-S Expert

  • Members
  • PipPipPip
  • 724 posts
  • Location:Nibelheim
  • Xbox Version:unk
  • 360 version:unknown

Posted 23 June 2006 - 01:13 AM

Man I had those tools on my hdd forever, but only used them for XBMC.
This oughta be linked from VampX's great emu guide, or pinned. This lil' guide will become very useful for me, and I'm sure a lot of others. Thanks nes6502.
pop.gif

#6 XaRaNn

XaRaNn

    X-S X-perience

  • Members
  • PipPip
  • 461 posts
  • Xbox Version:v1.1

Posted 23 June 2006 - 04:32 PM

I second the pinning of this thread.

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.

#7 GogoAckman

GogoAckman

    X-S Expert

  • Members
  • PipPipPip
  • 520 posts
  • Location:Brussels
  • Xbox Version:v1.4
  • 360 version:none

Posted 23 June 2006 - 04:51 PM

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 tongue.gif .

#8 nes6502

nes6502

    X-S Freak

  • Members
  • PipPipPipPipPip
  • 1,799 posts

Posted 23 June 2006 - 05:25 PM

I can only speak from my experience. I have mainly asked for help from Xport. But I have also gotten help from GogoAckman and Cacharus.

The available code is a good point. There is a lot of code that has already been written that can almost be plugged in with little change. Even though the Xport code I use only makes up about 1% of ZsnexBox, it was a 1% that saved me a lot of time, research, and effort (like screenshot saving, zip file contents, mounting partitions, HD support).

#9 Carcharius

Carcharius

    X-S Expert

  • Members
  • PipPipPip
  • 635 posts

Posted 23 June 2006 - 06:57 PM

QUOTE(nes6502 @ Jun 23 2006, 05:32 PM) View Post

I can only speak from my experience. I have mainly asked for help from Xport. But I have also gotten help from GogoAckman and Cacharus.

*cough* Carcharius *cough* tongue.gif


#10 nes6502

nes6502

    X-S Freak

  • Members
  • PipPipPipPipPip
  • 1,799 posts

Posted 23 June 2006 - 07:06 PM

QUOTE(Carcharius @ Jun 23 2006, 07:04 PM) View Post

*cough* Carcharius *cough* tongue.gif


Sorry, I allways mispell your name. Never was a good speller

#11 manlol

manlol

    X-S Enthusiast

  • Members
  • 9 posts

Posted 24 June 2006 - 10:52 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.

#12 VampX

VampX

    X-S Legend

  • Moderator
  • PipPipPipPipPipPipPipPipPip
  • 5,149 posts
  • Xbox Version:v1.2
  • 360 version:none

Posted 24 June 2006 - 12:14 PM

QUOTE(Diontae18 @ Jun 23 2006, 02:20 AM) View Post

This oughta be linked from VampX's great emu guide, or pinned.


Since there are like as many xbox developers as there are people that can't figure out pcsxbox right?
PIN PIN PIN THERE'S ROOM NOW!!! tongue.gif


ofcourse this is going to be in the new revision of the pinned thread, but lets refrain from pinning everything again ohmy.gif

Edited by VampX, 24 June 2006 - 12:14 PM.


#13 nes6502

nes6502

    X-S Freak

  • Members
  • PipPipPipPipPip
  • 1,799 posts

Posted 24 June 2006 - 02:15 PM

QUOTE(manlol @ Jun 24 2006, 10:59 AM) View Post

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)

Edited by nes6502, 24 June 2006 - 02:19 PM.


#14 Retroplay

Retroplay

    X-S Expert

  • Members
  • PipPipPip
  • 593 posts
  • Location:Denmark
  • Xbox Version:v1.1
  • 360 version:v3.0 (falcon)

Posted 24 June 2006 - 09:23 PM

What about the directX sdk?
No need to install that then?

I really have to start getting into this smile.gif

Edited by Retroplay, 24 June 2006 - 09:24 PM.


#15 GogoAckman

GogoAckman

    X-S Expert

  • Members
  • PipPipPip
  • 520 posts
  • Location:Brussels
  • Xbox Version:v1.4
  • 360 version:none

Posted 24 June 2006 - 10:02 PM

QUOTE(Retroplay @ Jun 24 2006, 10:30 PM) View Post

What about the directX sdk?
No need to install that then?

I really have to start getting into this smile.gif


No, the xbox uses direct3d8 version, and even a reprogrammed version of direct3d (textures and some functions differ from PC d3d, but you can have a lot of informations in the help section of the xdk smile.gif ).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users