Embed Switch game assets in RomFS

This commit is contained in:
2026-06-09 01:00:20 +08:00
parent b78aaa5cad
commit e8b05e93b9
7 changed files with 72 additions and 73 deletions
+5 -6
View File
@@ -21,7 +21,6 @@ game/
├─ movement/ 可复用的移动和碰撞辅助工具
├─ scene/ 游戏场景和关卡编排
├─ stage/ 关卡视觉层渲染
├─ switch_game_main.cpp Switch/NS 游戏入口
└─ main.cpp 游戏可执行文件入口点
```
@@ -116,9 +115,9 @@ xmake -b Frostbite2DGame
build/windows/x64/release/Frostbite2DGame.exe
```
Switch/NS 游戏框架目标为 `Frostbite2DGameSwitch`。它使
`game/src/switch_game_main.cpp` 作为平台入口,复用同一套 Scene、Stage、
Actor、Movement、Debug 和 Data 模块。
Switch/NS 游戏框架目标为 `Frostbite2DGameSwitch`。它
`game/src/main.cpp`,入口内部通过 `__SWITCH__` 编译分支处理平台差异,
并复用同一套 Scene、Stage、Actor、Movement、Debug 和 Data 模块。
构建命令:
@@ -133,10 +132,10 @@ build/switch/aarch64/release/Frostbite2DGame.elf
build/switch/aarch64/release/switch_game/NSUnknownGame.nro
```
Switch 运行时资源目录:
Switch 运行时资源目录优先使用内嵌 RomFS
```text
/switch/Frostbite2D/NS Unknown Game/assets
romfs:/assets
```
## 后续架构步骤
+3 -3
View File
@@ -305,16 +305,16 @@ mindmap
已有:
- `game/src/main.cpp`Windows/PC 游戏入口
- `game/src/switch_game_main.cpp`Switch/NS 游戏入口。
- `game/src/main.cpp`统一游戏入口,通过 `__SWITCH__` 区分 Windows/PC 与 Switch/NS
- `Frostbite2DGame`Windows 游戏目标。
- `Frostbite2DGameSwitch`Switch 游戏目标,生成 `NSUnknownGame.nro`
- Switch NRO 已内嵌 `game/` 为 RomFS,运行时优先读取 `romfs:/assets`
下一步:
- 将 Switch Joy-Con 输入接入 `InputStateProvider`
- 整理资源部署脚本,把 `assets` 放到 `/switch/Frostbite2D/NS Unknown Game/assets`
- 在 Ryujinx 或真机上验证主循环、shader 和角色纹理。
- 如果 RomFS 不可用,再补 SD 卡外部资源部署脚本。
## 数据流白板
+20
View File
@@ -3,7 +3,12 @@
#include <cstdio>
#ifndef __SWITCH__
#define SDL_MAIN_HANDLED
#else
#include <switch.h>
#endif
#include <frostbite2D/core/application.h>
#include <frostbite2D/scene/scene_manager.h>
@@ -11,12 +16,23 @@ int main(int argc, char** argv) {
(void)argc;
(void)argv;
#ifdef __SWITCH__
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
#endif
auto config = frostbite2D::AppConfig::createDefault();
config.appName = "NS Unknown Game";
#ifdef __SWITCH__
config.windowConfig.title = "NS Unknown Game";
config.windowConfig.width = ns_game::config::kVirtualWidth;
config.windowConfig.height = ns_game::config::kVirtualHeight;
config.windowConfig.resizable = false;
#else
config.windowConfig.title = "NS Unknown Game - Whitebox";
config.windowConfig.width = 1280;
config.windowConfig.height = 720;
config.windowConfig.resizable = true;
#endif
config.windowConfig.vsync = true;
config.useVirtualResolution = true;
config.virtualWidth = ns_game::config::kVirtualWidth;
@@ -27,7 +43,11 @@ int main(int argc, char** argv) {
auto& app = frostbite2D::Application::get();
if (!app.init(config)) {
#ifdef __SWITCH__
std::puts("NS Unknown Game Switch init failed.");
#else
std::puts("NS Unknown Game init failed.");
#endif
return 1;
}
-43
View File
@@ -1,43 +0,0 @@
#include "core/game_config.h"
#include "scene/whitebox_scene.h"
#include <cstdio>
#include <frostbite2D/core/application.h>
#include <frostbite2D/scene/scene_manager.h>
#include <switch.h>
int main(int argc, char** argv) {
(void)argc;
(void)argv;
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
auto config = frostbite2D::AppConfig::createDefault();
config.appName = "NS Unknown Game";
config.windowConfig.title = "NS Unknown Game";
config.windowConfig.width = ns_game::config::kVirtualWidth;
config.windowConfig.height = ns_game::config::kVirtualHeight;
config.windowConfig.resizable = false;
config.windowConfig.vsync = true;
config.useVirtualResolution = true;
config.virtualWidth = ns_game::config::kVirtualWidth;
config.virtualHeight = ns_game::config::kVirtualHeight;
config.resolutionMode = frostbite2D::ResolutionScaleMode::Fit;
config.renderStyleProfile = frostbite2D::RenderStyleProfileId::PixelArt2D;
config.maxFps = 60;
auto& app = frostbite2D::Application::get();
if (!app.init(config)) {
std::puts("NS Unknown Game Switch init failed.");
return 1;
}
app.run([]() {
frostbite2D::SceneManager::get().ReplaceScene(
frostbite2D::MakePtr<ns_game::WhiteboxScene>());
});
app.shutdown();
return 0;
}