Search in sources :

Example 1 with CartridgeFormatOption

use of org.javatari.atari.cartridge.CartridgeFormatOption 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);
}
Also used : Cartridge(org.javatari.atari.cartridge.Cartridge) CartridgeFormatOption(org.javatari.atari.cartridge.CartridgeFormatOption) ROMFormatUnsupportedException(org.javatari.atari.cartridge.ROMFormatUnsupportedException)

Example 2 with CartridgeFormatOption

use of org.javatari.atari.cartridge.CartridgeFormatOption 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();
}
Also used : Cartridge(org.javatari.atari.cartridge.Cartridge) Console(org.javatari.atari.console.Console) CartridgeFormatOption(org.javatari.atari.cartridge.CartridgeFormatOption) ROMFormatUnsupportedException(org.javatari.atari.cartridge.ROMFormatUnsupportedException)

Example 3 with CartridgeFormatOption

use of org.javatari.atari.cartridge.CartridgeFormatOption 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;
}
Also used : Cartridge(org.javatari.atari.cartridge.Cartridge) CartridgeFormat(org.javatari.atari.cartridge.CartridgeFormat) ArrayList(java.util.ArrayList) CartridgeFormatOption(org.javatari.atari.cartridge.CartridgeFormatOption) ROMFormatUnsupportedException(org.javatari.atari.cartridge.ROMFormatUnsupportedException)

Aggregations

Cartridge (org.javatari.atari.cartridge.Cartridge)3 CartridgeFormatOption (org.javatari.atari.cartridge.CartridgeFormatOption)3 ROMFormatUnsupportedException (org.javatari.atari.cartridge.ROMFormatUnsupportedException)3 ArrayList (java.util.ArrayList)1 CartridgeFormat (org.javatari.atari.cartridge.CartridgeFormat)1 Console (org.javatari.atari.console.Console)1