Demo of low res colour vga video for stm32f3 discovery board
Dependencies: STM32F3-Discovery-minimal
Fork of Space_Invaders_Demo by
Diff: gdi.c
- Revision:
- 8:34fb94209517
- Parent:
- 5:594c9712697c
- Child:
- 10:8ffcefda667a
--- a/gdi.c Mon May 28 10:38:27 2018 +0000 +++ b/gdi.c Tue May 29 23:16:35 2018 +0000 @@ -388,11 +388,11 @@ // return none //***************************************************************************** void gdiRectangle(i16 x0, i16 y0, i16 x1, i16 y1, u16 rop) { - - gdiLine(NULL,x0,y0,x1,y0,rop); - gdiLine(NULL,x0,y1,x1,y1,rop); - gdiLine(NULL,x0,y0,x0,y1,rop); - gdiLine(NULL,x1,y0,x1,y1,rop); + + gdiHLine(x0,y0,x1,rop); + gdiHLine(x0,y1,x1,rop); + gdiVLine(x0,y0,y1,rop); + gdiVLine(x1,y0,y1,rop); } //***************************************************************************** @@ -440,6 +440,10 @@ } void gdiHLine(u16 x, u16 y, u16 x1, u16 rop) { +// printf("gdiHline %d %d %d\n",x,y,x1); + if(x>=VID_HSIZE) x=VID_HSIZE-1; + if(x1>=VID_HSIZE) x1=VID_HSIZE-1; + if(y>=VID_VSIZE) y=VID_VSIZE-1; if(x>x1) { int t=x1; x1=x; @@ -452,6 +456,25 @@ } } + +void gdiVLine(u16 x, u16 y, u16 y1, u16 rop) { +// printf("gdiVline %d %d %d\n",x,y,y1); + if(x>=VID_HSIZE) x=VID_HSIZE-1; + if(y1>=VID_VSIZE) y1=VID_VSIZE-1; + if(y>=VID_VSIZE) y=VID_VSIZE-1; + if(y>y1) { + u16 t=y1; + y1=y; + y=t; + } + char *start=fb[y]+x; + int n=y1-y+1; + while(n--) { + *start|=(colour<<4); + start+=HTOTAL; + } +} + void gdiFilledCircle(u16 x, u16 y, u16 r, u16 rop) { i32 x1, y1;