feat: adds REU support to the system settings

This commit is contained in:
mikael.lantz 2021-02-05 10:30:19 +01:00
parent 901956a63d
commit e0b75056ca
2 changed files with 169 additions and 19 deletions

View File

@ -63,11 +63,15 @@ public class SystemPanel extends JPanel
private CardLayout cardLayout = new CardLayout(0, 0);
private final ButtonGroup audioGroup = new ButtonGroup();
private final ButtonGroup reuGroup = new ButtonGroup();
private SystemModel model;
private JCheckBox readOnlyCheckBox;
private JLabel displayShiftValueLabel;
private JPanel audioReuPanel;
private JPanel reuPanel;
private JCheckBox reu512kRadioButton;
private JCheckBox reu2mbRadioButton;
private JCheckBox reu16mbRadioButton;
public SystemPanel(SystemModel model)
{
@ -147,6 +151,9 @@ public class SystemPanel extends JPanel
getBank2CheckBox().setSelected(model.isBank2());
getBank3CheckBox().setSelected(model.isBank3());
getBank5CheckBox().setSelected(model.isBank5());
getReu512kRadioButton().setSelected(model.isREU512K());
getReu2mbRadioButton().setSelected(model.isREU2Mb());
getReu16mbRadioButton().setSelected(model.isREU16Mb());
getConfigTextField().setText(model.getConfigString());
getDisplayShiftComboBox().setSelectedItem(Integer.toString(model.getVerticalShift()));
@ -352,6 +359,30 @@ public class SystemPanel extends JPanel
{
reuPanel = new JPanel();
reuPanel.setBorder(new TitledBorder(null, "REU", TitledBorder.LEADING, TitledBorder.TOP, null, null));
GridBagLayout gbl_reuPanel = new GridBagLayout();
gbl_reuPanel.columnWidths = new int[]{0, 0};
gbl_reuPanel.rowHeights = new int[]{0, 0, 0, 0};
gbl_reuPanel.columnWeights = new double[]{0.0, Double.MIN_VALUE};
gbl_reuPanel.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
reuPanel.setLayout(gbl_reuPanel);
GridBagConstraints gbc_reu512kRadioButton = new GridBagConstraints();
gbc_reu512kRadioButton.anchor = GridBagConstraints.WEST;
gbc_reu512kRadioButton.insets = new Insets(0, 0, 0, 5);
gbc_reu512kRadioButton.gridx = 0;
gbc_reu512kRadioButton.gridy = 0;
reuPanel.add(getReu512kRadioButton(), gbc_reu512kRadioButton);
GridBagConstraints gbc_reu2mbRadioButton = new GridBagConstraints();
gbc_reu2mbRadioButton.anchor = GridBagConstraints.WEST;
gbc_reu2mbRadioButton.insets = new Insets(0, 0, 0, 5);
gbc_reu2mbRadioButton.gridx = 0;
gbc_reu2mbRadioButton.gridy = 1;
reuPanel.add(getReu2mbRadioButton(), gbc_reu2mbRadioButton);
GridBagConstraints gbc_reu16mbRadioButton = new GridBagConstraints();
gbc_reu16mbRadioButton.anchor = GridBagConstraints.WEST;
gbc_reu16mbRadioButton.insets = new Insets(0, 0, 0, 5);
gbc_reu16mbRadioButton.gridx = 0;
gbc_reu16mbRadioButton.gridy = 2;
reuPanel.add(getReu16mbRadioButton(), gbc_reu16mbRadioButton);
}
return reuPanel;
}
@ -436,8 +467,9 @@ public class SystemPanel extends JPanel
gbc_bank5CheckBox.gridy = 4;
ramPanel.add(getBank5CheckBox(), gbc_bank5CheckBox);
GridBagConstraints gbc_ramLabel = new GridBagConstraints();
gbc_ramLabel.weighty = 1.0;
gbc_ramLabel.insets = new Insets(0, 5, 10, 5);
gbc_ramLabel.anchor = GridBagConstraints.WEST;
gbc_ramLabel.anchor = GridBagConstraints.NORTHWEST;
gbc_ramLabel.weightx = 1.0;
gbc_ramLabel.gridx = 0;
gbc_ramLabel.gridy = 5;
@ -885,4 +917,43 @@ public class SystemPanel extends JPanel
}
return displayShiftValueLabel;
}
private JCheckBox getReu512kRadioButton() {
if (reu512kRadioButton == null) {
reu512kRadioButton = new JCheckBox("512K RAM Expansion Unit ");
reu512kRadioButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
model.setREU512K(reu512kRadioButton.isSelected());
model.setREU2Mb(false);
model.setREU16Mb(false);
}
});
}
return reu512kRadioButton;
}
private JCheckBox getReu2mbRadioButton() {
if (reu2mbRadioButton == null) {
reu2mbRadioButton = new JCheckBox("2Mb RAM Expansion Unit");
reu2mbRadioButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
model.setREU2Mb(reu2mbRadioButton.isSelected());
model.setREU512K(false);
model.setREU16Mb(false);
}
});
}
return reu2mbRadioButton;
}
private JCheckBox getReu16mbRadioButton() {
if (reu16mbRadioButton == null) {
reu16mbRadioButton = new JCheckBox("16Mb RAM Expansion Unit");
reu16mbRadioButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
model.setREU16Mb(reu16mbRadioButton.isSelected());
model.setREU512K(false);
model.setREU2Mb(false);
}
});
}
return reu16mbRadioButton;
}
}

View File

@ -4,24 +4,27 @@ import java.util.ArrayList;
public class SystemModel extends AbstractModel
{
private final static String C64 = "64";
private final static String VIC = "vic";
private final static String PAL = "pal";
private final static String NTSC = "ntsc";
private final static String DRIVEICON = "driveicon";
private final static String ACCURATEDISK = "accuratedisk";
private final static String READONLY = "readonly";
private final static String FULLHEIGHT = "fullheight";
private final static String SID6581 = "sid6581";
private final static String SID8580 = "sid8580";
private final static String SID8580D = "sid8580D";
private final static String NOAUDIOSCALE = "noaudioscale";
private final static String BANK0 = "bank0";
private final static String BANK1 = "bank1";
private final static String BANK2 = "bank2";
private final static String BANK3 = "bank3";
private final static String BANK5 = "bank5";
private final static String BASIC = "basic";
private static final String C64 = "64";
private static final String VIC = "vic";
private static final String PAL = "pal";
private static final String NTSC = "ntsc";
private static final String DRIVEICON = "driveicon";
private static final String ACCURATEDISK = "accuratedisk";
private static final String READONLY = "readonly";
private static final String FULLHEIGHT = "fullheight";
private static final String SID6581 = "sid6581";
private static final String SID8580 = "sid8580";
private static final String SID8580D = "sid8580D";
private static final String NOAUDIOSCALE = "noaudioscale";
private static final String BANK0 = "bank0";
private static final String BANK1 = "bank1";
private static final String BANK2 = "bank2";
private static final String BANK3 = "bank3";
private static final String BANK5 = "bank5";
private static final String BASIC = "basic";
private static final String REU512K = "reu512";
private static final String REU2MB = "reu2048";
private static final String REU16MB = "reu16384";
//TODO Support for 3K, 4K etc as aliases for Banks
//TODO vertical shift
@ -44,6 +47,9 @@ public class SystemModel extends AbstractModel
private boolean bank3 = false;
private boolean bank5 = false;
private boolean basic = false;
private boolean reu512K = false;
private boolean reu2Mb = false;
private boolean reu16Mb = false;
private int verticalShift = 0;
public SystemModel()
@ -104,6 +110,18 @@ public class SystemModel extends AbstractModel
{
list.add(NOAUDIOSCALE);
}
if (isREU512K())
{
list.add(REU512K);
}
if (isREU2Mb())
{
list.add(REU2MB);
}
if (isREU16Mb())
{
list.add(REU16MB);
}
}
else
{
@ -173,6 +191,10 @@ public class SystemModel extends AbstractModel
setBank2(false);
setBank3(false);
setBank5(false);
setBasic(false);
setREU512K(false);
setREU2Mb(false);
setREU16Mb(false);
}
public void setConfigString(String configString)
@ -250,6 +272,18 @@ public class SystemModel extends AbstractModel
{
setBank5(true);
}
else if (flag.equals(REU512K))
{
setREU512K(true);
}
else if (flag.equals(REU2MB))
{
setREU2Mb(true);
}
else if (flag.equals(REU16MB))
{
setREU16Mb(true);
}
else if (flag.equals(BASIC))
{
setBasic(true);
@ -564,6 +598,51 @@ public class SystemModel extends AbstractModel
}
}
public boolean isREU512K()
{
return reu512K;
}
public void setREU512K(boolean reu)
{
boolean old = isREU512K();
this.reu512K = reu;
if ((Boolean.compare(old, reu) != 0))
{
notifyChange();
}
}
public boolean isREU2Mb()
{
return reu2Mb;
}
public void setREU2Mb(boolean reu)
{
boolean old = isREU2Mb();
this.reu2Mb = reu;
if ((Boolean.compare(old, reu) != 0))
{
notifyChange();
}
}
public boolean isREU16Mb()
{
return reu16Mb;
}
public void setREU16Mb(boolean reu)
{
boolean old = isREU16Mb();
this.reu16Mb = reu;
if ((Boolean.compare(old, reu) != 0))
{
notifyChange();
}
}
public int getVerticalShift()
{
return verticalShift;