What every instruction does - counter185/DS4Windows_Scriptable_Lightbar GitHub Wiki

hookproc [name]

This instruction tells the program which process to read and should generally be at the first line of your script

Example:

hookproc Cemu

execcond

This instruction marks the beginning of the "execution condition", basically "if the following code returns anything other than 0, we're good to go with the main loop"
Useful for checking if an emulator is running the proper game

startloop

This marks the beginning of your main loop: the code that will be executed every time DS4Windows tries to read the color value

How values work

There are 3 types of values: a qword, a dword, and a bword (which is a byte but we named it that so it wouldn't cause a conflict with C#'s Byte class)
There are 2 reserved variables:

  • BASE_ADDRESS, equal to C#'s Process.MainModule.BaseAddress
  • DS4_PORT, which is equal to the currently requested controller port, and starts at 0

To declare a variable, use the setq/setd/setb instruction

setq/setd/setb [parameter1] [parameter2]

This assigns the value of [parameter2] to the variable [parameter1]

Examples:

setq samplevariable 0x105ADE8
setq variable1 samplevariable
setd someoffset 0x36D3FFBF
setb somebyte mem:someoffset

All numbers must be written in hexadecimal and start with 0x, otherwise they're treated like a variable name
mem: grabs the value from the memory address of its parameter

addq/addd [parameter1] [parameter2]

Increments [parameter1] by [parameter2]

Example:

addq someaddress someoffset

cond/cngr/cngq [parameter1] [parameter2] [lines to skip]

Compares [paramter1] and [parameter2], and
cond: Executes the next instruction only if the 2 values are equal, otherwise skips to the one after it
cngr: Executes the next instruction only if [parameter1] > [parameter2], otherwise skips to the one after it
cngq: Executes the next instruction only if [parameter1] >= [parameter2], otherwise skips to the one after it
cnls: Executes the next instruction only if [parameter1] < [parameter2], otherwise skips to the one after it
cnlq: Executes the next instruction only if [parameter1] <= [parameter2], otherwise skips to the one after it

Additionally, you can control how many lines will be skipped if the condition is false, with the optional [lines to skip] parameter.

Example:

cond somebyte 0x00
retn 0xff0000
retn 0x0000ff
This code returns the #FF0000 color value if somebyte is equal to 0, otherwise returns #0000FF

retn [parameter1]

This instruction ends the loop/execute condition. Required.

If you still don't understand how this works, try looking at the example script in the release zip