filltest.c (1458B)
1/* Sample Program to demonstrate the drawing functions in GBDK */ 2/* Jon Fuge jonny@q-continuum.demon.co.uk */ 3 4#include <gb/gb.h> 5#include <stdint.h> 6#include <gb/drawing.h> 7 8void linetest(uint8_t x, uint8_t y, uint8_t w) { 9 color(DKGREY,WHITE,SOLID); 10 for (int i = -w; i <= w; i++) line(x,y,x+i,y-w); 11 for (int i = -w; i <= w; i++) line(x,y,x+w,y+i); 12 for (int i = -w; i <= w; i++) line(x,y,x+i,y+w); 13 for (int i = -w; i <= w; i++) line(x,y,x-w,y+i); 14} 15 16void main(void) 17{ 18 uint8_t a,b,c,d,e; 19 c=0; 20 /* Draw many characters on the screen with different fg and bg colours */ 21 for (a=0; a<=15; a++) { 22 for (b=0; b<=15; b++) { 23 gotogxy(b,a); 24 d=a/4; 25 e=b/4; 26 if (d==e) { 27 d=3-e; 28 } 29 color(d,e,SOLID); 30 gprintf("%c",c++); 31 } 32 } 33 34 /* Draw two circles, a line, and two boxes in different drawing modes */ 35 color(LTGREY,WHITE,SOLID); 36 circle(140,20,15,M_FILL); 37 color(BLACK,WHITE,SOLID); 38 circle(140,20,10,M_NOFILL); 39 color(DKGREY,WHITE,XOR); 40 circle(120,40,30,M_FILL); 41 line(0,0,159,143); 42 color(BLACK,LTGREY,SOLID); 43 box(0,130,40,143,M_NOFILL); 44 box(50,130,90,143,M_FILL); 45 46 47 linetest(130, 100, 20); 48 49 /* Scroll the screen using the hardest method imaginable :) */ 50 for (c=0; c<=143; c++) { 51 for (b=0; b<=142; b++) { 52 for (a=0; a<=159; a++) { 53 color(getpix(a,b+1),WHITE,SOLID); 54 plot_point(a,b); 55 } 56 color(WHITE,WHITE,SOLID); 57 } 58 line(0,143,159,143); 59 } 60}