Skip to content

Commit 269610a

Browse files
committed
Convert bad buffering demo into a blitting demo
1 parent 86fb11a commit 269610a

File tree

6 files changed

+72
-61
lines changed

6 files changed

+72
-61
lines changed

examples/gfx_buffering/autotester.json renamed to examples/gfx_blitting/autotester.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,38 @@
99
},
1010
"sequence": [
1111
"action|launch",
12-
"delay|300",
13-
"hash|1",
12+
"hashWait|1",
1413
"key|enter",
14+
"hashWait|2",
1515
"key|enter",
16-
"delay|300",
17-
"hashWait|2"
16+
"hashWait|3",
17+
"key|enter",
18+
"hashWait|4"
1819
],
1920
"hashes": {
2021
"1": {
21-
"description": "The background will be blank",
22+
"description": "Nothing blitted yet, white screen",
2223
"start": "vram_start",
2324
"size": "vram_8_size",
2425
"expected_CRCs": [ "3132DE74" ]
2526
},
2627
"2": {
28+
"description": "Parts of buffer blitted to screen",
29+
"start": "vram_start",
30+
"size": "vram_8_size",
31+
"expected_CRCs": [ "830291D3" ]
32+
},
33+
"3": {
34+
"description": "Full buffer blitted to screen",
35+
"start": "vram_start",
36+
"size": "vram_8_size",
37+
"expected_CRCs": [ "EA181DC1" ]
38+
},
39+
"4": {
2740
"description": "Back to the home screen (exit check)",
2841
"start": "vram_start",
2942
"size": "vram_16_size",
3043
"expected_CRCs": [ "FFAF89BA", "101734A5", "9DA19F44" ]
3144
}
3245
}
3346
}
34-
File renamed without changes.

examples/gfx_blitting/readme.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### GraphX Blitting Demo
2+
3+
This example demonstrates blitting to manually copy data from the drawing buffer to the screen buffer
4+
5+
---
6+
7+
This demo is a part of the C SDK Toolchain for use on the CE.

examples/gfx_blitting/src/main.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include <stdbool.h>
2+
#include <stddef.h>
3+
#include <stdint.h>
4+
#include <tice.h>
5+
6+
#include <math.h>
7+
#include <stdio.h>
8+
#include <stdlib.h>
9+
#include <string.h>
10+
11+
#include <graphx.h>
12+
13+
/* This tutorial is meant to be played around with to get a feeling for how blitting works */
14+
void main(void) {
15+
uint8_t c;
16+
17+
/* Initialize the 8bpp graphics, screen cleared to white */
18+
gfx_Begin();
19+
20+
/* Draw to buffer instead of directly to screen */
21+
gfx_SetDrawBuffer(); // This is the same as gfx_SetDraw(gfx_buffer)
22+
23+
/* Draw a gradient (to the buffer) */
24+
for (c = 0; c < 8; c++) {
25+
gfx_SetColor(c);
26+
gfx_FillRectangle_NoClip(c * (LCD_WIDTH / 8), 0, LCD_WIDTH / 8, LCD_HEIGHT);
27+
}
28+
29+
/* Wait for a key */
30+
while (!os_GetCSC());
31+
32+
/* Copy parts of the buffer to the screen */
33+
gfx_BlitLines(gfx_buffer, LCD_HEIGHT - 32, 32);
34+
gfx_BlitRectangle(gfx_buffer, LCD_WIDTH / 4, LCD_HEIGHT / 4, LCD_WIDTH / 2, LCD_HEIGHT / 2);
35+
36+
/* Wait for a key */
37+
while (!os_GetCSC());
38+
39+
/* Copy the full buffer to the screen */
40+
gfx_BlitBuffer(); // This is the same as gfx_Blit(gfx_buffer)
41+
42+
/* Wait for a key */
43+
while (!os_GetCSC());
44+
45+
/* Close the graphics */
46+
gfx_End();
47+
}

examples/gfx_buffering/readme.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

examples/gfx_buffering/src/main.c

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)