Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(HG2, HG3): use image ID entry names, fix HG2 archive view. #479

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

trigger-segfault
Copy link

Change HG2/HG3 archive view entry names to use real ID names.
Fix multiple errors in ArcHG2.cs image view, and add version 0x20 support.

Changes

  • Fix bug in ArcHG2.cs where opened images would not pass Version to Hg2MetaData, causing the reader to unpack everything as version 0x10 instead.
  • Add support for viewing HG2 version 0x20 as archive, and read real data offset when assigning the HeaderSize field in Hg2MetaData.
  • HG2 and HG3 archive image names now use real IDs in names, instead of image index: Aside from HG2 version 0x10, all HG* images contain frame IDs, which are considered part of the name (at least when used in a multi-image fashion).
    • Note: A signed integer is used to match CatSystem 2 behavior. It can handle unnecessarily large and negative frame IDs, and will export frames as a signed number when using the WGC.exe tool (from the devkit).
    • 90% of the time, these IDs will just be the index of the frame. But the other 10%, these IDs are very specifically chosen when working with user interface layers and image variations (like a button highlight state).
    • When used for user interfaces, image IDs usually follow a pattern of reserving the lower decimal digits for image variations, and higher decimal digits for different UI elements (i.e. save/load/title/config button, background, etc.)

Example of new frame ID names:

new frame IDs in GARbro

About new fields referenced

HG3 fields referenced

Frame Header

Type Value Description
uint32 OffsetNext Offset to the next frame
uint32 ID Identifier for the frame used in game
* Tags Image tags, must start with "stdinfo" tag
HG2 fields referenced

See Version 0x20 fields: ID and OffsetData (referenced for the HeaderSize field assignment)

Frame Metadata: Version 0x10

Type Value Description
uint32 Width Condensed width of the image (without transparency)
uint32 Height Condensed height of the image (without transparency)
uint32 BitDepth Number of bits per pixel, 24 or 32 (different usage with version 0x10)
uint32 Reversed1 Unused (would be the slice index, like in HG3)
uint32 Reserved2 Unused (would be the slice length, like in HG3)
uint32 DataSize Compressed length of Zero Run-length copy data
uint32 OrigDataSize Decompressed length of Zero Run-length copy data
uint32 CtlSize Compressed length of Zero Run-length command bits
uint32 OrigCtlSize Original size of Zero Run-length command bits

Frame Metadata: Version 0x20 (extended)

Type Value Description
uint32 OffsetData Offset (relative to Version 0x20 metadata) to Image Data (Always >= 0x20)
Alternatively consider as extra metadata size
uint32 ID Identifier for the frame used in game
uint32 CanvasWidth Total width of the image with OffsetX applied
uint32 CanvasHeight Total height of the image with OffsetY applied
int32 OffsetX Horizontal offset of the image from the left
int32 OffsetY Vertical offset of the image from the top
bool32 IsTransparent True if transparency is used in the image
uint32 OffsetNext Offset from start of Version 0x10 to next frame
Value is 0 if no more frames

Frame Metadata: Version 0x25 (extended)

Type Value Description
int32 BaseX Horizontal center of the image, used for drawing in-game
int32 BaseY Vertical center of the image, used for drawing in-game

* Fix bug in `ArcHG2.cs` where opened images would not pass `Version` to `Hg2MetaData`, causing the reader to unpack everything as version `0x10` instead.
* Add support for viewing HG2 version `0x20` as archive, and read **real** data offset when assigning the `HeaderSize` field in `Hg2MetaData`.
* HG2 and HG3 archive image names now use **real** IDs in names, instead of image index: Aside from HG2 version `0x10`, all HG\* images contain frame IDs, which are considered part of the name (at least when used in a multi-image fashion).
    * 90% of the time, these IDs will just be the index of the frame. But the other 10%, these IDs are very specifically chosen when working with user interface layers and image variations (like a button highlight state).
	* When used for user interfaces, image IDs usually follow a pattern of reserving the lower **decimal** digits for image **variations**, and higher decimal digits for different UI elements (i.e. save/load/title/config button, background, etc.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant