Skip to content

Instantly share code, notes, and snippets.

@Dobby233Liu
Created April 19, 2024 15:59
Show Gist options
  • Save Dobby233Liu/ca81a636db08783a3d44366972a7e436 to your computer and use it in GitHub Desktop.
Save Dobby233Liu/ca81a636db08783a3d44366972a7e436 to your computer and use it in GitHub Desktop.
meta:
id: gm_iff_audo
file-extension:
- win
- dat
imports:
- /media/wav
- /media/ogg
title: "GameMaker: Studio WAD (sound-related chunks only, bytecode 14+)"
license: CC0-1.0
ks-version: 0.10
endian: le
doc-ref: https://github.com/UnderminersTeam/UndertaleModTool
seq:
- id: root
type: chunk
valid:
expr: _.four_cc == chunk_type::form
instances:
subchunks:
value: root.data.as<chunks>.entries
types:
chunks:
seq:
- id: entries
type: chunk
repeat: eos
chunk:
seq:
- id: four_cc
type: u4
enum: chunk_type
- id: size
type: u4
- id: data
size: size
type:
switch-on: four_cc
cases:
"chunk_type::form": chunks
"chunk_type::sond": pointer_list
"chunk_type::agrp": pointer_list
"chunk_type::audo": pointer_list
_: dummy
-webide-representation: "{fourCc}"
dummy: {}
pointer_list:
seq:
- id: length
type: u4
- id: entries_ofs
type: u4
repeat: expr
repeat-expr: length
instances:
entries:
repeat: expr
repeat-expr: length
type: pointer_list_item(_index)
pointer_list_item:
params:
- id: i
type: s4
instances:
body:
io: _root._io
pos: _parent.entries_ofs[i]
type:
switch-on: _parent._parent.four_cc
cases:
"chunk_type::sond": sound
"chunk_type::agrp": audio_group
"chunk_type::audo": embedded_audio
-webide-representation: "{body}"
gm_string_ref:
seq:
- id: str
type: strz
encoding: UTF-8
-webide-representation: "{str}"
sound:
seq:
- id: name_ofs
type: u4
- id: flags
type: u4
valid:
expr: "(_ & 0x64) == 0x64"
- id: type_ofs
type: u4
- id: filename_ofs
type: u4
- id: effects
type: u4
- id: volume
type: f4
- id: unknown
type: f4
- id: audio_group_id
type: u4
- id: file_id
type: s4
instances:
name_obj:
io: _root._io
if: name_ofs != 0
pos: name_ofs
type: gm_string_ref
name:
if: name_obj
value: name_obj.str
embedded:
value: "(flags & 0x1) == 0x1"
compressed:
value: "(flags & 0x2) == 0x2"
decompressed_on_load:
value: "(flags & 0x3) == 0x3"
type_obj:
io: _root._io
if: type_ofs != 0
pos: type_ofs
type: gm_string_ref
type:
if: type_obj
value: type_obj.str
filename_obj:
io: _root._io
if: filename_ofs != 0
pos: filename_ofs
type: gm_string_ref
filename:
if: filename_obj
value: filename_obj.str
audio_group_filename:
if: "audio_group_id != 0"
value: "\"audiogroup\" + audio_group_id.to_s + \".dat\""
-webide-representation: "{name}"
audio_group:
seq:
- id: name_ofs
type: u4
instances:
name_obj:
io: _root._io
pos: name_ofs
if: name_ofs != 0
type: gm_string_ref
name:
if: name_obj
value: name_obj.str
-webide-representation: "{name}"
embedded_audio:
seq:
- id: size
type: u4
- id: data
size: size
type: embedded_audio_data
embedded_audio_data:
seq:
- id: data
type:
switch-on: magic
cases:
"sound_data_magic::riff": wav
"sound_data_magic::oggs": ogg
_: wav
instances:
magic:
pos: 0
type: u4
enum: sound_data_magic
enums:
chunk_type:
0x4d524f46: form
0x444e4f53: sond
0x50524741: agrp
0x4f445541: audo
sound_data_magic:
0x52494646: riff
0x5367674f: oggs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment