diff --git a/CMakeLists.txt b/CMakeLists.txt index 076dffb..8ea5cd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,7 +246,34 @@ set(SOURCES_CG ) set(SOURCES_FXASCG - # R61524 driver + # Gray engine + src/gray/engine.c + src/gray/gclear.c + src/gray/ggetpixel.c + src/gray/gint_gline.c + src/gray/gpixel.c + src/gray/grect.c + src/gray/gsubimage.c + src/gray/gtext.c + # Rendering + src/render-fx/bopti-asm-gray-scsp.s + src/render-fx/bopti-asm-gray.s + src/render-fx/bopti-asm-mono-scsp.s + src/render-fx/bopti-asm.s + src/render-fx/bopti.c + src/render-fx/dclear.c + src/render-fx/dgetpixel.c + src/render-fx/dpixel.c + src/render-fx/drect.c + src/render-fx/dsubimage.c + src/render-fx/gint_dline.c + src/render-fx/masks.c + src/render-fx/topti-asm.s + src/render-fx/topti.c + #special dupdate functions to treat a FX VRAM and convert to a CG VRAM + src/render-fxascg/dupdate.c + # R61524 driver as we are working with a CG50 + src/r61524/r61524.c ) set(ASSETS_FX @@ -290,7 +317,7 @@ if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G_AS_CG) set(LINKER_SCRIPTS "${CMAKE_CURRENT_BINARY_DIR}/fxcg50.ld" "${CMAKE_CURRENT_BINARY_DIR}/fxcg50_fastload.ld") - add_library(gint-fxascg STATIC ${SOURCES_COMMON} ${SOURCES_CG} ${SOURCES_FXASCG} ${ASSETS_FX} + add_library(gint-fxascg STATIC ${SOURCES_COMMON} ${SOURCES_FXASCG} ${ASSETS_FX} ${LINKER_SCRIPTS}) endif() diff --git a/include/gint/display-cg.h b/include/gint/display-cg.h index e297205..e9fa807 100644 --- a/include/gint/display-cg.h +++ b/include/gint/display-cg.h @@ -15,7 +15,7 @@ #ifndef GINT_DISPLAY_CG #define GINT_DISPLAY_CG -#ifdef FXCG50 +#if defined(FXCG50) && !defined(FX9860G_AS_CG) #ifdef __cplusplus extern "C" { diff --git a/include/gint/display-fx.h b/include/gint/display-fx.h index af85e43..eb4eff6 100644 --- a/include/gint/display-fx.h +++ b/include/gint/display-fx.h @@ -9,7 +9,7 @@ #ifndef GINT_DISPLAY_FX #define GINT_DISPLAY_FX -#ifdef FX9860G +#if defined(FX9860G) || defined(FX9860G_AS_CG) #ifdef __cplusplus extern "C" { diff --git a/include/gint/display.h b/include/gint/display.h index 599fd15..7236800 100644 --- a/include/gint/display.h +++ b/include/gint/display.h @@ -19,11 +19,11 @@ extern "C" { /* Platform-specific functions include VRAM management and the definition of the color_t type. */ -#ifdef FX9860G +#if defined(FX9860G) || defined(FX9860G_AS_CG) #include #endif -#ifdef FXCG50 +#if defined(FXCG50) && ! defined(FX9860G_AS_CG) #include #endif diff --git a/src/render-fxascg/dupdate.c b/src/render-fxascg/dupdate.c new file mode 100644 index 0000000..be5d455 --- /dev/null +++ b/src/render-fxascg/dupdate.c @@ -0,0 +1,97 @@ +#include +#include +#include +#include +#include "../render-fx/render-fx.h" + +/* The destination VRAM for upscaling + centering + conversion B&W --> 16bits RGB565 */ +uint16_t *cg_vram; // set to 0 at initialisation + +/* Standard video RAM for fx9860g is 1 bit per pixel */ +GALIGNED(32) static uint32_t fx_vram[256]; + +/* Here is the definition of the VRAM pointer, exposed in */ +uint32_t *gint_vram = fx_vram; + +/* The current rendering mode */ +struct rendering_mode const *dmode = NULL; + + +bool dvram_init( void ) +{ + int const MARGIN = 32; + + /* Leave MARGIN bytes on each side of the region; this enables some + important optimizations in the image renderer. We also add another + 32 bytes so we can manually 32-align the region */ + uint32_t region = (uint32_t)kmalloc(DWIDTH*DHEIGHT*2 + MARGIN*2 + 32, +#if !defined(GINT_NO_OS_STACK) + "_ostk" +#else + NULL +#endif + ); + if(region == 0) + return false; + + /* 32-align the region */ + region = (region + 31) & -32; + /* Skip a MARGIN */ + region += MARGIN; + /* Use an uncached address */ + region = (region & 0x1fffffff) | 0xa0000000; + + /* Don't enable triple buffering by default */ + cg_vram = (void *)region; + return true; +} + +void dgetvram(uint16_t **ptr_vram_1, uint16_t **ptr_vram_2) +{ + if(ptr_vram_1) *ptr_vram_1 = &cg_vram; + if(ptr_vram_2) *ptr_vram_2 = &cg_vram; +} + +inline drawupscale( int x, int y, int color ) +{ + int u=y*396*3*2; + + uint16_t colorcg; + + if (color==C_WHITE) colorcg=0xFFFF; + else colorcg=0x0000; + + int baseindex = (396*16+6+x+u); // 16 lines on top/bottom remain black and 6 columns on left/right remain black + cg_vram[baseindex] = colorcg; + cg_vram[baseindex+1] = colorcg; + cg_vram[baseindex+2] = colorcg; + + baseindex+=396; + cg_vram[baseindex] = colorcg; + cg_vram[baseindex+1] = colorcg; + cg_vram[baseindex+2] = colorcg; + + baseindex+=396; + cg_vram[baseindex] = colorcg; + cg_vram[baseindex+1] = colorcg; + cg_vram[baseindex+2] = colorcg; +} + +/* dupdate(): Push the video RAM to the display driver */ +void dupdate(void) +{ + + for( int j=0; j