#include #include #include #include #include "../render/render.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; } void drawupscale( int x, int y, int color ) { int u=y*396*3; int v=x*3; uint16_t colorcg; if (color==C_WHITE) colorcg=0xFFFF; else colorcg=0x0000; int baseindex = (396*16+6+v+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) { bool run_default = true; if(dmode && dmode->dupdate) { /* Call the overridden dupdate(), but continue if it returns non-zero (this is used when stopping the gray engine) */ int rc = dmode->dupdate(); run_default = (rc != 0); } if(run_default) { for( int j=0; j