43#if defined(_MSC_VER) && (_MSC_VER == 1300)
52#define DUFFS_LOOP8(pixel_copy_increment, width) \
53{ int n = (width + 7) / 8; \
54 switch (width & 7) { \
55 case 0: do { pixel_copy_increment; \
57 case 7: pixel_copy_increment; \
59 case 6: pixel_copy_increment; \
61 case 5: pixel_copy_increment; \
63 case 4: pixel_copy_increment; \
65 case 3: pixel_copy_increment; \
67 case 2: pixel_copy_increment; \
69 case 1: pixel_copy_increment; \
70 } while ( --n > 0 ); \
75#define DUFFS_LOOP4(pixel_copy_increment, width) \
76{ int n = (width + 3) / 4; \
77 switch (width & 3) { \
78 case 0: do { pixel_copy_increment; \
80 case 3: pixel_copy_increment; \
82 case 2: pixel_copy_increment; \
84 case 1: pixel_copy_increment; \
85 } while ( --n > 0 ); \
90#define DUFFS_LOOP_DOUBLE2(pixel_copy_increment, \
91 double_pixel_copy_increment, width) \
94 pixel_copy_increment; \
100 case 0: do { double_pixel_copy_increment; \
102 case 2: double_pixel_copy_increment; \
103 } while ( --n > 0 ); \
109#define DUFFS_LOOP_QUATRO2(pixel_copy_increment, \
110 double_pixel_copy_increment, \
111 quatro_pixel_copy_increment, width) \
114 pixel_copy_increment; \
118 double_pixel_copy_increment; \
124 case 0: do { quatro_pixel_copy_increment; \
125 case 4: quatro_pixel_copy_increment; \
126 } while ( --n > 0 ); \
132#define DUFFS_LOOP(pixel_copy_increment, width) \
133 DUFFS_LOOP8(pixel_copy_increment, width)
138#define DUFFS_LOOP_DOUBLE2(pixel_copy_increment, \
139 double_pixel_copy_increment, width) \
142 pixel_copy_increment; \
145 for (; n > 0; --n) { \
146 double_pixel_copy_increment; \
152#define DUFFS_LOOP_QUATRO2(pixel_copy_increment, \
153 double_pixel_copy_increment, \
154 quatro_pixel_copy_increment, width) \
157 pixel_copy_increment; \
161 double_pixel_copy_increment; \
164 for (; n > 0; --n) { \
165 quatro_pixel_copy_increment; \
171#define DUFFS_LOOP(pixel_copy_increment, width) \
173 for ( n=width; n > 0; --n ) { \
174 pixel_copy_increment; \
178#define DUFFS_LOOP8(pixel_copy_increment, width) \
179 DUFFS_LOOP(pixel_copy_increment, width)
180#define DUFFS_LOOP4(pixel_copy_increment, width) \
181 DUFFS_LOOP(pixel_copy_increment, width)
187#define DEFAULT_ZOOM 0.5
188#define adj_surf(surf) zoomSurface((surf), DEFAULT_ZOOM, DEFAULT_ZOOM, 0)
190#define DEFAULT_ZOOM 1.0
192#define adj_surf(surf) copy_surface(surf)
306#define map_rgba_details(details, color) \
307 SDL_MapRGBA(details, NULL, (color).r, (color).g, (color).b, (color).a)
308#define map_rgba(format, color) \
309 map_rgba_details(SDL_GetPixelFormatDetails(format), color)
311#define crop_rect_from_screen(rect) \
312 crop_rect_from_surface(main_data.screen, &rect)
315#define FREESURFACE(ptr) \
318 SDL_DestroySurface(ptr); \
326#define lock_surf(surf) \
328 if (SDL_MUSTLOCK(surf)) { \
329 SDL_LockSurface(surf); \
337#define unlock_surf(surf) \
339 if (SDL_MUSTLOCK(surf)) { \
340 SDL_UnlockSurface(surf); \
347#define lock_screen() lock_surf(main_data.screen)
352#define unlock_screen() unlock_surf(main_data.screen)
354#define putpixel(surf, x, y, pixel) \
356 Uint8 *buf_ptr = ((Uint8 *)surf->pixels + (y * surf->pitch)); \
357 switch (surf->format->BytesPerPixel) { \
360 *(Uint8 *)buf_ptr = pixel; \
364 *((Uint16 *)buf_ptr) = pixel; \
367 buf_ptr += (x << 1) + x; \
368 if (is_bigendian()) { \
369 buf_ptr[0] = (pixel >> 16) & 0xff; \
370 buf_ptr[1] = (pixel >> 8) & 0xff; \
371 buf_ptr[2] = pixel & 0xff; \
373 buf_ptr[0] = pixel & 0xff; \
374 buf_ptr[1] = (pixel >> 8) & 0xff; \
375 buf_ptr[2] = (pixel >> 16) & 0xff; \
380 *((Uint32 *)buf_ptr) = pixel; \
386#define ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \
388 dR = (((sR-dR)*(A))>>8)+dR; \
389 dG = (((sG-dG)*(A))>>8)+dG; \
390 dB = (((sB-dB)*(A))>>8)+dB; \
393#define ALPHA_BLEND128(sR, sG, sB, dR, dG, dB) \
395 Uint32 __Src = (sR << 16 | sG << 8 | sB); \
396 Uint32 __Dst = (dR << 16 | dG << 8 | dB); \
397 __Dst = ((((__Src & 0x00fefefe) + (__Dst & 0x00fefefe)) >> 1) \
398 + (__Src & __Dst & 0x00010101)) | 0xFF000000; \
399 dR = (__Dst >> 16) & 0xFF; \
400 dG = (__Dst >> 8 ) & 0xFF; \
401 dB = (__Dst ) & 0xFF; \
struct canvas int int struct sprite int int int int height
struct canvas int int int int struct sprite *sprite struct canvas struct color * pcolor
struct canvas int int struct sprite int int int width
SDL_Surface * resize_surface(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth)
int main_window_width(void)
void layer_rect_to_screen_rect(struct gui_layer *gui_layer, SDL_Rect *dest_rect)
SDL_Surface * load_surf(const char *fname)
SDL_Surface * create_surf_with_format(SDL_PixelFormat *pf, int width, int height, Uint32 flags)
void update_main_screen(void)
void remove_gui_layer(struct gui_layer *gui_layer)
SDL_Surface * create_filled_surface(Uint16 w, Uint16 h, Uint32 flags, SDL_Color *pcolor)
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
void gui_layer_destroy(struct gui_layer **gui_layer)
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
SDL_Surface * copy_surface(SDL_Surface *src)
bool set_video_mode(unsigned width, unsigned height, unsigned flags)
SDL_Surface * mask_surface(SDL_Surface *src, SDL_Surface *mask, int mask_offset_x, int mask_offset_y)
struct gui_layer * gui_layer_new(int x, int y, SDL_Surface *surface)
SDL_Surface * crop_visible_part_from_surface(SDL_Surface *psrc)
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 right, Sint16 bottom, SDL_Color *pcolor)
struct gui_layer * get_gui_layer(SDL_Surface *surface)
bool is_in_rect_area(int x, int y, const SDL_Rect *rect)
int screen_blit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Rect *dstrect, unsigned char alpha_mod)
struct sdl2_data main_data
int blit_entire_src(SDL_Surface *psrc, SDL_Surface *pdest, Sint16 dest_x, Sint16 dest_y)
Uint32 get_first_pixel(SDL_Surface *surf)
SDL_Surface * convert_surf(SDL_Surface *surf_in)
SDL_Surface * create_surf(int width, int height, Uint32 flags)
void get_smaller_surface_rect(SDL_Surface *surf, SDL_Rect *rect)
struct gui_layer * add_gui_layer(int width, int height)
int clear_surface(SDL_Surface *surf, SDL_Rect *dstrect)
bool correct_rect_region(SDL_Rect *prect)
void screen_rect_to_layer_rect(struct gui_layer *gui_layer, SDL_Rect *dest_rect)
bool create_surfaces(int width, int height)
int main_window_height(void)
SDL_Surface * resize_surface_box(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth, bool scale_up, bool absolute_dimensions)
Uint32 get_pixel(SDL_Surface *surf, Sint16 x, Sint16 y)
struct sprite int int int int struct sprite * mask
struct sprite int int int int struct sprite int mask_offset_x
struct sprite int int int int struct sprite int int mask_offset_y
SDL_Rect rects[RECT_LIMIT]