Spectrum to MSX BASIC Conversion

Anything relating to non Sinclair computers from the 1980's, 90's or even before.
User avatar
PeterJ
Site Admin
Posts: 2999
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Spectrum to MSX BASIC Conversion

Post by PeterJ »

Having recently repaired my Sony HitBit HB-75B I thought I would look at the BASIC. Whilst I love the Spectrum, I have over the last 6 months explored other 8 bit systems to look at their advantages and disadvantages.

This may be the first of a series, or the first and last depending on if there is any interest. The MSX1 series use a Z80A just like the Spectrum. The resolution is the same as well, being 256x192. The MSX uses the Texas Instruments TMS9918 which has 16K of VRAM for the graphics functions.

You can emulate the MSX with either openMSX or BlueMSX. Whilst BlueMSX is quite old, its easier to get started with as you don't need to worry about finding the ROMS. If you want a web based solution then give webMSX a ago.

For my experiments I'm going to be using Screen 1 which is a character mode, which is again the same as the Spectrum with 32 columns and 24 rows.

Colours are again very similar to the Spectrum with a total of 16 (with main colours and a bright version). The format for the colour instruction is color foreground, background, border where each of these numbers is between 0 and 15.

The colours are as follows:
0 - Transparent
1 - Black
2 - Medium Green
3 - Light Green
4 - Dark Blue
5 - Light Blue
6 - Dark Red
7 - Sky Blue
8 - Medium Red
9 - Light Red
10 - Dark Yellow
11 - Light Yellow
12 - Dark Green
13 - Magenta
14 - Grey
15 - White

The locate command is very similar to print at apart from it uses the normal X,Y notation (columns, then rows).

So, to make me feel at home we can start with this:

Image

Which gives you this:

Image

The only issue, is that there is no Copyright symbol in the character set, so next time (if there is any interest), I will cover the creation of UDGs.
3 x
Rate your favourite games with Spectrum Computing

All Ratings (With Filters)
Top 100 Titles (5+ Votes)
Bottom 100 Titles (5+ Votes)

Click here for the Spectrum Emulator Features Spreadsheet - Feel free to request edit rights to contribute

User avatar
+3code
Manic Miner
Posts: 278
Joined: Fri Dec 06, 2019 11:43 pm
Location: Valencia, Spain

Re: Spectrum to MSX BASIC Conversion

Post by +3code »

A week ago I was with BlueMSX, looking old jrpg ported from nes to msx. It's a interesting system.
1 x

User avatar
Turrican
Microbot
Posts: 135
Joined: Thu Apr 12, 2018 5:48 pm
Location: Brazil

Re: Spectrum to MSX BASIC Conversion

Post by Turrican »

I didn't know that MSX has UDG...
0 x

User avatar
+3code
Manic Miner
Posts: 278
Joined: Fri Dec 06, 2019 11:43 pm
Location: Valencia, Spain

Re: Spectrum to MSX BASIC Conversion

Post by +3code »

I think in this context UDG=8x8 Sprite (character).
https://www.msx.org/wiki/SPRITE$()
1 x

User avatar
PeterJ
Site Admin
Posts: 2999
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Spectrum to MSX BASIC Conversion

Post by PeterJ »

Turrican wrote:
Sun Oct 04, 2020 7:07 pm
I didn't know that MSX has UDG...
I always thought it didn't too, but found out this week that it does. It's not sprites. Next episode soon.
1 x
Rate your favourite games with Spectrum Computing

All Ratings (With Filters)
Top 100 Titles (5+ Votes)
Bottom 100 Titles (5+ Votes)

Click here for the Spectrum Emulator Features Spreadsheet - Feel free to request edit rights to contribute

User avatar
PeterJ
Site Admin
Posts: 2999
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Spectrum to MSX BASIC Conversion

Post by PeterJ »

OK, I'm far from an expert but in the MSX VRAM you have 3 tables: Name Table, Pattern Table and the Colour Table.

You can redefine the whole character set. The pattern table start at address 0000. The Pattern Table contains a library of user defined patterns that can be displayed in any of the 788 screen positions. It is 2048 bytes long and is arranged as 256 eight byte patterns. Each one of these eight byte patterns defines an 8x8 pixel area.

There is a function called 'BASE' which holds the address of the VDP Tables. For screen 1 base (7) holds the address of the pattern table.

In the example above I'm setting F to 1152 which is 1152/8 which is 144 (So character 144).

Just note that we use vpoke rather than poke because we are accessing video RAM.


Image


Image

More next time, when we will look at colours.
2 x
Rate your favourite games with Spectrum Computing

All Ratings (With Filters)
Top 100 Titles (5+ Votes)
Bottom 100 Titles (5+ Votes)

Click here for the Spectrum Emulator Features Spreadsheet - Feel free to request edit rights to contribute

User avatar
PeterJ
Site Admin
Posts: 2999
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Spectrum to MSX BASIC Conversion

Post by PeterJ »

This evening, I'm covering colour. Like the ZX Spectrum the MSX Machines when using Screen 1, have one background and one foreground colour per 8x8 cell.

The way colour works is very different to the Spectrum though. The colour table is just 32 bytes long, and each byte is split into 2 nibbles (First nibble is ink, second is paper). Each of the 32 bytes sets the colour for 8 of the 256 characters in the character set. This is shown in detail below:

Image

The 32 bytes go from 8192 to 8223. I'm going to be printing character number 215, so I need to set the 26th byte (starting with 0) in the 8192 to 8223 sequence, which is 8218.

I'm after a light blue background which is colour 5, with light red ink which is colour 9 (Looking at the tables from yesterday). There we have 95 in Hex, which is 149 in decimal

So, here goes:

Image

Which gives us this:

Image

The next post will be about vpeeking the screen to get an equivalent of screen$
2 x
Rate your favourite games with Spectrum Computing

All Ratings (With Filters)
Top 100 Titles (5+ Votes)
Bottom 100 Titles (5+ Votes)

Click here for the Spectrum Emulator Features Spreadsheet - Feel free to request edit rights to contribute

User avatar
Turrican
Microbot
Posts: 135
Joined: Thu Apr 12, 2018 5:48 pm
Location: Brazil

Re: Spectrum to MSX BASIC Conversion

Post by Turrican »

Hmmmmm... I really don't like MSX Basic.
How can you get same result on Spectrum Basic?
0 x

User avatar
PeterJ
Site Admin
Posts: 2999
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Spectrum to MSX BASIC Conversion

Post by PeterJ »

Here you go @Turrican:

Image
1 x
Rate your favourite games with Spectrum Computing

All Ratings (With Filters)
Top 100 Titles (5+ Votes)
Bottom 100 Titles (5+ Votes)

Click here for the Spectrum Emulator Features Spreadsheet - Feel free to request edit rights to contribute

catmeows
Microbot
Posts: 199
Joined: Tue May 28, 2019 12:02 pm

Re: Spectrum to MSX BASIC Conversion

Post by catmeows »

Hi Peter. I'm really interested, please continue.
1 x
Proud owner of Didaktik M

Post Reply