Lorminator Dash (Lessphun)

From SpelWiki

Contents

Postmortem for Lorminator Dash for Lessphun

Game: Lorminator Dash
Programmer: Simon Kågström
Graphics: Simon Kågström
Platform: Cibyl, J2ME
Software: Debian GNU/Linux, GCC, Cibyl
Implementation time: 2004, 2006, two weekends
System: J2ME MIDP2-capable phone
Lessphun version of Lorminator Dash. Note the larger tiles/sprites compared to the Mophun version.
Enlarge
Lessphun version of Lorminator Dash. Note the larger tiles/sprites compared to the Mophun version.
Mophun version of the same game, for comparison
Enlarge
Mophun version of the same game, for comparison

Lorminator Dash for Lessphun is a direct port of the same game for Mophun, which is described in Swedish on the Lorminator dash page. It is primarily meant as a proof-of-concept port of a game to the Lessphun environment, which is a compatibility library to facilitate porting of games from Mophun to Cibyl.

I've been fond of Boulder Dash-style games for a long time, and sometime 1994-1996 I wrote a simple clone of Boulder Dash for MS-DOS (listed at bd-fans.com). My version for Mophun was rewritten and much better implemented, but since Mophun has a very much non-free runtime environment, it cannot be distributed freely. I therefore wanted to port it to the slightly more free J2ME environment, which is part of the reason why I wrote Cibyl and Lessphun.

The game itself is simple but has some features lacking in the original Boulder Dash:

  • Moomins patrolling the caves
  • Teleporters
  • Bombs to blow up weak walls and wooden doors. Bombs are found in boxes and are limited in number
  • Keys for doors, three types
  • Levers for special features
  • A lamp so that only part of the field is visible at a given time
  • Conveyor belts to transport boulders on

Differences to the Mophun implementation

  • The tiles and sprites are 16x16 instead of 8x8 in Mophun. I am a lousy artist, so I have simply scaled the images by two, but someone with a bit of talent could probably make the graphics nicer.
  • The level data is stored in little-endian format and has to be byte swapped to work in Cibyl (Java uses big endian).
  • Some initialization code had to be rewritten since it used non-standard GCC extensions which changed in the newer version (c/include/specials.h).

Things that went good

  • The game works and runs fine, everything that was in the Mophun version is also in the Lessphun version
  • Performance is as least as good as under Mophun (only tested in the emulator). Cibyl works best with the 32-bit int type, but I have not changed the original data structures since the performance is good enough anyway.
  • Small changes to the actual game code, although large parts of the Lessphun library had to be implemented.

Things that went bad

  • Some minor glitches are still present, but nothing that really affects gameplay (from what I've found!)
  • A few bugs in Cibyl and a few broken implementations in Lessphun was triggered. This is really a good thing! The most interesting of these was sllv:
sllv is a special case instruction on MIPS and looks like a Rfmt instruction but behaves differently. The parameters are in a different order compared to Rfmt instructions:
addu rd, rs, rt        #  rd = rs + rt
sllv rd, rt, rs        #  rd = rt << rs
  • The newer version of GCC broke some of my non-conforming code. Serves me right.

Bits and pieces from the code

The implementation of sllv and friends in Cibyl

class ShiftInstructionsV(Rfmt):
    """sllv, srlv and friends"""
    def compile(self):
	self.pushRegister( self.rt ) # The order is opposite here!
	self.pushRegister( self.rs )
	self.emit( insnToJavaInstruction[self.opCode][1] )
	self.popToRegister( self.rd )
...
  mips.OP_SRAV : (ShiftInstructionsV, "ishr", ">>"),
  mips.OP_SLLV : (ShiftInstructionsV, "ishl", "<<"),
  mips.OP_SRLV : (ShiftInstructionsV, "iushr", ">>>"), 

Download

Lorminator Dash for Lessphun is released under the GNU GPL and is part of the Lessphun distribution. You can also download it directly via subversion on:

https://mondragon.tek.bth.se/svn/main/world/ska/lessphun/trunk/examples/lorminator_dash

A binary for your phone can also be downloaded: lorminator-dash.jar