using System;
namespace pkNX.Structures;
public static class CodePattern
{
///
/// Finds a provided within the supplied .
///
/// Array to look in
/// Pattern to look for
/// Starting offset to look from
/// Amount of entries to look through
/// Index the pattern occurs at; if not found, returns -1.
public static int IndexOfBytes(ReadOnlySpan array, ReadOnlySpan pattern, int startIndex = 0, int length = -1)
{
var span = array[startIndex..];
if (length > 0 && length < span.Length)
span = span[..length];
return span.IndexOf(pattern) + startIndex;
}
///
/// byte pattern which precedes the TMHM list. This list is the tail end of item IDs for each TM(01->100).
///
public static readonly byte[] TMHM_GG =
[
0xA0, 0x01, 0xA1, 0x01, 0xA2, 0x01, 0xA3, 0x01,
0x6A, 0x02, 0x6B, 0x02, 0x6C, 0x02, 0xB2, 0x02,
0xB3, 0x02, 0xB4, 0x02, 0xB5, 0x02, 0xB6, 0x02,
];
}