Drunk-Fu

From mugen-net
Jump to navigation Jump to search

Drunk-Fu is a method created by Jesuszilla used in conjunction with Deep Buffering to detect a press or release of any 2 buttons. This is used mainly for ES attacks in his PotS-style Felicia. The name comes from the fact that he was drunk while coding this part of the system.

Algorithm[edit]

Drunk-Fu simply takes the bitwise OR of all inputs that can be stored in the command buffer and checks if at least two bits are set. All upper bits are shifted down and OR'd into the same bit space to simplify calculations. The buffering helper then sets a variable in the root with a 1 to signify that two or more buttons have been pressed or released, or 0 when no pattern has been found.

Implementation[edit]

; DrunkFu - Detects any two buttons, even in negative edge!
[State 10371, DrunkFu]
type = Null
trigger1 = e||(var(58) := 0) ; INIT
trigger1 = e||(var(58) := (var(58)| (var(0)&7)))
trigger1 = e||(var(58) := (var(58)| (var(0)&112)))

trigger1 = e||(var(58) := (var(58)|((var(0)&896)/128)))
trigger1 = e||(var(58) := (var(58)|((var(0)&14336)/128)))

trigger1 = e||(var(58) := (var(58)| (var(2)&7)))
trigger1 = e||(var(58) := (var(58)| (var(2)&112)))

[State 10371, DrunkFu]
type = ParentVarSet
trigger1 = 1
var(49) = 0
[State 10371, DrunkFu]
type = ParentVarSet
trigger1 = (var(58)&7) > 0
trigger1 = ((var(58)&7) != 1 && (var(58)&7) != 2 && (var(58)&7) != 4) || (var(58)&112) > 0

trigger2 = (var(58)&112) > 0
trigger2 = ((var(58)&112) != 16 && (var(58)&112) != 32 && (var(58)&112) != 64) || (var(58)&7) > 0
var(49) = 1

The inequality checks are used to determine whether or not the values are represented by a single bit, as only 3 bits are used for punches, and 3 for kicks. 1,2,4 are used for punches, and 16,32,64 are used for kicks. If any of the values are 1, 2, 4, 16, 32, or 64, then only a single bit has been set, indicating that only one button has been pressed or released.

The implementation above assumes Deep Buffering is used with 2 ticks for button and direction buffers, and 9 ticks for the element buffer.