This patch deducts a configurable amount of time from the timer when dropping the item box item with Select. There are three possible outcomes depending on the time cost and how much time remains on the timer (all three outcomes will drop the item box item):
- If the timer is greater than twice the time cost, the cost will be deducted from the timer
- If the timer is between the cost and twice the cost, the timer will be set to the cost value itself
- If the timer is less than the cost, the item will be dropped with no time deduction
This patch also allows enabling a nearby debug function that is otherwise overwritten. All code is fully commented.
This is a nice and small patch for those who want the item box to be harder to abuse. During the moderation, I fixed a small oversight which caused the debug code to never get called, even if it's enabled; the debug code isn't the main purpose of the patch and is unlikely to be used, which is why I decided it'd be quicker to just fix the oversight, especially considering how minor the fix is.
The routine which converts the timer to hexadecimal is very unoptimized. The dependency on $00, which is read and written during each iteration of the three loops, can be very easily removed because the accumulator is not used at all during the conversion. The positioning of the Item_Box_Time_Cost_SetAtCost label is also a little odd as it's in the middle of Item_Box_Time_Cost_ConvertTens but I assume that's due to branch distance. Finally, the hijacked routine returns to $00C592; $00C58F would be a better return address as it wouldn't skip an STZ instruction unrelated to the item box. I didn't manage to break anything because of the missed STZ and the new code isn't called often, so I didn't consider any of these rejection reasons.