public final void addressWrite(int addr, int data) {

		/*  if ((addr >= 0xCFF8) && (addr <= 0xCFF8) && (running)) {
   System.out.println(hexWord(data) + " written to " + hexWord(addr) + " at " + hexWord(pc) + " bank " + cartridge.currentBank);
  }
  if ((addr >= 0xEFF8) && (addr <= 0xEFF8) && (running)) {
   System.out.println(hexWord(data) + " written to " + hexWord(addr) + " at " + hexWord(pc) + " bank " + cartridge.currentBank);
  }*/

		/*  if ((addr < 0) || (addr > 65535)) {
   System.out.println(hexWord(data) + " written to " + hexWord(addr) + " at " + hexWord(pc) + " bank " + cartridge.currentBank);
  }*/

		switch (addr & 0xF000) {
		case 0x0000 :
		case 0x1000 :
		case 0x2000 :
		case 0x3000 :
		case 0x4000 :
		case 0x5000 :
		case 0x6000 :
		case 0x7000 :
			if (!running) {
				cartridge.debuggerAddressWrite(addr, data);
			} else {
				cartridge.addressWrite(addr, data);
				//    System.out.println("Tried to write to ROM! PC = " + hexWord(pc) + ", Data = " + LowLevelData.hexByte(LowLevelData.unsign((byte) data)));
			}
			break;

		case 0x8000 :
		case 0x9000 :
			graphicsChip.addressWrite(addr - 0x8000, (byte) data);
			break;

		case 0xA000 :
		case 0xB000 :
			cartridge.addressWrite(addr, data);
			break;

		case 0xC000 :
			mainRam[addr - 0xC000] = (byte) data;
			break;

		case 0xD000 :
			mainRam[addr - 0xD000 + (gbcRamBank * 0x1000)] = (byte) data;
			break;

		case 0xE000 :
			mainRam[addr - 0xE000] = (byte) data;
			break;

		case 0xF000 :
			if (addr < 0xFE00) {
				try {
					mainRam[addr - 0xE000] = (byte) data;
				} catch (ArrayIndexOutOfBoundsException e) {
					System.out.println("Address error: " + addr + " pc = " + LowLevelData.hexWord(pc));
				}
			} else if (addr < 0xFF00) {
				oam[addr - 0xFE00] = (byte) data;
			} else {
				ioHandler.ioWrite(addr - 0xFF00, (short) data);
			}
			break;
		}


	}