VOGONS


First post, by jmk

User metadata
Rank Newbie
Rank
Newbie

Wizball should have a bit of PC speaker sampled audio in it, according to this:
http://www.oldskool.org/sound/pc

Here is the routine which might be trying to do it. It is using a PIT mode which has not been added into the emulation - the Hardware Retriggerable One Shot.

0F63:4463 "routine". DI = 09 (usually) SI = Source? CX = Length?
4463 cli
4464 in al,61 or al,2 out 61,al (Speaker data enable).
446A in al,62 or al,20 out 62,al ("timer 2 channel out").
4470 in al,61 and al,FE out 61,al (Speaker data disable).
4476 mov al,92 out 43,al (PIT mode port: counter 2, counter latch, mode 1 (one shot), binary.
447A mov al,FF out 42,al (PIT counter 2, cassette & speaker).
447E mov dl,0
4480 push cx
4481 in al,61 or al,01 out 61,al ("timer 2 gate to speaker enable").
4487 and al,FE out 61,al ("timer 2 gate to speaker disable").
448B mov al,[si] out 42,al -> big table of "sample timing data" (usually 1A-2E).
448F mov cx,di
4491 loop 4491
4493 pop cx
4494 inc si
4495 loop 4480
4497 sti
4498 ret

I'm no expert on the timers and their interaction with the internal speaker... I think it may be trying some sort of pulse-width modulation?

Anyway, if someone who knows better would like to investigate, then I'd be grateful. 😉

Reply 1 of 2, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

well there is some support for mode 1 in our code. In both the PIT and the PCSpeaker.
Not sure if our emulation is compatible with this game though.

Water flows down the stream
How to ask questions the smart way!

Reply 2 of 2, by reenigne

User metadata
Rank Oldbie
Rank
Oldbie

I tried to implement something similar for MESS a while back, but it turns out to be quite difficult. While it's possible to use trickery to get good sound quality in games like Digger (which modulate pulse widths to control the volume of rectangular waves) and also possible to use different trickery to reproduce sampled sound if you know what the sample rate is, it's hard to know which of these techniques to use when.

A technique that would always work and give great sound would be to sample the speaker bit at very high rates (like 1.193MHz - the PIT frequency) and then downsample that to a rate suitable for output on a normal soundcard. This could be done with Fourier techniques or by convolving with a suitable filter kernel, but I never got around to writing this code. It also might be rather processor intensive.