To add onto the Wormhole Encounters info, here's a table for the Legendaries:
I may need to edit the yellow wormhole Pokemon but I'm pretty sure they're correct. The slots are correct.
Wormhole Legendaries
Flag UnSet
Const
Flag UnSet
Const
Red
Green
0001
851=1?
Articuno
0001
851=11?
Mewtwo
0002
851=2?
Zapdos
0002
851=12?
Raikou
0003
851=3?
Moltres
0003
851=13
Entei
0004
851=4?
Ho-Oh
0004
851=14?
Dialga
0005
851=5?
Rayquaza
0005
851=15?
Cobalion
0006
851=6?
Cresselia
0006
851=16?
Terrakion
0007
851=7?
Tornadus
0007
851=17?
Virizion
0008
851=8
Thundurus
0008
851=18?
Reshiram
0009
851=9?
Landorus
0009
851=19?
Zekrom
0010
851=10?
Yveltal
0010
851=20?
Xerneas
Yellow
Blue
0001
851=21?
Regirock
0001
851=29?
Suicune
0002
851=22?
Regice
0002
851=30
Lugia
0003
851=23?
Registeel
0003
851=31?
Latias
0004
851=24?
Groudon
0004
851=32?
Latios
0005
851=25?
Heatran
0005
851=33?
Kyogre
0006
851=26
Regigigas
0006
851=34?
Uxie
0007
851=27?
Palkia
0007
851=35?
Mesprit
0008
851=28?
Giratina
0008
851=36?
Azelf
0009
851=37?
Kyurem
I'm not sure if the 851 const does anything though. I tested a few times and it didn't affect which Pokemon appeared.
Here are some other consts that changed between my saves, before entering Ultra Space and after entering a wormhole with Thundurus in Ultra Moon:
0: 0->333 // unknown
1: 0->702 // unknown. Entei and Lugia had 702 also but Regigigas had 706.
2: 0->642 // Pokemon's Pokedex number used for message upon running away from Legendaries?
3: 0->4278 // Event flag to set upon capture (Thundurus's here)
4: 0->4541 // Unknown event flag (for Thundurus too I think).
851: 40->8 // 40 was when I edited it for Sigilyph prior to exiting the Wormhole and reentering. 8 is the const value from the legendary encounter table above.
852: 0->24 // unknown
IsSet flags upon entering a wormhole:
0001, 0002, 0003, 0004, 0005, 0006, 0007, 0009, 0010, 0011, 0012, 0013, 0014, 0015, 0016, 4114
0001 through 0015 are for determining the slot.
0016 might be too but I don't know. edit: I'm assume it's an unused slot flag.
I'm not sure what 4114 is. Maybe a "In wormhole" flag.
After finishing the battle, there are flags that are set like 0071 (Regigagas), 0067 (Lugia), 0068 (Entei). Also const 3's event flag is set if captured. const 4's event flag also appears to be set if captured but I need to make a clean save without any wormhole Pokemon caught to check.
I also ran into a shiny Thundurus that I assumed was caused by the wormhole's shiny flag and then soft-reset. I didn't have the shiny flag set though... nice.