diff --git a/TODO b/TODO index 11b6117..82dc7ed 100644 --- a/TODO +++ b/TODO @@ -12,10 +12,8 @@ Tests to run. Complementary elements on existing code. * topti: support unicode fonts * gray: find good values for more models than the Graph 35+E II -* render: get rid of GINT_NEED_VRAM and #define vram gint_vram if you need * dma: maybe relax the 4-byte size constraint for dma_memset() * core: try to leave add-in without reset in case of panic -* topti: support Unicode fonts * hardware: fill in the HWMEM_FITTLB flag * keyboard: think of extended functions * cpg: spread spectrum on fxcg50 diff --git a/include/gint/display-cg.h b/include/gint/display-cg.h index 979c375..966e53b 100644 --- a/include/gint/display-cg.h +++ b/include/gint/display-cg.h @@ -15,16 +15,14 @@ #include -/* Expose the VRAM variable if GINT_NEED_VRAM is defined. It must always point - to a 32-aligned buffer of size 177408. Any function can use it freely to - perform rendering or store data when not drawing. Triple buffering is - already implemented in gint, see the dvram() function below. +/* gint VRAM address. This value must always point to a 32-aligned bufer of + size 177408. Any function can use it freely to perform rendering or store + data when not drawing. Triple buffering is already implemented in gint, see + the dvram() function below. - In this module, colors are in the 16-bit R5G6B5 format, as it is the format - used by the display controller. */ -#ifdef GINT_NEED_VRAM -extern uint16_t *vram; -#endif + In this module, colors are in the 16-bit big-endian R5G6B5 format, as it is + the format used by the display controller. */ +extern uint16_t *gint_vram; /* Provide a platform-agnostic definition of color_t. Some functions also support transparency, in which case they take an [int] diff --git a/include/gint/display-fx.h b/include/gint/display-fx.h index f7ef95c..11cf72a 100644 --- a/include/gint/display-fx.h +++ b/include/gint/display-fx.h @@ -13,14 +13,12 @@ #include -/* Expose the VRAM variable if GINT_NEED_VRAM is defined. It must always point - to a 4-aligned buffer of size 1024. Any function can use it freely to: +/* gint VRAM address. This value must always point to a 4-aligned buffer of + size 1024. Any function can use it freely to: - Use another video ram area (triple buffering or more, gray engine); - Implement additional drawing functions; - Store data when not drawing. */ -#ifdef GINT_NEED_VRAM -extern uint32_t *vram; -#endif +extern uint32_t *gint_vram; /* color_t - colors available for drawing The following colors are defined by the library: diff --git a/src/core/exch.c b/src/core/exch.c index 3fd2a68..c06394a 100644 --- a/src/core/exch.c +++ b/src/core/exch.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include #include #include @@ -22,7 +21,7 @@ GNORETURN static void gint_default_panic(GUNUSED uint32_t code) #ifdef FX9860G dtext(1, 0, "Exception! (SysERROR)"); - for(int i = 0; i < 32; i++) vram[i] = ~vram[i]; + for(int i = 0; i < 32; i++) gint_vram[i] = ~gint_vram[i]; char const *name = ""; if(code == 0x040) name = "TLB miss read"; @@ -51,7 +50,7 @@ GNORETURN static void gint_default_panic(GUNUSED uint32_t code) #ifdef FXCG50 dtext(6, 3, "An exception occured! (System ERROR)"); - uint32_t *long_vram = (void *)vram; + uint32_t *long_vram = (void *)gint_vram; for(int i = 0; i < 198 * 16; i++) long_vram[i] = ~long_vram[i]; char const *name = ""; diff --git a/src/gray/engine.c b/src/gray/engine.c index 9b55a99..5adca4d 100644 --- a/src/gray/engine.c +++ b/src/gray/engine.c @@ -2,8 +2,6 @@ // gint:gray:engine - Core gray engine //--- -#define GINT_NEED_VRAM - #include #include @@ -39,8 +37,8 @@ GDATA static int delays[2] = { 762, 1311 }; /* gray_init(): Engine setup */ GCONSTRUCTOR static void gray_init(void) { - /* Here [vram] refers to the standard, monochrome VRAM */ - vrams[0] = vram; + /* Here [gint_vram] refers to the standard, monochrome VRAM */ + vrams[0] = gint_vram; #ifdef GINT_STATIC_GRAY vrams[1] = gvrams[0]; diff --git a/src/render-cg/bopti.c b/src/render-cg/bopti.c index 0a27b8b..aa294d6 100644 --- a/src/render-cg/bopti.c +++ b/src/render-cg/bopti.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include #include #include "bopti-asm.h" @@ -22,7 +21,7 @@ enum { void bopti_render(image_t const *img, struct box *box) { /* Offset in video RAM and output stride */ - uint16_t *target = vram + (396 * box->y + box->x); + uint16_t *target = gint_vram + (396 * box->y + box->x); int out = 2 * (396 - box->w); int profile = img->profile; diff --git a/src/render-cg/dclear.c b/src/render-cg/dclear.c index 939b2c5..3f8fabd 100644 --- a/src/render-cg/dclear.c +++ b/src/render-cg/dclear.c @@ -1,10 +1,9 @@ -#define GINT_NEED_VRAM #include #include /* dclear() - fill the screen with a single color */ void dclear(uint16_t color) { - dma_memset(vram, (color << 16) | color, 396 * 224 * 2); + dma_memset(gint_vram, (color << 16) | color, 396 * 224 * 2); return; } diff --git a/src/render-cg/dimage.c b/src/render-cg/dimage.c index 94e7dcc..0315ba1 100644 --- a/src/render-cg/dimage.c +++ b/src/render-cg/dimage.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include #include "bopti-asm.h" diff --git a/src/render-cg/dline.c b/src/render-cg/dline.c index fcbf915..c056c0e 100644 --- a/src/render-cg/dline.c +++ b/src/render-cg/dline.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include #include @@ -15,16 +14,16 @@ void gint_dhline(int x1, int x2, int y, uint16_t color) /* Use longwords to do the copy, but first paint the endpoints to heed for odd x1 and x2. Checking the parity may be a waste of time. */ - vram[offset + x1] = color; - vram[offset + x2] = color; + gint_vram[offset + x1] = color; + gint_vram[offset + x2] = color; /* Now round to longword boundaries and copy everything in-between with longwords */ x1 = x1 + (x1 & 1); x2 = (x2 + 1) & ~1; - uint32_t *start = (void *)(vram + offset + x1); - uint32_t *end = (void *)(vram + offset + x2); + uint32_t *start = (void *)(gint_vram + offset + x1); + uint32_t *end = (void *)(gint_vram + offset + x2); uint32_t op = (color << 16) | color; while(end > start) *--end = op; @@ -39,7 +38,7 @@ void gint_dvline(int y1, int y2, int x, uint16_t color) if(y1 < 0) y1 = 0; if(y2 >= 224) y2 = 223; - uint16_t *v = vram + 396 * y1 + x; + uint16_t *v = gint_vram + 396 * y1 + x; int height = y2 - y1 + 1; while(height--) *v = color, v += 396; diff --git a/src/render-cg/dpixel.c b/src/render-cg/dpixel.c index 574be5e..0dea647 100644 --- a/src/render-cg/dpixel.c +++ b/src/render-cg/dpixel.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include /* dpixel() - change a pixel's color */ @@ -7,5 +6,5 @@ void dpixel(int x, int y, uint16_t color) /* Coordinate checks */ if((uint)x >= 396 || (uint)y >= 224) return; - vram[396 * y + x] = color; + gint_vram[396 * y + x] = color; } diff --git a/src/render-cg/drect.c b/src/render-cg/drect.c index 6384e97..4307cf5 100644 --- a/src/render-cg/drect.c +++ b/src/render-cg/drect.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include #include @@ -18,7 +17,7 @@ void drect(int x1, int y1, int x2, int y2, uint16_t color) /* The method is exactly like dhline(). I first handle odd endpoints, then write longwords for the longest section */ - uint16_t *base = vram + 396 * y1; + uint16_t *base = gint_vram + 396 * y1; int height = y2 - y1 + 1; /* Now copy everything that's left as longwords */ diff --git a/src/render-cg/dupdate.c b/src/render-cg/dupdate.c index ec1bb23..eb9db94 100644 --- a/src/render-cg/dupdate.c +++ b/src/render-cg/dupdate.c @@ -1,15 +1,14 @@ -#define GINT_NEED_VRAM #include //#include /* dupdate() - Push the video RAM to the display driver */ void dupdate(void) { - r61524_display(vram, 0, 224, 1); + r61524_display(gint_vram, 0, 224, 1); } /* dupdate_noint() - Push VRAM to the display without interrupts */ void dupdate_noint(void) { - r61524_display(vram, 0, 224, 0); + r61524_display(gint_vram, 0, 224, 0); } diff --git a/src/render-cg/dvram.c b/src/render-cg/dvram.c index 184fd4d..d841541 100644 --- a/src/render-cg/dvram.c +++ b/src/render-cg/dvram.c @@ -1,12 +1,11 @@ -#define GINT_NEED_VRAM #include /* Put both VRAMs in the system stack! */ static uint16_t *main = (void *)0xac0f0000; static uint16_t *scnd = (void *)0xac11b500; -/* Shared VRAM pointer, the one exposed by GINT_NEED_VRAM */ -uint16_t *vram = (void *)0xac0f0000; +/* Shared VRAM pointer, the one exposed by */ +uint16_t *gint_vram = (void *)0xac0f0000; /* dvram() - Control video RAM address and triple buffering */ void dvram(uint16_t *new_main, uint16_t *new_secondary) diff --git a/src/render-cg/topti.c b/src/render-cg/topti.c index 28f4707..39a9a3d 100644 --- a/src/render-cg/topti.c +++ b/src/render-cg/topti.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include #include #include @@ -67,7 +66,7 @@ void topti_render(int x, int y, char const *str, size_t size, font_t const *f, if(y < 0) top = -y, height += y, y = 0; /* Move to top row */ - uint16_t *target = vram + 396 * y; + uint16_t *target = gint_vram + 396 * y; /* Character spacing and space waiting to be drawn */ int space = 1; diff --git a/src/render-fx/dclear.c b/src/render-fx/dclear.c index c78db59..adfd603 100644 --- a/src/render-fx/dclear.c +++ b/src/render-fx/dclear.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include /* dclear() - fill the screen with a single color */ @@ -11,9 +10,9 @@ void dclear(color_t color) if(color != C_WHITE && color != C_BLACK) return; uint32_t fill = -(color >> 1); - uint32_t *index = vram + 256; + uint32_t *index = gint_vram + 256; - while(index > vram) + while(index > gint_vram) { /* Do it by batches to avoid losing cycles on loop tests */ *--index = fill; diff --git a/src/render-fx/dimage.c b/src/render-fx/dimage.c index 4dbab00..de390d7 100644 --- a/src/render-fx/dimage.c +++ b/src/render-fx/dimage.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include #include #include "bopti-asm.h" @@ -13,7 +12,7 @@ static void *bopti_asm[] = { void dimage(int x, int y, image_t const *img) { if(img->gray) return; - bopti_render_clip(x, y, img, 0, 0, img->width, img->height, vram, + bopti_render_clip(x, y, img, 0, 0, img->width, img->height, gint_vram, NULL, bopti_asm[img->profile]); } @@ -26,11 +25,11 @@ void dsubimage(int x, int y, image_t const *img, int left, int top, if(flags & DIMAGE_NOCLIP) { bopti_render_noclip(x, y, img, left, top, width, height, - vram, NULL, bopti_asm[img->profile]); + gint_vram, NULL, bopti_asm[img->profile]); } else { bopti_render_clip(x, y, img, left, top, width, height, - vram, NULL, bopti_asm[img->profile]); + gint_vram, NULL, bopti_asm[img->profile]); } } diff --git a/src/render-fx/dline.c b/src/render-fx/dline.c index dba5118..90273fc 100644 --- a/src/render-fx/dline.c +++ b/src/render-fx/dline.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include #include #include @@ -13,7 +12,7 @@ void gint_dhline(int x1, int x2, int y, color_t color) uint32_t m[4]; masks(x1, x2, m); - uint32_t *data = vram + (y << 2); + uint32_t *data = gint_vram + (y << 2); if(color == C_WHITE) { @@ -44,7 +43,7 @@ void gint_dvline(int y1, int y2, int x, color_t color) if((uint)x >= 128) return; if(y1 > y2) swap(y1, y2); - uint32_t *base = vram + (y1 << 2) + (x >> 5); + uint32_t *base = gint_vram + (y1 << 2) + (x >> 5); uint32_t *lword = base + ((y2 - y1 + 1) << 2); uint32_t mask = 1 << (~x & 31); diff --git a/src/render-fx/dpixel.c b/src/render-fx/dpixel.c index 5b617dc..457ee28 100644 --- a/src/render-fx/dpixel.c +++ b/src/render-fx/dpixel.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include #include @@ -8,7 +7,7 @@ void dpixel(int x, int y, color_t color) /* Sanity checks */ if((uint)x >= 128 || (uint)y >= 64) return; - uint32_t *lword = vram + (y << 2) + (x >> 5); + uint32_t *lword = gint_vram + (y << 2) + (x >> 5); uint32_t mask = 1 << (~x & 31); if(color == C_WHITE) diff --git a/src/render-fx/drect.c b/src/render-fx/drect.c index 07d2b6a..123904b 100644 --- a/src/render-fx/drect.c +++ b/src/render-fx/drect.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include #include #include @@ -20,8 +19,8 @@ void drect(int x1, int y1, int x2, int y2, color_t color) uint32_t m[4]; masks(x1, x2, m); - uint32_t *base = vram + (y1 << 2); - uint32_t *lword = vram + (y2 << 2) + 4; + uint32_t *base = gint_vram + (y1 << 2); + uint32_t *lword = gint_vram + (y2 << 2) + 4; if(color == C_WHITE) while(lword > base) { diff --git a/src/render-fx/dtext.c b/src/render-fx/dtext.c index 5460c86..e85b64b 100644 --- a/src/render-fx/dtext.c +++ b/src/render-fx/dtext.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include #include #include "topti-asm.h" @@ -9,5 +8,5 @@ void dtext(int x, int y, char const *str, int fg, int bg) { if((uint)fg >= 8 || (uint)bg >= 8) return; topti_render(x, y, str, topti_font, topti_asm_text[fg], - topti_asm_text[bg], vram, vram); + topti_asm_text[bg], gint_vram, gint_vram); } diff --git a/src/render-fx/dupdate.c b/src/render-fx/dupdate.c index 8ff7297..0c23bd4 100644 --- a/src/render-fx/dupdate.c +++ b/src/render-fx/dupdate.c @@ -1,17 +1,16 @@ -#define GINT_NEED_VRAM #include #include /* Standard video RAM for fx9860g is 1 bit per pixel */ GSECTION(".bss") static uint32_t fx_vram[256]; -/* Here is the definition of the VRAM pointer */ -GDATA uint32_t *vram = fx_vram; +/* Here is the definition of the VRAM pointer, exposed in */ +GDATA uint32_t *gint_vram = fx_vram; /* dupdate() - push the video RAM to the display driver */ void dupdate(void) { - t6k11_display(vram, 0, 64, 16); + t6k11_display(gint_vram, 0, 64, 16); } /* dupdate_noint() - Push VRAM to the display without interrupts */ diff --git a/src/render-fx/topti.c b/src/render-fx/topti.c index 34a4cbf..f30874d 100644 --- a/src/render-fx/topti.c +++ b/src/render-fx/topti.c @@ -1,4 +1,3 @@ -#define GINT_NEED_VRAM #include #include #include