view formats/src/th06/pos.rs @ 791:a29122662cde

utils: Simplify translate_2d and align Mat4 to 16 bytes This lowers the amount of instructions from 61 to 32 on PowerPC with AltiVec, and from 25 to 14 on amd64 with AVX2.
author Link Mauve <linkmauve@linkmauve.fr>
date Sat, 17 Jan 2026 14:19:58 +0100
parents ec1e06402a97
children
line wrap: on
line source

//! POS music track format support.

use nom::{IResult, Parser, number::complete::le_u32};

/// A struct describing the loop points of Touhou background music.
#[derive(Debug, Clone)]
pub struct LoopPoints {
    /// Time to which the music should loop after reaching end.
    pub start: u32,

    /// Time at which to loop back to start.
    pub end: u32,
}

impl LoopPoints {
    /// Parse a slice of bytes into a `LoopPoints` struct.
    pub fn from_slice(input: &[u8]) -> IResult<&[u8], LoopPoints> {
        let (i, (start, end)) = (le_u32, le_u32).parse(input)?;
        Ok((i, LoopPoints { start, end }))
    }
}