Mercurial > touhou
annotate formats/src/th06/pos.rs @ 783:ec1e06402a97
Replace SDL2_mixer with the kira crate
| author | Link Mauve <linkmauve@linkmauve.fr> |
|---|---|
| date | Fri, 21 Nov 2025 10:21:59 +0100 |
| parents | |
| children |
| rev | line source |
|---|---|
|
783
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 //! POS music track format support. |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 use nom::{IResult, Parser, number::complete::le_u32}; |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 /// A struct describing the loop points of Touhou background music. |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 #[derive(Debug, Clone)] |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 pub struct LoopPoints { |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 /// Time to which the music should loop after reaching end. |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 pub start: u32, |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 /// Time at which to loop back to start. |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 pub end: u32, |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 } |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 impl LoopPoints { |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 /// Parse a slice of bytes into a `LoopPoints` struct. |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 pub fn from_slice(input: &[u8]) -> IResult<&[u8], LoopPoints> { |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 let (i, (start, end)) = (le_u32, le_u32).parse(input)?; |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 Ok((i, LoopPoints { start, end })) |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 } |
|
ec1e06402a97
Replace SDL2_mixer with the kira crate
Link Mauve <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 } |
