#include "sys.h"
#include "sf64audio_provisional.h"

// AudioTable gSampleBankTableInit = {
AudioTable D_800C0760 = {
    { 4, 0, 0 },
    {
        { 0x000000, 0x0DF120, MEDIUM_CART, CACHEPOLICY_4 },
        { 0x0DF120, 0x0D1D80, MEDIUM_CART, CACHEPOLICY_4 },
        { 0x1B0EA0, 0x48C480, MEDIUM_CART, CACHEPOLICY_4 },
        { 0x63D320, 0x0C3900, MEDIUM_CART, CACHEPOLICY_4 },
    },
};

// AudioTable gSeqTableInit = {
AudioTable D_800C07B0 = {
    { SEQ_ID_MAX, 0, 0 },
    {
        { 0x00000, 0x3AF0, MEDIUM_CART, CACHEPOLICY_0 },     { 0x03AF0, 0x5990, MEDIUM_CART, CACHEPOLICY_0 },
        { 0x09480, 0x2D80, MEDIUM_CART, CACHEPOLICY_3 },     { 0x0C200, 0x1410, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x0D610, 0x1600, MEDIUM_CART, CACHEPOLICY_3 },     { 0x0EC10, 0xF20, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x0FB30, 0x13A0, MEDIUM_CART, CACHEPOLICY_3 },     { 0x10ED0, 0x1100, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x11FD0, 0x19E0, MEDIUM_CART, CACHEPOLICY_3 },     { 0x139B0, 0x13E0, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x14D90, 0x12F0, MEDIUM_CART, CACHEPOLICY_3 },     { SEQ_ID_SECTOR_Y, 0, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x16080, 0xB70, MEDIUM_CART, CACHEPOLICY_3 },      { 0x16BF0, 0x2460, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x19050, 0xD40, MEDIUM_CART, CACHEPOLICY_3 },      { SEQ_ID_FORTUNA, 0, MEDIUM_CART, CACHEPOLICY_3 },
        { SEQ_ID_TITANIA, 0, MEDIUM_CART, CACHEPOLICY_3 },   { 0x19D90, 0x7F0, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x1A580, 0x1440, MEDIUM_CART, CACHEPOLICY_3 },     { 0x1B9C0, 0x1B20, MEDIUM_CART, CACHEPOLICY_3 },
        { SEQ_ID_BOSS_ME, 0, MEDIUM_CART, CACHEPOLICY_3 },   { SEQ_ID_BOSS_CO_1, 0, MEDIUM_CART, CACHEPOLICY_3 },
        { SEQ_ID_BOSS_CO_1, 0, MEDIUM_CART, CACHEPOLICY_3 }, { SEQ_ID_BOSS_ME, 0, MEDIUM_CART, CACHEPOLICY_3 },
        { SEQ_ID_BOSS_ME, 0, MEDIUM_CART, CACHEPOLICY_3 },   { 0x1D4E0, 0x1B30, MEDIUM_CART, CACHEPOLICY_3 },
        { SEQ_ID_BOSS_CO_1, 0, MEDIUM_CART, CACHEPOLICY_3 }, { SEQ_ID_BOSS_ME, 0, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x1F010, 0x10B0, MEDIUM_CART, CACHEPOLICY_3 },     { SEQ_ID_BOSS_BO, 0, MEDIUM_CART, CACHEPOLICY_3 },
        { SEQ_ID_BOSS_ME, 0, MEDIUM_CART, CACHEPOLICY_3 },   { SEQ_ID_BOSS_BO, 0, MEDIUM_CART, CACHEPOLICY_3 },
        { SEQ_ID_BOSS_ME, 0, MEDIUM_CART, CACHEPOLICY_3 },   { 0x200C0, 0x1410, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x214D0, 0xF30, MEDIUM_CART, CACHEPOLICY_3 },      { 0x22400, 0x2B30, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x24F30, 0x7F0, MEDIUM_CART, CACHEPOLICY_3 },      { 0x25720, 0x13B0, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x26AD0, 0xC70, MEDIUM_CART, CACHEPOLICY_3 },      { 0x27740, 0x180, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x278C0, 0x5C0, MEDIUM_CART, CACHEPOLICY_3 },      { SEQ_ID_TITLE, 0, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x27E80, 0x4E40, MEDIUM_CART, CACHEPOLICY_3 },     { 0x2CCC0, 0x14E0, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x2E1A0, 0x400, MEDIUM_CART, CACHEPOLICY_3 },      { 0x2E5A0, 0x800, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x2EDA0, 0x1AB0, MEDIUM_CART, CACHEPOLICY_3 },     { 0x30850, 0x1AA0, MEDIUM_CART, CACHEPOLICY_3 },
        { SEQ_ID_BOSS_ME, 0, MEDIUM_CART, CACHEPOLICY_3 },   { 0x322F0, 0x1370, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x33660, 0xB80, MEDIUM_CART, CACHEPOLICY_3 },      { 0x341E0, 0x5C0, MEDIUM_CART, CACHEPOLICY_3 },
        { SEQ_ID_CO_INTRO, 0, MEDIUM_CART, CACHEPOLICY_3 },  { SEQ_ID_CO_INTRO, 0, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x347A0, 0x550, MEDIUM_CART, CACHEPOLICY_3 },      { 0x34CF0, 0x360, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x35050, 0x620, MEDIUM_CART, CACHEPOLICY_3 },      { SEQ_ID_VS_MENU, 0, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x35670, 0xA70, MEDIUM_CART, CACHEPOLICY_3 },      { SEQ_ID_STAR_WOLF, 0, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x360E0, 0xAB0, MEDIUM_CART, CACHEPOLICY_3 },      { 0x36B90, 0x13D0, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x37F60, 0x250, MEDIUM_CART, CACHEPOLICY_3 },      { 0x381B0, 0x6F0, MEDIUM_CART, CACHEPOLICY_3 },
        { 0x388A0, 0xFB0, MEDIUM_CART, CACHEPOLICY_3 },      { 0x39850, 0x1780, MEDIUM_CART, CACHEPOLICY_3 },
    },
};
#define SOUNDFONT_ENTRY(offset, size, medium, cachePolicy, bank1, bank2, numInst, numDrums) \
    {                                                                                       \
        offset, size, medium, cachePolicy, (((bank1) &0xFF) << 8) | ((bank2) &0xFF),        \
            (((numInst) &0xFF) << 8) | ((numDrums) &0xFF)                                   \
    }

AudioTable gSoundFontTableInit = {
    { 33, 0, 0 },
    {
        SOUNDFONT_ENTRY(0x0, 0x2f00, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_SFX, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0x2f00, 0x820, MEDIUM_CART, CACHEPOLICY_1, SAMPLES_MAP, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0x3720, 0x6e0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0x3e00, 0x15e0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0x53e0, 0xc20, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0x6000, 0xfe0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0x6fe0, 0x1360, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0x8340, 0x1120, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0x9460, 0xea0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0xa300, 0xce0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0xafe0, 0x1ba0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0xcb80, 0xac0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0xd640, 0xac0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0xe100, 0xee0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0xefe0, 0xc00, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0xfbe0, 0x10a0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0x10c80, 0xf80, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0x11c00, 0x10c0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0x12cc0, 0x1380, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0x14040, 0x2b20, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0x16b60, 0x9a0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
        SOUNDFONT_ENTRY(0x17500, 0x1220, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 16, 64),
        SOUNDFONT_ENTRY(0x18720, 0x180, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 3, 0),
        SOUNDFONT_ENTRY(0x188a0, 0x11c0, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 16, 64),
        SOUNDFONT_ENTRY(0x19a60, 0x940, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
        SOUNDFONT_ENTRY(0x1a3a0, 0x9e0, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
        SOUNDFONT_ENTRY(0x1ad80, 0x920, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
        SOUNDFONT_ENTRY(0x1b6a0, 0x9e0, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
        SOUNDFONT_ENTRY(0x1c080, 0x9e0, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
        SOUNDFONT_ENTRY(0x1ca60, 0xa10, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
        SOUNDFONT_ENTRY(0x1d470, 0x9e0, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
        SOUNDFONT_ENTRY(0x1de50, 0xa00, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
        SOUNDFONT_ENTRY(0x1e850, 0x8d0, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
    }
};

#define AS_BYTES(x) (((x) >> 8) & 0xFF), ((x) &0xFF)

u8 gSeqFontTableInit[288] = {
    AS_BYTES(132),
    AS_BYTES(134),
    AS_BYTES(155),
    AS_BYTES(157),
    AS_BYTES(159),
    AS_BYTES(161),
    AS_BYTES(163),
    AS_BYTES(165),
    AS_BYTES(167),
    AS_BYTES(169),
    AS_BYTES(171),
    AS_BYTES(173),
    AS_BYTES(175),
    AS_BYTES(177),
    AS_BYTES(179),
    AS_BYTES(181),
    AS_BYTES(183),
    AS_BYTES(185),
    AS_BYTES(187),
    AS_BYTES(189),
    AS_BYTES(191),
    AS_BYTES(193),
    AS_BYTES(195),
    AS_BYTES(197),
    AS_BYTES(199),
    AS_BYTES(201),
    AS_BYTES(203),
    AS_BYTES(205),
    AS_BYTES(207),
    AS_BYTES(209),
    AS_BYTES(211),
    AS_BYTES(213),
    AS_BYTES(215),
    AS_BYTES(217),
    AS_BYTES(219),
    AS_BYTES(221),
    AS_BYTES(223),
    AS_BYTES(225),
    AS_BYTES(227),
    AS_BYTES(229),
    AS_BYTES(231),
    AS_BYTES(233),
    AS_BYTES(235),
    AS_BYTES(237),
    AS_BYTES(239),
    AS_BYTES(241),
    AS_BYTES(243),
    AS_BYTES(245),
    AS_BYTES(247),
    AS_BYTES(249),
    AS_BYTES(251),
    AS_BYTES(253),
    AS_BYTES(255),
    1,
    1,
    1,
    3,
    1,
    5,
    1,
    7,
    1,
    9,
    1,
    11,
    1,
    13,
    1,
    15,
    1,
    17,
    1,
    19,
    1,
    21,
    1,
    23,
    1,
    25,
    1,
    0,
    20,
    20,
    19,
    18,
    17,
    16,
    15,
    14,
    13,
    12,
    11,
    10,
    9,
    8,
    7,
    6,
    5,
    4,
    3,
    1,
    2,
    1,
    24,
    1,
    29,
    1,
    25,
    1,
    26,
    1,
    28,
    1,
    25,
    1,
    25,
    1,
    29,
    1,
    24,
    1,
    29,
    1,
    28,
    1,
    25,
    1,
    30,
    1,
    24,
    1,
    25,
    1,
    28,
    1,
    28,
    1,
    31,
    1,
    31,
    1,
    28,
    1,
    28,
    1,
    31,
    1,
    31,
    1,
    31,
    1,
    28,
    1,
    31,
    1,
    31,
    1,
    31,
    1,
    31,
    1,
    31,
    1,
    31,
    1,
    32,
    1,
    21,
    1,
    21,
    1,
    22,
    1,
    21,
    1,
    21,
    1,
    21,
    1,
    21,
    1,
    21,
    1,
    23,
    1,
    25,
    1,
    21,
    1,
    21,
    1,
    29,
    1,
    25,
    1,
    31,
    1,
    21,
    1,
    21,
    1,
    21,
    1,
    21,
    1,
    21,
    1,
    21,
    1,
    21,
    1,
    21,
    1,
    21,
    1,
    27,
    1,
    25,
    1,
    21,
    1,
    25,
    1,
    25,
    1,
    25,
    1,
    21,
    1,
    31,
    0,
    0,
    0,
    0,
    0,
};
