The Mugen Fighters Guild

Help => M.U.G.E.N Development Help => Code Library => Topic started by: ink on August 13, 2019, 02:53:08 PM

Title: Helper 1 frame delay study & Modifying Vans' Tiny Buffer to have no delay.
Post by: ink on August 13, 2019, 02:53:08 PM
First the study
M.U.G.E.N 1.0+ only
I did a big study on the cond() exploit (http://mugenguild.com/forum/msg.2429963), helpers and the 1 tick delay. There are a good amount of limitations in general worth noting.

These two pieces of code where put in the root(statedef -1) and a helper that had keyctrl =1. When "start" is pressed, mugen pauses and the results can be viewed with debug.
Code:
;Statedef -1
[state -1]
type = null
trigger1= command = "start"
trigger1 = Cond(NumHelper(33333333), Helper(33333333), Cond(1, Var(8) := 1, 0), 0)

[state -1]
type = null
trigger1= command = "start"
trigger1 = Cond(NumHelper(33333333), Helper(33333333), Cond(1, Var(12) := 1, 0), 0)

[state -1]
type = DisplayToClipboard
trigger1 = 1
text = " H-Var(8) = %d, H-Var(9) = %d, H-Var(10) = %d, H-Var(11) = %d, H-Var(12) = %d  \n"
params = helper(33333333),var(8) ,    helper(33333333),var(9) ,    helper(33333333),var(10),    helper(33333333),var(11),    helper(33333333),var(12)

[state -1]
type = pause
;trigger1 = command = "start"
trigger1 = helper(33333333),var(8) = 1
time = 100

Code:
;Helper(33333333)
[state test]
type = null
trigger1 = var(8) = 1 ;acts as "start", set in root.
trigger1 = var(9):= 1

[state test]
type = null
trigger1 = command = "start"
trigger1 = var(10):= 1

[state test]
type = null
trigger1 = root, command = "start"
trigger1 = var(11):= 1

;var(12) is set in the root and also read in the root.

What this code proves:


Modifying Vans' Tiny Buffer to have no delay.
M.U.G.E.N 1.0+ only
I recommend doing Vans' Tiny Buffer (http://mugenguild.com/forum/msg.2331601) as you normally would and use this information to convert it afterwards(if the 1frame delay bothers you). This is to avoid a 1 frame delay. psuedocode below should help you get an understanding of how this works.
Quote
Psuedocode
-----------------
-have a helper with keyctrl = 1 ; It's best to use the same helper that is used for the buffer system. That way no redirects will need changed in the cmd file.
-in root(statedef -2) use helper(##),command = " " for triggers; this is because the root can read helper,commands with 0 lag.
-set var() in helper using cond exploit from the root(statedef -2). This allows you to set vars and read them immediately with 0 lag.
-have root(statedef -1) read helper,var() in place of commands. ; this should already be set up from using Vans' Tiny Buffer.

The idea here is to use the helper to store the vars, while executing the code and reading the helper vars from the root.

To convert Vans' Tiny Buffer (http://mugenguild.com/forum/msg.2331601) all varset and varadd sctrls(in the helper) must be moved to statedef -2 and rewritten in the form of a null sctrl using the cond() exploit (http://mugenguild.com/forum/msg.2429963). Note,sysvars can not be set using cond()exploit, if any sysvars are used they can remain in the helper. *It’s wise to note what code is from Vans’ buffer system to avoid confusion in the future. I personally copy an paste his whole header and notes.

Example:
Code:
[State 654654, VarSet]
type = VarSet
trigger1 = root,movehit = 2
trigger2 = root,hitpausetime = 0
fvar(11) = 0
Once converted the code above becomes this.
Code:
[State -2, VarSet]
type = Null
trigger1 = movehit = 2
trigger1 = Cond(NumHelper(10371), Helper(10371), Cond(1, FVar(11) := 0, 0), 0) || 1
trigger2 = hitpausetime = 0
trigger2 = Cond(NumHelper(10371), Helper(10371), Cond(1, FVar(11) := 0, 0), 0) || 1