- rename standard integer types to a more familiar (u)int(8/16/32) - many function/struct renames. i don't _really_ know if what i've done for this is better, but it "feels" better to me. many draw/blit function names are shorter which is nice, at least. kinda important to me because i develop this on a real DOS machine in 80x50 text mode. - add 'extern "C"' blocks to headers for C++ compiler usage - draw/pixel color value arguments for functions should all have been changed to be uint8 instead of a full 32-bit int. feels right, but maybe should've left alone... - small fix to keyboard handler. noticed a problem on one thinkpad laptop. was a result of what i think was a typo in a constant value used during the part of the interrupt handler that tells the keyboard controller the key event was processed - fix uncommon potential crash function return in draw_filled_rect - renamed low-level "direct" assembly functions to "lowlevel_xxx" to be a little bit more explicit about what they are - add some convenience event helper functions for determining event types - add fixed point atan2 - fixed some tabs/spaces inconsistences (should all be spaces now?) - maybe some other minor things i've forgotten
95 lines
3 KiB
C
Executable file
95 lines
3 KiB
C
Executable file
#ifndef LIBDGL_DGLDRAW_H
|
|
#define LIBDGL_DGLDRAW_H
|
|
|
|
#include "dglgfx.h"
|
|
#include "dglclip.h"
|
|
#include "dglutil.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
static void pset(SURFACE *surface, int x, int y, uint8 color);
|
|
static void pset_f(SURFACE *surface, int x, int y, uint8 color);
|
|
static uint8 pget(const SURFACE *surface, int x, int y);
|
|
static uint8 pget_f(const SURFACE *surface, int x, int y);
|
|
|
|
static void draw_hline(SURFACE *surface, int x1, int x2, int y, uint8 color);
|
|
void draw_hline_f(SURFACE *surface, int x1, int x2, int y, uint8 color);
|
|
static void draw_vline(SURFACE *surface, int x, int y1, int y2, uint8 color);
|
|
void draw_vline_f(SURFACE *surface, int x, int y1, int y2, uint8 color);
|
|
void draw_line(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
|
|
void draw_line_f(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
|
|
|
|
void draw_rect(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
|
|
void draw_rect_f(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
|
|
void draw_filled_rect(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
|
|
void draw_filled_rect_f(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
|
|
|
|
void draw_text(SURFACE *surface, int x, int y, uint8 color, const char *text);
|
|
void draw_text_f(SURFACE *surface, int x, int y, uint8 color, const char *text);
|
|
void draw_printf(SURFACE *surface, int x, int y, uint8 color, const char *format, ...);
|
|
void draw_printf_f(SURFACE *surface, int x, int y, uint8 color, const char *format, ...);
|
|
|
|
void lowlevel_rect_f(
|
|
uint8 color,
|
|
int width,
|
|
int y_inc,
|
|
int lines,
|
|
uint8 *p1,
|
|
uint8 *p2
|
|
);
|
|
|
|
void lowlevel_filled_rect_f(
|
|
uint8 color,
|
|
int y_inc,
|
|
int width,
|
|
int lines,
|
|
uint8 *dest
|
|
);
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
static void pset(SURFACE *surface, int x, int y, uint8 color) {
|
|
if (is_point_in_bounds(&surface->clip_region, x, y))
|
|
pset_f(surface, x, y, color);
|
|
}
|
|
|
|
static void pset_f(SURFACE *surface, int x, int y, uint8 color) {
|
|
uint32 offset = surface_offset(surface, x, y);
|
|
surface->pixels[offset] = color;
|
|
}
|
|
|
|
static uint8 pget(const SURFACE *surface, int x, int y) {
|
|
if (is_point_in_bounds(&surface->clip_region, x, y))
|
|
return pget_f(surface, x, y);
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
static uint8 pget_f(const SURFACE *surface, int x, int y) {
|
|
uint32 offset = surface_offset(surface, x, y);
|
|
return surface->pixels[offset];
|
|
}
|
|
|
|
static void draw_hline(SURFACE *surface, int x1, int x2, int y, uint8 color) {
|
|
if (x2 < x1)
|
|
SWAP(int, x1, x2);
|
|
if (clamp_to_region(&surface->clip_region, &x1, &y, &x2, &y))
|
|
draw_hline_f(surface, x1, x2, y, color);
|
|
}
|
|
|
|
static void draw_vline(SURFACE *surface, int x, int y1, int y2, uint8 color) {
|
|
if (y2 < y1)
|
|
SWAP(int, y1, y2);
|
|
if (clamp_to_region(&surface->clip_region, &x, &y1, &x, &y2))
|
|
draw_vline_f(surface, x, y1, y2, color);
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|