I just merged my "symtab" branches in milkymist.git and flickernoise.git
into master. They contain quite a lot of changes:
- restructuring of how variables are passed: in the early says, it
was by string. Later, I refined this to be by unique string, so
one could often use == instead of strcmp. Now it's by a symbol
table entry, which contains the pointer to the unique string,
but also additional information.
Among other things, this allows symbols to contain the respective
per-frame or per-vertex variable number, so the translation
tables with yet another linear and strcmp-heavy search are no
longer needed.
- the compiler now warns about certain suspicious activities:
- variables used in the wrong section, e.g.,
per_vertex=dmx0=1
The purpose of this is to guide users who are confused about
where a variable can go.
- variables that are read but not assigned to. There are two
variants of this: old-style patches can use constructs like
foo = foo+1;
without initializing "foo", which will then default to 0.
New-style patches have to initialize "foo" explicitly, e.g.,
foo = 0;
per_frame:
foo = foo + 1;
In either case, there will be a warning of a variable is read
but never assigned to.
The purpose of all this is to warn if there's a typo in a
variable name. E.g.,
wave_r = 0.5+0.5*sin(tome);
I'll add more warnings in the future. Warnings are now always
enabled in Flickernoise. In ptest, they are disabled by default
but can be turned on with -Wsection and -Wundefined.
In Flickernoise, warning messages are displayed in the patch
editor. If there is a warning, compilation will continue and if
there is no error, the patch will run. When returning to the
patch editor, the warning will be visible in the status line.
This is perhaps an overly subdued way of reporting warnings.
I could also change the Run button such that one has to press
it twice if there are warnings.
- more fun with the language:
- I missed that per_vertex=, in old-style syntax, could also
have an equation number, e.g., per_vertex_5=
This is now permitted.
- in new-style syntax, per_pixel: is dead. Long live
per_vertex: (which was also there before)
- in new-style syntax, any per-frame variable can be explicitly
initialized to zero in the global/initial section.
The main purpose of this is currently to suppress "undefined
variable" warnings, but this can be generalized to non-zero
values in the future.
- the ! operator can now also be used without "if", e.g.,
wave_r = !wave_r;
- we now also have the Milkdrop variable "frame", which counts
the frame number starting at zero. "frame" and "time" are
related as follows:
time = frame/24
Don't yet expect miracles from the only patch using "frame"
(Zylot - The Inner Workings of my New Computer), though, since
there seems to be a problem with the modulo operator, making
the patch ignore any changes to "frame".
You can see the desired effect by making good use of the new
and improved "not", though:
f = !f;
per_frame=wave_a = if(f,if(above(bass,1.3),10,0),10.57);
There were more not user-visible changes, such as removal of
function names from the symbol table, some cleanup of the
handling of diagnostics, and smoother compiles (less chatter,
fewer warnings).
Note that milkdrop.git and flickernoise.git must be updated
together, and the updated libfpvm must be built and installed
before Flickernoise can be compiled.
The patch "Unchained - A Matter Of Taste (Remix)" still needs
some looking after: it used variables like bass_residual that
weren't assigned to, and it also has a rather interesting but
commented-out equation at the very beginning.
If anyone knows where to find the original, I'd see if I can
bring our variant closer to the original.
- Werner
_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode