Compare commits
33 Commits
2e6aa8dbe9
...
topic/bg/c
Author | SHA1 | Date | |
---|---|---|---|
9a5918f3f7 | |||
18ebf33e2c | |||
d8065f6266 | |||
f25548085f | |||
85d787151a | |||
d69b144ebe | |||
a686df5bf6 | |||
3500a288bc | |||
e51908ae09 | |||
4ea7575057 | |||
e3ed4a3b43 | |||
3f507fd19e | |||
f8ec08008a | |||
4942012da1 | |||
9501954587 | |||
751533dcf6 | |||
5a1997873d | |||
5cd29460fb | |||
7a2052575d | |||
a475a0c82d | |||
32da34cad6 | |||
af633a4fdf | |||
b0b8c43700 | |||
ed4671698a | |||
b487ca2591 | |||
a33aa6bb4e | |||
85b5aa0070 | |||
b3a666b5ea | |||
a8ca3bf859 | |||
ec6c20185e | |||
a6d8ecab16 | |||
a89699334e | |||
5f93549a05 |
3
.clangd
Normal file
3
.clangd
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
CompileFlags:
|
||||||
|
Remove: [-fmodules-ts, -mno-shared, -mno-llsc, -march=r2000, -mtune=r2000, implied_comparison_category_type_not_found]
|
||||||
|
Compiler: mipsel-linux-gnu-g++
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -9,6 +9,8 @@
|
|||||||
**/config
|
**/config
|
||||||
|
|
||||||
.lfsconfig
|
.lfsconfig
|
||||||
|
.cache
|
||||||
|
compile_commands.json
|
||||||
|
|
||||||
*.d
|
*.d
|
||||||
*.a
|
*.a
|
||||||
|
1
examples/PoolBox/.gitignore
vendored
1
examples/PoolBox/.gitignore
vendored
@@ -5,3 +5,4 @@
|
|||||||
*.o
|
*.o
|
||||||
*.lba
|
*.lba
|
||||||
**/bin
|
**/bin
|
||||||
|
**/auto_gen
|
@@ -11,7 +11,7 @@
|
|||||||
{
|
{
|
||||||
"label": "build",
|
"label": "build",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "${env:JABY_ENGINE_PATH}/scripts/podman_jaby_engine.sh ${workspaceFolder}:. make ${input:project}_${input:target} BUILD_PROFILE=${input:build profile} REGION=${input:region} CUSTOM_CONFIG=${input:custom config}",
|
"command": "${env:JABY_ENGINE_PATH}/scripts/podman_jaby_engine.sh ${workspaceFolder}:. bear -- make ${input:project}_${input:target} BUILD_PROFILE=${input:build profile} REGION=${input:region} CUSTOM_CONFIG=${input:custom config}",
|
||||||
"group": {
|
"group": {
|
||||||
"kind": "build",
|
"kind": "build",
|
||||||
"isDefault": true
|
"isDefault": true
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "auto_gen/vram_layout.hpp"
|
||||||
#include <PSX/File/cd_file_types.hpp>
|
#include <PSX/File/cd_file_types.hpp>
|
||||||
|
|
||||||
namespace Assets {
|
namespace Assets {
|
||||||
@@ -11,11 +12,6 @@ namespace Assets {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static constexpr auto PacoTIM = SimpleTIM::create(896, 0, 960, 510);
|
static constexpr auto PacoTIM = SimpleTIM::create(896, 0, 960, 510);
|
||||||
static constexpr auto DoenerFishInfo = ImageInfo{
|
|
||||||
.tim = SimpleTIM::create(896 + 30, 0, 960 + 16, 510),
|
|
||||||
.size = GPU::SizeI16::create(128, 64)
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace JabyLoader {
|
namespace JabyLoader {
|
||||||
static constexpr auto TIMLoaction = SimpleTIM::create(PacoTIM.get_texture_x(), PacoTIM.get_texture_y() + 128, 960 + 48, 510);
|
static constexpr auto TIMLoaction = SimpleTIM::create(PacoTIM.get_texture_x(), PacoTIM.get_texture_y() + 128, 960 + 48, 510);
|
||||||
static constexpr auto JabyFrame = GPU::AreaI16::create(0, 0, 32, 44);
|
static constexpr auto JabyFrame = GPU::AreaI16::create(0, 0, 32, 44);
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
#include "../../../include/auto_gen/vram_layout.hpp"
|
||||||
#include "../../../include/shared.hpp"
|
#include "../../../include/shared.hpp"
|
||||||
#include "include/controller_state.hpp"
|
#include "include/controller_state.hpp"
|
||||||
#include <PSX/Periphery/periphery.hpp>
|
#include <PSX/Periphery/periphery.hpp>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#include "include/controller_test_assets.hpp"
|
#include "../../../include/auto_gen/vram_layout.hpp"
|
||||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||||
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
||||||
|
|
||||||
@@ -13,6 +13,6 @@ namespace ControllerTest {
|
|||||||
__declare_lba_header(LBA);
|
__declare_lba_header(LBA);
|
||||||
|
|
||||||
CDFile Assets[1] = {
|
CDFile Assets[1] = {
|
||||||
CDFileBuilder::simple_tim(LBA::CONT, ControllerButtonTIM),
|
CDFileBuilder::simple_tim(LBA::CONT, Controller_png::tim),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "controller_test_assets.hpp"
|
#include "../../../../include/auto_gen/vram_layout.hpp"
|
||||||
#include <FontWriter/font_writer.hpp>
|
#include <FontWriter/font_writer.hpp>
|
||||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||||
#include <PSX/Periphery/controller.hpp>
|
#include <PSX/Periphery/controller.hpp>
|
||||||
@@ -18,43 +18,43 @@ namespace ControllerTest {
|
|||||||
ControllerState state;
|
ControllerState state;
|
||||||
|
|
||||||
for(auto& tex_page : state.tex_page) {
|
for(auto& tex_page : state.tex_page) {
|
||||||
tex_page = Make::TexPage(ControllerButtonTIM.get_texture_position(), GPU::TextureColorMode::clut4).linked();
|
tex_page = Make::TexPage(Controller_png::tim.get_texture_position(), GPU::TextureColorMode::clut4).linked();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& buttons : state.buttons) {
|
for(auto& buttons : state.buttons) {
|
||||||
// Triangle
|
// Triangle
|
||||||
buttons[0] = Make::SPRT_16(Make::Vertex(71, 0).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(0, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
buttons[0] = Make::SPRT_16(Make::Vertex(71, 0).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(0, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
|
||||||
// Circle
|
// Circle
|
||||||
buttons[1] = Make::SPRT_16(Make::Vertex(82, 12).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(1, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
buttons[1] = Make::SPRT_16(Make::Vertex(82, 12).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(1, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
|
||||||
// Cross
|
// Cross
|
||||||
buttons[2] = Make::SPRT_16(Make::Vertex(71, 23).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(2, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
buttons[2] = Make::SPRT_16(Make::Vertex(71, 23).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(2, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
|
||||||
// Square
|
// Square
|
||||||
buttons[3] = Make::SPRT_16(Make::Vertex(60, 11).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(3, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
buttons[3] = Make::SPRT_16(Make::Vertex(60, 11).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(3, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
|
||||||
// Play
|
// Play
|
||||||
buttons[4] = Make::SPRT_16(Make::Vertex(51, 21).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(4, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
buttons[4] = Make::SPRT_16(Make::Vertex(51, 21).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(4, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
|
||||||
// Block
|
// Block
|
||||||
buttons[5] = Make::SPRT_16(Make::Vertex(24, 21).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(5, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
buttons[5] = Make::SPRT_16(Make::Vertex(24, 21).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(5, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
|
||||||
// L1
|
// L1
|
||||||
buttons[6] = Make::SPRT_16(Make::Vertex(7, 39).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(7, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
buttons[6] = Make::SPRT_16(Make::Vertex(7, 39).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(7, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
|
||||||
// L2
|
// L2
|
||||||
buttons[7] = Make::SPRT_16(Make::Vertex(7, 49).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(8, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
buttons[7] = Make::SPRT_16(Make::Vertex(7, 49).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(8, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
|
||||||
// R1
|
// R1
|
||||||
buttons[8] = Make::SPRT_16(Make::Vertex(71, 39).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(7, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
buttons[8] = Make::SPRT_16(Make::Vertex(71, 39).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(7, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
|
||||||
// R2
|
// R2
|
||||||
buttons[9] = Make::SPRT_16(Make::Vertex(71, 49).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(8, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
buttons[9] = Make::SPRT_16(Make::Vertex(71, 49).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(8, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
|
||||||
// L3
|
// L3
|
||||||
buttons[10] = Make::SPRT_16(Make::Vertex(24, 34).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(9, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
buttons[10] = Make::SPRT_16(Make::Vertex(24, 34).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(9, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
|
||||||
// R3
|
// R3
|
||||||
buttons[11] = Make::SPRT_16(Make::Vertex(52, 34).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(9, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
buttons[11] = Make::SPRT_16(Make::Vertex(52, 34).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(9, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
|
||||||
// Connection Symbol
|
// Connection Symbol
|
||||||
buttons[12] = Make::SPRT_16(Make::Vertex(37, 9).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(10, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
buttons[12] = Make::SPRT_16(Make::Vertex(37, 9).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(10, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& arrows : state.arrows) {
|
for(auto& arrows : state.arrows) {
|
||||||
arrows[0] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect( Make::AreaI16(Make::PositionI16( 7, 5).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked();
|
arrows[0] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect( Make::AreaI16(Make::PositionI16( 7, 5).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(Controller_png::tim.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(Controller_png::tim.get_clut_position())).linked();
|
||||||
arrows[1] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect270(Make::AreaI16(Make::PositionI16(14, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked();
|
arrows[1] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect270(Make::AreaI16(Make::PositionI16(14, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(Controller_png::tim.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(Controller_png::tim.get_clut_position())).linked();
|
||||||
arrows[2] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect180(Make::AreaI16(Make::PositionI16( 7, 17).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked();
|
arrows[2] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect180(Make::AreaI16(Make::PositionI16( 7, 17).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(Controller_png::tim.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(Controller_png::tim.get_clut_position())).linked();
|
||||||
arrows[3] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect90( Make::AreaI16(Make::PositionI16( 0, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked();
|
arrows[3] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect90( Make::AreaI16(Make::PositionI16( 0, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(Controller_png::tim.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(Controller_png::tim.get_clut_position())).linked();
|
||||||
}
|
}
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <PSX/File/cd_file_types.hpp>
|
|
||||||
|
|
||||||
namespace ControllerTest {
|
|
||||||
using namespace JabyEngine;
|
|
||||||
|
|
||||||
static constexpr auto ControllerButtonTIM = SimpleTIM::create(384, 0, 384, 511);
|
|
||||||
}
|
|
@@ -86,10 +86,10 @@ namespace GTETest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static auto doener_fish = GTE_Sprite::create(Make::POLY_FT4(
|
static auto doener_fish = GTE_Sprite::create(Make::POLY_FT4(
|
||||||
Make::AreaI16(Make::PositionI16(0, 0), Assets::Main::DoenerFishInfo.size),
|
Make::AreaI16(Make::PositionI16(0, 0), doener_fish_png::size),
|
||||||
Assets::Main::DoenerFishInfo.tim.get_page_offset_clut4(),
|
doener_fish_png::tim.get_page_offset_clut4(),
|
||||||
Make::TPage(Assets::Main::DoenerFishInfo.tim.get_texture_position(), GPU::SemiTransparency::B_add_F, GPU::TextureColorMode::clut4),
|
Make::TPage(doener_fish_png::tim.get_texture_position(), GPU::SemiTransparency::B_add_F, GPU::TextureColorMode::clut4),
|
||||||
Make::PageClut(Assets::Main::DoenerFishInfo.tim.get_clut_position()),
|
Make::PageClut(doener_fish_png::tim.get_clut_position()),
|
||||||
GPU::Color24::Grey()
|
GPU::Color24::Grey()
|
||||||
).linked());
|
).linked());
|
||||||
|
|
||||||
|
@@ -6,8 +6,8 @@ namespace GTETest {
|
|||||||
using namespace JabyEngine;
|
using namespace JabyEngine;
|
||||||
|
|
||||||
static constexpr auto JabySTARTim = SimpleTIM::create(
|
static constexpr auto JabySTARTim = SimpleTIM::create(
|
||||||
// v Doenerfisch rotates so we need some space
|
// v Dönerfisch rotates so we need some space
|
||||||
Assets::Main::DoenerFishInfo.tim.get_texture_x(), Assets::Main::DoenerFishInfo.tim.get_texture_y() + Assets::Main::DoenerFishInfo.size.height + 2,
|
doener_fish_png::tim.get_texture_x(), doener_fish_png::tim.get_texture_y() + doener_fish_png::size.height + 2,
|
||||||
Assets::Main::DoenerFishInfo.tim.get_clut_x() + 16, Assets::Main::DoenerFishInfo.tim.get_clut_y()
|
doener_fish_png::tim.get_clut_x() + 16, doener_fish_png::tim.get_clut_y()
|
||||||
);
|
);
|
||||||
}
|
}
|
@@ -108,8 +108,9 @@ static const Menu::SimpleMenu::Entry MenuEntries[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const auto doener_fish = Make::SPRT(
|
static const auto doener_fish = Make::SPRT(
|
||||||
Make::AreaI16(Make::PositionI16(8, GPU::Display::Height - Assets::Main::DoenerFishInfo.size.height), Assets::Main::DoenerFishInfo.size), // v this needs to be nicer! Has to be
|
Make::AreaI16(Make::PositionI16(8, GPU::Display::Height - doener_fish_png::size.height), doener_fish_png::size),
|
||||||
Make::OffsetPageWithClut(Assets::Main::DoenerFishInfo.tim.get_page_offset_clut4(), Make::PageClut(Assets::Main::DoenerFishInfo.tim.get_clut_position())),
|
// v this needs to be nicer! Has to be
|
||||||
|
Make::OffsetPageWithClut(doener_fish_png::tim.get_page_offset_clut4(), Make::PageClut(doener_fish_png::tim.get_clut_position())),
|
||||||
GPU::Color24::Grey()
|
GPU::Color24::Grey()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -68,7 +68,7 @@ namespace Assets {
|
|||||||
|
|
||||||
static const CDFile Files[] = {
|
static const CDFile Files[] = {
|
||||||
CDFileBuilder::simple_tim(LBA::PACO, PacoTIM),
|
CDFileBuilder::simple_tim(LBA::PACO, PacoTIM),
|
||||||
CDFileBuilder::simple_tim(LBA::DFISH, DoenerFishInfo.tim),
|
CDFileBuilder::simple_tim(LBA::DFISH, doener_fish_png::tim),
|
||||||
CDFileBuilder::simple_tim(LBA::JABY_LOAD, JabyLoader::TIMLoaction),
|
CDFileBuilder::simple_tim(LBA::JABY_LOAD, JabyLoader::TIMLoaction),
|
||||||
CDFileBuilder::sony_vag(LBA::APPLE_SFX, VAG::create(0, 1.0_vol)),
|
CDFileBuilder::sony_vag(LBA::APPLE_SFX, VAG::create(0, 1.0_vol)),
|
||||||
CDFileBuilder::sony_vag(LBA::BLUBB_SFX, VAG::create(1, 1.0_vol)),
|
CDFileBuilder::sony_vag(LBA::BLUBB_SFX, VAG::create(1, 1.0_vol)),
|
||||||
|
@@ -2,6 +2,7 @@ include $(JABY_ENGINE_DIR)/mkfile/common/ExportPath.mk
|
|||||||
include $(JABY_ENGINE_DIR)/mkfile/common/RebuildTarget.mk
|
include $(JABY_ENGINE_DIR)/mkfile/common/RebuildTarget.mk
|
||||||
|
|
||||||
OUTPUT_DIR = bin
|
OUTPUT_DIR = bin
|
||||||
|
AUTO_GEN_DIR = ../application/include/auto_gen
|
||||||
CLUT_4_COLOR_TRANS_FLAGS = simple-tim clut4 --color-trans
|
CLUT_4_COLOR_TRANS_FLAGS = simple-tim clut4 --color-trans
|
||||||
|
|
||||||
# Ressources to convert
|
# Ressources to convert
|
||||||
@@ -22,12 +23,6 @@ IconTexture_FLAGS = simple-tim clut4 --semi-trans --color-trans
|
|||||||
INPUT += $(OUTPUT_DIR)/Paco.img
|
INPUT += $(OUTPUT_DIR)/Paco.img
|
||||||
Paco_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)
|
Paco_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)
|
||||||
|
|
||||||
INPUT += $(OUTPUT_DIR)/Controller.img
|
|
||||||
Controller_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)
|
|
||||||
|
|
||||||
INPUT += $(OUTPUT_DIR)/doener_fish.img
|
|
||||||
doener_fish_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)
|
|
||||||
|
|
||||||
INPUT += $(OUTPUT_DIR)/JabyStar.img
|
INPUT += $(OUTPUT_DIR)/JabyStar.img
|
||||||
JabyStar_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)
|
JabyStar_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)
|
||||||
|
|
||||||
@@ -60,7 +55,12 @@ $(OUTPUT_DIR)/%.tim: %.png
|
|||||||
@mkdir -p $(OUTPUT_DIR)
|
@mkdir -p $(OUTPUT_DIR)
|
||||||
psxfileconv --lz4 $< -o $@ $($*_TIM_FLAGS)
|
psxfileconv --lz4 $< -o $@ $($*_TIM_FLAGS)
|
||||||
|
|
||||||
all: $(INPUT)
|
$(AUTO_GEN_DIR)/vram_layout.hpp: tim_example.tim_project Controller.png doener_fish.png
|
||||||
|
@mkdir -p $(AUTO_GEN_DIR)
|
||||||
|
psxfileconv tim_example.tim_project -o $(OUTPUT_DIR)/dummy.img project --hpp $(AUTO_GEN_DIR)/vram_layout.hpp
|
||||||
|
|
||||||
|
all: $(INPUT) $(AUTO_GEN_DIR)/vram_layout.hpp
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -fr $(OUTPUT_DIR)
|
rm -fr $(OUTPUT_DIR)
|
||||||
|
rm -fr $(AUTO_GEN_DIR)
|
1
examples/PoolBox/assets/tim_example.tim_project
Normal file
1
examples/PoolBox/assets/tim_example.tim_project
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"jobs":[{"name":"doener_fish.png","file_path":"doener_fish.png","image_pos":{"x":926,"y":0},"palette_rect":{"pos":{"x":976,"y":510},"size":{"width":16,"height":1}},"settings":{"compress":true,"transparency":"FirstColor","encoding":"FourBit"}},{"name":"Controller.png","file_path":"Controller.png","image_pos":{"x":384,"y":0},"palette_rect":{"pos":{"x":384,"y":511},"size":{"width":16,"height":1}},"settings":{"compress":true,"transparency":"FirstColor","encoding":"FourBit"}}]}
|
@@ -224,7 +224,7 @@ namespace JabyEngine {
|
|||||||
return Size::create(static_cast<T>(size.width), static_cast<T>(size.height));
|
return Size::create(static_cast<T>(size.width), static_cast<T>(size.height));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto operator<=>(const Size<T>&) const = default;
|
bool operator<=>(const Size<T>&) const = default;
|
||||||
};
|
};
|
||||||
using SizeI8 = Size<int8_t>;
|
using SizeI8 = Size<int8_t>;
|
||||||
using SizeU8 = Size<uint8_t>;
|
using SizeU8 = Size<uint8_t>;
|
||||||
|
@@ -19,13 +19,13 @@
|
|||||||
{
|
{
|
||||||
"label": "make",
|
"label": "make",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "../../scripts/podman_jaby_engine.sh ../../:src/Library make ${input:target} BUILD_PROFILE=${input:build cfg} PSX_TV_FORMAT=${input:tv format} CUSTOM_CONFIG=${input:config options}",
|
"command": "../../scripts/podman_jaby_engine.sh ../../:src/Library bear --output ${workspaceFolder}/../../compile_commands.json -- make ${input:target} BUILD_PROFILE=${input:build cfg} PSX_TV_FORMAT=${input:tv format} CUSTOM_CONFIG=${input:config options}",
|
||||||
"group": "build"
|
"group": "build"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "make_all",
|
"label": "make_all",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "../../scripts/podman_jaby_engine.sh ../../:src/Library make -f MakeAll.mk ${input:target prefix}_${input:target} BUILD_PROFILE=${input:build cfg} CUSTOM_CONFIG=${input:config options}",
|
"command": "../../scripts/podman_jaby_engine.sh ../../:src/Library bear --output ${workspaceFolder}/../../compile_commands.json -- make -f MakeAll.mk ${input:target prefix}_${input:target} BUILD_PROFILE=${input:build cfg} CUSTOM_CONFIG=${input:config options}",
|
||||||
"group": "build"
|
"group": "build"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -75,29 +75,5 @@
|
|||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"cmake.configureOnOpen": false,
|
"cmake.configureOnOpen": false,
|
||||||
"C_Cpp.default.includePath": [
|
|
||||||
"include",
|
|
||||||
"../../include"
|
|
||||||
],
|
|
||||||
"C_Cpp.default.compilerPath": "",
|
|
||||||
"C_Cpp.default.cStandard": "c17",
|
|
||||||
"C_Cpp.default.cppStandard": "c++20",
|
|
||||||
"C_Cpp.default.intelliSenseMode": "linux-gcc-x86",
|
|
||||||
"C_Cpp.default.compilerArgs": [
|
|
||||||
],
|
|
||||||
"C_Cpp.default.defines": [
|
|
||||||
"JABYENGINE_PAL",
|
|
||||||
"__DEBUG_SPU_MMU__",
|
|
||||||
"__friends=public"
|
|
||||||
],
|
|
||||||
"files.exclude": {
|
|
||||||
"**/*.o": true,
|
|
||||||
"**/*.dep": true
|
|
||||||
},
|
|
||||||
"files.associations": {
|
|
||||||
"stdio.h": "c",
|
|
||||||
"TUTO0.C": "cpp",
|
|
||||||
"MAIN.C": "cpp"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
5748
src/Tools/psxfileconv/Cargo.lock
generated
5748
src/Tools/psxfileconv/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -28,11 +28,15 @@ symphonia-vorbis = ["symphonia", "symphonia/vorbis"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "2.8.0"
|
bitflags = "2.8.0"
|
||||||
cdtypes = {path = "../cdtypes"}
|
cdtypes = {path = "../cdtypes"}
|
||||||
|
cpp_out = {path = "../cpp_out"}
|
||||||
clap = {version = "4.5.27", features = ["derive"]}
|
clap = {version = "4.5.27", features = ["derive"]}
|
||||||
image = "0.24.9"
|
image = "0.24.9"
|
||||||
hound = "3.5.1"
|
hound = "3.5.1"
|
||||||
paste = "1.0.15"
|
paste = "1.0.15"
|
||||||
png = "0.17.16"
|
png = "0.17.16"
|
||||||
rubato = "0.16.1"
|
rubato = "0.16.1"
|
||||||
|
serde = {version = "1.0.219", features = ["derive"]}
|
||||||
|
serde_json = "1.0"
|
||||||
symphonia = {version = "0.5.4", optional = true, default-features = false}
|
symphonia = {version = "0.5.4", optional = true, default-features = false}
|
||||||
|
tim_tool = {path = "../tim_tool"}
|
||||||
tool_helper = {path = "../tool_helper"}
|
tool_helper = {path = "../tool_helper"}
|
||||||
|
@@ -36,7 +36,8 @@ fn modify_palette(mut image: IndexedImage, clut_align: ClutAlignment, semi_trans
|
|||||||
image
|
image
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode<T: PSXImageConverter>(header_conv: &mut dyn HeaderEncoder, image: T, tex_pos: Point, clut_pos: Point, color_depth: ColorType, clut_align: ClutAlignment, output: &mut dyn Write) -> Result<(), Error> {
|
fn encode<T: PSXImageConverter>(header_conv: &mut dyn HeaderEncoder, image: T, tex_pos: Point, clut_pos: Point, color_depth: ColorType, clut_align: ClutAlignment, output: &mut dyn Write) -> Result<(u16, u16), Error> {
|
||||||
|
let image_size = (image.width(), image.height());
|
||||||
let (width, height) = {
|
let (width, height) = {
|
||||||
fn return_error(clut_type: u32, div: u32, width: u16, height: u16) -> Result<(u16, u16), Error> {
|
fn return_error(clut_type: u32, div: u32, width: u16, height: u16) -> Result<(u16, u16), Error> {
|
||||||
return Err(Error::from_callback(|| {format!("CLUT {} images require a width divideable by {} (found width: {}/{}={}, height: {})", clut_type, div, width, div, (width as f32/div as f32), height)}));
|
return Err(Error::from_callback(|| {format!("CLUT {} images require a width divideable by {} (found width: {}/{}={}, height: {})", clut_type, div, width, div, (width as f32/div as f32), height)}));
|
||||||
@@ -115,10 +116,10 @@ fn encode<T: PSXImageConverter>(header_conv: &mut dyn HeaderEncoder, image: T, t
|
|||||||
tool_helper::raw::write_raw(output, &color)?;
|
tool_helper::raw::write_raw(output, &color)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(image_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_full16(header_conv: &mut dyn HeaderEncoder, input: Input, output: &mut dyn Write, tex_pos: Point) -> Result<(), Error> {
|
fn convert_full16(header_conv: &mut dyn HeaderEncoder, input: Input, output: &mut dyn Write, tex_pos: Point) -> Result<(u16, u16), Error> {
|
||||||
match ImageReader::new(Cursor::new(tool_helper::input_to_vec(input)?)).with_guessed_format()?.decode() {
|
match ImageReader::new(Cursor::new(tool_helper::input_to_vec(input)?)).with_guessed_format()?.decode() {
|
||||||
Ok(image) => {
|
Ok(image) => {
|
||||||
match image {
|
match image {
|
||||||
@@ -132,7 +133,7 @@ fn convert_full16(header_conv: &mut dyn HeaderEncoder, input: Input, output: &mu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_palette_based(header_conv: &mut dyn HeaderEncoder, input: Input, output: &mut dyn Write, tex_pos: Point, clut_pos: Point, color_type: ColorType, clut_align: ClutAlignment, semi_transparent: bool, transparent_palette: bool) -> Result<(), Error> {
|
fn convert_palette_based(header_conv: &mut dyn HeaderEncoder, input: Input, output: &mut dyn Write, tex_pos: Point, clut_pos: Point, color_type: ColorType, clut_align: ClutAlignment, semi_transparent: bool, transparent_palette: bool) -> Result<(u16, u16), Error> {
|
||||||
match png::Decoder::new(input).read_info() {
|
match png::Decoder::new(input).read_info() {
|
||||||
Ok(reader) => {
|
Ok(reader) => {
|
||||||
let output_type = {
|
let output_type = {
|
||||||
|
@@ -7,7 +7,7 @@ use tool_helper::{Error, Input};
|
|||||||
|
|
||||||
pub type Arguments = super::args::Arguments;
|
pub type Arguments = super::args::Arguments;
|
||||||
|
|
||||||
pub fn convert(args: Arguments, input: Input, output: &mut dyn Write) -> Result<(), Error> {
|
pub fn convert(args: Arguments, input: Input, output: &mut dyn Write) -> Result<(u16, u16), Error> {
|
||||||
let mut header_conv = Header::default();
|
let mut header_conv = Header::default();
|
||||||
match args.color_depth {
|
match args.color_depth {
|
||||||
ColorType::Full16 => super::convert_full16(&mut header_conv, input, output, Point::default()),
|
ColorType::Full16 => super::convert_full16(&mut header_conv, input, output, Point::default()),
|
||||||
|
@@ -9,16 +9,16 @@ use tool_helper::{Error, Input};
|
|||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
pub struct Arguments {
|
pub struct Arguments {
|
||||||
#[clap(flatten)]
|
#[clap(flatten)]
|
||||||
global: super::args::Arguments,
|
pub(crate) global: super::args::Arguments,
|
||||||
|
|
||||||
#[clap(long, value_parser, default_value_t, value_name = Point::POINT_VALUE_NAME)]
|
#[clap(long, value_parser, default_value_t, value_name = Point::POINT_VALUE_NAME)]
|
||||||
clut_pos: Point,
|
pub(crate) clut_pos: Point,
|
||||||
|
|
||||||
#[clap(long, value_parser, default_value_t, value_name = Point::POINT_VALUE_NAME)]
|
#[clap(long, value_parser, default_value_t, value_name = Point::POINT_VALUE_NAME)]
|
||||||
tex_pos: Point,
|
pub(crate) tex_pos: Point,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn convert(args: Arguments, input: Input, output: &mut dyn Write) -> Result<(), Error> {
|
pub fn convert(args: Arguments, input: Input, output: &mut dyn Write) -> Result<(u16, u16), Error> {
|
||||||
let global_args = args.global;
|
let global_args = args.global;
|
||||||
let mut header_conv = Header::default();
|
let mut header_conv = Header::default();
|
||||||
|
|
||||||
|
@@ -1,3 +1,88 @@
|
|||||||
pub mod audio;
|
pub mod audio;
|
||||||
pub mod images;
|
pub mod images;
|
||||||
pub mod nothing;
|
pub mod nothing;
|
||||||
|
pub mod project;
|
||||||
|
|
||||||
|
use crate::audio::*;
|
||||||
|
use crate::images::*;
|
||||||
|
|
||||||
|
use clap::Subcommand;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use tool_helper::Error;
|
||||||
|
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
pub enum SubCommands {
|
||||||
|
Nothing,
|
||||||
|
SimpleTIM(reduced_tim::Arguments),
|
||||||
|
TIM(tim::Arguments),
|
||||||
|
VAG(vag::Arguments),
|
||||||
|
XA(xa::Arguments),
|
||||||
|
Project(project::Arguments),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run_subcommand(compress_lz4: bool, input_path: Option<PathBuf>, output_path: Option<PathBuf>, sub_command: SubCommands) -> Result<Option<(u16, u16)>, Error> {
|
||||||
|
let mut input = tool_helper::open_input(&input_path)?;
|
||||||
|
let mut buffer = Vec::<u8>::new();
|
||||||
|
let mut output_file = tool_helper::open_output(&output_path)?;
|
||||||
|
let dst_buffer = {
|
||||||
|
if compress_lz4 {
|
||||||
|
&mut buffer as &mut dyn std::io::Write
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
&mut output_file as &mut dyn std::io::Write
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let cmd_result: Result<Option<(u16, u16)>, Error> = {
|
||||||
|
match sub_command {
|
||||||
|
SubCommands::Nothing => {
|
||||||
|
nothing::copy(&mut input, dst_buffer)?;
|
||||||
|
Ok(None)
|
||||||
|
},
|
||||||
|
SubCommands::SimpleTIM(args) => {
|
||||||
|
Ok(Some(reduced_tim::convert(args, input, dst_buffer)?))
|
||||||
|
},
|
||||||
|
SubCommands::TIM(args) => {
|
||||||
|
Ok(Some(tim::convert(args, input, dst_buffer)?))
|
||||||
|
},
|
||||||
|
SubCommands::VAG(args) => {
|
||||||
|
audio::vag::convert(args, &output_path, input, dst_buffer)?;
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
SubCommands::XA(args) => {
|
||||||
|
audio::xa::convert(args, input, dst_buffer)?;
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
SubCommands::Project(args) => {
|
||||||
|
project::run_project(input, args, input_path, &output_path)?;
|
||||||
|
if let Some(file_path) = &output_path {
|
||||||
|
let _result = std::fs::remove_file(file_path);
|
||||||
|
}
|
||||||
|
Ok(None)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
match cmd_result {
|
||||||
|
Ok(cmd_result) => {
|
||||||
|
// We encoded the file to a temporary buffer and now need to write it
|
||||||
|
if compress_lz4 {
|
||||||
|
let buffer = tool_helper::compress::psx_default::lz4(&buffer)?;
|
||||||
|
output_file.write(&buffer)?;
|
||||||
|
}
|
||||||
|
Ok(cmd_result)
|
||||||
|
}
|
||||||
|
Err(cmd_error) => {
|
||||||
|
if let Some(file_path) = output_path {
|
||||||
|
let _result = std::fs::remove_file(file_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
tool_helper::print_warning("Open stream detected! Incomplete file can not be deleted".to_owned());
|
||||||
|
}
|
||||||
|
|
||||||
|
Err(cmd_error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,11 +1,11 @@
|
|||||||
use clap::{Parser, Subcommand};
|
use clap::Parser;
|
||||||
use psxfileconv::{audio::{self, *}, images::*, nothing};
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tool_helper::{exit_with_error, Error};
|
use psxfileconv::{SubCommands, run_subcommand};
|
||||||
|
use tool_helper::exit_with_error;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(about = "Converts files to various JabyEngine related file formats", long_about = None)]
|
#[clap(about = "Converts files to various JabyEngine related file formats", long_about = None)]
|
||||||
struct CommandLine {
|
pub struct CommandLine {
|
||||||
#[clap(long="lz4", default_value_t=false)]
|
#[clap(long="lz4", default_value_t=false)]
|
||||||
compress_lz4: bool,
|
compress_lz4: bool,
|
||||||
|
|
||||||
@@ -19,64 +19,10 @@ struct CommandLine {
|
|||||||
sub_command: SubCommands,
|
sub_command: SubCommands,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
|
||||||
enum SubCommands {
|
|
||||||
Nothing,
|
|
||||||
SimpleTIM(reduced_tim::Arguments),
|
|
||||||
TIM(tim::Arguments),
|
|
||||||
VAG(vag::Arguments),
|
|
||||||
XA(xa::Arguments),
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_main(cmd: CommandLine) -> Result<(), Error> {
|
|
||||||
let mut input = tool_helper::open_input(&cmd.input_file)?;
|
|
||||||
let mut buffer = Vec::<u8>::new();
|
|
||||||
let mut output_file = tool_helper::open_output(&cmd.output_file)?;
|
|
||||||
let dst_buffer = {
|
|
||||||
if cmd.compress_lz4 {
|
|
||||||
&mut buffer as &mut dyn std::io::Write
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
&mut output_file as &mut dyn std::io::Write
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let cmd_result: Result<(), Error> = {
|
|
||||||
match cmd.sub_command {
|
|
||||||
SubCommands::Nothing => nothing::copy(&mut input, dst_buffer),
|
|
||||||
SubCommands::SimpleTIM(args) => reduced_tim::convert(args, input, dst_buffer),
|
|
||||||
SubCommands::TIM(args) => tim::convert(args, input, dst_buffer),
|
|
||||||
SubCommands::VAG(args) => audio::vag::convert(args, &cmd.output_file, input, dst_buffer),
|
|
||||||
SubCommands::XA(args) => audio::xa::convert(args, input, dst_buffer),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Err(cmd_error) = cmd_result {
|
|
||||||
if let Some(file_path) = cmd.output_file {
|
|
||||||
let _result = std::fs::remove_file(file_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
tool_helper::print_warning("Open stream detected! Incomplete file can not be deleted".to_owned());
|
|
||||||
}
|
|
||||||
|
|
||||||
return Err(cmd_error);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We encoded the file to a temporary buffer and now need to write it
|
|
||||||
if cmd.compress_lz4 {
|
|
||||||
let buffer = tool_helper::compress::psx_default::lz4(&buffer)?;
|
|
||||||
output_file.write(&buffer)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
match CommandLine::try_parse() {
|
match CommandLine::try_parse() {
|
||||||
Ok(cmd) => {
|
Ok(cmd) => {
|
||||||
if let Err(error) = run_main(cmd) {
|
if let Err(error) = run_subcommand(cmd.compress_lz4, cmd.input_file, cmd.output_file, cmd.sub_command) {
|
||||||
exit_with_error(error);
|
exit_with_error(error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
39
src/Tools/psxfileconv/src/project/hpp_out.rs
Normal file
39
src/Tools/psxfileconv/src/project/hpp_out.rs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
use std::path::PathBuf;
|
||||||
|
use tim_tool::logic::project::Job;
|
||||||
|
use tool_helper::{Error, Output};
|
||||||
|
|
||||||
|
pub struct CppHeader {
|
||||||
|
file_out: Output,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CppHeader {
|
||||||
|
pub fn new(file_path: &Option<PathBuf>) -> Result<CppHeader, Error> {
|
||||||
|
let mut file_out = tool_helper::open_output(file_path)?;
|
||||||
|
|
||||||
|
writeln!(file_out, "#pragma once")?;
|
||||||
|
writeln!(file_out, "#include <PSX/File/cd_file_types.hpp>")?;
|
||||||
|
writeln!(file_out, "")?;
|
||||||
|
|
||||||
|
Ok(CppHeader{file_out})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn push_job(&mut self, job: &Job, size: (u16, u16)) -> Result<(), Error> {
|
||||||
|
let name = job.name.replace('.', "_");
|
||||||
|
let (clut_x, clut_y) = if let Some(palette_rect) = &job.palette_rect {(palette_rect.pos.x, palette_rect.pos.y)} else {(0, 0)};
|
||||||
|
|
||||||
|
writeln!(self.file_out, "namespace {} {{", name)?;
|
||||||
|
writeln!(self.file_out, "\tusing namespace JabyEngine;")?;
|
||||||
|
writeln!(self.file_out, "")?;
|
||||||
|
writeln!(self.file_out, "\tstatic constexpr auto tim = SimpleTIM::create({}, {}, {}, {});", job.image_pos.x, job.image_pos.y, clut_x, clut_y)?;
|
||||||
|
writeln!(self.file_out, "\tstatic constexpr auto size = GPU::SizeI16::create({}, {});", size.0, size.1)?;
|
||||||
|
writeln!(self.file_out, "}}")?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for CppHeader {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
90
src/Tools/psxfileconv/src/project/mod.rs
Normal file
90
src/Tools/psxfileconv/src/project/mod.rs
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
mod hpp_out;
|
||||||
|
|
||||||
|
use crate::images::args::{Arguments as IMGArguments, ClutAlignment, ColorType};
|
||||||
|
use clap::Args;
|
||||||
|
use hpp_out::CppHeader;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use tool_helper::{Error, Input};
|
||||||
|
use tim_tool::logic::{tim::types::Encoding, project::*};
|
||||||
|
|
||||||
|
#[derive(Args)]
|
||||||
|
pub struct Arguments {
|
||||||
|
#[clap(long="hpp", value_parser)]
|
||||||
|
hpp_out_path: Option<PathBuf>
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run_project(input: Input, args: Arguments, input_path: Option<PathBuf>, output_path: &Option<PathBuf>) -> Result<(), Error> {
|
||||||
|
let location_path = if let Some(input_path) = input_path {input_path} else {PathBuf::from(".")};
|
||||||
|
let output_path = if let Some(output_path) = &output_path {
|
||||||
|
let mut output_path = output_path.clone();
|
||||||
|
if output_path.is_file() {
|
||||||
|
output_path.pop();
|
||||||
|
}
|
||||||
|
output_path
|
||||||
|
} else {PathBuf::from(".")};
|
||||||
|
let project = serde_json::from_reader::<Input, Project>(input).map_err(|error|{Error::from_text(format!("Reading project failed: {}", error))})?;
|
||||||
|
let mut hpp_out = CppHeader::new(&args.hpp_out_path)?;
|
||||||
|
|
||||||
|
for mut job in project.jobs {
|
||||||
|
let args = to_arguments(&job)?;
|
||||||
|
let output_path = {
|
||||||
|
let mut path = output_path.clone();
|
||||||
|
|
||||||
|
path.push(&job.name);
|
||||||
|
path.set_extension("img");
|
||||||
|
path
|
||||||
|
};
|
||||||
|
|
||||||
|
let sub_command = crate::SubCommands::SimpleTIM(args);
|
||||||
|
let org_img_size = crate::run_subcommand(job.settings.compress, Some(Job::create_file_path(job.file_path, &location_path)), Some(output_path), sub_command)?;
|
||||||
|
|
||||||
|
job.file_path = PathBuf::new();
|
||||||
|
hpp_out.push_job(&job, org_img_size.unwrap_or((0, 0)))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn to_arguments(job: &Job) -> Result<IMGArguments, Error> {
|
||||||
|
let (semi_transparent, transparent_palette) = get_transparency(&job.settings.transparency);
|
||||||
|
|
||||||
|
return Ok(IMGArguments {
|
||||||
|
color_depth: get_encoding(&job.settings.encoding),
|
||||||
|
clut_align: get_palette_rect(&job.palette_rect)?,
|
||||||
|
semi_transparent,
|
||||||
|
transparent_palette,
|
||||||
|
});
|
||||||
|
|
||||||
|
fn get_transparency(transparency: &Transparency) -> (bool, bool) {
|
||||||
|
match transparency {
|
||||||
|
Transparency::None => (false, false),
|
||||||
|
Transparency::FirstColor => (false, true),
|
||||||
|
Transparency::PSXSemi => (true, false),
|
||||||
|
Transparency::Both => (true, true),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_encoding(encoding: &Encoding) -> ColorType {
|
||||||
|
match encoding {
|
||||||
|
Encoding::FourBit => ColorType::Clut4,
|
||||||
|
Encoding::EightBit => ColorType::Clut8,
|
||||||
|
Encoding::FullColor => ColorType::Full16,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_palette_rect(rect: &Option<PaletteRect>) -> Result<ClutAlignment, Error> {
|
||||||
|
if let Some(rect) = rect {
|
||||||
|
if rect.size.height == 1 {
|
||||||
|
return Ok(ClutAlignment::Linear);
|
||||||
|
}
|
||||||
|
|
||||||
|
if rect.size.width%16 == 0 {
|
||||||
|
return Ok(ClutAlignment::Block);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Err(Error::from_text(format!("psxfileconv currently only supports linear or block CLUTs with a width of 16px")));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(ClutAlignment::None)
|
||||||
|
}
|
||||||
|
}
|
1669
src/Tools/tim_tool/Cargo.lock
generated
1669
src/Tools/tim_tool/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,22 +1,23 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "tim_tool"
|
name = "tim_tool"
|
||||||
version = "0.1.0"
|
version = "1.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
pathdiff = "0.2.3"
|
||||||
png = "0.17.16"
|
png = "0.17.16"
|
||||||
rfd = "0.15.2"
|
rfd = "0.15.3"
|
||||||
slint = "1.9.2"
|
slint = "1.10.0"
|
||||||
tiny-skia = "0.11.4"
|
serde = {version = "1.0.219", features = ["derive"]}
|
||||||
serde = {version = "1.0.140", features = ["derive"]}
|
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
tiny-skia = "0.11.4"
|
||||||
tool_helper = {path = "../tool_helper"}
|
tool_helper = {path = "../tool_helper"}
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
slint-build = "1.9.2"
|
slint-build = "1.10.0"
|
||||||
|
|
||||||
[package.metadata.bundle]
|
[package.metadata.bundle]
|
||||||
name = "TIMTOOL"
|
name = "TIMTOOL"
|
||||||
|
@@ -4,7 +4,7 @@ use crate::{gui::{self, main_tab::{MainTab, NewVRAMImageInfo}, MutexTIMManager,
|
|||||||
use super::FileTab;
|
use super::FileTab;
|
||||||
use rfd::FileDialog;
|
use rfd::FileDialog;
|
||||||
use slint::SharedString;
|
use slint::SharedString;
|
||||||
use tim_tool::logic::{project::{ImagePosition, Job, PaletteRect, Project}, tim::types::Encoding, TIMManager};
|
use tim_tool::logic::{project::{FileSettings, ImagePosition, Job, PaletteRect, Project, Transparency}, tim::types::Encoding, TIMManager};
|
||||||
use tool_helper::Error;
|
use tool_helper::Error;
|
||||||
|
|
||||||
pub(super) fn on_browse_file(tim_manager: MutexTIMManager) -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static {
|
pub(super) fn on_browse_file(tim_manager: MutexTIMManager) -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static {
|
||||||
@@ -46,7 +46,7 @@ pub(super) fn on_add_image(tim_manager: MutexTIMManager) -> impl FnMut(&mut File
|
|||||||
let file_name = file_tab.get_file_name();
|
let file_name = file_tab.get_file_name();
|
||||||
let encoding = file_tab.get_encoding()?;
|
let encoding = file_tab.get_encoding()?;
|
||||||
|
|
||||||
add_unadded_tim(main_tab, &mut tim_manager.lock().expect("VRAM already locked"), UnaddedTIM::new(&file_name, encoding))?;
|
add_unadded_tim(main_tab, &mut tim_manager.lock().expect("VRAM already locked"), UnaddedTIM::new(&file_name, encoding), FileSettings::from_encoding(encoding))?;
|
||||||
|
|
||||||
file_tab.clear_load();
|
file_tab.clear_load();
|
||||||
main_window.invoke_change_to_main();
|
main_window.invoke_change_to_main();
|
||||||
@@ -77,11 +77,20 @@ pub(super) fn on_load_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
|||||||
}
|
}
|
||||||
|
|
||||||
for job in new_project.jobs {
|
for job in new_project.jobs {
|
||||||
let (_, _) = tim_manager.load_unadded_tim(&job.file_path)?;
|
let file_path = Job::create_file_path(job.file_path, open_location.as_str());
|
||||||
let (pal_width, pal_height) = job.palette_rect.size.into();
|
let (_, _) = tim_manager.load_unadded_tim(&file_path)?;
|
||||||
|
let (pal_x, pal_y, pal_width, pal_height) = if let Some(palette_rect) = job.palette_rect {palette_rect.into()} else {(0, 0, 0, 0)};
|
||||||
|
|
||||||
tim_manager.change_unadded_tim_palette_size(pal_width, pal_height)?;
|
tim_manager.change_unadded_tim_palette_size(pal_width, pal_height)?;
|
||||||
add_unadded_tim(main_tab, &mut tim_manager, UnaddedTIM::from_job(&job))?;
|
let unadded_tim = UnaddedTIM{
|
||||||
|
file_name: &job.name,
|
||||||
|
image_x: job.image_pos.x,
|
||||||
|
image_y: job.image_pos.y,
|
||||||
|
palette_x: pal_x,
|
||||||
|
palette_y: pal_y,
|
||||||
|
encoding: job.settings.encoding
|
||||||
|
};
|
||||||
|
add_unadded_tim(main_tab, &mut tim_manager, unadded_tim, job.settings)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
main_window.invoke_change_to_main();
|
main_window.invoke_change_to_main();
|
||||||
@@ -98,6 +107,7 @@ pub(super) fn on_save_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
|||||||
|
|
||||||
let tim_info = tim_manager.lock().expect("VRAM already locked").clone_added_tims();
|
let tim_info = tim_manager.lock().expect("VRAM already locked").clone_added_tims();
|
||||||
let vram_info = main_tab.clone_vram_info();
|
let vram_info = main_tab.clone_vram_info();
|
||||||
|
let use_rel_path = main_window.get_project_widget_use_rel_paths();
|
||||||
|
|
||||||
if tim_info.len() != vram_info.len() {
|
if tim_info.len() != vram_info.len() {
|
||||||
return Err(Error::from_str("TIM and VRAM info not in sync! Please close program"));
|
return Err(Error::from_str("TIM and VRAM info not in sync! Please close program"));
|
||||||
@@ -105,13 +115,18 @@ pub(super) fn on_save_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
|||||||
|
|
||||||
let mut cur_job:Option<Job> = None;
|
let mut cur_job:Option<Job> = None;
|
||||||
let mut cur_palette:Option<PaletteRect> = None;
|
let mut cur_palette:Option<PaletteRect> = None;
|
||||||
let mut project = Project::new(tim_info.into_iter().zip(vram_info.into_iter()).filter_map(|(tim, (file_name, vram))| {
|
let mut map_result = Ok(());
|
||||||
|
let mut project = Project::new(tim_info.into_iter().zip(vram_info.into_iter()).filter_map(|(tim, (name, vram))| {
|
||||||
|
if map_result.is_err() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
if vram.is_palette {
|
if vram.is_palette {
|
||||||
let cur_palette = std::mem::replace(&mut cur_palette, None);
|
let cur_palette = std::mem::replace(&mut cur_palette, None);
|
||||||
if let Some(mut cur_palette) = cur_palette {
|
if let Some(mut cur_palette) = cur_palette {
|
||||||
cur_palette.pos = ImagePosition::new(vram.x as u16, vram.y as u16);
|
cur_palette.pos = ImagePosition::new(vram.x as u16, vram.y as u16);
|
||||||
if let Some(cur_job) = &mut cur_job {
|
if let Some(cur_job) = &mut cur_job {
|
||||||
cur_job.palette_rect = cur_palette;
|
cur_job.palette_rect = Some(cur_palette);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
@@ -125,11 +140,26 @@ pub(super) fn on_save_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
|||||||
if let Some((width, height)) = tim.get_palette_size() {
|
if let Some((width, height)) = tim.get_palette_size() {
|
||||||
cur_palette = Some(PaletteRect::new(0, 0, width, height));
|
cur_palette = Some(PaletteRect::new(0, 0, width, height));
|
||||||
}
|
}
|
||||||
cur_job = Some(Job::new(file_name, tim.get_path(), (vram.x as u16, vram.y as u16), Encoding::from_str(vram.encoding_str.as_str())));
|
let file_path = if use_rel_path {
|
||||||
|
match tim.get_path_rel_to(PathBuf::from(save_location.as_str())) {
|
||||||
|
Ok(file_path) => file_path,
|
||||||
|
Err(error) => {
|
||||||
|
map_result = Err(error);
|
||||||
|
PathBuf::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {tim.get_path()};
|
||||||
|
cur_job = Some(Job::new(name, file_path, (vram.x as u16, vram.y as u16), FileSettings::new(
|
||||||
|
vram.use_compression,
|
||||||
|
Transparency::from(vram.trans_setting),
|
||||||
|
Encoding::from_str(vram.encoding_str.as_str())
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
prev_job
|
prev_job
|
||||||
}
|
}
|
||||||
}).collect());
|
}).collect());
|
||||||
|
map_result?;
|
||||||
|
|
||||||
if let Some(cur_job) = cur_job {
|
if let Some(cur_job) = cur_job {
|
||||||
project.jobs.push(cur_job);
|
project.jobs.push(cur_job);
|
||||||
}
|
}
|
||||||
@@ -192,17 +222,13 @@ impl<'a> UnaddedTIM<'a> {
|
|||||||
pub fn new(file_name: &String, encoding: Encoding,) -> UnaddedTIM {
|
pub fn new(file_name: &String, encoding: Encoding,) -> UnaddedTIM {
|
||||||
UnaddedTIM{file_name, image_x: 0, image_y: 0, palette_x: 0, palette_y: 0, encoding}
|
UnaddedTIM{file_name, image_x: 0, image_y: 0, palette_x: 0, palette_y: 0, encoding}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_job(job: &Job) -> UnaddedTIM {
|
|
||||||
UnaddedTIM{file_name: &job.name, image_x: job.image_pos.x, image_y: job.image_pos.y, palette_x: job.palette_rect.pos.x, palette_y: job.palette_rect.pos.y, encoding: job.encoding }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_unadded_tim(main_tab: &mut MainTab, tim_manager: &mut TIMManager, unadded_tim: UnaddedTIM) -> Result<(), Error> {
|
fn add_unadded_tim(main_tab: &mut MainTab, tim_manager: &mut TIMManager, unadded_tim: UnaddedTIM, settings: FileSettings) -> Result<(), Error> {
|
||||||
let (image, palette_image) = tim_manager.get_converted_unadded_tim_image(unadded_tim.encoding)?;
|
let (image, palette_image) = tim_manager.get_converted_unadded_tim_image(unadded_tim.encoding)?;
|
||||||
let (full_image, _) = tim_manager.get_converted_unadded_tim_image(Encoding::FullColor)?;
|
let (full_image, _) = tim_manager.get_converted_unadded_tim_image(Encoding::FullColor)?;
|
||||||
let image = NewVRAMImageInfo::new(image, unadded_tim.image_x, unadded_tim.image_y, unadded_tim.encoding);
|
let image = NewVRAMImageInfo::new(image, unadded_tim.image_x, unadded_tim.image_y, settings);
|
||||||
let palette_image = if let Some(palette_image) = palette_image { Some(NewVRAMImageInfo::new(palette_image, unadded_tim.palette_x, unadded_tim.palette_y, Encoding::FullColor)) } else { None };
|
let palette_image = if let Some(palette_image) = palette_image { Some(NewVRAMImageInfo::new(palette_image, unadded_tim.palette_x, unadded_tim.palette_y, FileSettings::from_encoding(Encoding::FullColor))) } else { None };
|
||||||
|
|
||||||
let images_created = main_tab.add_new_vram_file(unadded_tim.file_name, full_image, image, palette_image);
|
let images_created = main_tab.add_new_vram_file(unadded_tim.file_name, full_image, image, palette_image);
|
||||||
if let Err(error) = tim_manager.add_unadded_tim(images_created) {
|
if let Err(error) = tim_manager.add_unadded_tim(images_created) {
|
||||||
|
@@ -4,18 +4,18 @@ use crate::{gui::{MutexTIMManager, VRAM_HEIGHT, VRAM_WIDTH}, VRAMImgData, VRAMIn
|
|||||||
use super::MainWindowRef;
|
use super::MainWindowRef;
|
||||||
use slint::{Model, SharedString};
|
use slint::{Model, SharedString};
|
||||||
use std::{cell::RefCell, ops::RangeInclusive, rc::Rc, sync::{Arc, Mutex}};
|
use std::{cell::RefCell, ops::RangeInclusive, rc::Rc, sync::{Arc, Mutex}};
|
||||||
use tim_tool::logic::tim::types::Encoding;
|
use tim_tool::logic::project::FileSettings;
|
||||||
|
|
||||||
pub struct NewVRAMImageInfo {
|
pub struct NewVRAMImageInfo {
|
||||||
pub image: slint::Image,
|
pub image: slint::Image,
|
||||||
pub x: u16,
|
pub x: u16,
|
||||||
pub y: u16,
|
pub y: u16,
|
||||||
pub encoding: Encoding,
|
pub settings: FileSettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NewVRAMImageInfo {
|
impl NewVRAMImageInfo {
|
||||||
pub fn new(image: slint::Image, x: u16, y: u16, encoding: Encoding) -> NewVRAMImageInfo {
|
pub fn new(image: slint::Image, x: u16, y: u16, settings: FileSettings) -> NewVRAMImageInfo {
|
||||||
NewVRAMImageInfo{image, x, y, encoding}
|
NewVRAMImageInfo{image, x, y, settings}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ impl MainTab {
|
|||||||
pub fn add_new_vram_file(&mut self, file_name: &String, full_image: slint::Image, texture: NewVRAMImageInfo, image_palette: Option<NewVRAMImageInfo>) -> usize {
|
pub fn add_new_vram_file(&mut self, file_name: &String, full_image: slint::Image, texture: NewVRAMImageInfo, image_palette: Option<NewVRAMImageInfo>) -> usize {
|
||||||
let mut vram_data = self.vram.lock().expect("VRAM already locked");
|
let mut vram_data = self.vram.lock().expect("VRAM already locked");
|
||||||
let mut add_new_image = |file_name: &String, full_image: slint::Image, vram_image: NewVRAMImageInfo, palette_count: i32, is_palette: bool| {
|
let mut add_new_image = |file_name: &String, full_image: slint::Image, vram_image: NewVRAMImageInfo, palette_count: i32, is_palette: bool| {
|
||||||
let encoding_str = if is_palette {"<Palette>"} else {vram_image.encoding.to_str()};
|
let encoding_str = if is_palette {"<Palette>"} else {vram_image.settings.encoding.to_str()};
|
||||||
let vram_image = VRAMData {
|
let vram_image = VRAMData {
|
||||||
images: VRAMImgData {
|
images: VRAMImgData {
|
||||||
full_image,
|
full_image,
|
||||||
@@ -94,6 +94,8 @@ impl MainTab {
|
|||||||
x: vram_image.x as i32,
|
x: vram_image.x as i32,
|
||||||
y: vram_image.y as i32,
|
y: vram_image.y as i32,
|
||||||
encoding_str: SharedString::from(encoding_str),
|
encoding_str: SharedString::from(encoding_str),
|
||||||
|
use_compression: vram_image.settings.compress,
|
||||||
|
trans_setting: vram_image.settings.transparency.as_idx(),
|
||||||
palette_count,
|
palette_count,
|
||||||
is_palette,
|
is_palette,
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,72 @@ use super::tim::types::Encoding;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct FileSettings {
|
||||||
|
pub compress: bool,
|
||||||
|
pub transparency: Transparency,
|
||||||
|
pub encoding: Encoding,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FileSettings {
|
||||||
|
pub fn new(compress: bool, transparency: Transparency, encoding: Encoding) -> FileSettings {
|
||||||
|
FileSettings{compress, transparency, encoding}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_encoding(encoding: Encoding) -> FileSettings {
|
||||||
|
let mut new_type = FileSettings::default();
|
||||||
|
|
||||||
|
new_type.encoding = encoding;
|
||||||
|
new_type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::default::Default for FileSettings {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self{compress: Default::default(), transparency: Transparency::None, encoding: Encoding::FullColor}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct Job {
|
||||||
|
pub name: String,
|
||||||
|
pub file_path: PathBuf,
|
||||||
|
pub image_pos: ImagePosition,
|
||||||
|
pub palette_rect: Option<PaletteRect>,
|
||||||
|
pub settings: FileSettings,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Job {
|
||||||
|
pub fn new(name: String, file_path: PathBuf, image_pos: (u16, u16), settings: FileSettings) -> Job {
|
||||||
|
Job{name, file_path, image_pos: ImagePosition{x: image_pos.0, y: image_pos.1}, palette_rect: None, settings}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn create_file_path<T:?Sized + std::convert::AsRef<std::ffi::OsStr>>(file_path: PathBuf, location_path: &T) -> PathBuf {
|
||||||
|
if file_path.is_file() {
|
||||||
|
file_path
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
let mut new_file_path = PathBuf::from(location_path);
|
||||||
|
|
||||||
|
new_file_path.pop();
|
||||||
|
new_file_path.push(file_path);
|
||||||
|
new_file_path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct Project {
|
||||||
|
pub jobs: Vec<Job>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Project {
|
||||||
|
pub fn new(jobs: Vec<Job>) -> Project {
|
||||||
|
Project{jobs}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct ImagePosition {
|
pub struct ImagePosition {
|
||||||
pub x: u16,
|
pub x: u16,
|
||||||
@@ -56,6 +122,12 @@ impl PaletteRect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<PaletteRect> for (u16, u16, u16, u16) {
|
||||||
|
fn from(value: PaletteRect) -> Self {
|
||||||
|
(value.pos.x, value.pos.y, value.size.width, value.size.height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl std::default::Default for PaletteRect {
|
impl std::default::Default for PaletteRect {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
PaletteRect{pos: ImagePosition::default(), size: ImageSize::default()}
|
PaletteRect{pos: ImagePosition::default(), size: ImageSize::default()}
|
||||||
@@ -63,27 +135,30 @@ impl std::default::Default for PaletteRect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct Job {
|
pub enum Transparency {
|
||||||
pub name: String,
|
None,
|
||||||
pub file_path: PathBuf,
|
FirstColor,
|
||||||
pub image_pos: ImagePosition,
|
PSXSemi,
|
||||||
pub palette_rect: PaletteRect,
|
Both,
|
||||||
pub encoding: Encoding,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Job {
|
impl Transparency {
|
||||||
pub fn new(name: String, file_path: PathBuf, image_pos: (u16, u16), encoding: Encoding) -> Job {
|
pub fn from(selection: i32) -> Transparency {
|
||||||
Job{name, file_path, image_pos: ImagePosition{x: image_pos.0, y: image_pos.1}, palette_rect: PaletteRect::default(), encoding}
|
match selection {
|
||||||
|
0 => Transparency::None,
|
||||||
|
1 => Transparency::FirstColor,
|
||||||
|
2 => Transparency::PSXSemi,
|
||||||
|
3 => Transparency::Both,
|
||||||
|
_ => Transparency::None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
pub fn as_idx(&self) -> i32 {
|
||||||
pub struct Project {
|
match self {
|
||||||
pub jobs: Vec<Job>
|
Transparency::None => 0,
|
||||||
}
|
Transparency::FirstColor => 1,
|
||||||
|
Transparency::PSXSemi => 2,
|
||||||
impl Project {
|
Transparency::Both => 3,
|
||||||
pub fn new(jobs: Vec<Job>) -> Project {
|
}
|
||||||
Project{jobs}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,5 +1,6 @@
|
|||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
|
use pathdiff::diff_paths;
|
||||||
use std::{fs::File, path::PathBuf};
|
use std::{fs::File, path::PathBuf};
|
||||||
use slint::{Rgba8Pixel, SharedPixelBuffer};
|
use slint::{Rgba8Pixel, SharedPixelBuffer};
|
||||||
use tool_helper::Error;
|
use tool_helper::Error;
|
||||||
@@ -20,7 +21,7 @@ impl TIMInfo {
|
|||||||
if load_alpha {*iter.next()?} else {0xFF}))
|
if load_alpha {*iter.next()?} else {0xFF}))
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut reader = png::Decoder::new(File::open(path)?).read_info().or_else(|error| {Err(Error::from_error(error))})?;
|
let mut reader = png::Decoder::new(File::open(path).map_err(|error| Error::from_text(format!("Failed loading \"{}\" with {}", path.to_string_lossy().as_ref(), error)))?).read_info().or_else(|error| {Err(Error::from_error(error))})?;
|
||||||
let info = reader.info().clone();
|
let info = reader.info().clone();
|
||||||
|
|
||||||
let mut buffer = vec![0; reader.output_buffer_size()];
|
let mut buffer = vec![0; reader.output_buffer_size()];
|
||||||
@@ -132,6 +133,15 @@ impl TIMInfo {
|
|||||||
pub fn get_path(&self) -> std::path::PathBuf {
|
pub fn get_path(&self) -> std::path::PathBuf {
|
||||||
self.path.clone()
|
self.path.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_path_rel_to(&self, mut reference_path: std::path::PathBuf) -> Result<std::path::PathBuf, Error> {
|
||||||
|
let file_path = self.path.clone();
|
||||||
|
|
||||||
|
reference_path.pop();
|
||||||
|
diff_paths(&file_path, &reference_path).ok_or_else(|| {
|
||||||
|
Error::from_text(format!("Can not create relative path from {} to {}", file_path.to_string_lossy().as_ref(), reference_path.to_string_lossy().as_ref()))
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@@ -81,6 +81,7 @@ export component MainWindow inherits Window {
|
|||||||
|
|
||||||
public function change_to_main() {
|
public function change_to_main() {
|
||||||
tab_widget.current-index = 1;
|
tab_widget.current-index = 1;
|
||||||
|
main_tab.set_active();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clear_file_tab-current_selected_file() {
|
public function clear_file_tab-current_selected_file() {
|
||||||
|
@@ -45,9 +45,7 @@ component ProjectWidget inherits Rectangle {
|
|||||||
alignment: start;
|
alignment: start;
|
||||||
CheckBox {
|
CheckBox {
|
||||||
text: "Append elements from project to existing elements";
|
text: "Append elements from project to existing elements";
|
||||||
toggled() => {
|
checked <=> root.append_project_elements;
|
||||||
root.append_project_elements = self.checked;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HorizontalLayout {
|
HorizontalLayout {
|
||||||
@@ -84,7 +82,7 @@ component ProjectWidget inherits Rectangle {
|
|||||||
}
|
}
|
||||||
CheckBox {
|
CheckBox {
|
||||||
text: "Use relative path for files";
|
text: "Use relative path for files";
|
||||||
checked: root.use_rel_paths;
|
checked <=> root.use_rel_paths;
|
||||||
}
|
}
|
||||||
HorizontalLayout {
|
HorizontalLayout {
|
||||||
alignment: start;
|
alignment: start;
|
||||||
@@ -263,7 +261,7 @@ component ConvertImageWidget inherits Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
LineEdit {
|
LineEdit {
|
||||||
text: root.image_name;
|
text <=> root.image_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HorizontalLayout {
|
HorizontalLayout {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { VRAMArea } from "../vram-components.slint";
|
import { VRAMArea } from "../vram-components.slint";
|
||||||
import { Button, ComboBox, GroupBox, StandardListView, LineEdit, ScrollView, Slider } from "std-widgets.slint";
|
import { Button, CheckBox, ComboBox, GroupBox, StandardListView, LineEdit, ScrollView, Slider } from "std-widgets.slint";
|
||||||
|
|
||||||
struct VRAMImgData {
|
struct VRAMImgData {
|
||||||
full_image: image,
|
full_image: image,
|
||||||
@@ -10,6 +10,8 @@ struct VRAMInfo {
|
|||||||
x: int,
|
x: int,
|
||||||
y: int,
|
y: int,
|
||||||
encoding_str: string,
|
encoding_str: string,
|
||||||
|
use_compression: bool,
|
||||||
|
trans_setting: int,
|
||||||
palette_count: int,
|
palette_count: int,
|
||||||
is_palette: bool, // < Can we combine the palette into this, instead of having it separate?
|
is_palette: bool, // < Can we combine the palette into this, instead of having it separate?
|
||||||
}
|
}
|
||||||
@@ -31,6 +33,7 @@ export component MainTab inherits Rectangle {
|
|||||||
|
|
||||||
width: group.width + group.x*2;
|
width: group.width + group.x*2;
|
||||||
height: group.height + group.y*2 + 32px;
|
height: group.height + group.y*2 + 32px;
|
||||||
|
forward-focus: key_focus;
|
||||||
|
|
||||||
group := GroupBox {
|
group := GroupBox {
|
||||||
title: "VRAM Layout";
|
title: "VRAM Layout";
|
||||||
@@ -90,10 +93,20 @@ export component MainTab inherits Rectangle {
|
|||||||
if event.kind == PointerEventKind.down {
|
if event.kind == PointerEventKind.down {
|
||||||
cur_sel_x.text = parent.img_x;
|
cur_sel_x.text = parent.img_x;
|
||||||
cur_sel_y.text = parent.img_y;
|
cur_sel_y.text = parent.img_y;
|
||||||
|
cur_sel_width.text = "Width: " + vram_data.images.image.width;
|
||||||
|
cur_sel_height.text = "Height: " + vram_data.images.image.height;
|
||||||
cur_sel_img.source = vram_data.images.full_image;
|
cur_sel_img.source = vram_data.images.full_image;
|
||||||
encoding_text.encoding_str = vram_data.info.encoding_str;
|
encoding_text.encoding_str = vram_data.info.encoding_str;
|
||||||
cur_sel_img.visible = true;
|
cur_sel_img.visible = true;
|
||||||
|
|
||||||
|
if !vram-data.info.is_palette {
|
||||||
|
file_settings_box.set_active(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
file_settings_box.set_inactive();
|
||||||
|
}
|
||||||
|
|
||||||
vram_files_list.current-item = i;
|
vram_files_list.current-item = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,10 +132,20 @@ export component MainTab inherits Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update_viewport() {
|
function update_viewport() {
|
||||||
|
// If this value is positive, then the image moved so much to the right, that we do not use the full display area anymore
|
||||||
|
if self.viewport-x > 0 {
|
||||||
|
self.viewport-x = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if abs(self.viewport-x) + self.width > self.viewport-width {
|
if abs(self.viewport-x) + self.width > self.viewport-width {
|
||||||
self.viewport-x += (self.width + abs(self.viewport-x)) - self.viewport-width;
|
self.viewport-x += (self.width + abs(self.viewport-x)) - self.viewport-width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.viewport-y > 0 {
|
||||||
|
self.viewport-y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this value is positive, then the image moved so much down, that we do not use the full display area anymore
|
||||||
if abs(self.viewport-y) + self.height > self.viewport-height {
|
if abs(self.viewport-y) + self.height > self.viewport-height {
|
||||||
self.viewport-y += (self.height + abs(self.viewport-y)) - self.viewport-height;
|
self.viewport-y += (self.height + abs(self.viewport-y)) - self.viewport-height;
|
||||||
}
|
}
|
||||||
@@ -139,7 +162,7 @@ export component MainTab inherits Rectangle {
|
|||||||
}
|
}
|
||||||
slider := Slider {
|
slider := Slider {
|
||||||
minimum: 100.0;
|
minimum: 100.0;
|
||||||
maximum: 400.0;
|
maximum: 800.0;
|
||||||
step: 1.0;
|
step: 1.0;
|
||||||
value: 100.0;
|
value: 100.0;
|
||||||
|
|
||||||
@@ -164,9 +187,34 @@ export component MainTab inherits Rectangle {
|
|||||||
current-item-changed(current-item) => {
|
current-item-changed(current-item) => {
|
||||||
cur_sel_x.text = root.vram_data[current-item].info.x;
|
cur_sel_x.text = root.vram_data[current-item].info.x;
|
||||||
cur_sel_y.text = root.vram_data[current-item].info.y;
|
cur_sel_y.text = root.vram_data[current-item].info.y;
|
||||||
|
cur_sel_width.text = "Width: " + root.vram_data[current-item].images.image.width;
|
||||||
|
cur_sel_height.text = "Height: " + root.vram_data[current-item].images.image.height;
|
||||||
cur_sel_img.source = root.vram_data[current-item].images.full_image;
|
cur_sel_img.source = root.vram_data[current-item].images.full_image;
|
||||||
encoding_text.encoding_str = root.vram_data[current-item].info.encoding_str;
|
encoding_text.encoding_str = root.vram_data[current-item].info.encoding_str;
|
||||||
cur_sel_img.visible = true;
|
cur_sel_img.visible = true;
|
||||||
|
|
||||||
|
if !root.vram_data[current-item].info.is_palette {
|
||||||
|
file_settings_box.set_active(current-item);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
file_settings_box.set_inactive();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
item-pointer-event(item, event, position) => {
|
||||||
|
if event.button == PointerEventButton.right && event.kind == PointerEventKind.down {
|
||||||
|
main_view.viewport-x = -(root.vram_data[item].info.x + (root.vram_data[item].info.x/64))*root.scale*1px + (main_view.width/4);
|
||||||
|
main_view.viewport-y = -(root.vram_data[item].info.y + (root.vram_data[item].info.y/256))*root.scale*1px + (main_view.height/4);
|
||||||
|
main_view.update_viewport();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HorizontalLayout {
|
||||||
|
padding: 4px;
|
||||||
|
alignment: center;
|
||||||
|
Text {
|
||||||
|
text: "Right click to focus element on screen";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HorizontalLayout {
|
HorizontalLayout {
|
||||||
@@ -211,7 +259,7 @@ export component MainTab inherits Rectangle {
|
|||||||
cur_sel_x := LineEdit {
|
cur_sel_x := LineEdit {
|
||||||
input-type: number;
|
input-type: number;
|
||||||
text: 0;
|
text: 0;
|
||||||
width: 64pt;
|
width: 48pt;
|
||||||
|
|
||||||
accepted(text) => {
|
accepted(text) => {
|
||||||
if(vram_files_list.current-item != -1) {
|
if(vram_files_list.current-item != -1) {
|
||||||
@@ -220,6 +268,12 @@ export component MainTab inherits Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
VerticalLayout {
|
||||||
|
alignment: center;
|
||||||
|
cur_sel_width := Text {
|
||||||
|
text: "Width: 0";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
HorizontalLayout {
|
HorizontalLayout {
|
||||||
alignment: start;
|
alignment: start;
|
||||||
@@ -232,7 +286,7 @@ export component MainTab inherits Rectangle {
|
|||||||
cur_sel_y := LineEdit {
|
cur_sel_y := LineEdit {
|
||||||
input-type: number;
|
input-type: number;
|
||||||
text: 0;
|
text: 0;
|
||||||
width: 64pt;
|
width: 48pt;
|
||||||
|
|
||||||
accepted(text) => {
|
accepted(text) => {
|
||||||
if(vram_files_list.current-item != -1) {
|
if(vram_files_list.current-item != -1) {
|
||||||
@@ -241,6 +295,12 @@ export component MainTab inherits Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
VerticalLayout {
|
||||||
|
alignment: center;
|
||||||
|
cur_sel_height := Text {
|
||||||
|
text: "Height: 0";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
encoding_text := Text {
|
encoding_text := Text {
|
||||||
in-out property <string> encoding_str;
|
in-out property <string> encoding_str;
|
||||||
@@ -248,11 +308,59 @@ export component MainTab inherits Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
file_settings_box := GroupBox {
|
||||||
|
title: "File settings";
|
||||||
|
enabled: false;
|
||||||
|
|
||||||
|
VerticalLayout {
|
||||||
|
alignment: start;
|
||||||
|
lz4_check_box := CheckBox {
|
||||||
|
text: "Compress (lz4)";
|
||||||
|
enabled: file_settings_box.enabled;
|
||||||
|
|
||||||
|
toggled => {
|
||||||
|
if(vram_files_list.current-item != -1) {
|
||||||
|
root.vram_data[vram_files_list.current-item].info.use_compression = self.checked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FocusScope {
|
GroupBox {
|
||||||
|
title: "Transparency:";
|
||||||
|
enabled: file_settings_box.enabled;
|
||||||
|
VerticalLayout {
|
||||||
|
alignment: start;
|
||||||
|
trans_combo_box := ComboBox {
|
||||||
|
model: ["No transparency", "First color transparent", "PSX semi-transparency", "Both"];
|
||||||
|
enabled: file_settings_box.enabled;
|
||||||
|
|
||||||
|
selected(current-value) => {
|
||||||
|
if(vram_files_list.current-item != -1) {
|
||||||
|
root.vram_data[vram_files_list.current-item].info.trans_setting = self.current-index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_active(current-item: int) {
|
||||||
|
lz4_check_box.checked = root.vram_data[current-item].info.use_compression;
|
||||||
|
trans_combo_box.current-index = root.vram_data[current-item].info.trans_setting;
|
||||||
|
self.enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_inactive() {
|
||||||
|
lz4_check_box.checked = false;
|
||||||
|
trans_combo_box.current-index = 0;
|
||||||
|
self.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
key_focus := FocusScope {
|
||||||
key-pressed(event) => {
|
key-pressed(event) => {
|
||||||
if(vram_files_list.current-item != -1) {
|
if(vram_files_list.current-item != -1) {
|
||||||
if(event.text == Key.LeftArrow) {
|
if(event.text == Key.LeftArrow) {
|
||||||
@@ -289,4 +397,8 @@ export component MainTab inherits Rectangle {
|
|||||||
cur_sel_y.text = 0;
|
cur_sel_y.text = 0;
|
||||||
cur_sel_img.visible = false;
|
cur_sel_img.visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function set_active() {
|
||||||
|
key_focus.focus();
|
||||||
|
}
|
||||||
}
|
}
|
@@ -19,7 +19,7 @@
|
|||||||
{
|
{
|
||||||
"label": "make",
|
"label": "make",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "../../scripts/podman_jaby_engine.sh ${workspaceFolder}/..:src/FontWriter make ${input:target} BUILD_PROFILE=${input:build cfg}",
|
"command": "../../scripts/podman_jaby_engine.sh ${workspaceFolder}/..:src/FontWriter bear --output ${workspaceFolder}/../compile_commands.json -- make ${input:target} BUILD_PROFILE=${input:build cfg}",
|
||||||
"group": "build"
|
"group": "build"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user