From 5e35560074b324ce739fc29e7d319973c8621fc2 Mon Sep 17 00:00:00 2001 From: Matthew Waltz Date: Sun, 6 Oct 2024 22:31:44 -0600 Subject: [PATCH] [graphx] fix and add tests for graphx #471 --- .../graphx/shapes/autotest.json | 4 +-- .../library_examples/graphx/shapes/src/main.c | 12 +++---- test/graphx/bug_471/autotest.json | 36 +++++++++++++++++++ test/graphx/bug_471/makefile | 15 ++++++++ test/graphx/bug_471/src/main.c | 19 ++++++++++ 5 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 test/graphx/bug_471/autotest.json create mode 100644 test/graphx/bug_471/makefile create mode 100644 test/graphx/bug_471/src/main.c diff --git a/examples/library_examples/graphx/shapes/autotest.json b/examples/library_examples/graphx/shapes/autotest.json index b09931c22..6accee0df 100644 --- a/examples/library_examples/graphx/shapes/autotest.json +++ b/examples/library_examples/graphx/shapes/autotest.json @@ -64,14 +64,14 @@ "description": "Test triangle fill display", "start": "vram_start", "size": "vram_8_size", - "expected_CRCs": [ "A1154AE5" ] + "expected_CRCs": [ "7AA72F13" ] }, "6": { "description": "Test line display", "start": "vram_start", "size": "vram_8_size", - "expected_CRCs": [ "08AE93E1" ] + "expected_CRCs": [ "D94140BB" ] }, "7": { diff --git a/examples/library_examples/graphx/shapes/src/main.c b/examples/library_examples/graphx/shapes/src/main.c index 4ad752d11..632c1046f 100644 --- a/examples/library_examples/graphx/shapes/src/main.c +++ b/examples/library_examples/graphx/shapes/src/main.c @@ -119,12 +119,12 @@ int main(void) /* Line Drawing */ gfx_SetColor(227); - gfx_Line(-10, -10, 330, 250); - gfx_Line(-10, 250, 330, -10); - gfx_Line_NoClip(0, 0, 320, 0); - gfx_Line_NoClip(0, 0, 0, 240); - gfx_Line_NoClip(0, 240, 320, 240); - gfx_Line_NoClip(320, 240, 320, 0); + gfx_Line(-10, -10, 329, 249); + gfx_Line(-10, 249, 329, -10); + gfx_Line_NoClip(0, 0, 319, 0); + gfx_Line_NoClip(0, 0, 0, 239); + gfx_Line_NoClip(0, 239, 319, 239); + gfx_Line_NoClip(319, 239, 319, 0); gfx_SetColor(18); gfx_HorizLine(-10, 10, 340); gfx_HorizLine_NoClip(0, 230, 320); diff --git a/test/graphx/bug_471/autotest.json b/test/graphx/bug_471/autotest.json new file mode 100644 index 000000000..26d18fe18 --- /dev/null +++ b/test/graphx/bug_471/autotest.json @@ -0,0 +1,36 @@ +{ + "transfer_files": + [ + "bin/DEMO.8xp" + ], + "target": + { + "name": "DEMO", + "isASM": true + }, + "sequence": + [ + "action|launch", + "delay|100", + "hashWait|1", + "key|enter", + "hashWait|2" + ], + "hashes": + { + "1": + { + "description": "Test line display", + "start": "vram_start", + "size": "vram_8_size", + "expected_CRCs": [ "69DA2AC4" ] + }, + "2": + { + "description": "Test program exit", + "start": "vram_start", + "size": "vram_16_size", + "expected_CRCs": [ "FFAF89BA", "101734A5", "9DA19F44", "A32840C8", "349F4775" ] + } + } +} diff --git a/test/graphx/bug_471/makefile b/test/graphx/bug_471/makefile new file mode 100644 index 000000000..b869526cc --- /dev/null +++ b/test/graphx/bug_471/makefile @@ -0,0 +1,15 @@ +# ---------------------------- +# Makefile Options +# ---------------------------- + +NAME = DEMO +ICON = icon.png +DESCRIPTION = "CE C Toolchain Demo" +COMPRESSED = NO + +CFLAGS = -Wall -Wextra -Oz +CXXFLAGS = -Wall -Wextra -Oz + +# ---------------------------- + +include $(shell cedev-config --makefile) diff --git a/test/graphx/bug_471/src/main.c b/test/graphx/bug_471/src/main.c new file mode 100644 index 000000000..1a5bd53a9 --- /dev/null +++ b/test/graphx/bug_471/src/main.c @@ -0,0 +1,19 @@ +#include +#include + +int main(void) +{ + gfx_Begin(); + + gfx_SetColor(7); // green + gfx_Line(-100, 20, 30, 40); + + gfx_SetColor(224); // red + gfx_Line(30, 40, -100, 20); // same numbers as above, just flipped order + + while (!os_GetCSC()); + + gfx_End(); + + return 0; +}