mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-21 20:59:52 +01:00
Add TXTH name_offset_absolute for some subsong cases
This commit is contained in:
parent
abb8d3fa1d
commit
af7cc73685
28
doc/TXTH.md
28
doc/TXTH.md
@ -366,10 +366,11 @@ Sets the name of the stream, most useful when used with subsongs. TXTH will read
|
||||
|
||||
`name_size` defaults to 0, which reads until null-terminator or a non-ascii character is found.
|
||||
|
||||
`name_offset` can be a (number) value, but being an offset it's also adjusted by `subsong_spacing`.
|
||||
`name_offset` can be a (number) value, but being an offset it's also adjusted by `subsong_spacing`. If you need to point to some absolute offset (for example a subsong pointings to name in another table) that doesn't depend on subsong (must not be changed by `subsong_spacing`), use `name_offset_absolute`.
|
||||
```
|
||||
name_offset = (value)
|
||||
name_size = (value)
|
||||
name_offset_absolute = (value)
|
||||
```
|
||||
|
||||
#### SUBFILES
|
||||
@ -853,7 +854,6 @@ JIN002.XAG: 0x168
|
||||
JIN003.XAG: 0x180
|
||||
```
|
||||
|
||||
|
||||
#### Grandia (PS1) bgm.txth
|
||||
```
|
||||
header_file = GM1.IDX
|
||||
@ -903,7 +903,6 @@ st_s01_02b.ssd: 6*0x04
|
||||
st_s01_02c.ssd: 7*0x04
|
||||
```
|
||||
|
||||
|
||||
#### Zack & Wiki (Wii) st_s01_00a.txth
|
||||
```
|
||||
#alt from above with untouched folders
|
||||
@ -993,6 +992,7 @@ subsong_spacing = 0xc8
|
||||
|
||||
start_offset = @0xc4 + 0xc0
|
||||
```
|
||||
|
||||
#### Sega Rally 3 (PC) EnglishStream.txth
|
||||
```
|
||||
codec = PCM16LE
|
||||
@ -1030,3 +1030,25 @@ subsong_spacing = 0xc8
|
||||
|
||||
start_offset = @0xc4 + 0xc0
|
||||
```
|
||||
|
||||
#### Starsky & Hutch (PS2) MUSICPS2.WAD.txth
|
||||
```
|
||||
codec = PSX
|
||||
channels = 1
|
||||
sample_type = bytes
|
||||
|
||||
header_file = MUSICPS2.WAD
|
||||
body_file = MUSICPS2.WAD
|
||||
|
||||
subsong_count = 0xC
|
||||
subsong_spacing = 0x30
|
||||
sample_rate = 32000
|
||||
base_offset = 0x70
|
||||
start_offset = @0x14 + 0x380
|
||||
num_samples = @0x18
|
||||
data_size = num_samples
|
||||
loop_flag = auto
|
||||
|
||||
#@0x10 is an absolute offset to another table, that shouldn't be affected by subsong_spacing
|
||||
name_offset_absolute = @0x10 + 0x270
|
||||
```
|
||||
|
@ -1154,6 +1154,13 @@ static int parse_keyval(STREAMFILE* sf_, txth_header* txth, const char * key, ch
|
||||
if (txth->subsong_spacing)
|
||||
txth->name_offset += txth->subsong_spacing * (txth->target_subsong - 1);
|
||||
}
|
||||
else if (is_string(key,"name_offset_absolute")) {
|
||||
if (!parse_num(txth->sf_head,txth,val, &txth->name_offset)) goto fail;
|
||||
txth->name_offset_set = 1;
|
||||
/* special adjustment */
|
||||
txth->name_offset += txth->base_offset;
|
||||
/* unlike the above this is meant for reads that point to somewhere in the file, regardless subsong number */
|
||||
}
|
||||
else if (is_string(key,"name_size")) {
|
||||
if (!parse_num(txth->sf_head,txth,val, &txth->name_size)) goto fail;
|
||||
}
|
||||
@ -1561,7 +1568,7 @@ static int parse_num(STREAMFILE* sf, txth_header* txth, const char * val, uint32
|
||||
uint32_t value_div = txth->value_div;
|
||||
uint32_t value_add = txth->value_add;
|
||||
uint32_t value_sub = txth->value_sub;
|
||||
uint32_t subsong_offset = txth->subsong_spacing;
|
||||
uint32_t subsong_spacing = txth->subsong_spacing;
|
||||
|
||||
char op = ' ';
|
||||
int brackets = 0;
|
||||
@ -1626,8 +1633,8 @@ static int parse_num(STREAMFILE* sf, txth_header* txth, const char * val, uint32
|
||||
else if (!(ed1 == 'L' && ed2 == 'E'))
|
||||
goto fail;
|
||||
|
||||
if (subsong_offset)
|
||||
offset = offset + subsong_offset * (txth->target_subsong - 1);
|
||||
if (subsong_spacing)
|
||||
offset = offset + subsong_spacing * (txth->target_subsong - 1);
|
||||
|
||||
switch(size) {
|
||||
case 1: value = (uint8_t)read_8bit(offset,sf); break;
|
||||
@ -1658,8 +1665,8 @@ static int parse_num(STREAMFILE* sf, txth_header* txth, const char * val, uint32
|
||||
else if ((n = is_string_field(val,"loop_end_sample"))) value = txth->loop_end_sample;
|
||||
else if ((n = is_string_field(val,"loop_end"))) value = txth->loop_end_sample;
|
||||
else if ((n = is_string_field(val,"subsong_count"))) value = txth->subsong_count;
|
||||
else if ((n = is_string_field(val,"subsong_offset"))) value = txth->subsong_spacing;
|
||||
else if ((n = is_string_field(val,"subsong_spacing"))) value = txth->subsong_spacing;
|
||||
else if ((n = is_string_field(val,"subsong_offset"))) value = txth->subsong_spacing;
|
||||
else if ((n = is_string_field(val,"subfile_offset"))) value = txth->subfile_offset;
|
||||
else if ((n = is_string_field(val,"subfile_size"))) value = txth->subfile_size;
|
||||
else if ((n = is_string_field(val,"base_offset"))) value = txth->base_offset;
|
||||
|
Loading…
x
Reference in New Issue
Block a user