From 927ab4638cc0b8f71125215107f09ddf3557ce7a Mon Sep 17 00:00:00 2001 From: Jean-Yves Lamoureux Date: Fri, 23 Feb 2007 14:34:48 +0000 Subject: [PATCH] * Added squared transition to cacademo --- build-kernel | 4 ++-- src/cacademo.c | 40 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/build-kernel b/build-kernel index fca0fa2..6419144 100755 --- a/build-kernel +++ b/build-kernel @@ -33,6 +33,6 @@ gcc $LDFLAGS -o src/cacademo kernel/multiboot.o kernel/kernel.o src/cacademo.o c objcopy -O binary src/cacademo cacademo.boot # For further development: create floppy images using the kernel -#gcc -traditional -c -o bootsect.o /usr/src/linux/arch/i386/boot/bootsect.S -#ld -Ttext 0x0 -s --oformat binary bootsect.o -o cacademo.img +gcc -traditional -c -o bootsect.o /usr/src/linux/arch/i386/boot/bootsect.S +ld -Ttext 0x0 -s --oformat binary bootsect.o -o cacademo.img diff --git a/src/cacademo.c b/src/cacademo.c index 30dc9d7..8592d68 100644 --- a/src/cacademo.c +++ b/src/cacademo.c @@ -52,10 +52,10 @@ void (*fn[])(enum action, cucul_canvas_t *) = #define DEMO_FRAMES cucul_rand(500, 1000) #define TRANSITION_FRAMES 40 -#define TRANSITION_COUNT 2 +#define TRANSITION_COUNT 3 #define TRANSITION_CIRCLE 0 #define TRANSITION_STAR 1 - +#define TRANSITION_SQUARE 2 /* Common macros for dither-based demos */ #define XSIZ 256 @@ -210,6 +210,16 @@ void transition(cucul_canvas_t *mask, int tmode, int completed) }; static float star_rot[sizeof(star)/sizeof(*star)]; + + static float const square[] = + { + -1, -1, + 1, -1, + 1, 1, + -1, 1 + }; + static float square_rot[sizeof(square)/sizeof(*square)]; + float mulx = 0.0075f * completed * cucul_get_canvas_width(mask); float muly = 0.0075f * completed * cucul_get_canvas_height(mask); int w2 = cucul_get_canvas_width(mask) / 2; @@ -219,6 +229,30 @@ void transition(cucul_canvas_t *mask, int tmode, int completed) switch(tmode) { + case TRANSITION_SQUARE: + /* Compute rotated coordinates */ + for(i = 0; i < (sizeof(square) / sizeof(*square)) / 2; i++) + { + x = square[i * 2]; + y = square[i * 2 + 1]; + + square_rot[i * 2] = x * cos(angle) - y * sin(angle); + square_rot[i * 2 + 1] = y * cos(angle) + x * sin(angle); + } + + mulx *= 1.8; + muly *= 1.8; + cucul_fill_triangle(mask, + square_rot[0*2] * mulx + w2, square_rot[0*2+1] * muly + h2, \ + square_rot[1*2] * mulx + w2, square_rot[1*2+1] * muly + h2, \ + square_rot[2*2] * mulx + w2, square_rot[2*2+1] * muly + h2, '#'); + cucul_fill_triangle(mask, + square_rot[0*2] * mulx + w2, square_rot[0*2+1] * muly + h2, \ + square_rot[2*2] * mulx + w2, square_rot[2*2+1] * muly + h2, \ + square_rot[3*2] * mulx + w2, square_rot[3*2+1] * muly + h2, '#'); + break; + + case TRANSITION_STAR: /* Compute rotated coordinates */ for(i = 0; i < (sizeof(star) / sizeof(*star)) / 2; i++) @@ -552,7 +586,7 @@ void moire(enum action action, cucul_canvas_t *cv) { draw_line(dx / 3, dy / 3, (i / DISCTHICKNESS) % 2); draw_line(dy / 3, dx / 3, (i / DISCTHICKNESS) % 2); - + t += t > 0 ? dx - dy-- : dx; } }