-
Notifications
You must be signed in to change notification settings - Fork 11
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
BMSSTOC (Sound TOC) #206
base: main
Are you sure you want to change the base?
BMSSTOC (Sound TOC) #206
Conversation
steven11sjf
commented
Aug 5, 2024
- contains helper data for the BFSAR about wave archives, sound streams, and groups
- added some hashes from BFSAR
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #206 +/- ##
==========================================
+ Coverage 76.33% 76.47% +0.14%
==========================================
Files 78 79 +1
Lines 3782 3809 +27
==========================================
+ Hits 2887 2913 +26
- Misses 895 896 +1 ☔ View full report in Codecov by Sentry. |
"file_id" / FileId, | ||
"warc_index" / Int32ul, # index of the WARC listed in BFSAR | ||
"idx" / Int32ul, # 0 to max wave archives | ||
Check(construct.this._index == construct.this.idx), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these Check
calls suggest the index fields ought to be in a Rebuild
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should i keep the check and just add a rebuild? or solely rely on the rebuild?
|
||
FileId = Struct( | ||
"file_idx" / Int24ul, | ||
"file_type" / construct.Enum(Byte, sound=1, soundgroup=2, bank=3, player=4, wavearchive=5, group=6), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a rule of thumb, always make an Enum
class for use with construct.Enum
"wav_name" / PropertyEnum, | ||
"file_id" / FileId, | ||
"warc_index" / Int32ul, # index of the WARC listed in BFSAR | ||
"idx" / Int32ul, # 0 to max wave archives |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not quite sure the best way to write it but in the BFSAR all sounds have a "global" index which is warc_index
(like, sounds are numbered 0 - (N-1)
and wave archives are N - N+len(WArc)
. and the idx field is the same but starts from 0.
"file_size" / Int32ul, # == length of romfs:/packs/sounds/<group>.bfgrp | ||
Const(0, Int64ul), | ||
"group" / PaddedString(0x80, "ascii"), | ||
"_size" / Rebuild(Int32ul, lambda ctx: len(ctx.wavs)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is a length/count, don't call it a size
"group" / PaddedString(0x80, "ascii"), | ||
"_size" / Rebuild(Int32ul, lambda ctx: len(ctx.wavs)), | ||
Const(0, Int32ul), | ||
Const(b"\x0D\xF0\xAD\xBA" * 4), # 16B of BAADF00D magic from heap alloc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does Const(0xBAADF00D)[4]
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BMSSTOC = Struct( | ||
"wave_archives" / PrefixedArray(Int32ul, WaveArchiveData), | ||
"sound_streams" / PrefixedArray(Int32ul, SoundStreams), | ||
"groups" / construct.Debugger(PrefixedArray(Int32ul, GroupData)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the debugger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to scare the bugs off obviously
"wave_archives" / PrefixedArray(Int32ul, WaveArchiveData), | ||
"sound_streams" / PrefixedArray(Int32ul, SoundStreams), | ||
"groups" / PrefixedArray(Int32ul, GroupData), | ||
construct.Terminated, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these arrays can all use make_vector()
- contains helper data for the BFSAR about wave archives, sound streams, and groups