AppStars

Mobstar Games, 2004 and 2025

AstralX: a 2004 phone game, ported to WebAssembly in 2025.

AstralX was the first Mobstar Games title, a shooter for Java ME phones. In 2025 we ported it by hand to a small C# engine on .NET 9 Blazor WebAssembly, so it runs in a browser tab at its original 176×208 screen size. The runtime changed completely. The game logic barely changed.

Owner
Mobstar Games, our own title
Industry
Games
Services
Legacy modernisation, web platforms
Platforms
Java ME in 2004; C#, .NET 9, Blazor WebAssembly and an HTML canvas in 2025
Our role
We wrote the original game, then ported it by hand with our own engine and asset converter.

The challenge

The first AstralX source files carry a November 2003 header and a note that they were created in Nokia's developer suite for J2ME. The game shipped in 2004 as the first Mobstar Games title: a Galaga-style shooter for Java ME phones, with 40 levels and boss fights, published by Telcogames in MIDP1 and MIDP2 builds. The phones it ran on are long gone.

The 2004 game was written for tiny heaps, slow processors and no floating-point unit worth relying on. It used integer maths, lookup tables for trigonometry, fixed-point numbers for movement and the MIDP canvas for drawing. The 2025 target was the opposite: a garbage-collected .NET runtime compiled to WebAssembly, a JavaScript event loop and an HTML canvas. Different language, memory model, timing and input.

Most organisations have a system like AstralX somewhere: logic that still works and is still valued, sitting on a platform that has gone away. The port was that problem in miniature.

Our approach

Not an emulator running the old binary, but a fresh, small engine, with every class ported by hand from its Java original. We set three rules:

  • Keep the behaviour. Enemies fly the same curves, attack in the same patterns and feel the same to play.
  • Keep the resolution. 176×208, scaled up with whole pixels, not redrawn for a modern screen.
  • Replace the runtime cleanly. No compatibility layer pretending to be a phone. A modern engine underneath.

What we built

JavaScript owns the clock, C# owns the game

A JavaScript module of under 200 lines runs requestAnimationFrame, tracks keys and the mouse, and calls an exported .NET RenderLoop once per frame with the elapsed time. In C#, a Sprite base class holds position, velocity, bounding box, frames and layer; a SpriteManager handles ordered drawing and collision queries; and a LevelManager of almost 900 lines runs the waves, bosses and level flow.

Software rendering into one native buffer

The engine allocates one frame buffer outside the managed heap with NativeMemory.AllocZeroed, clears it each frame, and draws every sprite into it with unsafe pointer code that skips transparent pixels. That's almost exactly how the original drew on a phone. A small software renderer is predictable: no driver, no GPU state, and the same output in every browser. One rough edge we know about: the render loop still allocates a new byte array each frame. At 176×208 it costs very little, but it's the first thing we'd change.

A port you can trace line by line

EnemyDroid.cs sits beside EnemyDroid.java, with the same state constants, the same method names and even the original "TODO" notes. What changed is the number representation: the Java tracked a loop angle as a fixed-point integer shifted down to index a sine table, and the C# uses float radians and the browser's elapsed time. Magic numbers like SetState(6) became named states. Keeping the shape makes the port slower to modernise, but every behaviour can be checked against the original by reading two files side by side.

Enemy AI that survived the port

Each enemy is an explicit finite-state machine: entry, loop left, loop right, retreat, spot-sit and attack left or right, with difficulty settings shaping the attack curves. An enemy in spot-sit waits, in the original comment's words, "for a command to attack". The level manager decides who attacks and when, so individual enemies stay simple and the wave behaves as a group. Four bosses, Ball, Blue, Morpher and Snake, came across too.

Assets compiled into the build

We wrote a small converter that reads each PNG with ImageSharp and writes a C# struct holding its pixels. The result is about 4,700 lines of generated pixel data beside about 2,300 lines of hand-written engine and gameplay code. There's no image loading at run time and nothing to go missing on a slow connection. A Dockerfile and compose file publish the release build and serve it.

Architecture

  1. requestAnimationFrameJavaScript keeps time and reads input
  2. RenderLoopExported from C#, called once per frame
  3. LevelManagerWaves, bosses and enemy state machines
  4. Software blitEvery sprite drawn into one native frame buffer
  5. CanvasThe finished frame, scaled with whole pixels

The canvas only ever receives a finished frame.

Results

Under the hood

A new runtime under twenty-year-old game logic.

What we’d do now

Parity first, then improvement. With parity in hand, this is the next list.

  • Remove the per-frame allocation. Keep one reusable output buffer and write opaque pixels in the first place, so the garbage collector has nothing to do during play.
  • Prove parity with recorded replays. Record input sequences, play them through the original and the port, and compare the game state frame by frame. Reading two files side by side works for one developer; replays let anyone check.
  • Use a fixed time step. Driving the game from the browser's variable frame time makes runs differ slightly between machines. A fixed simulation step with interpolated drawing makes every replay identical and every bug reproducible.
  • Trim the download. Ahead-of-time compilation and trimming shrink what a WebAssembly app sends on first load, which matters more than frame rate for a game this small.

The same list applies to business systems. Capture the old system's behaviour as tests before you touch it, keep a fixed reference to compare against, and modernise one part at a time while the rest keeps running.

What it taught us

Separate what a system does from what it runs on. AstralX's rules and state machines were worth keeping; its MIDP runtime wasn't. Keep the port traceable, prove parity, then modernise, and write the small tools that move work from run time to build time. We did the same with Magic Clouds, our other 2004 phone game, rebuilt in Unity in 2023 with the original Java kept alongside as a reference.

That's how we approach legacy modernisation at any size, whether it's an old desktop app, a retired mobile framework or a server nobody wants to patch, and how we move it to a modern web platform. The state-machine habit carried forward too: the Knowby platform's video-to-guide pipeline runs an explicit ladder of strategies rather than one opaque model. The rest of the 2004 catalogue is in the Mobstar Games story.

Questions

Is AstralX running in an emulator?

No. It’s a fresh C# engine on .NET 9, compiled to WebAssembly. Each class was ported by hand from its 2004 Java original.

Why keep the original resolution?

To keep the game as it played. The 176×208 frame is drawn in software and scaled up with whole pixels, so it looks the same in every browser.

What does a game port teach about legacy systems?

Separate the logic from the platform. Keep the behaviour, keep it traceable to the original, prove parity, then modernise.

Can you move our legacy application to the web?

Yes. Moving sound logic off an ending platform, with parity you can check, is the core of our integrations and legacy work.

Related

The services behind this work, and more stories like it.

Services

Case studies

Bring us the hard problem.

A 45-minute discovery call with the engineer who'll build it.