I was just discussing with cairnswm about creating stuff with Pascal and XNA. Since Chrome 1.5 supports .NET 2.0 I thought I would quickly try and get a Hello world progam workin. This is the result...

0. Install .NET 2.0 and XNA Game Studio Express
1. Download the Free Chrome 1.5 command line compiler and install it
2. Create a file named XNADemo.pas and copy code as follows...
Code:
namespace XNADemo;
interface
uses
Microsoft.Xna.Framework,
Microsoft.Xna.Framework.Content,
Microsoft.Xna.Framework.Audio,
Microsoft.Xna.Framework.Graphics,
Microsoft.Xna.Framework.Input,
Microsoft.Xna.Framework.Storage;
type
TXNAGame = class(Microsoft.Xna.Framework.Game)
private
// these are the size of the output window, ignored on Xbox 360
preferredWindowWidth : integer;
preferredWindowHeight : integer;
graphics : GraphicsDeviceManager;
class content : ContentManager;
protected
method Initialize; override;
method BeginRun; override;
method Update( gameTime : Gametime ); override;
method BeginDraw : boolean; override;
method Draw( gameTime : Gametime ); override;
method EndDraw; override;
method LoadGraphicsContent( loadAllContent : boolean ); override;
method UnloadGraphicsContent( unloadAllContent : boolean ); override;
public
constructor;
// Entry point into this object.
class method Main;
end;
implementation
constructor TXNAGame;
begin
inherited;
preferredWindowWidth := 320;//1280;
preferredWindowHeight := 240;//720;
Self.graphics := new Microsoft.Xna.Framework.GraphicsDeviceManager(Self);
Self.graphics.PreferredBackBufferWidth := preferredWindowWidth;
Self.graphics.PreferredBackBufferHeight := preferredWindowHeight;
end;
class method TXNAGame.Main;
begin
try
// probably should not be instantiating an object within itself :).
with lGame := new TXNAGame do
lGame.Run;
except
on E: Exception do
begin
// MessageBox.Show(E.Message);
end;
end;
end;
method TXNAGame.Initialize;
begin
// Your Initialize Code here
Window.Title := 'Pascal and XNA';
inherited;
end;
method TXNAGame.BeginRun;
begin
// Your BeginRun Code here
inherited;
end;
method TXNAGame.Update( gameTime : Gametime );
begin
// Allows the default game to exit on Xbox 360 and Windows
if (GamePad.GetState(PlayerIndex.One).Buttons.Back = ButtonState.Pressed) then
Self.Exit();
// Your Update Code here
inherited Update( gameTime );
end;
method TXNAGame.BeginDraw : boolean;
begin
if not ( inherited BeginDraw ) then
begin
result := false;
exit;
end;
// Your BeginDraw Code here
result := true;
end;
method TXNAGame.Draw( gameTime : Gametime );
begin
graphics.GraphicsDevice.Clear( Color.CornflowerBlue );
inherited Draw( gameTime );
// Your Draw Code here
end;
method TXNAGame.EndDraw;
begin
// Your EndDraw Code here
inherited;
end;
method TXNAGame.LoadGraphicsContent( loadAllContent : boolean );
begin
if (loadAllContent) then
begin
// TODO: Load any ResourceManagementMode.Automatic content
end;
// TODO: Load any ResourceManagementMode.Manual content
end;
method TXNAGame.UnloadGraphicsContent( unloadAllContent : boolean );
begin
if (unloadAllContent) then
begin
content.Unload;
end;
end;
end.
3. At the command line type
Code:
Chrome XNADemo.pas /frameworkversion:v2.0.50727 /ref:"C:\Program Files\Microsoft XNA\XNA Game Studio Express\v1.0\References\Windows\x86\Microsoft.Xna.Framework.dll" /ref:"C:\Program Files\Microsoft XNA\XNA Game Studio Express\v1.0\References\Windows\x86\Microsoft.Xna.Framework.Game.dll"
If all goes well you should have an XNADemo.exe file ready to run. This will display a blank screen with the Window title "Pascal and XNA"!
Remember this is Chrome Object Pascal, which is slightly different to CodeGear Object Pascal
Bookmarks