diff --git a/tools/new_project_layout/project_studio/ops.py b/tools/new_project_layout/project_studio/ops.py index a9ee0289..e951ec03 100644 --- a/tools/new_project_layout/project_studio/ops.py +++ b/tools/new_project_layout/project_studio/ops.py @@ -464,6 +464,11 @@ def op_rewrite_cmake_setup_host(root: Path, options: MigrateOptions) -> ApplyRes _fill(templates_dir() / "CMakeLists.txt.in", cmake, tokens, options.dry_run) + go = root / "game_options.toml" + if not go.is_file(): + _fill(templates_dir() / "game_options.toml.in", go, tokens, options.dry_run) + changed.append("game_options.toml") + if extras_bits and not options.dry_run: extras_note.write_text( "Preserved notes after setup-host CMake rewrite:\n\n" diff --git a/tools/new_project_layout/setup_project.ps1 b/tools/new_project_layout/setup_project.ps1 index f9badb84..3fc8a08a 100644 --- a/tools/new_project_layout/setup_project.ps1 +++ b/tools/new_project_layout/setup_project.ps1 @@ -354,6 +354,7 @@ git init -q Fill-Template (Join-Path $TemplateDir "CMakeLists.txt.in") (Join-Path $Root "CMakeLists.txt") Fill-Template (Join-Path $TemplateDir "game.toml.in") (Join-Path $Root "game.toml") +Fill-Template (Join-Path $TemplateDir "game_options.toml.in") (Join-Path $Root "game_options.toml") Fill-Template (Join-Path $TemplateDir "codegen_setup.c.in") (Join-Path $Root "codegen_setup.c") Fill-Template (Join-Path $TemplateDir "codegen_setup.h.in") (Join-Path $Root "codegen_setup.h") Fill-Template (Join-Path $TemplateDir "gitignore.in") (Join-Path $Root ".gitignore") diff --git a/tools/new_project_layout/setup_project.sh b/tools/new_project_layout/setup_project.sh index b571eff5..256c1c64 100755 --- a/tools/new_project_layout/setup_project.sh +++ b/tools/new_project_layout/setup_project.sh @@ -566,6 +566,7 @@ git init -q fill_template "$TEMPLATE_DIR/CMakeLists.txt.in" "$ROOT/CMakeLists.txt" fill_template "$TEMPLATE_DIR/game.toml.in" "$ROOT/game.toml" +fill_template "$TEMPLATE_DIR/game_options.toml.in" "$ROOT/game_options.toml" fill_template "$TEMPLATE_DIR/codegen_setup.c.in" "$ROOT/codegen_setup.c" fill_template "$TEMPLATE_DIR/codegen_setup.h.in" "$ROOT/codegen_setup.h" fill_template "$TEMPLATE_DIR/gitignore.in" "$ROOT/.gitignore" diff --git a/tools/new_project_layout/templates/CMakeLists.txt.in b/tools/new_project_layout/templates/CMakeLists.txt.in index 062a5083..24db61d1 100644 --- a/tools/new_project_layout/templates/CMakeLists.txt.in +++ b/tools/new_project_layout/templates/CMakeLists.txt.in @@ -25,3 +25,17 @@ psxrecomp_add_game_runtime(psx-runtime GEN_FULL_GLOB "generated/@BOOT_EXE@_full_*.c" @CODEGEN_SETUP_ARG@ ) + +# Stage runtime configs next to the exe for direct build/ launches. Only copy +# files that exist — never fail POST_BUILD when game_options.toml is absent. +foreach(_PSX_RUNTIME_CONFIG game.toml game_options.toml) + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_PSX_RUNTIME_CONFIG}") + add_custom_command(TARGET psx-runtime POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_CURRENT_SOURCE_DIR}/${_PSX_RUNTIME_CONFIG}" + "$/${_PSX_RUNTIME_CONFIG}" + COMMENT "Staging ${_PSX_RUNTIME_CONFIG}" + VERBATIM) + endif() +endforeach() + diff --git a/tools/new_project_layout/templates/game_options.toml.in b/tools/new_project_layout/templates/game_options.toml.in new file mode 100644 index 00000000..dba252d8 --- /dev/null +++ b/tools/new_project_layout/templates/game_options.toml.in @@ -0,0 +1,12 @@ +# Native in-game OPTION persistence (optional). +# Declared next to game.toml; read by the recompiler (init-store hooks) and +# runtime (restore / save). Omit [[option]] rows until the title needs them. +# See psxrecomp GameOptions / runtime game_options.c. +# +# [[option]] +# name = "example" +# addr = "0x80000000" +# size = 1 +# init_store_pc = "0x80000000" +# min = 0 +# max = 1