render: remove the GINT_NEED_VRAM macro

This macro used to protect the declaration of the [vram] variable of
gint. This variable was short to keep drawing functions short but could
clutter the namespace.

That being said, it's even better to just [#define vram gint_vram] if
you need. This change renames the variable to [gint_vram], exposes it
whenever <gint/display.h> is included, and removes the GINT_NEED_VRAM
macro altogether.
This commit is contained in:
Lephe 2019-10-27 08:14:42 +01:00
parent 95a3345326
commit 9eb723ee53
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
22 changed files with 42 additions and 68 deletions

2
TODO
View file

@ -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

View file

@ -15,16 +15,14 @@
#include <gint/defs/types.h>
/* 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]

View file

@ -13,14 +13,12 @@
#include <gint/defs/types.h>
/* 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:

View file

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/exc.h>
#include <gint/display.h>
#include <gint/clock.h>
@ -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 = "";

View file

@ -2,8 +2,6 @@
// gint:gray:engine - Core gray engine
//---
#define GINT_NEED_VRAM
#include <gint/defs/types.h>
#include <gint/std/stdlib.h>
@ -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];

View file

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/defs/types.h>
#include <gint/display.h>
#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;

View file

@ -1,10 +1,9 @@
#define GINT_NEED_VRAM
#include <gint/display.h>
#include <gint/dma.h>
/* 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;
}

View file

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/display.h>
#include "bopti-asm.h"

View file

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/display.h>
#include <gint/defs/util.h>
@ -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;

View file

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/display.h>
/* 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;
}

View file

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/defs/util.h>
#include <gint/display.h>
@ -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 */

View file

@ -1,15 +1,14 @@
#define GINT_NEED_VRAM
#include <gint/display.h>
//#include <gint/drivers/r61524.h>
/* 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);
}

View file

@ -1,12 +1,11 @@
#define GINT_NEED_VRAM
#include <gint/display.h>
/* 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 <gint/display.h> */
uint16_t *gint_vram = (void *)0xac0f0000;
/* dvram() - Control video RAM address and triple buffering */
void dvram(uint16_t *new_main, uint16_t *new_secondary)

View file

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/defs/types.h>
#include <gint/defs/attributes.h>
#include <gint/display.h>
@ -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;

View file

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/display.h>
/* 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;

View file

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/display.h>
#include <display/fx.h>
#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]);
}
}

View file

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/display.h>
#include <gint/defs/util.h>
#include <display/fx.h>
@ -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);

View file

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/display.h>
#include <gint/defs/types.h>
@ -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)

View file

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/defs/util.h>
#include <gint/display.h>
#include <display/fx.h>
@ -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)
{

View file

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/display.h>
#include <display/common.h>
#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);
}

View file

@ -1,17 +1,16 @@
#define GINT_NEED_VRAM
#include <gint/display.h>
#include <gint/drivers/t6k11.h>
/* 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 <gint/display.h> */
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 */

View file

@ -1,4 +1,3 @@
#define GINT_NEED_VRAM
#include <gint/defs/types.h>
#include <gint/defs/attributes.h>
#include <gint/display.h>