mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-04-03 17:17:10 +02:00
r61524, render-fx, gray: allow changing fxg3a border/mono/gray colors
This commit is contained in:
parent
48718bf9be
commit
704c6b3f24
6 changed files with 200 additions and 16 deletions
|
@ -81,6 +81,36 @@ void dupdate_set_hook(gint_call_t function);
|
|||
/* dupdate_get_hook(): Get a copy of the dupdate() hook */
|
||||
gint_call_t dupdate_get_hook(void);
|
||||
|
||||
#define DMONO_BORDER_DEFAULT 0xe71c /* C_RGB(28, 28, 28) */
|
||||
#define DMONO_BLACK_DEFAULT 0x0000
|
||||
#define DMONO_WHITE_DEFAULT 0xffff
|
||||
|
||||
/* dmono_setborder(): Set the mono border color
|
||||
|
||||
When using the fxg3a compilation target, there is a border drawn around the
|
||||
screen because the 128x64 screen is scaled to 384x192, yet the display is
|
||||
396x224. This function allows changing the color used for the border. The
|
||||
default color is DMONO_BORDER_DEFAULT.
|
||||
|
||||
@border New mono border color (RGB565) */
|
||||
void dmono_setborder(const uint16_t border);
|
||||
|
||||
/* dmono_setcolors(): Set the mono screen colors
|
||||
|
||||
When using the fxg3a compilation target, this function allows changing the
|
||||
colors used for the screen. The default colors are:
|
||||
DMONO_BLACK_DEFAULT, DMONO_WHITE_DEFAULT.
|
||||
|
||||
@black New mono black color (RGB565)
|
||||
@white New mono white color (RGB565) */
|
||||
void dmono_setcolors(const uint16_t black, const uint16_t white);
|
||||
|
||||
/* dmono_resetcolors(): Reset mono border and screen colors to defaults
|
||||
|
||||
When using the fxg3a compilation target, this function will reset the mono
|
||||
border color and all screen colors to their default values. */
|
||||
void dmono_resetcolors(void);
|
||||
|
||||
//---
|
||||
// Rendering mode control
|
||||
//---
|
||||
|
|
|
@ -49,13 +49,53 @@ 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_set_mono_border_128x64(): Set mono border color
|
||||
|
||||
This function sets the border color for a 128x64 mono VRAM, used with
|
||||
the fxg3a compilation target.
|
||||
|
||||
@border New mono VRAM border color (RGB565) */
|
||||
void r61524_set_mono_border_128x64(const uint16_t border);
|
||||
|
||||
/* r61524_set_mono_colors_128x64(): Set mono colors
|
||||
|
||||
This function sets the colors for a 128x64 mono VRAM, used with the fxg3a
|
||||
compilation target.
|
||||
|
||||
@black New mono VRAM black color (RGB565)
|
||||
@white New mono VRAM white color (RGB565) */
|
||||
void r61524_set_mono_colors_128x64(const uint16_t black, const uint16_t white);
|
||||
|
||||
/* 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_display_mono_128x64(): Display a gray-style VRAM
|
||||
/* r61524_set_gray_border_128x64(): Set gray border color
|
||||
|
||||
This function sets the border color for a 128x64 gray VRAM, used with
|
||||
the fxg3a compilation target.
|
||||
|
||||
@border New gray VRAM border color (RGB565) */
|
||||
void r61524_set_gray_border_128x64(const uint16_t border);
|
||||
|
||||
/* r61524_set_gray_colors_128x64(): Set gray colors
|
||||
|
||||
This function sets the colors for a 128x64 gray VRAM, used with the fxg3a
|
||||
compilation target.
|
||||
|
||||
@black New gray VRAM black color (RGB565)
|
||||
@dark New gray VRAM dark color (RGB565)
|
||||
@light New gray VRAM light color (RGB565)
|
||||
@white New gray VRAM white color (RGB565) */
|
||||
|
||||
void r61524_set_gray_colors_128x64(const uint16_t black, const uint16_t dark,
|
||||
const uint16_t light, const uint16_t white);
|
||||
|
||||
/* r61524_display_gray_128x64(): Display a gray-style VRAM
|
||||
|
||||
This experimental function updates the display with the contents of a 128x64
|
||||
gray VRAM pair, used with the fxg3a compilation target.
|
||||
TODO: Make that a video mode. */
|
||||
|
|
|
@ -140,6 +140,43 @@ void dgray_setdelays(uint32_t light, uint32_t dark);
|
|||
@dark Set to the current dark delay setting */
|
||||
void dgray_getdelays(uint32_t *light, uint32_t *dark);
|
||||
|
||||
#define DGRAY_BORDER_DEFAULT 0xe71c /* C_RGB(28, 28, 28) */
|
||||
#define DGRAY_BLACK_DEFAULT 0x0000
|
||||
#define DGRAY_DARK_DEFAULT 0x528a
|
||||
#define DGRAY_LIGHT_DEFAULT 0xad55
|
||||
#define DGRAY_WHITE_DEFAULT 0xffff
|
||||
|
||||
/* dgray_setborder(): Set the gray engine border color
|
||||
|
||||
When using the fxg3a compilation target, there is a border drawn around the
|
||||
screen because the 128x64 screen is scaled to 384x192, yet the display is
|
||||
396x224. This function allows changing the color used for the border. The
|
||||
default color is DGRAY_BORDER_DEFAULT.
|
||||
|
||||
@border New gray engine border color (RGB565) */
|
||||
void dgray_setborder(const uint16_t border);
|
||||
|
||||
/* dgray_setcolors(): Set the gray engine colors
|
||||
|
||||
When using the fxg3a compilation target, the gray engine is simulated using
|
||||
colors. This function allows changing the colors used for the screen. The
|
||||
default colors are: DGRAY_BLACK_DEFAULT, DGRAY_DARK_DEFAULT,
|
||||
DGRAY_LIGHT_DEFAULT, DGRAY_WHITE_DEFAULT.
|
||||
|
||||
@black New gray engine black color (RGB565)
|
||||
@dark New gray engine dark color (RGB565)
|
||||
@light New gray engine light color (RGB565)
|
||||
@white New gray engine white color (RGB565) */
|
||||
void dgray_setcolors(const uint16_t black, const uint16_t dark,
|
||||
const uint16_t light, const uint16_t white);
|
||||
|
||||
/* dgray_resetcolors(): Reset border and all gray engine colors to defaults
|
||||
|
||||
When using the fxg3a compilation target, this function will reset the gray
|
||||
engine border color and all gray engine screen colors to their default
|
||||
values. */
|
||||
void dgray_resetcolors(void);
|
||||
|
||||
//---
|
||||
// VRAM management
|
||||
//---
|
||||
|
|
|
@ -264,6 +264,25 @@ int gupdate(void)
|
|||
r61524_display_gray_128x64(vrams[0], vrams[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dgray_setborder(const uint16_t border)
|
||||
{
|
||||
r61524_set_gray_border_128x64(border);
|
||||
}
|
||||
|
||||
void dgray_setcolors(const uint16_t black, const uint16_t dark,
|
||||
const uint16_t light, const uint16_t white)
|
||||
{
|
||||
r61524_set_gray_colors_128x64(black, dark, light, white);
|
||||
}
|
||||
|
||||
void dgray_resetcolors(void)
|
||||
{
|
||||
r61524_set_gray_border_128x64(DGRAY_BORDER_DEFAULT);
|
||||
r61524_set_gray_colors_128x64(DGRAY_BLACK_DEFAULT, DGRAY_DARK_DEFAULT,
|
||||
DGRAY_LIGHT_DEFAULT, DGRAY_WHITE_DEFAULT);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//---
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include <gint/video.h>
|
||||
#include <gint/image.h>
|
||||
#include <gint/config.h>
|
||||
#include <gint/display.h>
|
||||
#include <gint/gray.h>
|
||||
|
||||
#if GINT_HW_CG
|
||||
|
||||
|
@ -34,6 +36,24 @@ static volatile uint16_t *DISPLAY = (void *)0xb4000000;
|
|||
/* Bit 4 of Port R controls the RS bit of the display driver */
|
||||
static volatile uint8_t *PRDR = (void *)0xa405013c;
|
||||
|
||||
/* 128x64 mono VRAM border color */
|
||||
static uint16_t mono_border = DMONO_BORDER_DEFAULT;
|
||||
/* 128x64 mono VRAM screen colors
|
||||
White is at index 0 rather than 1, because the LCD has a white background and
|
||||
when pixels are on, they are black. When a bit is set the LCD driver turns on
|
||||
a black pixel. Therefore, black is 1 and white is 0. */
|
||||
static uint16_t mono_colors[] = { DMONO_WHITE_DEFAULT, DMONO_BLACK_DEFAULT };
|
||||
|
||||
/* 128x64 gray VRAM border color */
|
||||
static uint16_t gray_border = DGRAY_BORDER_DEFAULT;
|
||||
/* 128x64 gray VRAM gray engine colors */
|
||||
static uint16_t gray_colors[] = {
|
||||
DGRAY_BLACK_DEFAULT,
|
||||
DGRAY_DARK_DEFAULT,
|
||||
DGRAY_LIGHT_DEFAULT,
|
||||
DGRAY_WHITE_DEFAULT
|
||||
};
|
||||
|
||||
/* Select a register */
|
||||
GINLINE static void select(uint16_t reg)
|
||||
{
|
||||
|
@ -186,28 +206,37 @@ void r61524_display_rect(uint16_t *vram, int xmin, int xmax, int ymin,
|
|||
}
|
||||
}
|
||||
|
||||
void r61524_set_mono_border_128x64(const uint16_t border)
|
||||
{
|
||||
mono_border = border;
|
||||
}
|
||||
|
||||
void r61524_set_mono_colors_128x64(const uint16_t black, const uint16_t white)
|
||||
{
|
||||
mono_colors[0] = white;
|
||||
mono_colors[1] = black;
|
||||
}
|
||||
|
||||
void r61524_display_mono_128x64(uint32_t *vram)
|
||||
{
|
||||
dma_transfer_wait(0);
|
||||
r61524_start_frame(0, 395, 0, 223);
|
||||
|
||||
int border = 0xe71c; /* C_RGB(28, 28, 28) */
|
||||
|
||||
for(int i = 0; i < 16 * 396; i++)
|
||||
write(border);
|
||||
write(mono_border);
|
||||
|
||||
for(int y = 0; y < 64; y++) {
|
||||
/* sub-y position */
|
||||
for(int sy = 0; sy < 3; sy++) {
|
||||
for(int i = 0; i < 6; i++)
|
||||
write(border);
|
||||
write(mono_border);
|
||||
|
||||
/* longword-x position */
|
||||
for(int lwx = 0; lwx < 4; lwx++) {
|
||||
int32_t i = vram[lwx];
|
||||
/* sub-x position */
|
||||
for(int sx = 0; sx < 32; sx++) {
|
||||
int color = ~(i >> 31);
|
||||
const int color = mono_colors[(uint32_t)i >> 31];
|
||||
i <<= 1;
|
||||
write(color);
|
||||
write(color);
|
||||
|
@ -216,13 +245,27 @@ void r61524_display_mono_128x64(uint32_t *vram)
|
|||
}
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
write(border);
|
||||
write(mono_border);
|
||||
}
|
||||
vram += 4;
|
||||
}
|
||||
|
||||
for(int i = 0; i < 16 * 396; i++)
|
||||
write(border);
|
||||
write(mono_border);
|
||||
}
|
||||
|
||||
void r61524_set_gray_border_128x64(const uint16_t border)
|
||||
{
|
||||
gray_border = border;
|
||||
}
|
||||
|
||||
void r61524_set_gray_colors_128x64(const uint16_t black, const uint16_t dark,
|
||||
const uint16_t light, const uint16_t white)
|
||||
{
|
||||
gray_colors[0] = black;
|
||||
gray_colors[1] = dark;
|
||||
gray_colors[2] = light;
|
||||
gray_colors[3] = white;
|
||||
}
|
||||
|
||||
void r61524_display_gray_128x64(uint32_t *light, uint32_t *dark)
|
||||
|
@ -230,17 +273,14 @@ void r61524_display_gray_128x64(uint32_t *light, uint32_t *dark)
|
|||
dma_transfer_wait(0);
|
||||
r61524_start_frame(0, 395, 0, 223);
|
||||
|
||||
int border = 0xe71c; /* C_RGB(28, 28, 28) */
|
||||
int colors[] = { 0x0000, 0x528a, 0xad55, 0xffff };
|
||||
|
||||
for(int i = 0; i < 16 * 396; i++)
|
||||
write(border);
|
||||
write(gray_border);
|
||||
|
||||
for(int y = 0; y < 64; y++) {
|
||||
/* sub-y position */
|
||||
for(int sy = 0; sy < 3; sy++) {
|
||||
for(int i = 0; i < 6; i++)
|
||||
write(border);
|
||||
write(gray_border);
|
||||
|
||||
/* longword-x position */
|
||||
for(int lwx = 0; lwx < 4; lwx++) {
|
||||
|
@ -248,7 +288,7 @@ void r61524_display_gray_128x64(uint32_t *light, uint32_t *dark)
|
|||
int32_t id = dark[lwx];
|
||||
/* sub-x position */
|
||||
for(int sx = 0; sx < 32; sx++) {
|
||||
int color = colors[(id >= 0) * 2 + (il >= 0)];
|
||||
const int color = gray_colors[(id >= 0) * 2 + (il >= 0)];
|
||||
il <<= 1;
|
||||
id <<= 1;
|
||||
write(color);
|
||||
|
@ -258,14 +298,14 @@ void r61524_display_gray_128x64(uint32_t *light, uint32_t *dark)
|
|||
}
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
write(border);
|
||||
write(gray_border);
|
||||
}
|
||||
light += 4;
|
||||
dark += 4;
|
||||
}
|
||||
|
||||
for(int i = 0; i < 16 * 396; i++)
|
||||
write(border);
|
||||
write(gray_border);
|
||||
}
|
||||
|
||||
static bool r61524_update(int x, int y, image_t const *fb, int flags)
|
||||
|
|
|
@ -56,4 +56,22 @@ void dupdate(void)
|
|||
__attribute__((alias("dupdate")))
|
||||
void _WEAK_dupdate(void);
|
||||
|
||||
#if GINT_HW_CG
|
||||
void dmono_setborder(const uint16_t border)
|
||||
{
|
||||
r61524_set_mono_border_128x64(border);
|
||||
}
|
||||
|
||||
void dmono_setcolors(const uint16_t black, const uint16_t white)
|
||||
{
|
||||
r61524_set_mono_colors_128x64(black, white);
|
||||
}
|
||||
|
||||
void dmono_resetcolors(void)
|
||||
{
|
||||
r61524_set_mono_border_128x64(DMONO_BORDER_DEFAULT);
|
||||
r61524_set_mono_colors_128x64(DMONO_BLACK_DEFAULT, DMONO_WHITE_DEFAULT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GINT_RENDER_MONO */
|
||||
|
|
Loading…
Add table
Reference in a new issue