[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Programming the DOC pt2
In article <mbusse.0tc5@amiganet.chi.il.us> mbusse@amiganet.chi.il.us (Marco Busse) writes:
>
> [turn off the internal speaker by setting sound volume to zero manually]
>
> I want to accomplish the same effect under program control. However, I am
> having difficulty in doing so. It has always been my untested impression that
> the lower four bits of the SOUNDCTL softswitch at $c03c controlled the volume
> of the internal speaker. So I figured a short routine like:
>
> lda SOUNDCTL
> and #$F0
> ora #$0x
> sta SOUNDCTL
>
> would set the volume of the internal speaker to 'x' (assuming 8 bit
> accumulator in the above code of course). This doesn't seem to be the case.
> The above routine has no effect on the volume of the internal speaker that I
> can tell. Am I missing something obvious?
Yep. The above code WILL work. The next sound generated through the
internal speaker will be at the new volume. However, consider that
the volume bits are write-only. If any software needs to write
anything into the upper four bits of SOUNDCTL (i.e. access the DOC or
sound RAM), they need to write some value into the lower four bits.
This will override your 'temporary' volume setting.
What you need to do is adjust the value that other routines are using
as the source for the sound volume. The current system volume is
obtained from a variable called IRQ.VOLUME, which can be located using
the GetAddr call in the miscellaneous toolset. If you change this
value (and also update SOUNDCTL), the system volume will remain at the
new setting until someone calls up the CDA menu or adjusts the control
panel setting (which will set IRQ.VOLUME back to its correct value).
When your program finishes, you should return IRQ.VOLUME to its correct
value. In case the user has been into the control panel, it is safest
to read the appropriate parameter from the battery RAM (using
GetBParam) and set IRQ.VOLUME according to that.
--
David Empson
Internet: David.Empson@bbs.actrix.gen.nz EMPSON_D@kosmos.wcc.govt.nz
Snail mail: P.O. Box 27-103, Wellington, New Zealand