vxKernel/src/modules/display/draw/dpixel.c

61 lines
1.1 KiB
C
Raw Normal View History

#include <vhex/display.h>
#include <vhex/defs/attributes.h>
#include <vhex/defs/types.h>
//---
// Kernel-level API
//---
/* dpixel_render() : drawing algorithm */
void dpixel_render(dsurface_t *surface, int x, int y, int color)
{
if (color == C_NONE)
return;
/* check point culling */
if (y < surface->y1
|| x < surface->x1
|| y > surface->y2
|| x > surface->x2) {
return;
}
/* calculate the draw index */
int real_y = (y - surface->y1) * surface->width;
int real_x = (x - surface->x1);
int draw_idx = real_y + real_x;
/* handle special color */
uint16_t *vram = surface->vram;
if (color == C_INVERT)
color = vram[draw_idx] ^ 0xffff;
/* set the pixel */
vram[draw_idx] = color;
}
//---
// Dstack-level API
//---
/* dpixel_render_dstack() : dstack-API compatible render */
void dpixel_dstack(dsurface_t *surface, uint32_t *arg)
{
dpixel_render(surface, arg[0], arg[1], arg[2]);
}
//---
// User-level API
//---
/* dpixel() : draw a pixel in screen */
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
void dpixel(int x, int y, int color)
{
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
dstack_add_action(
&DSTACK_CALL(&dpixel_dstack, x, y, color),
NULL,
NULL
);
}