Skip to content

Commit

Permalink
Externalize adecode (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbatalov authored Jan 15, 2025
1 parent a09aa10 commit 0609bcf
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 1,337 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
7 changes: 4 additions & 3 deletions src/game/sfxcache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/game/sfxlist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
7 changes: 4 additions & 3 deletions src/int/audio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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;
Expand All @@ -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);
}
Expand Down
7 changes: 4 additions & 3 deletions src/int/audiof.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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;
Expand All @@ -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);
}
Expand Down
Loading

0 comments on commit 0609bcf

Please sign in to comment.