Add scad_format namespace

This commit is contained in:
scawful
2024-04-14 15:49:57 -05:00
parent 5f7cd952d9
commit 11004cfa46
3 changed files with 50 additions and 19 deletions

View File

@@ -502,8 +502,8 @@ absl::Status GraphicsEditor::DrawCgxImport() {
[this]() { ImGui::SetClipboardText(cgx_file_path_); }); [this]() { ImGui::SetClipboardText(cgx_file_path_); });
gui::ButtonPipe("Load CGX Data", [this]() { gui::ButtonPipe("Load CGX Data", [this]() {
status_ = gfx::LoadCgx(current_bpp_, cgx_file_path_, cgx_data_, status_ = gfx::scad_format::LoadCgx(current_bpp_, cgx_file_path_, cgx_data_,
decoded_cgx_, extra_cgx_data_); decoded_cgx_, extra_cgx_data_);
cgx_bitmap_.InitializeFromData(0x80, 0x200, 8, decoded_cgx_); cgx_bitmap_.InitializeFromData(0x80, 0x200, 8, decoded_cgx_);
if (col_file_) { if (col_file_) {
@@ -533,11 +533,12 @@ absl::Status GraphicsEditor::DrawScrImport() {
InputInt("SCR Mod", &scr_mod_value_); InputInt("SCR Mod", &scr_mod_value_);
gui::ButtonPipe("Load Scr Data", [this]() { gui::ButtonPipe("Load Scr Data", [this]() {
status_ = gfx::LoadScr(scr_file_path_, scr_mod_value_, scr_data_); status_ =
gfx::scad_format::LoadScr(scr_file_path_, scr_mod_value_, scr_data_);
decoded_scr_data_.resize(0x100 * 0x100); decoded_scr_data_.resize(0x100 * 0x100);
status_ = gfx::DrawScrWithCgx(current_bpp_, scr_data_, decoded_scr_data_, status_ = gfx::scad_format::DrawScrWithCgx(current_bpp_, scr_data_,
decoded_cgx_); decoded_scr_data_, decoded_cgx_);
scr_bitmap_.InitializeFromData(0x100, 0x100, 8, decoded_scr_data_); scr_bitmap_.InitializeFromData(0x100, 0x100, 8, decoded_scr_data_);
if (scr_loaded_) { if (scr_loaded_) {
@@ -576,7 +577,7 @@ absl::Status GraphicsEditor::DrawPaletteControls() {
col_file_palette_ = gfx::SnesPalette(col_data_); col_file_palette_ = gfx::SnesPalette(col_data_);
// gigaleak dev format based code // gigaleak dev format based code
decoded_col_ = gfx::DecodeColFile(col_file_path_); decoded_col_ = gfx::scad_format::DecodeColFile(col_file_path_);
col_file_ = true; col_file_ = true;
is_open_ = true; is_open_ = true;
}); });

View File

@@ -15,6 +15,7 @@
namespace yaze { namespace yaze {
namespace app { namespace app {
namespace gfx { namespace gfx {
namespace scad_format {
void FindMetastamp() { void FindMetastamp() {
int matching_position = -1; int matching_position = -1;
@@ -276,6 +277,7 @@ absl::Status DecodeObjFile(
return absl::OkStatus(); return absl::OkStatus();
} }
} // namespace scad_format
} // namespace gfx } // namespace gfx
} // namespace app } // namespace app
} // namespace yaze } // namespace yaze

View File

@@ -22,18 +22,27 @@ namespace yaze {
namespace app { namespace app {
namespace gfx { namespace gfx {
// キャラクタ(.SCH)ファイル /**
// ヘッダー情報 * @namespace yaze::app::gfx::scad_format
// アドレス 説明 * @brief Loading from prototype SCAD format
// 00000 - 00003 ファイルタイプ "SCH" */
// 00004 - 00008 ビットモード "?BIT" namespace scad_format {
// 00009 - 00013 バージョンナンバー "Ver-????\n"
// 00014 - 00017 ヘッダーサイズ /**
// 00018 - 0001B ハード名 "SFC" or "CGB" or "GB" * @brief Cgx file header
// 0001C - 0001C BG/OBJフラグ(AGBの時) * キャラクタ(.SCH)ファイル
// 0001D - 0001D Color Pallette Number * ヘッダー情報
// 0001D - 000FF 予約 * アドレス 説明
// 00100 - 001FF Color Path * 00000 - 00003 ファイルタイプ "SCH"
* 00004 - 00008 ビットモード "?BIT"
* 00009 - 00013 バージョンナンバー "Ver-????\n"
* 00014 - 00017 ヘッダーサイズ
* 00018 - 0001B ハード名 "SFC" or "CGB" or "GB"
* 0001C - 0001C BG/OBJフラグ(AGBの時)
* 0001D - 0001D Color Pallette Number
* 0001D - 000FF 予約
* 00100 - 001FF Color Path
*/
struct CgxHeader { struct CgxHeader {
char file_type[4]; char file_type[4];
char bit_mode[5]; char bit_mode[5];
@@ -49,28 +58,47 @@ struct CgxHeader {
constexpr uint16_t kMatchedBytes[] = {0x4E, 0x41, 0x4B, 0x31, 0x39, 0x38, 0x39}; constexpr uint16_t kMatchedBytes[] = {0x4E, 0x41, 0x4B, 0x31, 0x39, 0x38, 0x39};
constexpr uint16_t kOffsetFromMatchedBytesEnd = 0x1D; constexpr uint16_t kOffsetFromMatchedBytesEnd = 0x1D;
/**
* @brief Find metastamp in CGX file
*/
void FindMetastamp(); void FindMetastamp();
/**
* @brief Load Scr file (screen data)
*/
absl::Status LoadScr(std::string_view filename, uint8_t input_value, absl::Status LoadScr(std::string_view filename, uint8_t input_value,
std::vector<uint8_t>& map_data); std::vector<uint8_t>& map_data);
/**
* @brief Load Cgx file (graphical content)
*/
absl::Status LoadCgx(uint8_t bpp, std::string_view filename, absl::Status LoadCgx(uint8_t bpp, std::string_view filename,
std::vector<uint8_t>& cgx_data, std::vector<uint8_t>& cgx_data,
std::vector<uint8_t>& cgx_loaded, std::vector<uint8_t>& cgx_loaded,
std::vector<uint8_t>& cgx_header); std::vector<uint8_t>& cgx_header);
/**
* @brief Draw screen tilemap with graphical data
*/
absl::Status DrawScrWithCgx(uint8_t bpp, std::vector<uint8_t>& map_bitmap_data, absl::Status DrawScrWithCgx(uint8_t bpp, std::vector<uint8_t>& map_bitmap_data,
std::vector<uint8_t>& map_data, std::vector<uint8_t>& map_data,
std::vector<uint8_t>& cgx_loaded); std::vector<uint8_t>& cgx_loaded);
/**
* @brief Decode color file
*/
std::vector<SDL_Color> DecodeColFile(const std::string_view filename); std::vector<SDL_Color> DecodeColFile(const std::string_view filename);
/**
* @brief Decode obj file
*/
absl::Status DecodeObjFile( absl::Status DecodeObjFile(
std::string_view filename, std::vector<uint8_t>& obj_data, std::string_view filename, std::vector<uint8_t>& obj_data,
std::vector<uint8_t> actual_obj_data, std::vector<uint8_t> actual_obj_data,
std::unordered_map<std::string, std::vector<uint8_t>> decoded_obj, std::unordered_map<std::string, std::vector<uint8_t>> decoded_obj,
std::vector<uint8_t>& decoded_extra_obj, int& obj_loaded); std::vector<uint8_t>& decoded_extra_obj, int& obj_loaded);
} // namespace scad_format
} // namespace gfx } // namespace gfx
} // namespace app } // namespace app
} // namespace yaze } // namespace yaze