# HG changeset patch # User Paul Boddie # Date 1540773991 -3600 # Node ID 32cb6b232444bb6a0b045a6dbcfe94bb07e481b3 # Parent 812e66b7ad470985ebfe64a014c36f3bcb3ecbde Improved the blitting code to permit saving and restoring framebuffer data and for blitting with a key colour for transparency. Introduced a sprite to test the blitting code. Established a function to introduce delays in the example code. diff -r 812e66b7ad47 -r 32cb6b232444 examples/vga-dual/Makefile --- a/examples/vga-dual/Makefile Mon Oct 29 01:43:42 2018 +0100 +++ b/examples/vga-dual/Makefile Mon Oct 29 01:46:31 2018 +0100 @@ -27,8 +27,8 @@ # Ordering of objects is important and cannot be left to replacement rules. -SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S -OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o +SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S sprite.S +OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o sprite.o # Application-specific adjustments. # See: examples/vga/Makefile diff -r 812e66b7ad47 -r 32cb6b232444 examples/vga-dual/sprite.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/vga-dual/sprite.S Mon Oct 29 01:46:31 2018 +0100 @@ -0,0 +1,1 @@ +../vga/sprite.S \ No newline at end of file diff -r 812e66b7ad47 -r 32cb6b232444 examples/vga-pmp/Makefile --- a/examples/vga-pmp/Makefile Mon Oct 29 01:43:42 2018 +0100 +++ b/examples/vga-pmp/Makefile Mon Oct 29 01:46:31 2018 +0100 @@ -27,8 +27,8 @@ # Ordering of objects is important and cannot be left to replacement rules. -SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S -OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o +SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S sprite.S +OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o sprite.o # Application-specific adjustments. diff -r 812e66b7ad47 -r 32cb6b232444 examples/vga-pmp/sprite.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/vga-pmp/sprite.S Mon Oct 29 01:46:31 2018 +0100 @@ -0,0 +1,1 @@ +../vga/sprite.S \ No newline at end of file diff -r 812e66b7ad47 -r 32cb6b232444 examples/vga-timer/Makefile --- a/examples/vga-timer/Makefile Mon Oct 29 01:43:42 2018 +0100 +++ b/examples/vga-timer/Makefile Mon Oct 29 01:46:31 2018 +0100 @@ -27,8 +27,8 @@ # Ordering of objects is important and cannot be left to replacement rules. -SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S -OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o +SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S sprite.S +OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o sprite.o # Application-specific adjustments. # See: examples/vga/Makefile diff -r 812e66b7ad47 -r 32cb6b232444 examples/vga-timer/sprite.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/vga-timer/sprite.S Mon Oct 29 01:46:31 2018 +0100 @@ -0,0 +1,1 @@ +../vga/sprite.S \ No newline at end of file diff -r 812e66b7ad47 -r 32cb6b232444 examples/vga/Makefile --- a/examples/vga/Makefile Mon Oct 29 01:43:42 2018 +0100 +++ b/examples/vga/Makefile Mon Oct 29 01:46:31 2018 +0100 @@ -27,8 +27,8 @@ # Ordering of objects is important and cannot be left to replacement rules. -SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S -OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o +SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S sprite.S +OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o sprite.o # Application-specific adjustments. diff -r 812e66b7ad47 -r 32cb6b232444 examples/vga/main.c --- a/examples/vga/main.c Mon Oct 29 01:43:42 2018 +0100 +++ b/examples/vga/main.c Mon Oct 29 01:46:31 2018 +0100 @@ -67,24 +67,32 @@ extern uint8_t screendata[]; extern uint32_t screendata_width, screendata_height; +extern uint8_t sprite[]; +extern uint32_t sprite_width, sprite_height; + +/* Busy wait. */ + +static void wait(uint32_t delay) +{ + uint32_t counter = delay; + + if (!delay) return; + while (counter--) __asm__(""); /* retain loop */ +} /* Blink an attached LED with delays implemented using a loop. */ static void blink(uint32_t delay, uint32_t port, uint32_t pins) { - uint32_t counter; - /* Clear outputs (LED). */ CLR_REG(port, pins); while (1) { - counter = delay; - - while (counter--) __asm__(""); /* retain loop */ + wait(delay); /* Invert outputs (LED). */ @@ -92,6 +100,31 @@ } } +/* Move a sprite around on the framebuffer. */ + +static void animate(uint32_t delay) +{ + uint8_t background[sprite_width * sprite_height]; + int x, y; + + while (1) + for (y = 0; y < screendata_height - sprite_height; y++) + for (x = 0; x < screendata_width - sprite_width; x++) + { + /* Copy to the store from the display, then blit the image. */ + + copy_display(&display_config, background, sprite_width, sprite_height, x, y, -1, 0); + copy_display(&display_config, sprite, sprite_width, sprite_height, x, y, 0x8c, 1); + + wait(delay); + + /* Copy to the display from the store, restoring the original + background. */ + + copy_display(&display_config, background, sprite_width, sprite_height, x, y, -1, 1); + } +} + /* Main program. */ @@ -136,8 +169,14 @@ interrupts_on(); - copy_to_framebuffer(&display_config, screendata, screendata_width, screendata_height); - blink(1 << 24, PORTA, LED_PIN); + /* Plot the image centred on the screen. */ + + copy_display(&display_config, screendata, screendata_width, screendata_height, + (LINE_LENGTH - screendata_width) / 2, (LINE_COUNT - screendata_height) / 2, -1, 1); + + /* Move a sprite around on the screen with a delay between each movement. */ + + animate(1 << 24); } diff -r 812e66b7ad47 -r 32cb6b232444 examples/vga/sprite.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/vga/sprite.S Mon Oct 29 01:46:31 2018 +0100 @@ -0,0 +1,1425 @@ +.section .rodata, "a" + +/* Options: +['-W', '48', '-H', '64', '-S', '-b'] +*/ + +.globl sprite +.globl sprite_width +.globl sprite_height + +sprite_width: +.word 22 +sprite_height: +.word 64 + +sprite: + +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x80 +.byte 0x80 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xaa +.byte 0x95 +.byte 0x90 +.byte 0x90 +.byte 0x90 +.byte 0xaa +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xbf +.byte 0x3f +.byte 0xa5 +.byte 0xa4 +.byte 0xa5 +.byte 0xa5 +.byte 0x3f +.byte 0xbf +.byte 0x2a +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xa5 +.byte 0xb9 +.byte 0x94 +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x3f +.byte 0xbf +.byte 0xbf +.byte 0xbe +.byte 0xaa +.byte 0xbe +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0x3f +.byte 0x00 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0x3f +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0x3f +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0x3f +.byte 0xbf +.byte 0x80 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x95 +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xa5 +.byte 0x80 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xbf +.byte 0xaa +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x80 +.byte 0xaa +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xba +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x80 +.byte 0x95 +.byte 0xaa +.byte 0xa5 +.byte 0xbe +.byte 0x95 +.byte 0x95 +.byte 0x90 +.byte 0x80 +.byte 0x80 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x80 +.byte 0x95 +.byte 0x95 +.byte 0xbe +.byte 0x95 +.byte 0xbe +.byte 0x2a +.byte 0xba +.byte 0xa9 +.byte 0xaa +.byte 0xaa +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x95 +.byte 0xaa +.byte 0xaa +.byte 0x95 +.byte 0x81 +.byte 0x15 +.byte 0x15 +.byte 0xbf +.byte 0x3f +.byte 0xba +.byte 0xaa +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xaa +.byte 0xbf +.byte 0xbf +.byte 0xa6 +.byte 0x81 +.byte 0x95 +.byte 0x95 +.byte 0xbf +.byte 0xbf +.byte 0xaa +.byte 0xaa +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xba +.byte 0x3f +.byte 0xbf +.byte 0x15 +.byte 0x81 +.byte 0x80 +.byte 0x15 +.byte 0xbf +.byte 0x3f +.byte 0x3f +.byte 0xba +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xaa +.byte 0xba +.byte 0xbf +.byte 0xbf +.byte 0x95 +.byte 0x95 +.byte 0x2a +.byte 0xaa +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xa9 +.byte 0x95 +.byte 0xaa +.byte 0x3f +.byte 0xbf +.byte 0x95 +.byte 0x80 +.byte 0xaa +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0x3f +.byte 0xbf +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x95 +.byte 0x90 +.byte 0x15 +.byte 0x95 +.byte 0xbf +.byte 0xbe +.byte 0xbf +.byte 0xba +.byte 0xaa +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xaa +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x95 +.byte 0x95 +.byte 0x95 +.byte 0x90 +.byte 0xa5 +.byte 0x94 +.byte 0x95 +.byte 0x95 +.byte 0x95 +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0x3f +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x3f +.byte 0x95 +.byte 0x95 +.byte 0xa5 +.byte 0x15 +.byte 0xa5 +.byte 0x90 +.byte 0x95 +.byte 0xbe +.byte 0x2a +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xaa +.byte 0x95 +.byte 0x95 +.byte 0xaa +.byte 0x95 +.byte 0x90 +.byte 0x90 +.byte 0xa5 +.byte 0xbe +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xaa +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xa5 +.byte 0x95 +.byte 0x15 +.byte 0x95 +.byte 0x95 +.byte 0x80 +.byte 0x95 +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xa9 +.byte 0xaa +.byte 0xa9 +.byte 0xa5 +.byte 0x94 +.byte 0x95 +.byte 0x95 +.byte 0xba +.byte 0x3f +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0x3f +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x95 +.byte 0x95 +.byte 0x95 +.byte 0x95 +.byte 0x95 +.byte 0x95 +.byte 0x95 +.byte 0x95 +.byte 0x15 +.byte 0xbe +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xaa +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x95 +.byte 0x90 +.byte 0x95 +.byte 0xa5 +.byte 0x95 +.byte 0x95 +.byte 0x90 +.byte 0x95 +.byte 0x2a +.byte 0x3f +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0x2a +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xaa +.byte 0xa5 +.byte 0x95 +.byte 0x95 +.byte 0x95 +.byte 0x90 +.byte 0x15 +.byte 0x2a +.byte 0xbe +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbe +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x90 +.byte 0x90 +.byte 0xaa +.byte 0x90 +.byte 0x90 +.byte 0x95 +.byte 0xbf +.byte 0x94 +.byte 0x3f +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xaa +.byte 0x2a +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xaa +.byte 0x90 +.byte 0x90 +.byte 0x15 +.byte 0xba +.byte 0xba +.byte 0xa5 +.byte 0xa5 +.byte 0xaa +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xaa +.byte 0xa5 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xba +.byte 0x15 +.byte 0x90 +.byte 0x90 +.byte 0xbf +.byte 0xaa +.byte 0xaa +.byte 0xaa +.byte 0xa5 +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0x3f +.byte 0xbf +.byte 0xaa +.byte 0x2a +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x94 +.byte 0x90 +.byte 0x90 +.byte 0x95 +.byte 0xbf +.byte 0xbf +.byte 0xaa +.byte 0x90 +.byte 0x80 +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xaa +.byte 0xaa +.byte 0xaa +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x95 +.byte 0xa5 +.byte 0x90 +.byte 0xaa +.byte 0xbf +.byte 0x3f +.byte 0x94 +.byte 0x80 +.byte 0xa9 +.byte 0x00 +.byte 0x3f +.byte 0xbf +.byte 0xbf +.byte 0x3f +.byte 0xaa +.byte 0x2a +.byte 0x2a +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x2a +.byte 0x90 +.byte 0x2a +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xaa +.byte 0x80 +.byte 0xa5 +.byte 0xa5 +.byte 0xbf +.byte 0x3f +.byte 0xba +.byte 0xbf +.byte 0xaa +.byte 0xaa +.byte 0xaa +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xaa +.byte 0x80 +.byte 0xa9 +.byte 0xbf +.byte 0xbf +.byte 0x3f +.byte 0x80 +.byte 0x80 +.byte 0x95 +.byte 0xaa +.byte 0xbf +.byte 0xbf +.byte 0xaa +.byte 0xba +.byte 0xaa +.byte 0x2a +.byte 0xaa +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x95 +.byte 0xaa +.byte 0x90 +.byte 0xbf +.byte 0x3f +.byte 0xbf +.byte 0x80 +.byte 0x90 +.byte 0x80 +.byte 0x95 +.byte 0x3f +.byte 0xba +.byte 0xba +.byte 0xbe +.byte 0xaa +.byte 0xaa +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x2a +.byte 0xaa +.byte 0x80 +.byte 0xbf +.byte 0xbf +.byte 0x80 +.byte 0x90 +.byte 0x90 +.byte 0x90 +.byte 0xaa +.byte 0x3f +.byte 0xba +.byte 0x3f +.byte 0x3f +.byte 0xaa +.byte 0xa5 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x2a +.byte 0x95 +.byte 0x94 +.byte 0x90 +.byte 0x2a +.byte 0x90 +.byte 0xa5 +.byte 0x80 +.byte 0x80 +.byte 0xaa +.byte 0xaa +.byte 0xba +.byte 0xaa +.byte 0xaa +.byte 0xaa +.byte 0x80 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x3f +.byte 0x90 +.byte 0x94 +.byte 0xbe +.byte 0x3f +.byte 0xbf +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0x3f +.byte 0x3f +.byte 0xaa +.byte 0xaa +.byte 0xba +.byte 0xaa +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x95 +.byte 0x90 +.byte 0x90 +.byte 0x94 +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0xba +.byte 0xbf +.byte 0xba +.byte 0xbe +.byte 0xaa +.byte 0x3f +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x95 +.byte 0x90 +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0xbe +.byte 0xbf +.byte 0xba +.byte 0xaa +.byte 0xbf +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xa9 +.byte 0x80 +.byte 0x90 +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0xbe +.byte 0xbf +.byte 0xbe +.byte 0xaa +.byte 0xba +.byte 0x95 +.byte 0x80 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x95 +.byte 0x95 +.byte 0x80 +.byte 0x80 +.byte 0x94 +.byte 0x80 +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xaa +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xaa +.byte 0x95 +.byte 0x80 +.byte 0x95 +.byte 0x80 +.byte 0x95 +.byte 0xbf +.byte 0xbf +.byte 0xbf +.byte 0xba +.byte 0xba +.byte 0xa5 +.byte 0x95 +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xbe +.byte 0x2a +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0xaa +.byte 0xba +.byte 0xbf +.byte 0x8c +.byte 0xba +.byte 0xbe +.byte 0xbe +.byte 0xba +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x80 +.byte 0xaa +.byte 0x2a +.byte 0xa5 +.byte 0x15 +.byte 0x8c +.byte 0x95 +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x15 +.byte 0xa5 +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0x8c +.byte 0x8c +.byte 0xa6 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0x90 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x80 +.byte 0x80 +.byte 0x80 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x80 +.byte 0x80 +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x80 +.byte 0x80 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x80 +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x80 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xaa +.byte 0x90 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x95 +.byte 0xbf +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x90 +.byte 0x80 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x80 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xbf +.byte 0xb9 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xa5 +.byte 0xbf +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x90 +.byte 0x15 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x95 +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xaa +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0xbe +.byte 0xaa +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c +.byte 0x8c diff -r 812e66b7ad47 -r 32cb6b232444 include/display.h --- a/include/display.h Mon Oct 29 01:43:42 2018 +0100 +++ b/include/display.h Mon Oct 29 01:46:31 2018 +0100 @@ -65,7 +65,10 @@ /* Access functions. */ int get_position(display_config_t *cfg, int x); + void test_linedata(display_config_t *cfg); -void copy_to_framebuffer(display_config_t *cfg, uint8_t *image, int width, int height); + +void copy_display(display_config_t *cfg, uint8_t *store, int width, int height, + int x, int y, int key, int to_display); #endif /* __DISPLAY_H__ */ diff -r 812e66b7ad47 -r 32cb6b232444 lib/display.c --- a/lib/display.c Mon Oct 29 01:43:42 2018 +0100 +++ b/lib/display.c Mon Oct 29 01:46:31 2018 +0100 @@ -55,21 +55,31 @@ } } -/* Copy to framebuffer. */ +/* Copying from/to the display to/from a backing store. */ -void copy_to_framebuffer(display_config_t *cfg, uint8_t *image, int width, int height) +void copy_display(display_config_t *cfg, uint8_t *store, int width, int height, + int x, int y, int key, int to_display) { - int sx, sy, tx, ty; - uint8_t *targetline = cfg->framebuffer, *sourceline = image; + int sx, sy, dx, dy; + uint8_t *storeline = store, + *displayline = cfg->framebuffer + y * cfg->line_length, + pixel; - for (sy = 0, ty = 0; (sy < height) && (ty < cfg->line_count); sy++, ty++) + for (sy = 0, dy = y; (sy < height) && (dy < cfg->line_count); sy++, dy++) { - for (sx = 0, tx = 0; (tx < cfg->line_length); sx++, tx++) + for (sx = 0, dx = x; (sx < width) && (dx < cfg->line_length); sx++, dx++) { - targetline[get_position(cfg, tx)] = (sx < width) ? sourceline[sx] : 0; + if (to_display) + { + pixel = storeline[sx]; + if ((key < 0) || (pixel != key)) + displayline[get_position(cfg, dx)] = pixel; + } + else + storeline[sx] = displayline[get_position(cfg, dx)]; } - sourceline += width; - targetline += cfg->line_length; + storeline += width; + displayline += cfg->line_length; } }