From c313f84d9202fb3a65aa2982aa076a738fc22dc5 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 23 Nov 2019 12:46:50 -0800 Subject: modules/stub: add a stub sample module Intended as a bootstrap for new module creation, particularly aimed at new contributors. No module context, fragmenting, taps, or settings are implemented, to keep things as simple as possible. --- configure.ac | 1 + src/Makefile.am | 2 +- src/modules/Makefile.am | 2 +- src/modules/stub/Makefile.am | 3 +++ src/modules/stub/stub.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/til.c | 2 ++ 6 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 src/modules/stub/Makefile.am create mode 100644 src/modules/stub/stub.c diff --git a/configure.ac b/configure.ac index 9ebc957..f400a44 100644 --- a/configure.ac +++ b/configure.ac @@ -68,6 +68,7 @@ AC_CONFIG_FILES([ src/modules/spiro/Makefile src/modules/stars/Makefile src/modules/strobe/Makefile + src/modules/stub/Makefile src/modules/submit/Makefile src/modules/swab/Makefile src/modules/swarm/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index 5d4c982..b6569ac 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,7 +3,7 @@ SUBDIRS = libs modules noinst_LTLIBRARIES = libtil.la libtil_la_SOURCES = til.c til.h til_args.c til_args.h til_builtins.c til_fb.c til_fb.h til_jenkins.c til_jenkins.h til_limits.h til_module_context.c til_module_context.h til_settings.h til_settings.c til_setup.c til_setup.h til_str.c til_str.h til_stream.c til_stream.h til_tap.h til_threads.c til_threads.h til_util.c til_util.h libtil_la_CPPFLAGS = -I@top_srcdir@/src -libtil_la_LIBADD = modules/asc/libasc.la modules/blinds/libblinds.la modules/checkers/libcheckers.la modules/compose/libcompose.la modules/drizzle/libdrizzle.la modules/flow/libflow.la modules/flui2d/libflui2d.la modules/julia/libjulia.la modules/meta2d/libmeta2d.la modules/mixer/libmixer.la modules/moire/libmoire.la modules/montage/libmontage.la modules/pixbounce/libpixbounce.la modules/plasma/libplasma.la modules/plato/libplato.la modules/ray/libray.la modules/rkt/librkt.la modules/roto/libroto.la modules/rtv/librtv.la modules/shapes/libshapes.la modules/signals/libsignals.la modules/snow/libsnow.la modules/sparkler/libsparkler.la modules/spiro/libspiro.la modules/stars/libstars.la modules/strobe/libstrobe.la modules/submit/libsubmit.la modules/swab/libswab.la modules/swarm/libswarm.la modules/voronoi/libvoronoi.la libs/grid/libgrid.la libs/puddle/libpuddle.la libs/ray/libray.la libs/rocket/librocket.la libs/sig/libsig.la libs/txt/libtxt.la libs/ascii/libascii.la libs/din/libdin.la +libtil_la_LIBADD = modules/asc/libasc.la modules/blinds/libblinds.la modules/checkers/libcheckers.la modules/compose/libcompose.la modules/drizzle/libdrizzle.la modules/flow/libflow.la modules/flui2d/libflui2d.la modules/julia/libjulia.la modules/meta2d/libmeta2d.la modules/mixer/libmixer.la modules/moire/libmoire.la modules/montage/libmontage.la modules/pixbounce/libpixbounce.la modules/plasma/libplasma.la modules/plato/libplato.la modules/ray/libray.la modules/rkt/librkt.la modules/roto/libroto.la modules/rtv/librtv.la modules/shapes/libshapes.la modules/signals/libsignals.la modules/snow/libsnow.la modules/sparkler/libsparkler.la modules/spiro/libspiro.la modules/stars/libstars.la modules/strobe/libstrobe.la modules/stub/libstub.la modules/submit/libsubmit.la modules/swab/libswab.la modules/swarm/libswarm.la modules/voronoi/libvoronoi.la libs/grid/libgrid.la libs/puddle/libpuddle.la libs/ray/libray.la libs/rocket/librocket.la libs/sig/libsig.la libs/txt/libtxt.la libs/ascii/libascii.la libs/din/libdin.la bin_PROGRAMS = rototiller rototiller_SOURCES = fps.c fps.h main.c mem_fb.c setup.h setup.c til.h til_fb.c til_fb.h til_settings.c til_settings.h til_threads.c til_threads.h til_util.c til_util.h diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am index ea82374..aa63268 100644 --- a/src/modules/Makefile.am +++ b/src/modules/Makefile.am @@ -1 +1 @@ -SUBDIRS = asc blinds checkers compose drizzle flow flui2d julia meta2d mixer moire montage pixbounce plasma plato ray rkt roto rtv shapes signals snow sparkler spiro stars strobe submit swab swarm voronoi +SUBDIRS = asc blinds checkers compose drizzle flow flui2d julia meta2d mixer moire montage pixbounce plasma plato ray rkt roto rtv shapes signals snow sparkler spiro stars strobe stub submit swab swarm voronoi diff --git a/src/modules/stub/Makefile.am b/src/modules/stub/Makefile.am new file mode 100644 index 0000000..c7f5e2f --- /dev/null +++ b/src/modules/stub/Makefile.am @@ -0,0 +1,3 @@ +noinst_LTLIBRARIES = libstub.la +libstub_la_SOURCES = stub.c +libstub_la_CPPFLAGS = -I@top_srcdir@/src diff --git a/src/modules/stub/stub.c b/src/modules/stub/stub.c new file mode 100644 index 0000000..b7fabac --- /dev/null +++ b/src/modules/stub/stub.c @@ -0,0 +1,41 @@ +#include "til.h" +#include "til_fb.h" + +/* Sample module fills the frame with white pixels in a non-threaded manner, + * replace the body of stub_render_fragment() with your own algorithm. + * + * To finalize a module implementation derived from this stub, perform a global + * substitution of "stub" with your module's name, including copying into + * src/modules/$name, and updating all the build system and til.c references. + * + * A quick way to see what's involved in introducing a new module is to just + * `git show` the commit adding this stub module to rototiller. + * + * XXX: Note that since this module has the TIL_MODULE_EXPERIMENTAL flag set, it + * won't appear in the modules list or participate in randomizers. You can stil + * access it explicitly by name via the ":" prefix override, e.g.: + * rototiller --module=:stub + * + * Or just remove the TIL_MODULE_EXPERIMENTAL flag during development so it's + * treated normally. + */ + +static void stub_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) +{ + til_fb_fragment_t *fragment = *fragment_ptr; + + for (unsigned y = fragment->y; y < fragment->y + fragment->height; y++) { + for (unsigned x = fragment->x; x < fragment->x + fragment->width; x++) { + til_fb_fragment_put_pixel_unchecked(fragment, 0, x, y, 0xffffffff); + } + } +} + + +til_module_t stub_module = { + .render_fragment = stub_render_fragment, + .name = "stub", + .description = "Minimal stub sample module", + .author = "Your Name ", + .flags = TIL_MODULE_EXPERIMENTAL, /* XXX: remove this line to make module generally available */ +}; diff --git a/src/til.c b/src/til.c index 016eada..89e0046 100644 --- a/src/til.c +++ b/src/til.c @@ -53,6 +53,7 @@ extern til_module_t sparkler_module; extern til_module_t spiro_module; extern til_module_t stars_module; extern til_module_t strobe_module; +extern til_module_t stub_module; extern til_module_t submit_module; extern til_module_t swab_module; extern til_module_t swarm_module; @@ -91,6 +92,7 @@ static const til_module_t *modules[] = { &spiro_module, &stars_module, &strobe_module, + &stub_module, &submit_module, &swab_module, &swarm_module, -- cgit v1.2.3