58 Commits
Author SHA1 Message Date
bubio 5d8e941ad2 storm_svid: use letterbox instead of stretch for USE_SDL3 2026-09-20 03:20:07 +02:00
Anders Jenbo 1ca75e4776 Migrate DOS to SDL3 (fixing AUDIO and stuff) 2026-07-15 21:56:02 +02:00
Anders Jenbo 7b65d70419 Implement audio via SDL3_mixer 2026-04-12 08:04:46 +02:00
Anders Jenbo 005e7dcc23 chore: clang-tidy cleanup part 1 2026-04-03 22:57:48 +02:00
Gleb Mazovetskiy 20ad675558 SDL3: Build with sound
This doesn't implement full sound support but stubs out most of the
sound code under SDL3, so that we can implement it piecemeal.

Implemented here:
1. Sound device initialization.
2. SVid sound playback.

Does not add a dependency on `SDL_mixer`: SDL3 built-ins
are enough to play SVid audio.
2025-10-18 17:21:58 +01:00
Gleb Mazovetskiy 88f706e0d1 SDL3: Add some backports / compat helpers 2025-10-10 00:49:44 +01:00
Gleb Mazovetskiy 1bbe8bfe08 SDL3: Even more migration 2025-10-09 01:28:37 +01:00
Gleb Mazovetskiy 50ac397013 Add 8-bit video mode for SDL2 and use it in DOS
There are still some glitches in screen transitions but that's probably
our fault. We can improve it later.
2025-09-01 18:18:14 +01:00
Anders Jenbo 1c76897f2c Apply simple const rules using clang-tidy 2025-08-16 01:21:36 +02:00
Gleb Mazovetskiy d94bc424df sgOptions -> GetOptions()
In C++, globals initialization order accross translation units is not
defined. Accessing a global via a function ensures that it is initialized.

This will be needed for #7638, which will statically initialize change
handlers after the Options object has been initialized.
2025-01-13 11:57:25 +00:00
Apaczer fc0f58c839 storm_svid: use DISPLAY_TEXTURE_FORMAT for PlayEnd
otherwise we get incorrect menu graphics
2024-12-27 00:12:12 +01:00
Gleb Mazovetskiy f476754313 Videos: Avoid float math for frame durations
SMK format actually defines frame durations in units that are 0.01ms:

https://github.com/diasurgical/libsmackerdec/blob/91e732bb6953489077430572f43fc802bf2c75b2/src/SmackerDecoder.cpp#L329-L334

That's great because it means we can do everything using integer math.
2024-10-04 01:55:27 +02:00
Gleb Mazovetskiy c2ad6da733 Add DEVILUTIONX_DISPLAY_TEXTURE_FORMAT
Some platforms, such as PS2, can benefit from a different texture
format. Makes the texture format a CMake setting.
2023-09-03 00:48:06 +01:00
Gleb Mazovetskiy 14540164a7 Remove utils/stdcompat/optional.hpp 2023-08-14 01:54:29 +01:00
Gleb Mazovetskiy 3ab2f49a92 Audio: Avoid creating same-rate resamplers
Each resampler allocates an input buffer and an output buffer.

Since we create ~100 audio stream objects (1 per `sfx_MISC` effect),
the memory cost of these buffers adds up.

Avoids creating a resampler when the audio sampler rate matches the
output sample rate. This is mostly the case when the output sample
rate is 22050.
2023-01-19 13:09:31 +01:00
Gleb Mazovetskiy 9db80ef5d7 Assets: Load files directly for UNPACKED_MPQS
When using `UNPACKED_MPQS`, avoid all the SDL machinery for reading
files.

This is beneficial not only due to reduced indirection but also because
we can test for the file's existence and get the file size without
opening it, which is much faster.
2022-11-22 02:44:25 +01:00
Anders Jenbo 72656b3011 Move path and palette to the engine folder 2022-06-24 16:34:20 +02:00
Anders Jenbo 99181fd709 Move more files to the engine folder 2022-06-24 11:08:15 +02:00
Gleb Mazovetskiy 4cdbd358dd Audio: Use SDL resampler where available 2022-04-16 04:20:47 +02:00
obligaron 79b926c375 Move more options to OptionEntryBase 2022-02-05 20:51:54 +01:00
staphen 6418d7a2f0 Detect window focus state to mute automatically when starting audio 2022-01-18 13:13:31 +01:00
staphen a7bca3a1ec Extend window focus mute to cinematic audio 2022-01-18 13:13:31 +01:00
obligaron 8a4d4b6375 Add OptionEntries for Audio 2021-12-14 04:10:16 +01:00
Gleb Mazovetskiy d99dd678e2 storm_svid: Cleanup video rendering code
1. Removes adjustments to `orig/system_palette`.
   They're not needed because videos have a separate render loop.
   For an in-game movie, the caller sets the palette after the movie.

2. Splits some of `SVidPlayContinue` code into functions
   (`UpdatePalette` and `BlitFrame`).
3. Adds a separate config variable for SDL1 SVid video mode.
   E.g. on rg99 there isn't enough video RAM for double-buffering
   the main game but we can do it for the videos.
2021-12-12 17:30:48 +01:00
Gleb MazovetskiyandAnders Jenbo 7e1fea6f76 clang-format all files in {Source,test}/
Also includes a few manual tweaks to comments and newlines for better results.

Co-authored-by: Anders Jenbo <[email protected]>
2021-11-24 23:44:12 +01:00
staphen 25afdee39b Replace libsmacker with libsmackerdec 2021-11-23 21:04:10 +01:00
Gleb Mazovetskiy fa90679416 game_assets.* -> assets.* 2021-11-17 11:49:57 +01:00
Gleb Mazovetskiy 3d308983a8 Migrate to libmpq
libmpq is a much simpler alternative to StormLib for reading MPQ archives.

We use our own fork of libmpq: https://github.com/diasurgical/libmpq

Impact:

* DevilutionX is now a lot more portable. Unlike StormLib, libmpq only
  needs platform-specific code for Windows.
* Locks around file access **removed** (instead we duplicate the file descriptor for streamed audio only).
* RAM usage is **300 KiB** lower than StormLib.
* Stripped release linux_x86_64 binary is **32 KiB** smaller.
* Amiga build now hangs instead of crashing.
2021-11-06 23:51:42 +00:00
Anders Jenbo 8df5912dc6 Always use SDL wrapper for file access 2021-10-20 21:52:59 +02:00
Vladimir Olteanu bcd7f89319 Have SDLWrap::AllocPalette allocate space for 256 colors by default 2021-09-13 23:07:04 +02:00
Vladimir Olteanu e14504ae56 SVidPlayContinue: use SDLWrap::ConvertSurface* 2021-09-13 23:07:04 +02:00
Vladimir Olteanu d226885672 Introduce SDLWrap::AllocPalette 2021-09-13 23:07:04 +02:00
Vladimir Olteanu cc9ea97e0f Introduce SDLWrap::CreateTexture 2021-09-13 23:07:04 +02:00
Vladimir Olteanu e9063c578f Introduce SDLWrap::CreateRGBSurfaceWithFormatFrom 2021-09-13 23:07:04 +02:00
Anders Jenbo a207644d88 Rename HaveAudio to HasAudio 2021-08-30 10:57:59 +02:00
Anders Jenbo 0889780923 Remove more usage of miniwin types 2021-07-18 02:11:58 +02:00
Anders Jenbo 2ca6e37c46 Clean up sub folders using clang-tidy/Android Studio 2021-07-08 03:30:25 -07:00
ephphatha 3520dc4201 Update numeric literals to use appropriate suffix
Mainly things like .F for floats instead of doubles in float context.
2021-07-05 08:52:05 -07:00
Anders Jenbo a7c7fa0030 Fully apply clang-tidy/format to all files 2021-07-03 16:41:43 -07:00
Anders Jenbo 8e07ef8fe5 Clang-tidy: misc-unused-parameters 2021-06-27 17:34:32 +02:00
Anders Jenbo f167bd4dfb Clang-tidy: llvm-include-order 2021-06-27 01:45:49 +02:00
Anders Jenbo 22b632f04a ♻️Clean up implicit bool conversions 2021-06-26 08:57:59 -07:00
Anders Jenbo a095bc0bf7 ♻️Migrate more code away from miniwin 2021-05-13 02:30:18 +02:00
staphen 3e5e5b2696 Synchronize SFileCloseFile() access 2021-05-08 04:01:07 +02:00
Anders Jenbo 4a7ba94702 🎨 Run clang-format 2021-05-07 23:26:39 +02:00
Gleb Mazovetskiy 987ab2533b 🐞 Synchronize SFileReadFile access
StormLib read function is not thread-safe: https://github.com/ladislav-zezula/StormLib/issues/175
2021-05-03 02:35:22 +02:00
Gleb Mazovetskiy f33f7ae7eb 💨 Do not zero-initalize arrays we write to
`std::make_unique<T[]>(size)` always zero-initalizes the array.

C++20 has `std::make_unique_for_overwrite` to avoid that, while
older C++ versions can use the approach applied here.
2021-05-02 05:52:11 +02:00
Gleb Mazovetskiy 7bdfb0655c 🐞 Support multiple playback of the same sound 2021-05-02 00:36:36 +02:00
Gleb Mazovetskiy c770ae676f 🎉 Stream videos on Linux and FreeBSD
Previously, we always loaded entire videos in memory before playing them.

`libsmacker` does not provide a streaming API but it does provide a
`FILE *` file pointer API.

We now take advantage of the `FILE *` API by streaming the videos on
platforms that support `fopencookie`.

This means faster startup and less memory usage on these platforms.
2021-05-02 00:23:05 +02:00
Vladimir Olteanu f5d1dc756a Make SVidBuffer unique_ptr 2021-04-30 14:52:28 +02:00