MSX Music Player using R800

By jepmsx

Master (194)

jepmsx's picture

24-11-2022, 20:14

I'm trying to build a Player in C for MSX-Music (OPLL). I've noticed that when it is played with R800 enabled, there are some notes that are skipped. I've discovered this thread where it says that R800 has to wait a little bit before rewriting the registers. Does anybody know how long? Maybe two ex af,af'?

Login or register to post comments

By Metalion

Paragon (1589)

Metalion's picture

24-11-2022, 20:26

The OPLL needs:
. between writing an address and sending data: 3.36µs.
. after writing data, and before writing new data or address: 23.52µs
(these infos are in the OPLL user's manual)

Now, all you need is to translate those delays into R800 cycles.

By jepmsx

Master (194)

jepmsx's picture

25-11-2022, 09:47

Thanks a lot for the explanation, I didn't know about those timings.

I've found in this wiki that MULUB lasts 14T around 1.96µs. The problem is that I don't think that this command is understood by SDCC.

I also found the timing of opcodes and it matches the previous 14T. In the information that I have about OPLL, it does two ex af,af' after writing the registers. These are 4T in Z80 and 1T in R800. Maybe I'll do eight ex af,af' in R800 mode.

By Metalion

Paragon (1589)

Metalion's picture

25-11-2022, 13:50

The R800 is clocked at 7.159MHz, so a single T state take 0.14µs
Therefore you'll need:
. between writing an address and sending data: 24T
. after writing data, and before writing new data or address: 168T

By aoineko

Paladin (695)

aoineko's picture

25-11-2022, 13:59

jepmsx wrote:

I've found in this wiki that MULUB lasts 14T around 1.96µs. The problem is that I don't think that this command is understood by SDCC.

#define MULUB_A_A		.db 0xED, 0xF9
#define MULUB_A_B		.db 0xED, 0xC1
#define MULUB_A_C		.db 0xED, 0xC9
#define MULUB_A_D		.db 0xED, 0xD1
#define MULUB_A_E		.db 0xED, 0xD9
#define MULUB_A_H		.db 0xED, 0xE1
#define MULUB_A_L		.db 0xED, 0xE9
#define MULUW_HL_BC		.db 0xED, 0xC3
#define MULUW_HL_DE		.db 0xED, 0xD3
#define MULUW_HL_HL		.db 0xED, 0xE3
#define MULUW_HL_SP		.db 0xED, 0xF3

Problem solved :)

(https://github.com/aoineko-fr/MSXgl/blob/main/engine/src/asm.h)

By jepmsx

Master (194)

jepmsx's picture

26-11-2022, 07:31

Thanks Metallion for the translation of T states to µs and the final maths for waiting time.
Thanks aoineko for the trick to assemble R800 opcodes, I wouldn't have thought of this technique.