EasyFlashEapi.java

/*
 * EasyAPI Am/M29F040 V1.4, from VICE's easyflash.c.
 *
 * VICE EasyFlash cartridge implementation written by
 * ALeX Kazik <alx@kazik.de> and
 * Marco van den Heuvel <blackystardust68@yahoo.com>.
 *
 * 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.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * for more details.
 *
 * Source: https://github.com/VICE-Team/svn-mirror/blob/6ab477a19dc3c98742a6f1d923183fc4e4e1e7e0/vice/src/c64/cart/easyflash.c
 * Extracted verbatim from eapiam29f040[768], without a PRG load address.
 * Payload SHA-256: 032f3f21f2299e2fd96b28dc1a901a6ed19a04f600d446c7a362781b4592f432
 */
package libsidplay.components.cart.supported;

/** Embedded in Java so desktop and TeaVM cartridges install the same flash driver. */
final class EasyFlashEapi {
    private static final byte[] DATA = {
            0x65, 0x61, 0x70, 0x69, (byte) 0xc1, 0x4d, 0x2f, (byte) 0xcd, 0x32, 0x39, (byte) 0xc6, 0x30,
            0x34, 0x30, 0x20, (byte) 0xd6, 0x31, 0x2e, 0x34, 0x00, 0x08, 0x78, (byte) 0xa5, 0x4b,
            0x48, (byte) 0xa5, 0x4c, 0x48, (byte) 0xa9, 0x60, (byte) 0x85, 0x4b, 0x20, 0x4b, 0x00, (byte) 0xba,
            (byte) 0xbd, 0x00, 0x01, (byte) 0x85, 0x4c, (byte) 0xca, (byte) 0xbd, 0x00, 0x01, (byte) 0x85, 0x4b, 0x18,
            (byte) 0x90, 0x70, 0x4c, 0x67, 0x01, 0x4c, (byte) 0xa4, 0x01, 0x4c, 0x39, 0x02, 0x4c,
            0x40, 0x02, 0x4c, 0x44, 0x02, 0x4c, 0x4e, 0x02, 0x4c, 0x58, 0x02, 0x4c,
            (byte) 0x8e, 0x02, 0x4c, (byte) 0xd9, 0x02, 0x4c, (byte) 0xd9, 0x02, (byte) 0x8d, 0x02, (byte) 0xde, (byte) 0xa9,
            (byte) 0xaa, (byte) 0x8d, 0x55, (byte) 0x85, (byte) 0xa9, 0x55, (byte) 0x8d, (byte) 0xaa, (byte) 0x82, (byte) 0xa9, (byte) 0xa0, (byte) 0x8d,
            0x55, (byte) 0x85, (byte) 0xad, (byte) 0xf2, (byte) 0xdf, (byte) 0x8d, 0x00, (byte) 0xde, (byte) 0xa9, 0x00, (byte) 0x8d, (byte) 0xff,
            (byte) 0xff, (byte) 0xa2, 0x07, (byte) 0x8e, 0x02, (byte) 0xde, 0x60, (byte) 0x8d, 0x02, (byte) 0xde, (byte) 0xa9, (byte) 0xaa,
            (byte) 0x8d, 0x55, (byte) 0xe5, (byte) 0xa9, 0x55, (byte) 0x8d, (byte) 0xaa, (byte) 0xe2, (byte) 0xa9, (byte) 0xa0, (byte) 0x8d, 0x55,
            (byte) 0xe5, (byte) 0xd0, (byte) 0xdb, (byte) 0xa2, 0x55, (byte) 0x8e, (byte) 0xe3, (byte) 0xdf, (byte) 0x8c, (byte) 0xe4, (byte) 0xdf, (byte) 0xa2,
            (byte) 0x85, (byte) 0x8e, 0x02, (byte) 0xde, (byte) 0x8d, (byte) 0xff, (byte) 0xff, 0x4c, (byte) 0xbb, (byte) 0xdf, (byte) 0xad, (byte) 0xff,
            (byte) 0xff, 0x60, (byte) 0xcd, (byte) 0xff, (byte) 0xff, 0x60, (byte) 0xa2, 0x6f, (byte) 0xa0, 0x7f, (byte) 0xb1, 0x4b,
            (byte) 0x9d, (byte) 0x80, (byte) 0xdf, (byte) 0xdd, (byte) 0x80, (byte) 0xdf, (byte) 0xd0, 0x21, (byte) 0x88, (byte) 0xca, 0x10, (byte) 0xf2,
            (byte) 0xa2, 0x00, (byte) 0xe8, 0x18, (byte) 0xbd, (byte) 0x80, (byte) 0xdf, 0x65, 0x4b, (byte) 0x9d, (byte) 0x80, (byte) 0xdf,
            (byte) 0xe8, (byte) 0xbd, (byte) 0x80, (byte) 0xdf, 0x65, 0x4c, (byte) 0x9d, (byte) 0x80, (byte) 0xdf, (byte) 0xe8, (byte) 0xe0, 0x1e,
            (byte) 0xd0, (byte) 0xe8, 0x18, (byte) 0x90, 0x06, (byte) 0xa9, 0x01, (byte) 0x8d, (byte) 0xb9, (byte) 0xdf, 0x38, 0x68,
            (byte) 0x85, 0x4c, 0x68, (byte) 0x85, 0x4b, (byte) 0xb0, 0x48, (byte) 0xa9, (byte) 0xaa, (byte) 0xa0, (byte) 0xe5, 0x20,
            (byte) 0xd5, (byte) 0xdf, (byte) 0xa0, (byte) 0x85, 0x20, (byte) 0xd5, (byte) 0xdf, (byte) 0xa9, 0x55, (byte) 0xa2, (byte) 0xaa, (byte) 0xa0,
            (byte) 0xe2, 0x20, (byte) 0xd7, (byte) 0xdf, (byte) 0xa2, (byte) 0xaa, (byte) 0xa0, (byte) 0x82, 0x20, (byte) 0xd7, (byte) 0xdf, (byte) 0xa9,
            (byte) 0x90, (byte) 0xa0, (byte) 0xe5, 0x20, (byte) 0xd5, (byte) 0xdf, (byte) 0xa0, (byte) 0x85, 0x20, (byte) 0xd5, (byte) 0xdf, (byte) 0xad,
            0x00, (byte) 0xa0, (byte) 0x8d, (byte) 0xf1, (byte) 0xdf, (byte) 0xae, 0x01, (byte) 0xa0, (byte) 0x8e, (byte) 0xb9, (byte) 0xdf, (byte) 0xc9,
            0x01, (byte) 0xd0, 0x06, (byte) 0xe0, (byte) 0xa4, (byte) 0xd0, 0x02, (byte) 0xf0, 0x0c, (byte) 0xc9, 0x20, (byte) 0xd0,
            0x39, (byte) 0xe0, (byte) 0xe2, (byte) 0xd0, 0x35, (byte) 0xf0, 0x02, (byte) 0xb0, 0x50, (byte) 0xad, 0x00, (byte) 0x80,
            (byte) 0xae, 0x01, (byte) 0x80, (byte) 0xc9, 0x01, (byte) 0xd0, 0x06, (byte) 0xe0, (byte) 0xa4, (byte) 0xd0, 0x02, (byte) 0xf0,
            0x08, (byte) 0xc9, 0x20, (byte) 0xd0, 0x19, (byte) 0xe0, (byte) 0xe2, (byte) 0xd0, 0x15, (byte) 0xa0, 0x3f, (byte) 0x8c,
            0x00, (byte) 0xde, (byte) 0xae, 0x02, (byte) 0x80, (byte) 0xd0, 0x13, (byte) 0xae, 0x02, (byte) 0xa0, (byte) 0xd0, 0x12,
            (byte) 0x88, 0x10, (byte) 0xf0, 0x18, (byte) 0x90, 0x12, (byte) 0xa9, 0x02, (byte) 0xd0, 0x0a, (byte) 0xa9, 0x03,
            (byte) 0xd0, 0x06, (byte) 0xa9, 0x04, (byte) 0xd0, 0x02, (byte) 0xa9, 0x05, (byte) 0x8d, (byte) 0xb9, (byte) 0xdf, 0x38,
            (byte) 0xa9, 0x00, (byte) 0x8d, 0x00, (byte) 0xde, (byte) 0xa0, (byte) 0xe0, (byte) 0xa9, (byte) 0xf0, 0x20, (byte) 0xd7, (byte) 0xdf,
            (byte) 0xa0, (byte) 0x80, 0x20, (byte) 0xd7, (byte) 0xdf, (byte) 0xad, (byte) 0xb9, (byte) 0xdf, (byte) 0xb0, 0x08, (byte) 0xae, (byte) 0xf1,
            (byte) 0xdf, (byte) 0xa0, 0x40, 0x28, 0x18, 0x60, 0x28, 0x38, 0x60, (byte) 0x8d, (byte) 0xb7, (byte) 0xdf,
            (byte) 0x8e, (byte) 0xb9, (byte) 0xdf, (byte) 0x8e, (byte) 0xed, (byte) 0xdf, (byte) 0x8c, (byte) 0xba, (byte) 0xdf, 0x08, 0x78, (byte) 0x98,
            0x29, (byte) 0xbf, (byte) 0x8d, (byte) 0xee, (byte) 0xdf, (byte) 0xa9, 0x00, (byte) 0x8d, 0x00, (byte) 0xde, (byte) 0xa9, (byte) 0x85,
            (byte) 0xc0, (byte) 0xe0, (byte) 0x90, 0x05, 0x20, (byte) 0xc1, (byte) 0xdf, (byte) 0xb0, 0x03, 0x20, (byte) 0x9e, (byte) 0xdf,
            (byte) 0xa2, 0x14, 0x20, (byte) 0xec, (byte) 0xdf, (byte) 0xf0, 0x06, (byte) 0xca, (byte) 0xd0, (byte) 0xf8, 0x18, (byte) 0x90,
            0x63, (byte) 0xad, (byte) 0xf2, (byte) 0xdf, (byte) 0x8d, 0x00, (byte) 0xde, 0x18, (byte) 0x90, 0x72, (byte) 0x8d, (byte) 0xb7,
            (byte) 0xdf, (byte) 0x8e, (byte) 0xb9, (byte) 0xdf, (byte) 0x8c, (byte) 0xba, (byte) 0xdf, 0x08, 0x78, (byte) 0x98, (byte) 0xc0, (byte) 0x80,
            (byte) 0xf0, 0x04, (byte) 0xa0, (byte) 0xe0, (byte) 0xa9, (byte) 0xa0, (byte) 0x8d, (byte) 0xee, (byte) 0xdf, (byte) 0xc8, (byte) 0xc8, (byte) 0xc8,
            (byte) 0xc8, (byte) 0xc8, (byte) 0xa9, (byte) 0xaa, 0x20, (byte) 0xd5, (byte) 0xdf, (byte) 0xa9, 0x55, (byte) 0xa2, (byte) 0xaa, (byte) 0x88,
            (byte) 0x88, (byte) 0x88, 0x20, (byte) 0xd7, (byte) 0xdf, (byte) 0xa9, (byte) 0x80, (byte) 0xc8, (byte) 0xc8, (byte) 0xc8, 0x20, (byte) 0xd5,
            (byte) 0xdf, (byte) 0xa9, (byte) 0xaa, 0x20, (byte) 0xd5, (byte) 0xdf, (byte) 0xa9, 0x55, (byte) 0xa2, (byte) 0xaa, (byte) 0x88, (byte) 0x88,
            (byte) 0x88, 0x20, (byte) 0xd7, (byte) 0xdf, (byte) 0xad, (byte) 0xb7, (byte) 0xdf, (byte) 0x8d, 0x00, (byte) 0xde, (byte) 0xa2, 0x00,
            (byte) 0x8e, (byte) 0xed, (byte) 0xdf, (byte) 0x88, (byte) 0x88, (byte) 0xa9, 0x30, 0x20, (byte) 0xd7, (byte) 0xdf, (byte) 0xa9, (byte) 0xff,
            (byte) 0xaa, (byte) 0xa8, (byte) 0xd0, 0x24, (byte) 0xad, (byte) 0xf2, (byte) 0xdf, (byte) 0x8d, 0x00, (byte) 0xde, (byte) 0xa0, (byte) 0x80,
            (byte) 0xa9, (byte) 0xf0, 0x20, (byte) 0xd7, (byte) 0xdf, (byte) 0xa0, (byte) 0xe0, (byte) 0xa9, (byte) 0xf0, 0x20, (byte) 0xd7, (byte) 0xdf,
            0x28, 0x38, (byte) 0xb0, 0x02, 0x28, 0x18, (byte) 0xac, (byte) 0xba, (byte) 0xdf, (byte) 0xae, (byte) 0xb9, (byte) 0xdf,
            (byte) 0xad, (byte) 0xb7, (byte) 0xdf, 0x60, 0x20, (byte) 0xec, (byte) 0xdf, (byte) 0xf0, 0x09, (byte) 0xca, (byte) 0xd0, (byte) 0xf8,
            (byte) 0x88, (byte) 0xd0, (byte) 0xf5, 0x18, (byte) 0x90, (byte) 0xce, (byte) 0xad, (byte) 0xf2, (byte) 0xdf, (byte) 0x8d, 0x00, (byte) 0xde,
            0x18, (byte) 0x90, (byte) 0xdd, (byte) 0x8d, (byte) 0xf2, (byte) 0xdf, (byte) 0x8d, 0x00, (byte) 0xde, 0x60, (byte) 0xad, (byte) 0xf2,
            (byte) 0xdf, 0x60, (byte) 0x8d, (byte) 0xf3, (byte) 0xdf, (byte) 0x8e, (byte) 0xe9, (byte) 0xdf, (byte) 0x8c, (byte) 0xea, (byte) 0xdf, 0x60,
            (byte) 0x8e, (byte) 0xf4, (byte) 0xdf, (byte) 0x8c, (byte) 0xf5, (byte) 0xdf, (byte) 0x8d, (byte) 0xf6, (byte) 0xdf, 0x60, (byte) 0xad, (byte) 0xf2,
            (byte) 0xdf, (byte) 0x8d, 0x00, (byte) 0xde, 0x20, (byte) 0xe8, (byte) 0xdf, (byte) 0x8d, (byte) 0xb7, (byte) 0xdf, (byte) 0x8e, (byte) 0xf0,
            (byte) 0xdf, (byte) 0x8c, (byte) 0xf1, (byte) 0xdf, (byte) 0xa9, 0x00, (byte) 0x8d, (byte) 0xba, (byte) 0xdf, (byte) 0xf0, 0x3b, (byte) 0xad,
            (byte) 0xf4, (byte) 0xdf, (byte) 0xd0, 0x10, (byte) 0xad, (byte) 0xf5, (byte) 0xdf, (byte) 0xd0, 0x08, (byte) 0xad, (byte) 0xf6, (byte) 0xdf,
            (byte) 0xf0, 0x0b, (byte) 0xce, (byte) 0xf6, (byte) 0xdf, (byte) 0xce, (byte) 0xf5, (byte) 0xdf, (byte) 0xce, (byte) 0xf4, (byte) 0xdf, (byte) 0x90,
            0x45, 0x38, (byte) 0xb0, 0x42, (byte) 0x8d, (byte) 0xb7, (byte) 0xdf, (byte) 0x8e, (byte) 0xf0, (byte) 0xdf, (byte) 0x8c, (byte) 0xf1,
            (byte) 0xdf, (byte) 0xae, (byte) 0xe9, (byte) 0xdf, (byte) 0xad, (byte) 0xea, (byte) 0xdf, (byte) 0xc9, (byte) 0xa0, (byte) 0x90, 0x02, 0x09,
            0x40, (byte) 0xa8, (byte) 0xad, (byte) 0xb7, (byte) 0xdf, 0x20, (byte) 0x80, (byte) 0xdf, (byte) 0xb0, 0x24, (byte) 0xee, (byte) 0xe9,
            (byte) 0xdf, (byte) 0xd0, 0x19, (byte) 0xee, (byte) 0xea, (byte) 0xdf, (byte) 0xad, (byte) 0xf3, (byte) 0xdf, 0x29, (byte) 0xe0, (byte) 0xcd,
            (byte) 0xea, (byte) 0xdf, (byte) 0xd0, 0x0c, (byte) 0xad, (byte) 0xf3, (byte) 0xdf, 0x0a, 0x0a, 0x0a, (byte) 0x8d, (byte) 0xea,
            (byte) 0xdf, (byte) 0xee, (byte) 0xf2, (byte) 0xdf, 0x18, (byte) 0xad, (byte) 0xba, (byte) 0xdf, (byte) 0xf0, (byte) 0xa1, (byte) 0xac, (byte) 0xf1,
            (byte) 0xdf, (byte) 0xae, (byte) 0xf0, (byte) 0xdf, (byte) 0xad, (byte) 0xb7, (byte) 0xdf, 0x60, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
    };

    private EasyFlashEapi() {
    }

    static void install(byte[] romh) {
        // EasyProg and VICE update this reserved area only when the image opts in.
        if (romh[0x1800] == 'e' && romh[0x1801] == 'a' && romh[0x1802] == 'p' && romh[0x1803] == 'i') {
            System.arraycopy(DATA, 0, romh, 0x1800, DATA.length);
        }
    }
}