Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Commit 7ef0ad4

Browse files
committed
Bump max instr count from 63 to 255
Apparently hUGETracker *can* generate that many! Fixes #18
1 parent 4dd8d24 commit 7ef0ad4

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

teNOR/src/uge.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,11 @@ fn instrument_v3(input: &[u8]) -> PResult<Instrument<'_>> {
168168
let (input, kind) = nom::number::complete::le_u32(input)?;
169169
let (input, name) = short_string(input)?;
170170
let (new_input, length) = integer(input)?;
171-
if length >= 64 {
172-
return Err(InnerError::err(input, InnerErrorKind::BadLength(length)));
171+
if length >= 255 {
172+
return Err(InnerError::err(
173+
input,
174+
InnerErrorKind::TooManyInstrs(length),
175+
));
173176
}
174177
let length = unsafe { NonZeroU8::new_unchecked(length as u8 + 1) };
175178
let (input, length_enabled) = boolean(new_input)?;
@@ -486,7 +489,6 @@ enum InnerErrorKind {
486489
BadBool(u8),
487490
BadTimerDivider(u32),
488491
BadInstrType(u32),
489-
BadLength(u32),
490492
BadEnvDir(u32),
491493
BadSweepDir(u32),
492494
BadDutyType(u8),
@@ -499,6 +501,7 @@ enum InnerErrorKind {
499501
BadWave(u8),
500502
OrderNotMatrix(usize, usize, usize, usize),
501503
NumOutOfRange(TryFromIntError),
504+
TooManyInstrs(u32),
502505
Context(&'static str),
503506
Nom(nom::error::ErrorKind),
504507
}
@@ -509,7 +512,6 @@ impl Display for InnerErrorKind {
509512
Self::BadBool(n) => write!(f, "Boolean out of range (0x{n:08x})"),
510513
Self::BadTimerDivider(n) => write!(f, "Timer divider out of range (0x{n:08x})"),
511514
Self::BadInstrType(n) => write!(f, "Instrument type out of range (0x{n:08x})"),
512-
Self::BadLength(n) => write!(f, "Length out of range ({n:08x})"),
513515
Self::BadEnvDir(n) => write!(f, "Envelope direction out of range (0x{n:08x})"),
514516
Self::BadSweepDir(n) => write!(f, "Sweep direction out of range (0x{n:08x})"),
515517
Self::BadDutyType(n) => write!(f, "Duty type out of range (0x{n:08x})"),
@@ -525,6 +527,7 @@ impl Display for InnerErrorKind {
525527
"Length of order \"columns\" don't match! ({ch1}, {ch2}, {ch3}, {ch4})"
526528
),
527529
Self::NumOutOfRange(err) => write!(f, "Number out of range: {err}"),
530+
Self::TooManyInstrs(n) => write!(f, "Too many instruments (0x{n:08x})"),
528531
Self::Context(ctx) => f.write_str(ctx),
529532
Self::Nom(err) => write!(f, "Error in parser \"{}\"", err.description()),
530533
}

0 commit comments

Comments
 (0)