use of org.javatari.atari.cartridge.Cartridge in project javatari by ppeccin.
the class Console method cycleCartridgeFormat.
protected void cycleCartridgeFormat() {
if (cartridge() == null) {
showOSD("NO CARTRIDGE INSERTED!", true);
return;
}
ArrayList<CartridgeFormatOption> options;
try {
options = CartridgeDatabase.getFormatOptions(cartridge().rom());
} catch (ROMFormatUnsupportedException e) {
return;
}
CartridgeFormatOption currOption = null;
for (CartridgeFormatOption option : options) if (option.format.equals(cartridge().format()))
currOption = option;
// cycle through options
int pos = options.indexOf(currOption) + 1;
if (pos >= options.size())
pos = 0;
CartridgeFormatOption newOption = options.get(pos);
Cartridge newCart = newOption.format.createCartridge(cartridge().rom());
cartridgeSocket().insert(newCart, true);
showOSD(newOption.format.toString(), true);
}
use of org.javatari.atari.cartridge.Cartridge in project javatari by ppeccin.
the class JComboBoxNim method cartridgeAutoDetect.
private void cartridgeAutoDetect() {
Console console = room.currentConsole();
Cartridge cart = console.cartridgeSocket().inserted();
if (cart == null)
return;
ArrayList<CartridgeFormatOption> options;
try {
options = CartridgeDatabase.getFormatOptions(cart.rom());
} catch (ROMFormatUnsupportedException e) {
return;
}
Cartridge newCart = options.get(0).format.createCartridge(cart.rom());
console.cartridgeSocket().insert(newCart, true);
refreshCartridge();
}
use of org.javatari.atari.cartridge.Cartridge in project javatari by ppeccin.
the class JComboBoxNim method refreshCartridge.
private void refreshCartridge() {
if (refreshInProgress)
return;
refreshInProgress = true;
if (room.currentConsole().cartridgeSocket().inserted() == null) {
romNameTf.setText("<NO CARTRIDGE INSERTED>");
romFormatLb.setListData(new Object[0]);
romFormatLb.setEnabled(false);
defaultsB.setVisible(false);
} else {
Cartridge cart = room.currentConsole().cartridgeSocket().inserted();
romNameTf.setText(cart.rom().info.name);
romNameTf.setCaretPosition(0);
ArrayList<CartridgeFormat> formats = new ArrayList<CartridgeFormat>();
try {
ArrayList<CartridgeFormatOption> formatOptions;
formatOptions = CartridgeDatabase.getFormatOptions(cart.rom());
for (CartridgeFormatOption option : formatOptions) formats.add(option.format);
} catch (ROMFormatUnsupportedException e) {
// Leave formats empty
}
if (!formats.contains(cart.format()))
formats.add(0, cart.format());
romFormatLb.setListData(formats.toArray());
romFormatLb.setSelectedValue(cart.format(), true);
romFormatLb.setEnabled(!formats.isEmpty() && !room.isClientMode());
defaultsB.setText("Auto Detect");
defaultsB.setVisible(!room.isClientMode());
}
refreshInProgress = false;
}
use of org.javatari.atari.cartridge.Cartridge in project javatari by ppeccin.
the class JComboBoxNim method romFormatLbAction.
private void romFormatLbAction() {
Object sel = romFormatLb.getSelectedValue();
if (sel == null || !(sel instanceof CartridgeFormat))
return;
CartridgeFormat format = (CartridgeFormat) sel;
Console console = room.currentConsole();
Cartridge cart = console.cartridgeSocket().inserted();
if (cart == null || cart.format().equals(format))
return;
Cartridge newCart = format.createCartridge(cart.rom());
console.cartridgeSocket().insert(newCart, true);
}
use of org.javatari.atari.cartridge.Cartridge in project javatari by ppeccin.
the class Room method morphToServerMode.
public void morphToServerMode() {
if (isServerMode())
return;
powerOff();
Cartridge lastCartridge = isClientMode() ? cartridgeProvided : currentConsole.cartridgeSocket().inserted();
if (serverConsole == null)
buildAndPlugServerConsole();
else
plugConsole(serverConsole);
adjustPeripheralsToStandaloneOrServerOperation();
currentConsole.cartridgeSocket().insert(lastCartridge, false);
powerOn();
}
Aggregations