-
Notifications
You must be signed in to change notification settings - Fork 2
/
vmutil.cfg
56 lines (44 loc) · 2.32 KB
/
vmutil.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Some utility functions
set _ver_vmutil 1
// defer expansion of until_do
alias do_until_do "$until_do $*"
// until_dec(string var, int to, alias do)
// do { exec `do`, decrement var } while(var > to)
// until_inc(string var, int to, alias do)
// do { exec `do`, increment var } while(var < to)
// for(string var, int from, int to, alias do)
// set var from;
// if(from < to)
// until_inc(var, to, do)
// else
// until_dec(var, to, do)
alias until_dec "$3; dec $1; cmp $1 $2; jg \"until_dec $1 $2 \\\"$3\\\"\""
alias until_inc "$3; inc $1; cmp $1 $2; jl \"until_inc $1 $2 \\\"$3\\\"\""
alias for "mov $1 $2; cmp $2 $3; set until_do nop; cmovl until_do until_inc; cmovg until_do until_dec; do_until_do $1 $3 \"$4\"; set $1 $3"
alias fordec "mov $1 $2; cmp $2 $3; set until_do nop; cmovg until_do until_dec; do_until_do $1 $3 \"$4\"; set $1 $3"
alias forinc "mov $1 $2; cmp $2 $3; set until_do nop; cmovl until_do until_inc; do_until_do $1 $3 \"$4\"; set $1 $3"
alias untileq_dec "$3; dec $1; cmp $1 $2; jge \"untileq_dec $1 $2 \\\"$3\\\"\""
alias untileq_inc "$3; inc $1; cmp $1 $2; jle \"untileq_inc $1 $2 \\\"$3\\\"\""
alias foreq "mov $1 $2; cmp $2 $3; set until_do nop; cmovl until_do untileq_inc; cmovg until_do untileq_dec; do_until_do $1 $3 \"$4\"; set $1 $3"
// strcmp(string a, string b)
// compare two strings
// CRITICAL ALIAS ABUSE!
// sets the zero flag if a equals b
// I replaced 1 and 2 cvars with one and two cvars without dollar to get rid of console warnings
//alias strcmp "clf; alias \"strcmp_{two}\" \"\"; alias \"strcmp_{one}\" \"mov flag_z 1\"; \"strcmp_{two}\""
// fixed:
alias strcmp "clf; set flag_z \"_$1\"; toggle flag_z 0 \"_$2\" 1"
// if condition trueblock falseblock
alias if_do "$_if"
alias if "$1; mov _if nop; cmovz _if $2; cmovnz _if $3; if_do"
// boo... swap there lol
alias ifnot "if \"$1\" \"$3\" \"$2\""
alias floor "menu_cmd rpn /$1 $1 floor def"
alias ceil "menu_cmd rpn /$1 $1 ceil def"
alias abs "menu_cmd rpn /$1 $1 abs def"
//backup a variable into _backup_<variable>
alias _func_bak_2 "alias _fp_x \"set _backup_$_get ${$_get}\"; _fp_x"
alias varsto "set _get \"$1\"; _func_bak_2"
//restore a variable from _backup_<variable>
alias _func_res_2 "alias _fp_x \"set $_get ${$_get2}\"; _fp_x"
alias varrcl "set _get \"$1\"; set _get2 \"_backup_$1\"; _func_res_2"