Commit 658b7813 authored by Ben Avison's avatar Ben Avison
Browse files

Given a major overhaul to work with the HAL version of the SoundControl...

Given a major overhaul to work with the HAL version of the SoundControl module. Slider list is now dynamically generated to reflect hardware capabilities. Configuration of beep voice and volume is now consistent with the rest of !Configure (ie doesn't happen until you click 'Set').

Version 1.00. Tagged as 'SndSetup-1_00'
parent 7c3112cd
*,ffb gitlab-language=bbcbasic linguist-language=bbcbasic linguist-detectable=true
c/** gitlab-language=c linguist-language=c linguist-detectable=true
**/c/** gitlab-language=c linguist-language=c linguist-detectable=true
h/** gitlab-language=c linguist-language=c linguist-detectable=true
......@@ -61,11 +61,15 @@ INCLUDES = -Itbox:,C:
FILES =\
Resources.!Boot \
LocalRes:!Run \
Resources.!RunImage \
Resources.<UserIF>.!Sprites \
LocalRes:Blank \
Resources.<UserIF>.CoSprite \
Resources.!RunImage \
LocalRes:Messages \
LocalRes:Res
LocalRes:Res \
Resources.Sprites \
Resources.Sprites11 \
Resources.Sprites22 \
OBJS =\
o.main \
......@@ -88,17 +92,21 @@ OBJS =\
all: ${FILES}
@echo ${COMPONENT}: Application made.
install: ${FILES}
install: ${FILES} o._Messages_
@echo
@echo ${COMPONENT}: Creating application ${APP}
${MKDIR} ${INSTDIR}.${APP}
${CP} Resources.!Boot ${INSTDIR}.${APP}.!Boot ${CPFLAGS}
${CP} LocalRes:!Run ${INSTDIR}.${APP}.!Run ${CPFLAGS}
${CP} Resources.!RunImage ${INSTDIR}.${APP}.!RunImage ${CPFLAGS}
${CP} Resources.<UserIF>.!Sprites ${INSTDIR}.${APP}.!Sprites ${CPFLAGS}
${CP} LocalRes:Blank ${INSTDIR}.${APP}.Blank ${CPFLAGS}
${CP} Resources.<UserIF>.CoSprite ${INSTDIR}.${APP}.CoSprite ${CPFLAGS}
${CP} Resources.!RunImage ${INSTDIR}.${APP}.!RunImage ${CPFLAGS}
${CP} LocalRes:Messages ${INSTDIR}.${APP}.Messages ${CPFLAGS}
${CP} o._Messages_ ${INSTDIR}.${APP}.Messages ${CPFLAGS}
${CP} LocalRes:Res ${INSTDIR}.${APP}.Res ${CPFLAGS}
${CP} Resources.Sprites ${INSTDIR}.${APP}.Sprites ${CPFLAGS}
${CP} Resources.Sprites11 ${INSTDIR}.${APP}.Sprites11 ${CPFLAGS}
${CP} Resources.Sprites22 ${INSTDIR}.${APP}.Sprites22 ${CPFLAGS}
Access ${INSTDIR}.${APP}.* wr/r
@echo
@echo ${COMPONENT}: Application installed {Disc}
......@@ -106,8 +114,13 @@ install: ${FILES}
clean:
${RM} ${OBJS}
${RM} Resources.!RunImage
${RM} o._Messages_
@echo ${COMPONENT}: cleaned
o._Messages_: LocalRes:Messages
@echo Creating messages file
/PatchVers LocalRes:Messages o._Messages_
#
# Static dependencies:
#
......
File added
| !Boot file for Sound configuration plug-in
Set SoundConfig$Dir <Obey$Dir>
Iconsprites <SoundConfig$Dir>.!Sprites
Set SndSetup$Dir <Obey$Dir>
IconSprites <SndSetup$Dir>.!Sprites
File added
File added
File added
| !Run file for Sound configuration plug-in
RMEnsure UtilityModule 5.03 Error This version of SndSetup requires RISC OS 5.03 or later
RMEnsure UtilityModule 3.10 Error This version of Sound Configure requires RISC OS 3.1 or later.
IF "<Choices$Write>" = "" OR "<Boot$Path>" = "" THEN Error No Boot application appears to have been run
IF "<Boot$Dir>" = "" THEN Error No !Boot application has been run.
IF "<Choices$Write>" = "" THEN Error No !Boot application has been run.
Set SndSetup$Dir <Obey$Dir>
IconSprites <SndSetup$Dir>.!Sprites
Set SoundConfig$Dir <Obey$Dir>
Iconsprites <SoundConfig$Dir>.!Sprites
RMEnsure Toolbox 1.36 RMLoad System:Modules.Toolbox.Toolbox
RMEnsure Toolbox 1.36 Error You need Toolbox 1.36 or later to run SndSetup
RMEnsure Toolbox 1.36 RMLoad System:modules.toolbox.toolbox
RMEnsure Toolbox 1.36 Error You need Toolbox 1.36 or later to run Sound Configure
RMEnsure Window 1.41 RMLoad System:modules.toolbox.window
RMEnsure Window 1.41 Error You need Window 1.41 or later to run Sound Configure.
RMEnsure Menu 0.28 RMLoad System:modules.toolbox.menu
RMEnsure Menu 0.28 Error You need Menu 0.28 or later to run Sound Configure.
RMEnsure SoundControl 0.00 Error You need SoundControl 0.00 or later to run Sound Configure.
RMEnsure Window 1.44 RMLoad System:Modules.Toolbox.Window
RMEnsure Window 1.44 Error You need Window 1.44 or later to run SndSetup
WimpSlot -min 256k -max 256k
Run <SoundConfig$Dir>.!RunImage %*0
RMEnsure Menu 0.29 RMLoad System:Modules.Toolbox.Menu
RMEnsure Menu 0.29 Error You need Menu 0.29 or later to run SndSetup
RMEnsure SoundControl 1.00 Error You need SoundControl 1.00 or later to run SndSetup
WimpSlot 40k 40k
Run <SndSetup$Dir>.!RunImage %*0
|
| Sound setup file
|
| This file was automatically generated by SndSetup (part of Configure).
| Do not edit it by hand.
|
......@@ -2,7 +2,7 @@
_TaskName:Sound setup
_Purpose:Configuring the sound system
_Author:© Acorn Computers Ltd, 1998
_Version:0.04 (05-Jun-98)
_Version:VERSION
_ConfigText:Sound
_ConfigHelp:Click SELECT to open the Sound configuration window.
_ConfigSprite:co_sound
......@@ -13,3 +13,66 @@ reportt:Message from Configure
# Error messages
NotEnoughMemory:There is not enough memory to do that operation.
ChoicesFileNotOpen:Couldn't open choices file.
# Tokens for mixer channels.
# Suffixes: [O]utput/[I]nput, absolute category number, [m]ono/[s]tereo, index (starting from 0), total indexes for this category.
# These are the names of the channels, as passed as parameters to the other strings. The parameter is either a null string, or a space followed by the index (starting from 1).
nameO1m??:speaker%0
nameO1s??:speakers%0
nameO2m??:earpiece%0
nameO2s??:headphones%0
nameO3???:line out%0
nameO4???:aux out%0
nameO????:unrecognised output
nameI0???:system%0
nameI1???:microphone%0
nameI2???:line in%0
nameI3???:aux in%0
nameI????:unrecognised input
# These are the names of channels, as used for labels. The parameter is either a null string, or a space followed by the index (starting from 1).
NameO1m??:Speaker%0
NameO1s??:Speakers%0
NameO2m??:Earpiece%0
NameO2s??:Headphones%0
NameO3???:Line out%0
NameO4???:Aux out%0
NameO????:Audio out
NameI0???:System%0
NameI1???:Microphone%0
NameI2???:Line in%0
NameI3?0?:Aux in%0 (CD)
NameI3???:Aux in%0
NameI????:Audio in
# These are the help strings for labels.
HelpLO1??1:This is the volume output on the %0.
HelpLO1???:This is the volume output on %0.
HelpLO2???/HelpLO3???:This is the volume output on the %0 socket.
HelpLO4???:This is the volume output on the %0 header.
HelpLO????:This is an %0 channel.
HelpLI0???:This is the mix level of %0 audio. This includes system beeps, audio playback and most games.
HelpLI3?0?:This is the mix level of %0 audio. This is usually connected to your CD or DVD drive, for use with playback of audio CDs.
HelpLI????:This is the mix level of %0 audio.
# These are the help strings for the mono/stereo indicator buttons.
HelpB??m??:This indicates that this is a monophonic channel.
HelpB??s??:This indicates that this is a stereophonic channel.
# These are the normal help strings for the sliders.
HelpS?????:You can adjust the %0 volume using the slider.
# These are the help strings for the sliders for fixed channels.
HelpSF?????:You cannot adjust the %0 volume on this hardware.
# These are the help strings for the sliders when the channel is muted.
HelpSM?????:You cannot adjust the %0 volume while it is muted.
# These are the normal help strings for the mute option buttons.
HelpOO1??1:This indicates if the %0 is muted.|MClick SELECT to select or deselect this option.
HelpOO1???:This indicates if %0 is muted.|MClick SELECT to select or deselect this option.
HelpOO2???/HelpOO3???:This indicates if the %0 socket is muted.|MClick SELECT to select or deselect this option.
HelpOO4???:This indicates if the %0 header is muted.|MClick SELECT to select or deselect this option.
HelpOO????:This indicates if the %0 channel is muted.|MClick SELECT to select or deselect this option.
HelpOI????:This indicates if %0 audio is muted.|MClick SELECT to select or deselect this option.
# These are the help strings for the mute option buttons for fixed channels.
HelpOFO1??1:You cannot mute the %0 on this hardware.
HelpOFO1???:You cannot mute %0 on this hardware.
HelpOFO2???/HelpOFO3???:You cannot mute the %0 socket on this hardware.
HelpOFO4???:You cannot mute the %0 header on this hardware.
HelpOFO????:You cannot mute the %0 channel on this hardware.
HelpOFI????:You cannot mute %0 audio on this hardware.
No preview for this file type
/* (0.06)
/* (1.00)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.68.
*
*/
#define Module_MajorVersion_CMHG 0.06
#define Module_MajorVersion_CMHG 1.00
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 24 Feb 2003
#define Module_Date_CMHG 28 Feb 2003
#define Module_MajorVersion "0.06"
#define Module_Version 6
#define Module_MajorVersion "1.00"
#define Module_Version 100
#define Module_MinorVersion ""
#define Module_Date "24 Feb 2003"
#define Module_Date "28 Feb 2003"
#define Module_ApplicationDate "24-Feb-03"
#define Module_ApplicationDate "28-Feb-03"
#define Module_ComponentName "SndSetup"
#define Module_ComponentPath "RiscOS/Sources/SystemRes/Configure2/PlugIns/SndSetup"
#define Module_FullVersion "0.06"
#define Module_HelpVersion "0.06 (24 Feb 2003)"
#define Module_LibraryVersionInfo "0:6"
#define Module_FullVersion "1.00"
#define Module_HelpVersion "1.00 (28 Feb 2003)"
#define Module_LibraryVersionInfo "1:0"
......@@ -29,13 +29,16 @@
#include "toolbox.h"
#include "gadgets.h"
#include "swis.h"
#include "common.h"
#include "defines.h"
#define Flag_GadgetFaded 1u<<31
char TaskName[30] = "?";
/* Global messages file descriptor and string pointer */
MessagesFD *message_block;
char *message_buffer;
static MessagesFD *message_block;
static char *message_buffer;
/*---------------------------------------------------------------------------*
......@@ -48,17 +51,7 @@ char *message_buffer;
* type - 0 means non-fatal, otherwise program will exit after reporting *
*---------------------------------------------------------------------------*/
void error_trap(_kernel_oserror *err, int err_type)
{
/* Report the appropriate error, has one occured */
if (err != NULL)
{
wimp_report_error(err, 0, TaskName, 0, 0, 0);
/* Now, if it was a fatal error (type != 0), exit at once */
if (err_type != 0) exit(0);
}
}
extern inline void error_trap(_kernel_oserror *err, int err_type);
/*---------------------------------------------------------------------------*
......@@ -74,6 +67,9 @@ void messages_register(MessagesFD *messagefd_point, char *messagebuff_point)
{
message_block = messagefd_point;
message_buffer = messagebuff_point;
char *taskname = messages_lookup("_TaskName");
strncpy(TaskName, taskname, sizeof TaskName - 1);
TaskName[sizeof TaskName - 1] = '\0';
}
......@@ -99,6 +95,29 @@ char* messages_lookup(char *token_string)
}
/*---------------------------------------------------------------------------*
* messages_lookup_withparam *
* *
* Searches the 'messages' file for the text represented by the token string *
* and returns a pointer to a buffer storing this text *
* *
* In: *
*---------------------------------------------------------------------------*/
const char* messages_lookup_withparam(const char *token_string, const char* parameter)
{
_kernel_swi_regs regs;
regs.r[0] = (int)message_block;
regs.r[1] = (int)token_string;
regs.r[2] = (int)message_buffer;
regs.r[3] = 255;
regs.r[4] = (int)parameter;
_kernel_swi(MessageTrans_Lookup, &regs, &regs);
return message_buffer;
}
/*---------------------------------------------------------------------------*
* common_read_screensize *
* *
......
......@@ -53,44 +53,14 @@ static void program_exit(void)
/*---------------------------------------------------------------------------*
* set_default_choices *
* *
* Fill in the default choices in the dialogue box. *
*---------------------------------------------------------------------------*/
static void set_default_choices(void)
{
int n;
/* Default volume level is 0 for each channel */
for (n=0; n<NumberOfChannels; n++)
{
error_trap(numberrange_set_value(0, config_window_id, n, 0), 0);
sound_set_volume(n, 0);
}
sound_set_cmos_defaults();
error_trap(stringset_set_selected(1, config_window_id, VoicesStringset, (char*)0), 0);
error_trap(radiobutton_set_state(0, config_window_id, LoudRadio, 1), 0);
}
/*---------------------------------------------------------------------------*
* restore_choices *
* try_system_beep *
* *
* Restore original choices. *
*---------------------------------------------------------------------------*/
static void restore_choices(void)
{
sound_read_choices(config_window_id);
sound_read_write_cmos_settings(WriteCMOSSettings, config_window_id);
}
static void try_system_beep(void)
{
printf("\07");
printf("\07");
}
......@@ -133,72 +103,6 @@ static int default_key_handler(int event_code, WimpPollBlock *event, IdBlock *id
}
/*---------------------------------------------------------------------------*
* radio_changed *
* *
* The quiet/loud radio button has changed state. *
*---------------------------------------------------------------------------*/
static int radio_changed(int event_code, ToolboxEvent *event_block, IdBlock *id_block, void *handle)
{
int state;
int selected;
int byte;
byte = read_cmos_value(CMOS_BellVolume);
error_trap(radiobutton_get_state(0, config_window_id, QuietRadio, &state, &selected), 0);
switch(selected)
{
case QuietRadio:
if (byte & 2) byte = byte^2;
break;
case LoudRadio:
if (!(byte & 2)) byte = byte^2;
break;
}
/* Beep */
write_cmos_value(CMOS_BellVolume, byte);
_kernel_osbyte(OSBYTE_ReadWriteBellVolume, selected == LoudRadio ? 0x80 : 0xd0, 0);
return 1;
}
/*---------------------------------------------------------------------------*
* voice_changed *
*---------------------------------------------------------------------------*/
static int voice_changed(int event_code, ToolboxEvent *event_block, IdBlock *id_block, void *handle)
{
int index;
error_trap(stringset_get_selected(1, config_window_id, VoicesStringset, &index), 0);
sound_change_voice(index);
return 1;
}
/*---------------------------------------------------------------------------*
* slider_value_changed *
* *
* The user has dragged a slider and changed it's value. *
*---------------------------------------------------------------------------*/
static int slider_value_changed(int event_code, ToolboxEvent *event_block, IdBlock *id_block, void *handle)
{
NumberRangeValueChangedEvent *event = (NumberRangeValueChangedEvent*)event_block;
int value = event->new_value;
int icon = id_block->self_component;
sound_set_volume(icon, value);
return 1;
}
/*---------------------------------------------------------------------------*
* action_selected *
* *
......@@ -214,18 +118,22 @@ static int action_selected(int event_code, ToolboxEvent *event_block, IdBlock *i
{
case SetButton:
sound_save_choices(config_window_id);
if ((block->hdr.flags & 7)==0) program_exit(); /* Return pressed */
if (block->hdr.flags & 4) program_exit(); /* Left button */
sound_read_write_cmos_settings(WriteCMOSSettings, config_window_id);
if ((block->hdr.flags & 1) == 0) program_exit(); /* Return or left button pressed */
sound_reset_to_configured(config_window_id);
break;
case CancelButton:
restore_choices();
if ((block->hdr.flags & 7)==0) program_exit(); /* Escape pressed */
if (block->hdr.flags & 4) program_exit(); /* Left button */
if ((block->hdr.flags & 1) == 0) /* Escape or left button pressed */
{
sound_restore_original_settings();
program_exit();
}
sound_reset_to_configured(config_window_id);
break;
case DefaultButton:
set_default_choices();
sound_reset_to_defaults(config_window_id);
break;
case TryButton:
......@@ -266,20 +174,6 @@ static int message_reopen(WimpMessage *event, void *handler)
}
/*---------------------------------------------------------------------------*
* close_window *
* *
* Called when user has clicked on close icon of window. *
*---------------------------------------------------------------------------*/
static int close_window(int event_code, WimpPollBlock *event, IdBlock *id_block, void *handle)
{
program_exit();
return 1;
}
/*----------------------------------------------------------------------------------------------*/
/* Program startup & polling loop */
/*----------------------------------------------------------------------------------------------*/
......@@ -295,32 +189,173 @@ static void open_configure_window(int at_x, int at_y)
BBox bbox;
int screenx;
int screeny;
int buffer[2];
WindowShowObjectBlock buffer;
const ComponentId stretch_gadgets[] = { BeepGroup, VoicesStringset };
const ComponentId move_gadgets[] = { DefaultButton, VoicesLabel, QuietRadio, LoudRadio };
/* Create window */
error_trap(toolbox_create_object(0, "Window", &config_window_id), 1);
/* Register handlers for the configure window */
error_trap(event_register_toolbox_handler(config_window_id, ActionButton_Selected, action_selected, NULL), 0);
error_trap(event_register_toolbox_handler(config_window_id, NumberRange_ValueChanged, slider_value_changed, NULL), 0);
error_trap(event_register_toolbox_handler(config_window_id, RadioButton_StateChanged, radio_changed, NULL), 0);
error_trap(event_register_toolbox_handler(config_window_id, StringSet_ValueChanged, voice_changed, NULL), 0);
error_trap(event_register_wimp_handler(config_window_id, Wimp_ECloseWindow, close_window, NULL), 0);
error_trap(event_register_toolbox_handler(config_window_id, OptionButton_StateChanged, sound_reflect_gadget_state, NULL), 0);
error_trap(event_register_toolbox_handler(config_window_id, RadioButton_StateChanged, sound_reflect_gadget_state, NULL), 0);
error_trap(event_register_toolbox_handler(config_window_id, Slider_ValueChanged, sound_reflect_gadget_state, NULL), 0);
error_trap(event_register_toolbox_handler(config_window_id, StringSet_ValueChanged, sound_reflect_gadget_state, NULL), 0);
error_trap(event_register_wimp_handler(-1, Wimp_EKeyPressed, default_key_handler, NULL), 0);
/* Do dynamic gadget creation and resizing */
error_trap(window_remove_gadget(0, config_window_id, TemplateLabel), 0);
error_trap(window_remove_gadget(0, config_window_id, TemplateButton), 0);
error_trap(window_remove_gadget(0, config_window_id, TemplateSlider), 0);
error_trap(window_remove_gadget(0, config_window_id, TemplateOption), 0);
ObjectTemplateHeader *object_template;
error_trap(toolbox_template_lookup(0, "Window", (void **)&object_template), 0);
const char *gadget_template[4];
size_t gadget_template_size[4];
error_trap(window_extract_gadget_info(0, object_template, TemplateLabel, (void **)&gadget_template[0], (int *)&gadget_template_size[0]), 0);
error_trap(window_extract_gadget_info(0, object_template, TemplateButton, (void **)&gadget_template[1], (int *)&gadget_template_size[1]), 0);
error_trap(window_extract_gadget_info(0, object_template, TemplateSlider, (void **)&gadget_template[2], (int *)&gadget_template_size[2]), 0);
error_trap(window_extract_gadget_info(0, object_template, TemplateOption, (void **)&gadget_template[3], (int *)&gadget_template_size[3]), 0);
size_t max_template_size = (gadget_template_size[0] > gadget_template_size[1]) ? gadget_template_size[0] : gadget_template_size[1];
if (gadget_template_size[2] > max_template_size) max_template_size = gadget_template_size[2];
if (gadget_template_size[3] > max_template_size) max_template_size = gadget_template_size[3];
char gadget[max_template_size];
memcpy(gadget, gadget_template[0], gadget_template_size[0]);
((Gadget *)gadget)->hdr.box.ymax += nchannels * SLIDER_HEIGHT;
((Gadget *)gadget)->hdr.box.ymin += nchannels * SLIDER_HEIGHT;
unsigned int widest_label = 0;
for (int i = 0; i < nchannels; i++)
{
char token[11] = "Name";
strcat(token, channel[i].token_suffix);
char param[4];
if (channel[i].token_suffix[4] == '1')
{
param[0] = '\0';
}
else
{
sprintf(param, " %d", channel[i].index + 1);
}
const char *name = messages_lookup_withparam(token, param);
char label[strlen(name) + 1];
strcpy(label, name);
unsigned int this_width = 0;
_swix(Wimp_TextOp, _INR(0,2)|_OUT(0),
1,
label,
0,
&this_width);
if (this_width > widest_label) widest_label = this_width;
((Gadget *)gadget)->hdr.box.ymax -= SLIDER_HEIGHT;
((Gadget *)gadget)->hdr.box.ymin -= SLIDER_HEIGHT;
((Gadget *)gadget)->hdr.component_id = i * 4;
sprintf(token, "HelpL%s", channel[i].token_suffix);
((Gadget *)gadget)->hdr.help_message = (char *)messages_lookup_withparam(token, channel[i].name);
((Gadget *)gadget)->data.label.label = label;
error_trap(window_add_gadget(0, config_window_id, (Gadget *)gadget, NULL), 0);
}
memcpy(gadget, gadget_template[1], gadget_template_size[1]);
((Gadget *)gadget)->hdr.box.ymax += nchannels * SLIDER_HEIGHT;
((Gadget *)gadget)->hdr.box.ymin += nchannels * SLIDER_HEIGHT;
for (int i = 0; i < nchannels; i++)
{
((Gadget *)gadget)->hdr.box.ymax -= SLIDER_HEIGHT;
((Gadget *)gadget)->hdr.box.ymin -= SLIDER_HEIGHT;
((Gadget *)gadget)->hdr.component_id = 1 + i * 4;
char token[11] = "HelpB";
strcat(token, channel[i].token_suffix);
((Gadget *)gadget)->hdr.help_message = (char *)messages_lookup_withparam(token, channel[i].name);
((Gadget *)gadget)->data.button.validation = channel[i].mono ? "R2;Smono" : "R2;Sstereo";
error_trap(window_add_gadget(0, config_window_id, (Gadget *)gadget, NULL), 0);
}
memcpy(gadget, gadget_template[2], gadget_template_size[2]);
((Gadget *)gadget)->hdr.box.ymax += nchannels * SLIDER_HEIGHT;
((Gadget *)gadget)->hdr.box.ymin += nchannels * SLIDER_HEIGHT;
for (int i = 0; i < nchannels; i++)
{
((Gadget *)gadget)->hdr.box.ymax -= SLIDER_HEIGHT;
((Gadget *)gadget)->hdr.box.ymin -= SLIDER_HEIGHT;
((Gadget *)gadget)->hdr.component_id = 2 + i * 4;
char token[12] = "HelpS";
if (channel[i].fixed) strcpy(token, "HelpSF");
strcat(token, channel[i].token_suffix);
((Gadget *)gadget)->hdr.help_message = (char *)messages_lookup_withparam(token, channel[i].name);
((Gadget *)gadget)->hdr.flags &= ~(Gadget_Faded | Slider_BarColour);
((Gadget *)gadget)->hdr.flags |= (channel[i].category >= 0 ? 10 : 11) << Slider_BarColourShift;
if (channel[i].fixed) ((Gadget *)gadget)->hdr.flags |= Gadget_Faded;
error_trap(window_add_gadget(0, config_window_id, (Gadget *)gadget, NULL), 0);
}
memcpy(gadget, gadget_template[3], gadget_template_size[3]);
((Gadget *)gadget)->hdr.box.ymax += nchannels * SLIDER_HEIGHT;
((Gadget *)gadget)->hdr.box.ymin += nchannels * SLIDER_HEIGHT;
for (int i = 0; i < nchannels; i++)
{
((Gadget *)gadget)->hdr.box.ymax -= SLIDER_HEIGHT;
((Gadget *)gadget)->hdr.box.ymin -= SLIDER_HEIGHT;
((Gadget *)gadget)->hdr.component_id = 3 + i * 4;
char token[12] = "HelpO";
if (channel[i].fixed) strcpy(token, "HelpOF");
strcat(token, channel[i].token_suffix);
((Gadget *)gadget)->hdr.help_message = (char *)messages_lookup_withparam(token, channel[i].name);
((Gadget *)gadget)->hdr.flags &= ~Gadget_Faded;
if (channel[i].fixed) ((Gadget *)gadget)->hdr.flags |= Gadget_Faded;
error_trap(window_add_gadget(0, config_window_id, (Gadget *)gadget, NULL), 0);
}
unsigned int stretch_width = ((Gadget *)gadget_template[0])->hdr.box.xmax - ((Gadget *)gadget_template[0])->hdr.box.xmin;
stretch_width = widest_label + /* fudge factor */ 16 - stretch_width;
error_trap(window_get_extent(0, config_window_id, &bbox), 0);
bbox.xmin -= stretch_width;
bbox.ymax += (nchannels - 1) * SLIDER_HEIGHT;
error_trap(window_set_extent(0, config_window_id, &bbox), 0);
for (ComponentId g = 0; g < 4 * nchannels; g+= 4)
{
BBox bbox;
error_trap(gadget_get_bbox(0, config_window_id, g, &bbox), 0);
bbox.xmin -= stretch_width;
error_trap(gadget_move_gadget(0, config_window_id, g, &bbox), 0);
}
for (int i = 0; i < (sizeof stretch_gadgets / sizeof *stretch_gadgets); i++)
{
BBox bbox;
error_trap(gadget_get_bbox(0, config_window_id, stretch_gadgets[i], &bbox), 0);
bbox.xmin -= stretch_width;
error_trap(gadget_move_gadget(0, config_window_id, stretch_gadgets[i], &bbox), 0);
}
for (int i = 0; i < (sizeof move_gadgets / sizeof *move_gadgets); i++)
{
BBox bbox;
error_trap(gadget_get_bbox(0, config_window_id, move_gadgets[i], &bbox), 0);
bbox.xmin -= stretch_width;
bbox.xmax -= stretch_width;
error_trap(gadget_move_gadget(0, config_window_id, move_gadgets[i], &bbox), 0);
}
/* Work out positioning (unless it was supplied in the command line) */
if ((at_x==-1) && (at_y==-1))
{
error_trap(common_read_screensize(&screenx, &screeny), 0);
error_trap(window_get_extent(0, config_window_id, &bbox), 0);
at_y = screeny - ((screeny+bbox.ymin)/2);
at_x = (screenx - bbox.xmax)/2;
at_y = (screeny + bbox.ymax - bbox.ymin) / 2;
at_x = (screenx - bbox.xmax + bbox.xmin) / 2;
}
/* Show the window */
buffer[0] = at_x;
buffer[1] = at_y;
error_trap(toolbox_show_object(0, config_window_id, 2, buffer, 0, 0), 0);
buffer.visible_area.xmin = at_x;
buffer.visible_area.ymax = at_y;
buffer.visible_area.xmax = at_x + bbox.xmax - bbox.xmin;
buffer.visible_area.ymin = at_y - bbox.ymax + bbox.ymin;
buffer.xscroll = 0;
buffer.yscroll = 0;
buffer.behind = -1;
error_trap(toolbox_show_object(0, config_window_id, 1, &buffer, 0, 0), 0);
}
......@@ -341,14 +376,15 @@ static int main_initialise(void)
0};
static int tbox_wanted[] = {Toolbox_Error,
ActionButton_Selected,
NumberRange_ValueChanged,
OptionButton_StateChanged,
RadioButton_StateChanged,
Slider_ValueChanged,
StringSet_ValueChanged,
0};
int task_handle;
error_trap(toolbox_initialise(0, 310, mess_wanted, tbox_wanted,
"<SoundConfig$Dir>", &messages_desc, &idb,
"<SndSetup$Dir>", &messages_desc, &idb,
0, &task_handle, 0) ,1);
error_trap(event_initialise(&idb), 0);
error_trap(event_set_mask(Wimp_Poll_NullMask), 0);
......@@ -384,11 +420,10 @@ int main(int argc, char *argv[])
/* Do main initialisation */
if (!main_initialise()) return 0;
sound_read_channel_info();
open_configure_window(openat_x, openat_y);
sound_make_voices_menu(config_window_id);
sound_read_channel_info(config_window_id);
sound_read_choices(config_window_id);
sound_read_write_cmos_settings(ReadCMOSSettings, config_window_id);
sound_reset_to_configured(config_window_id);
/* Poll loop */
while (TRUE)
......
This diff is collapsed.
......@@ -16,6 +16,10 @@
/* File: h.common */
/*---------------------------------------------------------------------------*/
#include "wimplib.h"
#include "defines.h"
#define NewLine 0x0A
#define Wimp_MOpenConfigWindow 0x50d83
......@@ -27,9 +31,10 @@ typedef struct
} evexp;
void error_trap(_kernel_oserror *err, int err_type);
inline void error_trap(_kernel_oserror *err, int err_type);
void messages_register(MessagesFD *messagefd_point, char *messagebuff_point);
char *messages_lookup(char *token_string);
const char* messages_lookup_withparam(const char *token_string, const char* parameter);
_kernel_oserror *common_read_screensize(int* x, int* y);
_kernel_oserror* common_error(char *s);
void grey_gadget(int objectid, int gadgetid);
......@@ -37,3 +42,28 @@ void ungrey_gadget(int objectid, int gadgetid);
int strncmpa(char* str1, char* str2, int size);
int read_cmos_value(int location);
void write_cmos_value(int location, int value);
extern char TaskName[];
/*---------------------------------------------------------------------------*
* error_trap *
* *
* Wrap around a function to report an error if one occurred eg.: *
* error_trap(event_initialise(&idb), 0); *
* *
* In: err - a kernel_oserror block *
* type - 0 means non-fatal, otherwise program will exit after reporting *
*---------------------------------------------------------------------------*/
inline void error_trap(_kernel_oserror *err, int err_type)
{
/* Report the appropriate error, has one occured */
if (err != NULL)
{
wimp_report_error(err, 0, TaskName, 0, 0, 0);
/* Now, if it was a fatal error (type != 0), exit at once */
if (err_type != 0) exit(0);
}
}
......@@ -17,13 +17,22 @@
/*---------------------------------------------------------------------------*/
/* Toolbox gadgets */
#define VoicesStringset 0x1a
#define QuietRadio 0x1e
#define LoudRadio 0x1f
#define DefaultButton 0x20
#define CancelButton 0x21
#define SetButton 0x22
#define TryButton 0x37
#define TemplateLabel ((ComponentId) 0x000)
#define TemplateButton ((ComponentId) 0x001)
#define TemplateSlider ((ComponentId) 0x002)
#define TemplateOption ((ComponentId) 0x003)
#define SetButton ((ComponentId) 0x100)
#define CancelButton ((ComponentId) 0x101)
#define DefaultButton ((ComponentId) 0x102)
#define BeepGroup ((ComponentId) 0x200)
#define VoicesLabel ((ComponentId) 0x201)
#define VoicesStringset ((ComponentId) 0x202)
#define QuietRadio ((ComponentId) 0x203)
#define LoudRadio ((ComponentId) 0x204)
#define TryButton ((ComponentId) 0x205)
/* Heigt offset between volume sliders (OS units) */
#define SLIDER_HEIGHT (56)
/* CMOS */
#define CMOS_BellVolume 0x10
......@@ -33,12 +42,7 @@
#define CMOS_Voice 0x94
#define CMOS_Speaker 0x94
/* Strings to output to file */
#define SoundConfigurationString "# Sound configuration"
#define VolumeLevelsString "# Volume levels"
/* Other stuff */
#define TaskName "Sound setup"
#define ChoicesDir "<Choices$Write>.Sound"
#define ChoicesFile "<Choices$Write>.Sound.Sound"
#define ScrapFile "<Wimp$ScrapDir>.Sound"
#define ChoicesWrite "<Choices$Write>.Boot.PreDesk.SndSetup"
#define ChoicesRead "Choices:Boot.PreDesk.SndSetup"
#define BlankChoices "<SndSetup$Dir>.Blank"
......@@ -16,18 +16,39 @@
/* File: h.sound */
/*---------------------------------------------------------------------------*/
#define NumberOfChannels 8
#include <stdbool.h>
#define ReadCMOSSettings 1
#define WriteCMOSSettings 2
#define OSBYTE_ReadWriteBellVolume 212
void sound_read_channel_info(int window_id);
#define MAX_CHANNELS 64 /* currently dictated by component IDs */
extern struct channel
{
char token_suffix[6];
char *name;
int category;
unsigned int index;
int original_gain; /* what to restore if the user SELECT-clicks Cancel */
bool original_mute;
int configured_gain; /* what to show if the user ADJUST-clicks Cancel */
bool configured_mute;
bool fixed;
bool mono;
bool muted_by_default;
}
channel[MAX_CHANNELS];
extern unsigned int nchannels;
void sound_read_channel_info(void);
void sound_make_voices_menu(int window_id);
void sound_read_write_cmos_settings(int condition_code, int window_id);
void sound_read_choices(int window_id);
void sound_set_volume(int channel_no, int volume);
void sound_save_choices(int window_id);
void sound_make_voices_menu(int window_id);
void sound_change_voice(int n);
void sound_set_cmos_defaults(void);
int sound_reflect_gadget_state(int event_code, ToolboxEvent *event_block, IdBlock *id_block, void *handle);
void sound_reset_to_configured(int window_id);
void sound_reset_to_defaults(int window_id);
void sound_restore_original_settings(void);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment