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], 0 );
 
  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
 
  198   if( NULL == target ) {
 
  199      target = retroflat_screen_buffer();
 
  203   retroflat_px_lock( target );
 
  207      for( y_iter = y ; y_iter < y + h ; y_iter++ ) {
 
  208         for( x_iter = x ; x_iter < x + w ; x_iter++ ) {
 
  210            retroflat_2d_px( target, color_idx, x_iter, y_iter, 0 );
 
  216#if defined( RETROFLAT_SOFT_LINES ) || defined( RETROFLAT_3D ) 
  230   retroflat_px_release( target );
 
  237   int x, 
int y, 
int w, 
int h, uint8_t flags
 
  252   if( NULL == target ) {
 
  253      target = retroflat_screen_buffer();
 
  257   retroflat_px_lock( target );
 
  261      for( i = 100 ; 2 * MFIX_PI + 100 > i ; i += 100 ) {
 
  270            mfix_to_i( mfix_cos( i_prev ) * w / 2 );
 
  272         px_y1 = y + (h / 2) + mfix_to_i( mfix_sin( i_prev ) * (h / 2) );
 
  273         px_x2 = x + (w / 2) + mfix_to_i( mfix_cos( i ) * (w / 2) );
 
  274         px_y2 = y + (h / 2) + mfix_to_i( mfix_sin( i ) * (h / 2) );
 
  312   retroflat_px_release( target );
 
int8_t RETROFLAT_COLOR
Defines an index in the platform-specific color-table.
Definition: retroflt.h:325
#define RETROFLAT_FLAGS_FILL
Flag for retroflat_rect() or retroflat_ellipse(), indicating drawn shape should be filled.
Definition: retroflt.h:373
void retroflat_line(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int16_t x1, int16_t y1, int16_t x2, int16_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.