X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=samples%2Ftgidemo.c;h=2a603dd1d9bb70823ec35355372ba268ed4c1032;hb=5ef1f65c9bd9f83ecbb8c66c6d8f8da0dec85e47;hp=818d35d25b51ccc535fd9e4e4da124ebfe1de299;hpb=6106ec729e02fa19d87be1c407442a6bdc44c784;p=cc65 diff --git a/samples/tgidemo.c b/samples/tgidemo.c index 818d35d25..2a603dd1d 100644 --- a/samples/tgidemo.c +++ b/samples/tgidemo.c @@ -56,7 +56,7 @@ static unsigned YRes; /*****************************************************************************/ -/* Code */ +/* Code */ /*****************************************************************************/ @@ -90,15 +90,17 @@ static void DoCircles (void) static const unsigned char Palette[2] = { COLOR_WHITE, COLOR_LIGHTRED }; unsigned char I; unsigned char Color = 1; + unsigned X = XRes / 2; + unsigned Y = YRes / 2; tgi_setpalette (Palette); while (!kbhit ()) { tgi_setcolor (1); - tgi_line (0, 0, 319, 199); - tgi_line (0, 199, 319, 0); + tgi_line (0, 0, XRes-1, YRes-1); + tgi_line (0, YRes-1, XRes-1, 0); tgi_setcolor (Color); for (I = 10; I < 240; I += 10) { - tgi_circle (160, 100, I); + tgi_circle (X, Y, I); } Color ^= 0x01; } @@ -140,18 +142,42 @@ static void DoCheckerboard (void) static void DoDiagram (void) { static const unsigned char Palette[2] = { COLOR_WHITE, COLOR_BLACK }; - unsigned X; + unsigned X, I; tgi_setpalette (Palette); tgi_setcolor (1); - tgi_line (10, 10, 10, 190); - tgi_lineto (310, 190); + tgi_line (10, 10, 10, YRes-10); + tgi_lineto (XRes-10, YRes-10); tgi_line (8, 12, 10, 10); tgi_lineto (12, 12); - tgi_line (308, 188, 310, 190); - tgi_lineto (308, 192); - for (X = 0; X < sizeof (SinusTable); ++X) { - tgi_setpixel (X+10, SinusTable[X]); + tgi_line (XRes-12, YRes-12, XRes-10, YRes-10); + tgi_lineto (XRes-12, YRes-8); + for (I = 0, X = 10; X < XRes-10; ++X) { + tgi_setpixel (X, SinusTable[I]); + if (++I >= sizeof (SinusTable)) { + I = 0; + } + } + + cgetc (); + tgi_clear (); +} + + + +static void DoLines (void) +{ + static const unsigned char Palette[2] = { COLOR_WHITE, COLOR_BLACK }; + unsigned X; + + tgi_setpalette (Palette); + tgi_setcolor (1); + + for (X = 0; X < YRes; X+=10) { + tgi_line (0, 0, YRes, X); + tgi_line (0, 0, X, YRes); + tgi_line (YRes, YRes, 0, YRes-X); + tgi_line (YRes, YRes, YRes-X, 0); } cgetc (); @@ -170,7 +196,7 @@ int main (void) /* Load and initialize the driver */ tgi_load (TGI_MODE_320_200_2); CheckError ("tgi_load"); - tgi_init (TGI_MODE_320_200_2); + tgi_init (); CheckError ("tgi_init"); /* Get stuff from the driver */ @@ -184,6 +210,7 @@ int main (void) DoCircles (); DoCheckerboard (); DoDiagram (); + DoLines (); /* Unload the driver */ tgi_unload (); @@ -195,3 +222,5 @@ int main (void) printf ("Done\n"); return EXIT_SUCCESS; } + +