aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2019-01-16 17:22:42 -0500
committerPaul Duncan <pabs@pablotron.org>2019-01-16 17:22:42 -0500
commit0fd2a97e6f169468b3a48f996ba35cd70210baa0 (patch)
treea1df62f9225cd35ba6b947ce82031ad60b0a1fef
parente09c3840d46767c4c5d1e62303e80a5845696afc (diff)
downloadsok-0fd2a97e6f169468b3a48f996ba35cd70210baa0.tar.bz2
sok-0fd2a97e6f169468b3a48f996ba35cd70210baa0.zip
add src/sdl/sounds.[hc], assets/wavs, and set default sounds
-rw-r--r--assets/wavs/blip-0.wavbin0 -> 1501 bytes
-rw-r--r--assets/wavs/coin-0.wavbin0 -> 1395 bytes
-rw-r--r--assets/wavs/coin-1.wavbin0 -> 1252 bytes
-rw-r--r--assets/wavs/coin-2.wavbin0 -> 2919 bytes
-rw-r--r--assets/wavs/hit-0.wavbin0 -> 1293 bytes
-rw-r--r--assets/wavs/hit-1.wavbin0 -> 3119 bytes
-rw-r--r--assets/wavs/hit-2.wavbin0 -> 1314 bytes
-rw-r--r--assets/wavs/jump-0.wavbin0 -> 8558 bytes
-rw-r--r--assets/wavs/jump-1.wavbin0 -> 3190 bytes
-rw-r--r--assets/wavs/jump-2.wavbin0 -> 6002 bytes
-rw-r--r--assets/wavs/jump-3.wavbin0 -> 36826 bytes
-rw-r--r--assets/wavs/laser-0.wavbin0 -> 8397 bytes
-rw-r--r--assets/wavs/powerup-0.wavbin0 -> 12832 bytes
-rw-r--r--assets/wavs/powerup-1.wavbin0 -> 12946 bytes
-rw-r--r--assets/wavs/powerup-2.wavbin0 -> 8586 bytes
-rw-r--r--assets/wavs/powerup-3.wavbin0 -> 8406 bytes
-rw-r--r--assets/wavs/powerup-4.wavbin0 -> 2075 bytes
-rw-r--r--assets/wavs/powerup-5.wavbin0 -> 14335 bytes
-rw-r--r--assets/wavs/powerup-6.wavbin0 -> 16219 bytes
-rw-r--r--assets/wavs/undo-0.wavbin0 -> 1342 bytes
-rw-r--r--assets/wavs/undo-1.wavbin0 -> 1303 bytes
-rw-r--r--src/msi/sok.wxs11
-rw-r--r--src/sdl/action.c2
-rw-r--r--src/sdl/draw.c2
-rw-r--r--src/sdl/sounds.c47
-rw-r--r--src/sdl/sounds.h10
26 files changed, 70 insertions, 2 deletions
diff --git a/assets/wavs/blip-0.wav b/assets/wavs/blip-0.wav
new file mode 100644
index 0000000..d70e2ae
--- /dev/null
+++ b/assets/wavs/blip-0.wav
Binary files differ
diff --git a/assets/wavs/coin-0.wav b/assets/wavs/coin-0.wav
new file mode 100644
index 0000000..a4011b1
--- /dev/null
+++ b/assets/wavs/coin-0.wav
Binary files differ
diff --git a/assets/wavs/coin-1.wav b/assets/wavs/coin-1.wav
new file mode 100644
index 0000000..db9a8e1
--- /dev/null
+++ b/assets/wavs/coin-1.wav
Binary files differ
diff --git a/assets/wavs/coin-2.wav b/assets/wavs/coin-2.wav
new file mode 100644
index 0000000..fd8abca
--- /dev/null
+++ b/assets/wavs/coin-2.wav
Binary files differ
diff --git a/assets/wavs/hit-0.wav b/assets/wavs/hit-0.wav
new file mode 100644
index 0000000..7d80ded
--- /dev/null
+++ b/assets/wavs/hit-0.wav
Binary files differ
diff --git a/assets/wavs/hit-1.wav b/assets/wavs/hit-1.wav
new file mode 100644
index 0000000..6204c6e
--- /dev/null
+++ b/assets/wavs/hit-1.wav
Binary files differ
diff --git a/assets/wavs/hit-2.wav b/assets/wavs/hit-2.wav
new file mode 100644
index 0000000..b7b4977
--- /dev/null
+++ b/assets/wavs/hit-2.wav
Binary files differ
diff --git a/assets/wavs/jump-0.wav b/assets/wavs/jump-0.wav
new file mode 100644
index 0000000..e60eab8
--- /dev/null
+++ b/assets/wavs/jump-0.wav
Binary files differ
diff --git a/assets/wavs/jump-1.wav b/assets/wavs/jump-1.wav
new file mode 100644
index 0000000..e2f87cb
--- /dev/null
+++ b/assets/wavs/jump-1.wav
Binary files differ
diff --git a/assets/wavs/jump-2.wav b/assets/wavs/jump-2.wav
new file mode 100644
index 0000000..e8cc257
--- /dev/null
+++ b/assets/wavs/jump-2.wav
Binary files differ
diff --git a/assets/wavs/jump-3.wav b/assets/wavs/jump-3.wav
new file mode 100644
index 0000000..cc0acff
--- /dev/null
+++ b/assets/wavs/jump-3.wav
Binary files differ
diff --git a/assets/wavs/laser-0.wav b/assets/wavs/laser-0.wav
new file mode 100644
index 0000000..7fc08f0
--- /dev/null
+++ b/assets/wavs/laser-0.wav
Binary files differ
diff --git a/assets/wavs/powerup-0.wav b/assets/wavs/powerup-0.wav
new file mode 100644
index 0000000..bb41230
--- /dev/null
+++ b/assets/wavs/powerup-0.wav
Binary files differ
diff --git a/assets/wavs/powerup-1.wav b/assets/wavs/powerup-1.wav
new file mode 100644
index 0000000..0e9d375
--- /dev/null
+++ b/assets/wavs/powerup-1.wav
Binary files differ
diff --git a/assets/wavs/powerup-2.wav b/assets/wavs/powerup-2.wav
new file mode 100644
index 0000000..eb156af
--- /dev/null
+++ b/assets/wavs/powerup-2.wav
Binary files differ
diff --git a/assets/wavs/powerup-3.wav b/assets/wavs/powerup-3.wav
new file mode 100644
index 0000000..d72febd
--- /dev/null
+++ b/assets/wavs/powerup-3.wav
Binary files differ
diff --git a/assets/wavs/powerup-4.wav b/assets/wavs/powerup-4.wav
new file mode 100644
index 0000000..9af69db
--- /dev/null
+++ b/assets/wavs/powerup-4.wav
Binary files differ
diff --git a/assets/wavs/powerup-5.wav b/assets/wavs/powerup-5.wav
new file mode 100644
index 0000000..eab59d3
--- /dev/null
+++ b/assets/wavs/powerup-5.wav
Binary files differ
diff --git a/assets/wavs/powerup-6.wav b/assets/wavs/powerup-6.wav
new file mode 100644
index 0000000..203c7d3
--- /dev/null
+++ b/assets/wavs/powerup-6.wav
Binary files differ
diff --git a/assets/wavs/undo-0.wav b/assets/wavs/undo-0.wav
new file mode 100644
index 0000000..4e512ae
--- /dev/null
+++ b/assets/wavs/undo-0.wav
Binary files differ
diff --git a/assets/wavs/undo-1.wav b/assets/wavs/undo-1.wav
new file mode 100644
index 0000000..94b9a92
--- /dev/null
+++ b/assets/wavs/undo-1.wav
Binary files differ
diff --git a/src/msi/sok.wxs b/src/msi/sok.wxs
index b02bd50..7099390 100644
--- a/src/msi/sok.wxs
+++ b/src/msi/sok.wxs
@@ -186,6 +186,16 @@ adc88948-391e-48cf-8067-b002dcba4411
/>
</Component>
+ <Component Id='cmp-sdl2-mixer-dll' Guid='*'>
+ <File
+ Id='file-sdl2-mixer-dll'
+ Name='SDL2_mixer.dll'
+ DiskId='1'
+ Source='$(var.SDL_LIB_DIR)/SDL2_mixer.dll'
+ KeyPath='yes'
+ />
+ </Component>
+
<Component Id='cmp-sdl2-dll' Guid='*'>
<File
Id='file-sdl2-dll'
@@ -217,6 +227,7 @@ adc88948-391e-48cf-8067-b002dcba4411
<ComponentRef Id='cmp-text-exe'/>
<ComponentRef Id='cmp-libfreetype-dll'/>
<ComponentRef Id='cmp-sdl2-ttf-dll'/>
+ <ComponentRef Id='cmp-sdl2-mixer-dll'/>
<ComponentRef Id='cmp-sdl2-dll'/>
<ComponentRef Id='cmp-zlib1-dll'/>
</Feature>
diff --git a/src/sdl/action.c b/src/sdl/action.c
index 18badc1..bc0cf89 100644
--- a/src/sdl/action.c
+++ b/src/sdl/action.c
@@ -125,7 +125,7 @@ get_action(
};
break;
case SOLVE_EVENT_FAIL:
- warn("solve failed: %s", ev->user.data2 ? ev->user.data2 : "unknown error");
+ warn("solve failed: %s", ev->user.data2 ? (char*) ev->user.data2 : "unknown error");
return (action_t) { .type = ACTION_SOLVE_EVENT_FAIL };
break;
case SOLVE_EVENT_DONE:
diff --git a/src/sdl/draw.c b/src/sdl/draw.c
index 37d9ba2..d95e83f 100644
--- a/src/sdl/draw.c
+++ b/src/sdl/draw.c
@@ -291,7 +291,7 @@ draw_solve_moves_text(
char buf[1024];
// fill buffer
- snprintf(buf, sizeof(buf), " %lu attempts ", draw_ctx->solve_num_steps);
+ snprintf(buf, sizeof(buf), " %u attempts ", (unsigned int) draw_ctx->solve_num_steps);
// draw text
draw_text(draw_ctx->renderer, draw_ctx->font, style, buf);
diff --git a/src/sdl/sounds.c b/src/sdl/sounds.c
new file mode 100644
index 0000000..956229c
--- /dev/null
+++ b/src/sdl/sounds.c
@@ -0,0 +1,47 @@
+#include <SDL.h>
+#include "util.h"
+#include "assets.h"
+#include "sounds.h"
+
+#define SOUND_OFS(asset_id) ((asset_id) - ASSET_SOUND_FIRST - 1)
+
+void
+sounds_init(
+ Mix_Chunk ** const sounds
+) {
+ for (asset_id_t id = ASSET_SOUND_FIRST + 1; id < ASSET_SOUND_LAST; id++) {
+ // get asset
+ const asset_t * const asset = asset_get(id);
+
+ // create rwops
+ SDL_RWops *rw = SDL_RWFromConstMem(asset->buf, asset->len);
+ if (!rw) {
+ die("SDL_RWFromConstMem(): %s", SDL_GetError());
+ }
+
+ // load chunk
+ Mix_Chunk *chunk = Mix_LoadWAV_RW(rw, 1);
+ if (!chunk) {
+ die("Mix_LoadWAV_RW(): %s", Mix_GetError());
+ }
+
+ // add to list of sounds
+ sounds[SOUND_OFS(id)] = chunk;
+ }
+}
+
+void
+sound_play(
+ Mix_Chunk ** const sounds,
+ const asset_id_t id
+) {
+ // check ID
+ if (id <= ASSET_SOUND_FIRST || id >= ASSET_SOUND_LAST) {
+ die("invalid sound asset id: %u", id);
+ }
+
+ // play sound
+ if (Mix_PlayChannel(-1, sounds[SOUND_OFS(id)], 0)) {
+ die("Mix_PlayChannel(): %s", Mix_GetError());
+ }
+}
diff --git a/src/sdl/sounds.h b/src/sdl/sounds.h
new file mode 100644
index 0000000..3b74aff
--- /dev/null
+++ b/src/sdl/sounds.h
@@ -0,0 +1,10 @@
+#ifndef SOUNDS_H
+#define SOUNDS_H
+
+#include <SDL_mixer.h>
+#include "assets.h"
+
+void sounds_init(Mix_Chunk ** const);
+void sound_play(Mix_Chunk ** const sounds, const asset_id_t);
+
+#endif /* SOUNDS_H */