From 332ec3ced094923dee6a07f550d689a34b45154d Mon Sep 17 00:00:00 2001 From: Jon Langseth Date: Sat, 21 Jul 2012 13:25:07 +0200 Subject: [PATCH] Someone was complaining about my use of tabs vs spaces. I agree. This commit replaces all indentation with tabs, except for ASM code. --- draw.c | 102 +++++++++++++++++++++++++++---------------------------- render.c | 24 ++++++------- 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/draw.c b/draw.c index f2355c3..43af32b 100644 --- a/draw.c +++ b/draw.c @@ -6,34 +6,34 @@ extern uint8_t hres_bytes; void sp(uint8_t x, uint8_t y, uint8_t color) { - if (color==0) screen_buffer[(x/8) + (y*hres_bytes)] &= ~0x80 >> (x&7); - else if (color==1) screen_buffer[(x/8) + (y*hres_bytes)] |= 0x80 >> (x&7); - else screen_buffer[(x/8) + (y*hres_bytes)] ^= 0x80 >> (x&7); + if (color==0) screen_buffer[(x/8) + (y*hres_bytes)] &= ~0x80 >> (x&7); + else if (color==1) screen_buffer[(x/8) + (y*hres_bytes)] |= 0x80 >> (x&7); + else screen_buffer[(x/8) + (y*hres_bytes)] ^= 0x80 >> (x&7); } void set_pixel(uint8_t x, uint8_t y, uint8_t color) { - if (x >= hres_bytes*8 || y >= VRES) - return; - sp(x,y,color); + if (x >= hres_bytes*8 || y >= VRES) + return; + sp(x,y,color); } void fill(uint8_t color) { - switch(color) { - case c_BLACK: - for (int i = 0; i < (hres_bytes*VRES); i++) - screen_buffer[i] = 0; - break; - case c_WHITE: - for (int i = 0; i < (hres_bytes*VRES); i++) - screen_buffer[i] = 0xFF; - break; - case c_INVERT: - for (int i = 0; i < (hres_bytes*VRES); i++) - screen_buffer[i] = ~screen_buffer[i]; - break; - } + switch(color) { + case c_BLACK: + for (int i = 0; i < (hres_bytes*VRES); i++) + screen_buffer[i] = 0; + break; + case c_WHITE: + for (int i = 0; i < (hres_bytes*VRES); i++) + screen_buffer[i] = 0xFF; + break; + case c_INVERT: + for (int i = 0; i < (hres_bytes*VRES); i++) + screen_buffer[i] = ~screen_buffer[i]; + break; + } } @@ -63,8 +63,8 @@ Bresenham's line algorithm, optimized and simplified. void draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t c) { - if (x0 > hres_bytes*8 || y0 > VRES || x1 > hres_bytes*8 || y1 > VRES) - return; + if (x0 > hres_bytes*8 || y0 > VRES || x1 > hres_bytes*8 || y1 > VRES) + return; int dx, dy, sx, sy, err, p; @@ -77,7 +77,7 @@ void draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t c) while (1) { sp(x0, y0, c); - if ( ( x0 == x1 ) && ( y0 == y1 ) ) return; + if ( ( x0 == x1 ) && ( y0 == y1 ) ) return; p = 2 * err; if ( p > -dy ) { @@ -118,30 +118,30 @@ void _draw_rect(uint8_t x0, uint8_t y0, uint8_t w, uint8_t h, int8_t c, int8_t f void _draw_circle(uint8_t x0, uint8_t y0, uint8_t radius, int8_t c, int8_t fc) { - int f = 1 - radius; - int ddF_x = 1; - int ddF_y = -2 * radius; - int x = 0; - int y = radius; - uint8_t pyy = y,pyx = x; - - //there is a fill color - if (fc != -1) - draw_row(y0,x0-radius,x0+radius,fc); - - sp(x0, y0 + radius,c); - sp(x0, y0 - radius,c); - sp(x0 + radius, y0,c); - sp(x0 - radius, y0,c); - - while(x < y) { - if(f >= 0) { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; + int f = 1 - radius; + int ddF_x = 1; + int ddF_y = -2 * radius; + int x = 0; + int y = radius; + uint8_t pyy = y,pyx = x; + + //there is a fill color + if (fc != -1) + draw_row(y0,x0-radius,x0+radius,fc); + + sp(x0, y0 + radius,c); + sp(x0, y0 - radius,c); + sp(x0 + radius, y0,c); + sp(x0 - radius, y0,c); + + while(x < y) { + if(f >= 0) { + y--; + ddF_y += 2; + f += ddF_y; + } + x++; + ddF_x += 2; f += ddF_x; //there is a fill color if (fc > -1) { @@ -163,10 +163,10 @@ void _draw_circle(uint8_t x0, uint8_t y0, uint8_t radius, int8_t c, int8_t fc) { sp(x0 + x, y0 - y,c); sp(x0 - x, y0 - y,c); sp(x0 + y, y0 + x,c); - sp(x0 - y, y0 + x,c); - sp(x0 + y, y0 - x,c); - sp(x0 - y, y0 - x,c); - } + sp(x0 - y, y0 + x,c); + sp(x0 + y, y0 - x,c); + sp(x0 - y, y0 - x,c); + } } void draw_rect(uint8_t x0, uint8_t y0, uint8_t w, uint8_t h, uint8_t c) diff --git a/render.c b/render.c index 06e6a22..910ef09 100644 --- a/render.c +++ b/render.c @@ -8,7 +8,7 @@ extern volatile char* screen_buffer; void asm_render_line( void ) { - __asm__ __volatile__ ( + __asm__ __volatile__ ( ".macro outbit p" "\n\t" "BST __tmp_reg__,7" "\n\t" // Store bit 7 to T "BLD r16,7" "\n\t" // Load bit T into r16 bit number 7 @@ -34,33 +34,33 @@ void asm_render_line( void ) { "start_line:" "\n\t" "LD __tmp_reg__,X+" "\n\t" // Load from address pointed to by X into temporary register, then increment X-pointer - "outbit %[port]" "\n\t" // Output bit 7 using Macro + "outbit %[port]" "\n\t" // Output bit 7 using Macro "LSL __tmp_reg__" "\n\t" // Left-shift for next bit - "outbit %[port]" "\n\t" // Output bit 6 using Macro + "outbit %[port]" "\n\t" // Output bit 6 using Macro "LSL __tmp_reg__" "\n\t" // Left-shift for next bit - "outbit %[port]" "\n\t" // Output bit 5 using Macro + "outbit %[port]" "\n\t" // Output bit 5 using Macro "LSL __tmp_reg__" "\n\t" // Left-shift for next bit - "outbit %[port]" "\n\t" // Output bit 4 using Macro + "outbit %[port]" "\n\t" // Output bit 4 using Macro "LSL __tmp_reg__" "\n\t" // Left-shift for next bit - "outbit %[port]" "\n\t" // Output bit 3 using Macro + "outbit %[port]" "\n\t" // Output bit 3 using Macro "LSL __tmp_reg__" "\n\t" // Left-shift for next bit - "outbit %[port]" "\n\t" // Output bit 2 using Macro + "outbit %[port]" "\n\t" // Output bit 2 using Macro "LSL __tmp_reg__" "\n\t" // Left-shift for next bit - "outbit %[port]" "\n\t" // Output bit 1 using Macro + "outbit %[port]" "\n\t" // Output bit 1 using Macro "DEC %[hr]" "\n\t" // Decrement num-bytes-remaining-in-resolution "BRNE loop_byte" "\n\t" // Branch to loop6 if %[hres] != zero "LSL __tmp_reg__" "\n\t" // Left-shift for last bit on the line - "outbit %[port]" "\n\t" // Output bit 0 using Macro. + "outbit %[port]" "\n\t" // Output bit 0 using Macro. "CBI %[port],7" "\n\t" // Clear our "display bit" to ensure we end on black - : + : : [port] "i" (_SFR_IO_ADDR(PORTD)), "x" (screen_buffer), "y" (buffer_position), [hr] "d" (hres_bytes) - : "r16" - ); + : "r16" + ); } -- 2.39.2