Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play sound on two different DOSBoxes simultaneously?

I have created the game "Angry Birds" in assembly 8086. My main problem now is that I want to play the song of the game while the main loop is running. I've already written the code for the music. I thought about using multi-threading but found out the assembly interrupt for creating threads only works on cmd and not on DOSBox.

However, I found another way of doing multi-threading, which was to call a command from the C++ Windows.h file, that creates a thread. That was too complicated.

Now, I have managed to communicate between two different DOSBox windows, using interrupt 14h for sending messages over LAN ports. Basically, I've written a separate code for the music. Both codes run and only when the music code gets the sign, it starts playing the music.

However, I found out that when two DOSBox windows are open, only the sound of the main one works. You have to switch windows in order to hear the music, which means you can't hear it.

Does anyone have any idea of how I can solve this problem, or generally play music while the main loop is running?

Thank you

like image 988
Boomer Avatar asked May 08 '19 14:05

Boomer


1 Answers

As mentioned, you could use a multi-channel sound device (not specified in question, see the soundchip(s) docs for that) but the PWM based DOS speaker output is a single waveform output with no concept of second frequency unless you want to digitally merge PWM waveforms and output the merged data (going to be nasty work, possibly tens of microseconds between edges that you will have to bit stuff manually. DMA should work, but buffers are probably going to be large, which means the sound lag will be many milliseconds.

like image 77
Hans Schulze Avatar answered Oct 21 '22 09:10

Hans Schulze