[MSX-C] Q&A official thread

Page 32/57
25 | 26 | 27 | 28 | 29 | 30 | 31 | | 33 | 34 | 35 | 36 | 37

By Sylvester

Hero (563)

Sylvester's picture

26-04-2016, 13:38

It's the memory location of the Background color. You can use it to set or read this color.
When you execute COLOR 15,1,1 in BASIC it will put these values on 0xf3e9, 0xf3ea, 0xf3eb.

By AxelStone

Prophet (3120)

AxelStone's picture

26-04-2016, 13:39

Sylvester wrote:

It's the memory location of the Background color. You can use it to set or read this color.
When you execute COLOR 15,1,1 in BASIC it will put these values on 0xf3e9, 0xf3ea, 0xf3eb.

You are right, thanks Wink

By AxelStone

Prophet (3120)

AxelStone's picture

11-05-2016, 21:56

Here goes again. I've started with FM programming, so the first stop is to detect it. I've following this tutorial, and detection of external FM-PAC works fine.

However, detection of internal FM doesn't works. Here goes my code:

#include<stdio.h>
#include<msxbios.h>

#define FMADDR (* (char *)0x4018)
/* Scan for internal FM */
VOID scanint() {
    TINY i;
    for(i=0;i<8;i++) {
        printf("%c",FMADDR+i);
    }
    printf("Finished\n");
}

The output of this code is allways "qrstuvwx" instead of "APRLOPLL", whenever configuration I've tried on OpenMSX (MSX2, MSX2+, MSX tR).

What could be wrong? Thanks.

By Manuel

Ascended (18861)

Manuel's picture

11-05-2016, 22:28

Are you looking in the right slot?

By Grauw

Ascended (10604)

Grauw's picture

11-05-2016, 22:36

Seems like a slot selection problem, maybe with subslots, but you’ve omitted that part Smile. Also probably easiest to use RDSLT interslot reads. Semi-MSX-C code example:

int findfmslot() {
    for (int p = 0; p < 4; p++) {
        for (int s = 0; s < 4; s++) {
            int slotId = (&(0xFCC1 + p) & 0x80) | (s << 2) | p;
            if (testfmslot(slotId))
                return slotId;
            if (&(0xFCC1 + p) & 0x80 != 0)
                break;
        }
    }
    return -1;
}

bool testfmslot(slotId) {
    return rdslt(slotId, FMADDR + 4) == 'O' &&
        rdslt(slotId, FMADDR + 5) == 'P' &&
        rdslt(slotId, FMADDR + 6) == 'L' &&
        rdslt(slotId, FMADDR + 7) == 'L';
}

By tvalenca

Paladin (747)

tvalenca's picture

11-05-2016, 22:36

The substring "qrstuvwx" is part of the Main ROM. You probably need to change to the slot/subslot the FM BIOS is located. On Turbo R, it is located on slot 0-2, so, you need to change the subslot register on slot 0 (page 3 to slot 0, write on 0xFFFF, page 3 back to the slot it were before) before running it.

So, your routine has to check every slot/subslot (from 0-0 to 3-3) for this string before assuming there's no OPLL chip installed. And Internal FM BIOS has to be given preference over external FM BIOS (the Turbo R FM BIOS has some patches to allow FM working properly on R800 mode)

By AxelStone

Prophet (3120)

AxelStone's picture

12-05-2016, 17:55

It works, thanks a lot people Wink

By Sylvester

Hero (563)

Sylvester's picture

12-05-2016, 18:37

Maybe you can use the fmlib for FM programming: https://github.com/sndpl/msx-c-examples
It contains an example that plays some notes :) And when I have some time I will try to update the FM detection so it will also find the FM clones.

By AxelStone

Prophet (3120)

AxelStone's picture

12-05-2016, 19:59

Very interesting Sylvester, what kind of music format can play? I see functions to play music, what kind of formats support?

Thanks.

By Sylvester

Hero (563)

Sylvester's picture

12-05-2016, 20:58

It doesn't play any tracker format, it's more like a Play command (see also: https://www.msx.org/wiki/MSX-Music_programming). Just put the song data in fmdata (see the example script) and place it into the memory. The play music will play the data.

Still busy with the moonblaster lib, but it's more difficult. The current replayer needs to be in the memory above 4000h, also you need to define where the song data is etc. I already have a mbplay.com in assembly :) but now I have to create a msx-c library of it.

Page 32/57
25 | 26 | 27 | 28 | 29 | 30 | 31 | | 33 | 34 | 35 | 36 | 37