Why the Playstation?
Hardware and Memory
JSX has been written with some modularity in mind. Global variables are avoided
like plague and disparate components are connected through the
Memory class implements the memory map, and special devices can
wire themselves through the
The CPU core dynamically translates MIPS R3000a machine code into JS, leveraging most modern engines' ability to compile JS into native code. While most of the core instruction set has been implemented, instructions from the Geometry Transformation Engine are notably missing.
The MIPS R3000a has two instruction families to modify the execution flow:
branches (opcodes starting in b) and jumps (opcodes starting in j).
Branches are possibly-conditional, small jumps that are performed inside the
same subroutine. Jumps will usually go to a far place, start a new subroutine
jal, jump-and-link), or go to a variable location. The two are handled
differently by the code generator.
goto statements, labels for branches are
implemented using a
switch statement inside a loop. Each time a branch is
pc variable is modified and execution is returned at the beginning
of the loop. The
switch then targets a different location based on said
Jumps, on the other hand, cause the generated function to return the next execution address. This gracefully handles indirect jumps, since we cannot determine their address at recompile-time. We simply have to return the value of a register.
Since the PSX has only 2 MB or RAM, games will often swap in and out executable
code. Because of that constraint, a
FunctionCache class connected to the code
generator and to the
Memory class keeps track of the generated functions, and
when a memory write is performed, it will invalidate all functions in the 256
bytes range it belongs to.
To run JSX, you will need to obtain a Playstation BIOS first. As this file is copyrighted by Sony, its distribution is illegal and you will need to dump your Playstation to obtain it.
Currently, JSX is able to execute some of the BIOS code and gets stuck when it would need the GPU to actually do something.