KillzXGaming / Switch-Toolbox

A tool to edit many video game file formats
GNU General Public License v3.0
930 stars 147 forks source link

Support v5 Meta entries for BARS #208

Open MegAmi24 opened 4 years ago

MegAmi24 commented 4 years ago

Most files (e.x. .bars and some .zs files) from Animal Crossing: New Horizons can't be opened by the tool. I double checked files from other games and they worked fine, so I'm guessing this game uses different versions of the file formats.

KillzXGaming commented 4 years ago

Yes the meta data sections are different and heavily changed

Sch1nken commented 4 years ago

Do you have any information on what changed? I could try to implement things for a pull request then.

GiovanH commented 4 years ago

There is also a new BYML header that switch-toolbox doesn't seem to support.

SloneFallion commented 4 years ago

My knowledge and expertise is limited; I'm pretty green on this kind of stuff. That said, I hope this helps for BARS in Animal Crossing:

There is documentation on the BWAV files contained within the BARS files here: https://gota7.github.io/Citric-Composer/specs/binaryWav.html. I haven't been able to determine a way to know how large of a BWAV file to expect, other than looking for the next "BWAV" header or end of file. But that might pull in extra null data that is not needed.

AMTA changes:

Offset | Type       | Description
0x0    | char[4]    | Header start, should always be "AMTA"
0x8    | u32        | Length of the AMTA chunk
0x48   | char[20]   | File name, null terminated.
K-E-R-A-D commented 3 years ago

i think i can help a bit w/ AMTA v5 thing, but don't expect me that i know of its whole structure... (and be wary that i'm talking of a specific game, animal crossing new horizons that is, hope you don't mind)

but the only i can help is, most of AMTA v5 seem to begin its file name on offset 0x48

however, on update files, other file names begin on offset of 0x4C, or even 0x56. here are a few examples

HxD64_2HGDlvvY18 (found in Keyboard_Boy_en.bars, a .bars file that plays sound when typing using in game english keyboard, found in base game) as you can see, the starting offset there of file name is 0x48

HxD64_tYqFTFKP6R (this one is found in FtrWeddingOrgan.bars, a .bars file for an instrument Wedding Pipe Organ, added in update 1.2.0 of the game. you need an update file to get it however.) this one however, as the .bars file itself was added in an update, the structure is different than the ones found in base game. instead of the default starting offset, it starts on 0x56.

HxD64_kL2U7woUxk (and this is found in the Fireworks.bars, a .bars file used to play fireworks sounds, added in 1.4.0 update, again, you need an update file to get it, preferably the latest one.) another one, the starting offset of file name however, is 0x4C

you need a hex editor tool to view it like that, it's another program though so far i think that's my find on AMTA v5 in ACNH

oh also allow me to add one or some noteworthy thing about ACNH .bars files:

bear in mind that some, or most ACNH .bars files may contain AMTA tag more than the BWAV files, it is either found in base game, or update. i'll give you quick example the ones found in base game: -Bgm_Base.bars (a .bars file contains game soundtracks, found in base game) contains 702 AMTA tags and 699 BWAV files -Character_HumanActor.bars (a .bars file contains um, any sort of interactions done by player [?], also reactions) contains 198 AMTA tags and 189 BWAV files. -Player.bars (a .bars file contains sounds whenever the player is doing an action or two, like putting an item to inventory, vaulting through river bank, and so on) contains 248 AMTA tags and 241 BWAV files. -and the biggest one i found, Pl_Footstep.bars (a .bars file contains footstep sounds) contains 1680 AMTA tags and 1112 BWAV files.

one example i found in update: Doubutsugo_Ghost.bars (i suspect this is a .bars file of animalese for a wisp character, found in update 1.4.0, i think) contains 36 AMTA tags and 5 BWAV files

and this is where the codes thing come in: HxD64_trNB2YZMkw (found in Doubutsugo_Ghost.bars) these codes are actually a code for pointing which AMTA is related to a certain BWAV. there could be more than one AMTA tag related to the same BWAV file

they are in um, QWORD and they will look like this HxD64_sBDh6qEXVy take one example of QWORD code, and you get C0 01 00 00 00 11 00 00. following the wiki here, they are an actual offset, except, they read in reverse. look at the example above, the code itself means an AMTA tag on an offset of 0x1C0 is related to the BWAV on an offset of 0x1100. quick breakdown: C0 01 00 00 is AMTA tag on an offset of 0x1C0, and 00 11 00 00 is BWAV on an offset of 0x1100.

another example is 2C 02 00 00 C0 49 00 00. it means the AMTA tag on an offset of 0x22C is related to the BWAV on an offset of 0x49C0. Quick breakdown: 2C 02 00 00 is AMTA tag on an offset of 0x22C, and C0 49 00 00 is BWAV on an offset of 0x49C0.

and another example: 04 03 00 00 00 11 00 00. it means the AMTA tag on an offset of 0x304 is related to the BWAV on an offset of 0x1100. Quick breakdown: 04 03 00 00 is AMTA tag on an offset of 0x304 (yes the 0 on 04 on the leftmost is count for an offset), and 00 11 00 00 is the BWAV on an offset of 0x1100. Notice the code, this suggests that there are more than one AMTA tag related to the same BWAV file.

i can show you another example on another .bars file but i think that should suffice...

if you wish to look for starting offset where an array of those, QWORD code begins, simply look at the wiki i linked above (https://github.com/Kinnay/Nintendo-File-Formats/wiki/BARS-File-Format). Starting from 0x10, the CRC32 has thing. They are in DWORD and the number of them are matching with the number of AMTA tags the .bars file has.

HxD64_FBAv6cE8QX example DWORD codes: 02 6F 4F 03, 90 9A 24 10, E2 E9 9F 25, 2E 5A 17 2D, and so on until 88 87 A0 F9.

and the ending offset of, an array QWORD codes is where the first AMTA is declared upon HxD64_PeJxt5S6jt

and alright, that's it...

EDIT: i was told by someone some time ago about a kicker of AMTA v5

look at offset 0x24, it has a value that indicates an offset the starting file name, and here's the kicker: perform a hex addition operation, 0x24 + the value on offset 0x24 itself

e.g.: from the AMTA of Fireworks.bars like an example above, the value on offset 0x24 is 28, and therefore 24 + 28 = 4C and therefore, the offset of starting file name is 0x4C

P.S.: i unfortunately don't know how the switch toolbox is working with .bars files for some reason on other games somehow...