| Jack Palevich 的个人资料GrammerJack日志 | 帮助 |
|
2006/12/24 Linus Torvalds on CPUsLinus Torvalds is famous as the "Martin Luther" of the Linux OS, but recently I've discovered than one of his other interests is CPU design. And he knows quite a bit about x86 CPU architecture, both from the OS writer's point of view, and as an x86 CPU implementor, courtesy of his time at Transmeta.
Linus posts frequently on the Real World Tech forums. I've learned a lot of interesting points about modern CPU design from his posts.
The easiest way to keep track of Linus's posts is to use the Search the Forums page and search for "Linus".
His general thesis is that the x86 (at least starting with the 386) is a fine architecture, and that many x86 implementations provide excellent performance by making every case fast, not just some cases like other CPUs.
2006/12/11 How to Write XNA Game Studio Express Games with F# - Part 3: Running on the Xbox 360Now to run on the 360. First, you need to set up your Xbox 360 and PC to run regular C# XNA games. That's beyond the scope of this article, but you should be able to find directions on the XNA Game Studio Express web site. I'm going to assume you've already created and run the sample C# games on your Xbox 360, so that you have everything configured correctly. Now, in order to run your F# game on the Xbox 360, you'll need to make these changes:
Let's go over that process in detail: Step 1: Modify the F# game.fs file you created in Part 2: Change this line (that's near the beginning) from the Windows path: #I @"C:\Program Files\Microsoft XNA\XNA Game Studio Express\v1.0\References\Windows\x86" To the following lines, which conditionally use the correct path, depending upon whether we're compiling for Windows or for Xbox 360: #if XBOX360 #I @"C:\Program Files\Microsoft XNA\XNA Game Studio Express\v1.0\References\Xbox360" #else #I @"C:\Program Files\Microsoft XNA\XNA Game Studio Express\v1.0\References\Windows\x86" #endif Step 2: Compile the F# DLL as a standalone DLL:
"C:\Program Files\FSharp-1.1.13.8\bin\fsc.exe" -a -g --standalone --define XBOX360 -o game360.dll game.fs Step 3: Create an Xbox 360 Game XNA GSE project:
Step 4: Add your F# DLL to the Xbox 360 Game XNA GSE project
Step 5: Write some C# code to call your F# game
Step 6: Compile and run your game on the Xbox 360
That's all there is to it! I hope you've enjoyed these posts. If you're interested in the F# language, a good resource is hubFS: THE place for F# FAQQ: Can I use this call-a-DLL approach to write Xbox 360 XNA Game Studio Express games for other non-C# CLR languages like Iron Python or Visual Basic? A: Unfortunately no, not for those two specific languages. (Sorry!) The reason is that the Xbox 360 version of the XNA GSE CLR is based on the .NET Compact Framework 2.0. This is a problem for Iron Python and Visual Basic because those particular languages rely on CLR features that are not present in the .NET Compact Framework 2.0. Therefore you will get a runtime error when you try and run your Iron Python or Visual Basic code on the 360. It's possible that future versions of either the languages or the Xbox 360 GSE runtime will fix this problem. (But don't hold your breath -- nobody has promised anything in these areas. Only C# is officially supported for XNA GSE games.) Note that this limitation to run on top of the .NET Compact Framework only applies to the Xbox 360 version of your game. Although I have not tried it, I believe that it should be possible to use a variation of the techniques in Part 2 to run Iron Python and/or Visual Basic XNA GSE games on Windows. Alan Phipps has written set of tutorials on Using Visual Basic with XNA GSE on Windows Q: Have you written an Xbox 360 game in F#? A: Yes, a small game "Dandy Dungeon". I haven't had time to clean up the sources for publication yet. You can find the sources to an early non-XNA version of this game on hubFS. Q: Why are you messing around with F# anyway? Isn't C# cool enough for you? A: I love C# (and I do most of my day-job programming in either C# or C++), but I'm attracted to F# for it's brevity and its neat-o functional programming language features. It's also a lot of fun to watch the language evolve and improve. How to Write XNA Game Studio Express Games with F# - Part 2 Using F# with Visual C# ExpressIn Part 1 we saw how to create a simple stand-alone F# game based on XNA GSE. But the stand-along game had two limitations:
The reason for both of these limitations is that the approach we took avoided using Visual C# Express. In order to get around the limitations, we have to bring Visual C# Express into the picture. Unfortunately, we can't just create an F# project in Visual C# Express. For one reason or another, Visual C# Express only supports compiling C# source files. However, there is an escape hatch: Visual C# Express allows you to reference any number of DLLs, and those DLLs can be written in any language. Even better, the Visual C# debugger works fine with DLLs written in any .NET language. So our strategy is:
That's all there is to it! Let's go through the process step by step in more detail: Step 1: Configure Visual C# Express to expose advanced features:
Step 2: Write our F# code. Use the text editor of your choice to write the following F# code. NOTE: This version of game.fs is slightly different than the game.fs file in the previous post. The difference is that we do not call the main() function at the end of the file. (Instead we will call it from the C# code in a C# project that we create in a later step.)
Step 3: Save the F# file as "game.fs", and then open a cmd.exe shell window and compile the game as a DLL using the F# compiler:
The -a flag means "create an assembly", which is the CLR name for a DLL. The -g flag means "add debugging information", which lets you step through your F# code in the debugger. Step 4: Create a Visual C# XNA Game Studio Express project
Step 5: Add your F# DLL to the XNA GSE project
Step 6: Write some C# code to call your F# game
Step 7: Compile and run your game
That's all there is to it! The benefits of this round-about approach are
Coming in part 3: Changes needed to support Xbox 360 development. How to Write XNA Game Studio Express Games with F# - Part 1 Getting StartedThis blog entry explains how to write XNA Game Studio Express games in the F# programming language. To begin, let me explain what "XNA GSE" and "F#" are:
In this series of articles, I'm going to show how to:
Let's get started with creating a trivial F# XNA game that runs on Windows. (And by trivial I mean really trivial: the game just draws a blank green screen.) Step 1: Download and install Visual C# Express: Visual C# Express Home Page Step 2: Download and install XNA Game Studio Express: XNA Game Studio Express Home Page Step 3: Download and install F#: F# Home Page
Step 4: Create an F# source file using your favorite text editor:
Step 5: Save the F# file as "game.fs", and then open a cmd.exe shell window and compile the game using the F# compiler:
Step 6: Run the game by double-clicking on the "game.exe" or by typing "game.exe" at the command line. That's all there is to it! However, is are some drawbacks to this approach. By bypassing Visual C# Express:
In the Part 2 of this article I will explain how to work around these problems. |
|
|