Two functions set the color of either the bottom or the top of the screen. If
the two colors are equal a solid colour draw is used. The color is supplied by
three floats specitying red green and blue elements.
Using nested switch statements made it easy to decide what to do in each
situation but this is rather verbose and causes -Wextra to complain (a lot).
Also added script_obj_is_[type] to help identify object easier and not repeat
code.
The example script now can show a spinfinity or a fade_in behaviour. This is
just to see how easy it is to implement current plugins. In the case of fade_in
it is around 23 lines of script code
Matches the use in C as "for (first, condition, last)" where first is executed
once, last is executed at the end of each iteration (even when continue is
executed) and condition is tested at the start of every cycle.
This should allow local and global to be assigned to a different vareable.
This is discouriged as it may cause asserts to fail, but may be useful to save
current state and continue the function at a later time.
Strings in C are often set to NULL to signify that they have not been set. This
should be carried through to the script system rather than failing at the
conversion.
The scripts can now attach themselves to the following callbacks: refresh,
boot_progress, root_mounted, keyboard_input, update_status, display_normal,
display_password and display_question.
Allows script functions to be executed without extracting the body of the
function and executing that. This makes implementing callbacks simpler and
enables passing of parameters.
The parses should now produce useful error messages of syntax errors in the
parsed files. This is not a 100% coverage but at least it now gives an error
with a line number rather than just an assert and a crash.
This is useful for scan and parse error reporting. The first column is zero but
this can be changed. Nedit and Emacs say zero, gedit says 1 and Vi says "0-1".
Treats "/*" and "*/" as block comment markers. Block comments may be nested.
There is a bug where if a comment or a string is not terminated before the end
of a file, the scanner deadlocks. Need to add a way or reporting scanner
errors to the parser.
These are currently hard coded to '//' and '#'. The code is there to return
them to the caller but currently they are thrown away.
Should add a skip_comments option and allow customisable markers.
Tokens now contain the number of white space characters since the last token.
This is useful in situations where white space between symbols changes the
meaning (e.g. a++ vs. a+ +).
An image rotate operation creates a new image with the same dimensions but with
the contents rotated by an angle around the centre of the image. Also added a
script object to float function to allow this.
Allows execution of unary operations: Pre/postfix inc/decrement, logical
negation and unary plus/minus.
The writebacks of increment/decrements happen during the execution of the
expression, unlike C where they are executed after the line if executed. This
is the case simply because it is simpler to execute this way.
There are links from the script state to parsed script data. Destroy the parsed
data after freeing the state.
This should be done properly with more ref counting or moving the freeme var to
the linking structure.
Allows the use of "&&" and "||". These are evaluated lazily and return the
evaluated sub-value which completed the operation rather than a bool. It allows
things like:
reply = cache_lookup(index) || slow_lookup(index);
If cache_lookup returns a false value (NULL, or 0) then slow_lookup is executed
and its result is placed in reply. Otherwise the result from cache_lookup is
used.
This is an initial support for the scripted plugin. There are _many_ FIXMEs
and the whole code is reather unstable. The formatting is completely incorrect
and will be changed soon. There are scripts which are converted using a perl
to an C embeddable string.
These are used to feed the keyboard input a single character at a time, to
determine the number of bullets in the password dialogue and process backspaes.
When drawing the gradient, rather than creating each dithered pixel, a block
of 8 pixels is created and copied repeatedly to the target. So long as the
number of noise bits is low and the random number generator is good, no
repetition is visible.
In some plugins about 80% of time is spent in the random number generation
functions. These are used to create the dithering noise to stop the banding in
the gradient functions.
The simpler version is an adaptation of a linear feedback register which
creates a pseudo random sequence repeating every 4,194,303 generations.
When adding areas to be flushed, the algorithm now looks for partial overlap
with existing areas and if found it either: throws away an area as it is fully
overlapped, reduces the area to remove the overlap or breaks the area into two
skirt around the area already in the list.
The algorithm does does not scale particularly well when there are more than 30
areas stacked with each being partly (but not fully) overlapped by others. This
creates a large list of small areas to check against which could eventually
become counter productive.
One advantage of the previous bounding box approach to flushing
is overlapping flush areas wouldn't get flushed multiple times.
This commit tries to identify overlapping flush areas and eliminate
them. It's not perfect though.
A better approach might be to store a sorted tree of areas to be
flushed, and walk the tree when adding new flush areas to quickly find
overlapping areas. Then we'd split each area into two or more new areas
to avoid overlaps.
Previously we would always aggregate flush areas together even
if they were disjoint and far apart. That meant that if two
images on opposites sides of the screen were updated in one
frame, then the entire screen would get redrawn.
We now track flush areas in a list, instead of a bounding box.
Before this commit it would always flush the area_to_flush
area. Now the interface allows flushing arbitrary areas. This
change paves the way for us to flush multiple disjoint areas
at one time.