New Moonblaster 1.4 driver

by Meits on 06-04-2011, 02:37
Topic: Software
Tags: Utilities
Languages:

After a request by Near Dark to implement a 50Hz/60Hz equalizer which will play the music at the same speed on both frequencies, BiFi of The New Image adapted the Basic driver for Moonblaster 1.4 songs with the following results:

  • map.com/bin are no longer needed
  • music written for 50Hz will play perfectly on both frequencies
  • adapted errors to use BASIC errors
  • added hertz equalizer, controllable with _MBEQUAL
  • added DOS2 mapper support, controllable with _MBBANK, _MBALLOC and _MBFREE
  • added DOS2 directory support
  • fixed incorrect writes to PSG R#7 bug
  • fixed a few other typical internal bugs

Relevant link: MSX Banzai!

Comments (19)

By ro

Guardian (4122)

ro's picture

06-04-2011, 11:18

I'm confused, wasn't MB already equiped with the equal-replay option? (or is that because I had implemented it myself in the FK version? hmm... me's gonna check)

By ARTRAG

Enlighted (6276)

ARTRAG's picture

06-04-2011, 14:00

no sources included...
@bifi, you have already done part of the work, why not completing it by releasing the disassembled sources ?

By ro

Guardian (4122)

ro's picture

06-04-2011, 16:27

disassembled source? afaik the source is provided on the original MB disk Wink

By Meits

Scribe (5647)

Meits's picture

06-04-2011, 16:53

Ro... Sorry chap, you're wrong twice... The basic replayer for MBWAVE is DOS2 compatible, frequency equalized and such... The sources of the basic driver were never released, only the sources for the asm guys like you (that's probably the reason why you didn't know, cuz you don't need it Wink )

By ro

Guardian (4122)

ro's picture

06-04-2011, 19:29

aaah, we're talking the BASIC replayer here. aha, totally miz'd that. but wtil, that came without the eqplaythingy? hmmm. who needs basic anyway...

signed, your asm friend.Running Naked in a Field of Flowers

By Meits

Scribe (5647)

Meits's picture

06-04-2011, 21:25

For basic muzax eh Tongue And being independent of external coders kinda suits us Smile

By ro

Guardian (4122)

ro's picture

07-04-2011, 08:51

Yeah, we're the lazy bunch eh Smile

By Lord_Zett

Paladin (807)

Lord_Zett's picture

08-04-2011, 08:16

yeah more basic stuff!

By norakomi

Paladin (1003)

norakomi's picture

24-10-2019, 11:38

Quote:

music written for 50Hz will play perfectly on both frequencies

With the asm replayer this is not supported. At 50hertz the music is clearly slower.
Am I missing something? I can't find any support for this in the code either.
Is this only for the basic replayer maybe ?

Conditionals in the assemby file:
;
; conditionals
;
withBIN: equ 0 ;1=include .bin header
withTurboR: equ 0 ;1=include TurboR supported code
; (pre-select and timing)
withMapper: equ 0 ;1=include Mapper supported code
;withMapper: equ 1 ;1=include Mapper supported code
withHook: equ 0 ;1=strmus will set the hook
;0=you will need to call musint
withFade: equ 1 ;1=include fade-out code

The withHook doesn't solve this. The withTurboR doesn't change things either....
Any idea?

Should music be written specifically for 50hertz ? And if so, how ? I don't see the option in Moonblaster to write specifically for 50hertz.

By Meits

Scribe (5647)

Meits's picture

24-10-2019, 14:42

Both basic and asm players by Moonsoft were frequency dependent. End user-coders implemented the equalizer themself. It turned out to be more convenient to equalize 50Hz to play on 60Hz (entering a few waits while on 60Hz) than the other way around. It's quite an old trick which I can not explain by lack of asm knowledge. Just wait for guys like grauw to step into the conversation or contact him, or bifi, who did this basic.bin mod.

norakomi][quote wrote:

Should music be written specifically for 50hertz ? And if so, how ? I don't see the option in Moonblaster to write specifically for 50hertz.

Toggle frequency with ctrl+z and alter the tempo. Smile

By norakomi

Paladin (1003)

norakomi's picture

24-10-2019, 16:24

Well I can see how you can write music for 50 hertz.
Then when you play it back in 60 hertz just skip the music playback once every 6 frames.
But you would 'hear' that, and it wouldn't sound so nice....
Doesn't seem the best sollution, but if it's the only solution I'll take it

By Meits

Scribe (5647)

Meits's picture

24-10-2019, 17:22

Don't trust me on my brown eyes how it's done. But the mentioned guys know it for sure.

By Grauw

Ascended (8508)

Grauw's picture

24-10-2019, 18:51

norakomi wrote:

Well I can see how you can write music for 50 hertz.
Then when you play it back in 60 hertz just skip the music playback once every 6 frames.
But you would 'hear' that, and it wouldn't sound so nice....
Doesn't seem the best sollution, but if it's the only solution I'll take it

Indeed that's the simplest way to do it. Or compose for 60 Hz and call the replayer code twice every 5th frame, depending on which frequency you want to optimise for. This is the common solution and likely what BiFi did here. It will introduce a slight shuffle but I don't think the effect is super noticeable (but your ears may have a different opinion).

For the perfect solution, use line interrupts to create a 300 Hz timer, and then invoke the replayer every 5th or 6th interrupt depending on composition frequency (recommend 60 Hz in this case). I do this in VGMPlay (see LineTimer.asm); after each line interrupt increment the split line number by 52 (60 Hz) or 51 (50 Hz), and reset to 0 when it overflows. Now you've got a great 300 Hz timer with only a small inaudible imprecision of 0.2 ms.

It's not very complicated in principle, but for use with games of course downside is that 1. it may interfere with other splits that you use, possibly complicating your line split setup a bit, and 2. music interrupt handling can occur at various moments during the frame. That's why I recommend to compose for 60 Hz so that when playing on 60Hz it is always done once per frame at the exact same moment, while on 50 Hz it occurs roughly every 262 lines (out of 313) so at different parts of the frame and sometimes twice per frame (but you likely have spare CPU time then).

By norakomi

Paladin (1003)

norakomi's picture

24-10-2019, 19:52

Cool, I was hoping for a simpler solution (like adjusting the tempo at which the song has been made (isnt that possible?),
but a linesplit alternative for the 50 hertz version seems doable.
Another alternative is to have all songs 2x (the 50hz and 60hz version), and just load the one which is appropriate. But that costs a lot of romspace.
Why reset to 0 at overflow btw ?
And the sfx, they stay at Vblank ?

By Grauw

Ascended (8508)

Grauw's picture

24-10-2019, 20:10

Grauw wrote:

For the perfect solution, use line interrupts to create a 300 Hz timer, and then invoke the replayer every 5th or 6th interrupt depending on composition frequency (recommend 60 Hz in this case). I do this in VGMPlay (see LineTimer.asm); after each line interrupt increment the split line number by 52 (60 Hz) or 51 (50 Hz), and reset to 0 when it overflows. Now you've got a great 300 Hz timer with only a small inaudible imprecision of 0.2 ms.

To clarify this method a bit further; to get an exact 300 Hz timer you need to generate an interrupt every 52.33 lines (3579545 / 300 Hz / 228 CPU cycles per line).

At 60 Hz there are 262 lines displayed per frame, which we want to divide in 5 parts. So if we increment the 8-bit line counter by 52 until it overflows, we get 5 interrupts on lines 0, 52, 104, 156 and 208.

At 50 Hz we want to divide its 313 lines in 6 parts, for which we use a little trick by incrementing the counter by 51; then we will get 6 interrupts on lines 0, 51, 102, 153, 204 and 255 before it overflows.

Refining this a bit further, in VGMPlay I actually need a 300 Hz timer, but if your music is authored for 60 Hz you don’t actually need all of those line interrupts, but only a fifth of them. If you would want to reduce the amount, at 60 Hz you could simply use the VBLANK interrupt, and at 50 Hz set line interrupts on the following sequence of lines: 0, 255, 204, 153, 102, 51.

Note that the line numbers are not exact multiples of 52.33, and neither are the 50 / 60 Hz display frequencies actually exact divisions of 300 Hz since they’re really 50.15 Hz and 59.92 Hz. So there is a small amount of error but it’s too small to notice, and it syncs up predictably to the frames which is good for games.

By Grauw

Ascended (8508)

Grauw's picture

24-10-2019, 20:54

norakomi wrote:

Cool, I was hoping for a simpler solution (like adjusting the tempo at which the song has been made (isnt that possible?). Another alternative is to have all songs 2x (the 50hz and 60hz version), and just load the one which is appropriate. But that costs a lot of romspace.

Isn’t that effectively the same as the first approach of skipping / repeating the replayer call? The problem remains that the base timer frequency from which all counters derive is different.

norakomi wrote:

but a linesplit alternative for the 50 hertz version seems doable.

Though I would first make sure the above mentioned simpler approach is not acceptable to you. But I must admit you do get extra cool bonus points for the line timer approach, for attention to detail.

norakomi wrote:

Why reset to 0 at overflow btw ?

I hope I explained it in my follow-up post above. The screen has 262 (60 Hz) / 313 (50 Hz) lines, but the interrupt line register is 8-bit so you can only specify lines up to 255.

norakomi wrote:

And the sfx, they stay at Vblank ?

I think that’s fine, do whatever is convenient.

By norakomi

Paladin (1003)

norakomi's picture

30-11-2019, 16:00

I want to add a volume control in the moonblaster-driver.
This way the user can balance the volumes (psg, msx-music and msx-audio).

But after 2 days of hacking in the code I haven't been succesful. There are barely any comments in the code, so it's extremely hard to figure out what's happening.

Is there anyone who has tried something like this themselves ?

By AxelF

Champion (343)

AxelF's picture

30-11-2019, 16:28

Yeah its a shame, this kind of projects should be open source for community sake.

By Meits

Scribe (5647)

Meits's picture

02-12-2019, 10:51

The guys of Hegega did something like that. When pressing the i button in the replayer of Carbuncle Big Band you can control the volume of all channels.