Skip to content
Newer
Older
100644 84 lines (76 sloc) 2.45 KB
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
1 #ifndef _REGMACH_H_
2 #define _REGMACH_H_
3
4 #include <stdio.h>
5 #include <math.h>
6 #include "image.h"
7
8 enum rm_byte_codes {
9 rbc_add, /* ra + rb -> r*/
10 rbc_subtract, /* ra - rb -> r */
11 rbc_mult, /* ra * rb -> r */
12 rbc_div, /* ra / rb -> r */
13 rbc_mod, /* ra % rb -> r */
14 rbc_pow, /* ra ** rb -> r */
15 rbc_uminus, /* -ra -> r */
16 rbc_multp, /* pa ** rb -> p */
17 rbc_addp, /* pa + pb -> p */
18 rbc_subtractp, /* pa - pb -> p */
19 /* rbcParm, we just preload a register */
20 rbc_sin, /* sin(ra) -> r */
21 rbc_cos, /* cos(ra) -> r */
22 rbc_atan2, /* atan2(ra,rb) -> r */
23 rbc_sqrt, /* sqrt(ra) -> r */
24 rbc_distance, /* distance(rx, ry, rx, ry) -> r */
25 /* getp? codes must be in order */
26 rbc_getp1, /* getp1(ra, rb) -> p */
27 rbc_getp2, /* getp2(ra, rb) -> p */
28 rbc_getp3, /* getp3(ra, rb) -> p */
29 rbc_value, /* value(pa) -> r */
30 rbc_hue, /* hue(pa) -> r */
31 rbc_sat, /* sat(pa) -> r */
32 rbc_hsv, /* hsv(rh, rs, rv) -> p */
33 rbc_red, /* red(pa) -> r */
34 rbc_green, /* green(pa) -> r */
35 rbc_blue, /* blue(pa) -> r */
36 rbc_rgb, /* rgb(rr, rg, rb) -> p */
37 rbc_int, /* int(ra) -> r */
38 rbc_if, /* if(rc, rt, rf) -> r */
39 rbc_ifp, /* if(rc, pt, pf) -> p */
40 rbc_le, /* ra <= rb -> r */
41 rbc_lt, /* ra < rb -> r */
42 rbc_ge, /* ra >= rb -> r */
43 rbc_gt, /* ra > rb -> r */
44 rbc_eq, /* ra == rb -> r -- does approx equal */
45 rbc_ne, /* ra != rb -> r -- does approx equal */
46 rbc_and, /* ra && rb -> r */
47 rbc_or, /* ra || rb -> r */
48 rbc_not, /* !ra -> r */
49 rbc_abs, /* abs(ra) -> r */
50 rbc_ret, /* returns pa */
51 rbc_jump, /* jump to ja */
52 rbc_jumpz, /* jump if ra == 0 to jb */
53 rbc_jumpnz, /* jump if ra != 0 to jb */
54 rbc_set, /* ra -> r */
55 rbc_setp, /* pa -> p*/
56 rbc_print, /* prints ra */
57 rbc_op_count
58 };
59
60 /* rm_word was originally char, but even for some simpler expressions
61 I was getting close to running out of register numbers.
62 It should also simplify structure alignment issues. (I hope.)
63 */
64 typedef int rm_word;
65 #define RM_WORD_PACK "i"
66
67 struct rm_op {
68 rm_word code; /* op code */
69 rm_word ra; /* first operand */
70 rm_word rb; /* possible second operand */
71 rm_word rc; /* possible third operand */
72 rm_word rd; /* possible fourth operand */
73 rm_word rout; /* output register */
74 };
75
76 i_color rm_run(struct rm_op codes[], size_t code_count,
77 double n_regs[], size_t n_regs_count,
78 i_color c_regs[], size_t c_regs_count,
79 i_img *images[], size_t image_count);
80
81 /* op_run(fx, sizeof(fx), parms, 2)) */
82
83 #endif /* _REGMACH_H_ */
Something went wrong with that request. Please try again.