diff --git a/include/gint/display-cg.h b/include/gint/display-cg.h index 9ca0b25..ebbdf38 100644 --- a/include/gint/display-cg.h +++ b/include/gint/display-cg.h @@ -94,6 +94,10 @@ typedef image_t bopti_image_t; @main Main VRAM area, used alone if [secondary] is NULL @secondary Additional VRAM area, enables triple buffering if non-NULL */ +// TODO: In gint 3 the triple buffering mechanism will be removed. Applications +// that want to change VRAMs in-between every frame will be able to do so by +// talking directly to the video interface to set VRAM, and wrapping dupdate. +// Basically it will just no longer be handled by gint itself. void dsetvram(uint16_t *main, uint16_t *secondary); /* dgetvram() - Get VRAM addresses diff --git a/include/gint/drivers/r61524.h b/include/gint/drivers/r61524.h index 9ffc25c..ff2d1b5 100644 --- a/include/gint/drivers/r61524.h +++ b/include/gint/drivers/r61524.h @@ -49,6 +49,12 @@ void r61524_display(uint16_t *vram, int start, int height, int method); void r61524_display_rect(uint16_t *vram, int xmin, int xmax, int ymin, int ymax); +/* r61524_display_mono_128x64(): Display a mono-style VRAM + This experimental function updates the display with the contents of a 128x64 + VRAM, used with the fxg3a compilation target. + TODO: Make that a video mode. */ +void r61524_display_mono_128x64(uint32_t *vram); + /* 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/kernel/kernel.c b/src/kernel/kernel.c index 5d6378c..33a3176 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -114,12 +114,9 @@ void kinit(void) gint_world_addin = gint_world_alloc(); gint_driver_flags = malloc(gint_driver_count()); - #ifdef FXCG50 - /* Allocate VRAMs, which is important for panic screens */ extern bool dvram_init(void); if(!dvram_init()) abort(); - #endif if(!gint_world_os || !gint_world_addin || !gint_driver_flags) gint_panic(0x1060); diff --git a/src/kernel/world.c b/src/kernel/world.c index aed10b2..301510f 100644 --- a/src/kernel/world.c +++ b/src/kernel/world.c @@ -220,11 +220,11 @@ void gint_copy_vram(void) { void *__GetVRAMAddress(void); - #ifdef FX9860G + #if GINT_OS_FX memcpy(__GetVRAMAddress(), gint_vram, 1024); #endif - #ifdef FXCG50 + #if GINT_OS_CG && GINT_RENDER_RGB /* TODO: Improve copied VRAM behavior in gint_osmenu() on fxcg50 */ uint16_t *vram1, *vram2; dgetvram(&vram1, &vram2); @@ -238,6 +238,10 @@ void gint_copy_vram(void) dst[x] = src[x]; } #endif + + #if GINT_OS_CG && GINT_RENDER_MONO + // TODO: VRAM save mechanism for mono video mode on R61524 + #endif } void gint_poweroff(bool show_logo) diff --git a/src/r61524/r61524.c b/src/r61524/r61524.c index b671ffe..831f657 100644 --- a/src/r61524/r61524.c +++ b/src/r61524/r61524.c @@ -11,7 +11,7 @@ #include #include -#if GINT_RENDER_RGB +#if GINT_HW_CG #define DMA SH7305_DMA #define POWER SH7305_POWER @@ -199,6 +199,26 @@ void r61524_display_rect(uint16_t *vram, int xmin, int xmax, int ymin, } } +void r61524_display_mono_128x64(uint32_t *vram) +{ + dma_transfer_wait(0); + r61524_start_frame(0, 383, 0, 191); + + for(int y = 0; y < 64; y++) { + for(int sy = 0; sy < 3; sy++) { + /* Get pixels manually, ooh, slow */ + for(int x = 0; x < 128; x++) { + int pixel = vram[x >> 5] >> (~x & 31); + int color = (pixel & 1) ? 0x0000 : 0xffff; + write(color); + write(color); + write(color); + } + } + vram += 4; + } +} + //--- // State and driver metadata //--- @@ -221,4 +241,4 @@ gint_driver_t drv_r61524 = { }; GINT_DECLARE_DRIVER(26, drv_r61524); -#endif /* GINT_RENDER_RGB */ +#endif /* GINT_HW_CG */ diff --git a/src/render-fx/dupdate.c b/src/render-fx/dupdate.c index 4eda33e..4e27589 100644 --- a/src/render-fx/dupdate.c +++ b/src/render-fx/dupdate.c @@ -1,10 +1,17 @@ #include -#include #include "../render/render.h" #include #if GINT_RENDER_MONO +#if GINT_HW_FX +# include +#elif GINT_HW_CG +# include +#else +# error Platform unknown for mono video mode update +#endif + /* Standard video RAM for fx9860g is 1 bit per pixel */ GSECTION(".bss") GALIGNED(32) static uint32_t fx_vram[256]; @@ -14,6 +21,12 @@ uint32_t *gint_vram = fx_vram; /* The current rendering mode */ struct rendering_mode const *dmode = NULL; +/* For parity with the current RGB interface */ +bool dvram_init(void) +{ + return true; +} + /* dupdate(): Push the video RAM to the display driver */ void dupdate(void) { @@ -28,7 +41,11 @@ void dupdate(void) } if(run_default) { +#if GINT_HW_FX t6k11_display(gint_vram, 0, 64, 16); +#elif GINT_HW_CG + r61524_display_mono_128x64(gint_vram); +#endif } gint_call(dupdate_get_hook()); diff --git a/src/usb/classes/ff-bulk.c b/src/usb/classes/ff-bulk.c index c90af33..a94aea7 100644 --- a/src/usb/classes/ff-bulk.c +++ b/src/usb/classes/ff-bulk.c @@ -104,12 +104,12 @@ static void capture_vram(GUNUSED bool onscreen, char const *type) void *source = gint_vram; int size, format; - #ifdef FX9860G + #if GINT_RENDER_MONO size = 1024; format = USB_FXLINK_IMAGE_MONO; #endif - #ifdef FXCG50 + #if GINT_RENDER_RGB if(onscreen) { uint16_t *main, *secondary; dgetvram(&main, &secondary); @@ -187,11 +187,11 @@ static void execute_command(char const *cmd) usb_fxlink_text(text, 0); } if(!strncmp(cmd, "identify", 8)) { -#if defined(FX9860G) +#if GINT_OS_FX char const *serial_number = (void *)0x8000ffd0; char const *OS_version = (void *)0x80010020; char const *BC_version = (void *)0x8000ffb0; -#elif defined(FXCG50) +#elif GINT_OS_CG char const *serial_number = (void *)0x8001ffd0; char const *OS_version = (void *)0x80020020; char const *BC_version = (void *)0x8001ffb0;