Spectrum to MSX BASIC Conversion
Spectrum to MSX BASIC Conversion
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:
Which gives you this:
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.
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:
Which gives you this:
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.
Re: Spectrum to MSX BASIC Conversion
A week ago I was with BlueMSX, looking old jrpg ported from nes to msx. It's a interesting system.
Re: Spectrum to MSX BASIC Conversion
I didn't know that MSX has UDG...
Creator of ZX App: https://play.google.com/store/apps/deta ... boys.zxapp
Re: Spectrum to MSX BASIC Conversion
I think in this context UDG=8x8 Sprite (character).
https://www.msx.org/wiki/SPRITE$()
https://www.msx.org/wiki/SPRITE$()
Re: Spectrum to MSX BASIC Conversion
I always thought it didn't too, but found out this week that it does. It's not sprites. Next episode soon.
Re: Spectrum to MSX BASIC Conversion
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.
More next time, when we will look at colours.
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.
More next time, when we will look at colours.
Re: Spectrum to MSX BASIC Conversion
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:
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:
Which gives us this:
The next post will be about vpeeking the screen to get an equivalent of screen$
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:
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:
Which gives us this:
The next post will be about vpeeking the screen to get an equivalent of screen$
Re: Spectrum to MSX BASIC Conversion
Hmmmmm... I really don't like MSX Basic.
How can you get same result on Spectrum Basic?
How can you get same result on Spectrum Basic?
Creator of ZX App: https://play.google.com/store/apps/deta ... boys.zxapp
Re: Spectrum to MSX BASIC Conversion
Here you go [mention]Turrican[/mention]:
Re: Spectrum to MSX BASIC Conversion
Hi Peter. I'm really interested, please continue.
Proud owner of Didaktik M
Re: Spectrum to MSX BASIC Conversion
Thanks [mention]catmeows[/mention],
This is a table I produced in Google Sheets which holds the addresses for each of the characters in VRAM and the addresses to VPOKE your UDG Data into, and the associated Colour addresses too.
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Feel free to ask any questions. I'm in the process of converting a simple Spectrum game and will post the code here too.
This is a table I produced in Google Sheets which holds the addresses for each of the characters in VRAM and the addresses to VPOKE your UDG Data into, and the associated Colour addresses too.
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Feel free to ask any questions. I'm in the process of converting a simple Spectrum game and will post the code here too.