diff options
Diffstat (limited to 'frontends/calculator/CEdev/examples/gfx_light_dark')
| -rw-r--r-- | frontends/calculator/CEdev/examples/gfx_light_dark/autotester.json | 63 | ||||
| -rw-r--r-- | frontends/calculator/CEdev/examples/gfx_light_dark/makefile | 15 | ||||
| -rw-r--r-- | frontends/calculator/CEdev/examples/gfx_light_dark/readme.md | 10 | ||||
| -rw-r--r-- | frontends/calculator/CEdev/examples/gfx_light_dark/screenshot.gif | bin | 0 -> 67785 bytes | |||
| -rw-r--r-- | frontends/calculator/CEdev/examples/gfx_light_dark/src/main.c | 59 |
5 files changed, 147 insertions, 0 deletions
diff --git a/frontends/calculator/CEdev/examples/gfx_light_dark/autotester.json b/frontends/calculator/CEdev/examples/gfx_light_dark/autotester.json new file mode 100644 index 0000000..772c268 --- /dev/null +++ b/frontends/calculator/CEdev/examples/gfx_light_dark/autotester.json @@ -0,0 +1,63 @@ +{ + "rom": "84pce_515.rom", + "transfer_files": [ + "bin/DEMO.8xp" + ], + "target": { + "name": "DEMO", + "isASM": true + }, + "sequence": [ + "action|launch", "delay|300", "hash|rectangles", "hash|palette_0", + "key|enter", "delay|1000", "hash|palette_25", + "key|enter", "delay|1000", "hash|palette_50", + "key|enter", "delay|1000", "hash|palette_75", + "key|enter", "delay|1000", "hash|palette_100", + "key|enter", "delay|300", "hash|after_exit" + ], + "hashes": { + "rectangles": { + "description": "Test rectangles", + "start": "vram_start", + "size": "vram_8_size", + "expected_CRCs": [ "328D511E" ] + }, + "palette_0": { + "description": "Test lighten/darken fade, 0% progress", + "start": "lcdPalette", + "size": "8", + "expected_CRCs": [ "41C3BFF8" ] + }, + "palette_25": { + "description": "Test lighten/darken fade, 25% progress", + "start": "lcdPalette", + "size": "8", + "expected_CRCs": [ "5F64F889" ] + }, + "palette_50": { + "description": "Test lighten/darken fade, 50% progress", + "start": "lcdPalette", + "size": "8", + "expected_CRCs": [ "C48CEF7C" ] + }, + "palette_75": { + "description": "Test lighten/darken fade, 75% progress", + "start": "lcdPalette", + "size": "8", + "expected_CRCs": [ "81FEDD4E" ] + }, + "palette_100": { + "description": "Test lighten/darken fade, 100% progress", + "start": "lcdPalette", + "size": "8", + "expected_CRCs": [ "B451E096" ] + }, + "after_exit": { + "description": "Back to the home screen (exit check)", + "start": "vram_start", + "size": "vram_16_size", + "expected_CRCs": [ "FFAF89BA", "101734A5" ] + } + } +} + diff --git a/frontends/calculator/CEdev/examples/gfx_light_dark/makefile b/frontends/calculator/CEdev/examples/gfx_light_dark/makefile new file mode 100644 index 0000000..1f1b36b --- /dev/null +++ b/frontends/calculator/CEdev/examples/gfx_light_dark/makefile @@ -0,0 +1,15 @@ +# ---------------------------- +# Set NAME to the program name +# Set ICON to the png icon file name +# Set DESCRIPTION to display within a compatible shell +# Set COMPRESSED to "YES" to create a compressed program +# ---------------------------- + +NAME ?= DEMO +COMPRESSED ?= NO +ICON ?= iconc.png +DESCRIPTION ?= "C SDK Demo" + +# ---------------------------- + +include $(CEDEV)/include/.makefile diff --git a/frontends/calculator/CEdev/examples/gfx_light_dark/readme.md b/frontends/calculator/CEdev/examples/gfx_light_dark/readme.md new file mode 100644 index 0000000..e429c6c --- /dev/null +++ b/frontends/calculator/CEdev/examples/gfx_light_dark/readme.md @@ -0,0 +1,10 @@ +### GraphX Lighten and Darken Demo + +Demonstrates rectangle drawing and using gfx_Darken and gfx_Lighten to modify colors in the palette to implement fade effects. + + + +--- + +This demo is a part of the C SDK Toolchain for use on the CE. + diff --git a/frontends/calculator/CEdev/examples/gfx_light_dark/screenshot.gif b/frontends/calculator/CEdev/examples/gfx_light_dark/screenshot.gif Binary files differnew file mode 100644 index 0000000..8470736 --- /dev/null +++ b/frontends/calculator/CEdev/examples/gfx_light_dark/screenshot.gif diff --git a/frontends/calculator/CEdev/examples/gfx_light_dark/src/main.c b/frontends/calculator/CEdev/examples/gfx_light_dark/src/main.c new file mode 100644 index 0000000..d4c0a06 --- /dev/null +++ b/frontends/calculator/CEdev/examples/gfx_light_dark/src/main.c @@ -0,0 +1,59 @@ +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> +#include <tice.h> + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <graphx.h> + +#define color gfx_RGBTo1555(34, 55, 89) + +void main(void) { + uint8_t i = 0; + + /* Initialize the 8bpp graphics */ + gfx_Begin(); + + /* For i in 0..255 */ + do { + + /* Fade out to black */ + gfx_palette[0] = gfx_Darken(color, i); + /* Fade in from black */ + gfx_palette[1] = gfx_Darken(color, ~i); + /* Fade in from white */ + gfx_palette[3] = gfx_Lighten(color, ~i); + /* Fade out to white */ + gfx_palette[2] = gfx_Lighten(color, i); + + /* Fade out to black */ + gfx_SetColor(0); + gfx_FillRectangle_NoClip(0, 0, 160, 120); + /* Fade in from black */ + gfx_SetColor(1); + gfx_FillRectangle_NoClip(160, 0, 160, 120); + /* Fade in from white */ + gfx_SetColor(2); + gfx_FillRectangle_NoClip(0, 120, 160, 120); + /* Fade out to white */ + gfx_SetColor(3); + gfx_FillRectangle_NoClip(160, 120, 160, 120); + + /* Wait for a keypress at the start of each quarter of the fade */ + if (!(i & 0x3f)) { + while (!os_GetCSC()); + } + + /* Loop until i is 0 again because of 8 bit range */ + } while (++i); + + /* Wait for a keypress */ + while (!os_GetCSC()); + + /* Usual cleanup */ + gfx_End(); +} |