00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdlib.h>
00022 #include <stdio.h>
00023 #include <math.h>
00024 #include "gfx.h"
00025 #include "line.h"
00026
00027 typedef struct {
00028 int x;
00029 int y;
00030 } point_t;
00031
00032 #define MAX_POINT 12
00033
00034 main() {
00035 u_char* buf = (u_char*)malloc(MODE2_MAX);
00036
00037 double M_PI;
00038 double a;
00039 int c, i;
00040 surface_t surf;
00041 point_t p[MAX_POINT];
00042
00043 printf("calculating, wait...\n");
00044
00045 M_PI = 8.0 * atan(1.0);
00046
00047
00048 for (c = 0; c < MAX_POINT; c++) {
00049 a = (M_PI * (double)c) / (double)MAX_POINT;
00050 p[c].x = (int)(100.0 * cos(a) + 128.0);
00051 p[c].y = (int)(80.0 * sin(a) + 96.0);
00052 }
00053
00054
00055 printf("clearing buffer...\n");
00056 memset(buf, MODE2_MAX, 0);
00057
00058 printf("drawing...\n");
00059 surf.data.ram = buf;
00060
00061
00062 for (c = 0; c < MAX_POINT; c++)
00063 for (i = c+1; i < MAX_POINT; i++)
00064 surface_line(&surf, p[c].x, p[c].y, p[i].x, p[i].y);
00065
00066
00067 set_color(15, 1, 1);
00068 set_mode(mode_2);
00069 fill(MODE2_ATTR, 0xF1, MODE2_MAX);
00070
00071
00072 vwrite(surf.data.ram, 0, MODE2_MAX);
00073
00074 while (!get_trigger(0)) {}
00075
00076 set_mode(mode_0);
00077 }