diff --git a/include/gint/drivers/r61524.h b/include/gint/drivers/r61524.h index ff2d1b5..71510c8 100644 --- a/include/gint/drivers/r61524.h +++ b/include/gint/drivers/r61524.h @@ -55,6 +55,12 @@ void r61524_display_rect(uint16_t *vram, int xmin, int xmax, int ymin, TODO: Make that a video mode. */ void r61524_display_mono_128x64(uint32_t *vram); +/* r61524_display_mono_128x64(): Display a gray-style VRAM + This experimental function updates the display with the contents of a 128x64 + gray VRAM pair, used with the fxg3a compilation target. + TODO: Make that a video mode. */ +void r61524_display_gray_128x64(uint32_t *light, uint32_t *dark); + /* r61524_start_frame(): Prepare the display for a region update This function sets up the display driver to receive graphics data to update diff --git a/src/gray/engine.c b/src/gray/engine.c index ccb6f53..c5cc857 100644 --- a/src/gray/engine.c +++ b/src/gray/engine.c @@ -14,8 +14,12 @@ #include "../render/render.h" #include -// TODO: Move the gray "engine" into the T6K11 driver. -#if GINT_RENDER_MONO && GINT_HW_FX +#if GINT_HW_CG +#include +#endif + +// TODO: Move the gray "engine" part into the T6K11 driver. +#if GINT_RENDER_MONO /* Three additional video RAMS, allocated statically if --static-gray was set at configure time, or with malloc() otherwise. */ @@ -26,6 +30,8 @@ GBSS static uint32_t gvrams[3][256]; /* Four VRAMs: two to draw and two to display */ static uint32_t *vrams[4] = { NULL, NULL, NULL, NULL }; +#if GINT_HW_FX + /* Current VRAM pair used for drawing; the value can either be 0 (draws to VRAMs 0 and 1) or 2 (draws to VRAMs 2 and 3). */ static int volatile st = 0; @@ -40,6 +46,10 @@ static int runs = 0; /* Delays of the light and dark frames for the above setting */ GBSS static int delays[2]; +static int gray_int(void); + +#endif + /* The alternate rendering mode structure used to override d*() */ static struct rendering_mode const gray_mode = { .dupdate = gupdate, @@ -68,13 +78,16 @@ static struct rendering_mode const gray_exit_mode = { // Engine control (init/quit and start/stop) //--- -static int gray_int(void); static void gray_quit(void); /* gray_isinit(): Check whether the engine is initialized and ready to run */ static int gray_isinit(void) { - return (vrams[0] && vrams[1] && vrams[2] && vrams[3] && timer >= 0); + return (vrams[0] && vrams[1] && vrams[2] && vrams[3] +#if GINT_HW_FX + && timer >= 0 +#endif + ); } /* gray_init(): Initialize the engine @@ -95,6 +108,7 @@ GCONSTRUCTOR static void gray_init(void) vrams[3] = malloc(1024); #endif /* GINT_STATIC_GRAY */ +#if GINT_HW_FX /* Default delays from Graph 35+E II are different from other models */ if(gint[HWCALC] == HWCALC_G35PE2) { @@ -110,6 +124,7 @@ GCONSTRUCTOR static void gray_init(void) /* Try to obtain the timer right away */ timer = timer_configure(GRAY_TIMER | GRAY_CLOCK, 1000, GINT_CALL(gray_int)); +#endif /* On failure, release the resources that we obtained */ if(!gray_isinit()) gray_quit(); @@ -128,10 +143,13 @@ GDESTRUCTOR static void gray_quit(void) vrams[3] = NULL; #endif /* GINT_STATIC_GRAY */ +#if GINT_HW_FX if(timer >= 0) timer_stop(timer); timer = -1; +#endif } +#if GINT_HW_FX /* gray_start(): Start the gray engine */ static void gray_start(void) { @@ -148,6 +166,7 @@ static void gray_stop(void) runs = 0; st = 0; } +#endif //--- // Dynamic udpate and rendering mode @@ -201,6 +220,7 @@ int dgray(int mode) return 0; } +#if GINT_HW_FX /* gray_int(): Interrupt handler */ int gray_int(void) { @@ -232,6 +252,19 @@ int gupdate(void) st ^= 2; return 0; } +#elif GINT_HW_CG +int gupdate(void) +{ + if(dmode == &gray_exit_mode) + { + dmode = NULL; + return 1; + } + + r61524_display_gray_128x64(vrams[0], vrams[1]); + return 0; +} +#endif //--- // Query and configuration functions @@ -243,6 +276,7 @@ int dgray_enabled(void) return (dmode == &gray_mode); } +#if GINT_HW_FX /* dgray_setdelays(): Set the gray engine delays */ void dgray_setdelays(uint32_t light, uint32_t dark) { @@ -274,5 +308,12 @@ void dgray_getscreen(uint32_t **light, uint32_t **dark) if(light) *light = vrams[base & 2]; if(dark) *dark = vrams[base | 1]; } +#elif GINT_HW_CG +void dgray_getvram(uint32_t **light, uint32_t **dark) +{ + *light = vrams[0]; + *dark = vrams[1]; +} +#endif #endif /* GINT_RENDER_MONO && GINT_HW_FX */ diff --git a/src/r61524/r61524.c b/src/r61524/r61524.c index e5adac4..2e256d8 100644 --- a/src/r61524/r61524.c +++ b/src/r61524/r61524.c @@ -238,12 +238,13 @@ void r61524_display_mono_128x64(uint32_t *vram) write(border); } -void r61524_display_gray_128x64(uint32_t *vram) +void r61524_display_gray_128x64(uint32_t *light, uint32_t *dark) { dma_transfer_wait(0); r61524_start_frame(0, 395, 0, 223); int border = 0xe71c; /* C_RGB(28, 28, 28) */ + int colors[] = { 0x0000, 0x528a, 0xad55, 0xffff }; for(int i = 0; i < 16 * 396; i++) write(border); @@ -256,11 +257,13 @@ void r61524_display_gray_128x64(uint32_t *vram) /* longword-x position */ for(int lwx = 0; lwx < 4; lwx++) { - int32_t i = vram[lwx]; + int32_t il = light[lwx]; + int32_t id = dark[lwx]; /* sub-x position */ for(int sx = 0; sx < 32; sx++) { - int color = ~(i >> 31); - i <<= 1; + int color = colors[(id >= 0) * 2 + (il >= 0)]; + il <<= 1; + id <<= 1; write(color); write(color); write(color); @@ -270,7 +273,8 @@ void r61524_display_gray_128x64(uint32_t *vram) for(int i = 0; i < 6; i++) write(border); } - vram += 4; + light += 4; + dark += 4; } for(int i = 0; i < 16 * 396; i++)