summaryrefslogtreecommitdiff
path: root/ZAPD/ZFile.cpp
AgeCommit message (Collapse)Author
2021-05-08Add const to most functions that need it and remove all "using namespace ↵louist103
std" (#132) * started on basic type errors * Done. For now * remove libgfxd binary * const * no more namespace std * revert alloca * re add a few missing consts
2021-05-07Change image library to `libpng` and improve how palettized textures are ↵Anghelo Carvajal
extracted (#133) * trying to change to libpng * It works again! * move the libpng abstraction to another file * GetBytesPerPixel * I'm dumb * fix warnings and remove dead code * Fix CRC being called multiples times and clean up code * textureDataRaw * code clean * Optimizations and removal of redundant data moves * ups * run format * use fs::path more * i'm dumb again * Add a Readme * remove texDeclarations * handle tluts better * vtx change and set segment file * small changes * Fix ZAPD ignoring textures declared in a scene in the XML * small cleanup before tluts * paletted images are broken * kinda works for automatic textures * fix automatic ci * TEXTURE_DEBUG * Remove extra `-j` * Fix extraction of ci4 * Finally palettes OK * ups * Move textures map to ZFile * Fix intersection warnings * Add `TlutOffset` attribute * Move Tlut declaration to a later step * Hopefully the last cleanup of this branch * Run format * Always calc hash * run format * Delete stb * fix merge issues * run format
2021-05-06Refactor: Removed `relPath` since it is no longer used. (#136)Nicholas Estelami
* Refactor: Removed relPath since it is no longer used. * Removed remaining references Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
2021-05-06Add a `format` rule to Makefile (#134)Anghelo Carvajal
* Add format rule to makefile * run format
2021-05-05Background array declarations now use string literal (#128)Nicholas Estelami
* Initial implementation * Fixed typo * Minor tweaks * Fixed merge issues Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
2021-04-28Use OutputFormatter for every C and H file, to improve the generated output ↵Anghelo Carvajal
(#122) * Small changes in collision * Use outputformatter to write C files * Outputformatter for .h files * Use more fs::path * Use gfxd_udata_set and gfxd_udata_get instead of an instance * Fix merge issues and warnings * run format
2021-04-24Texture Pool Fully Implemented (#123)Nicholas Estelami
* Texture Pool Up and Running * Cleaned up code * Removed redundant GetRawData() overrides. * Fixed up merge issues. Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
2021-04-24Fix most -Wall warnings (#115)louist103
* started on basic type errors * Done. For now * remove libgfxd binary * Most warnings fixed * Fix conflicts and new warnings * Makefile * Sig * Clang format * destructor * Add a bunch of destructors * clear the scalars vector after freeing the elements * PR fixes (Anghelo Alf) * Fix most clang -Wall warnings
2021-04-22Add a few errors checks (#119)Anghelo Carvajal
* Check for repeated names, outnames and offsets Signed-off-by: angie <angheloalf95@gmail.com> * Check for File inside File Signed-off-by: angie <angheloalf95@gmail.com> * Error if a ZResource node has a child Signed-off-by: angie <angheloalf95@gmail.com> * Error if an invalid ZResource name is included in the XML Signed-off-by: angie <angheloalf95@gmail.com> * error when a ZResource is not in a ZFile Signed-off-by: angie <angheloalf95@gmail.com> * ups Signed-off-by: angie <angheloalf95@gmail.com> * Add error if unknown element is found and other fixes * Run format
2021-04-22Warn unaccounted and name small zero-only unaccounted as padding (#118)Anghelo Carvajal
* warn unaccounted Signed-off-by: Angie <angheloalf95@gmail.com> * count the unaccounteds at the end of each file Signed-off-by: Angie <angheloalf95@gmail.com> * print the internal filename Signed-off-by: Angie <angheloalf95@gmail.com> * fix merge problem * Add `-wu` flag * Remove redundant code * Add `possiblePadding` detection * run format
2021-04-15Rename "Prerender" to "Background", properly extract PolygonType1 multi ↵Anghelo Carvajal
format and change some structs used. (#107) * Extract BgImage Signed-off-by: angie <angheloalf95@gmail.com> * improve the output a bit Signed-off-by: angie <angheloalf95@gmail.com> * extract backgrounds for multipoly Signed-off-by: angie <angheloalf95@gmail.com> * Extract the dlists of PolygonDlist Signed-off-by: angie <angheloalf95@gmail.com> * commands in the next line Signed-off-by: angie <angheloalf95@gmail.com> * Move a lot of repeated code into a class Signed-off-by: angie <angheloalf95@gmail.com> * Use PolygonDlist instead of MeshEntry0 Signed-off-by: angie <angheloalf95@gmail.com> * Rename prerender to background Signed-off-by: angie <angheloalf95@gmail.com> * format Signed-off-by: angie <angheloalf95@gmail.com> * last cleanup Signed-off-by: angie <angheloalf95@gmail.com> * Handle jpg padding Signed-off-by: angie <angheloalf95@gmail.com> * Add a few checks and warnings for jpeg validity Signed-off-by: Angie <angheloalf95@gmail.com> * typo Signed-off-by: Angie <angheloalf95@gmail.com> * fix merge error Signed-off-by: angie <angheloalf95@gmail.com> * Fix background extraction that somehow was broken Signed-off-by: angie <angheloalf95@gmail.com> * re-add the trailling line feed Signed-off-by: angie <angheloalf95@gmail.com> * add trailing line feed again Signed-off-by: angie <angheloalf95@gmail.com> * fix an already fixed warning Signed-off-by: angie <angheloalf95@gmail.com> * fix crash when no config file is provided * run format
2021-04-13Refactoring and various features added (#108)Nicholas Estelami
* ZAPD prints out git hash * Refactor: ZResource constructor sets parent always. ZOverlay also no longer a ZResource, since it did not make much sense. * Organized ZResource a bit * A number of bug fixes, cleanup, and feature improvements. * Prepping for legacy dlist disasm * Fixed some merging issues. Fixed compilation issues with MSVC. Added in proper support for legacy display list disassembler. Refactored parts of ZFile. * Merge with upstream * Finished ZFile refactor, and other tidying. * Fixed up merge issues * Minor cleanup * Got rid of libgfxd_win.a * Fixed matching issue * Fixed up a few bugs * Fixed issue with exceptions * Fixed up merge issues with ZPrerender, along with cleaning up some code * Additional cleanup * Fixed merge issues with ZMtx and fixed a bug with ZDisplayList * Fixes based on PR feedback * run clang-format (#7) Signed-off-by: angie <angheloalf95@gmail.com> * Fixed merge issues with Roz's PR * Misc fixes * Fixed MM bug, removed redundant file. * Removed some commented out code Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com> Co-authored-by: Anghelo Carvajal <anghelo.carvajal.14@sansano.usm.cl>
2021-04-02Add Mtx extraction (#105)Anghelo Carvajal
* ZMtx resource Signed-off-by: Angie <angheloalf95@gmail.com> * remove extra braces Signed-off-by: Angie <angheloalf95@gmail.com> * make dlist extracts mtx Signed-off-by: Angie <angheloalf95@gmail.com> * run format Signed-off-by: angie <angheloalf95@gmail.com>
2021-04-01Add prerenders extraction (#106)Anghelo Carvajal
* extracting prerenders Signed-off-by: angie <angheloalf95@gmail.com> * not tested Signed-off-by: angie <angheloalf95@gmail.com> * recompiling into c code Signed-off-by: Angie <angheloalf95@gmail.com> * Extract prerenders automatically Signed-off-by: Angie <angheloalf95@gmail.com> * Extract PolygonDlist Signed-off-by: Angie <angheloalf95@gmail.com> * trying to extract dlists contained by PolygonDlist Signed-off-by: Angie <angheloalf95@gmail.com> * Rename ZBackground to ZPrerender Signed-off-by: angie <angheloalf95@gmail.com> * forgot to rename this too Signed-off-by: angie <angheloalf95@gmail.com> * format Signed-off-by: angie <angheloalf95@gmail.com> * Change jfif to jpg Signed-off-by: angie <angheloalf95@gmail.com>
2021-04-01Unmangle backtrace (#100)Anghelo Carvajal
* its kinda functional Signed-off-by: angie <angheloalf95@gmail.com> * Looks nicer now Signed-off-by: angie <angheloalf95@gmail.com> * cleanup the makefile Signed-off-by: angie <angheloalf95@gmail.com> * Fix small issues with error handling Signed-off-by: angie <angheloalf95@gmail.com> * fix order of dependencies of main.cpp in makefile Signed-off-by: Angie <angheloalf95@gmail.com> * Add varname to the intersection warning Signed-off-by: angie <angheloalf95@gmail.com> * run clang-format Signed-off-by: angie <angheloalf95@gmail.com> * Don't print the backtrace two times Signed-off-by: angie <angheloalf95@gmail.com>
2021-04-01Add more warnings for textures (#104)louist103
* started on basic type errors * Done. For now * remove libgfxd binary * added errors if Height or width is not spelled correctly * change the error message and fix reverted warning fixes
2021-03-20Add a clang-format config and reformat all source files (#63)Léo Lam
* build: Add genbuildinfo as a dependency for ZAPD object files * Add a clang-format config and reformat all source files The existing code style is mostly preserved; this just makes formatting more consistent and prevents lines from getting too long. * Fix missing includes
2021-03-20Final Warning pass (#99)louist103
* started on basic type errors * Done. For now * remove libgfxd binary * Fix Clang Warnings * Fix2 * Fix rollback of #92 and missed warning in ZCutscene.cpp * ? * add stdexcept to ZResource * Fix make clean * PR fixes * Fix make file stuff * Remove many more errors and remove -Wall * Turns out Globals was used * Final pass Co-authored-by: Fig02 <fig02srl@gmail.com>
2021-03-20std::map is already a sorted container, no need to sort it (#88)gamestabled
* std::map is already a sorted container, no need to sort it * another sort removed Co-authored-by: gamestabled <chandler2016@yahoo.com> Co-authored-by: Fig02 <fig02srl@gmail.com>
2021-03-19Fix all warnings output by Clang++ (#94)louist103
* started on basic type errors * Done. For now * remove libgfxd binary * Fix Clang Warnings * Fix2 * Fix rollback of #92 and missed warning in ZCutscene.cpp * ? * add stdexcept to ZResource * Fix make clean * PR fixes * Fix make file stuff * Remove many more errors and remove -Wall * Turns out Globals was used Co-authored-by: Fig02 <fig02srl@gmail.com>
2021-03-19Add support to `SkelCurve` and its animation type (#98)Anghelo Carvajal
* Type="Curve" Signed-off-by: angie <angheloalf95@gmail.com> * Starting to extract CurveLimbs Signed-off-by: angie <angheloalf95@gmail.com> * Fix a few oversights Signed-off-by: angie <angheloalf95@gmail.com> * Reading the TransformUpdateIndex Signed-off-by: angie <angheloalf95@gmail.com> * Export the body of the ZCurveAnimation Signed-off-by: angie <angheloalf95@gmail.com> * Add TransformData Signed-off-by: angie <angheloalf95@gmail.com> * Extracting one element of the arrays Signed-off-by: angie <angheloalf95@gmail.com> * Extract the whole refIndexArr Signed-off-by: Angie <angheloalf95@gmail.com> * fix a typo Signed-off-by: Angie <angheloalf95@gmail.com> * Extract the whole transformData array Signed-off-by: Angie <angheloalf95@gmail.com> * Extract copyValues array Signed-off-by: Angie <angheloalf95@gmail.com>
2021-03-17Add new resource ZSymbol (#92)Anghelo Carvajal
* ZSymbol Signed-off-by: Angie <angheloalf95@gmail.com> * Add array support to ZSymbol Signed-off-by: Angie <angheloalf95@gmail.com> * Export symbol as array Signed-off-by: Angie <angheloalf95@gmail.com> * Final cleanup Signed-off-by: Angie <angheloalf95@gmail.com> * Ups, forgot the offset in a constructor Signed-off-by: Angie <angheloalf95@gmail.com>
2021-03-12Add horses support (#89)Anghelo Carvajal
* Factor common code as a function Signed-off-by: angie <angheloalf95@gmail.com> * Add some missing methods and change limbs from structs to classes Signed-off-by: angie <angheloalf95@gmail.com> * ZSkeleton::GetRawDataSize Signed-off-by: angie <angheloalf95@gmail.com> * add segAddress and fileAddress in ZLimbStandard Signed-off-by: angie <angheloalf95@gmail.com> * Move code to ZLimbStandard::GetSourceOutputCode Signed-off-by: angie <angheloalf95@gmail.com> * Move code to ZLimbLOD::GetSourceOutputCode and a few fixes Signed-off-by: angie <angheloalf95@gmail.com> * Add missing & and reestructure the code a bit. Signed-off-by: angie <angheloalf95@gmail.com> * Fix merge issues Signed-off-by: angie <angheloalf95@gmail.com> * Move stuff from FromRawData to constructors Signed-off-by: angie <angheloalf95@gmail.com> * Merge both Limb classes and refactor Signed-off-by: angie <angheloalf95@gmail.com> * Initial SkinLimb support Signed-off-by: angie <angheloalf95@gmail.com> * Extract SkinLimb type 11 dlist Signed-off-by: Angie <angheloalf95@gmail.com> * Extracting the first struct of SkinLimb Signed-off-by: Angie <angheloalf95@gmail.com> * Exporting the dlist of SkinLimb breaks stuff Signed-off-by: Angie <angheloalf95@gmail.com> * Add another struct of skinlimb Signed-off-by: Angie <angheloalf95@gmail.com> * Parse Struct_800A598C_2 Signed-off-by: Angie <angheloalf95@gmail.com> * Parse Struct_800A57C0 Signed-off-by: Angie <angheloalf95@gmail.com> * Extract sublimbs as array Signed-off-by: Angie <angheloalf95@gmail.com> * Export the full array of Struct_800A5E28 Signed-off-by: Angie <angheloalf95@gmail.com> * A few stylistic changes Signed-off-by: angie <angheloalf95@gmail.com> * a bit of cleanup Signed-off-by: angie <angheloalf95@gmail.com> * ZSkeleton::ParseXML Signed-off-by: angie <angheloalf95@gmail.com> * ZSkeleton::ParseRawData() Signed-off-by: Angie <angheloalf95@gmail.com> * Move the code around a bit Signed-off-by: Angie <angheloalf95@gmail.com> * Remove ZSkeletonType::Skin Signed-off-by: Angie <angheloalf95@gmail.com> * class Struct_800A57C0 Signed-off-by: Angie <angheloalf95@gmail.com> * class Struct_800A598C_2 Signed-off-by: Angie <angheloalf95@gmail.com> * class Struct_800A598C and class Struct_800A5E28 Signed-off-by: angie <angheloalf95@gmail.com> * MakeInternalDeclarations Signed-off-by: angie <angheloalf95@gmail.com> * Move limbs to ZLimb Signed-off-by: Angie <angheloalf95@gmail.com> * A bit of cleanup Signed-off-by: angie <angheloalf95@gmail.com> * Works, but something is wrong... Signed-off-by: angie <angheloalf95@gmail.com> * Final cleanup Signed-off-by: angie <angheloalf95@gmail.com> * I hope this is the final cleanup Signed-off-by: angie <angheloalf95@gmail.com>
2021-03-12A few bugfixes (#87)Anghelo Carvajal
* remove extra %i in ZCutscene Signed-off-by: angie <angheloalf95@gmail.com> * Don't extract vertices from a unknown segment. Signed-off-by: Angie <angheloalf95@gmail.com> * Fix SurfaceType in CollisionHeader Signed-off-by: Angie <angheloalf95@gmail.com> * Fix merge issue Signed-off-by: angie <angheloalf95@gmail.com>
2021-01-23WIP F3DEX Support, Bug Fixes, Game definable in XML (#75)Nicholas Estelami
* WIP F3DEX support * Additional work on F3DEX support, fixed bug with actorlist * Fixed crash bug * Adds ZFile attribute "Game" to be able to change the game mode for ZAPD. * Additional changes to support F3DEX * Fixed bug with cullDL and with dlist type selection * F3DEX Opcode fix * Fixed up a few bugs * Cleaned up some code and fixed bug with directory creation. * ZAPD now supports correct bitpacking for gsSPSetOtherMode on F3DEX * Fixes syntax error in ZDisplayList.h * Updates Actor and Object Lists * Updated actor and object list * G_MTX updated for F3DEX * Fixed bug with transition actor list * Updated G_Texture for F3DEX * SW97 maps: Removes actor 0x22, and shifts actors 0x23 and above down by one to match retail enum. * Fixes issue in reuse of actorCount variable in SetActorList::GetActorListArraySize. Co-authored-by: Kenix3
2021-01-19Added in support for ZArray (WIP) and ZVtx. Also cleaned up some of the ↵Nicholas Estelami
virtual functions. (#73)
2021-01-19Always print an error if there is a bad "tag" (#72)louist103
* started on basic type errors * Done. For now * Push2
2021-01-15Various bug fixes.Nicholas Estelami
- Fixed bug with `gsDPSetTextureImage` when texture is in 0x80 "segment" (#70) - Fixed bug with RangeStart and RangeEnd not always working properly. - Fixed bug with collision header components at offset 0
2021-01-12Various bug fixes and added functionality (#69)Nicholas Estelami
* Fixed bug with extraction of ci4 textures * Made a bunch of declarations static * Removed manual writes to declarations dictionary from external classes. * Fixed SharpOcarina related bug.
2021-01-08Fixed bug with declarations at 0x0000, and fixed improperly sized palettes. ↵Nicholas Estelami
(#65) * Fixed bug with extraction of ci4 textures * Made a bunch of declarations static * Removed manual writes to declarations dictionary from external classes. * Added a bunch of deconstructors, freed a bunch of stuff * Fixed bug with declarations at 0x0000, and fixed issue with palette sizing. * Fixed VS Lib and Include Dirs
2021-01-08ZAPD now supports Vector types. (#64)Kenix3
2021-01-05ZAPD now supports scalar types (#54)Kenix3
* ZAPD now supports scalar types Additionally wrapped a few output statements in verbosity checks. Additionally added checks for environment float types in BitConverter * ZScalar now has a ZResourceType * ZScalar now uses a reference to the string passed to GetSourceOutputCode. * ZScalar now uses parent->AddDeclaration rather than access the declarations dictionary directly.
2021-01-05Made a bunch of declarations static. Removed external writes to declarations ↵Nicholas Estelami
dictionary. (#55) * Fixed bug with extraction of ci4 textures * Made a bunch of declarations static * Avoid unnecessary copies (#46) Pass some parameters by reference to avoid unnecessary copies. When the parameter is intended to be copied into a member variable, pass it by value and move it into the member instead. This doesn't fix every occurrence of the issue but this diff is already getting big so let's stop here for the moment. * Removed manual writes to declarations dictionary from external classes. Co-authored-by: Léo Lam <leo@leolam.fr>
2021-01-01Misc changes (#41)fig02
* fixes * changes * progress * Vertices -> Vtx * done i think
2021-01-01Added in support for player animations (#40)Nicholas Estelami
* Added in support for Player Animations * Fixed up a bunch of non matching issues
2021-01-01No longer using snake case name variables and segment offsets now print to 6 ↵Kenix3
characters (#39)
2020-12-31various changes (#36)fig02
2020-12-31CollisionHeader XML support, LOD limbs, various bug fixes and tweaks (#35)Nicholas Estelami
* Update Makefile * - Removed basefile.txt writes - CollisionHeader can now be defined in the XML - Fixed nonmatching issue with ZCutscene - LOD Limbs should work, but still needs testing - Fixed bug where default limb DL names would not be generated - CFG Files no longer generated, since it is no longer necessary.
2020-12-30ZAP2 project renamed to ZAPD (#27)Kenix3