5#ifndef RETROSOFT_PRESENT
6# error "RETROSOFT_PRESENT must be defined in order to use retrosoft!"
24#define RETROFLAT_LINE_X 0
25#define RETROFLAT_LINE_Y 1
27#ifndef RETROSOFT_TRACE_LVL
28# define RETROSOFT_TRACE_LVL 0
38 int x1,
int y1,
int x2,
int y2, uint8_t flags );
47 int x,
int y,
int w,
int h, uint8_t flags );
58 int x,
int y,
int w,
int h, uint8_t flags );
66void retrosoft_line_strategy(
67 int x1,
int y1,
int x2,
int y2,
68 uint8_t* p_for_axis, uint8_t* p_off_axis, int16_t dist[2],
69 int16_t start[2], int16_t end[2], int16_t iter[2],
70 int16_t* p_inc, int16_t* p_delta
74 if( abs( y2 - y1 ) < abs( x2 - x1 ) ) {
76 start[RETROFLAT_LINE_X] = x2;
77 start[RETROFLAT_LINE_Y] = y2;
78 end[RETROFLAT_LINE_X] = x1;
79 end[RETROFLAT_LINE_Y] = y1;
80 *p_for_axis = RETROFLAT_LINE_X;
82 start[RETROFLAT_LINE_X] = x1;
83 start[RETROFLAT_LINE_Y] = y1;
84 end[RETROFLAT_LINE_X] = x2;
85 end[RETROFLAT_LINE_Y] = y2;
86 *p_for_axis = RETROFLAT_LINE_X;
90 start[RETROFLAT_LINE_X] = x2;
91 start[RETROFLAT_LINE_Y] = y2;
92 end[RETROFLAT_LINE_X] = x1;
93 end[RETROFLAT_LINE_Y] = y1;
94 *p_for_axis = RETROFLAT_LINE_Y;
96 start[RETROFLAT_LINE_X] = x1;
97 start[RETROFLAT_LINE_Y] = y1;
98 end[RETROFLAT_LINE_X] = x2;
99 end[RETROFLAT_LINE_Y] = y2;
100 *p_for_axis = RETROFLAT_LINE_Y;
105 *p_off_axis = 1 - *p_for_axis;
106 iter[RETROFLAT_LINE_X] = start[RETROFLAT_LINE_X];
107 iter[RETROFLAT_LINE_Y] = start[RETROFLAT_LINE_Y];
108 dist[RETROFLAT_LINE_X] = end[RETROFLAT_LINE_X] - start[RETROFLAT_LINE_X];
109 dist[RETROFLAT_LINE_Y] = end[RETROFLAT_LINE_Y] - start[RETROFLAT_LINE_Y];
112 *p_delta = (2 * dist[*p_off_axis]) - dist[*p_for_axis];
113 if( 0 > dist[*p_off_axis] ) {
115 dist[*p_off_axis] *= -1;
123#if defined( RETROFLAT_OPENGL ) || \
124 defined( RETROFLAT_API_PC_BIOS ) || \
125 defined( RETROFLAT_SOFT_LINES )
129 int x1,
int y1,
int x2,
int y2, uint8_t flags
132 uint8_t for_axis = 0,
145 if( NULL == target ) {
146 target = retroflat_screen_buffer();
150 retroflat_px_lock( target );
152 retrosoft_line_strategy(
154 &for_axis, &off_axis, dist, start, end, iter, &inc, &delta );
157 iter[for_axis] = start[for_axis] ;
158 end[for_axis] > iter[for_axis] ;
170 iter[RETROFLAT_LINE_X], iter[RETROFLAT_LINE_Y], flags );
175 iter[off_axis] += inc;
176 delta += (2 * (dist[off_axis] - dist[for_axis]));
178 delta += (2 * dist[off_axis]);
182 retroflat_px_release( target );
191 int x,
int y,
int w,
int h, uint8_t flags
202 if( NULL == target ) {
203 target = retroflat_screen_buffer();
207 retroflat_px_lock( target );
211 for( y_iter = y ; y_iter < y + h ; y_iter++ ) {
212 for( x_iter = x ; x_iter < x + w ; x_iter++ ) {
214 retroflat_2d_px( target, color_idx, x_iter, y_iter, flags );
220#if defined( RETROFLAT_SOFT_LINES ) || defined( RETROFLAT_3D )
222 retrosoft_line( target, color_idx, x + w, y, x + w, y + h, flags );
223 retrosoft_line( target, color_idx, x + w, y + h, x, y + h, flags );
227 retroflat_line( target, color_idx, x + w, y, x + w, y + h, flags );
228 retroflat_line( target, color_idx, x + w, y + h, x, y + h, flags );
234 retroflat_px_release( target );
241 int x,
int y,
int w,
int h, uint8_t flags
256 if( NULL == target ) {
257 target = retroflat_screen_buffer();
261 retroflat_px_lock( target );
265 for( i = 100 ; 2 * MFIX_PI + 100 > i ; i += 100 ) {
274 mfix_to_i( mfix_cos( i_prev ) * w / 2 );
276 px_y1 = y + (h / 2) + mfix_to_i( mfix_sin( i_prev ) * (h / 2) );
277 px_x2 = x + (w / 2) + mfix_to_i( mfix_cos( i ) * (w / 2) );
278 px_y2 = y + (h / 2) + mfix_to_i( mfix_sin( i ) * (h / 2) );
284#ifdef RETROSOFT_HARD_LINES
285 retroflat_line( target, color, px_x1, px_y1, px_x2, px_y2, flags );
287 retrosoft_line( target, color, px_x1, px_y1, px_x2, px_y2, flags );
320 retroflat_px_release( target );
int8_t RETROFLAT_COLOR
Defines an index in the platform-specific color-table.
Definition: retroflt.h:328
#define RETROFLAT_DRAW_FLAG_FILL
Flag for retroflat_rect() or retroflat_ellipse(), indicating drawn shape should be filled.
Definition: retroflt.h:376
void retroflat_line(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, retroflat_pxxy_t x1, retroflat_pxxy_t y1, retroflat_pxxy_t x2, retroflat_pxxy_t y2, uint8_t flags)
Draw a straight line onto the target ::RETROFLAT_BITMAP.
void retrosoft_rect(retroflat_blit_t *target, const RETROFLAT_COLOR color_idx, int x, int y, int w, int h, uint8_t flags)
Draw a rectangle at the given coordinates, with the given dimensions.
void retrosoft_ellipse(retroflat_blit_t *target, RETROFLAT_COLOR color, int x, int y, int w, int h, uint8_t flags)
Draw an ellipsoid at the given coordinates, with the given dimensions.
void retrosoft_line(retroflat_blit_t *target, RETROFLAT_COLOR color, int x1, int y1, int x2, int y2, uint8_t flags)
Draw a line from x1, y1 to x2, y2.