private void preloadMap(int mapBanks, int mapAddresses, int mapID) {

		if (maps[mapID] != null || mapID == 0xED || mapID == 0xFF) {
			return;
		}

		SubMap map = new SubMap();
		maps[mapID] = map;

		map.id = mapID;
		map.addr = calculateOffset(rom[mapBanks + mapID] & 0xFF,
				readWord(mapAddresses + mapID * 2));
		map.bank = bankOf(map.addr);

		map.header = new MapHeader();
		map.header.tileset_id = rom[map.addr] & 0xFF;
		map.header.map_h = rom[map.addr + 1] & 0xFF;
		map.header.map_w = rom[map.addr + 2] & 0xFF;
		map.header.map_ptr = calculateOffset(map.bank, readWord(map.addr + 3));
		map.header.text_ptr = calculateOffset(map.bank, readWord(map.addr + 5));
		map.header.script_ptr = calculateOffset(map.bank,
				readWord(map.addr + 7));
		map.header.connect_byte = rom[map.addr + 9] & 0xFF;

		int cb = map.header.connect_byte;
		map.n_cons = ((cb & 8) >> 3) + ((cb & 4) >> 2) + ((cb & 2) >> 1)
				+ (cb & 1);

		int cons_offset = map.addr + 10;

		map.cons = new Connection[map.n_cons];
		for (int i = 0; i < map.n_cons; i++) {
			int tcon_offs = cons_offset + i * 11;
			Connection con = new Connection();
			con.index = rom[tcon_offs] & 0xFF;
			con.connected_map = readWord(tcon_offs + 1);
			con.current_map = readWord(tcon_offs + 3);
			con.bigness = rom[tcon_offs + 5] & 0xFF;
			con.map_width = rom[tcon_offs + 6] & 0xFF;
			con.y_align = rom[tcon_offs + 7] & 0xFF;
			con.x_align = rom[tcon_offs + 8] & 0xFF;
			con.window = readWord(tcon_offs + 9);
			map.cons[i] = con;
			preloadMap(mapBanks, mapAddresses, con.index);
		}
		map.obj_addr = calculateOffset(map.bank, readWord(cons_offset
				+ map.n_cons * 11));

		// Read objects
		// +0 is the border tile (ignore)
		// +1 is warp count

		int n_warps = rom[map.obj_addr + 1] & 0xFF;
		int offs = map.obj_addr + 2;
		for (int i = 0; i < n_warps; i++) {
			// track this warp
			int to_map = rom[offs + 3] & 0xFF;
			preloadMap(mapBanks, mapAddresses, to_map);
			offs += 4;
		}

		// Now we're pointing to sign count
		int n_signs = rom[offs++] & 0xFF;
		offs += n_signs * 3;

		// Finally, entities, which contain the items
		map.itemOffsets = new ArrayList<Integer>();
		int n_entities = rom[offs++] & 0xFF;
		for (int i = 0; i < n_entities; i++) {
			// Read text ID
			int tid = rom[offs + 5] & 0xFF;
			if ((tid & (1 << 6)) > 0) {
				// trainer
				offs += 8;
			} else if ((tid & (1 << 7)) > 0 && (rom[offs + 6] != 0x00)) {
				// item
				map.itemOffsets.add(offs + 6);
				offs += 7;
			} else {
				// generic
				offs += 6;
			}
		}
	}