Xbox 360 port

Discussion about other and unofficial ports of ScummVM

Moderator: ScummVM Team

User avatar
Vinterstum
ScummVM Developer
Posts: 580
Joined: Sun Oct 16, 2005 6:59 am

Post by Vinterstum »

TommyBear wrote:I think you are forgetting that you cannot run managed C++ on XNA at the moment.
You can (Well, not Managed C++, that's deprecated, but C++/CLR). MS just doesn't make it as easy as with C#, but compiled down the bytecode is identical.

http://forums.microsoft.com/MSDN/ShowPo ... 1&SiteID=1
TommyBear
Posts: 13
Joined: Thu Dec 21, 2006 1:08 pm

Post by TommyBear »

Okay, I'll bite. How would I make this compile and then deploy on the 360?

I can develop C++/CLR code C++ express, but then I need a way to deploy it and C# express is the only thing that deploy at the moment. Perhaps I'll hunt around the command line tools for a bit. Hmmmmm

Tommy.
User avatar
Vinterstum
ScummVM Developer
Posts: 580
Joined: Sun Oct 16, 2005 6:59 am

Post by Vinterstum »

Can't really help you there, haven't tried it out yet. Perhaps you might be able to make a small C# wrapper and call the C++ project from there.
User avatar
Vinterstum
ScummVM Developer
Posts: 580
Joined: Sun Oct 16, 2005 6:59 am

Post by Vinterstum »

TommyBear
Posts: 13
Joined: Thu Dec 21, 2006 1:08 pm

Post by TommyBear »

That is awesome... I tried this a while back and had some issues calling the class library I compiled... but perhaps I was doing something wrong... Going to take a look at this soon. :)

Thanks Vinterstum!
TommyBear
Posts: 13
Joined: Thu Dec 21, 2006 1:08 pm

Post by TommyBear »

Ok I've managed to build ScummVM in C++ CLR... I'm now hunting for bits and pieces of code that force native compilation. After this I will write the C# wrapper and reference the new ScummVM-CLR assembly via gse.

If all goes well I'll just need to modify scummVM slightly to allow the ScummVM update loop to be ticked from within C# and it's XNA game framework and then I'll be writing the backend!

This is, of course, if I can get gse abd the xbox360 to accept the assembly :) We'll see. Thanks again for the advice.

Tommy.
User avatar
Vinterstum
ScummVM Developer
Posts: 580
Joined: Sun Oct 16, 2005 6:59 am

Post by Vinterstum »

Nice work!

You might have some problems with the game loop though, since each engine in ScummVM uses its own. The easiest solution might be to just run the actual ScummVM in a thread of its own, with a shared buffer for the screen updates (If Microsoft would've just allowed us to override the Game.Run method, things would've been so much simpler...).
TommyBear
Posts: 13
Joined: Thu Dec 21, 2006 1:08 pm

Post by TommyBear »

Okay... I've got ScummVM compiled totally to MSIL (using /clr:pure), and I've got a small XNA wrapper, that instantiates the class in the assembly and calls a method. It does deploy to the console, but running the assembly I get:

An unhandled exception of type 'System.TypeLoadException' occurred in ScummVM-XNA.exe

Which makes me think that the two are not using the same framework etc etc.

Anyway I'm off to get some sleep I'll take a look at this tomorrow.

Tommy.
TommyBear
Posts: 13
Joined: Thu Dec 21, 2006 1:08 pm

Post by TommyBear »

Well I've taken I good long look at the problem, which basically seems to boil down to that the ScummVM classes end up looking like this in the assembly:

Code: Select all

using System.Runtime.CompilerServices;
using Microsoft.VisualC;

namespace Saga
{

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Size = 480)]
    [NativeCppClass]
    [DebugInfoInPDB]
    [MiscellaneousBits(64)]
    [UnsafeValueType]
    internal struct Actor
    {

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Size = 8)]
        [DebugInfoInPDB]
        [NativeCppClass]
        [MiscellaneousBits(65)]
        internal struct PathNode
        {
        }

    }

}
With that in mind, it appears that the C++ code in ScummVM is still being compiled as native x86 code in clr mode. Even when pure mode is used, I imagine the absence on both the CompilerServices and VisualC namespaces on the framework running on the XBox360, can't make this a better situation. The code simply cannot be in PPC format. So it looks like it's C# or bust... note that managed c++ segments work fine, it's just trying to call the native bits that blows up. If anyone has any suggestions, then I'm all ears.

Tommy.
User avatar
Vinterstum
ScummVM Developer
Posts: 580
Joined: Sun Oct 16, 2005 6:59 am

Post by Vinterstum »

At a guess, the above might be compiled to native code because packing of structs isn't supported in MSIL? There should be ways around that, as well as the lack of varargs.

I'm less sure about the missing namespaces though, I haven't seen the 360 framework in a lot of detail (what exactly is being called in those namespaces?).

I'll try to spare some time to look at this before new years :).
TommyBear
Posts: 13
Joined: Thu Dec 21, 2006 1:08 pm

Post by TommyBear »

I could drop what I've done into the scummvm-xna repository if you wish. Anyway, any hints on this would be appreciated.
TommyBear
Posts: 13
Joined: Thu Dec 21, 2006 1:08 pm

Post by TommyBear »

Also note that I took the packing out of the structs, by #define-ing out the packing explicitly. I also tried to force include a header with "#pragma managed" into each compiled file. I haven't removed all the varargs instances, but surely I'd expect to see some managed code somewhere even with those in there.

I'm currently committing the entire group of CLR work into the repository. I expect it to be finished committing in about 40 minutes. You can get it here when it's done:

http://sourceforge.net/projects/scummvmxna

Tommy.
User avatar
Vinterstum
ScummVM Developer
Posts: 580
Joined: Sun Oct 16, 2005 6:59 am

Post by Vinterstum »

Nice, I'll take a look at this tomorrow.
TommyBear
Posts: 13
Joined: Thu Dec 21, 2006 1:08 pm

Post by TommyBear »

Cool. Please note that the all scummvm code is included in the repository as I have actually made changes to it to get it to compile... at the moment this is all a hack... this is my disclaimer :) If this actually works, I'll do a proper diff of this tree against the 0.9.1 branch and include only the changes blah blah blah.

Tommy.
User avatar
sev
ScummVM Lead
Posts: 2305
Joined: Wed Sep 21, 2005 1:06 pm
Contact:

Post by sev »

TommyBear wrote:If this actually works, I'll do a proper diff of this tree against the 0.9.1 branch
Please, please, work with latest SVN code, not 0.9.1. 0.9.1 is a half year old codebase. We got several restructuring and new features.


Eugene
Post Reply