VICChipModel.java

package libsidplay.common;

/**
 * VIC chip identities and existing luminance profiles.
 * <p>
 * A configured identity is not a claim that every revision-specific behavior
 * has been implemented. C64 applies the supported timing rules from this
 * identity, including MOS8562 D021 grey dots; palette selection remains independent.
 */
public enum VICChipModel {
    /**
     * Old NTSC (Early NTSC VIC-II, found in pre-1983 C64s in North America)
     */
    MOS6567R56A(CPUClock.NTSC,
            new float[]{560, 1825, 840, 1500, 1180, 1180, 840, 1500, 1180, 840, 1180, 840, 1180, 1500, 1180, 1500}),
    /**
     * NTSC (Final NTSC VIC-II used in most US/Canada C64s)
     */
    MOS6567R8(CPUClock.NTSC,
            new float[]{590, 1825, 950, 1380, 1030, 1210, 860, 1560, 1030, 860, 1210, 950, 1160, 1560, 1160, 1380}),
    /**
     * PAL (Very early PAL chip, rare)
     */
    MOS6569R1(CPUClock.PAL,
            new float[]{630, 1850, 900, 1560, 1260, 1260, 900, 1560, 1260, 900, 1260, 900, 1260, 1560, 1260, 1560}),
    /**
     * PAL (Common early PAL chip)
     */
    MOS6569R3(CPUClock.PAL, new float[]{700, 1850, 1090, 1480, 1180, 1340, 1020, 1620, 1180, 1020, 1340, 1090, 1300, 1620, 1300,
            1480}),
    /**
     * PAL (Common PAL chip)
     */
    MOS6569R4(CPUClock.PAL, new float[]{500, 1875, 840, 1300, 920, 1100, 760, 1500, 920, 760, 1100, 840, 1050, 1500, 1050, 1300}),
    /**
     * PAL (Latest PAL VIC-II, found in later C64s sold in Europe)
     */
    MOS6569R5(CPUClock.PAL, new float[]{540, 1850, 900, 1340, 980, 1150, 810, 1520, 980, 810, 1150, 900, 1110, 1520, 1110, 1340}),
    /**
     * New PAL VIC-II, with the implemented grey-dot, sprite-write and lightpen
     * trigger behavior selected by C64. No separate measured luminance table is supplied;
     * the legacy palette API explicitly falls back to MOS6569R3.
     */
    MOS8565(CPUClock.PAL, MOS6569R3),
    /**
     * New NTSC VIC-II default identity for C64C, with D021 grey-dot behavior.
     * Other timing rules retain the MOS6567R8 fallback. No separate measured
     * luminance table is supplied; the legacy palette API falls back to MOS6567R8.
     */
    MOS8562(CPUClock.NTSC, MOS6567R8);

    private final CPUClock clock;
    private final float[] luminances;
    private final VICChipModel luminanceSource;

    VICChipModel(CPUClock clock, float[] luminances) {
        this.clock = clock;
        this.luminances = luminances;
        this.luminanceSource = this;
    }

    VICChipModel(CPUClock clock, VICChipModel luminanceSource) {
        this.clock = clock;
        // Do not share the mutable array with an existing palette profile.
        this.luminances = luminanceSource.getLuminances().clone();
        this.luminanceSource = luminanceSource;
    }

    /**
     * Video-standard family of the chip. NTSC here does not imply that the
     * early MOS6567R56A has the same raster timing as MOS6567R8.
     */
    public CPUClock getClock() {
        return clock;
    }

    /**
     * Profile supplying the legacy luminance data. Returns this for an
     * original profile, or the explicitly documented fallback for a new target.
     * This does not select or change the active PAL renderer's palette.
     */
    public VICChipModel getLuminanceSource() {
        return luminanceSource;
    }

    /**
     * Voltage by color (0x0-0x0F)
     *
     * <pre>
     * <a href="http://www.zimmers.net/anonftp/pub/cbm/documents/chipdata/656x-luminances.txt">656x-luminances.txt</a>
     * </pre>
     */
    public float[] getLuminances() {
        return luminances;
    }
}