mirror of
https://github.com/alexbatalov/fallout1-ce.git
synced 2025-12-19 18:06:12 -05:00
Externalize adecode (#211)
This commit is contained in:
committed by
GitHub
parent
a09aa10e14
commit
0609bcfd0e
@@ -257,8 +257,6 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
|
||||
"src/plib/gnw/winmain.h"
|
||||
"src/movie_lib.cc"
|
||||
"src/movie_lib.h"
|
||||
"src/sound_decoder.cc"
|
||||
"src/sound_decoder.h"
|
||||
)
|
||||
|
||||
target_sources(${EXECUTABLE_NAME} PUBLIC
|
||||
@@ -353,6 +351,9 @@ else()
|
||||
find_package(SDL2)
|
||||
endif()
|
||||
|
||||
add_subdirectory("third_party/adecode")
|
||||
target_link_libraries(${EXECUTABLE_NAME} adecode::adecode)
|
||||
|
||||
add_subdirectory("third_party/fpattern")
|
||||
target_link_libraries(${EXECUTABLE_NAME} fpattern::fpattern)
|
||||
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <adecode/adecode.h>
|
||||
|
||||
#include "game/cache.h"
|
||||
#include "game/gconfig.h"
|
||||
#include "game/sfxlist.h"
|
||||
#include "plib/db/db.h"
|
||||
#include "plib/gnw/memory.h"
|
||||
#include "sound_decoder.h"
|
||||
|
||||
namespace fallout {
|
||||
|
||||
@@ -42,7 +43,7 @@ static void sfxc_handle_destroy(int handle);
|
||||
static bool sfxc_handle_is_legal(int a1);
|
||||
static bool sfxc_mode_is_legal(int mode);
|
||||
static int sfxc_decode(int handle, void* buf, unsigned int size);
|
||||
static int sfxc_ad_reader(void* stream, void* buf, unsigned int size);
|
||||
static unsigned int sfxc_ad_reader(void* stream, void* buf, unsigned int size);
|
||||
|
||||
// 0x507A70
|
||||
static int sfxc_dlevel = INT_MAX;
|
||||
@@ -515,7 +516,7 @@ static int sfxc_decode(int handle, void* buf, unsigned int size)
|
||||
}
|
||||
|
||||
// 0x4978F0
|
||||
static int sfxc_ad_reader(void* stream, void* buf, unsigned int size)
|
||||
static unsigned int sfxc_ad_reader(void* stream, void* buf, unsigned int size)
|
||||
{
|
||||
if (size == 0) {
|
||||
return 0;
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <adecode/adecode.h>
|
||||
|
||||
#include "platform_compat.h"
|
||||
#include "plib/db/db.h"
|
||||
#include "plib/gnw/debug.h"
|
||||
#include "plib/gnw/memory.h"
|
||||
#include "sound_decoder.h"
|
||||
|
||||
namespace fallout {
|
||||
|
||||
@@ -27,7 +28,7 @@ static int sfxl_copy_names(char** fileNameList);
|
||||
static int sfxl_get_sizes();
|
||||
static int sfxl_sort_by_name();
|
||||
static int sfxl_compare_by_name(const void* a1, const void* a2);
|
||||
static int sfxl_ad_reader(void* stream, void* buf, unsigned int size);
|
||||
static unsigned int sfxl_ad_reader(void* stream, void* buf, unsigned int size);
|
||||
|
||||
// 0x507A8C
|
||||
static bool sfxl_initialized = false;
|
||||
@@ -408,7 +409,7 @@ static int sfxl_compare_by_name(const void* a1, const void* a2)
|
||||
}
|
||||
|
||||
// 0x4980A0
|
||||
static int sfxl_ad_reader(void* stream, void* buf, unsigned int size)
|
||||
static unsigned int sfxl_ad_reader(void* stream, void* buf, unsigned int size)
|
||||
{
|
||||
return db_fread(buf, 1, size, (DB_FILE*)stream);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <adecode/adecode.h>
|
||||
|
||||
#include "int/memdbg.h"
|
||||
#include "int/sound.h"
|
||||
#include "plib/db/db.h"
|
||||
#include "plib/gnw/debug.h"
|
||||
#include "sound_decoder.h"
|
||||
|
||||
namespace fallout {
|
||||
|
||||
@@ -28,7 +29,7 @@ typedef struct Audio {
|
||||
} Audio;
|
||||
|
||||
static bool defaultCompressionFunc(char* filePath);
|
||||
static int decodeRead(void* stream, void* buf, unsigned int size);
|
||||
static unsigned int decodeRead(void* stream, void* buf, unsigned int size);
|
||||
|
||||
// 0x4FEC00
|
||||
static AudioQueryCompressedFunc* queryCompressedFunc = defaultCompressionFunc;
|
||||
@@ -51,7 +52,7 @@ static bool defaultCompressionFunc(char* filePath)
|
||||
}
|
||||
|
||||
// 0x419910
|
||||
static int decodeRead(void* stream, void* buffer, unsigned int size)
|
||||
static unsigned int decodeRead(void* stream, void* buffer, unsigned int size)
|
||||
{
|
||||
return db_fread(buffer, 1, size, (DB_FILE*)stream);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <adecode/adecode.h>
|
||||
|
||||
#include "int/memdbg.h"
|
||||
#include "int/sound.h"
|
||||
#include "platform_compat.h"
|
||||
#include "plib/gnw/debug.h"
|
||||
#include "sound_decoder.h"
|
||||
|
||||
namespace fallout {
|
||||
|
||||
@@ -28,7 +29,7 @@ typedef struct AudioFile {
|
||||
} AudioFile;
|
||||
|
||||
static bool defaultCompressionFunc(char* filePath);
|
||||
static int decodeRead(void* stream, void* buffer, unsigned int size);
|
||||
static unsigned int decodeRead(void* stream, void* buffer, unsigned int size);
|
||||
|
||||
// 0x4FEC04
|
||||
static AudioFileQueryCompressedFunc* queryCompressedFunc = defaultCompressionFunc;
|
||||
@@ -51,7 +52,7 @@ static bool defaultCompressionFunc(char* filePath)
|
||||
}
|
||||
|
||||
// 0x419EB0
|
||||
static int decodeRead(void* stream, void* buffer, unsigned int size)
|
||||
static unsigned int decodeRead(void* stream, void* buffer, unsigned int size)
|
||||
{
|
||||
return fread(buffer, 1, size, (FILE*)stream);
|
||||
}
|
||||
|
||||
1309
src/sound_decoder.cc
1309
src/sound_decoder.cc
File diff suppressed because it is too large
Load Diff
@@ -1,14 +0,0 @@
|
||||
#ifndef FALLOUT_SOUND_DECODER_H_
|
||||
#define FALLOUT_SOUND_DECODER_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef int(AudioDecoderReadFunc)(void* data, void* buffer, unsigned int size);
|
||||
|
||||
typedef struct _AudioDecoder AudioDecoder;
|
||||
|
||||
size_t AudioDecoder_Read(AudioDecoder* ad, void* buffer, size_t size);
|
||||
void AudioDecoder_Close(AudioDecoder* ad);
|
||||
AudioDecoder* Create_AudioDecoder(AudioDecoderReadFunc* reader, void* data, int* channels, int* sampleRate, int* sampleCount);
|
||||
|
||||
#endif /* FALLOUT_SOUND_DECODER_H_ */
|
||||
10
third_party/adecode/CMakeLists.txt
vendored
Normal file
10
third_party/adecode/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(adecode
|
||||
GIT_REPOSITORY "https://github.com/alexbatalov/adecode"
|
||||
GIT_TAG e4a8b0f3b66826e0b7779a25d79df8497f8f8087 # v1.0.0
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(adecode)
|
||||
Reference in New Issue
Block a user