|
|
![]()
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Cxbx : PC XBox Emulator
Cxbx's Emulation Theory The basic theory behind Cxbx is a tasty blend of HLE (High Level Emulation), and extremely efficient direct code execution. Since the Xbox uses an Intel Pentium processor, a large percentage of the code (most importantly, the code that tends to eat up the CPU) can be executed directly. This means there is no need for DynaRec (Dynamic Recompilation), which saves alot of CPU and RAM. Emulators such as UltraHLE and Project64 have proven that High Level Emulation is a really great way to achieve high performance. Cxbx takes this idea and, because of the Xbox's architecture, takes it to the next level by combining it with direct code execution. The result is speed and accuracy.
Here is a
progress report I wrote a while back
for my student project.
The first step to creating an Xbox Emulator was determining the hardware and
software systems used by the Xbox. Since the Xbox is pretty much a PC
dressed up like a console, the hardware component was easy enough. The
software side was a bit more complicated. The Xbox uses a stripped down and
partially modified Windows 2000 Kernel. The Xbox also only executes a single
process at a time.
In order to give an Xbox game the chance to execute, it must first be loaded
as a new process, with specific environmental requirements. This task was
accomplished by analyzing the XBE (Xbox Executable) file format, and finding
a suitable conversion to the PE (Windows Exe) file format. During the time
this conversion was being programmed, the
XBE File Format was documented.
Typically, a multi-threaded environment will provide some way for the
programmer to access thread-specific data. In x86 Win32, this is done using
the FS segment selector register. Unfortunately, the Xbox and Win32 do this
just a tad bit differently. The idea is the same, but the structures are a
little bit different. After banging my head against a few walls, and brute
force hacking my way around to figure out exactly how the Xbox does it's
TLS, I was able to stabilize a very efficient method for handling the
differences. TLS is actually not used very heavily in games. It is, however,
used by the CRT and must be emulated correctly.
The basic purpose of the Xbox operating system is to provide Xbox games with
a stable and efficient environment to run inside of. Typically, the closest
an Xbox game programmer will get to the hardware is through the Xbox
Kernel's API interface. Cxbx takes over this interface, and mimics the
expected behavior of the Xbox operating system. Much of the API is wrapped
almost directly around the Win2k/XP NTDLL interface. This is very efficient,
and leaves very little overhead.
In addition to the Xbox Kernel API interface, Xbox games use statically
linked libraries that directly access the NVidia chip and other hardware
components. In order to allow an Xbox game to run on a PC, these libraries
must be located, intercepted, and emulated and/or wrapped around existing
Windows API. If you are familiar with
IDAPro, the concept of FLIRT
libraries is very similar to the technique used by Cxbx. Taking advantage of
the fact that even relocatable libraries have distinguishing
characteristics, Direct3D and other APIs can be located inside of the
virtual address space of a loaded XBE file, hooked, and emulated.
Direct3D is a complex system in itself. In addition to this complexity is
the added optimizations provided on the Xbox system. Since it is safe for
the developer to assume a very specific set of hardware, many pieces of code
are literally removed by an optimizing compiler. Other pieces of code have
changed in significant ways from Windows Direct3D. There are also many Xbox
specific features which must be emulated, including hardware specific
precompiled texture formats, vertex and pixel shaders, CPU optimized
routines, texture swizzling, special alpha ops, etc. In order for a game to
not only run but look good, these features must be accurated
emulated. The depth of the Cxbx project is significant enough that certain aspects were basically ignored for the time being. Relatively speaking, sound and network support are non-crucial features that can be implemented after retail games become playable. For the time being, there is no support for these two components. In the big picture, these features are relatively easy to add Screenshots
|
This site was last updated 08/26/03
This site is best viewed at a
resolution of 800x600 with IE 6.0+ and 16 bit colors or higher.
All images and trademarks are the copyright of their respective owners, we are
not affiliated
nor are we related to any of the companies listed on this site unless otherwise
mentioned.
If there is a mistake on the site and we offend you in some way, please mail us
and let us know the problem and we will fix it asap.
2002
Xbox world©. All rights reserved.