public InputStream openRom(String romFileName) {
		byte bFormat;
		boolean bFoundGBROM = false;
		//String romName = "None";

		if (romFileName.toUpperCase().indexOf("ZIP") > -1) {
			bFormat = bZip;
		} else if (romFileName.toUpperCase().indexOf("JAR") > -1) {
			bFormat = bZip;
		} else if (romFileName.toUpperCase().indexOf("GZ") > -1) {
			bFormat = bGZip;
		} else {
			bFormat = bNotCompressed;
		}

		// Simplest case, open plain gb or gbc file.
		if (bFormat == bNotCompressed) {
			try {
				romIntFileName = stripExtention(romFileName);

				return new FileInputStream(new File(romFileName));
				//}
			} catch (Exception e) {
				System.out.println("Cant open file");
				return null;
			}
		}

		// Should the ROM be loaded from a ZIP compressed file?
		if (bFormat == bZip) { 
			System.out.println("Loading ZIP Compressed ROM");

			java.util.zip.ZipInputStream zip;

			try {

				zip = new java.util.zip.ZipInputStream(new java.net.URL(romFileName).openStream());


				// Check for valid files (GB or GBC ending in filename)
				java.util.zip.ZipEntry ze;

				while ((ze = zip.getNextEntry()) != null) {
					String str = ze.getName();
					if (str.toUpperCase().indexOf(".GB") > -1 || str.toUpperCase().indexOf(".GBC") > -1) {
						bFoundGBROM = true;
						romIntFileName = stripExtention(str);
						//romName = str;
						// Leave loop if a ROM was found.
						break;
					}
				}
				// Show an error if no ROM file was found in the ZIP
				if (!bFoundGBROM) {

					//new ModalDialog((Frame) a, "Error", "No GBx ROM found!", "");

					System.err.println("No GBx ROM found!");
					throw new java.io.IOException("ERROR");
				}

				return zip;
			} catch (Exception e) {
				System.out.println(e);
				return null;
			}
		}

		if (bFormat == bGZip) {
			System.out.println("Loading GZIP Compressed ROM");
			romIntFileName = stripExtention(romFileName);
			try {

				//return new java.util.zip.GZIPInputStream(new java.net.URL(((Applet) (a)).getDocumentBase(), romFileName).openStream());
				return new java.util.zip.GZIPInputStream( new java.util.zip.ZipInputStream(new java.net.URL(romFileName).openStream()));
			} catch (Exception e) {
				System.out.println("Can't open file");
				return null;
			}
		}

		// Will never get here
		return null;
	}