vxKernel/src/drivers/screen/R61524/r61524.c

142 lines
2.9 KiB
C
Raw Normal View History

#include <vhex/defs/types.h>
#include <vhex/driver.h>
#include <vhex/driver/screen/r61524.h>
#include <vhex/display/interface.h>
//---
// R61524 driver API
//---
/* r61524_frame_start() - prepar the screen and reset surfaces */
int r61524_frame_start(dsurface_t *surface)
{
/* Set the windows size */
r61524_select(horizontal_ram_start);
r61524_write(0);
r61524_select(horizontal_ram_end);
r61524_write(395);
r61524_select(vertical_ram_start);
r61524_write(0);
r61524_select(vertical_ram_end);
r61524_write(223);
/* Set the RAM position */
r61524_select(ram_address_horizontal);
r61524_write(0);
r61524_select(ram_address_vertical);
r61524_write(0);
/* Bind address 0xb4000000 to the data write command */
r61524_select(write_data);
/* initialize surface information */
surface->vram = (void*)0xe5017000;
surface->width = 396;
surface->height = 10;
surface->x1 = 0;
surface->y1 = 0;
surface->x2 = 395;
surface->y2 = 9;
return (0);
}
int r61524_frame_frag_next(dsurface_t *surface)
{
surface->y1 += 10;
if (surface->y1 >= 224) {
surface->y1 -= 10;
return (-1);
}
if (surface->y1 >= 220)
surface->height = 4;
surface->y2 += surface->height;
return (0);
}
VWEAK int r61524_frame_frag_send(dsurface_t *surface)
{
uint16_t * restrict yram = surface->vram;
int size = (surface->y1 == 220) ? 1584 : 3960;
VxKernel 0.6.0-4 : Support the text API @add <> src/modules/display/text/dascii | proof-of-concept of "one-char" drawing API (used for kernel debug) <> src/modules/fs | empty File System module used to expose some primitives used by the libc: | write(), read(), lseek() and close() which there have been removed from the | `fxlibc` project which used an old / deprecated ABI/sycall interface that | doesn't exist in this version of Vhex @update <> include/display/draw/pixel | remove the display ID returned by dpixel(). All primitives that support | shaders must provide explicit API. This to allow fast-optimized API and | polyvalence API for shadering which impact the performance <> src/modules/display/dclear | isolate tree level for this primitive: | - kernel : direct fragment drawing primitive (by-pass dstack) | - dstack : dstack drawing primitive | - user : user drawing primitive (dstack-API) | invalidate automatically the dstack each time the primitive (user-level) is | involved <> src/modules/display/dstack | isolate the dstack invalidate part in a specific primitive @fix <> make/Makefile | proper support of the OpenLibm header path <> src/drivers/screen/r61524 | proper support of the last data fragment size. This caused an override on | the first X line of the screen <> src/modules/display/dstack | fix a crash when the number of action is full | fix a crash with the default index used for action cache | fix a crash with the default index used for shader cache | fix action initialization | fix action quit primitive <> src/modules/display/text/dfont | fix the character drawing algorithm | proper support of the character drawing color (foreground/background) | fix the kernel-level primitive used to display a Unicode string <> src/modules/display/text/dtext | fix a crash with the internal index counter | fix a crash in the internal cache | fix the quit function
2022-06-10 21:28:51 +02:00
for (int i = 0; i < size; ++i) {
r61524_write(yram[i]);
}
return (0);
}
int r61524_frame_end(dsurface_t *surface)
{
(void)surface;
return (0);
}
//---
// Driver definition
//---
/* R61524 display (graphics RAM range) */
struct r61524_ctx {
uint16_t HSA;
uint16_t HEA;
uint16_t VSA;
uint16_t VEA;
};
static void __r61524_configure(struct r61524_ctx *s)
{
s->HSA = 0;
s->HEA = 395;
s->VSA = 0;
s->VEA = 223;
}
static void __r61524_hsave(struct r61524_ctx *s)
{
r61524_select(horizontal_ram_start);
s->HSA = r61524_read();
r61524_select(horizontal_ram_end);
s->HEA = r61524_read();
r61524_select(vertical_ram_start);
s->VSA = r61524_read();
r61524_select(vertical_ram_end);
s->VEA = r61524_read();
}
static void __r61524_hrestore(struct r61524_ctx const *s)
{
r61524_select(horizontal_ram_start);
r61524_write(s->HSA);
r61524_select(horizontal_ram_end);
r61524_write(s->HEA);
r61524_select(vertical_ram_start);
r61524_write(s->VSA);
r61524_select(vertical_ram_end);
r61524_write(s->VEA);
}
struct vhex_driver drv_r61524 = {
.name = "R61524",
.hsave = (void*)&__r61524_hsave,
.hrestore = (void*)&__r61524_hrestore,
.configure = (void*)&__r61524_configure,
.state_size = sizeof(struct r61524_ctx),
.flags = {
.DISPLAY = 1,
.SHARED = 0,
.UNUSED = 0,
},
.module_data = &(struct dstack_drv_interface){
.frame_start = &r61524_frame_start,
.frame_frag_next = &r61524_frame_frag_next,
.frame_frag_send = &r61524_frame_frag_send,
.frame_end = &r61524_frame_end,
.display_width = 396,
.display_height = 224
}
};
VHEX_DECLARE_DRIVER(16, drv_r61524);