// Path: javatari/src/org/javatari/utils/Terminator.java
// public final class Terminator {
// 
// 	public static void terminate() {
// 		if (Room.currentRoom() != null) Room.currentRoom().exit();
// 		throw new IllegalStateException("Emulator terminated");
// 	}
// 	
// }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import org.javatari.utils.Terminator;

// Copyright 2011-2012 Paulo Augusto Peccin. See licence.txt distributed with this file.

package org.javatari.pc.cartridge;




public class BuiltInROM {

	public BuiltInROM(String label, String labelColors, URL romURL) {
		super();
		this.label = label;
		this.labelColors = labelColors;
		this.url = romURL;
	}

	
	public static ArrayList<BuiltInROM> all() {
		ArrayList<BuiltInROM> result = new ArrayList<BuiltInROM>();
		InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(ROMS_FOLDER + "/" + ROMS_LIST_FILE);
		if (stream == null) return result;
				
		BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
		try {
			try {
				String line;
				while((line = reader.readLine()) != null) {
					line = line.trim();
					if (line.isEmpty() || line.startsWith("#")) continue;
					String[] specs = line.split("@");
					if (specs.length == 0) continue; 
					String location = specs[specs.length -1].trim();
					if (location.isEmpty()) continue; 
					// First try to find as resource
					URL url = fileNameAsResourceURL(location);
					if (url == null) {
						// If not try as URL directly
						try {
							url = new URL(location);
						} catch (Exception e) {
							errorMessage(location);

// Path: javatari/src/org/javatari/utils/Terminator.java
// public final class Terminator {
// 
// 	public static void terminate() {
// 		if (Room.currentRoom() != null) Room.currentRoom().exit();
// 		throw new IllegalStateException("Emulator terminated");
// 	}
// 	
// }


// Path: javatari/src/org/javatari/pc/cartridge/BuiltInROM.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import org.javatari.utils.Terminator;

// Copyright 2011-2012 Paulo Augusto Peccin. See licence.txt distributed with this file.

package org.javatari.pc.cartridge;




public class BuiltInROM {

	public BuiltInROM(String label, String labelColors, URL romURL) {
		super();
		this.label = label;
		this.labelColors = labelColors;
		this.url = romURL;
	}

	
	public static ArrayList<BuiltInROM> all() {
		ArrayList<BuiltInROM> result = new ArrayList<BuiltInROM>();
		InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(ROMS_FOLDER + "/" + ROMS_LIST_FILE);
		if (stream == null) return result;
				
		BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
		try {
			try {
				String line;
				while((line = reader.readLine()) != null) {
					line = line.trim();
					if (line.isEmpty() || line.startsWith("#")) continue;
					String[] specs = line.split("@");
					if (specs.length == 0) continue; 
					String location = specs[specs.length -1].trim();
					if (location.isEmpty()) continue; 
					// First try to find as resource
					URL url = fileNameAsResourceURL(location);
					if (url == null) {
						// If not try as URL directly
						try {
							url = new URL(location);
						} catch (Exception e) {
							errorMessage(location);

							Terminator.terminate();
