Compare commits
13 Commits
b7ae166e65
...
more_music
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d685fcdb9 | |||
| ebc969603d | |||
| d0b3ce1bd0 | |||
| 97a83b20f6 | |||
| 9ad3754829 | |||
| 0522e842c4 | |||
| 9ba6071f9b | |||
| 131323fbea | |||
| e77c85b004 | |||
| 11d5f34522 | |||
| 285cc9b5ad | |||
| b4438c1510 | |||
| 989b0d30cc |
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Vendored
+1
-1
Submodule External/tely updated: a1e15e336b...4a4c88a9f0
@@ -1,25 +1,5 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set script_dir_backslash=%~dp0
|
||||
set script_dir=%script_dir_backslash:~0,-1%
|
||||
set build_dir=%script_dir%\Build
|
||||
set code_dir=%script_dir%
|
||||
call build_all.bat %* --fast-dev-build || exit /b 1
|
||||
|
||||
REM Bootstrap a version
|
||||
git show -s --date=format:%%Y-%%m-%%d --format=%%cd HEAD> feely_pona_version.txt
|
||||
git rev-parse --short=8 HEAD>> feely_pona_version.txt
|
||||
git rev-list --count HEAD>> feely_pona_version.txt
|
||||
|
||||
REM Bootstrap the build program
|
||||
mkdir %build_dir% 2>nul
|
||||
pushd %build_dir%
|
||||
cl /nologo /Z7 /W4 %code_dir%\feely_pona_build.cpp || exit /B 1
|
||||
copy feely_pona_build.exe %code_dir% 1>nul
|
||||
popd
|
||||
|
||||
REM Run the build program
|
||||
%code_dir%\feely_pona_build.exe %* || exit /B 1
|
||||
|
||||
popd
|
||||
exit /B 1
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set script_dir_backslash=%~dp0
|
||||
set script_dir=%script_dir_backslash:~0,-1%
|
||||
set build_dir=%script_dir%\Build
|
||||
set code_dir=%script_dir%
|
||||
|
||||
REM Bootstrap a version
|
||||
git show -s --date=format:%%Y-%%m-%%d --format=%%cd HEAD> feely_pona_version.txt
|
||||
git rev-parse --short=8 HEAD>> feely_pona_version.txt
|
||||
git rev-list --count HEAD>> feely_pona_version.txt
|
||||
|
||||
REM Bootstrap the build program
|
||||
mkdir %build_dir% 2>nul
|
||||
pushd %build_dir%
|
||||
cl /nologo /Z7 /W4 %code_dir%\feely_pona_build.cpp || exit /B 1
|
||||
copy feely_pona_build.exe %code_dir% 1>nul
|
||||
popd
|
||||
|
||||
REM Run the build program
|
||||
%code_dir%\feely_pona_build.exe %* || exit /B 1
|
||||
|
||||
popd
|
||||
exit /B 1
|
||||
+4
-4
@@ -5,7 +5,7 @@ set script_dir_backslash=%~dp0
|
||||
set script_dir=%script_dir_backslash:~0,-1%
|
||||
set build_dir=%script_dir%\Build
|
||||
|
||||
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.html doylet@doylet.dev:/selfhost/TerryCherry/index.html
|
||||
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.data doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.data
|
||||
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.js doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.js
|
||||
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.wasm doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.wasm
|
||||
scp -P 8110 %build_dir%\Terry_Cherry\Terry_Cherry.html doylet@doylet.dev:/selfhost/TerryCherry/index.html
|
||||
scp -P 8110 %build_dir%\Terry_Cherry\Terry_Cherry.data doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.data
|
||||
scp -P 8110 %build_dir%\Terry_Cherry\Terry_Cherry.js doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.js
|
||||
scp -P 8110 %build_dir%\Terry_Cherry\Terry_Cherry.wasm doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.wasm
|
||||
|
||||
+540
-320
File diff suppressed because it is too large
Load Diff
@@ -165,6 +165,12 @@ struct FP_ParticleDescriptor
|
||||
Dqn_usize duration_ms;
|
||||
};
|
||||
|
||||
struct FP_ListenForNewPlayerResult
|
||||
{
|
||||
bool yes;
|
||||
bool tutorial_requested;
|
||||
};
|
||||
|
||||
#if defined(DQN_PLATFORM_EMSCRIPTEN)
|
||||
#define FP_DEVELOPER_MODE 0
|
||||
#else
|
||||
|
||||
+101
-20
@@ -97,7 +97,7 @@ int main(int argc, char const **argv)
|
||||
dry_run = true;
|
||||
} else if (arg == DQN_STR8("--web")) {
|
||||
target_web = true;
|
||||
} else if (arg == DQN_STR8("--dev-fast-build")) {
|
||||
} else if (arg == DQN_STR8("--fast-dev-build")) {
|
||||
dev_fast_build = true;
|
||||
} else {
|
||||
PRINT_HELP;
|
||||
@@ -229,6 +229,38 @@ int main(int argc, char const **argv)
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: sokol_audio ================================================================================
|
||||
Dqn_Str8 sokol_audio_source_code_file = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/sokol/sokol_audio.c", DQN_STR_FMT(tely_dir));
|
||||
uint64_t sokol_audio_pc_timings[2] = {};
|
||||
Dqn_List<Dqn_Str8> sokol_audio_pc_output_files = Dqn_List_Init<Dqn_Str8>(scratch.arena, 16);
|
||||
{
|
||||
sokol_audio_pc_timings[0] = Dqn_OS_PerfCounterNow();
|
||||
DQN_DEFER { sokol_audio_pc_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||
|
||||
Dqn_CPPBuildContext build_context = {};
|
||||
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||
Dqn_CPPBuildCompileFile{
|
||||
{}, // Args
|
||||
sokol_audio_source_code_file,
|
||||
},
|
||||
});
|
||||
|
||||
Dqn_List_Add(&sokol_audio_pc_output_files, DQN_STR8("sokol_audio.obj"));
|
||||
|
||||
Dqn_List<Dqn_Str8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 16, common_compile_flags);
|
||||
Dqn_List_Add(&compile_flags, DQN_STR8("/c"));
|
||||
build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
||||
build_context.build_dir = build_dir;
|
||||
|
||||
if (dry_run) {
|
||||
Dqn_Str8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STR_FMT(cmd));
|
||||
} else {
|
||||
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: QOI Converter =========================================================================
|
||||
uint64_t qoi_converter_timings[2] = {};
|
||||
{
|
||||
@@ -286,6 +318,8 @@ int main(int argc, char const **argv)
|
||||
{
|
||||
for (Dqn_ListIterator<Dqn_Str8> it = {}; Dqn_List_Iterate(&raylib_pc_output_files, &it, 0); )
|
||||
Dqn_List_Add(&link_flags, *it.data);
|
||||
for (Dqn_ListIterator<Dqn_Str8> it = {}; Dqn_List_Iterate(&sokol_audio_pc_output_files, &it, 0); )
|
||||
Dqn_List_Add(&link_flags, *it.data);
|
||||
Dqn_List_Add(&link_flags, DQN_STR8("gdi32.lib"));
|
||||
Dqn_List_Add(&link_flags, DQN_STR8("opengl32.lib"));
|
||||
Dqn_List_Add(&link_flags, DQN_STR8("winmm.lib"));
|
||||
@@ -302,14 +336,21 @@ int main(int argc, char const **argv)
|
||||
DQN_DEFER { feely_pona_no_dll_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||
|
||||
Dqn_CPPBuildCompileFile build_file = {};
|
||||
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity_nodll.h", DQN_STR_FMT(code_dir));
|
||||
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity.h", DQN_STR_FMT(code_dir));
|
||||
build_file.output_file_path = Dqn_FsPath_ConvertF(scratch.arena, "terry_cherry");
|
||||
build_file.flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STR8("/Tp")});
|
||||
|
||||
Dqn_List<Dqn_Str8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 16, common_compile_flags);
|
||||
Dqn_List_AddCArray(&compile_flags, {
|
||||
DQN_STR8("/D TELY_WITH_PLATFORM"),
|
||||
DQN_STR8("/D FEELY_PONA_IMPLEMENTATION"),
|
||||
});
|
||||
|
||||
Dqn_CPPBuildContext feely_pona_no_dll_build_context = {};
|
||||
feely_pona_no_dll_build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||
feely_pona_no_dll_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||
feely_pona_no_dll_build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {raylib_dir});
|
||||
feely_pona_no_dll_build_context.compile_flags = common_compile_flags;
|
||||
feely_pona_no_dll_build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
||||
feely_pona_no_dll_build_context.build_dir = build_dir;
|
||||
feely_pona_no_dll_build_context.link_flags = feely_pona_platform_link_flags;
|
||||
|
||||
@@ -329,12 +370,14 @@ int main(int argc, char const **argv)
|
||||
|
||||
Dqn_CPPBuildCompileFile build_file = {};
|
||||
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity.h", DQN_STR_FMT(code_dir));
|
||||
build_file.output_file_path = Dqn_FsPath_ConvertF(scratch.arena, "tely_dll_msvc", DQN_STR_FMT(code_dir));
|
||||
build_file.output_file_path = Dqn_FsPath_ConvertF(scratch.arena, "terry_cherry_dev_dll");
|
||||
build_file.flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STR8("/Tp")});
|
||||
|
||||
Dqn_List<Dqn_Str8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_compile_flags);
|
||||
Dqn_List_Add(&compile_flags, DQN_STR8("/LD"));
|
||||
Dqn_List_Add(&compile_flags, DQN_STR8("/Fetely_dll_msvc"));
|
||||
Dqn_List<Dqn_Str8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 16, common_compile_flags);
|
||||
Dqn_List_AddCArray(&compile_flags, {
|
||||
DQN_STR8("/LD"),
|
||||
DQN_STR8("/D FEELY_PONA_IMPLEMENTATION"),
|
||||
});
|
||||
|
||||
if (!dev_fast_build)
|
||||
Dqn_List_Add(&compile_flags, DQN_STR8("/analyze"));
|
||||
@@ -361,12 +404,15 @@ int main(int argc, char const **argv)
|
||||
DQN_DEFER { feely_pona_platform_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||
|
||||
Dqn_CPPBuildCompileFile build_file = {};
|
||||
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/tely_platform_raylib_unity.h", DQN_STR_FMT(tely_dir));
|
||||
build_file.output_file_path = Dqn_FsPath_ConvertF(scratch.arena, "feely_pona_msvc", DQN_STR_FMT(code_dir));
|
||||
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity.h", DQN_STR_FMT(code_dir));
|
||||
build_file.output_file_path = Dqn_FsPath_ConvertF(scratch.arena, "terry_cherry_dev", DQN_STR_FMT(code_dir));
|
||||
build_file.flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STR8("/Tp")});
|
||||
|
||||
Dqn_List<Dqn_Str8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_compile_flags);
|
||||
Dqn_List_Add(&compile_flags, DQN_STR8("/Fefeely_pona_msvc"));
|
||||
Dqn_List_AddCArray(&compile_flags, {
|
||||
DQN_STR8("/D TELY_WITH_PLATFORM"),
|
||||
DQN_STR8("/D TELY_WITH_PLATFORM_DLL"),
|
||||
});
|
||||
|
||||
Dqn_CPPBuildContext build_context = {};
|
||||
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||
@@ -380,7 +426,7 @@ int main(int argc, char const **argv)
|
||||
Dqn_Str8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STR_FMT(cmd));
|
||||
} else {
|
||||
Dqn_Str8 exe_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_msvc.exe", DQN_STR_FMT(build_dir));
|
||||
Dqn_Str8 exe_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/terry_cherry_dev.exe", DQN_STR_FMT(build_dir));
|
||||
bool exe_is_locked = false;
|
||||
if (Dqn_Fs_Exists(exe_path)) {
|
||||
Dqn_FsFile exe_file = Dqn_Fs_OpenFile(exe_path, Dqn_FsFileOpen_OpenIfExist, Dqn_FsFileAccess_Read | Dqn_FsFileAccess_Write);
|
||||
@@ -422,9 +468,9 @@ int main(int argc, char const **argv)
|
||||
DQN_DEFER { raylib_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||
|
||||
// NOTE: Setup build context ===========================================================
|
||||
Dqn_List<Dqn_Str8> raylib_emscripten_output_files = Dqn_List_Init<Dqn_Str8>(scratch.arena, 16);
|
||||
Dqn_CPPBuildContext raylib_emscripten_build_context = {};
|
||||
raylib_emscripten_build_context.compiler = Dqn_CPPBuildCompiler_GCC;
|
||||
Dqn_List<Dqn_Str8> emscripten_obj_files = Dqn_List_Init<Dqn_Str8>(scratch.arena, 16);
|
||||
Dqn_CPPBuildContext raylib_emscripten_build_context = {};
|
||||
raylib_emscripten_build_context.compiler = Dqn_CPPBuildCompiler_GCC;
|
||||
|
||||
for (Dqn_Str8 base_file : raylib_base_files) {
|
||||
Dqn_Str8 file_stem = Dqn_Str8_FileNameNoExtension(base_file);
|
||||
@@ -449,7 +495,7 @@ int main(int argc, char const **argv)
|
||||
raylib_emscripten_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||
raylib_emscripten_build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
||||
raylib_emscripten_build_context.build_dir = build_dir;
|
||||
Dqn_List_Add(&raylib_emscripten_output_files, build_file.output_file_path);
|
||||
Dqn_List_Add(&emscripten_obj_files, build_file.output_file_path);
|
||||
|
||||
if (dry_run) {
|
||||
Dqn_Str8 cmd = Dqn_CPPBuild_ToCommandLine(raylib_emscripten_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||
@@ -459,13 +505,45 @@ int main(int argc, char const **argv)
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Build the wasm raylib library =================================================
|
||||
{
|
||||
Dqn_Str8 base_file = sokol_audio_source_code_file;
|
||||
Dqn_Str8 file_stem = Dqn_Str8_FileNameNoExtension(base_file);
|
||||
|
||||
// NOTE: Append "emscripten" suffix to the object files
|
||||
Dqn_CPPBuildCompileFile build_file = {};
|
||||
build_file.input_file_path = base_file;
|
||||
build_file.output_file_path = Dqn_Str8_InitF(scratch.allocator, "sokol_audio_emscripten.o");
|
||||
|
||||
Dqn_List<Dqn_Str8> compile_flags = Dqn_List_InitCArrayCopy(scratch.arena, 32, {
|
||||
DQN_STR8("cmd"),
|
||||
DQN_STR8("/C"),
|
||||
DQN_STR8("emcc.bat"),
|
||||
DQN_STR8("-c"), // Compile and assemble, but do not link
|
||||
DQN_STR8("-Wall"),
|
||||
DQN_STR8("-Os"), // Optimize for size
|
||||
});
|
||||
Dqn_List_AddList(&compile_flags, build_specific_compile_flags);
|
||||
|
||||
raylib_emscripten_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||
raylib_emscripten_build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
||||
raylib_emscripten_build_context.build_dir = build_dir;
|
||||
Dqn_List_Add(&emscripten_obj_files, build_file.output_file_path);
|
||||
|
||||
if (dry_run) {
|
||||
Dqn_Str8 cmd = Dqn_CPPBuild_ToCommandLine(raylib_emscripten_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STR_FMT(cmd));
|
||||
} else {
|
||||
Dqn_CPPBuild_ExecOrAbort(raylib_emscripten_build_context, Dqn_CPPBuildMode_CacheBuild);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Build the wasm raylib+sokol_audio library =====================================
|
||||
{
|
||||
Dqn_Str8Builder builder = {};
|
||||
builder.allocator = scratch.allocator;
|
||||
Dqn_Str8Builder_AppendF(&builder, "cmd /C emar.bat rcs %.*s", DQN_STR_FMT(raylib_emscripten_lib_name));
|
||||
|
||||
for (Dqn_ListIterator<Dqn_Str8> it = {}; Dqn_List_Iterate(&raylib_emscripten_output_files, &it, 0); )
|
||||
for (Dqn_ListIterator<Dqn_Str8> it = {}; Dqn_List_Iterate(&emscripten_obj_files, &it, 0); )
|
||||
Dqn_Str8Builder_AppendF(&builder, " %.*s", DQN_STR_FMT(*it.data));
|
||||
|
||||
Dqn_Str8 cmd = Dqn_Str8Builder_Build(&builder, scratch.allocator);
|
||||
@@ -528,7 +606,7 @@ int main(int argc, char const **argv)
|
||||
Dqn_CPPBuildContext build_context = {};
|
||||
build_context.compile_file_obj_suffix = DQN_CPP_BUILD_OBJ_SUFFIX_O;
|
||||
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity_nodll.cpp", DQN_STR_FMT(code_dir)) },
|
||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity.cpp", DQN_STR_FMT(code_dir)) },
|
||||
});
|
||||
|
||||
Dqn_Str8 output_name = DQN_STR8("Terry_Cherry");
|
||||
@@ -545,6 +623,8 @@ int main(int argc, char const **argv)
|
||||
DQN_STR8("--preload-file"), DQN_STR8("Data"),
|
||||
DQN_STR8("-msimd128"),
|
||||
DQN_STR8("-msse2"),
|
||||
DQN_STR8("-D"), DQN_STR8("TELY_WITH_PLATFORM"),
|
||||
DQN_STR8("-D"), DQN_STR8("FEELY_PONA_IMPLEMENTATION"),
|
||||
});
|
||||
Dqn_List_AddList(&compile_flags, build_specific_compile_flags);
|
||||
|
||||
@@ -559,7 +639,7 @@ int main(int argc, char const **argv)
|
||||
}
|
||||
|
||||
// NOTE: Move the files to a directory
|
||||
Dqn_Str8 folder_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s_Emscripten", DQN_STR_FMT(build_dir), DQN_STR_FMT(output_name));
|
||||
Dqn_Str8 folder_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s", DQN_STR_FMT(build_dir), DQN_STR_FMT(output_name));
|
||||
if (!Dqn_Fs_DirExists(folder_path)) {
|
||||
Dqn_Str8 mkdir_cmd = Dqn_Str8_InitF(scratch.allocator, "mkdir %.*s", DQN_STR_FMT(folder_path));
|
||||
Dqn_OS_ExecOrAbort(mkdir_cmd, {});
|
||||
@@ -588,7 +668,8 @@ int main(int argc, char const **argv)
|
||||
build_timings[1] = Dqn_OS_PerfCounterNow();
|
||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "\n-- Dqn_CPPBuild Timings (%.2fms)", Dqn_OS_PerfCounterMs(build_timings[0], build_timings[1]));
|
||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " robocopy: %.2fms", Dqn_OS_PerfCounterMs(robocopy_timings[0], robocopy_timings[1]));
|
||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " raylib: %.2fms", Dqn_OS_PerfCounterMs(raylib_pc_timings[0], raylib_pc_timings[1]));
|
||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " raylib: %.2fms", Dqn_OS_PerfCounterMs(raylib_pc_timings[0], raylib_pc_timings[1]));
|
||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " sokol_audio: %.2fms", Dqn_OS_PerfCounterMs(sokol_audio_pc_timings[0], sokol_audio_pc_timings[1]));
|
||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " qoi_converter: %.2fms", Dqn_OS_PerfCounterMs(qoi_converter_timings[0], qoi_converter_timings[1]));
|
||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona sprite packer: %.2fms", Dqn_OS_PerfCounterMs(feely_pona_sprite_packer_timings[0], feely_pona_sprite_packer_timings[1]));
|
||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (no dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_no_dll_timings[0], feely_pona_no_dll_timings[1]));
|
||||
|
||||
@@ -185,6 +185,7 @@ static FP_GameEntityHandle FP_Entity_CreateTerryInternal(FP_Game *game, Dqn_V2 p
|
||||
entity->local_hit_box_size = FP_Game_MetersToPixelsNx2(game->play, 0.5f, entity->sprite_height.meters * .6f);
|
||||
entity->hp_cap = FP_DEFAULT_DAMAGE * 3;
|
||||
entity->hp = entity->hp_cap;
|
||||
entity->coins = 10;
|
||||
FP_Entity_AddDebugEditorFlags(game, result);
|
||||
entity->flags |= FP_GameEntityFlag_NonTraversable;
|
||||
entity->flags |= FP_GameEntityFlag_Attackable;
|
||||
|
||||
+7
-6
@@ -3,24 +3,24 @@
|
||||
#include "feely_pona_unity.h"
|
||||
#endif
|
||||
|
||||
static bool FP_Game_KeyBindIsPressed(TELY_PlatformInput const *input, FP_GameControls const *controls, FP_GameKeyBind key_bind)
|
||||
static bool FP_Game_KeyBindIsPressed(TELY_OSInput const *input, FP_GameControls const *controls, FP_GameKeyBind key_bind)
|
||||
{
|
||||
bool result = false;
|
||||
if (controls->mode == FP_GameControlMode_Keyboard) {
|
||||
result = TELY_Platform_InputScanCodeIsPressed(input, key_bind.scan_code);
|
||||
result = TELY_OSInput_ScanKeyIsPressed(input, key_bind.scan_key);
|
||||
} else {
|
||||
result = TELY_Platform_InputGamepadKeyIsPressed(input, controls->gamepad_index, key_bind.gamepad_key);
|
||||
result = TELY_OSInput_GamepadKeyIsPressed(input, controls->gamepad_index, key_bind.gamepad_key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool FP_Game_KeyBindIsDown(TELY_PlatformInput const *input, FP_GameControls const *controls, FP_GameKeyBind key_bind)
|
||||
static bool FP_Game_KeyBindIsDown(TELY_OSInput const *input, FP_GameControls const *controls, FP_GameKeyBind key_bind)
|
||||
{
|
||||
bool result = false;
|
||||
if (controls->mode == FP_GameControlMode_Keyboard) {
|
||||
result = TELY_Platform_InputScanCodeIsDown(input, key_bind.scan_code);
|
||||
result = TELY_OSInput_ScanKeyIsDown(input, key_bind.scan_key);
|
||||
} else {
|
||||
result = TELY_Platform_InputGamepadKeyIsDown(input, controls->gamepad_index, key_bind.gamepad_key);
|
||||
result = TELY_OSInput_GamepadKeyIsDown(input, controls->gamepad_index, key_bind.gamepad_key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -250,6 +250,7 @@ static FP_GameEntity *FP_Game_MakeEntityPointerFV(FP_Game *game, DQN_FMT_ATTRIB
|
||||
result->buildings_visited = FP_SentinelList_Init<FP_GameEntityHandle>(game->play.chunk_pool);
|
||||
result->action.sprite_alpha = 1.f;
|
||||
result->stamina_cap = 93;
|
||||
result->stamina = result->stamina_cap;
|
||||
|
||||
result->hp_cap = DQN_CAST(uint32_t)(FP_DEFAULT_DAMAGE * .8f);
|
||||
result->hp = result->hp_cap;
|
||||
|
||||
+51
-6
@@ -168,8 +168,8 @@ enum FP_GameInGameMenu
|
||||
|
||||
struct FP_GameKeyBind
|
||||
{
|
||||
TELY_PlatformInputScanCode scan_code;
|
||||
TELY_PlatformInputGamepadKey gamepad_key;
|
||||
TELY_OSInputScanKey scan_key;
|
||||
TELY_OSInputGamepadKey gamepad_key;
|
||||
};
|
||||
|
||||
enum FP_GameControlMode
|
||||
@@ -334,12 +334,19 @@ enum FP_GameAudio
|
||||
FP_GameAudio_Message,
|
||||
FP_GameAudio_Monkey,
|
||||
FP_GameAudio_PortalDestroy,
|
||||
FP_GameAudio_GameStart,
|
||||
FP_GameAudio_PerryStart,
|
||||
FP_GameAudio_Ambience1,
|
||||
FP_GameAudio_Ambience2,
|
||||
FP_GameAudio_Music1,
|
||||
FP_GameAudio_Music2,
|
||||
FP_GameAudio_Count,
|
||||
};
|
||||
|
||||
enum FP_GameState
|
||||
{
|
||||
FP_GameState_IntroScreen,
|
||||
FP_GameState_Tutorial,
|
||||
FP_GameState_Play,
|
||||
FP_GameState_Pause,
|
||||
FP_GameState_WinGame,
|
||||
@@ -365,6 +372,35 @@ struct FP_Particle
|
||||
Dqn_usize end_ms;
|
||||
};
|
||||
|
||||
enum FP_GameStateTutorial
|
||||
{
|
||||
FP_GameStateTutorial_ShowPlayer,
|
||||
FP_GameStateTutorial_ShowPlayerWait,
|
||||
FP_GameStateTutorial_ShowPortalOne,
|
||||
FP_GameStateTutorial_ShowPortalOneWait,
|
||||
FP_GameStateTutorial_ShowPortalTwo,
|
||||
FP_GameStateTutorial_ShowPortalTwoWait,
|
||||
FP_GameStateTutorial_ShowPortalThree,
|
||||
FP_GameStateTutorial_ShowPortalThreeWait,
|
||||
FP_GameStateTutorial_ShowBillboardBuild,
|
||||
FP_GameStateTutorial_ShowBillboardBuildWait,
|
||||
FP_GameStateTutorial_Count,
|
||||
};
|
||||
|
||||
Dqn_V2 const FP_MONKEY_SPAWN_LOCATIONS[] =
|
||||
{
|
||||
Dqn_V2_InitNx2(-592, 538),
|
||||
Dqn_V2_InitNx2(-1503, -568),
|
||||
Dqn_V2_InitNx2(1890, 1150),
|
||||
Dqn_V2_InitNx2(1815, -1192),
|
||||
Dqn_V2_InitNx2(520, 1230),
|
||||
Dqn_V2_InitNx2(-934, -238),
|
||||
Dqn_V2_InitNx2(1915, 15),
|
||||
Dqn_V2_InitNx2(247, 560),
|
||||
Dqn_V2_InitNx2(-290, -1120),
|
||||
Dqn_V2_InitNx2(1126, -646),
|
||||
};
|
||||
|
||||
struct FP_GamePlay
|
||||
{
|
||||
TELY_ChunkPool *chunk_pool;
|
||||
@@ -388,6 +424,7 @@ struct FP_GamePlay
|
||||
FP_GameEntityHandle merchant_graveyard;
|
||||
FP_GameEntityHandle merchant_gym;
|
||||
FP_GameEntityHandle merchant_phone_company;
|
||||
FP_GameEntityHandle billboard_build;
|
||||
|
||||
FP_GameEntityHandle clicked_entity;
|
||||
FP_GameEntityHandle hot_entity;
|
||||
@@ -429,22 +466,30 @@ struct FP_GamePlay
|
||||
|
||||
FP_Particle particles[256];
|
||||
uint32_t particle_next_index;
|
||||
|
||||
FP_GameStateTutorial tutorial_state;
|
||||
uint64_t tutorial_wait_end_time_ms;
|
||||
|
||||
uint8_t monkey_spawn_shuffled_list[DQN_ARRAY_UCOUNT(FP_MONKEY_SPAWN_LOCATIONS)];
|
||||
uint8_t monkey_spawn_count;
|
||||
};
|
||||
|
||||
struct FP_Game
|
||||
{
|
||||
TELY_AssetFontHandle inter_regular_font_large;
|
||||
TELY_AssetFontHandle inter_regular_font;
|
||||
TELY_AssetFontHandle inter_italic_font;
|
||||
TELY_AssetFontHandle jetbrains_mono_font;
|
||||
TELY_AssetFontHandle talkco_font;
|
||||
TELY_AssetFontHandle talkco_font_large;
|
||||
TELY_AssetFontHandle talkco_font_xlarge;
|
||||
|
||||
TELY_AssetAudioHandle audio[FP_GameAudio_Count];
|
||||
TELY_AssetSpriteSheet atlas_sprite_sheet;
|
||||
TELY_RFui rfui;
|
||||
FP_GamePlay play;
|
||||
Dqn_Arena *frame_arena;
|
||||
uint16_t font_size;
|
||||
uint16_t large_font_size;
|
||||
uint16_t large_talkco_font_size;
|
||||
uint16_t xlarge_talkco_font_size;
|
||||
};
|
||||
|
||||
struct FP_GameAStarNode
|
||||
@@ -473,7 +518,7 @@ FP_GamePlaceableBuilding const PLACEABLE_BUILDINGS[] = {
|
||||
{FP_EntityType_AirportTerry, FP_EntityAirportTerryState_Idle},
|
||||
{FP_EntityType_ChurchTerry, FP_EntityChurchTerryState_Idle},
|
||||
{FP_EntityType_ClubTerry, FP_EntityClubTerryState_Idle},
|
||||
{FP_EntityType_KennelTerry, FP_EntityKennelTerryState_Idle},
|
||||
// {FP_EntityType_KennelTerry, FP_EntityKennelTerryState_Idle},
|
||||
};
|
||||
|
||||
struct FP_GameCanMoveToPositionResult
|
||||
|
||||
+7
-7
@@ -3,7 +3,7 @@
|
||||
#include "feely_pona_unity.h"
|
||||
#endif
|
||||
|
||||
void FP_UnitTests(TELY_Platform *platform)
|
||||
void FP_UnitTests(TELY_OS *os)
|
||||
{
|
||||
{
|
||||
uint32_t array[] = {1};
|
||||
@@ -318,9 +318,9 @@ void FP_UnitTests(TELY_Platform *platform)
|
||||
}
|
||||
|
||||
{
|
||||
Dqn_Arena_TempMemoryScope(&platform->arena);
|
||||
Dqn_Arena_TempMemoryScope(&os->arena);
|
||||
TELY_ChunkPool pool = {};
|
||||
pool.arena = &platform->arena;
|
||||
pool.arena = &os->arena;
|
||||
|
||||
void *bytes16 = TELY_ChunkPool_Alloc(&pool, 16);
|
||||
TELY_ChunkPool_Dealloc(&pool, bytes16);
|
||||
@@ -346,13 +346,13 @@ void FP_UnitTests(TELY_Platform *platform)
|
||||
}
|
||||
|
||||
// NOTE: Unit test DFS pre-order and post-order walk
|
||||
Dqn_Arena_TempMemoryScope(&platform->arena);
|
||||
Dqn_Arena_TempMemoryScope(&os->arena);
|
||||
TELY_ChunkPool chunk_pool = {};
|
||||
chunk_pool.arena = &platform->arena;
|
||||
chunk_pool.arena = &os->arena;
|
||||
|
||||
FP_Game *game = Dqn_Arena_New(&platform->arena, FP_Game, Dqn_ZeroMem_Yes);
|
||||
FP_Game *game = Dqn_Arena_New(&os->arena, FP_Game, Dqn_ZeroMem_Yes);
|
||||
game->play.chunk_pool = &chunk_pool;
|
||||
game->play.entities = Dqn_VArray_Init<FP_GameEntity>(&platform->arena, 1024 * 8);
|
||||
game->play.entities = Dqn_VArray_Init<FP_GameEntity>(&os->arena, 1024 * 8);
|
||||
game->play.root_entity = Dqn_VArray_Make(&game->play.entities, Dqn_ZeroMem_No);
|
||||
Dqn_FArray_Add(&game->play.parent_entity_stack, game->play.root_entity->handle);
|
||||
|
||||
|
||||
@@ -37,17 +37,17 @@ struct SpriteSpecification
|
||||
uint16_t frames_per_second;
|
||||
};
|
||||
|
||||
static Dqn_String8 SpriteAnimNameFromFilePath(Dqn_String8 path)
|
||||
static Dqn_Str8 SpriteAnimNameFromFilePath(Dqn_Str8 path)
|
||||
{
|
||||
// NOTE: Enumerate the number of frames for this animation =================================
|
||||
Dqn_String8 file_name = Dqn_String8_FileNameFromPath(path);
|
||||
Dqn_String8 file_name_without_extension = Dqn_String8_BinarySplit(file_name, DQN_STRING8(".")).lhs;
|
||||
Dqn_Str8 file_name = Dqn_Str8_FileNameFromPath(path);
|
||||
Dqn_Str8 file_name_without_extension = Dqn_Str8_BinarySplit(file_name, DQN_STR8(".")).lhs;
|
||||
|
||||
// NOTE: If the sprite is a standalone sprite without any frame suffix (e.g. "_1.png") then
|
||||
// we accept the entry as the name of the sprite as is.
|
||||
Dqn_String8 result = {};
|
||||
Dqn_Str8 result = {};
|
||||
if (Dqn_Char_IsDigit(file_name_without_extension.data[file_name_without_extension.size - 1])) {
|
||||
Dqn_String8BinarySplitResult split = Dqn_String8_BinarySplitReverse(file_name_without_extension, DQN_STRING8("_"));
|
||||
Dqn_Str8BinarySplitResult split = Dqn_Str8_BinarySplitReverse(file_name_without_extension, DQN_STR8("_"));
|
||||
result = split.lhs;
|
||||
} else {
|
||||
result = file_name_without_extension;
|
||||
@@ -67,26 +67,26 @@ int main(int argc, char const *argv[])
|
||||
}
|
||||
|
||||
// NOTE: Verify some arguments =================================================================
|
||||
Dqn_String8 atlas_dimensions = Dqn_String8_InitCString8(argv[1]);
|
||||
Dqn_String8 sprite_spec_path = Dqn_String8_InitCString8(argv[2]);
|
||||
Dqn_String8 dir = Dqn_String8_InitCString8(argv[3]);
|
||||
Dqn_Str8 atlas_dimensions = Dqn_Str8_InitCStr8(argv[1]);
|
||||
Dqn_Str8 sprite_spec_path = Dqn_Str8_InitCStr8(argv[2]);
|
||||
Dqn_Str8 dir = Dqn_Str8_InitCStr8(argv[3]);
|
||||
|
||||
if (!Dqn_Fs_Exists(sprite_spec_path)) {
|
||||
Dqn_Log_ErrorF("Sprite specification file does not exist, we tried to find \"%.*s\" but it does not exist", DQN_STRING_FMT(sprite_spec_path));
|
||||
Dqn_Log_ErrorF("Sprite specification file does not exist, we tried to find \"%.*s\" but it does not exist", DQN_STR_FMT(sprite_spec_path));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!Dqn_Fs_DirExists(dir)) {
|
||||
Dqn_Log_ErrorF("Directory to load sprites from does not exist, we tried to find \"%.*s\" but it does not exist", DQN_STRING_FMT(dir));
|
||||
Dqn_Log_ErrorF("Directory to load sprites from does not exist, we tried to find \"%.*s\" but it does not exist", DQN_STR_FMT(dir));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// NOTE: Parse the atlas size ==================================================================
|
||||
Dqn_V2I atlas_size = {};
|
||||
{
|
||||
Dqn_String8BinarySplitResult atlas_dimensions_split = Dqn_String8_BinarySplit(atlas_dimensions, DQN_STRING8("x"));
|
||||
Dqn_String8ToU64Result width = Dqn_String8_ToU64(atlas_dimensions_split.lhs, 0);
|
||||
Dqn_String8ToU64Result height = Dqn_String8_ToU64(atlas_dimensions_split.rhs, 0);
|
||||
Dqn_Str8BinarySplitResult atlas_dimensions_split = Dqn_Str8_BinarySplit(atlas_dimensions, DQN_STR8("x"));
|
||||
Dqn_Str8ToU64Result width = Dqn_Str8_ToU64(atlas_dimensions_split.lhs, 0);
|
||||
Dqn_Str8ToU64Result height = Dqn_Str8_ToU64(atlas_dimensions_split.rhs, 0);
|
||||
|
||||
if (!width.success || width.value == 0) {
|
||||
Dqn_Log_ErrorF("Width for the sprite atlas was not a number > 0");
|
||||
@@ -106,51 +106,51 @@ int main(int argc, char const *argv[])
|
||||
Dqn_DSMap<SpriteSpecification> sprite_spec_table = Dqn_DSMap_Init<SpriteSpecification>(1024);
|
||||
{
|
||||
Dqn_ThreadScratch inner_scratch = Dqn_Thread_GetScratch(scratch.arena);
|
||||
Dqn_String8 sprite_spec_buffer = Dqn_Fs_Read(sprite_spec_path, inner_scratch.allocator);
|
||||
Dqn_String8SplitAllocResult sprite_spec_lines = Dqn_String8_SplitAlloc(inner_scratch.allocator, sprite_spec_buffer, DQN_STRING8("\n"));
|
||||
Dqn_Str8 sprite_spec_buffer = Dqn_Fs_Read(sprite_spec_path, inner_scratch.allocator);
|
||||
Dqn_Str8SplitAllocResult sprite_spec_lines = Dqn_Str8_SplitAlloc(inner_scratch.allocator, sprite_spec_buffer, DQN_STR8("\n"));
|
||||
DQN_FOR_UINDEX(line_index, sprite_spec_lines.size) {
|
||||
Dqn_String8 line = Dqn_String8_TrimWhitespaceAround(sprite_spec_lines.data[line_index]);
|
||||
Dqn_Str8 line = Dqn_Str8_TrimWhitespaceAround(sprite_spec_lines.data[line_index]);
|
||||
if (line.size == 0) // NOTE: Support empty lines, just ignore them
|
||||
continue;
|
||||
|
||||
Dqn_String8SplitAllocResult line_parts = Dqn_String8_SplitAlloc(inner_scratch.allocator, line, DQN_STRING8(";"));
|
||||
Dqn_Str8SplitAllocResult line_parts = Dqn_Str8_SplitAlloc(inner_scratch.allocator, line, DQN_STR8(";"));
|
||||
DQN_ASSERTF(line_parts.size == 2, "Line must have 2 parts in the sprite specification\n"
|
||||
"\n"
|
||||
"<animation name>;<frames per second>\\n\n"
|
||||
"\n"
|
||||
"Line was '%.*s' loaded from '%.*s'", DQN_STRING_FMT(line), DQN_STRING_FMT(sprite_spec_path));
|
||||
"Line was '%.*s' loaded from '%.*s'", DQN_STR_FMT(line), DQN_STR_FMT(sprite_spec_path));
|
||||
|
||||
Dqn_String8 anim_name = line_parts.data[0];
|
||||
Dqn_String8ToU64Result frames_per_second = Dqn_String8_ToU64(line_parts.data[1], 0);
|
||||
Dqn_Str8 anim_name = line_parts.data[0];
|
||||
Dqn_Str8ToU64Result frames_per_second = Dqn_Str8_ToU64(line_parts.data[1], 0);
|
||||
DQN_ASSERTF(frames_per_second.success, "Frames per second was not a convertible number, line was '%.*s'", line);
|
||||
|
||||
Dqn_DSMapResult<SpriteSpecification> slot = Dqn_DSMap_MakeKeyString8Copy(&sprite_spec_table, scratch.allocator, anim_name);
|
||||
Dqn_DSMapResult<SpriteSpecification> slot = Dqn_DSMap_MakeKeyStr8Copy(&sprite_spec_table, scratch.allocator, anim_name);
|
||||
slot.value->frames_per_second = DQN_CAST(uint16_t)frames_per_second.value;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Get the list of files =================================================================
|
||||
Dqn_List<Dqn_String8> file_list_raw = Dqn_List_Init<Dqn_String8>(scratch.arena, 128);
|
||||
Dqn_List<Dqn_Str8> file_list_raw = Dqn_List_Init<Dqn_Str8>(scratch.arena, 128);
|
||||
for (Dqn_Win_FolderIterator it = {}; Dqn_Win_FolderIterate(dir, &it); ) {
|
||||
if (Dqn_String8_EndsWithInsensitive(it.file_name, DQN_STRING8(".png"))) {
|
||||
Dqn_String8 *item = Dqn_List_Make(&file_list_raw, Dqn_ZeroMem_Yes);
|
||||
*item = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s", DQN_STRING_FMT(dir), DQN_STRING_FMT(it.file_name));
|
||||
if (Dqn_Str8_EndsWithInsensitive(it.file_name, DQN_STR8(".png"))) {
|
||||
Dqn_Str8 *item = Dqn_List_Make(&file_list_raw, Dqn_ZeroMem_Yes);
|
||||
*item = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s", DQN_STR_FMT(dir), DQN_STR_FMT(it.file_name));
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Sort the list of files ================================================================
|
||||
if (file_list_raw.count == 0) {
|
||||
Dqn_Log_InfoF("There are no '.png' files in the directory '%.*s' to create an atlas from, exiting", DQN_STRING_FMT(dir));
|
||||
Dqn_Log_InfoF("There are no '.png' files in the directory '%.*s' to create an atlas from, exiting", DQN_STR_FMT(dir));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// NOTE: Bubble sort the file list naturally ===================================================
|
||||
Dqn_Slice<Dqn_String8> file_list = Dqn_List_ToSliceCopy(&file_list_raw, scratch.arena);
|
||||
Dqn_Slice<Dqn_Str8> file_list = Dqn_List_ToSliceCopy(&file_list_raw, scratch.arena);
|
||||
for (bool swapped = true; swapped; ) {
|
||||
swapped = false;
|
||||
for (Dqn_usize list_index = 0; list_index < file_list.size - 1; list_index++) {
|
||||
Dqn_String8 left = file_list.data[list_index + 0];
|
||||
Dqn_String8 right = file_list.data[list_index + 1];
|
||||
Dqn_Str8 left = file_list.data[list_index + 0];
|
||||
Dqn_Str8 right = file_list.data[list_index + 1];
|
||||
if (strnatcmp(left.data, right.data) > 0) {
|
||||
DQN_SWAP(file_list.data[list_index + 0], file_list.data[list_index + 1]);
|
||||
swapped = true;
|
||||
@@ -165,7 +165,7 @@ int main(int argc, char const *argv[])
|
||||
|
||||
// NOTE: Load the sprites to determine their dimensions for rect packing =======================
|
||||
Dqn_SArray<stbrp_rect> rects = Dqn_SArray_Init<stbrp_rect>(scratch.arena, file_list.size, Dqn_ZeroMem_Yes);
|
||||
for (Dqn_String8 it : file_list) {
|
||||
for (Dqn_Str8 it : file_list) {
|
||||
int x = 0, y = 0, channels_in_file = 0;
|
||||
stbi_uc *pixels = stbi_load(it.data, &x, &y, &channels_in_file, 4 /*desired_channels*/);
|
||||
DQN_ASSERT(pixels);
|
||||
@@ -177,16 +177,16 @@ int main(int argc, char const *argv[])
|
||||
rect->h = y;
|
||||
|
||||
// NOTE: Enumerate the number of frames for this animation =================================
|
||||
Dqn_String8 anim_prefix = SpriteAnimNameFromFilePath(it);
|
||||
Dqn_String8 file_name = Dqn_String8_FileNameFromPath(it);
|
||||
DQN_ASSERTF(!Dqn_String8_HasChar(file_name, ';'),
|
||||
Dqn_Str8 anim_prefix = SpriteAnimNameFromFilePath(it);
|
||||
Dqn_Str8 file_name = Dqn_Str8_FileNameFromPath(it);
|
||||
DQN_ASSERTF(!Dqn_Str8_HasChar(file_name, ';'),
|
||||
"\n\nSprite frame loaded from file\n"
|
||||
" '%.*s'\n"
|
||||
"\n"
|
||||
"however the file name has a semicolon which is not supported because we use a semicolon to delimit our sprite specification",
|
||||
DQN_STRING_FMT(file_name));
|
||||
DQN_STR_FMT(file_name));
|
||||
|
||||
Dqn_DSMapResult<SpriteSpecification> slot = Dqn_DSMap_FindKeyString8(&sprite_spec_table, anim_prefix);
|
||||
Dqn_DSMapResult<SpriteSpecification> slot = Dqn_DSMap_FindKeyStr8(&sprite_spec_table, anim_prefix);
|
||||
DQN_ASSERTF(slot.found,
|
||||
"\n\nSprite frame loaded from file\n"
|
||||
" '%.*s'\n"
|
||||
@@ -196,12 +196,12 @@ int main(int argc, char const *argv[])
|
||||
"\n"
|
||||
"Add a line in format of <animation name>;<frames_per_second> to the file, e.g.\n"
|
||||
" %.*s;8\n",
|
||||
DQN_STRING_FMT(it),
|
||||
DQN_STRING_FMT(sprite_spec_path),
|
||||
DQN_STRING_FMT(anim_prefix));
|
||||
DQN_STR_FMT(it),
|
||||
DQN_STR_FMT(sprite_spec_path),
|
||||
DQN_STR_FMT(anim_prefix));
|
||||
|
||||
slot.value->frame_count++;
|
||||
Dqn_Log_InfoF("Packing sprite: %.*s", DQN_STRING_FMT(it));
|
||||
Dqn_Log_InfoF("Packing sprite: %.*s", DQN_STR_FMT(it));
|
||||
}
|
||||
|
||||
// NOTE: Pack the rects ========================================================================
|
||||
@@ -217,7 +217,7 @@ int main(int argc, char const *argv[])
|
||||
int final_bpp = 4;
|
||||
int final_image_stride = atlas_size.w * final_bpp;
|
||||
char *final_image = Dqn_Arena_NewArray(scratch.arena, char, atlas_size.h * final_image_stride, Dqn_ZeroMem_Yes);
|
||||
Dqn_String8 atlas_path = Dqn_String8_InitF(scratch.allocator, "%.*s.png", DQN_STRING_FMT(dir));
|
||||
Dqn_Str8 atlas_path = Dqn_Str8_InitF(scratch.allocator, "%.*s.png", DQN_STR_FMT(dir));
|
||||
|
||||
// NOTE: Generate the meta file ================================================================
|
||||
// NOTE: Count the number of animations we loaded frames fore
|
||||
@@ -231,18 +231,18 @@ int main(int argc, char const *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
Dqn_String8 meta_path = Dqn_String8_InitF(scratch.allocator, "%.*s.txt", DQN_STRING_FMT(dir));
|
||||
Dqn_Str8 meta_path = Dqn_Str8_InitF(scratch.allocator, "%.*s.txt", DQN_STR_FMT(dir));
|
||||
Dqn_FsFile meta_file = Dqn_Fs_OpenFile(meta_path, Dqn_FsFileOpen_CreateAlways, Dqn_FsFileAccess_Write);
|
||||
Dqn_Fs_WriteFileF(&meta_file,
|
||||
"@file;%.*s;%d;%d\n",
|
||||
DQN_STRING_FMT(Dqn_String8_FileNameFromPath(atlas_path)),
|
||||
DQN_STR_FMT(Dqn_Str8_FileNameFromPath(atlas_path)),
|
||||
DQN_CAST(int) num_anim_rects,
|
||||
DQN_CAST(int) num_anims);
|
||||
|
||||
Dqn_Log_InfoF("Generating meta file: %.*s", DQN_STRING_FMT(meta_path));
|
||||
Dqn_String8 active_anim_prefix = {};
|
||||
Dqn_Log_InfoF("Generating meta file: %.*s", DQN_STR_FMT(meta_path));
|
||||
Dqn_Str8 active_anim_prefix = {};
|
||||
DQN_FOR_UINDEX (file_list_index, file_list.size) {
|
||||
Dqn_String8 it = file_list.data[file_list_index];
|
||||
Dqn_Str8 it = file_list.data[file_list_index];
|
||||
int w, h, channels_in_file;
|
||||
stbi_uc *loaded_image = stbi_load(it.data, &w, &h, &channels_in_file, 4 /*desired_channels*/);
|
||||
|
||||
@@ -263,22 +263,22 @@ int main(int argc, char const *argv[])
|
||||
stbi_image_free(loaded_image);
|
||||
|
||||
// NOTE: Detect what animation we are currently processing =================================
|
||||
Dqn_String8 anim_prefix = SpriteAnimNameFromFilePath(it);
|
||||
Dqn_Str8 anim_prefix = SpriteAnimNameFromFilePath(it);
|
||||
if (active_anim_prefix.size == 0 || active_anim_prefix != anim_prefix) {
|
||||
// NOTE: Anim prefix is different, we are starting a new animation- mark it accordingly
|
||||
active_anim_prefix = anim_prefix;
|
||||
Dqn_DSMapResult<SpriteSpecification> slot = Dqn_DSMap_FindKeyString8(&sprite_spec_table, active_anim_prefix);
|
||||
Dqn_Fs_WriteFileF(&meta_file, "@anim;%.*s;%u;%u\n", DQN_STRING_FMT(active_anim_prefix), slot.value->frames_per_second, slot.value->frame_count);
|
||||
Dqn_DSMapResult<SpriteSpecification> slot = Dqn_DSMap_FindKeyStr8(&sprite_spec_table, active_anim_prefix);
|
||||
Dqn_Fs_WriteFileF(&meta_file, "@anim;%.*s;%u;%u\n", DQN_STR_FMT(active_anim_prefix), slot.value->frames_per_second, slot.value->frame_count);
|
||||
}
|
||||
|
||||
// NOTE: Write the sprite rectangles in ====================================================
|
||||
Dqn_String8 file_name = Dqn_String8_FileNameFromPath(it);
|
||||
Dqn_Fs_WriteFileF(&meta_file, "%d;%d;%d;%d;%.*s", packed_rect.x, packed_rect.y, packed_rect.w, packed_rect.h, DQN_STRING_FMT(file_name));
|
||||
Dqn_Str8 file_name = Dqn_Str8_FileNameFromPath(it);
|
||||
Dqn_Fs_WriteFileF(&meta_file, "%d;%d;%d;%d;%.*s", packed_rect.x, packed_rect.y, packed_rect.w, packed_rect.h, DQN_STR_FMT(file_name));
|
||||
if (file_list_index != (file_list.size - 1))
|
||||
Dqn_Fs_WriteFileF(&meta_file, "\n");
|
||||
}
|
||||
|
||||
Dqn_Log_InfoF("Generating atlas: %.*s", DQN_STRING_FMT(atlas_path));
|
||||
Dqn_Log_InfoF("Generating atlas: %.*s", DQN_STR_FMT(atlas_path));
|
||||
stbi_write_png(atlas_path.data, atlas_size.w, atlas_size.h, 4, final_image, final_image_stride);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include "feely_pona_unity.h"
|
||||
+8
-59
@@ -1,65 +1,13 @@
|
||||
// =================================================================================================
|
||||
// NOTE: feely_pona ================================================================================
|
||||
// Unity build header to compile the entire application as a single translation unit
|
||||
|
||||
// NOTE(doyle): Work-around for clangd to correctly resolve symbols in unity
|
||||
// builds by providing symbol definition and prototypes by including this
|
||||
// mega-header in all files and using the "#pragma once" directive to
|
||||
// avoid multiple defined symbols when compiling the unity build itself.
|
||||
//
|
||||
// See: https://www.frogtoss.com/labs/clangd-with-unity-builds.html
|
||||
|
||||
#pragma once
|
||||
|
||||
// NOTE: DQN =======================================================================================
|
||||
|
||||
// NOTE: C-strings declared in a ternary cause global-buffer-overflow in
|
||||
// MSVC2022.
|
||||
// stb_sprintf assumes c-string literals are 4 byte aligned which is always
|
||||
// true, however, reading past the end of a string whose size is not a multiple
|
||||
// of 4 is UB causing ASAN to complain.
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define STBSP__ASAN __declspec(no_sanitize_address)
|
||||
#endif
|
||||
|
||||
#define DQN_ASAN_POISON 0
|
||||
#define DQN_ASAN_VET_POISON 1
|
||||
#define DQN_ONLY_RECT
|
||||
#define DQN_ONLY_V2
|
||||
#define DQN_ONLY_V3
|
||||
#define DQN_ONLY_V4
|
||||
#define DQN_ONLY_WIN
|
||||
#define DQN_ONLY_FARRAY
|
||||
#define DQN_ONLY_PROFILER
|
||||
#define DQN_ONLY_SLICE
|
||||
#define DQN_ONLY_LIST
|
||||
#define DQN_ONLY_VARRAY
|
||||
#define DQN_ONLY_DSMAP
|
||||
#define DQN_ONLY_FS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define DQN_IMPLEMENTATION
|
||||
#include "External/tely/External/dqn/dqn.h"
|
||||
|
||||
// NOTE: TELY ======================================================================================
|
||||
|
||||
DQN_MSVC_WARNING_PUSH
|
||||
DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with internal linkage has been removed
|
||||
#include "External/tely/tely_profile.h"
|
||||
#include "External/tely/tely_platform_input.h"
|
||||
#include "External/tely/tely_tools.h"
|
||||
#include "External/tely/tely_asset.h"
|
||||
#include "External/tely/tely_colour.h"
|
||||
#include "External/tely/tely_render.h"
|
||||
#include "External/tely/tely_audio.h"
|
||||
#include "External/tely/tely_platform.h"
|
||||
#include "External/tely/tely_rfui.h"
|
||||
|
||||
#include "External/tely/tely_tools.cpp"
|
||||
#include "External/tely/tely_asset.cpp"
|
||||
#include "External/tely/tely_audio.cpp"
|
||||
#include "External/tely/tely_render.cpp"
|
||||
#include "External/tely/tely_platform_input.cpp"
|
||||
#include "External/tely/tely_rfui.cpp"
|
||||
#define TELY_PLATFORM_DLL_FILE_NAME "terry_cherry_dev_dll"
|
||||
#include "External/tely/tely_os_raylib_unity.h"
|
||||
|
||||
// NOTE: feely_pona ================================================================================
|
||||
#if defined(_CLANGD) || defined(FEELY_PONA_IMPLEMENTATION)
|
||||
DQN_MSVC_WARNING_PUSH
|
||||
DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with internal linkage has been removed
|
||||
#include "feely_pona.h"
|
||||
#include "feely_pona_stdlib.h"
|
||||
#include "feely_pona_entity.h"
|
||||
@@ -71,3 +19,4 @@ DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with inte
|
||||
#include "feely_pona_misc.cpp"
|
||||
#include "feely_pona.cpp"
|
||||
DQN_MSVC_WARNING_POP
|
||||
#endif
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
#include "feely_pona_unity_nodll.h"
|
||||
@@ -1,102 +0,0 @@
|
||||
// =================================================================================================
|
||||
|
||||
// NOTE(doyle): Work-around for clangd to correctly resolve symbols in unity
|
||||
// builds by providing symbol definition and prototypes by including this
|
||||
// mega-header in all files and using the "#pragma once" directive to
|
||||
// avoid multiple defined symbols when compiling the unity build itself.
|
||||
//
|
||||
// See: https://www.frogtoss.com/labs/clangd-with-unity-builds.html
|
||||
|
||||
#pragma once
|
||||
|
||||
// NOTE: DQN =======================================================================================
|
||||
|
||||
// NOTE: C-strings declared in a ternary cause global-buffer-overflow in
|
||||
// MSVC2022.
|
||||
// stb_sprintf assumes c-string literals are 4 byte aligned which is always
|
||||
// true, however, reading past the end of a string whose size is not a multiple
|
||||
// of 4 is UB causing ASAN to complain.
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define STBSP__ASAN __declspec(no_sanitize_address)
|
||||
#endif
|
||||
|
||||
#define DQN_ASAN_POISON 0
|
||||
#define DQN_ASAN_VET_POISON 1
|
||||
#define DQN_ONLY_RECT
|
||||
#define DQN_ONLY_V2
|
||||
#define DQN_ONLY_V3
|
||||
#define DQN_ONLY_V4
|
||||
#define DQN_ONLY_WIN
|
||||
#define DQN_ONLY_FARRAY
|
||||
#define DQN_ONLY_PROFILER
|
||||
#define DQN_ONLY_SLICE
|
||||
#define DQN_ONLY_LIST
|
||||
#define DQN_ONLY_VARRAY
|
||||
#define DQN_ONLY_DSMAP
|
||||
#define DQN_ONLY_FS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define DQN_IMPLEMENTATION
|
||||
#include "External/tely/External/dqn/dqn.h"
|
||||
|
||||
// NOTE: STB Headers ===============================================================================
|
||||
|
||||
DQN_GCC_WARNING_PUSH
|
||||
DQN_GCC_WARNING_DISABLE(-Wunused-function)
|
||||
#include "External/tely/External/stb/stb_image.h"
|
||||
DQN_GCC_WARNING_POP
|
||||
|
||||
// =================================================================================================
|
||||
|
||||
#include "External/tely/External/raylib/raylib.h"
|
||||
#include "External/tely/External/raylib/rlgl.h"
|
||||
#include "External/tely/External/raylib/external/glfw/include/GLFW/glfw3.h"
|
||||
|
||||
// NOTE: TELY ======================================================================================
|
||||
|
||||
DQN_MSVC_WARNING_PUSH
|
||||
DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with internal linkage has been removed
|
||||
|
||||
DQN_GCC_WARNING_PUSH
|
||||
DQN_GCC_WARNING_DISABLE(-Wunused-function)
|
||||
|
||||
#include "External/tely/tely_profile.h"
|
||||
#include "External/tely/tely_platform_input.h"
|
||||
#include "External/tely/tely_tools.h"
|
||||
#include "External/tely/tely_asset.h"
|
||||
#include "External/tely/tely_colour.h"
|
||||
#include "External/tely/tely_render.h"
|
||||
#include "External/tely/tely_audio.h"
|
||||
#include "External/tely/tely_platform.h"
|
||||
#include "External/tely/tely_rfui.h"
|
||||
|
||||
#include "External/tely/tely_tools.cpp"
|
||||
#include "External/tely/tely_asset.cpp"
|
||||
#include "External/tely/tely_audio.cpp"
|
||||
#include "External/tely/tely_render.cpp"
|
||||
#include "External/tely/tely_platform_input.cpp"
|
||||
#include "External/tely/tely_rfui.cpp"
|
||||
|
||||
// NOTE: feely_pona ================================================================================
|
||||
#include "feely_pona.h"
|
||||
#include "feely_pona_stdlib.h"
|
||||
#include "feely_pona_entity.h"
|
||||
#include "feely_pona_game.h"
|
||||
|
||||
#include "feely_pona_entity.cpp"
|
||||
#include "feely_pona_game.cpp"
|
||||
#include "feely_pona_entity_create.cpp"
|
||||
#include "feely_pona_misc.cpp"
|
||||
#include "feely_pona.cpp"
|
||||
DQN_MSVC_WARNING_POP
|
||||
DQN_GCC_WARNING_POP
|
||||
|
||||
#if defined(DQN_PLATFORM_EMSCRIPTEN)
|
||||
#include <emscripten/emscripten.h>
|
||||
#include <emscripten/html5.h>
|
||||
#endif
|
||||
|
||||
// NOTE: TELY_Platform =============================================================================
|
||||
#define TELY_PLATFORM_NO_DLL
|
||||
#include "External/tely/tely_platform.cpp"
|
||||
#include "External/tely/tely_platform_raylib.cpp"
|
||||
|
||||
Binary file not shown.
@@ -25,7 +25,7 @@ forwards them to the command line).
|
||||
You must ensure you have MSVC's `cl.exe` on your path to build. This game was
|
||||
tested on MSVC 2023 (v14.34.31933).
|
||||
|
||||
For most intents and purposes you may simply execute `build.bat` on Windows
|
||||
For most intents and purposes you may simply execute `build_all.bat` on Windows
|
||||
which bootstraps the build program and automatically calls the meta-build
|
||||
program. With fast computers nowadays our default is to build all targets by
|
||||
default (except web due to extra toolchain requirements).
|
||||
@@ -57,7 +57,7 @@ then be done by
|
||||
Tools\emsdk\emsdk.bat activate latest
|
||||
|
||||
# Build the game
|
||||
build --web
|
||||
build_all --web
|
||||
```
|
||||
|
||||
This will produce at `Build\Terry_Cherry_Emscripten` a HTML and WASM file ready
|
||||
|
||||
Reference in New Issue
Block a user