typescript psp emulator
C++ JavaScript C TypeScript Makefile Assembly Other
Latest commit d9c3ebf Oct 30, 2016 @soywiz soywiz Small update
Failed to load latest commit information.
.vscode Updated to typescript 2.0 Oct 30, 2016
data Merge commit 'f7303b7a28404c387c233f939e272c2224e510e4' as 'data/pspa… Oct 30, 2016
project Updated to typescript 1.5 with noImplicitAny and to work with Visual … May 1, 2015
source Small update Oct 30, 2016
tools WIP emulator in worker and WEBGL in UI May 13, 2015
.gitdescribe - Added version information Jul 22, 2014
.gitignore WIP emulator in worker and WEBGL in UI May 13, 2015
.travis.yml Another travis-ci try May 1, 2015
README.md Updated to typescript 1.5 with noImplicitAny and to work with Visual … May 1, 2015
benchmark Added headless and normal benchmark Apr 6, 2015
benchmark.bat Fixed npm start build Apr 18, 2015
benchmark.html WIP broken May 4, 2015
build Updated to typescript 2.0 Oct 30, 2016
build.bat Updated to typescript 1.5 with noImplicitAny and to work with Visual … May 1, 2015
clean Updated to typescript 2.0 Oct 30, 2016
index.html WIP emulator in worker and WEBGL in UI May 13, 2015
jspspemu-me.js WIP emulator in worker and WEBGL in UI May 13, 2015
jspspemu.js Small update Oct 30, 2016
jspspemu_headless.js Added headless and normal benchmark Apr 6, 2015
jspspemu_tests.js BROKEN index.html (removing jquery, underscore, moment and google ana… May 4, 2015
oauth_receive.html - updated dropbox oauth May 12, 2014
package.json Small update Oct 30, 2016
test.html WIP new MediaEngine based on ffmpeg that will enable at3. at3+, mp3, … May 10, 2015
tests Updated to typescript 2.0 Oct 30, 2016



Build Status

A PSP emulator made using javascript (actually typescript). It works with modern browsers.

Valhalla Knights screenshot


You must have Visual Studio Code, that is available for Windows, Linux and Mac. https://code.visualstudio.com/ Then you have to open "source" folder, it will detect tsconfig.json and you will be able to edit. In order to compile as you edit, please read next section "Building from source".

Building from source:

First install node.js >= 0.12: http://nodejs.org/ Then you must have tsc command in path, install typescript:

npm -g install typescript

Then you can start a debug web server that also will compile typescript whenever it changes with this command in the project's folder:

npm start

Then you can just change .ts files and refresh the page.

This will compile, watch for changes and start a server at port 8080. So you can check the emulator in:

You can run tests accessing this url:

Or by calling "npm test".


Lastest version have been tested on:

  • Google Chrome 36 (fastest)
  • Opera 23
  • Firefox 31
  • Internet Explorer 11 (no sound)
  • Safari 8 (it won't work with prior versions because of the lack of webgl support)

Opera and Chrome performs the best because they use V8 that is lightning fast.

More information:

You can view the lastest version here (updated from git every push):

You can reference some samples like this:

It uses promises, Typed Arrays, Audio API, Canvas, WebGL, FullScreen API, File API, Web Workers, WebSockets and the Gamepad API. It will use FileSystem API / IndexedDB too.

At this point it can run some demos and homebrew games.

Typescript, and the integrated console and profiler from chrome allowed me to convert some of my cspspemu code pretty fast, in a crazy weekend for this first version. You can debug apps with the chrome console.

The project can be opened with Visual Studio Express but it should work with intelliJ/webstorm or any typescript IDE too.

It can load at this point: ELF, PBP, ISO, CSO and ZIP files. Not support for DAX yet.

It JITs the cpu (though still slow because loops, function calls, and returns are not JITted yet) (just compiles basic blocks without any kind of control flow). As with my other psp emulator cspspemu, it has a single instruction table that allows to create the cpu dynarec, assembler and disassembler. It JITs the instruction decoding nested switch. It JITs the vertex decoding.

Module exported functions are like this:

sceAudioOutputPannedBlocking = createNativeFunction(0x13F592BC, 150, 'uint', 'int/int/int/void*', this, (channelId: number, leftVolume: number, rightVolume: number, buffer: Stream) => {
    var channel = this.channels[channelId];
    return channel.channel.playAsync(core.PspAudio.convertS16ToF32(buffer.readInt16Array(2 * channel.sampleCount)));

Exported functions returning promises suspend the current psp thread until the promise is resolved.

And binary structs are defined like this so it is pretty agile to work with binary stuff:

export class ElfPspModuleInfo {
    moduleAtributes: number;
    moduleVersion: number;
    name: string;
    gp: number;
    pc: number;
    exportsStart: number;
    exportsEnd: number;
    importsStart: number;
    importsEnd: number;

    // http://hitmen.c02.at/files/yapspd/psp_doc/chap26.html
    static struct = StructClass.create<ElfPspModuleInfo>(ElfPspModuleInfo, [
        { moduleAtributes: UInt16 },
        { moduleVersion: UInt16 },
        { name: Stringz(28) },
        { gp: UInt32 },
        { exportsStart: UInt32 },
        { exportsEnd: UInt32 },
        { importsStart: UInt32 },
        { importsEnd: UInt32 },

var item:ElfPspModuleInfo = ElfPspModuleInfo.struct.reed(stream);
var item:ElfPspModuleInfo = ElfPspModuleInfo.struct.write(stream, item);

The performance is mainly determined by function lookup and performing arithmetic ops with Int32Array: http://jsperf.com/loop-with-array-as-variables/3 Maybe in the future javascript implementations will be able to convert typed arrays access into local variables/registers and store them when exiting functions, analyzing the origin ArrayBuffer of all the typed arrays used.

You can test real psp performance with your favourite browser/platform with this demo: