10 #include <propeller.h>
62 0x00, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x02, 0x05,
64 0x0A, 0x0A, 0x1A, 0x1A,
65 0x34, 0x3a, 0x74, 0x74
78 extern uint32_t binary_Graphics_dat_start[];
79 #if defined(__PROPELLER_XMM__)
80 extern uint32_t pasm[];
81 extern uint32_t binary_Graphics_dat_end[];
82 int binsize = (binary_Graphics_dat_end - binary_Graphics_dat_start);
83 memcpy(pasm, binary_Graphics_dat_start, binsize*4);
88 #if 0 // defined(__PROPELLER_XMM__) || defined(__PROPELLER_XMMC__)
89 printf(
"Graph_start\n");
90 printf(
"GraphCmd_ST %x\n", &
gGraph);
91 printf(
"%x\n", &
gGraph.cog);
92 printf(
"%x\n", &
gGraph.command);
93 printf(
"%x\n", &
gGraph.pixel_width);
94 printf(
"%x\n", &
gGraph.bitmap_ptr);
95 printf(
"%x\n", &
gGraph.bitmap_len);
96 printf(
"%x\n", &
gGraph.bases);
97 printf(
"%x\n", &
gGraph.slices);
98 printf(
"%x\n", &
gGraph.text_xs);
99 printf(
"%x\n", &
gGraph.text_ys);
100 printf(
"%x\n", &
gGraph.text_sp);
101 printf(
"%x\n", &
gGraph.text_just);
104 for(n = 0; n < 496; n++) {
106 printf(
"\n%03x ",n<<2);
107 printf(
"0x%08x ",pasm[n]);
113 #if defined(__PROPELLER_XMM__)
116 cog =
cognew(binary_Graphics_dat_start, (uint32_t)&
gGraph.command)+1;
118 while(
gGraph.command != 0)
133 uint32_t cog = gp->cog-1;
144 void Graph_setup(uint32_t x_tiles, uint32_t y_tiles, uint32_t x_origin, uint32_t y_origin, uint32_t base_ptr)
152 for(n = 0; n < x_tiles && n < 32; n++)
153 gp->bases[n] = base_ptr + ((n * y_tiles) << 6);
156 y_origin = y_tiles - y_origin - 1;
162 pa[4] = (uint32_t)gp->bases;
163 pa[5] = (uint32_t)gp->bases;
164 pa[6] = (uint32_t)gp->slices;
169 gp->bitmap_ptr = (uint32_t*)base_ptr;
170 gp->bitmap_len = x_tiles * y_tiles;
191 memcpy((
void*)dest_ptr, (
void*)
gGraph.bitmap_ptr,
gGraph.bitmap_len<<2);
209 int passes, r, n, pw;
214 passes = (w >> 1) + 1;
223 for(n = 0; n <= w >> 1; n++) {
224 gGraph.slices[n] = (uint32_t)(0xffffffff >> (pw << 1)) << (pw & 0xE);
227 if(r && n == passes - 2)
268 void Graph_arc(uint32_t
x, uint32_t y, uint32_t xr, uint32_t yr,
int angle,
int anglestep,
int steps,
int arcmode)
285 void Graph_vec(uint32_t
x, uint32_t y,
int vecscale,
int vecangle, uint16_t* vecdef_ptr)
291 pa[4] = (uint32_t)vecdef_ptr;
299 void Graph_vecarc(uint32_t
x, uint32_t y, uint32_t xr, uint32_t yr,
int angle,
int vecscale,
int vecangle, uint16_t* vecdef_ptr)
308 pa[7] = (uint32_t)vecdef_ptr;
316 void Graph_pix(uint32_t
x, uint32_t y,
int pixrot, uint16_t* pixdef_ptr)
321 pa[3] = (long)pixdef_ptr;
329 void Graph_pixarc(uint32_t
x, uint32_t y, uint32_t xr, uint32_t yr,
int angle,
int pixrot, uint16_t* pixdef_ptr)
337 pa[6] = (uint32_t)pixdef_ptr;
347 char s[2] = {
'\0',
'\0' };
363 pa[2] = (uint32_t)string_ptr;
373 void Graph_textarc(uint32_t
x, uint32_t y, uint32_t xr, uint32_t yr,
int angle,
char* string_ptr)
383 pa[5] = (uint32_t)string_ptr;
393 void Graph_textmode(uint32_t x_scale, uint32_t y_scale, uint32_t spacing, uint32_t justification)
396 pa[0] = gp->text_xs = x_scale;
397 pa[1] = gp->text_ys = y_scale;
398 pa[2] = gp->text_sp = spacing;
399 pa[3] = gp->text_just = justification;
409 uint32_t x2, y2, pmin, pmax;
410 int width =
gGraph.pixel_width;
412 if((box_width > width) && (box_height > width))
418 x2 =
x + box_width - 1 - width;
419 y2 = y + box_height - 1 - width;
426 fill(
x, y2 + pmax, 0, (x2 -
x) << 16, 0, 0, pmax);
427 fill(
x, y, 0, (x2 -
x) << 16, 0, 0, pmin);
428 fill(
x - pmin, y2, 0, (x2 -
x + width) << 16, 0, 0, y2 - y);
436 void Graph_quad(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, uint32_t x3, uint32_t y3, uint32_t x4, uint32_t y4)
442 void Graph_tri(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, uint32_t x3, uint32_t y3)
445 int mycase = ((y1 >= y2) ? 4 : 0) | ((y2 >= y3) ? 2 : 0) | ((y1 >= y3) ? 1 : 0);
496 fill(x1, y1, ((x3 - x1) << 16) / (y1 - y3 + 1), ((x2 - x1) << 16) / (y1 - y2 + 1), ((x3 - x2) << 16) / (y2 - y3 + 1), y1 - y2, y1 - y3);
511 void fill(
int x,
int y,
int da,
int db,
int db2,
int linechange,
int lines_minus_1)
519 pa[6] = lines_minus_1;
526 void justify(
char* string_ptr, uint32_t* justptr)
529 uint32_t
x = (strlen(string_ptr) - 1) * gp->text_xs * gp->text_sp + gp->text_xs * 5 - 1;
538 justptr[0] = -ja1[gp->text_just];
542 ja2[1] = gp->text_ys << 3;
543 ja2[2] = gp->text_ys << 4;
545 justptr[1] = -ja2[gp->text_just];
553 "Arc",
"Vec",
"VecArc",
555 "Text",
"TextArc",
"TextMode",
568 gGraph.command = ((cmd << 16) | ((
int)argptr & 0xffff));
570 printf(
"\nsendCommand(0x%x, 0x%x): 0x%x ... %s", cmd, (
int)argptr,
gGraph.command, cmds[cmd]);
574 while(
gGraph.command != 0)