Melkhior’s Mansion – Project Update #10

Welcome to project update #10 for the conversion of Melkhior’s Mansion Spectrum Next!

It’s been a crazy week! The game is starting to take shape, the main character can now run around and explore the game world!

In the last update, I mentioned the collision data and adding the player sprite as well as the 3D isometric engine. I decided that it would be a good idea to turn my attention to the main character and press ahead with navigation of the rooms and game world now that I had collision data. I rescheduled the 3D isometric engine development to the following Monday.

The first half of the week was spent coding various routines to act on the collision data. I created several resources to gather data allowing the code to interact with the game world. The methods involved would require ‘code talk’ technical explanations so I have spared you the pain by not providing those this week!

I started development of the main character movement on Thursday. This involved adding the walk animation, inertia and the slide around obstacles bringing Sir Stamperlot to life!

I spent some time studying the original PC version. I spoke with the developer to discuss the physics and logic to make sure I was implementing their game mechanics correctly.

There were math problems to solve as the 8 bit Z80 cannot use the floating point calculations that the C# Monogame based PC version implements. The subject of normalizing a vector was brought up which requires a square root calculation. This was not ideal for the Spectrum Next’s 8 bit Z80 CPU so time was spent finding an alternate solution. The movement algorithms took a couple of days to develop and I still feel that some refinement is necessary.

Saturday was a game changer lol This was a great moment for me as I implemented the room linking system to allow Sir Stamperlot to walk through a door into a new location. At last!! I could run around the game world.

There are several coloured doors which require a key to pass through them. I have not added the object system so I have limited access to the Mansion which I found rather amusing although I can press a shortcut key to room skip.

There were various problems to solve with the room linking as the location of a door in each room is specified in a high level format. This is expected as the original version is programmed in C#. I had to resolve each door position by looking up the room’s floor size and calculating the position from a set of compass codes.

For example, the largest room is made up from a 3×3 grid of 24×24 pixel floor tiles – row and columns are used, numbered 0,1,2. A door in the centre of the north east wall has a code of NE1_0 as it relates to row 1.0 of the floor tiles. I have to calculate the position of the door in 2D space by multiplying the floor tile size of 24 by the row and column, thus it would be 72,24 pixels from the origin of 0,0 (bottom right).

Each door has a destination room number so I have to lookup the wall of the door in the new room location that points to the current room. So room 006, door NE1_0 may point to room 007 so I lookup the door in room 007 that links to room 006, find the wall which would be opposite of north east, south west in most cases, resolve the 2D location in pixels and place the player in the centre of the doorway. Lots of fun!

There are a maximum of six exits and one trapdoor in each room. Here are the Z80/x86 room data structures described above:

room_006

db LEVEL_GROUND
db FLOOR3X3HEX

db DOOR_SE1_0,0
dw 005

db DOOR_NE1_0,0
dw 007

db DOOR_SW1_0,GATE_CYAN
dw 010

db DOOR_NONE,0
dw 000

db DOOR_NONE,0
dw 000

db DOOR_NONE,0
dw 000

db TRAPDOOR_1
dw 073

; ————

room_007

db LEVEL_GROUND
db FLOOR2X3

db DOOR_NE0_5,0
dw 008

db DOOR_SW0_5,0
dw 006

db DOOR_NW1_0,0
dw 017

db DOOR_NONE,0
dw 000

db DOOR_NONE,0
dw 000

db DOOR_NONE,0
dw 000

db 0
dw 000

Here is the original XML data: