Pstros NDS - MIDP for the Nintendo DS

Pstros NDS is a MIDP implementation running on the CLDC java machine compiled for the Nintendo DS. It allows you to run some java programs and games written for the mobile phones on your NDS.

To achieve this goal one needs a java machine for processing the bytecode and a program library that implements the MIDP api. In this case the Sun's KVM java machine was used (thanks to Torlus and davr for porting it for the NDS and providing the source) and an altered version of the Pstros was used as the MIDP library. Both parts were built into the single binary to simplify the execution of the java code on the NDS.

How to run...

The program is a homebrewed application so you have to have one of the cards that allows you to run a custom software on the NDS. Just copy the content of the archive to the card and run the kvm.nds file (dont forget to patch the program if your card requires it). Then select a .class or .jad file and run it by pressing the (A) button. Hopefully the java program will run.

Key mapping:

Left Soft key - left pad
Right Soft key - right pad
Cursor keys - d-pad
Fire - (B) button
key [1] - (Y) button
key [3] - (A) button
key [0] - (X) button
key [#] - (Start) button
key [*] - (Select) button

Technical stuff

The MIDP screen size is set to 176x192 resolution to get the best compatibility and visual output. I've tried the HW scaled resolution of 176x208 but it was visually inacceptable (the NDS roto scaller simply discards some lines instead of making the pixel interpolation).

The heap memory of the JVM is set to 2 Mbytes to leave a reserve for the library growth (libraries are bundled in the kvm binary) and for the needs of the native methods (and for the memory leeks I made :-) and jar loader.

Key codes are set to the standard of Nokia and SonyEricsson phones.

The overall speed of the JVM is rather slow, although still usable. According the JBenchmark2 test it ranges around the speed of the Nokia 6600 phone (some operations are slightly slower some of them are faster). It might be interesting to compare the performance with the PhoneMe JVM as it should be technically more advanced than the KVM.

Note that class files must be preverified before it can be run on the KVM. Use the preverifier supplied by the J2ME WTK.

Latest version 0.7.2

Download the latest NDS binary

2008.07.06: version 0.7.2 - R6 build

New configuration options can be stored in the jad file (case senitive !)
Note: none of the parameters is manadatory. If you don't specify any of the
parameter then the default values are used.

NDS-resolution: WWWxHHH
- sets the dimensions of the screen to width WWW and height HHH.
Maximal resolution is 256x256. Example:
NDS-resolution: 176x208

NDS-screen-X: XXX
- sets the screen X position (negative values are valid). By default the X position
of the screen is set to center the image. Example:
NDS-screen-X: 0

NDS-screen-Y: YYY
- sets the screen Y position (negative values are valid). By default the Y position
of the screen is set to center the image. Example:
NDS-screen-Y: -12

NDS-key-[button]: [key]
- remaps the NDS button [button] to the phone key [key]
valid [button] values: A,B,X,Y,L,R,Start,Select,Left,Right,Up,Down
valid [key] values: keyNum0, keyNum1,..., keyNum9, keySoftLeft, keySoftRight,
keyFire, keyLeft, keyRight, keyUp, keyDown, keyStar, keyCross
NDS-key-A: keyNum5
this line will remap NDS button A to press of the nuber [5] on the phone

NDS-key-Start: keySoftLeft
this line will remap NDS button Start to press of the Left soft key of the phone

2008.06.24: version 0.7.1 - R5 build

- added HttpConnection class to satisfy dependencies of some applications
- implemented drawing of the ellipses (note: draw/fillArc is not fully functional yet)

2008.06.20: version 0.7.0 - R4 build

- Nokia UI api partially implemented: drawPixels and getPixels implemented for the 4444,444,8888 and 888 pixel formats with the full manipulation support (mirroring and rotation).
- bug fixes (JBenchamrkPro works now)

2008.05.31: version 0.6.0 - initial R3 build

- fixed the CLDC implementation (timer, memory size, system properties)
- added support for reading of the PNG images (code taken from the PhoneMe project)
- implemented native functions for rendering the basic graphics primitives on the screen (lines, rectangles, triangles, images)
- added support for accepting the JAD files in the application browser
- ported the core part of the Pstros MIDP library to use CLDC java machine instead of the fully featured j2se java machine.


Several people and their resources contributed directly or indirectly to the project. Here is the list:

- The CLDC reference implementation source code from Sun.
- Torlus and davr ported the CLDC to GBA and NDS.
- Ole added the MIDP support .
- The DevkitPro compiler and libraries (excelent tools, I was really surprised that everything was set up correctly right from the start and worked like a charm!).
- DeSmuME NDS emulator, 90% of the development and code testing was inspected in this great emulator.
- NDS development tutorial web pages - invaluable source of information.