The Heal Berry 255 Item Trick

You probably already know how this trick is performed. If you wonder how does it work, I'll explain it here.

Requirements
You need to have 3 party members.
You only have 1 item that you want to duplicate.
You have 2 or more consumable item (Heal Berry preferred due to its abundance).
Steps
Order first character use Heal Berry.
Order second character use Heal Berry
Order third character to swap heal berry with the item you want to duplicate, and then Defend.
Let the battle commence.
The item swapped with Heal Berry will now be 255.

Let's say that the Heal Berry is in slot 1, and the item to be duplicated, Ambrosia, is in slot 2. Due to requirement, there's only 1 Ambrosia.

Order first character to use Heal Berry (Slot 1)
This orders the game to use Heal Berry and reduce Item in slot 1 by 1. Take note of how I write this. The game was not ordered to use Item 1, the game was ordered to use the Heal Berry instead.
Order second character to use Heal Berry (Slot 1)
This orders the game to use Heal Berry and reduce Item in slot 1 by 1.
Third character swap Heal Berry (Slot 1) With Ambrosia (Slot 2) and Defend
Different from previous two, this actually sort the item, not ordering just order the game to do it. Now Ambrosia is in Slot 1 and Heal Berry is in Slot 2.
Turn commence - Third Character
Third character defend (defend being a high priority move s/he goes first. Nothing changed.
Turn commence - First Character
First character uses Heal Berry as ordered, but reduces the item in slot 1, which is Ambrosia. Ambrosia is now 0. However, the game only reduce the amount, not clearing the Item Type itself, hence at this state, item slot 1 is occupied with 0 Ambrosia.
Turn commence - Second Character
Second character uses Heal Berry as ordered, but again reduces the item in slot 1, Since item slot 1 is occupied by 0 Ambrosia and the game only know how to reduce the amount using this mechanism, the item become -1 Ambrosia. This causes overflow, and since item amount is Integer 1 byte, it converts the signed value (-1) to its unsigned value (255). Hence you get the 255 Ambrosias.
What if the target duplicated item is more than 1?
Let's say you have 2 Ambrosias, at the end of battle, it will become 0 Ambrosia. You can redo the trick by swapping Heal Berry with the empty slot and end with 254 item.