<?xml version="1.0" encoding="utf-8" ?>
<EternityPatchFile name="PseudoCacs" enabled="new_chara" comment="This file enables patches to allow Cac2x2m features. This was sadly needed since version 1.08 of the game" >	

	<Patch name="StopPCColors" type="hook" search_start="0x27E360" comment="addr 1.08" >
		<Instruction code="40 55 56 57 41 54 41 55 41 56 41 57" comment="push rbp, rsi, rdi, r12, r13, r14, r15" />
		<Instruction code="48 83 EC 50" comment="sub rsp, 50h" />
		<Instruction code="48 C7 44 24 20 FE FF FF FF" comment="mov qword ptr[rsp+20h], -2" />
		<Instruction code="48 89 9C 24 A8 00 00 00" comment="mov [rsp+0A8h], rbx" />
		<Instruction code="48 8B 05 XXXXXXXX" comment="mov rax, XXXXXXXX" />
		<Instruction code="48 33 C4" comment="xor rax, rsp" />
		<Instruction code="48 89 44 24 48" comment="mov [rsp+48h], rax" />
		<Instruction code="49 8B F0" comment="mov rsi, r8" />
		<Instruction code="44 8B EA" comment="mov r13d, edx" />
		<Instruction code="4C 8B F1" comment="mov r14, rcx" />
		<Instruction code="33 ED" comment="xor ebp, ebp" />
		<Instruction code="45 33 E4" comment="xor r12d, r12d" />
		<Instruction code="41 BF D8 00 00 00" comment="mov r15d, 0D8h; address of skin color1" />
		<Instruction code="0F 1F 40 00 0F 1F 84 00 00 00 00 00" comment="very large nop" />
		<Instruction code="49 8B 4E 30" comment="mov rcx, [r14+30h]" />
		
		<Hook value="ApplyCacMatsPatched" setup="ApplyCacMats_Setup" />
	</Patch>
	
	<!-- Added in xv2patcher 1.5 -->
	<Patch name="FixPCTransColorPortrait" type="write" search_start="0x156B9A" comment="addr 1.08" >
		<Instruction code="42 8D 14 2E" comment="lea edx, [rsi+r13]" />
		<Instruction code="85 D2" comment="test edx, edx" />
		<Instruction code="7E 14" comment="jle +14" />
		<Instruction code="41 83 C9 FF" comment="or r9d, FFFFFFFF" />
		<Instruction code="45 33 C0" comment="xor r8d, r8d" />
		<Instruction code="48 8B CF" comment="mov rcx, rdi" />		
		<Instruction code="E8 XXXXXXXX" comment="call Battle_Mob::ChangePartSet" />
		
		<!-- r9: -1 to 0 -->
		<Write inst_index="3" value="45 31 C9 90" />
	</Patch>

</EternityPatchFile>