Skip to content

Instantly share code, notes, and snippets.

@leiradel
Last active July 1, 2018 22:08
Show Gist options
  • Save leiradel/9b22e1bc9484b56add8dd5563ad8f1fa to your computer and use it in GitHub Desktop.
Save leiradel/9b22e1bc9484b56add8dd5563ad8f1fa to your computer and use it in GitHub Desktop.
(Sort of) BNF of the Retro Achievements memaddr field
memaddr = achievement | leaderboard .
memory_size = ( 'm' | 'M' ) // bit 0
| ( 'n' | 'N' ) // bit 1
| ( 'o' | 'O' ) // bit 2
| ( 'p' | 'P' ) // bit 3
| ( 'q' | 'Q' ) // bit 4
| ( 'r' | 'R' ) // bit 5
| ( 's' | 'S' ) // bit 6
| ( 't' | 'T' ) // bit 7
| ( 'l' | 'L' ) // upper nibble
| ( 'u' | 'U' ) // lower nibble
| ( 'h' | 'H' ) // 8 bits
| ( 'x' | 'X' ) // 32 bits
| ' ' // 16 bits
| /* empty */ // 16 bits
.
memory_contents = (
( 'd' | 'D' ) // delta
| ( 'b' | 'B' ) // address (BCD)
| /* empty */ // address
)
'0' ( 'x' | 'X' )
memory_size
hexadecimal
.
lua_function = '@' identifier . // name of the Lua function that returns the value of the variable
condition_type = ( 'r' | 'R' ) // reset
| ( 'p' | 'P' ) // pause
| ( 'a' | 'A' ) // add source
| ( 'b' | 'B' ) // subtract source
| ( 'c' | 'C' ) // add hits
| /* empty */ // standard
.
comparison_op = '=' // equal
| '==' // equal
| '!=' // not equal
| '<' // less than
| '<=' // less than or equal to
| '>' // greater than
| '>=' // greater than or equal to
.
trigger_operand = memory_contents
| ( 'h' | 'H' ) hexadecimal
| decimal
| lua_function
.
required_hits = '(' decimal ')'
| '.' decimal '.'
.
condition = condition_type ':'
trigger_operand
comparison_op
trigger_operand
[ required_hits ]
.
condition_set = condition { '_' condition } .
trigger = condition_set { 'S' condition_set } .
achievement = trigger .
term_operand = memory_contents
| ( 'h' | 'H' ) hexadecimal
| ( 'v' | 'V' ) decimal
| floating_point
| lua_function
.
term = term_operand
[
'*' [ '~' ] term_operand
]
.
expression = term { '_' term } .
maximum_of = expression { '$' expression } .
start = ( 's' | 'S' ) ( 't' | 'T' ) ( 'a' | 'A' )
':'
trigger
.
cancel = ( 'c' | 'C' ) ( 'a' | 'A' ) ( 'n' | 'N' )
':'
trigger
.
submit = ( 's' | 'S' ) ( 'u' | 'U' ) ( 'b' | 'B' )
':'
trigger
.
value = ( 'v' | 'V' ) ( 'a' | 'A' ) ( 'l' | 'L' )
':'
maximum_of
.
leaderboard = start '::' // not necessarily in this order?
cancel '::'
submit '::'
value
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment