ChipModel.java
package libsidplay.common;
import libsidplay.config.IEmulationSection;
import libsidplay.sidtune.SidTune;
import libsidplay.sidtune.SidTune.Model;
import static libsidplay.config.ISidPlay2SystemProperties.MAX_SIDS;
import static libsidplay.sidtune.SidTune.Model.UNKNOWN;
import static libsidplay.sidtune.SidTune.RESET;
/**
* SID chip model
*
*/
public enum ChipModel {
/**
* Auto-detect SID model
*/
AUTO,
/**
* SID chip of the old C64
*/
MOS6581,
/**
* SID chip of the new C64
*/
MOS8580;
/**
* Detect a chip model of specified SID number in the following order:
* <OL>
* <LI>chip model forced by user configuration
* <LI>chip model detected by tune recognition WhatsSID
* <LI>chip model provided by tune information and if unknown, then
* <LI>default chip model for the 1st SID and for 2nd or 3rd chip use the same
* chip model as for the 1st SID
* </OL>
*
* @return chip model to be used for SID number 0..MAX_SIDS-1
*/
public static ChipModel getChipModel(IEmulationSection emulation, SidTune tune, int sidNum) {
ChipModel forcedChipModel = emulation.getForcedSidModel(sidNum);
ChipModel overrideSidModel = emulation.getOverrideSection().getSidModel()[sidNum];
Model tuneSidModel;
ChipModel defaultSidModel;
switch (sidNum) {
case 0:
tuneSidModel = tune != RESET ? tune.getInfo().getSIDModel(0) : UNKNOWN;
defaultSidModel = emulation.getDefaultSidModel();
break;
case 1:
case 2:
default:
if (sidNum < MAX_SIDS) {
tuneSidModel = tune != RESET ? tune.getInfo().getSIDModel(sidNum) : UNKNOWN;
defaultSidModel = getChipModel(emulation, tune, 0);
break;
}
throw new RuntimeException("Maximum supported SIDS exceeded!");
}
if (forcedChipModel != AUTO) {
return forcedChipModel;
}
if (overrideSidModel != null) {
return overrideSidModel;
}
switch (tuneSidModel) {
case MOS6581:
case MOS8580:
return tuneSidModel.asChipModel();
case UNKNOWN:
default:
return defaultSidModel;
}
}
}