diff --git a/CMakeLists.txt b/CMakeLists.txt index f381719..a013672 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,7 @@ set(SOURCES src/gint/kmalloc.c src/gint/overclock.c src/gint/ram.c + src/gint/render.c src/gint/rtc.c src/gint/spuram.c src/gint/timer.c diff --git a/include/gintctl/gint.h b/include/gintctl/gint.h index 9bd00f3..6102ad2 100644 --- a/include/gintctl/gint.h +++ b/include/gintctl/gint.h @@ -44,6 +44,9 @@ void gintctl_gint_dma(void); /* gintctl_gint_rtc(): Configure RTC and check timer speed */ void gintctl_gint_rtc(void); +/* gintctl_gint_render(): Test basic rendering functions */ +void gintctl_gint_render(void); + /* gintctl_gint_image(): Test image rendering */ void gintctl_gint_image(void); diff --git a/src/gint/image.c b/src/gint/image.c index a67e7b2..92e3fa7 100644 --- a/src/gint/image.c +++ b/src/gint/image.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include #include diff --git a/src/gint/render.c b/src/gint/render.c new file mode 100644 index 0000000..121e580 --- /dev/null +++ b/src/gint/render.c @@ -0,0 +1,52 @@ +#define __BSD_VISIBLE 1 +#include +#include +#include +#include + +static void hexa_shape(int x, int y, int r, float alpha) +{ + int xs[6], ys[6]; + for(int i = 0; i < 6; i++) { + xs[i] = x + r * cosf(alpha + 1.57 + i * (2*M_PI/6)); + ys[i] = y + r * sinf(alpha + 1.57 + i * (2*M_PI/6)); + } + + for(int i = 0; i < 6; i++) { + int j = (i + 1) % 6; + dline(xs[i], ys[i], xs[j], ys[j], C_BLACK); + } + dline(xs[0], ys[0], xs[2], ys[2], C_BLACK); + dline(xs[2], ys[2], xs[5], ys[5], C_BLACK); + dline(xs[5], ys[5], xs[3], ys[3], C_BLACK); + dline(xs[3], ys[3], xs[1], ys[1], C_BLACK); + dline(xs[1], ys[1], xs[4], ys[4], C_BLACK); + dline(xs[4], ys[4], xs[0], ys[0], C_BLACK); +} + +void gintctl_gint_render(void) +{ + dclear(C_WHITE); + drect_border(1, 1, DWIDTH-2, DHEIGHT-2, C_NONE, 1, C_BLACK); + +#ifdef FXCG50 + drect_border(3, 3, DWIDTH-4, DHEIGHT-4, C_NONE, 1, C_BLACK); +#endif + + hexa_shape(DWIDTH/2, DHEIGHT/2, _(24, 72), 0.0); + + for(int y = _(3,5); y < DHEIGHT - _(3,5); y++) + for(int x = _(3,5); x < DWIDTH - _(3,5); x++) { + if(dgetpixel(x-1, y) == C_BLACK + || dgetpixel(x+1, y) == C_BLACK + || dgetpixel(x, y-1) == C_BLACK + || dgetpixel(x, y+1) == C_BLACK) + continue; + + if((x ^ y) & 1) dpixel(x, y, C_BLACK); + } + + dupdate(); + + while(getkey().key != KEY_EXIT) {} +} diff --git a/src/gintctl.c b/src/gintctl.c index 33aa5f7..c7abfcb 100644 --- a/src/gintctl.c +++ b/src/gintctl.c @@ -1,5 +1,3 @@ -#define GINT_NEED_VRAM - #include #include #include @@ -53,6 +51,7 @@ struct menu menu_gint = { { "DMA control", gintctl_gint_dma, MENU_SH4_ONLY }, { "Real-time clock", gintctl_gint_rtc, 0 }, { "USB communication", gintctl_gint_usb, MENU_SH4_ONLY }, + { "Basic rendering", gintctl_gint_render, 0 }, { "Image rendering", gintctl_gint_image, 0 }, { "Text rendering", gintctl_gint_topti, 0 }, #ifdef FX9860G diff --git a/src/util.c b/src/util.c index 84f6bb4..67bba5c 100644 --- a/src/util.c +++ b/src/util.c @@ -88,8 +88,7 @@ void row_highlight(int row) #endif #ifdef FXCG50 - uint32_t *long_vram = (void *)gint_vram; - for(int i = 198 * y1; i < 198 * y2; i++) long_vram[i] = ~long_vram[i]; + drect(0, y1, DWIDTH - 1, y2 - 1, C_INVERT); #endif }