@Override
	public void setTrainers(List<Trainer> trainerData) {
		int traineroffset = romEntry.getValue("TrainerDataTableOffset");
		int traineramount = romEntry.getValue("TrainerClassAmount");
		int[] trainerclasslimits = romEntry.arrayEntries
				.get("TrainerDataClassCounts");

		int[] pointers = new int[traineramount + 1];
		for (int i = 1; i <= traineramount; i++) {
			int pointer = readWord(traineroffset + (i - 1) * 2);
			pointers[i] = calculateOffset(bankOf(traineroffset), pointer);
		}

		Iterator<Trainer> allTrainers = trainerData.iterator();
		for (int i = 1; i <= traineramount; i++) {
			int offs = pointers[i];
			int limit = trainerclasslimits[i];
			for (int trnum = 0; trnum < limit; trnum++) {
				Trainer tr = allTrainers.next();
				if (tr.trainerclass != i) {
					System.err.println("Trainer mismatch: " + tr.name);
				}
				// Write their name
				int trnamelen = internalStringLength(tr.name);
				writeFixedLengthString(tr.name, offs, trnamelen + 1);
				offs += trnamelen + 1;
				// Poketype
				tr.poketype = 0; // remove held items and moves
				rom[offs++] = (byte) tr.poketype;
				Iterator<TrainerPokemon> tPokes = tr.pokemon.iterator();
				for (int tpnum = 0; tpnum < tr.pokemon.size(); tpnum++) {
					TrainerPokemon tp = tPokes.next();
					rom[offs] = (byte) tp.level;
					rom[offs + 1] = (byte) tp.pokemon.number;
					offs += 2;
					if (tr.poketype == 2 || tr.poketype == 3) {
						rom[offs] = (byte) tp.heldItem;
						offs++;
					}
					if (tr.poketype % 2 == 1) {
						rom[offs] = (byte) tp.move1;
						rom[offs + 1] = (byte) tp.move2;
						rom[offs + 2] = (byte) tp.move3;
						rom[offs + 3] = (byte) tp.move4;
						offs += 4;
					}
				}
				rom[offs] = (byte) 0xFF;
				offs++;
			}
		}

	}