8f8fa8f8d1
- Add Scene.set(module) so JerryScript can switch scenes via
require()'d {init, update, dispose} modules; wire it into
engineUpdate() and rework overworldscene.js/init.js to the new shape.
- Fix scriptManagerExecFile() never pushing its own file's directory
onto the require() dir stack, breaking relative require() calls from
a top-level entry script (e.g. init.js -> ./overworldscene.js).
- Cache sprite geometry across frames for uislider/uitab/uiframe
(dialogs/textbox/settings) and give uitextbox a per-page glyph cache
instead of one spriteBatchBuffer call per visible character. uiconsole
drops its alloc/free vertex buffer for a fixed-size one. uifps skips
rebuilding its label when the text hasn't changed.
- Add PSP_OPTIMIZATION_PLAN.md and a handful of UI/spritebatch unit
tests covering the new caching logic.
- Add Dolphin/PPSSPP emulator smoke-test scripts (+ Docker variants and
CI jobs) for GameCube/Wii/PSP.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
93 lines
2.8 KiB
C
93 lines
2.8 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "dusktest.h"
|
|
#include "display/spritebatch/spritebatchsprite.h"
|
|
|
|
static void test_spriteBatchSpriteTilesetPosition_create(void **state) {
|
|
tileset_t tileset = {
|
|
.tileWidth = 8,
|
|
.tileHeight = 8,
|
|
.tileCount = 4,
|
|
.columns = 2,
|
|
.rows = 2,
|
|
.uv = { 0.5f, 0.5f }
|
|
};
|
|
|
|
spritebatchsprite_t sprite = spriteBatchSpriteTilesetPosition(
|
|
&tileset, 1, 1, 10.0f, 20.0f, 8.0f, 8.0f
|
|
);
|
|
|
|
assert_float_equal(sprite.min[0], 10.0f, 0.0001f);
|
|
assert_float_equal(sprite.min[1], 20.0f, 0.0001f);
|
|
assert_float_equal(sprite.min[2], 0.0f, 0.0001f);
|
|
assert_float_equal(sprite.max[0], 18.0f, 0.0001f);
|
|
assert_float_equal(sprite.max[1], 28.0f, 0.0001f);
|
|
assert_float_equal(sprite.uvMin[0], 0.5f, 0.0001f);
|
|
assert_float_equal(sprite.uvMin[1], 0.5f, 0.0001f);
|
|
assert_float_equal(sprite.uvMax[0], 1.0f, 0.0001f);
|
|
assert_float_equal(sprite.uvMax[1], 1.0f, 0.0001f);
|
|
}
|
|
|
|
static void test_spriteBatchSpriteTilesetPosition_zeroSize(void **state) {
|
|
tileset_t tileset = {
|
|
.tileWidth = 8,
|
|
.tileHeight = 8,
|
|
.tileCount = 1,
|
|
.columns = 1,
|
|
.rows = 1,
|
|
.uv = { 1.0f, 1.0f }
|
|
};
|
|
|
|
spritebatchsprite_t sprite = spriteBatchSpriteTilesetPosition(
|
|
&tileset, 0, 0, 10.0f, 20.0f, 0.0f, 8.0f
|
|
);
|
|
|
|
assert_float_equal(sprite.min[0], 0.0f, 0.0001f);
|
|
assert_float_equal(sprite.min[1], 0.0f, 0.0001f);
|
|
assert_float_equal(sprite.max[0], 0.0f, 0.0001f);
|
|
assert_float_equal(sprite.max[1], 0.0f, 0.0001f);
|
|
}
|
|
|
|
static void test_spriteBatchSpriteTranslate(void **state) {
|
|
spritebatchsprite_t sprite = {
|
|
.min = { 1.0f, 2.0f, 0.0f },
|
|
.max = { 5.0f, 6.0f, 0.0f },
|
|
.uvMin = { 0.25f, 0.5f },
|
|
.uvMax = { 0.75f, 1.0f }
|
|
};
|
|
|
|
spritebatchsprite_t translated = spriteBatchSpriteTranslate(
|
|
&sprite, 10.0f, -3.0f
|
|
);
|
|
|
|
assert_float_equal(translated.min[0], 11.0f, 0.0001f);
|
|
assert_float_equal(translated.min[1], -1.0f, 0.0001f);
|
|
assert_float_equal(translated.max[0], 15.0f, 0.0001f);
|
|
assert_float_equal(translated.max[1], 3.0f, 0.0001f);
|
|
|
|
// UVs must be untouched by translation.
|
|
assert_float_equal(translated.uvMin[0], 0.25f, 0.0001f);
|
|
assert_float_equal(translated.uvMin[1], 0.5f, 0.0001f);
|
|
assert_float_equal(translated.uvMax[0], 0.75f, 0.0001f);
|
|
assert_float_equal(translated.uvMax[1], 1.0f, 0.0001f);
|
|
|
|
// Original sprite must be untouched.
|
|
assert_float_equal(sprite.min[0], 1.0f, 0.0001f);
|
|
assert_float_equal(sprite.min[1], 2.0f, 0.0001f);
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
const struct CMUnitTest tests[] = {
|
|
cmocka_unit_test(test_spriteBatchSpriteTilesetPosition_create),
|
|
cmocka_unit_test(test_spriteBatchSpriteTilesetPosition_zeroSize),
|
|
cmocka_unit_test(test_spriteBatchSpriteTranslate),
|
|
};
|
|
|
|
return cmocka_run_group_tests(tests, NULL, NULL);
|
|
}
|