# Original patch by Soly, in Blue Burst Patch Project # https://github.com/Solybum/Blue-Burst-Patch-Project # GC and Xbox ports by fuzziqersoftware .meta visibility="all" .meta name="No rare selling" .meta description="Stops you from\naccidentally\nselling rares\nto shops" entry_ptr: reloc0: .offsetof start .versions 3OJ2 3OJ3 3OJ4 3OJ5 3OE0 3OE1 3OE2 3OP0 start: .include WriteCodeBlocks # See comments in the 59NL version of this patch for details on how it works. .data .data 0x00000004 li r29, 0 .data .data 0x00000004 li r29, 0 .data .data 0x00000004 li r29, 0 .label tool_check_hook_loc, 0x800041A0 .data tool_check_hook_loc .deltaof tool_check_hook_start, tool_check_hook_end .address tool_check_hook_loc tool_check_hook_start: lwz r29, [r3 + 0x10] # Flags xori r29, r29, 0x0080 andi. r29, r29, 0x0080 beqlr # Not rare; r29 (returned price) is zero already lwz r29, [r3 + 0x0C] # Cost blr tool_check_hook_end: .label tool_check_hook_call, .data tool_check_hook_call .data 0x00000004 .address tool_check_hook_call bl tool_check_hook_start .data 0x00000000 .data 0x00000000 .versions 4OED 4OEU 4OJB 4OJD 4OJU 4OPD 4OPU start: .include WriteCodeBlocks # See comments in the 59NL version of this patch for details on how it works. .data .data 0x00000004 .data 0x00000000 .data .data 0x00000004 .data 0x00000000 .data .data 0x00000005 .binary E98E0C0000 .data .deltaof tool_check_start, tool_check_end tool_check_start: xor edi, edi test byte [eax + 0x10], 0x80 cmovz edi, [eax + 0x0C] .binary E995F3FFFF tool_check_end: .data 0x00000000 .data 0x00000000 .versions 50YJ 59NJ 59NL start: # This works by setting the item price to zero if it's rare, which causes the game to prevent you from selling the # item. For armors and weapons, this is easy because there are easily-patchable opcodes within branches that return a # constant price for rare items. xor eax, eax mov [], eax # Rare armors mov [], eax # Unidentified weapons mov [], eax # Rare weapons # For tools, it's harder to implement this, because the price comes from the ItemPMT tools table and there is no # branch for rares. Still, we can add a branch to a stub to handle tools. pop ecx push 5 push call get_code_size .deltaof patch_code, patch_code_end get_code_size: pop eax push dword [eax] call patch_code_end patch_code: # TODO: It'd be nice to have something like WriteJumpToAndFromCode, since this hook is supposed to return to a # different place than where it was called, hence this mov [esp]. mov dword [esp], xor edi, edi test byte [eax + 0x14], 0x80 # flags & 0x80 = is rare cmovz edi, [eax + 0x10] # Use price from table if not rare ret patch_code_end: push ecx .include WriteCallToCode