/***************************************************************************
 *   Nintendo GameCube/Wii disc-header classifier                         *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#ifndef NINTENDO_DISC_HEADER_H_INCLUDED
#define NINTENDO_DISC_HEADER_H_INCLUDED

#include <stddef.h>
#include <stdint.h>

typedef enum {
    NINTENDO_DISC_HEADER_UNKNOWN = 0,
    NINTENDO_DISC_HEADER_GAMECUBE,
    NINTENDO_DISC_HEADER_WII
} nintendo_disc_header_type;

/*
 * Classify an unscrambled Nintendo optical-disc header.
 *
 * Wii discs carry big-endian magic 0x5d1c9ea3 at byte 0x18.
 * GameCube discs carry big-endian magic 0xc2339f3d at byte 0x1c.
 * Wii is checked first, matching the console-side discrimination order.
 */
nintendo_disc_header_type nintendo_disc_header_detect(
    const uint8_t *sector,
    size_t sector_length
);

const char *nintendo_disc_header_type_name(
    nintendo_disc_header_type type
);

#endif
