Development with MSX BASIC

Page 1/9
| 2 | 3 | 4 | 5 | 6

By baltasarq

Rookie (27)

baltasarq's picture

07-09-2010, 21:44

Hi, there!

My name is Baltasar. I'm not a very advanced MSX developer, my goal is just to port a Basic program

I've ported this program from Sinclair Basic to Amstrad Basic, and also to Blassic (PC).
I've tried to port it to MSX using an actual MSX Philips VG8020. I'm using a disk drive, so I can copy the basic file to disk directly from PC (in ASCII) and load them in MSX.

However, the complete program, while working perfectly in Sinclair Spectrum and Amstrad CPC, was impossible to be loaded in the MSX computer. I tried to divide the file in code and data (BASIC DATA's), but when I try to merge them in order to obtain the complete file, I also get the "out of memory" message.

I'd like to know how I could port this program by one of the following means (or maybe any other possibility):

- Extending BASIC memory somehow. PRINT FRE(0) returns just 20k. I need about 10k extra for my program to fit.
- Keep the current division of code and data, and program a little loader that loads the data basic program, executes it and then, without losing memory (but erasing the program memory) loads the code program.
- Use the BASIC commands for files, and store all data in true data file. This will imply a lot of coding, not a simple port.

Maybe there is another possibility I'm missing. Any help will be appreciated.

Login or register to post comments

By pitpan

Prophet (3131)

pitpan's picture

07-09-2010, 22:18

If you keep pressed the SHIFT key while booting the computer you will get 28,815 bytes but no disk drive support.

On the other hand, the "Out of memory" error is displayed while executing the MERGE instruction or when you RUN the game?

IIRC, MERGE needs both programs to be in ASCII, this means not tokenized BASIC. If this is the case, you should save both files as ASCII and append them in a PC editor, for example. Then you adjust the line numbers et voila.

On the other hand, if you are running out of memory when running the game, you should try to use some CLEAR statements to adjust variable space. Probably you are running out of string space... If you don't state the string length, it is set to 255 chars (haven't checked this, I just remember a similar issue when I was coding in BASIC 20 years ago).

(Y si no te sirve nada de todo esto, ponme un e-mail en erobsy AT gmail DOT com, que igual es más fácil).

By cax

Prophet (3722)

cax's picture

07-09-2010, 22:24

I just loaded your game into MSX from disk, and I still have 1K free.

Here is what I did with CPC version I downloaded:

1) renamed GO TO to GOTO and GO SUB to GOSUB
2) removed INK, BORDER, PEN and other command that don't exist in MSX-BASIC
3) replaced all PRINT with ?
4) removed all LET
5) removed a lot of spaces (almost not needed) - e.g. "IF " with "IF" etc.
6) replaced DIFF with DF
7) replaced LOC with LO
8) replaced CORTADO with co

and then loaded the file from disk.

MSX Basic uses only 2 first letters of variable name, so you may optimize your program even more by choosing shorter variables names.
You should also rename different variables that start with the same 2 letters (e.g. LOC and LOCS are the same variable).
You may try also merging separate DATA lines into one (up to 250+ chars in line).

P.S. I also see MID$() in line 9865 attempts to use a zero index, which results in Illegal function call.
Here I stop - you should fix the code yourself.

By baltasarq

Rookie (27)

baltasarq's picture

08-09-2010, 10:42

Thanks for your help; specially to Cax. Interesting that error in MID$, as it is a code working in CPC & Sinclair.
I'll follow the steps given and try to "manually compress" my BASIC file.

In general, I have to say that this BASIC is probably the most limited one, compared at least to Sinclair's and Amstrads. The most capable and powerful one is Amstrad's.

I still have some doubts for the near future:
- Distribution: what is best for distribution?
- The BAS ASCII file. This is not a very good option, though it would work.
- Creating a ROM file: I suppose this would be tricky, since I suppose BASIC wouldn't be available.
- tape/disk file: which one is better? how do i create any of them from a BASIC program?

PS: Perdón, este foro ¿es en Inglés o Español?

By baltasarq

Rookie (27)

baltasarq's picture

08-09-2010, 10:48

In SCREEN 0, I've learned that COLOR fg, bg changes the whole screen colors. However, I'd like to only change the ink or pen color. Is that possible?

Thank you.

By MäSäXi

Paragon (1884)

MäSäXi's picture

08-09-2010, 11:46


Changes just character colour to black (for all characters).

COLOR 4,14

Changes character colour to blue and whole background to grey.

With ink and pen colours, you probably mean something like this:


Where H is red, E is green, L is light yellow, L is blue, O is white.... etc, so you can alter colour for every character you want?

If you meant that, you must:

30 PRESET(100,100): COLOR8: PRINT#1,"H": PRESET(108,100): COLOR2: PRINT"E": PRESET(116,100): COLOR11: PRINT"L": PRESET(124,100): COLOR5: PRINT"L": PRESET(132,100): COLOR15: PRINT"O"
40 GOTO 40

You can change PRESET(100,100):COLOR8 to PSET(100,100),8 if that suits you better. Smile

PSET plots pixel, PRESET unplots. Try PSET and PRESET and please notice what happens to the top left corner of the first printed character in the string. Wink

Of course there are other ways too to do that same thing I described here. Smile It depends what you want to do. Smile

In SCREEN 1, you can alter foreground and background colours for each eight character blocks.

Like characters @ABCDEFG to dark red with black background and HIJKLMNO to light green with green background:

VPOKE &H2008,&H61:VPOKE&H2009,&H32


I hope I answered your question. Smile

By baltasarq

Rookie (27)

baltasarq's picture

08-09-2010, 11:55

My God! It's actually very difficult to manage colors in MSX!

I'd just like to be able to do something like:

COLOR 7:?"Hello":COLOR 15:?" world!"

So Hello would be printed in cyan and world in white (actual code colors are not important).
Unfortunately, this code changes colors for the whole screen each time.
This is weird. I cannot afford to poke each eight characters, nor calculate the pixels for each message.

Isn't there any other possibility?

By MäSäXi

Paragon (1884)

MäSäXi's picture

08-09-2010, 12:09

Oh, I thought you wanted different colour for EACH character. Tongue I am sorry for misunderstooding. Smile

<I have edited this few times>

Try this instead:

10 SCREEN 2: REM goes to high resolution graphics mode
20 OPEN"GRP:"AS1: REM without this you cannot PRINT in SCREEN 2 and SCREEN 3
30 COLOR 7: PRINT#1,"Hello":COLOR 15: PRINT#1," world!": REM Please notice the use of #1, when PRINTing in SCREEN 2, you need this only in SCREEN 2 and SCREEN 3.
40 GOTO 40

But I will advice you to add either PSET or PRESET, as with them you can select X- and Y-coordinates where you want to PRINT. Smile

I hope it´s easier now. Smile

You can select ONLY ONE character colour in SCREEN 0, just as you noticed already. Smile

I have thought many times, that some INK type command would have been handy to change character colours for each character. But every old computer has it´s own personality. Wink Smile

I haven´t checked your program, so I don´t know what kind of things you may need, but IF you can live with one character colour (=all text has same colour), then use SCREEN 0 or SCREEN 1 and LOCATE X,Y to tell computer where you want to PRINT"HELLO WORLD!" Smile

But if you want to change colour for each word, use SCREEN 2.

By baltasarq

Rookie (27)

baltasarq's picture

08-09-2010, 12:30

@Masaxi, unfortunately your pogram does not work. It shows me "Illegal instruction call" in 30.

I don't need locate, since it is an adventure game and its a text buffer oriented one.
This color limitations remembers me the Dragon BASIC.

Thank you for your help.

By JohnHassink

Ambassador (5417)

JohnHassink's picture

08-09-2010, 12:38

It shows me "Illegal instruction call" in 30.
Change line 20 to:


By JohnHassink

Ambassador (5417)

JohnHassink's picture

08-09-2010, 12:49

COLOR 7:?"Hello":COLOR 15:?" world!"

So Hello would be printed in cyan and world in white (actual code colors are not important).
Unfortunately, this code changes colors for the whole screen each time.
This is weird.
In SCREEN 0 and SCREEN 1, it does.
Better switch to SCREEN 2 if you want to do it the 'simple' way (the way as described above).

Doing the same in SCREEN 1 (different colors for characters) takes more work.

Page 1/9
| 2 | 3 | 4 | 5 | 6