Search in sources :

Example 1 with Cartridge

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

Example 2 with Cartridge

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();
}
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 Cartridge

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;
}
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)

Example 4 with Cartridge

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

Example 5 with Cartridge

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

Aggregations

Cartridge (org.javatari.atari.cartridge.Cartridge)9 CartridgeFormatOption (org.javatari.atari.cartridge.CartridgeFormatOption)3 ROMFormatUnsupportedException (org.javatari.atari.cartridge.ROMFormatUnsupportedException)3 AccessControlException (java.security.AccessControlException)2 CartridgeFormat (org.javatari.atari.cartridge.CartridgeFormat)2 Console (org.javatari.atari.console.Console)2 Clipboard (java.awt.datatransfer.Clipboard)1 Transferable (java.awt.datatransfer.Transferable)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 FileContents (javax.jnlp.FileContents)1