Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
openjazz
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
openjazz
Commits
2334cb55
Commit
2334cb55
authored
Mar 27, 2010
by
alistert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made sound effect volume adjustable.
parent
7cb1543f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
20 deletions
+82
-20
sound.cpp
src/io/sound.cpp
+2
-2
sound.h
src/io/sound.h
+11
-3
main.cpp
src/main.cpp
+22
-10
menu.h
src/menu/menu.h
+1
-0
setupmenu.cpp
src/menu/setupmenu.cpp
+43
-2
wiz.cpp
src/platforms/wiz.cpp
+3
-3
No files found.
src/io/sound.cpp
View file @
2334cb55
...
@@ -82,7 +82,7 @@ void audioCallback (void * userdata, unsigned char * stream, int len) {
...
@@ -82,7 +82,7 @@ void audioCallback (void * userdata, unsigned char * stream, int len) {
SDL_MixAudio
(
stream
,
SDL_MixAudio
(
stream
,
sounds
[
count
].
data
+
sounds
[
count
].
position
,
len
,
sounds
[
count
].
data
+
sounds
[
count
].
position
,
len
,
SDL_MIX_MAXVOLUME
>>
2
);
soundsVolume
*
SDL_MIX_MAXVOLUME
/
MAX_VOLUME
);
sounds
[
count
].
position
+=
len
;
sounds
[
count
].
position
+=
len
;
...
@@ -93,7 +93,7 @@ void audioCallback (void * userdata, unsigned char * stream, int len) {
...
@@ -93,7 +93,7 @@ void audioCallback (void * userdata, unsigned char * stream, int len) {
SDL_MixAudio
(
stream
,
SDL_MixAudio
(
stream
,
sounds
[
count
].
data
+
sounds
[
count
].
position
,
sounds
[
count
].
data
+
sounds
[
count
].
position
,
sounds
[
count
].
length
-
sounds
[
count
].
position
,
sounds
[
count
].
length
-
sounds
[
count
].
position
,
SDL_MIX_MAXVOLUME
>>
2
);
soundsVolume
*
SDL_MIX_MAXVOLUME
/
MAX_VOLUME
);
sounds
[
count
].
position
=
-
1
;
sounds
[
count
].
position
=
-
1
;
...
...
src/io/sound.h
View file @
2334cb55
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -50,6 +50,8 @@
...
@@ -50,6 +50,8 @@
#define S_ROCKET 18
#define S_ROCKET 18
#define S_STOP 19
#define S_STOP 19
#define S_BLOCK 20
#define S_BLOCK 20
#define MAX_VOLUME 100
// Datatype
// Datatype
...
@@ -67,8 +69,14 @@ typedef struct {
...
@@ -67,8 +69,14 @@ typedef struct {
// Variables
// Variables
EXTERN
Sound
*
sounds
;
EXTERN
Sound
*
sounds
;
EXTERN
int
nSounds
;
EXTERN
int
nSounds
;
EXTERN
char
soundsVolume
;
#if defined(WIZ) || defined(GP2X)
EXTERN
int
volume
;
EXTERN
int
volume_direction
;
#endif
// Functions
// Functions
...
...
src/main.cpp
View file @
2334cb55
...
@@ -48,9 +48,7 @@
...
@@ -48,9 +48,7 @@
#include <string.h>
#include <string.h>
#if defined(WIZ) || defined(GP2X)
#if defined(WIZ) || defined(GP2X)
#include "platforms/wiz.h"
#include "platforms/wiz.h"
extern
int
volume
;
extern
int
volume_direction
;
#endif
#endif
#ifdef __SYMBIAN32__
#ifdef __SYMBIAN32__
...
@@ -58,7 +56,7 @@ extern char KOpenJazzPath[256];
...
@@ -58,7 +56,7 @@ extern char KOpenJazzPath[256];
#endif
#endif
#ifdef SCALE
#ifdef SCALE
#include "io/gfx/scale2x/scalebit.h"
#include "io/gfx/scale2x/scalebit.h"
#endif
#endif
int
loadMain
(
int
argc
,
char
*
argv
[])
{
int
loadMain
(
int
argc
,
char
*
argv
[])
{
...
@@ -83,11 +81,11 @@ int loadMain (int argc, char *argv[]) {
...
@@ -83,11 +81,11 @@ int loadMain (int argc, char *argv[]) {
#ifdef __SYMBIAN32__
#ifdef __SYMBIAN32__
#ifdef UIQ3
#ifdef UIQ3
firstPath
=
new
Path
(
firstPath
,
createString
(
"c:
\\
shared
\\
openjazz
\\
"
));
firstPath
=
new
Path
(
firstPath
,
createString
(
"c:
\\
shared
\\
openjazz
\\
"
));
#else
#else
firstPath
=
new
Path
(
firstPath
,
createString
(
"c:
\\
data
\\
openjazz
\\
"
));
firstPath
=
new
Path
(
firstPath
,
createString
(
"c:
\\
data
\\
openjazz
\\
"
));
#endif
#endif
firstPath
=
new
Path
(
firstPath
,
createString
(
KOpenJazzPath
));
firstPath
=
new
Path
(
firstPath
,
createString
(
KOpenJazzPath
));
#endif
#endif
...
@@ -144,9 +142,9 @@ int loadMain (int argc, char *argv[]) {
...
@@ -144,9 +142,9 @@ int loadMain (int argc, char *argv[]) {
#ifdef HOMEDIR
#ifdef HOMEDIR
#ifdef WIN32
#ifdef WIN32
firstPath
=
new
Path
(
firstPath
,
createString
(
getenv
(
"HOME"
),
"
\\
"
));
firstPath
=
new
Path
(
firstPath
,
createString
(
getenv
(
"HOME"
),
"
\\
"
));
#else
#else
firstPath
=
new
Path
(
firstPath
,
createString
(
getenv
(
"HOME"
),
"/."
));
firstPath
=
new
Path
(
firstPath
,
createString
(
getenv
(
"HOME"
),
"/."
));
#endif
#endif
#endif
#endif
...
@@ -165,7 +163,14 @@ int loadMain (int argc, char *argv[]) {
...
@@ -165,7 +163,14 @@ int loadMain (int argc, char *argv[]) {
#ifndef FULLSCREEN_ONLY
#ifndef FULLSCREEN_ONLY
fullscreen
=
false
;
fullscreen
=
false
;
#endif
#endif
// Sound settings
#if defined(WIZ) || defined(GP2X)
volume
=
40
;
#endif
soundsVolume
=
MAX_VOLUME
>>
2
;
// Create the player's name
// Create the player's name
characterName
=
createEditableString
(
CHAR_NAME
);
characterName
=
createEditableString
(
CHAR_NAME
);
...
@@ -229,6 +234,10 @@ int loadMain (int argc, char *argv[]) {
...
@@ -229,6 +234,10 @@ int loadMain (int argc, char *argv[]) {
characterCols
[
2
]
=
file
->
loadChar
();
characterCols
[
2
]
=
file
->
loadChar
();
characterCols
[
3
]
=
file
->
loadChar
();
characterCols
[
3
]
=
file
->
loadChar
();
// Read the sound effect volume
soundsVolume
=
file
->
loadChar
();
if
(
soundsVolume
>
MAX_VOLUME
)
soundsVolume
=
MAX_VOLUME
;
delete
file
;
delete
file
;
}
else
{
}
else
{
...
@@ -538,6 +547,9 @@ void freeMain () {
...
@@ -538,6 +547,9 @@ void freeMain () {
file
->
storeChar
(
characterCols
[
2
]);
file
->
storeChar
(
characterCols
[
2
]);
file
->
storeChar
(
characterCols
[
3
]);
file
->
storeChar
(
characterCols
[
3
]);
// Write the sound effect volume
file
->
storeChar
(
soundsVolume
);
delete
file
;
delete
file
;
}
else
{
}
else
{
...
...
src/menu/menu.h
View file @
2334cb55
...
@@ -57,6 +57,7 @@ class Menu {
...
@@ -57,6 +57,7 @@ class Menu {
#ifdef SCALE
#ifdef SCALE
int
setupScaling
();
int
setupScaling
();
#endif
#endif
int
setupSound
();
public
:
public
:
SDL_Color
palettes
[
4
][
256
];
SDL_Color
palettes
[
4
][
256
];
...
...
src/menu/setupmenu.cpp
View file @
2334cb55
...
@@ -461,9 +461,44 @@ int Menu::setupScaling () {
...
@@ -461,9 +461,44 @@ int Menu::setupScaling () {
#endif
#endif
int
Menu
::
setupSound
()
{
while
(
true
)
{
if
(
loop
(
NORMAL_LOOP
)
==
E_QUIT
)
return
E_QUIT
;
if
(
controls
.
release
(
C_ESCAPE
))
return
E_NONE
;
if
(
controls
.
release
(
C_ENTER
))
return
E_NONE
;
SDL_Delay
(
T_FRAME
);
clearScreen
(
0
);
// Volume
fontmn2
->
mapPalette
(
240
,
8
,
114
,
16
);
fontmn2
->
showString
(
"effect volume"
,
canvasW
>>
2
,
canvasH
>>
1
);
fontmn2
->
restorePalette
();
drawRect
((
canvasW
>>
2
)
+
120
,
canvasH
>>
1
,
soundsVolume
>>
1
,
11
,
175
);
if
(
controls
.
release
(
C_LEFT
))
soundsVolume
-=
4
;
if
(
soundsVolume
<
0
)
soundsVolume
=
0
;
if
(
controls
.
release
(
C_RIGHT
))
soundsVolume
+=
4
;
if
(
soundsVolume
>
MAX_VOLUME
)
soundsVolume
=
MAX_VOLUME
;
}
return
E_NONE
;
}
int
Menu
::
setup
()
{
int
Menu
::
setup
()
{
const
char
*
setupOptions
[
5
]
=
{
"character"
,
"keyboard"
,
"joystick"
,
"resolution"
,
"scaling
"
};
const
char
*
setupOptions
[
6
]
=
{
"character"
,
"keyboard"
,
"joystick"
,
"resolution"
,
"scaling"
,
"sound
"
};
const
char
*
setupCharacterOptions
[
5
]
=
{
"name"
,
"fur"
,
"bandana"
,
"gun"
,
"wristband"
};
const
char
*
setupCharacterOptions
[
5
]
=
{
"name"
,
"fur"
,
"bandana"
,
"gun"
,
"wristband"
};
const
char
*
setupCharacterColOptions
[
8
]
=
{
"white"
,
"red"
,
"orange"
,
"yellow"
,
"green"
,
"blue"
,
"animation 1"
,
"animation 2"
};
const
char
*
setupCharacterColOptions
[
8
]
=
{
"white"
,
"red"
,
"orange"
,
"yellow"
,
"green"
,
"blue"
,
"animation 1"
,
"animation 2"
};
const
unsigned
char
setupCharacterCols
[
8
]
=
{
PC_WHITE
,
PC_RED
,
PC_ORANGE
,
const
unsigned
char
setupCharacterCols
[
8
]
=
{
PC_WHITE
,
PC_RED
,
PC_ORANGE
,
...
@@ -475,7 +510,7 @@ int Menu::setup () {
...
@@ -475,7 +510,7 @@ int Menu::setup () {
while
(
true
)
{
while
(
true
)
{
ret
=
generic
(
setupOptions
,
5
,
&
option
);
ret
=
generic
(
setupOptions
,
6
,
&
option
);
if
(
ret
==
E_UNUSED
)
return
E_NONE
;
if
(
ret
==
E_UNUSED
)
return
E_NONE
;
if
(
ret
<
0
)
return
ret
;
if
(
ret
<
0
)
return
ret
;
...
@@ -553,6 +588,12 @@ int Menu::setup () {
...
@@ -553,6 +588,12 @@ int Menu::setup () {
break
;
break
;
case
5
:
setupSound
();
break
;
}
}
}
}
...
...
src/platforms/wiz.cpp
View file @
2334cb55
...
@@ -6,9 +6,9 @@
...
@@ -6,9 +6,9 @@
#include <fcntl.h>
#include <fcntl.h>
#include <unistd.h>
#include <unistd.h>
int
volume
=
40
;
#include "io/sound.h"
int
volume_direction
;
void
WIZ_AdjustVolume
(
int
direction
)
void
WIZ_AdjustVolume
(
int
direction
)
{
{
if
(
direction
!=
VOLUME_NOCHG
)
if
(
direction
!=
VOLUME_NOCHG
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment