mp3 support for playing background music

This commit is contained in:
Ondřej Novák 2025-06-15 12:56:18 +02:00
parent 73a4187f79
commit dd23d8c989
24 changed files with 2245 additions and 252 deletions

View file

@ -11,7 +11,7 @@
#include <shellapi.h>
void show_help(std::ostream &out, const char *arg0) {
out <<
out <<
"Brany Skeldalu (Gates of Skeldal) portable game player\n"
"Copyright (c) 2025 Ondrej Novak. All rights reserved.\n\n"
"This work is licensed under the terms of the MIT license.\n"
@ -21,9 +21,10 @@ void show_help(std::ostream &out, const char *arg0) {
out << arg0 << " [-f <file>] [-a <file>] [-l <lang>] [-s <dir>] [-h]\n\n";
out << "-f <file> path to configuration file\n"
"-a <adv> path for adventure file (.adv)\n"
"-p <file> patch data with custom DDL\n"
"-l <lang> set language (cz|en)\n"
"-s <directory> generate string-tables (for localization) and exit\n"
"-h this help\n";
"-h this help\n";
}
void show_help_short(std::ostream &out) {
@ -31,20 +32,22 @@ void show_help_short(std::ostream &out) {
}
int main(int argc, char **argv) {
int main(int argc, char **argv) {
std::string config_name = SKELDALINI;
std::string adv_config_file;
std::string gen_stringtable_path;
std::string lang;
std::string patch;
std::ostringstream console;
for (int optchr = -1; (optchr = getopt(argc, argv, "hf:a:s:l:")) != -1; ) {
for (int optchr = -1; (optchr = getopt(argc, argv, "hf:a:s:l:p:")) != -1; ) {
switch (optchr) {
case 'f': config_name = optarg;break;
case 'a': adv_config_file = optarg;break;
case 'h': show_help(console, argv[0]);break;
case 'p': patch = optarg; break;
case 'l': lang = optarg;break;
case 's': gen_stringtable_path = optarg;break;
default: show_help_short(console);break;
default: show_help_short(console);break;
}
}
@ -64,6 +67,7 @@ int main(int argc, char **argv) {
cfg.adventure_path = adv_config_file.empty()?NULL:adv_config_file.c_str();
cfg.config_path = config_name.c_str();
cfg.lang_path = lang.empty()?NULL:lang.c_str();
cfg.patch_file = patch.empty()?NULL:patch.c_str();
{
std::string msg = console.str();

View file

@ -12,7 +12,7 @@ extern "C" {
#include <stdexcept>
// Funkce pro mapování souboru do paměti
void* map_file_to_memory_cpp(const char *name, size_t *sz) {
const void* map_file_to_memory_cpp(const char *name, size_t *sz) {
if (!name || !sz) {
return NULL;
}
@ -26,7 +26,7 @@ void* map_file_to_memory_cpp(const char *name, size_t *sz) {
throw std::runtime_error(std::string("failed to get size of file:").append(name));
}
HANDLE hMapping = CreateFileMapping(h,NULL,PAGE_READONLY,0,0,NULL);
if (hMapping == NULL || hMapping == INVALID_HANDLE_VALUE) {
@ -40,16 +40,16 @@ void* map_file_to_memory_cpp(const char *name, size_t *sz) {
if (mappedData == NULL) {
throw std::runtime_error(std::string("Failed to map file:").append(name));
}
*sz = fsize.LowPart;
return mappedData;
}
void* map_file_to_memory(const char *name, size_t *sz) {
const void* map_file_to_memory(const char *name, size_t *sz) {
return map_file_to_memory_cpp(name, sz);
}
// Funkce pro zrušení mapování
void unmap_file(void *ptr, size_t) {
UnmapViewOfFile(ptr);
void unmap_file(const void *ptr, size_t) {
UnmapViewOfFile((void *)ptr);
}

View file

@ -1,4 +1,4 @@
#include <stddef.h>
#include <stdint.h>
void *map_file_to_memory(const char *name, size_t *sz);
void unmap_file(void *ptr, size_t sz);
const void *map_file_to_memory(const char *name, size_t *sz);
void unmap_file(const void *ptr, size_t sz);