Thomas Fach-Pedersen

@madmoose
208 Followers
238 Following
533 Posts
Blade Runner. ScummVM dev. Possibly a replicant.
Websitehttps://thomas.fach-pedersen.net

The Dune map renderer is complete!

You can navigate around the map here: https://thomas.fach-pedersen.net/dune/map/

Click the arrow icons or use the arrow keys on your keyboard.

If you want the globe view, you'll have to navigate to https://thomas.fach-pedersen.net/dune/globe/, I haven't put them into one app yet :)

#ReverseEngineering #Dune #CryoInteractive

I think the map renderer might be complete!

I still want to do a complete verification against the original.

So now we have both a globe renderer and a zoomed map renderer for Dune, time to integrate them in a wasm app and try to draw the sietches and palaces in their proper places!

#ReverseEngineering #Dune #CryoInteractive

And if you've ever wanted to see the writes that the original Dune engine does to its internal buffer when drawing a map view, well, do I have a 79003 frame video for you!

#ReverseEngineering #Dune #CryoInteractive

Here's a video of the internal scaling process, you might want to open this on a big screen.

#ReverseEngineering #Dune #CryoInteractive

Before finishing it, I decided I needed to extract the end result from the original engine.

I hacked my emulator to loop over the part of the engine that generates a 4 pixel high band of map output 186 times and write the result to an image.

Here’s all 186 bands that the engine would show at longitude 0 stacked on top of each other.

If you look closely you might event spot a couple of bugs in the original engine ;-)

#ReverseEngineering #Dune #CryoInteractive

I’m almost done implementing the last major graphics algorithm in Cryo's Dune, the zoomed in map view.

The map generated as a 4 by 4 scaling of the map resource. Basically, two sequential bands of latitude are scaled horizontally in an internal buffer with three blank lines between them, and then the engine interpolates vertically between them. But add rotation and error correction on top of that :)

Here's the map resource unpacked.

#ReverseEngineering #Dune #CryoInteractive

My reverse engineered implementation of Dune's particle system now matches the original perfectly, at least for the cases encounted in the intro :)

(Original on the left, mine on the right)

To compare frame by frame, I had to limit the randomness in between the frames when it’s running in my emulator.

The code is available here, but it's still messy: https://github.com/madmoose/dune-rust/blob/main/crates/dune/src/attack/mod.rs

And a WASM version for your enjoyment: https://thomas.fach-pedersen.net/dune/attack/

#ReverseEngineering #Dune #CryoInteractive

All the particles finally appear to go the right places, only the palette transitions are missing.

(The original is on the left, my reimplementation is on the right.)

The code contain wonderful little bit-shuffling snippets like this to calculate particle positions, which'll never really be "Clean Code" :)

```asm
seg000:0B9A xchg dl, dh
seg000:0B9C rol dh, 1
seg000:0B9E and dx, 1FFh
seg000:0BA2 cmp dx, 320
```

#ReverseEngineering #Dune #CryoInteractive

I hope that whoever at Google decided on these values is suitably embarrassed.

For the night attack scene in the game intro, Dune uses a particle system with very gnarly assembly code in it.

They freely treat registers as either 16-bit values or a pair of 8-bit values, first treating the 8-bit parts as signed values, then rotating and shifting bits in the whole 16-bit register. I haven't worked out the meaning of it yet, but I've mostly replicated it, at least.

Here's a video of my in-progress Rust replica, until it crashes :-)

#ReverseEngineering #Dune #CryoInteractive