xboxscene.org forums

Author Topic: Spacewar Windows Starter Kit (patches)  (Read 443 times)

openxdkman

  • Archived User
  • Hero Member
  • *
  • Posts: 550
Spacewar Windows Starter Kit (patches)
« on: December 12, 2006, 08:14:00 AM »

About joypad problem. I was using a wired xbox360 controller + XBCD driver + ControlMK
That's the best free configuration to play with all games on PC, and I use joypad instead of mouse when ps/2 mouse signal gets lost to avoid reboot (giant mobile phones antenas near my home sparkle EM spikes that do that sometimes) (see http://xbcd360guide.....com/guide.html for details about xbcd)

I retried with wired xbox360 controller + official driver. It worked.

Many people complain about xna not being able to use all existing joypad. I don't know what to think.
On one hand, it's frustrating, on other hand joypad is not expensive and forcing developpers to adopt same kind of button/trigger/stick configuration may make things easier for developers and players...
It seems there is a way to add a complete module that will handle all joypads, but MS won't write it I bet.
That will come from an independant developer surely, somedays. I doubt I can do it myself, I only have one usb joypad, it's the xbox360 controller... But I may try to see what prevents the xbcd from working.

For now, xbcd driver users, like me, need a way to quickly switch from a driver to another. The official xbox360 driver is a bit annoying to install, because the online automatic procedure may be slow sometimes.

I detected the files installed with official driver and found a way to put them in a directory with the appropriate structure so I can reinstall driver by just giving that directory path (so now it's faster to remove/add driver and you don't need internet) :

/oem30.inf (retrieve it from /Windows/Inf)
/oem30.PNF (retrieve it from /Windows/Inf)
/x86/WdfCoInstaller01001.dll (retrieve it from /Windows/System32/)
/x86/xusb20.sys (retrieve it from /Windows/System32/drivers)

/x86/wdf01000.sys (not needed probably)
/x86/wdfldr.sys (not needed probably)

About bad window size, I'm using 800x600 because I get better quality on my old plasma with that.
It seems some autodetection code is missing to get things right.
I will work on it.
Logged

openxdkman

  • Archived User
  • Hero Member
  • *
  • Posts: 550
Spacewar Windows Starter Kit (patches)
« Reply #1 on: December 12, 2006, 11:18:00 AM »

For those without wired xbox360 controller and with wrong window size, on right appears :
B : Retro
A : Evolved
X : Info

The default keyboard mapping for Spacewar can be found in settings.xml (fits well qwerty keyboards)

Player1:

Start:LeftControl
Back:LeftShift
A:V
B:G
X:F
Y:T
ThumbstickLeftXmin:A
ThumbstickLeftXmax:D
ThumbstickLeftYmin:S
ThumbstickLeftYmax:W
Left:A
Right:D
Down:S
Up:W
LeftTrigger:Q
RightTrigger:E

Player2:

Start:RightControl
Back:RightShift
A:Home
B:End
X:PageUp
Y:PageDown
ThumbstickLeftXmin:Left
ThumbstickLeftXmax:Right
ThumbstickLeftYmin:Down
ThumbstickLeftYmax:Up
Left:Left
Right:Right
Down:Down
Up:Up
LeftTrigger:Insert
RightTrigger:Delete

Logged

openxdkman

  • Archived User
  • Hero Member
  • *
  • Posts: 550
Spacewar Windows Starter Kit (patches)
« Reply #2 on: December 12, 2006, 11:34:00 AM »

Patch in order to have all Spacewar window visible in lower resolution than 1280x720 :

In SpacewarGame.cs, at line 151, replace


#else
            enableDrawScaling = true;
#endif

with

#else
            preferredWindowWidth = 800;
            preferredWindowHeight = 600;
            enableDrawScaling = true;
#endif

I'm currently looking for a way to set variables with the current width and height of current Windows desktop resolution. I will post it if I find it.
Logged

openxdkman

  • Archived User
  • Hero Member
  • *
  • Posts: 550
Spacewar Windows Starter Kit (patches)
« Reply #3 on: December 12, 2006, 12:35:00 PM »

Ok, I found a way :

At line 175, replace :


            // game initialization code here

with

            // game initialization code here
            {
                #if XBOX360
                #else
                GraphicsAdapter adapter;
                adapter = graphics.GraphicsDevice.CreationParameters.Adapter;
                preferredWindowWidth = adapter.CurrentDisplayMode.Width;
                preferredWindowHeight = adapter.CurrentDisplayMode.Height;
                ToggleFullScreen();
                ToggleFullScreen();
                #endif
            }


I thought I could use this code where preferred sizes are first set, but it doesn't work.
Right after graphics creation, it's probably too soon. The GraphicsDevice member is not initialized yet.
So in game initialization area it works, but it's too late window is already created with hardcoded size.
So I call TogleFullScreen twice to switch to fullscreen (black screen syndrome on my xp+geforce7300) then immediately switch to window again but with new calculated size. Doesn't work too bad...

To manually toggle between fullscreen and windowed it's Alt+Return

All program should start in windowed mode by default, because full screen mode won't work at all on many PCs (my PC is quite recent and graphic card is recent too). There's a nasty issue in full screen mode I feel...
Logged

openxdkman

  • Archived User
  • Hero Member
  • *
  • Posts: 550
Spacewar Windows Starter Kit (patches)
« Reply #4 on: December 14, 2006, 08:53:00 AM »

Fix for full screen mode (for many screens, refreshrate in fullscreen mode will be too high)

Replace

        void PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
        {
            // We turn off auto depth buffer creation when scaling output.
            //
            e.GraphicsDeviceInformation.PresentationParameters.EnableAutoDepthStencil = !enableDrawScaling;
        }

with

        void PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
        {
            // We turn off auto depth buffer creation when scaling output.
            //
            e.GraphicsDeviceInformation.PresentationParameters.EnableAutoDepthStencil = !enableDrawScaling;
#if XBOX360            
#else
           
            if (e.GraphicsDeviceInformation.PresentationParameters.IsFullScreen)
                e.GraphicsDeviceInformation.PresentationParameters.FullScreenRefreshRateInHz = 60;
#endif            
        }


I will look for a way to improve this patch (better to detect the current windows desktop resolution refreshrate and keep it for full screen mode)
Logged

openxdkman

  • Archived User
  • Hero Member
  • *
  • Posts: 550
Spacewar Windows Starter Kit (patches)
« Reply #5 on: December 14, 2006, 09:15:00 AM »

Ok, that will be the last needed patch I think.
This one will set in fullscreen mode the same refreshrate detected in windowed mode :
(you can still force its value though if you wish)

At line 30, add a new variable

private int preferredRefreshRate = 0;
        //0 will mean you want to set this variable when we are in windowed
        //mode and reuse it later when we go back to fullscreen mode



replace

void PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
{
// We turn off auto depth buffer creation when scaling output.
//
e.GraphicsDeviceInformation.PresentationParameters.EnableAutoDepthStencil = !enableDrawScaling;
}

with


void PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
{
// We turn off auto depth buffer creation when scaling output.
//
e.GraphicsDeviceInformation.PresentationParameters.EnableAutoDepthStencil = !enableDrawScaling;

#if XBOX360            
#else
            if (e.GraphicsDeviceInformation.PresentationParameters.IsFullScreen)
            {
                if (preferredRefreshRate!=0)
                    e.GraphicsDeviceInformation.PresentationParameters.FullScreenRefreshRateInHz = preferredRefreshRate;
                else //we never went in windowed mode before, dunno what is refreshrate yet
                    e.GraphicsDeviceInformation.PresentationParameters.FullScreenRefreshRateInHz = 60;
                }
#endif            
}



finally, replace

                // going fullscreen, use desktop resolution to minimize display mode changes
                // this also has the nice effect of working around some displays that lie about
                // supporting 1280x720
                GraphicsAdapter adapter = graphics.GraphicsDevice.CreationParameters.Adapter;
                graphics.PreferredBackBufferWidth = adapter.CurrentDisplayMode.Width;
                graphics.PreferredBackBufferHeight = adapter.CurrentDisplayMode.Height;

with

                // going fullscreen, use desktop resolution to minimize display mode changes
                // this also has the nice effect of working around some displays that lie about
                // supporting 1280x720
                GraphicsAdapter adapter = graphics.GraphicsDevice.CreationParameters.Adapter;
                graphics.PreferredBackBufferWidth = adapter.CurrentDisplayMode.Width;
                graphics.PreferredBackBufferHeight = adapter.CurrentDisplayMode.Height;
                if (preferredRefreshRate==0) preferredRefreshRate = adapter.CurrentDisplayMode.RefreshRate;


Ok... now we can have fun!
Logged