Saturday, 14 August 2010

Windows vs Xbox360

I do most of my development and testing on Windows. It's a much quicker cycle from code to test to code again. From time to time I have to test on the Xbox360 to make sure it all runs.

Whenever I test on the 360 there are always differences. The number of times I have seen a code 4 error! This time it was very unexpected because it was type casting.

I had tidied up my storage code. I had lots of the same loading and saving code where the only difference was the class of file it was working with. I did the obvious and converted it to a generic function using the base 'object' class and type cast to the type I needed.

This all worked perfectly first time on Windows. Not at all on the Xbox360. Turns out that no matter how I try I cannot return a value when I cast it back from the 'object' class. On the Xbox360 it always returns null.

I re-wrote the code so I didn't have to return a value. I keep the generic 'object' in the one method and have a set of if statements to store the results in the correct type. Not as neat but it works.

While on the subject of peculiarities and storage the Guide function on the 360 can be misleading. Sometimes it returns busy when it is not or perhaps it was a moment ago but it's not now! I have had to add several automatic retry loops in my code to avoid that problem.

2 comments:

Unwise Enterprise said...

Hey -- just found this blog from XNA. Just thought I'd tell you that you're doing some impressive work.

John C Brown said...

Thanks the encouragement is welcome. A lot of work has gone in to it.