aboutsummaryrefslogtreecommitdiff
path: root/backends/PalmOS
diff options
context:
space:
mode:
authorChris Apers2004-09-12 13:32:58 +0000
committerChris Apers2004-09-12 13:32:58 +0000
commit262c6e0d8428fd0533bad1214be56f5e8128d4ee (patch)
treee1a27f09883452420ee29b8742235b412cae7207 /backends/PalmOS
parent2be4ef999fddab612b0435c7ad5eec7e92d91808 (diff)
downloadscummvm-rg350-262c6e0d8428fd0533bad1214be56f5e8128d4ee.tar.gz
scummvm-rg350-262c6e0d8428fd0533bad1214be56f5e8128d4ee.tar.bz2
scummvm-rg350-262c6e0d8428fd0533bad1214be56f5e8128d4ee.zip
- Music and sound options can now be defined for each games
svn-id: r15059
Diffstat (limited to 'backends/PalmOS')
-rw-r--r--backends/PalmOS/Src/forms/formmusic.cpp199
1 files changed, 150 insertions, 49 deletions
diff --git a/backends/PalmOS/Src/forms/formmusic.cpp b/backends/PalmOS/Src/forms/formmusic.cpp
index ecaf8e25b1..152a7ecc6c 100644
--- a/backends/PalmOS/Src/forms/formmusic.cpp
+++ b/backends/PalmOS/Src/forms/formmusic.cpp
@@ -3,10 +3,15 @@
#include "start.h"
#include "formTabs.h"
#include "forms.h"
+#include "games.h"
+
+#include "globals.h"
static TabType *myTabP;
static UInt16 lastTab = 0;
+static MusicInfoType *musicInfoP = NULL;
+
// Music
static Boolean MusicTabSave() {
ControlType *cck1P, *cck2P;
@@ -30,11 +35,11 @@ static Boolean MusicTabSave() {
return false;
}
- gPrefs->sound.music = CtlGetValue(cck1P);
- gPrefs->sound.multiMidi = CtlGetValue(cck2P);
+ musicInfoP->sound.music = CtlGetValue(cck1P);
+ musicInfoP->sound.multiMidi = CtlGetValue(cck2P);
- gPrefs->sound.drvMusic = LstGetSelection(list1P);
- gPrefs->sound.tempo = tempo;
+ musicInfoP->sound.drvMusic = LstGetSelection(list1P);
+ musicInfoP->sound.tempo = tempo;
return true;
}
@@ -51,15 +56,18 @@ static void MusicTabInit() {
list1P = (ListType *)GetObjectPtr(TabMusicDriverList);
fld1P = (FieldType *)GetObjectPtr(TabMusicTempoField);
- CtlSetValue(cck1P, gPrefs->sound.music);
- CtlSetValue(cck2P, gPrefs->sound.multiMidi);
+ CtlSetValue(cck1P, musicInfoP->sound.music);
+ CtlSetValue(cck2P, musicInfoP->sound.multiMidi);
- LstSetSelection(list1P, gPrefs->sound.drvMusic);
+ if (musicInfoP->sound.drvMusic > 4)
+ musicInfoP->sound.drvMusic = 0;
+
+ LstSetSelection(list1P, musicInfoP->sound.drvMusic);
CtlSetLabel((ControlType *)GetObjectPtr(TabMusicDriverPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
tempoH = MemHandleNew(FldGetMaxChars(fld1P)+1);
tempoP = (Char *)MemHandleLock(tempoH);
- StrIToA(tempoP, gPrefs->sound.tempo);
+ StrIToA(tempoP, musicInfoP->sound.tempo);
MemHandleUnlock(tempoH);
FldSetTextHandle(fld1P, tempoH);
}
@@ -67,34 +75,43 @@ static void MusicTabInit() {
// Sound
static void SoundTabSave() {
ControlType *cck1P;
-
+ ListType *list1P;
+
cck1P = (ControlType *)GetObjectPtr(TabSoundSoundCheckbox);
- gPrefs->sound.sfx = CtlGetValue(cck1P);
+ list1P = (ListType *)GetObjectPtr(TabSoundRateList);
+
+ musicInfoP->sound.sfx = CtlGetValue(cck1P);
+ musicInfoP->sound.rate = LstGetSelection(list1P);
}
static void SoundTabInit() {
ControlType *cck1P;
+ ListType *list1P;
cck1P = (ControlType *)GetObjectPtr(TabSoundSoundCheckbox);
- CtlSetValue(cck1P, gPrefs->sound.sfx);
+ list1P = (ListType *)GetObjectPtr(TabSoundRateList);
+
+ CtlSetValue(cck1P, musicInfoP->sound.sfx);
+ LstSetSelection(list1P, musicInfoP->sound.rate);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabSoundRatePopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
}
// Audio CD
static Boolean AudioCDTabSave() {
- ControlType *cck3P, *cck4P;
+ ControlType *cck3P;
FieldType *fld2P, *fld3P;
- ListType *list1P;
+ ListType *list1P, *list2P;
UInt16 firstTrack;
FormPtr frmP;
frmP = FrmGetActiveForm();
cck3P = (ControlType *)GetObjectPtr(TabAudioCDMP3Checkbox);
- cck4P = (ControlType *)GetObjectPtr(TabAudioCDTrackLengthCheckbox);
fld2P = (FieldType *)GetObjectPtr(TabAudioCDLengthSecsField);
fld3P = (FieldType *)GetObjectPtr(TabAudioCDFirstTrackField);
list1P = (ListType *)GetObjectPtr(TabAudioCDDriverList);
-
+ list2P = (ListType *)GetObjectPtr(TabAudioCDFormatList);
+
firstTrack = StrAToI(FldGetTextPtr(fld3P));
if (firstTrack < 1 || firstTrack > 999) {
TabSetActive(frmP, myTabP, 2);
@@ -103,97 +120,140 @@ static Boolean AudioCDTabSave() {
return false;
}
- gPrefs->sound.CD = CtlGetValue(cck3P);
- gPrefs->sound.setDefaultTrackLength = CtlGetValue(cck4P);
+ musicInfoP->sound.CD = CtlGetValue(cck3P);
- gPrefs->sound.drvCD = LstGetSelection(list1P);
+ musicInfoP->sound.drvCD = LstGetSelection(list1P);
+ musicInfoP->sound.frtCD = LstGetSelection(list2P);
- gPrefs->sound.defaultTrackLength = StrAToI(FldGetTextPtr(fld2P));
- gPrefs->sound.firstTrack = firstTrack;
+ musicInfoP->sound.defaultTrackLength = StrAToI(FldGetTextPtr(fld2P));
+ musicInfoP->sound.firstTrack = firstTrack;
return true;
}
static void AudioCDTabInit() {
- ControlType *cck3P, *cck4P;
+ ControlType *cck3P;
FieldType *fld2P, *fld3P;
- ListType *list1P;
+ ListType *list1P, *list2P;
MemHandle lengthH, firstTrackH;
Char *lengthP, *firstTrackP;
cck3P = (ControlType *)GetObjectPtr(TabAudioCDMP3Checkbox);
- cck4P = (ControlType *)GetObjectPtr(TabAudioCDTrackLengthCheckbox);
fld2P = (FieldType *)GetObjectPtr(TabAudioCDLengthSecsField);
fld3P = (FieldType *)GetObjectPtr(TabAudioCDFirstTrackField);
list1P = (ListType *)GetObjectPtr(TabAudioCDDriverList);
+ list2P = (ListType *)GetObjectPtr(TabAudioCDFormatList);
- LstSetSelection(list1P, gPrefs->sound.drvCD);
+ LstSetSelection(list1P, musicInfoP->sound.drvCD);
CtlSetLabel((ControlType *)GetObjectPtr(TabAudioCDDriverPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
- CtlSetValue(cck3P, gPrefs->sound.CD);
- CtlSetValue(cck4P, gPrefs->sound.setDefaultTrackLength);
+ LstSetSelection(list2P, musicInfoP->sound.frtCD);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabAudioCDFormatPopTrigger), LstGetSelectionText(list2P, LstGetSelection(list2P)));
+
+ CtlSetValue(cck3P, musicInfoP->sound.CD);
lengthH = MemHandleNew(FldGetMaxChars(fld2P)+1);
lengthP = (Char *)MemHandleLock(lengthH);
- StrIToA(lengthP, gPrefs->sound.defaultTrackLength);
+ StrIToA(lengthP, musicInfoP->sound.defaultTrackLength);
MemHandleUnlock(lengthH);
FldSetTextHandle(fld2P, lengthH);
firstTrackH = MemHandleNew(FldGetMaxChars(fld3P)+1);
firstTrackP = (Char *)MemHandleLock(firstTrackH);
- StrIToA(firstTrackP, gPrefs->sound.firstTrack);
+ StrIToA(firstTrackP, musicInfoP->sound.firstTrack);
MemHandleUnlock(firstTrackH);
FldSetTextHandle(fld3P, firstTrackH);
}
// Volume
static void VolumeTabSave() {
- SliderControlType *slid1P, *slid2P, *slid3P, *slid4P;
+ SliderControlType *slid1P, *slid2P, *slid3P, *slid4P, *slid5P;
slid1P = (SliderControlType *)GetObjectPtr(TabVolumeMasterSliderControl);
slid2P = (SliderControlType *)GetObjectPtr(TabVolumeMusicSliderControl);
slid3P = (SliderControlType *)GetObjectPtr(TabVolumeSfxSliderControl);
slid4P = (SliderControlType *)GetObjectPtr(TabVolumeSpeechSliderControl);
-
- CtlGetSliderValues ((ControlType *)slid1P, 0, 0, 0, &gPrefs->volume.master);
- CtlGetSliderValues ((ControlType *)slid2P, 0, 0, 0, &gPrefs->volume.music);
- CtlGetSliderValues ((ControlType *)slid3P, 0, 0, 0, &gPrefs->volume.sfx);
- CtlGetSliderValues ((ControlType *)slid4P, 0, 0, 0, &gPrefs->volume.speech);
+ slid5P = (SliderControlType *)GetObjectPtr(TabVolumeAudioCDSliderControl);
+
+ CtlGetSliderValues ((ControlType *)slid1P, 0, 0, 0, &musicInfoP->volume.master);
+ CtlGetSliderValues ((ControlType *)slid2P, 0, 0, 0, &musicInfoP->volume.music);
+ CtlGetSliderValues ((ControlType *)slid3P, 0, 0, 0, &musicInfoP->volume.sfx);
+ CtlGetSliderValues ((ControlType *)slid4P, 0, 0, 0, &musicInfoP->volume.speech);
+ CtlGetSliderValues ((ControlType *)slid5P, 0, 0, 0, &musicInfoP->volume.audiocd);
}
static void VolumeTabInit() {
- SliderControlType *slid1P, *slid2P, *slid3P, *slid4P;
+ SliderControlType *slid1P, *slid2P, *slid3P, *slid4P, *slid5P;
UInt16 value;
slid1P = (SliderControlType *)GetObjectPtr(TabVolumeMasterSliderControl);
slid2P = (SliderControlType *)GetObjectPtr(TabVolumeMusicSliderControl);
slid3P = (SliderControlType *)GetObjectPtr(TabVolumeSfxSliderControl);
slid4P = (SliderControlType *)GetObjectPtr(TabVolumeSpeechSliderControl);
+ slid5P = (SliderControlType *)GetObjectPtr(TabVolumeAudioCDSliderControl);
- value = gPrefs->volume.master;
+ value = musicInfoP->volume.master;
CtlSetSliderValues ((ControlType *)slid1P, 0, 0, 0, &value);
- value = gPrefs->volume.music;
+ value = musicInfoP->volume.music;
CtlSetSliderValues ((ControlType *)slid2P, 0, 0, 0, &value);
- value = gPrefs->volume.sfx;
+ value = musicInfoP->volume.sfx;
CtlSetSliderValues ((ControlType *)slid3P, 0, 0, 0, &value);
- value = gPrefs->volume.speech;
+ value = musicInfoP->volume.speech;
CtlSetSliderValues ((ControlType *)slid4P, 0, 0, 0, &value);
+ value = musicInfoP->volume.audiocd;
+ CtlSetSliderValues ((ControlType *)slid5P, 0, 0, 0, &value);
}
-static void MusicFormSave() {
- if (!MusicTabSave()) return;
- SoundTabSave();
- if (!AudioCDTabSave()) return;
- VolumeTabSave();
+static void MusicFormSave(UInt16 index) {
+ if (index != dmMaxRecordIndex) {
+ MemHandle recordH;
+ GameInfoType *gameInfoP;
+
+ if (!MusicTabSave()) return;
+ SoundTabSave();
+ if (!AudioCDTabSave()) return;
+ VolumeTabSave();
+
+ recordH = DmGetRecord(gameDB, index);
+ gameInfoP = (GameInfoType *)MemHandleLock(recordH);
+ DmWrite(gameInfoP, OffsetOf(GameInfoType, musicInfo), musicInfoP, sizeof(MusicInfoType));
+ MemHandleUnlock(recordH);
+ DmReleaseRecord (gameDB, index, 0);
+ }
+
+ MemPtrFree(musicInfoP);
+ musicInfoP = NULL;
TabDeleteTabs(myTabP);
FrmReturnToMain();
}
-static void MusicFormInit() {
+static void MusicFormInit(UInt16 index) {
TabType *tabP;
FormType *frmP = FrmGetActiveForm();
+ if (index != dmMaxRecordIndex) {
+ MemHandle recordH = NULL;
+ GameInfoType *gameInfoP;
+
+ recordH = DmQueryRecord(gameDB, index);
+ gameInfoP = (GameInfoType *)MemHandleLock(recordH);
+
+ if (!gameInfoP) {
+ FrmCustomAlert(FrmErrorAlert, "An error occured.",0,0);
+ return;
+ }
+
+ musicInfoP = (MusicInfoType *)MemPtrNew(sizeof(MusicInfoType));
+ MemMove(musicInfoP, &gameInfoP->musicInfo, sizeof(MusicInfoType));
+ MemHandleUnlock(recordH);
+
+ } else {
+ FrmCustomAlert(FrmWarnAlert, "Select an entry first.",0,0);
+ FrmReturnToMain();
+ return;
+ }
+
tabP = TabNewTabs(4);
TabAddContent(&frmP, tabP, "Music", TabMusicForm);
TabAddContent(&frmP, tabP, "Sound", TabSoundForm);
@@ -217,7 +277,7 @@ Boolean MusicFormHandleEvent(EventPtr eventP) {
switch (eventP->eType) {
case frmOpenEvent:
- MusicFormInit();
+ MusicFormInit(GamGetSelected());
handled = true;
break;
@@ -235,20 +295,61 @@ Boolean MusicFormHandleEvent(EventPtr eventP) {
case TabMusicDriverPopTrigger:
FrmList(eventP, TabMusicDriverList);
FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabMusicDriverList));
+
+ if (!OPTIONS_TST(kOptDeviceZodiac) && !OPTIONS_TST(kOptSonyPa1LibAPI)) {
+ ListType *list1P = (ListType *)GetObjectPtr(TabMusicDriverList);
+
+ if (LstGetSelection(list1P) == 1) {
+ FrmCustomAlert(FrmInfoAlert, "There is no built-in MIDI support on your device.", 0, 0);
+ LstSetSelection(list1P, 0);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabMusicDriverPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
+ }
+ }
+ break;
+
+ case TabSoundRatePopTrigger:
+ FrmList(eventP, TabSoundRateList);
+ FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabSoundRateList));
+
+ if (!OPTIONS_TST(kOptPalmSoundAPI)) {
+ ListType *list1P = (ListType *)GetObjectPtr(TabSoundRateList);
+
+ if (LstGetSelection(list1P) != 0) {
+ FrmCustomAlert(FrmInfoAlert, "You cannot use this rate on your device.", 0, 0);
+ LstSetSelection(list1P, 0);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabSoundRatePopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
+ }
+ }
+ break;
+
+ case TabAudioCDFormatPopTrigger:
+ FrmList(eventP, TabAudioCDFormatList);
+ FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabAudioCDFormatList));
+
+ if (LstGetSelection((ListPtr)GetObjectPtr(TabAudioCDDriverList)) == 1) {
+ ListType *list1P = (ListType *)GetObjectPtr(TabAudioCDFormatList);
+ LstSetSelection(list1P, 0);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabAudioCDFormatPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
+ }
break;
case TabAudioCDDriverPopTrigger:
FrmList(eventP, TabAudioCDDriverList);
FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabAudioCDDriverList));
+
+ if (LstGetSelection((ListPtr)GetObjectPtr(TabAudioCDDriverList)) == 1) {
+ ListType *list1P = (ListType *)GetObjectPtr(TabAudioCDFormatList);
+ LstSetSelection(list1P, 0);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabAudioCDFormatPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
+ }
break;
case MusicOKButton:
- MusicFormSave();
+ MusicFormSave(GamGetSelected());
break;
case MusicCancelButton:
- TabDeleteTabs(myTabP);
- FrmReturnToMain();
+ MusicFormSave(dmMaxRecordIndex);
break;
}
handled = true;