public Cartridge(String romFileName) {
		/* 5823 */
		this.romFileName = romFileName;
		InputStream is = null;
		try {
			/*   if (runningAsApplet) {
    Applet myApplet = (Applet) a;
    is = new URL(myApplet.getDocumentBase(), romFileName).openStream();
   } else {
    is = new FileInputStream(new File(romFileName));
   }*/
			is = openRom(romFileName);//, a);
			byte[] firstBank = new byte[0x04000];

			int total = 0x04000;
			do {
				total -= is.read(firstBank, 0x04000 - total, total);      // Read the first bank (bank 0)
			} while (total > 0);

			cartType = firstBank[0x0147];

			numBanks = lookUpCartSize(firstBank[0x0148]);   // Determine the number of 16kb rom banks

			//   is.close();
			//   is = new FileInputStream(new File(romFileName));
			rom = new byte[0x04000 * numBanks];   // Recreate the ROM array with the correct size

			// Copy first bank into main rom array
			for (int r = 0; r < 0x4000; r++) {
				rom[r] = firstBank[r];
			}

			total = 0x04000 * (numBanks - 1);           // Calculate total ROM size (first one already loaded)
			do {                                  // Read ROM into memory
				total -= is.read(rom, rom.length - total, total); // Read the entire ROM
			} while (total > 0);
			is.close();

			Logger.log("Loaded ROM '" + romFileName + "'.  " + numBanks + " banks, " + (numBanks * 16) + "Kb.  " + getNumRAMBanks() + " RAM banks.");
			Logger.log("Type: " + cartTypeTable[cartType] + " (" + LowLevelData.hexByte(cartType) + ")");


			if (!verifyChecksum()){ 
				System.out.println("This cartridge has an invalid checksum.");
			}

			// Set up the real time clock
			Calendar rightNow = Calendar.getInstance();

			int days = rightNow.get(Calendar.DAY_OF_YEAR);
			int hour = rightNow.get(Calendar.HOUR_OF_DAY);
			int minute = rightNow.get(Calendar.MINUTE);
			int second = rightNow.get(Calendar.SECOND);

			RTCReg[SECONDS] = second;
			RTCReg[MINUTES] = minute;
			RTCReg[HOURS] = hour;
			RTCReg[DAYS_LO] = days & 0x00FF;
			RTCReg[DAYS_HI] = (days & 0x01FF) >> 8;

			realTimeStart = System.currentTimeMillis();
			lastSecondIncrement = realTimeStart;


			cartridgeReady = true;

		} catch (IOException e) {
			System.out.println("Error opening ROM image '" + romFileName + "'!");
		} catch (IndexOutOfBoundsException e) {
			/*new ModalDialog((Frame) a, "Error",
					"Loading the ROM image failed.",
			"The file is not a valid Gameboy ROM.");*/
			System.out.println("Loading the ROM image failed.");
		}

	}