From 586b1e812423dbd26c643e8a535d6e55ad54fc87 Mon Sep 17 00:00:00 2001 From: jaby Date: Sun, 29 Dec 2024 21:57:38 +0100 Subject: [PATCH] Support for loading TIM --- .../PoolBox/application/include/asset_mgr.hpp | 2 +- .../application/src/Overlay/Overlays.hpp | 2 + .../Overlay/ScreenCenter/screen_center.cpp | 9 ++ .../ScreenCenter/screen_center_assets.cpp | 17 +++ .../PoolBox/application/src/asset_mgr.cpp | 2 +- examples/PoolBox/assets/IMG_6921.png | 3 + examples/PoolBox/assets/Makefile | 11 +- examples/PoolBox/iso/Config.xml | 3 +- include/PSX/File/Processor/file_processor.hpp | 4 +- include/PSX/File/cd_file_types.hpp | 6 + include/PSX/File/file_types.hpp | 8 ++ .../GPU/Primitives/primitive_poly_types.hpp | 6 +- include/PSX/GPU/make_gpu_primitives.hpp | 2 +- .../Processor/TIM/simpletim_processor.cpp | 73 +++++++++++ .../src/File/Processor/TIM/tim_helper.cpp | 67 +++++++++++ .../src/File/Processor/TIM/tim_helper.hpp | 26 ++++ .../src/File/Processor/TIM/tim_processor.cpp | 54 +++++++++ .../src/File/Processor/cd_file_processor.cpp | 3 + .../src/File/Processor/tim_processor.cpp | 113 ------------------ 19 files changed, 286 insertions(+), 125 deletions(-) create mode 100644 examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center_assets.cpp create mode 100644 examples/PoolBox/assets/IMG_6921.png create mode 100644 src/Library/src/File/Processor/TIM/simpletim_processor.cpp create mode 100644 src/Library/src/File/Processor/TIM/tim_helper.cpp create mode 100644 src/Library/src/File/Processor/TIM/tim_helper.hpp create mode 100644 src/Library/src/File/Processor/TIM/tim_processor.cpp delete mode 100644 src/Library/src/File/Processor/tim_processor.cpp diff --git a/examples/PoolBox/application/include/asset_mgr.hpp b/examples/PoolBox/application/include/asset_mgr.hpp index ff6c4f55..4dd3165d 100644 --- a/examples/PoolBox/application/include/asset_mgr.hpp +++ b/examples/PoolBox/application/include/asset_mgr.hpp @@ -10,7 +10,7 @@ namespace Assets { GPU::SizeI16 size; }; - 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) diff --git a/examples/PoolBox/application/src/Overlay/Overlays.hpp b/examples/PoolBox/application/src/Overlay/Overlays.hpp index d4dcd7d7..0a7f1641 100644 --- a/examples/PoolBox/application/src/Overlay/Overlays.hpp +++ b/examples/PoolBox/application/src/Overlay/Overlays.hpp @@ -32,5 +32,7 @@ namespace FontCycler { } namespace ScreenCenter { + extern const volatile JabyEngine::AutoLBAEntry lba[]; + extern JabyEngine::CDFile Assets[1]; void main(); } \ No newline at end of file diff --git a/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp b/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp index 186a58d0..bad6be4d 100644 --- a/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp +++ b/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp @@ -2,6 +2,7 @@ #include "include/frame.hpp" #include #include +#include #include #include @@ -76,6 +77,13 @@ namespace ScreenCenter { Formular{.name = PSYQ::Name, .function = PSYQ::set_offset} }; + static constexpr const auto background_img = Make::POLY_FT4( + Make::AreaI16(Make::PositionI16((GPU::Display::Width - 256)/2, (GPU::Display::Height - 240)/2), Make::SizeI16(256, 240)), + Make::PageOffset(0, 0), + Make::TPage(Make::PositionU16(384, 256), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), + Make::PageClut(Make::PositionU16(384, 255)) + ); + static auto frame = Frame::create(); static ButtonPulser button_pulse[4]; @@ -182,6 +190,7 @@ namespace ScreenCenter { } static void render() { + GPU::render(background_img); frame.render(); Shared::back_menu.render(); } diff --git a/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center_assets.cpp b/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center_assets.cpp new file mode 100644 index 00000000..6d1670bb --- /dev/null +++ b/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center_assets.cpp @@ -0,0 +1,17 @@ +#include +#include + +namespace ScreenCenter { + using namespace JabyEngine; + + enum LBA { + __jabyengine_start_lba_request + __jabyengine_request_lba_for(BG_IMAGE, "ASSETS/SAND.TIM"), + __jabyengine_end_lba_request + }; + __declare_lba_header(LBA); + + CDFile Assets[1] = { + CDFileBuilder::sony_tim(LBA::BG_IMAGE, TIM::create()) + }; +} \ No newline at end of file diff --git a/examples/PoolBox/application/src/asset_mgr.cpp b/examples/PoolBox/application/src/asset_mgr.cpp index 8adc3dc9..b5b8f337 100644 --- a/examples/PoolBox/application/src/asset_mgr.cpp +++ b/examples/PoolBox/application/src/asset_mgr.cpp @@ -121,7 +121,7 @@ namespace Assets { } void load_screen_center() { - load(CDFileBuilder::overlay(LBA::SCREEN_CENT_OVL, &__screen_center_start)); + load(CDFileBuilder::overlay(LBA::SCREEN_CENT_OVL, &__screen_center_start), ScreenCenter::lba, ScreenCenter::Assets); } } diff --git a/examples/PoolBox/assets/IMG_6921.png b/examples/PoolBox/assets/IMG_6921.png new file mode 100644 index 00000000..6e7b9eaf --- /dev/null +++ b/examples/PoolBox/assets/IMG_6921.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:88baf322cd713884e15a7b346f2bd193d25e439a7ef3ca4cbe29c9037da4f45d +size 26397 diff --git a/examples/PoolBox/assets/Makefile b/examples/PoolBox/assets/Makefile index a1efdf0e..52172fc2 100644 --- a/examples/PoolBox/assets/Makefile +++ b/examples/PoolBox/assets/Makefile @@ -1,10 +1,6 @@ include $(JABY_ENGINE_DIR)/mkfile/common/ExportPath.mk include $(JABY_ENGINE_DIR)/mkfile/common/RebuildTarget.mk -define wuff - $1_FLAGS = $2 -endef - OUTPUT_DIR = bin CLUT_4_COLOR_TRANS_FLAGS = simple-tim clut4 --color-trans @@ -38,6 +34,9 @@ JabyStar_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS) INPUT += $(OUTPUT_DIR)/JabyTails.img JabyTails_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS) +INPUT += $(OUTPUT_DIR)/IMG_6921.tim +IMG_6921_TIM_FLAGS = tim clut4 --clut-pos {384,255} --tex-pos {384,256} + $(OUTPUT_DIR)/fox.xa: audio/temp/fox.wav @mkdir -p $(OUTPUT_DIR) psxfileconv $< -o $@ xa @@ -54,6 +53,10 @@ $(OUTPUT_DIR)/%.img: %.png @mkdir -p $(OUTPUT_DIR) psxfileconv --lz4 $< -o $@ $($*_FLAGS) +$(OUTPUT_DIR)/%.tim: %.png + @mkdir -p $(OUTPUT_DIR) + psxfileconv $< -o $@ $($*_TIM_FLAGS) + all: $(INPUT) clean: diff --git a/examples/PoolBox/iso/Config.xml b/examples/PoolBox/iso/Config.xml index 2c795919..f1ad9b65 100644 --- a/examples/PoolBox/iso/Config.xml +++ b/examples/PoolBox/iso/Config.xml @@ -22,7 +22,7 @@ ../application/bin/%PSX_TV_FORMAT%/PSX-release/Overlay.gpu_tests ../application/bin/%PSX_TV_FORMAT%/PSX-release/Overlay.gte_tests ../application/bin/%PSX_TV_FORMAT%/PSX-release/Overlay.font_cycler - ../application/bin/%PSX_TV_FORMAT%/PSX-release/Overlay.screen_center + ../application/bin/%PSX_TV_FORMAT%/PSX-release/Overlay.screen_center