On CG50 gint utilizes a triple-buffer mechanism to speed up rendering by DMA transfering one of the back buffers to display while allowing client code to write to the other at the same time. Except being swapped in and out between the two, they are apparently independ to each other, eg. there is no pixel copy when `dupdate()`. This is suitable for frame based applications like games.
In one of my add-ins I simply disabled triple-buffering (to save one `memcpy()` call), but the calc would reboot in a few seconds each time when the add-in was launched.
Anyone ever encountered the same problem please advise?
Here is the relevant
Code:
Thanks!
In one of my add-ins I simply disabled triple-buffering (to save one `memcpy()` call), but the calc would reboot in a few seconds each time when the add-in was launched.
Anyone ever encountered the same problem please advise?
Here is the relevant
Code:
static void print(const char *buf, int len) {
#define LINE_HEIGHT 16
static struct {
bool init;
int x, y;
} a = { .init = false, };
if (!a.init) {
a.init = true;
a.x = 0;
a.y = LINE_HEIGHT;
// Disable triple buffer
uint16_t *vram1, *vram2;
dgetvram(&vram1, &vram2);
dsetvram(vram1, NULL);
dclear(C_WHITE);
dupdate();
}
int x1 = a.x;
int y1 = a.y;
int len1 = 0;
while (len1 < len) {
int w;
dnsize(buf + len1, 1, NULL, &w, NULL);
int max_w = DWIDTH - x1;
if (w > max_w) {
x1 = 0;
y1 += LINE_HEIGHT;
if (y1 >= DHEIGHT) {
dupdate();
dclear(C_WHITE);
dupdate();
y1 = LINE_HEIGHT;
}
}
dtext_opt(x1, y1, C_BLACK, C_NONE, DTEXT_LEFT, DTEXT_BOTTOM, buf + len1, 1);
x1 += w;
len1++;
} // while
dupdate();
a.x = x1;
a.y = y1;
#undef LINE_HEIGHT
}
Thanks!