@Override
	public void setTrainerNames(List<String> trainerNames) {
		if (romEntry.getValue("CanChangeTrainerText") != 0) {
			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);
			}
			// Build up new trainer data using old as a guideline.
			int[] offsetsInNew = new int[traineramount + 1];
			int oInNewCurrent = 0;
			Iterator<String> allTrainers = trainerNames.iterator();
			ByteArrayOutputStream newData = new ByteArrayOutputStream();
			try {
				for (int i = 1; i <= traineramount; i++) {
					int offs = pointers[i];
					int limit = trainerclasslimits[i];
					offsetsInNew[i] = oInNewCurrent;
					for (int trnum = 0; trnum < limit; trnum++) {
						String name = readVariableLengthString(offs);
						String newName = allTrainers.next();
						byte[] newNameStr = translateString(newName);
						newData.write(newNameStr);
						newData.write(0x50);
						oInNewCurrent += newNameStr.length + 1;
						offs += internalStringLength(name) + 1;
						int dataType = rom[offs] & 0xFF;
						offs++;
						newData.write(dataType);
						oInNewCurrent++;
						while ((rom[offs] & 0xFF) != 0xFF) {
							newData.write(rom, offs, 2);
							oInNewCurrent += 2;
							offs += 2;
							if (dataType == 2 || dataType == 3) {
								newData.write(rom, offs, 1);
								oInNewCurrent += 1;
								offs++;
							}
							if (dataType % 2 == 1) {
								newData.write(rom, offs, 4);
								oInNewCurrent += 4;
								offs += 4;
							}
						}
						newData.write(0xFF);
						oInNewCurrent++;
						offs++;
					}
				}

				// Copy new data into ROM
				byte[] newTrainerData = newData.toByteArray();
				int tdBase = pointers[1];
				System.arraycopy(newTrainerData, 0, rom, pointers[1],
						newTrainerData.length);

				// Finally, update the pointers
				for (int i = 2; i <= traineramount; i++) {
					int newOffset = tdBase + offsetsInNew[i];
					writeWord(traineroffset + (i - 1) * 2,
							makeGBPointer(newOffset));
				}
			} catch (IOException ex) {
				// This should never happen, but abort if it does.
			}
		}

	}