Running F# on a PlayStation Vita

At the progressive F# hackathon yesterday I set myself the task of getting something written in F# running on a PlayStation Vita. It’s something that I’ve wanted to do for a while now and thought there was no better time to try it. Here’s the results running on an actual device which is always a bit more impressive than just running it within an emulator.

How to do it

  1. The first thing you’ll need is a Mono compatible version of FSharp.Core, the quickest way I found to get this was to download the fsharp_30 branch of the fsharp tools from and in the FSharp.Core.fsproj add the defined symbol CROSS_PLATFORM_COMPILER. I also removed the listed references and instead added those provided by SCE in C:\Program Files (x86)\SCE\PSM\mono\lib\mono\2.1 and then run the fsharp-library-build.proj file with MSBuild
  2. Create a new F# library project (I did this in Visual Studio)
  3. Remove all of the references. Add a reference to FSharp.Core which you just built. Add a reference to all of the Sce.PlayStation dlls listed in C:\Program Files (x86)\SCE\PSM\mono\lib\psm Add references to System.dll and mscorlib.dll as provided in C:\Program Files (x86)\SCE\PSM\mono\lib\mono\2.1
  4. Delete all of the files in the project and add a new file called game.fs replace it with the following code
    namespace TestPSMLibrary
    open Sce.PlayStation.Core.Graphics
    open Sce.PlayStation.Core.Environment
    type Game() =
      let graphics = new GraphicsContext()
      member this.Run () =
        while true do
          SystemEvents.CheckEvents ()
          graphics.SetClearColor(127, 127, 127, 255)
          graphics.Clear ()
          graphics.SwapBuffers ()
  5. Build your library project
  6. Open up PSM Studio and create a new PSM Application
  7. Add a reference to your library project as well as the version of FSharp.Core you built in Step 1
  8. Replace the contents of main.cs with the following
    using System;
    using System.Collections.Generic;
    using TestPSMLibrary;
    namespace TestApplication
      public class AppMain
        public static void Main (string[] args)
          var game = new Game();
  9. Run it in the simulator or on device and you should see a grey screen

One comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s