gint/render: add a test for basic rendering functions

This commit is contained in:
Lephenixnoir 2022-11-16 19:14:48 +01:00
parent 33cb3fc698
commit d0806af51e
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
6 changed files with 58 additions and 5 deletions

View File

@ -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

View File

@ -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);

View File

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/display.h>
#include <gint/keyboard.h>

52
src/gint/render.c Normal file
View File

@ -0,0 +1,52 @@
#define __BSD_VISIBLE 1
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gintctl/util.h>
#include <math.h>
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) {}
}

View File

@ -1,5 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/gint.h>
@ -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

View File

@ -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
}