-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FF8: World chara.one textures replacement (#615)
- Loading branch information
Showing
7 changed files
with
181 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/****************************************************************************/ | ||
// Copyright (C) 2009 Aali132 // | ||
// Copyright (C) 2018 quantumpencil // | ||
// Copyright (C) 2018 Maxime Bacoux // | ||
// Copyright (C) 2020 Chris Rizzitello // | ||
// Copyright (C) 2020 John Pritchard // | ||
// Copyright (C) 2023 myst6re // | ||
// Copyright (C) 2023 Julian Xhokaxhiu // | ||
// Copyright (C) 2023 Cosmos // | ||
// Copyright (C) 2023 Tang-Tang Zhou // | ||
// // | ||
// This file is part of FFNx // | ||
// // | ||
// FFNx is free software: you can redistribute it and/or modify // | ||
// it under the terms of the GNU General Public License as published by // | ||
// the Free Software Foundation, either version 3 of the License // | ||
// // | ||
// FFNx is distributed in the hope that it will be useful, // | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of // | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // | ||
// GNU General Public License for more details. // | ||
/****************************************************************************/ | ||
|
||
#include "chara_one.h" | ||
#include "../../image/tim.h" | ||
#include "../../saveload.h" | ||
#include "../../log.h" | ||
|
||
std::vector<CharaOneModelTextures> ff8_world_chara_one_parse_models(const uint8_t *chara_one_data, size_t size) | ||
{ | ||
std::vector<CharaOneModelTextures> models; | ||
|
||
const uint8_t *cur = chara_one_data + size, *min_cur = chara_one_data + 4; | ||
|
||
// The header is at the end of the file | ||
uint32_t count; | ||
cur -= 4; | ||
memcpy(&count, cur, 4); | ||
|
||
for (uint32_t i = 0; i < count && cur >= min_cur; ++i) { | ||
CharaOneModelTextures textures; | ||
|
||
uint32_t tim_offset; | ||
|
||
while (cur >= min_cur) { | ||
cur -= 4; | ||
memcpy(&tim_offset, cur, 4); | ||
|
||
if (tim_offset == 0xFFFFFFFF) { | ||
break; | ||
} | ||
|
||
textures.push_back(tim_offset & 0xFFFFFFF); | ||
} | ||
|
||
models.push_back(textures); | ||
|
||
cur -= 4; // Skipping offset to the model data | ||
} | ||
|
||
return models; | ||
} | ||
|
||
bool ff8_world_chara_one_model_save_textures(const std::vector<CharaOneModelTextures> &models, const uint8_t *chara_one_model_data, const char *dirname) | ||
{ | ||
if (trace_all || trace_vram) ffnx_trace("%s: %s\n", __func__, dirname); | ||
|
||
int model_id = 0; | ||
for (const CharaOneModelTextures &textures: models) { | ||
int texture_id = 0; | ||
for (uint32_t texture_pointer: textures) { | ||
char name[MAX_PATH] = {}; | ||
snprintf(name, sizeof(name), "%s/model%d-%d", dirname, model_id, texture_id); | ||
Tim tim = Tim::fromTimData(chara_one_model_data + texture_pointer); | ||
|
||
if (!tim.save(name, 0, 0, true)) { | ||
return false; | ||
} | ||
++texture_id; | ||
} | ||
++model_id; | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/****************************************************************************/ | ||
// Copyright (C) 2009 Aali132 // | ||
// Copyright (C) 2018 quantumpencil // | ||
// Copyright (C) 2018 Maxime Bacoux // | ||
// Copyright (C) 2020 Chris Rizzitello // | ||
// Copyright (C) 2020 John Pritchard // | ||
// Copyright (C) 2023 myst6re // | ||
// Copyright (C) 2023 Julian Xhokaxhiu // | ||
// Copyright (C) 2023 Cosmos // | ||
// Copyright (C) 2023 Tang-Tang Zhou // | ||
// // | ||
// This file is part of FFNx // | ||
// // | ||
// FFNx is free software: you can redistribute it and/or modify // | ||
// it under the terms of the GNU General Public License as published by // | ||
// the Free Software Foundation, either version 3 of the License // | ||
// // | ||
// FFNx is distributed in the hope that it will be useful, // | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of // | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // | ||
// GNU General Public License for more details. // | ||
/****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include "../../common.h" | ||
|
||
#include <vector> | ||
|
||
typedef std::vector<uint32_t> CharaOneModelTextures; | ||
|
||
std::vector<CharaOneModelTextures> ff8_world_chara_one_parse_models(const uint8_t *chara_one_data, size_t size); | ||
bool ff8_world_chara_one_model_save_textures(const std::vector<CharaOneModelTextures> &models, const uint8_t *chara_one_model_data, const char *dirname); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters