Re: Arbitrary code execution in Gold/Silver UE using the Coin Case
Posted by: spamviech
        Date: 2017-11-07 06:57:25
    This one will fill your current box with 20 Pokémon of your chosing with same Item and Moveset. Be sure to remove any Pokémon you want to keep, since they will get overwritten (mostly).
First, use this box name code to give you 255 of every TM/HM:
1)Ap'vCé025
2)'vj'vué25
3)'v.é32p'v9
4)é22pé425
5)'vué62'v 5
6)'v:é72p09
7)55555's5
8)x'd
Coin Case Variant (untested):
1)Ap'vCé025
2)'vj'vué25
3)'v.é32p'v9
4)é22pé425
5)'vué62'v 5
6)'v:é72p09
7)55555's5
8)ppp'v9éZ
9).9'l'l'l'lx'd
Then write the code with TM quantities by keeping/depositing (you might need to toss inbetween to make space in the PC):
format:	keep/deposit	code
TM01	62/193			LD A, 0a
TM02	10/245			
TM03	234/21			LD [ff00], A | A->0a
TM04	255/0			
TM05	0/255			
TM06	62/193			LD A, 01
TM07	01/254			
TM08	234/21			LD [ff40], A | A->00
TM09	255/0			
TM10	64/191			
TM11	33/222			LD HL, 6cad | HL->ad6c
TM12	108/147			
TM13	173/82			
TM14	1/254			LD BC, 1a00 | BC->001a
TM15	26/229			
TM16	0/255			
TM17	62/193			LD A, 14 | A->14
TM18	20/235			
TM19	87/168			LD D, A
TM20	95/160			LD E, A
TM21	34/221			LD [HLI], A
TM22	62/193			LD A, (species)
TM23	(species)/		
TM24	34/221			LD [HLI], A
TM25	21/234			DEC D
TM26	32/223			JR NZ, fc | (Loop back to last LD [HLI], A)
TM27	252/3			
TM28	54/201			LD [HL], ff
TM29	255/0			
TM30	35/220			INC HL
TM31	87/168			LD D, A
TM32	122/133			LD A, D
TM33	34/221			LD [HLI], A
TM34	62/193			LD A, (item)
TM35	(item)/			
TM36	34/221			LD [HLI], A
TM37	62/193			LD A, (move1)
TM38	(move1)/		
TM39	34/221			LD [HLI], A
TM40	62/193			LD A, (move2)
TM41	(move2)/		
TM42	34/221			LD [HLI], A
TM43	62/193			LD A, $(move3)
TM44	(move3)/		
TM45	34/221			LD [HLI], A
TM46	62/193			LD A, $(move4)
TM47	(move4)/		
TM48	34/221			LD [HLI], A
TM49	9/246			ADD HL, BC
TM50	29/226			DEC E
HM01	32/223			JR NZ, eb | (Loop Back to LD A, D)
HM02	235/20			
HM03	201/54			RET
Now change your box names to the code below and execute via wrong pocket TM execution:
1)  5  5  5  p  0  A 'v  x		XOR A; OR 80; SUB b7 | A->c9
2)  é  s    p  0  é 'v  9		LD [b2f5], A; XOR A; OR ea; SUB ff | A->eb
3)  é  r    p  0  a 'v  A		LD [b1f5], A; XOR A; OR a0; SUB 80 | A-> 20
4)  é  q    p  0  8  ?  _		LD [b0f5], A; XOR A; LD OR fe; AND 7f | A->7e (_ is space)
5)  é  .  2  x 'm 'm  			LD [e7f8], A; OR A; JP NC, [{7e}f5]
Coin Case Variant (untested):
1)  5  5  5  p  0  A 'v  x		XOR A; OR 80; SUB b7 | A->c9
2)  é  s    p  0  é 'v  9		LD [b2f5], A; XOR A; OR ea; SUB ff | A->eb
3)  é  r    p  0  a 'v  A		LD [b1f5], A; XOR A; OR a0; SUB 80 | A-> 20
4)  é  q    p  0  8  ?  _		LD [b0f5], A; XOR A; LD OR fe; AND 7f | A->7e (_ is space)
5)  é  1  2  p 'v   9  . 9		LD [f7f8], A; XOR A; SUB ff; ADD SP, ff | A->01
6)  é  Z   'l 'l 'l 'l  5		LD [99f1], A; POP DE; POP DE; POP DE; POP DE |  ( is mult)
7)  x 'm 'm  				OR A; JP NC, [{7e}f5]
Execute using the usual Quagsire holding TM02 with Return as first move (start execution from second character of first box name).
Level, Nickname, OT, DV, etc. will be the same from the Pokémon who were in the place before (0/empty for a new box).
For Celebi with its Level 1 moveset use the following values at their appropriate place:
For Celebi use the following Quantities:
Species:
	Celebi		251/4
Item:
	Lucky Egg	126/129
Moveset Level 1:
	Leech Seed	73/182
	Recover		105/150
	Confusion	93/162
	Heal Bell	215/40
Edit: fixed a bug which would shift bytes upon releasing/withdrawing of Pokémon.
If you set $D199 to $01, fast text speed will be active and laggy menu will be fixed.
To do this, end coin case codes with:
p'v9éZ(mult)55
.9'l'l'l'lp'd
Neat. :)