Commit graph

920 commits

Author SHA1 Message Date
Charlie Brej
c44fcbb6df [script] Use the helper hash element extraction functions
This should simplify the code a little as it removes the need to play with
objects which must be unreffed.
2009-07-24 09:30:20 -04:00
Charlie Brej
25fa788801 [script] Add support for setting the window background color
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.
2009-07-24 09:30:20 -04:00
Charlie Brej
3ffc473b96 [script] Add support for getting the window width and height
The example script has been updated to use this as well as to use other
features recently committed.
2009-07-24 09:30:20 -04:00
Charlie Brej
3a24c86b31 [script] Simplify the object operations
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.
2009-07-24 09:30:19 -04:00
Charlie Brej
4a82c35e4a [script] Add modify assignments (+=, *= ...)
Adds the following modify assignments: +=, -=, *=, /=, %=
2009-07-24 09:30:19 -04:00
Charlie Brej
a99a8a27c9 [script] Move object operating functions to script-object to avoid repetition 2009-07-24 09:30:19 -04:00
Charlie Brej
a11fac81f6 [script] Fix bug of assigning a var to itself (e.g. val = val;)
Problem was that the var is cleared before being re-assigned, which also clears
the value we were about to write into it.
2009-07-24 09:30:18 -04:00
Charlie Brej
cf730d7b07 [script] Add an example progress bar to the example script 2009-07-24 09:30:18 -04:00
Charlie Brej
370e0522f0 [script] Add support for image scale 2009-07-24 09:30:18 -04:00
Charlie Brej
c9831c9dfa [script] Implement script based fade_in implementation
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
2009-07-24 09:30:17 -04:00
Charlie Brej
bb4ed684b8 [script] Add support for 'for'
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.
2009-07-24 09:30:17 -04:00
Charlie Brej
156d12b87a [script] Add support for an "else" after an "if" 2009-07-24 09:30:16 -04:00
Charlie Brej
e0774cc8f1 [script] Add support for loading the system logo image
This is done specifying the filename is special://logo. Not sure if this is the
best way of implementing but it is expandable to other special files.
2009-07-24 09:30:16 -04:00
Charlie Brej
d7fa520a77 [script] Add support for the password dialogue in the example script theme 2009-07-24 09:30:16 -04:00
Charlie Brej
a3b9e728c6 [script] Added a turn float to integer function to the math library 2009-07-24 09:30:15 -04:00
Charlie Brej
985a3c030e [script] Deref the state to allow local and global to be reassigned
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.
2009-07-24 09:30:15 -04:00
Charlie Brej
8786b2eba6 [script] Handle -0 in float comparisons correctly 2009-07-24 09:30:15 -04:00
Charlie Brej
4a6ba0212e [script] Add simple Math functions (abs, min, max and clamp) 2009-07-24 09:30:14 -04:00
Charlie Brej
76666c2955 [script] Remember the width and height of old sprite image for next refresh
When we change the sprite image, the redraw now remembers to refresh the old
area despite any change in the image size.
2009-07-24 09:30:14 -04:00
Charlie Brej
83c8977e34 [script] Refresh the part of the screen that a sprite was on when removing
When a sprite is destroyed, this should now refresh the area the sprite was
occupying.
2009-07-24 09:30:13 -04:00
Charlie Brej
e7fad23f70 [script] Creating a string object with a NULL string now returns a NULL object
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.
2009-07-24 09:30:13 -04:00
Charlie Brej
5df19c2b1b [script] Free the functions, in the script lib plymouth, when library is freed 2009-07-24 09:30:13 -04:00
Charlie Brej
b3496bd54a [script] add sprite opacity control
SpriteSetOpacity sets the opacity of the sprite. Also a couple fixups to
refresh when the image has been changed.
2009-07-24 09:30:12 -04:00
Charlie Brej
58e51c4302 [script] Add cos, sin, tan and square root functions to the script math library 2009-07-24 09:30:12 -04:00
Charlie Brej
a316d77674 [script] Allow scripts to attach themselves to plymouth plugin callbacks
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.
2009-07-24 09:30:12 -04:00
Charlie Brej
b2e08f4968 [script] Correctly parse multiple parameter functions and allow dangeling comma
Typo was causing parsing errors.
2009-07-24 09:30:11 -04:00
Charlie Brej
7901df33f9 [script] Don't error on object unref of NULL
This follows the usage of free with a NULL as well as ply-image etc.
2009-07-24 09:30:11 -04:00
Charlie Brej
9af3a9d3db [script] Rationalize function calls and callbacks
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.
2009-07-24 09:30:10 -04:00
Charlie Brej
0892d0c66a [script] Output error mesages when parsing files
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.
2009-07-24 09:30:10 -04:00
Charlie Brej
3dff5d2b4f [scan] Correct character index calculation
Index should point to the coordinate before the character and not after.
2009-07-24 09:30:10 -04:00
Charlie Brej
8b32ab721c [scan] Remember the line and column number of tokens
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".
2009-07-24 09:30:09 -04:00
Charlie Brej
6f307ed7b4 [scan] Add error reporting to the scanner
The canner now returs error tokens when strings or comments are not correctly
terminated.
2009-07-24 09:30:09 -04:00
Charlie Brej
6257228266 [scan] Add block comments
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.
2009-07-24 09:30:09 -04:00
Charlie Brej
67b8703dd6 [scan] Add parsing of line comments
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.
2009-07-24 09:30:08 -04:00
Charlie Brej
d86416e23b [script] Ensure two character operators have no space between characters
Checks whitespace before the second token is zero.
2009-07-24 09:30:08 -04:00
Charlie Brej
583dd45be2 [scan] Remember white space between tokens
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+ +).
2009-07-24 09:30:07 -04:00
Charlie Brej
8c9f902ecc [script] Add support for script image rotation
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.
2009-07-24 09:30:07 -04:00
Charlie Brej
bccf288229 [script] Add support for unary operations (!/+/-/++/--)
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.
2009-07-24 09:30:07 -04:00
Charlie Brej
efb543e294 [script] Free the main script after freeing the state
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.
2009-07-24 09:30:07 -04:00
Charlie Brej
f66f6078c1 [script] Dereference on assign without affecting refcount
Assigns were incorrectly dereferencing creating an incorrect refcount.
2009-07-24 09:30:06 -04:00
Charlie Brej
cf8c99c38f [script] Add support for logical AND and OR
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.
2009-07-24 09:30:05 -04:00
Charlie Brej
02e878a728 [script] Add support for floats
Adds parsing and execution support for floats. Some operations upgrade ints to
floats with no way of turning them back to ints.
2009-07-24 09:30:05 -04:00
Charlie Brej
5ea8be95ab Initial scripted plugin support
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.
2009-07-24 09:30:05 -04:00
Charlie Brej
fc2d96de67 [utils] Add utf-8 support functions to determine character and string length
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.
2009-07-15 11:30:19 +01:00
Charlie Brej
f6da5d5aeb [frame-buffer] Unroll gradient drawing loop
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.
2009-06-18 15:31:36 +01:00
Charlie Brej
5232df3238 [frame-buffer] Use a simpler pseudo-random number generator for gradient noise
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.
2009-06-18 14:55:51 +01:00
Charlie Brej
1230d1d3ec [frame-buffer] Make additions to the areas to flush non-overlapping
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.
2009-06-17 15:22:42 +01:00
Ray Strode
bed202ac28 [frame-buffer] Discard overlapping flush areas
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.
2009-06-11 23:37:03 -04:00
Ray Strode
a741222aca [frame-buffer] Track multiple flush areas
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.
2009-06-11 23:18:30 -04:00
Ray Strode
ffec2f1e67 [frame-buffer] Rework flush interface to take area
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.
2009-06-11 22:49:32 -04:00