diff options
-rw-r--r-- | Data/sounds/BodyHit.ogg (renamed from Data/Sounds/BodyHit.ogg) | bin | 6109 -> 6109 bytes | |||
-rw-r--r-- | Data/sounds/Lose.ogg (renamed from Data/Sounds/Lose.ogg) | bin | 13958 -> 13958 bytes | |||
-rw-r--r-- | Data/sounds/Nearbullet.ogg (renamed from Data/Sounds/Nearbullet.ogg) | bin | 6408 -> 6408 bytes | |||
-rw-r--r-- | Data/sounds/SW.ogg (renamed from Data/Sounds/SW.ogg) | bin | 11795 -> 11795 bytes | |||
-rw-r--r-- | Data/sounds/WallHit.ogg (renamed from Data/Sounds/WallHit.ogg) | bin | 10136 -> 10136 bytes | |||
-rw-r--r-- | Data/sounds/bodyland.ogg (renamed from Data/Sounds/bodyland.ogg) | bin | 8736 -> 8736 bytes | |||
-rw-r--r-- | Data/sounds/bounce.ogg (renamed from Data/Sounds/bounce.ogg) | bin | 5327 -> 5327 bytes | |||
-rw-r--r-- | Data/sounds/bounce2.ogg (renamed from Data/Sounds/bounce2.ogg) | bin | 5190 -> 5190 bytes | |||
-rw-r--r-- | Data/sounds/click.ogg (renamed from Data/Sounds/click.ogg) | bin | 4271 -> 4271 bytes | |||
-rw-r--r-- | Data/sounds/disguise-kill.ogg (renamed from Data/Sounds/DisguiseKill.ogg) | bin | 7634 -> 7634 bytes | |||
-rw-r--r-- | Data/sounds/explosion.ogg (renamed from Data/Sounds/explosion.ogg) | bin | 35756 -> 35756 bytes | |||
-rw-r--r-- | Data/sounds/footstep1.ogg (renamed from Data/Sounds/footstep1.ogg) | bin | 5861 -> 5861 bytes | |||
-rw-r--r-- | Data/sounds/footstep2.ogg (renamed from Data/Sounds/footstep2.ogg) | bin | 6096 -> 6096 bytes | |||
-rw-r--r-- | Data/sounds/footstep3.ogg (renamed from Data/Sounds/footstep3.ogg) | bin | 6667 -> 6667 bytes | |||
-rw-r--r-- | Data/sounds/footstep4.ogg (renamed from Data/Sounds/footstep4.ogg) | bin | 5831 -> 5831 bytes | |||
-rw-r--r-- | Data/sounds/footstep5.ogg (renamed from Data/Sounds/footstep5.ogg) | bin | 5547 -> 5547 bytes | |||
-rw-r--r-- | Data/sounds/glock.ogg (renamed from Data/Sounds/glock.ogg) | bin | 13347 -> 13347 bytes | |||
-rw-r--r-- | Data/sounds/handlerelease.ogg (renamed from Data/Sounds/handlerelease.ogg) | bin | 5118 -> 5118 bytes | |||
-rw-r--r-- | Data/sounds/headland.ogg (renamed from Data/Sounds/headland.ogg) | bin | 4788 -> 4788 bytes | |||
-rw-r--r-- | Data/sounds/headshot.ogg (renamed from Data/Sounds/headshot.ogg) | bin | 6328 -> 6328 bytes | |||
-rw-r--r-- | Data/sounds/knifeslash.ogg (renamed from Data/Sounds/knifeslash.ogg) | bin | 7632 -> 7632 bytes | |||
-rw-r--r-- | Data/sounds/knifesong.ogg (renamed from Data/Sounds/knifesong.ogg) | bin | 38211 -> 38211 bytes | |||
-rw-r--r-- | Data/sounds/machinegun.ogg (renamed from Data/Sounds/machinegun.ogg) | bin | 8256 -> 8256 bytes | |||
-rw-r--r-- | Data/sounds/mainmenusong.ogg (renamed from Data/Sounds/mainmenusong.ogg) | bin | 73271 -> 73271 bytes | |||
-rw-r--r-- | Data/sounds/pinpull.ogg (renamed from Data/Sounds/pinpull.ogg) | bin | 4311 -> 4311 bytes | |||
-rw-r--r-- | Data/sounds/pinreplace.ogg (renamed from Data/Sounds/pinreplace.ogg) | bin | 4471 -> 4471 bytes | |||
-rw-r--r-- | Data/sounds/rain.ogg (renamed from Data/Sounds/rain.ogg) | bin | 61448 -> 61448 bytes | |||
-rw-r--r-- | Data/sounds/reload.ogg (renamed from Data/Sounds/reload.ogg) | bin | 16577 -> 16577 bytes | |||
-rw-r--r-- | Data/sounds/riflewhack.ogg (renamed from Data/Sounds/riflewhack.ogg) | bin | 5843 -> 5843 bytes | |||
-rw-r--r-- | Data/sounds/shootsong.ogg (renamed from Data/Sounds/shootsong.ogg) | bin | 44491 -> 44491 bytes | |||
-rw-r--r-- | Data/sounds/shotgun.ogg (renamed from Data/Sounds/shotgun.ogg) | bin | 7872 -> 7872 bytes | |||
-rw-r--r-- | Data/sounds/sniperrifle.ogg (renamed from Data/Sounds/sniperrifle.ogg) | bin | 11960 -> 11960 bytes | |||
-rw-r--r-- | Data/sounds/soul-in.ogg (renamed from Data/Sounds/SoulIn.ogg) | bin | 13292 -> 13292 bytes | |||
-rw-r--r-- | Data/sounds/soul-out.ogg (renamed from Data/Sounds/SoulOut.ogg) | bin | 14137 -> 14137 bytes | |||
-rw-r--r-- | Data/sounds/underwater.ogg (renamed from Data/Sounds/underwater.ogg) | bin | 42752 -> 42752 bytes | |||
-rw-r--r-- | Data/sounds/zombiesong.ogg (renamed from Data/Sounds/zombiesong.ogg) | bin | 35880 -> 35880 bytes | |||
-rw-r--r-- | build.zig | 5 | ||||
m--------- | lib/zeal | 0 | ||||
-rw-r--r-- | src/GameDraw.cpp | 3 | ||||
-rw-r--r-- | src/GameInitDispose.cpp | 166 | ||||
-rw-r--r-- | src/GameLoop.cpp | 3 | ||||
-rw-r--r-- | src/GameTick.cpp | 3 | ||||
-rw-r--r-- | src/Globals.cpp | 4 | ||||
-rw-r--r-- | src/Person.cpp | 3 | ||||
-rw-r--r-- | src/Skeleton.cpp | 3 | ||||
-rw-r--r-- | src/Support.cpp | 69 | ||||
-rw-r--r-- | src/Support.h | 4 | ||||
-rw-r--r-- | src/main.zig | 6 | ||||
-rw-r--r-- | src/misc.h | 2 | ||||
-rw-r--r-- | src/misc.zig | 16 |
50 files changed, 113 insertions, 174 deletions
diff --git a/Data/Sounds/BodyHit.ogg b/Data/sounds/BodyHit.ogg index f6b5d77..f6b5d77 100644 --- a/Data/Sounds/BodyHit.ogg +++ b/Data/sounds/BodyHit.ogg Binary files differdiff --git a/Data/Sounds/Lose.ogg b/Data/sounds/Lose.ogg index f929e15..f929e15 100644 --- a/Data/Sounds/Lose.ogg +++ b/Data/sounds/Lose.ogg Binary files differdiff --git a/Data/Sounds/Nearbullet.ogg b/Data/sounds/Nearbullet.ogg index cfff9a7..cfff9a7 100644 --- a/Data/Sounds/Nearbullet.ogg +++ b/Data/sounds/Nearbullet.ogg Binary files differdiff --git a/Data/Sounds/SW.ogg b/Data/sounds/SW.ogg index 4445758..4445758 100644 --- a/Data/Sounds/SW.ogg +++ b/Data/sounds/SW.ogg Binary files differdiff --git a/Data/Sounds/WallHit.ogg b/Data/sounds/WallHit.ogg index dc8ebb8..dc8ebb8 100644 --- a/Data/Sounds/WallHit.ogg +++ b/Data/sounds/WallHit.ogg Binary files differdiff --git a/Data/Sounds/bodyland.ogg b/Data/sounds/bodyland.ogg index 06d1bbd..06d1bbd 100644 --- a/Data/Sounds/bodyland.ogg +++ b/Data/sounds/bodyland.ogg Binary files differdiff --git a/Data/Sounds/bounce.ogg b/Data/sounds/bounce.ogg index 5360183..5360183 100644 --- a/Data/Sounds/bounce.ogg +++ b/Data/sounds/bounce.ogg Binary files differdiff --git a/Data/Sounds/bounce2.ogg b/Data/sounds/bounce2.ogg index 2d4688b..2d4688b 100644 --- a/Data/Sounds/bounce2.ogg +++ b/Data/sounds/bounce2.ogg Binary files differdiff --git a/Data/Sounds/click.ogg b/Data/sounds/click.ogg index 1e779e6..1e779e6 100644 --- a/Data/Sounds/click.ogg +++ b/Data/sounds/click.ogg Binary files differdiff --git a/Data/Sounds/DisguiseKill.ogg b/Data/sounds/disguise-kill.ogg index 8c2b359..8c2b359 100644 --- a/Data/Sounds/DisguiseKill.ogg +++ b/Data/sounds/disguise-kill.ogg Binary files differdiff --git a/Data/Sounds/explosion.ogg b/Data/sounds/explosion.ogg index a88bd8c..a88bd8c 100644 --- a/Data/Sounds/explosion.ogg +++ b/Data/sounds/explosion.ogg Binary files differdiff --git a/Data/Sounds/footstep1.ogg b/Data/sounds/footstep1.ogg index 15f0396..15f0396 100644 --- a/Data/Sounds/footstep1.ogg +++ b/Data/sounds/footstep1.ogg Binary files differdiff --git a/Data/Sounds/footstep2.ogg b/Data/sounds/footstep2.ogg index d0b9634..d0b9634 100644 --- a/Data/Sounds/footstep2.ogg +++ b/Data/sounds/footstep2.ogg Binary files differdiff --git a/Data/Sounds/footstep3.ogg b/Data/sounds/footstep3.ogg index 05bc694..05bc694 100644 --- a/Data/Sounds/footstep3.ogg +++ b/Data/sounds/footstep3.ogg Binary files differdiff --git a/Data/Sounds/footstep4.ogg b/Data/sounds/footstep4.ogg index 4545d44..4545d44 100644 --- a/Data/Sounds/footstep4.ogg +++ b/Data/sounds/footstep4.ogg Binary files differdiff --git a/Data/Sounds/footstep5.ogg b/Data/sounds/footstep5.ogg index 77ed23b..77ed23b 100644 --- a/Data/Sounds/footstep5.ogg +++ b/Data/sounds/footstep5.ogg Binary files differdiff --git a/Data/Sounds/glock.ogg b/Data/sounds/glock.ogg index 0913e30..0913e30 100644 --- a/Data/Sounds/glock.ogg +++ b/Data/sounds/glock.ogg Binary files differdiff --git a/Data/Sounds/handlerelease.ogg b/Data/sounds/handlerelease.ogg index 4dc2e43..4dc2e43 100644 --- a/Data/Sounds/handlerelease.ogg +++ b/Data/sounds/handlerelease.ogg Binary files differdiff --git a/Data/Sounds/headland.ogg b/Data/sounds/headland.ogg index b9b51de..b9b51de 100644 --- a/Data/Sounds/headland.ogg +++ b/Data/sounds/headland.ogg Binary files differdiff --git a/Data/Sounds/headshot.ogg b/Data/sounds/headshot.ogg index 3809dc3..3809dc3 100644 --- a/Data/Sounds/headshot.ogg +++ b/Data/sounds/headshot.ogg Binary files differdiff --git a/Data/Sounds/knifeslash.ogg b/Data/sounds/knifeslash.ogg index 6b09bb1..6b09bb1 100644 --- a/Data/Sounds/knifeslash.ogg +++ b/Data/sounds/knifeslash.ogg Binary files differdiff --git a/Data/Sounds/knifesong.ogg b/Data/sounds/knifesong.ogg index ee93c91..ee93c91 100644 --- a/Data/Sounds/knifesong.ogg +++ b/Data/sounds/knifesong.ogg Binary files differdiff --git a/Data/Sounds/machinegun.ogg b/Data/sounds/machinegun.ogg index 6c8ef30..6c8ef30 100644 --- a/Data/Sounds/machinegun.ogg +++ b/Data/sounds/machinegun.ogg Binary files differdiff --git a/Data/Sounds/mainmenusong.ogg b/Data/sounds/mainmenusong.ogg index aa40fc9..aa40fc9 100644 --- a/Data/Sounds/mainmenusong.ogg +++ b/Data/sounds/mainmenusong.ogg Binary files differdiff --git a/Data/Sounds/pinpull.ogg b/Data/sounds/pinpull.ogg index 08e7ef9..08e7ef9 100644 --- a/Data/Sounds/pinpull.ogg +++ b/Data/sounds/pinpull.ogg Binary files differdiff --git a/Data/Sounds/pinreplace.ogg b/Data/sounds/pinreplace.ogg index 7f4508a..7f4508a 100644 --- a/Data/Sounds/pinreplace.ogg +++ b/Data/sounds/pinreplace.ogg Binary files differdiff --git a/Data/Sounds/rain.ogg b/Data/sounds/rain.ogg index 0c1933f..0c1933f 100644 --- a/Data/Sounds/rain.ogg +++ b/Data/sounds/rain.ogg Binary files differdiff --git a/Data/Sounds/reload.ogg b/Data/sounds/reload.ogg index 4147992..4147992 100644 --- a/Data/Sounds/reload.ogg +++ b/Data/sounds/reload.ogg Binary files differdiff --git a/Data/Sounds/riflewhack.ogg b/Data/sounds/riflewhack.ogg index 3bf4fc5..3bf4fc5 100644 --- a/Data/Sounds/riflewhack.ogg +++ b/Data/sounds/riflewhack.ogg Binary files differdiff --git a/Data/Sounds/shootsong.ogg b/Data/sounds/shootsong.ogg index 5503e84..5503e84 100644 --- a/Data/Sounds/shootsong.ogg +++ b/Data/sounds/shootsong.ogg Binary files differdiff --git a/Data/Sounds/shotgun.ogg b/Data/sounds/shotgun.ogg index d0c8777..d0c8777 100644 --- a/Data/Sounds/shotgun.ogg +++ b/Data/sounds/shotgun.ogg Binary files differdiff --git a/Data/Sounds/sniperrifle.ogg b/Data/sounds/sniperrifle.ogg index 1d2f526..1d2f526 100644 --- a/Data/Sounds/sniperrifle.ogg +++ b/Data/sounds/sniperrifle.ogg Binary files differdiff --git a/Data/Sounds/SoulIn.ogg b/Data/sounds/soul-in.ogg index e38479d..e38479d 100644 --- a/Data/Sounds/SoulIn.ogg +++ b/Data/sounds/soul-in.ogg Binary files differdiff --git a/Data/Sounds/SoulOut.ogg b/Data/sounds/soul-out.ogg index a14ec80..a14ec80 100644 --- a/Data/Sounds/SoulOut.ogg +++ b/Data/sounds/soul-out.ogg Binary files differdiff --git a/Data/Sounds/underwater.ogg b/Data/sounds/underwater.ogg index eb43d04..eb43d04 100644 --- a/Data/Sounds/underwater.ogg +++ b/Data/sounds/underwater.ogg Binary files differdiff --git a/Data/Sounds/zombiesong.ogg b/Data/sounds/zombiesong.ogg index 910002c..910002c 100644 --- a/Data/Sounds/zombiesong.ogg +++ b/Data/sounds/zombiesong.ogg Binary files differdiff --git a/build.zig b/build.zig index d43a430..d3b348c 100644 --- a/build.zig +++ b/build.zig @@ -57,11 +57,11 @@ pub fn build(b: *Builder) void { exe.addPackage(.{ .name = "loca", .path = "lib/loca/src/main.zig" }); exe.addPackage(.{ .name = "zeal", .path = "lib/zeal/src/zeal.zig" }); exe.linkSystemLibrary("openal"); + exe.linkSystemLibrary("sndfile"); exe.linkSystemLibrary("GL"); exe.linkSystemLibrary("GLU"); exe.linkSystemLibrary("c++"); - exe.linkSystemLibrary("vorbisfile"); // Standard target options allows the person running `zig build` to choose // what target to build for. Here we do not override the defaults, which @@ -80,9 +80,8 @@ pub fn build(b: *Builder) void { const run_cmd = exe.run(); run_cmd.step.dependOn(b.getInstallStep()); - if (b.args) |args| { + if (b.args) |args| run_cmd.addArgs(args); - } const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); diff --git a/lib/zeal b/lib/zeal -Subproject 735e9aff1d1443abc8107a9895d4b71e43fdf63 +Subproject bcbf7fbed0392762d35613a995c5ab4fbcfb666 diff --git a/src/GameDraw.cpp b/src/GameDraw.cpp index 471786d..abb0919 100644 --- a/src/GameDraw.cpp +++ b/src/GameDraw.cpp @@ -25,8 +25,7 @@ extern int thirdperson; extern float multiplier; extern int nocolors; extern int visions; -extern unsigned int gSourceID[100]; -extern unsigned int gSampleSet[100]; +extern unsigned int gSourceID[37]; extern Camera camera; extern Sprites sprites; extern float camerashake; diff --git a/src/GameInitDispose.cpp b/src/GameInitDispose.cpp index 94ad884..ed767fd 100644 --- a/src/GameInitDispose.cpp +++ b/src/GameInitDispose.cpp @@ -26,8 +26,8 @@ #include "misc.h" #include "Game.h" -extern unsigned int gSourceID[100]; -extern unsigned int gSampleSet[100]; +extern unsigned int gSourceID[37]; +extern unsigned int gSampleSet[37]; extern Camera camera; extern Skeleton testskeleton; extern Sprites sprites; @@ -109,87 +109,88 @@ Game* makeGame(Config config) void LoadSounds(bool musictoggle) { - // generate ten OpenAL sample sets and two sources - alGenBuffers(37, gSampleSet); - alGenSources(37, gSourceID); - - // load up some audio data... - loadOgg((char*) ":Data:Sounds:underwater.ogg", - gSampleSet[visionsound], gSourceID[visionsound]); - loadOgg((char*) ":Data:Sounds:soulin.ogg", - gSampleSet[soulinsound], gSourceID[soulinsound]); - loadOgg((char*) ":Data:Sounds:soulout.ogg", - gSampleSet[souloutsound], gSourceID[souloutsound]); - loadOgg((char*) ":Data:Sounds:footstep1.ogg", - gSampleSet[footstepsound], gSourceID[footstepsound]); - loadOgg((char*) ":Data:Sounds:footstep2.ogg", - gSampleSet[footstepsound+1], gSourceID[footstepsound+1]); - loadOgg((char*) ":Data:Sounds:footstep3.ogg", - gSampleSet[footstepsound+2], gSourceID[footstepsound+2]); - loadOgg((char*) ":Data:Sounds:footstep4.ogg", - gSampleSet[footstepsound+3], gSourceID[footstepsound+3]); - loadOgg((char*) ":Data:Sounds:footstep5.ogg", - gSampleSet[footstepsound+4], gSourceID[footstepsound+4]); - loadOgg((char*) ":Data:Sounds:bodyland.ogg", - gSampleSet[bodylandsound], gSourceID[bodylandsound]); - loadOgg((char*) ":Data:Sounds:headland.ogg", - gSampleSet[headlandsound], gSourceID[headlandsound]); - loadOgg((char*) ":Data:Sounds:sniperrifle.ogg", - gSampleSet[riflesound], gSourceID[riflesound]); - loadOgg((char*) ":Data:Sounds:BodyHit.ogg", - gSampleSet[bodyhitsound], gSourceID[bodyhitsound]); - loadOgg((char*) ":Data:Sounds:WallHit.ogg", - gSampleSet[wallhitsound], gSourceID[wallhitsound]); - loadOgg((char*) ":Data:Sounds:machinegun.ogg", - gSampleSet[machinegunsound], gSourceID[machinegunsound]); - loadOgg((char*) ":Data:Sounds:Nearbullet.ogg", - gSampleSet[nearbulletsound], gSourceID[nearbulletsound]); - loadOgg((char*) ":Data:Sounds:riflewhack.ogg", - gSampleSet[headwhacksound], gSourceID[headwhacksound]); - loadOgg((char*) ":Data:Sounds:headshot.ogg", - gSampleSet[headshotsound], gSourceID[headshotsound]); - loadOgg((char*) ":Data:Sounds:reload.ogg", - gSampleSet[reloadsound], gSourceID[reloadsound]); - loadOgg((char*) ":Data:Sounds:click.ogg", - gSampleSet[clicksound], gSourceID[clicksound]); - loadOgg((char*) ":Data:Sounds:SW.ogg", - gSampleSet[pistol1sound], gSourceID[pistol1sound]); - loadOgg((char*) ":Data:Sounds:glock.ogg", - gSampleSet[pistol2sound], gSourceID[pistol2sound]); - loadOgg((char*) ":Data:Sounds:pinpull.ogg", - gSampleSet[pinpullsound], gSourceID[pinpullsound]); - loadOgg((char*) ":Data:Sounds:pinreplace.ogg", - gSampleSet[pinreplacesound], gSourceID[pinreplacesound]); - loadOgg((char*) ":Data:Sounds:handlerelease.ogg", - gSampleSet[grenadethrowsound], gSourceID[grenadethrowsound]); - loadOgg((char*) ":Data:Sounds:bounce.ogg", - gSampleSet[bouncesound], gSourceID[bouncesound]); - loadOgg((char*) ":Data:Sounds:bounce2.ogg", - gSampleSet[bounce2sound], gSourceID[bounce2sound]); - loadOgg((char*) ":Data:Sounds:explosion.ogg", - gSampleSet[explosionsound], gSourceID[explosionsound]); - loadOgg((char*) ":Data:Sounds:headland.ogg", - gSampleSet[bodywhacksound], gSourceID[bodywhacksound]); - loadOgg((char*) ":Data:Sounds:rain.ogg", - gSampleSet[rainsound], gSourceID[rainsound]); - loadOgg((char*) ":Data:Sounds:Lose.ogg", - gSampleSet[losesound], gSourceID[losesound]); - loadOgg((char*) ":Data:Sounds:Disguisekill.ogg", - gSampleSet[disguisekillsound], gSourceID[disguisekillsound]); - loadOgg((char*) ":Data:Sounds:knifeslash.ogg", - gSampleSet[knifeslashsound], gSourceID[knifeslashsound]); - loadOgg((char*) ":Data:Sounds:shotgun.ogg", - gSampleSet[shotgunsound], gSourceID[shotgunsound]); + gSampleSet[visionsound] = loadSound("underwater.ogg"); + gSampleSet[soulinsound] = loadSound("soul-in.ogg"); + gSampleSet[souloutsound] = loadSound("soul-out.ogg"); + gSampleSet[footstepsound + 0] = loadSound("footstep1.ogg"); + gSampleSet[footstepsound + 1] = loadSound("footstep2.ogg"); + gSampleSet[footstepsound + 2] = loadSound("footstep3.ogg"); + gSampleSet[footstepsound + 3] = loadSound("footstep4.ogg"); + gSampleSet[footstepsound + 4] = loadSound("footstep5.ogg"); + gSampleSet[bodylandsound] = loadSound("bodyland.ogg"); + gSampleSet[headlandsound] = loadSound("headland.ogg"); + gSampleSet[riflesound] = loadSound("sniperrifle.ogg"); + gSampleSet[machinegunsound] = loadSound("machinegun.ogg"); + gSampleSet[bodyhitsound] = loadSound("BodyHit.ogg"); + gSampleSet[wallhitsound] = loadSound("WallHit.ogg"); + gSampleSet[machinegunsound] = loadSound("machinegun.ogg"); + gSampleSet[nearbulletsound] = loadSound("Nearbullet.ogg"); + gSampleSet[headwhacksound] = loadSound("riflewhack.ogg"); + gSampleSet[headshotsound] = loadSound("headshot.ogg"); + gSampleSet[reloadsound] = loadSound("reload.ogg"); + gSampleSet[clicksound] = loadSound("click.ogg"); + gSampleSet[pistol1sound] = loadSound("SW.ogg"); + gSampleSet[pistol2sound] = loadSound("glock.ogg"); + gSampleSet[pinpullsound] = loadSound("pinpull.ogg"); + gSampleSet[pinreplacesound] = loadSound("pinreplace.ogg"); + gSampleSet[grenadethrowsound] = loadSound("handlerelease.ogg"); + gSampleSet[bouncesound] = loadSound("bounce.ogg"); + gSampleSet[bounce2sound] = loadSound("bounce2.ogg"); + gSampleSet[explosionsound] = loadSound("explosion.ogg"); + gSampleSet[headlandsound] = loadSound("headland.ogg"); + gSampleSet[rainsound] = loadSound("rain.ogg"); + gSampleSet[losesound] = loadSound("Lose.ogg"); + gSampleSet[disguisekillsound] = loadSound("disguise-kill.ogg"); + gSampleSet[knifeslashsound] = loadSound("knifeslash.ogg"); + gSampleSet[shotgunsound] = loadSound("shotgun.ogg"); + if (musictoggle) { + gSampleSet[mainmenusong] = loadSound("mainmenusong.ogg"); + gSampleSet[shootsong] = loadSound("shootsong.ogg"); + gSampleSet[zombiesong] = loadSound("zombiesong.ogg"); + gSampleSet[knifesong] = loadSound("knifesong.ogg"); + } + + alGenSources(33, gSourceID); + alSourcei(gSourceID[visionsound], AL_BUFFER, gSampleSet[visionsound]); + alSourcei(gSourceID[soulinsound], AL_BUFFER, gSampleSet[soulinsound]); + alSourcei(gSourceID[souloutsound], AL_BUFFER, gSampleSet[souloutsound]); + alSourcei(gSourceID[footstepsound + 0], AL_BUFFER, gSampleSet[footstepsound + 0]); + alSourcei(gSourceID[footstepsound + 1], AL_BUFFER, gSampleSet[footstepsound + 1]); + alSourcei(gSourceID[footstepsound + 2], AL_BUFFER, gSampleSet[footstepsound + 2]); + alSourcei(gSourceID[footstepsound + 3], AL_BUFFER, gSampleSet[footstepsound + 3]); + alSourcei(gSourceID[footstepsound + 4], AL_BUFFER, gSampleSet[footstepsound + 4]); + alSourcei(gSourceID[bodylandsound], AL_BUFFER, gSampleSet[bodylandsound]); + alSourcei(gSourceID[headlandsound], AL_BUFFER, gSampleSet[headlandsound]); + alSourcei(gSourceID[riflesound], AL_BUFFER, gSampleSet[riflesound]); + alSourcei(gSourceID[bodyhitsound], AL_BUFFER, gSampleSet[bodyhitsound]); + alSourcei(gSourceID[wallhitsound], AL_BUFFER, gSampleSet[wallhitsound]); + alSourcei(gSourceID[machinegunsound], AL_BUFFER, gSampleSet[machinegunsound]); + alSourcei(gSourceID[nearbulletsound], AL_BUFFER, gSampleSet[nearbulletsound]); + alSourcei(gSourceID[headwhacksound], AL_BUFFER, gSampleSet[headwhacksound]); + alSourcei(gSourceID[headshotsound], AL_BUFFER, gSampleSet[headshotsound]); + alSourcei(gSourceID[reloadsound], AL_BUFFER, gSampleSet[reloadsound]); + alSourcei(gSourceID[clicksound], AL_BUFFER, gSampleSet[clicksound]); + alSourcei(gSourceID[pistol1sound], AL_BUFFER, gSampleSet[pistol1sound]); + alSourcei(gSourceID[pistol2sound], AL_BUFFER, gSampleSet[pistol2sound]); + alSourcei(gSourceID[pinpullsound], AL_BUFFER, gSampleSet[pinpullsound]); + alSourcei(gSourceID[pinreplacesound], AL_BUFFER, gSampleSet[pinreplacesound]); + alSourcei(gSourceID[grenadethrowsound], AL_BUFFER, gSampleSet[grenadethrowsound]); + alSourcei(gSourceID[bouncesound], AL_BUFFER, gSampleSet[bouncesound]); + alSourcei(gSourceID[bounce2sound], AL_BUFFER, gSampleSet[bounce2sound]); + alSourcei(gSourceID[explosionsound], AL_BUFFER, gSampleSet[explosionsound]); + alSourcei(gSourceID[bodywhacksound], AL_BUFFER, gSampleSet[bodywhacksound]); + alSourcei(gSourceID[rainsound], AL_BUFFER, gSampleSet[rainsound]); + alSourcei(gSourceID[losesound], AL_BUFFER, gSampleSet[losesound]); + alSourcei(gSourceID[disguisekillsound], AL_BUFFER, gSampleSet[disguisekillsound]); + alSourcei(gSourceID[knifeslashsound], AL_BUFFER, gSampleSet[knifeslashsound]); + alSourcei(gSourceID[shotgunsound], AL_BUFFER, gSampleSet[shotgunsound]); if (musictoggle) { - loadOgg((char*) ":Data:Sounds:mainmenusong.ogg", - gSampleSet[mainmenusong], gSourceID[mainmenusong]); - loadOgg((char*) ":Data:Sounds:shootsong.ogg", - gSampleSet[shootsong], gSourceID[shootsong]); - loadOgg((char*) ":Data:Sounds:zombiesong.ogg", - gSampleSet[zombiesong], gSourceID[zombiesong]); - loadOgg((char*) ":Data:Sounds:knifesong.ogg", - gSampleSet[knifesong], gSourceID[knifesong]); + alGenSources(4, gSourceID + 33); + alSourcei(gSourceID[mainmenusong], AL_BUFFER, gSampleSet[mainmenusong]); + alSourcei(gSourceID[shootsong], AL_BUFFER, gSampleSet[shootsong]); + alSourcei(gSourceID[zombiesong], AL_BUFFER, gSampleSet[zombiesong]); + alSourcei(gSourceID[knifesong], AL_BUFFER, gSampleSet[knifesong]); } alListenerfv(AL_POSITION, {}); @@ -1677,5 +1678,6 @@ void closeGame(Game* game) game->flaretextureptr, }; glDeleteTextures(4, textures); - alDeleteSources(100, gSourceID); // delete sound sources + alDeleteSources(33 + game->musictoggle * 4, gSourceID); + alDeleteBuffers(33 + game->musictoggle * 4, gSampleSet); } diff --git a/src/GameLoop.cpp b/src/GameLoop.cpp index 77ec774..b3810c6 100644 --- a/src/GameLoop.cpp +++ b/src/GameLoop.cpp @@ -25,8 +25,7 @@ extern float multiplier; extern int thirdperson; extern int visions; extern float soundscalefactor; -extern unsigned int gSourceID[100]; -extern unsigned int gSampleSet[100]; +extern unsigned int gSourceID[37]; extern Camera camera; extern float rad2deg; extern Fog fog; diff --git a/src/GameTick.cpp b/src/GameTick.cpp index efc473f..57b2efe 100644 --- a/src/GameTick.cpp +++ b/src/GameTick.cpp @@ -28,8 +28,7 @@ extern float multiplier; extern int thirdperson; extern int visions; extern Sprites sprites; -extern unsigned int gSourceID[100]; -extern unsigned int gSampleSet[100]; +extern unsigned int gSourceID[37]; extern Camera camera; extern float camerashake; extern Fog fog; diff --git a/src/Globals.cpp b/src/Globals.cpp index 6fdad88..d1ae639 100644 --- a/src/Globals.cpp +++ b/src/Globals.cpp @@ -9,8 +9,8 @@ float sinefluctprog; float multiplier = 0.0f; -unsigned int gSourceID[100]; // hundred source IDs -unsigned int gSampleSet[100]; // hundred sample set ID numbers +unsigned int gSourceID[37]; +unsigned int gSampleSet[37]; float precipitationhorz; float precipitationvert; diff --git a/src/Person.cpp b/src/Person.cpp index d529143..ea2280c 100644 --- a/src/Person.cpp +++ b/src/Person.cpp @@ -22,8 +22,7 @@ #include "Person.h" extern float multiplier; -extern unsigned int gSourceID[100]; -extern unsigned int gSampleSet[100]; +extern unsigned int gSourceID[37]; extern Animation animation[30]; extern int thirdperson; extern int visions; diff --git a/src/Skeleton.cpp b/src/Skeleton.cpp index f1f3ff5..4f2a2a7 100644 --- a/src/Skeleton.cpp +++ b/src/Skeleton.cpp @@ -4,8 +4,7 @@ #include "Serialize.h" extern float multiplier; -extern unsigned int gSourceID[100]; -extern unsigned int gSampleSet[100]; +extern unsigned int gSourceID[37]; extern int visions; extern float rad2deg; extern Camera camera; diff --git a/src/Support.cpp b/src/Support.cpp index f7e726a..d070faa 100644 --- a/src/Support.cpp +++ b/src/Support.cpp @@ -7,7 +7,6 @@ #include <unistd.h> #include <GLFW/glfw3.h> -#include <vorbis/vorbisfile.h> #include "Support.h" #include "Files.h" @@ -195,71 +194,3 @@ void Files::EndLoad() sFile = -1; } - -/* Read the requested Ogg file and load it into OpenAL */ -void loadOgg(char *filename, ALuint buffer, ALuint source) -{ - /* Try to find the real file (and place it in filename1) */ - char filename1[MAX_PATH]; - fix_filename(filename, filename1); - - FILE* fp = fopen(filename1, "rb"); - if (fp == NULL) { - fprintf(stderr, "ERROR: unable to open %s\n", filename1); - exit(EXIT_FAILURE); - } - - OggVorbis_File vf; - int error = -ov_open(fp, &vf, NULL, 0); - if (error > 0) { - fprintf(stderr, "ERROR: vorbis error %d opening %s\n", - error, filename1); - exit(EXIT_FAILURE); - } - - vorbis_info* vi = ov_info(&vf, -1); - if (vi == NULL) { - fprintf(stderr, - "ERROR: vorbis error opening %s (ov_info failed)\n", - filename1); - exit(EXIT_FAILURE); - } - - /* Hack around some possible ogg vorbis weirdness */ - ALsizei size = vi->channels * 2 * ov_pcm_total(&vf, -1); - ALvoid* data = malloc(((size + 2047) / 2048 + 1) * 2048); - if (data == NULL) { - fprintf(stderr, - "ERROR: could not allocate %d bytes while loading %s\n", - size, filename1); - exit(EXIT_FAILURE); - } - - char* i = (char*) data; - int section; - long ret; -#if BYTE_ORDER == BIG_ENDIAN - while (ret = ov_read(&vf, i, 1024, 1, 2, 1, §ion)) -#else - while (ret = ov_read(&vf, i, 1024, 0, 2, 1, §ion)) -#endif - if (ret > 0) /* XXX: How about negative ret? */ - i += ret; - - switch (vi->channels) { - case 1: - alBufferData(buffer, AL_FORMAT_MONO16, data, size, vi->rate); - break; - case 2: - alBufferData(buffer, AL_FORMAT_STEREO16, data, size, vi->rate); - break; - default: - fprintf(stderr, "ERROR: ogg %s has %d channels\n", - filename1, vi->channels); - exit(EXIT_FAILURE); - } - - free(data); - ov_clear(&vf); - alSourcei(source, AL_BUFFER, buffer); -} diff --git a/src/Support.h b/src/Support.h index b033272..cd71fc0 100644 --- a/src/Support.h +++ b/src/Support.h @@ -4,8 +4,6 @@ #include <stdio.h> #include <unistd.h> -#include <AL/al.h> - #define fsFromStart SEEK_SET typedef char* Str255; @@ -28,8 +26,6 @@ typedef struct UnsignedWide int Random(); bool IsKeyDown(int key); -void loadOgg(char* filename, ALuint buffer, ALuint source); - FILE *cfh_fopen(const char *filename, const char *mode); #endif diff --git a/src/main.zig b/src/main.zig index e6eea7b..4b116c8 100644 --- a/src/main.zig +++ b/src/main.zig @@ -23,10 +23,12 @@ const configuration = @import("config.zig"); const gf = @import("gfz"); const gl = @import("zgl"); const legacy = @cImport(@cInclude("Game.h")); +const misc = @import("misc.zig"); comptime { // Work around lazy compilation. - @export(@import("misc.zig").loadTexture, .{ .name = "loadTexture" }); + @export(misc.loadSound, .{ .name = "loadSound" }); + @export(misc.loadTexture, .{ .name = "loadTexture" }); } var game: *legacy.Game = undefined; @@ -78,7 +80,7 @@ pub fn main() !void { defer device.deinit() catch unreachable; const context = try al.Context.init(device, &.{}); defer context.deinit() catch unreachable; - try al.useContext(context); + try context.makeCurrent(); legacy.initGame(game); defer legacy.closeGame(game); diff --git a/src/misc.h b/src/misc.h index b3a7f43..e3bef7d 100644 --- a/src/misc.h +++ b/src/misc.h @@ -1,8 +1,10 @@ #ifndef BLACKSHADES_MISC_H #define BLACKSHADES_MISC_H +#include <AL/al.h> #include <GL/gl.h> +extern "C" ALuint loadSound(const char*); extern "C" GLuint loadTexture(const char*); #endif // BLACKSHADES_MISC_H diff --git a/src/misc.zig b/src/misc.zig index 9015a02..9ad5933 100644 --- a/src/misc.zig +++ b/src/misc.zig @@ -22,14 +22,26 @@ usingnamespace @cImport({ @cInclude("lodepng.h"); }); +const al = @import("zeal"); const allocator = std.heap.c_allocator; const cwd = std.fs.cwd; const data_dir = @import("build_options").data_dir ++ [_]u8{ sep }; const free = std.c.free; -const sep = std.fs.path.sep; +const join = std.fs.path.joinZ; const maxInt = std.math.maxInt; -const std = @import("std"); +const sep = std.fs.path.sep; const span = std.mem.span; +const std = @import("std"); + +pub fn loadSound(filename: [*:0]const u8) callconv(.C) u32 { + const path = join(allocator, &.{ data_dir ++ "sounds", span(filename) }) + catch unreachable; + defer allocator.free(path); + const audio = al.Audio.read(allocator, span(path)) catch unreachable; + defer audio.free(); + const buffer = al.Buffer.init(audio) catch unreachable; + return buffer.reference; +} fn check(errorString: fn (c_uint) callconv(.C) [*c]const u8, status: anytype) void { |