Skip to content

Commit 9933224

Browse files
committed
Graphics demo 11 demonstrates and tests gfx_Darken and gfx_Lighten better
1 parent 9e7835a commit 9933224

File tree

3 files changed

+127
-80
lines changed

3 files changed

+127
-80
lines changed
Lines changed: 61 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,62 @@
1-
{
2-
"rom": "84pce_515.rom",
3-
"transfer_files": [
4-
"bin/GRAPHX11.8xp"
5-
],
6-
"target": {
7-
"name": "GRAPHX11",
8-
"isASM": true
9-
},
10-
"sequence": [
11-
"action|launch",
12-
"delay|4500",
13-
"hash|1",
14-
"key|enter",
15-
"delay|300",
16-
"hash|2"
17-
],
18-
"hashes": {
19-
"1": {
20-
"description": "Test lighten/darken routines",
21-
"start": "vram_start",
22-
"size": "vram_8_size",
23-
"expected_CRCs": [ "FCE2DEC" ]
24-
},
25-
"2": {
26-
"description": "Back to the home screen (exit check)",
27-
"start": "vram_start",
28-
"size": "vram_16_size",
29-
"expected_CRCs": [ "FFAF89BA", "101734A5", "9DA19F44" ]
30-
}
31-
}
1+
{
2+
"rom": "84pce_515.rom",
3+
"transfer_files": [
4+
"bin/GRAPHX11.8xp"
5+
],
6+
"target": {
7+
"name": "GRAPHX11",
8+
"isASM": true
9+
},
10+
"sequence": [
11+
"action|launch", "delay|300", "hash|rectangles", "hash|palette_0",
12+
"key|enter", "delay|1000", "hash|palette_25",
13+
"key|enter", "delay|1000", "hash|palette_50",
14+
"key|enter", "delay|1000", "hash|palette_75",
15+
"key|enter", "delay|1000", "hash|palette_100",
16+
"key|enter", "delay|300", "hash|after_exit"
17+
],
18+
"hashes": {
19+
"rectangles": {
20+
"description": "Test rectangles",
21+
"start": "vram_start",
22+
"size": "vram_8_size",
23+
"expected_CRCs": [ "328D511E" ]
24+
},
25+
"palette_0": {
26+
"description": "Test lighten/darken fade, 0% progress",
27+
"start": "lcdPalette",
28+
"size": "8",
29+
"expected_CRCs": [ "41C3BFF8" ]
30+
},
31+
"palette_25": {
32+
"description": "Test lighten/darken fade, 25% progress",
33+
"start": "lcdPalette",
34+
"size": "8",
35+
"expected_CRCs": [ "5F64F889" ]
36+
},
37+
"palette_50": {
38+
"description": "Test lighten/darken fade, 50% progress",
39+
"start": "lcdPalette",
40+
"size": "8",
41+
"expected_CRCs": [ "C48CEF7C" ]
42+
},
43+
"palette_75": {
44+
"description": "Test lighten/darken fade, 75% progress",
45+
"start": "lcdPalette",
46+
"size": "8",
47+
"expected_CRCs": [ "81FEDD4E" ]
48+
},
49+
"palette_100": {
50+
"description": "Test lighten/darken fade, 100% progress",
51+
"start": "lcdPalette",
52+
"size": "8",
53+
"expected_CRCs": [ "B451E096" ]
54+
},
55+
"after_exit": {
56+
"description": "Back to the home screen (exit check)",
57+
"start": "vram_start",
58+
"size": "vram_16_size",
59+
"expected_CRCs": [ "FFAF89BA", "101734A5" ]
60+
}
61+
}
3262
}
Binary file not shown.
Lines changed: 66 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,66 @@
1-
/* Keep these headers */
2-
#include <stdbool.h>
3-
#include <stddef.h>
4-
#include <stdint.h>
5-
#include <tice.h>
6-
7-
/* Standard headers - it's recommended to leave them included */
8-
#include <math.h>
9-
#include <stdio.h>
10-
#include <stdlib.h>
11-
#include <string.h>
12-
13-
/* Shared libraries */
14-
#include <lib/ce/graphx.h>
15-
16-
/* Put function prototypes here */
17-
18-
/* Put all your code here */
19-
void main(void) {
20-
uint8_t i = 0;
21-
22-
/* Initialize the 8bpp graphics */
23-
gfx_Begin( gfx_8bpp );
24-
25-
do {
26-
/* Change palette entries 0 and 1 */
27-
gfx_palette[0] = gfx_Darken(gfx_RGBTo1555(255,255,255), i);
28-
gfx_palette[1] = gfx_Lighten(gfx_RGBTo1555(0,0,150), i);
29-
30-
/* Draw using palette 0 entry */
31-
gfx_SetColor(0);
32-
gfx_FillRectangle_NoClip(0,0,160,120);
33-
gfx_FillRectangle_NoClip(160,120,160,120);
34-
35-
/* Draw using palette 1 entry */
36-
gfx_SetColor(1);
37-
gfx_FillRectangle_NoClip(160,0,160,120);
38-
gfx_FillRectangle_NoClip(0,120,160,120);
39-
40-
/* Loop until i is 0 again because of 8 bit range */
41-
} while(++i);
42-
43-
/* Wait for key */
44-
while(!os_GetCSC());
45-
46-
/* Usual cleanup */
47-
gfx_End();
48-
prgm_CleanUp();
49-
}
1+
/* Keep these headers */
2+
#include <stdbool.h>
3+
#include <stddef.h>
4+
#include <stdint.h>
5+
#include <tice.h>
6+
7+
/* Standard headers - it's recommended to leave them included */
8+
#include <math.h>
9+
#include <stdio.h>
10+
#include <stdlib.h>
11+
#include <string.h>
12+
13+
/* Shared libraries */
14+
#include <lib/ce/graphx.h>
15+
16+
#define color gfx_RGBTo1555(34, 55, 89)
17+
18+
/* Put function prototypes here */
19+
20+
/* Put all your code here */
21+
void main(void) {
22+
uint8_t i = 0;
23+
24+
/* Initialize the 8bpp graphics */
25+
gfx_Begin( gfx_8bpp );
26+
27+
/* For i in 0..255 */
28+
do {
29+
30+
/* Fade out to black */
31+
gfx_palette[0] = gfx_Darken(color, i);
32+
/* Fade in from black */
33+
gfx_palette[1] = gfx_Darken(color, ~i);
34+
/* Fade in from white */
35+
gfx_palette[3] = gfx_Lighten(color, ~i);
36+
/* Fade out to white */
37+
gfx_palette[2] = gfx_Lighten(color, i);
38+
39+
/* Fade out to black */
40+
gfx_SetColor(0);
41+
gfx_FillRectangle_NoClip(0,0,160,120);
42+
/* Fade in from black */
43+
gfx_SetColor(1);
44+
gfx_FillRectangle_NoClip(160,0,160,120);
45+
/* Fade in from white */
46+
gfx_SetColor(2);
47+
gfx_FillRectangle_NoClip(0,120,160,120);
48+
/* Fade out to white */
49+
gfx_SetColor(3);
50+
gfx_FillRectangle_NoClip(160,120,160,120);
51+
52+
/* Wait for a keypress at the start of each quarter of the fade */
53+
if (!(i & 0x3f)) {
54+
while(!os_GetCSC());
55+
}
56+
57+
/* Loop until i is 0 again because of 8 bit range */
58+
} while(++i);
59+
60+
/* Wait for a keypress */
61+
while(!os_GetCSC());
62+
63+
/* Usual cleanup */
64+
gfx_End();
65+
prgm_CleanUp();
66+
}

0 commit comments

Comments
 (0)