Saw your question in my thread, and brought it here, to not be off-topic. As usual, the answer to your question is "by learning ASM".
As for the Battle Tower itself, there are several ways you could go about it. You could look at how Crystal Version does it, or you could make up something on your own. At the core of it, you'll want to come up with a way to randomize which trainers you encounter, and you'll most likely want to disable experience gains when inside the tower.
Disabling experience should be pretty simple, since there is already a check to disable experience if you are in a link battle. You could just add a new check after the existing one, that would check which map you're on and disable it if you're in the Battle Tower's battle room thing.
As for how I'm going to do it all in Red++, I'm still working out the specifics. What I've come up with so far is:
- The trainer will use one of the "variable overworld sprites" that I've added, so it can be customized to match the trainer by another routine that runs when the map is loaded.
- The trainer will be assigned to use the first entry (actually the only entry) in a class used only by the Battle Tower and potentially other battle facilities, like the Battle Tent or something.
- That class will point to a 10 byte structure in RAM that is identical to a normal trainer entry, but in RAM instead of ROM.
- The background routine will write a randomized trainer pic entry, a level entry appropriate to which challenge you are taking, and a randomized team (most likely randomized from different lists based on which type of trainer it is).
Then once the trainer's info has been customized in the background, all the player has to do is walk up to the person and talk to them, and it will start the battle like a normal trainer. Then you'd just need to do something like Gary does in Oak's lab to heal the player if they lose instead of blacking out, and take them back to the lobby of the Battle Tower.
I can't give you anything more specific than that, because I haven't worked out all the specifics yet. But it will probably be slightly complicated.