Close

Patching Muhonmourn 3 (2)

danjovicdanjovic wrote 11/15/2022 at 03:12 • 5 min read • Like

Making a Cartridge version of the game

I have created a ROM version of Muhonmourn3. It was necessary to move the game to RAM because the game uses contiguous areas to store data (and some areas beyond 0xd400 too).

Additionally, it was required another routine to switch back page 1 from the Game ROM slot to the same slot of the BIOS, otherwise the game ran erratically (slowed down and missing time counter and player counters).

The ROM -> RAM loader is very primitive but it seems to be working fine in many emulated machines.

The loader executes the following steps:

  1. Check if the computer has enough RAM to load the game
  2. Load a Splash Screen (or a NO RAM screen advice)
  3. Copy patch code (from page 1) to RAM segment E000-E1F0
  4. Copy game code (from page 1) to RAM segment c000-d400
  5. Copy game code (from page 2) to RAM segment 8000-bfff using RDSLT
  6. copy page switch code (from page 1) to RAM segment E1F0
  7. switch page 1 to the same slot that is BIOS ROM
  8. Jump to game start at RAM 0x915f

The patch was modified to change the text on the screen accordingly with the Ninja Tap presence:

The whole repository can be found at my github page, and here's the link for downloading the ROM image.

Splash Screen

The ROM loader adds about 2 seconds to the startup of the machine running the game, then a Splash screen was added to divert the attention and reduce the perception of the loading time.

The Splash screen uses Screen 3 multi-color mode, with a resolution of 64 x 48 pixels. The image was edited using mspaint and the space color was reduced to 16 colors indexed mode (bitmap) using irfanview, then a python script to convert the pixel information into data to be included on the loader code. 

The screen 3 mode uses 1 byte to represent the color of two pixels (each nibble is a pixel color). The whole screen takes 1536 bytes which is the half of 64 x 48 -> 3072 pixels available.

The pixel addressing is not linear but with a bit of observation it is possible to assign the values of the coordinates X and Y to certain bits on a linear addressing word:

def getCoords ( linearCount ):
    # bit order   Y5 Y4 Y3 X5 - X4 X3 X2 X1 .Y2 Y1 Y0 X0
    #        x    0  0  0  1    1  1  1  1   0  0  0  1
    #        y    1  1  1  0    0  0  0  0   1  1  1  0
    cx = ( (linearCount & 0x1f0)  >> 3) + (  linearCount & 0x01 )
    cy = ( (linearCount & 0xe00) >> 6) + ( (linearCount & 0x0e) >> 1)
    return cx,cy


The color translation was done kinda manually, assigning the the indexes informed by clicking on the image opened on Irfanview  to the desired MSX color.

def translateColor (inputColor):
    #msxCores = [ 1, 3, 7, 9, 11, 14, 15]
    msxCores = [ 1, 3, 7, 15, 6, 14, 9]
    if inputColor <= len(msxCores):
        return msxCores [ inputColor ]
    else:
        return 1

 The main function iterates over all 3072 pixels, combining every 2 of them and generating the contents for a include file, skipping a line every 32 pixels (16 bytes).

for i in range (0,1536*2,2):
    x,y = getCoords (i)
    pp = translateColor ( pixels [x,y] )  # get MSB color
    x,y = getCoords (i+1)
    ss = translateColor ( pixels [x,y] )  # get LSB color
    bb = (pp<<4 | ss ) & 0xff

    if (i % 32 == 0 ):
        outputBuffer = outputBuffer + "\n db "
    else:
        outputBuffer = outputBuffer + ', '
    outputBuffer = outputBuffer + intToHexValue2digits (bb, '$')

print (outputBuffer)

 At the end the result is printed on the terminal and can be copied and pasted on a text editor.

It is a very crude script but it was enough for me. It is impressive what we can do with 40 lines of python ( nevermind the blank lines and comments)

Screenshots

The splash screen depends upon the slot where the ROM is inserted is even or odd. Both were inspired in Rock Bands.

Even Slots: Queen
Odd Slots: Information Society

As it was mentioned before, the game needs at least 32K of RAM to be copied to memory. On some machines without RAM expansion the No RAM splash screen is shown

Advert for machines with less than 32K of RAM

Worth to mention that after the splash screen was added it was necessary to add 3 more seconds of delay otherwise it could be barely seen.

Like

Discussions