gint_strcat/include/display.h

182 lines
2.9 KiB
C

#ifndef _DISPLAY_H
#define _DISPLAY_H 1
//---
// Types and constants.
//---
enum Color
{
Color_White = 0, // White (AND 0)
Color_Black = 1, // Black (OR 1)
Color_None = 2, // Transparent (NOP)
Color_Invert = 3, // Invert (XOR 1)
};
/*
enum BlendingMode
Describes the various blending modes available for drawing images.
Blending modes may be combined for special effects! For instance:
- Or Only sets black pixels.
- And Only erases white pixels.
- Or | And Fully draws the bitmap.
- Invert Inverts pixels where the bitmap is black.
- Or | Invert Erases black pixels.
Adding Checker to an existing combination limits the operation to
pixels (x, y) that satisfy (x + y) & 1 == 1.
Operations are done in the following order : Or - Invert - And.
*/
enum BlendingMode
{
Blend_Or = 0x01,
Blend_Invert = 0x02,
Blend_And = 0x04,
Blend_Checker = 0x10,
};
enum ImageFormat
{
ImageFormat_Mono = 0x01,
ImageFormat_Gray = 0x02,
ImageFormat_Alpha = 0x10,
ImageFormat_ColorMask = 0x0f,
};
struct Image
{
unsigned char width;
unsigned char height;
unsigned char format;
// Ensures data is 4-aligned.
unsigned char gap;
const unsigned char __attribute__((aligned(4))) data[];
} __attribute__((aligned(4)));
typedef struct Image Image;
#define DISPLAY_WIDTH 128
#define DISPLAY_HEIGHT 64
//---
// Generic functions.
//---
/*
display_getLocalVRAM()
Returns the local video ram. This address should not be used directly
when running the gray engine.
@return Video ram address of the monochrome display module.
*/
void *display_getLocalVRAM(void);
/*
display_useVRAM()
Changes the current video ram address. Expects a *4-aligned* 1024-byte
buffer.
Do not use this function while running the gray engine.
@arg New video ram address.
*/
void display_useVRAM(void *vram);
//---
// Global drawing functions.
//---
/*
dupdate()
Displays the vram on the physical screen.
*/
void dupdate(void);
/*
dclear()
Clears the whole video ram.
*/
void dclear(void);
/*
dclear_area()
Clears an area of the video ram.
@arg x1
@arg y1
@arg x2
@arg y2
*/
void dclear_area(int x1, int y1, int x2, int y2);
/*
dreverse_area()
Reverses an area of the screen.
@arg x1
@arg y1
@arg x2
@arg y2
*/
void dreverse_area(int x1, int y1, int x2, int y2);
//---
// Local drawing functions.
//---
/*
dpixel()
Puts a pixel on the screen.
@arg x
@arg y
@arg color
*/
void dpixel(int x, int y, enum Color color);
/*
dline()
Draws a line on the screen. Automatically optimizes horizontal and
vertical lines.
Uses an algorithm written by PierrotLL for MonochromeLib.
@arg x1
@arg y1
@arg x2
@arg y2
@arg color
*/
void dline(int x1, int y1, int x2, int y2, enum Color color);
//---
// Image drawing.
//---
/*
dimage()
Displays an image in the vram.
@arg image
@arg x
@arg y
@arg mode
*/
void dimage(struct Image *image, int x, int y, enum BlendingMode mode);
#endif // _DISPLAY_H