Melkhior’s Mansion – Project Update #4

Project update four has arrived which means I am one month into the conversion of Melkhior’s Mansion Spectrum Next!

The previous two updates have been centred around the SD card system which plays an important role in Next games just as the cassette tape was the backbone of loading original ZX Spectrum data. The visual side of the project is moving forward again now that the low level foundations are complete.

Too much to read… skip to the end for a quick summary.

Day #20, Monday 11th March 2019 saw completion of the sprite module of my Spectrum Next PC emulator allowing me to continue work on the rooms moving the project forward.

Here is a brief refresher on my emulator… I decided at the beginning of the conversion to create a Windows based Spectrum Next emulator specifically for this project.

WARNING – MACHINE CODE TALK!!! Intel x86 and Zilog Z80 share some common features as they evolved from the 8080. The AX CPU register on the x86 is 16 bits and splits into two 8 bit registers; AL, AH which maps to HL, L, H on the Z80. The Intel CPU instruction MOV AX,16384 translates to LD HL,16384 on the Zilog Z80 and so on for several instructions. It made sense to convert, test and process the complex and constantly evolving original game data with the same CPU to make sure the conversion process was error free. I also find that x86 has a quicker development cycle compared to Z80.

I emulated the Spectrum Next hardware needed to run Melkhior’s Mansion, wiring it up to an Intel CPU. I find the concept of a 2.8Ghz x86 based Next with 768K of RAM rather amusing!!! I did upgrade the sprite display engine to render 4096 16×16 sprites but that was just silly and pointless so I keep to the Next’s hardware specification.

My emulator allows me to prototype the main logic of the game in simple 16 bit Intel x86 assembler with the intention that most of this code will be ported to Z80 once it is refined. It is not an easy task to implement the full isometric engine used in the original C# Monogame version on the Next. I am able to use the power of the x86 to profile various algorithms before committing them to development time consuming optimised Z80. The data conversion routines are coded in full 32 bit monster x86 as this code doesn’t execute on the Next.

I am also able to share one set of source code data include files as NXASM, my own Z80N assembler is based on NASM syntax, the x86 assembler used to create the Microsoft Windows code.

Overall, the benefit is a single integrated application to process and work with the complex game data in a virtual Spectrum Next Windows based environment – viewing and rapidly tweaking results in an instant. Changes can be made on the fly during emulation. Game editing and data debugging tools are also built into the emulator as and when they are needed.

Day #21, Tuesday 12th March 2019. It was now time to write the code that would parse the XML based game data from the original C# Monogame version. It was not going to be practical to work with the XML on the Next so it would have to be converted into a smaller, simpler token based data set.

Here is the original XML map data for room 001:

Theme=”Red” Description=”Ground Floor”>