Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

caca0.h 7.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * libcaca Colour ASCII-Art library
  3. * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the Do What The Fuck You Want To
  10. * Public License, Version 2, as published by Sam Hocevar. See
  11. * http://sam.zoy.org/wtfpl/COPYING for more details.
  12. */
  13. /*
  14. * This header contains glue code for applications using the pre-1.0
  15. * libcaca API.
  16. */
  17. #ifndef __CACA0_H__
  18. #define __CACA0_H__
  19. #include <caca.h>
  20. #ifdef __cplusplus
  21. extern "C"
  22. {
  23. #endif
  24. /* Function emulation */
  25. extern int __caca0_init(void);
  26. extern void __caca0_end(void);
  27. extern unsigned int __caca0_get_event(unsigned int, int);
  28. extern unsigned int __caca0_sqrt(unsigned int);
  29. extern int __caca0_get_feature(int);
  30. extern void __caca0_set_feature(int);
  31. extern char const *__caca0_get_feature_name(int);
  32. extern cucul_canvas_t *__caca0_load_sprite(char const *);
  33. extern cucul_dither_t *__caca0_create_bitmap(unsigned int, unsigned int,
  34. unsigned int, unsigned int, unsigned long int, unsigned long int,
  35. unsigned long int, unsigned long int);
  36. extern void __caca0_free_bitmap(cucul_dither_t *);
  37. extern char const *__caca0_get_color_name(unsigned char);
  38. /* These variables are needed to emulate old non-thread safe behaviour */
  39. extern cucul_canvas_t *__caca0_cv;
  40. extern caca_display_t *__caca0_dp;
  41. extern unsigned char __caca0_fg;
  42. extern unsigned char __caca0_bg;
  43. /* These enums and macros changed names or values */
  44. enum caca_color
  45. {
  46. CACA_COLOR_BLACK = CUCUL_BLACK,
  47. CACA_COLOR_BLUE = CUCUL_BLUE,
  48. CACA_COLOR_GREEN = CUCUL_GREEN,
  49. CACA_COLOR_CYAN = CUCUL_CYAN,
  50. CACA_COLOR_RED = CUCUL_RED,
  51. CACA_COLOR_MAGENTA = CUCUL_MAGENTA,
  52. CACA_COLOR_BROWN = CUCUL_BROWN,
  53. CACA_COLOR_LIGHTGRAY = CUCUL_LIGHTGRAY,
  54. CACA_COLOR_DARKGRAY = CUCUL_DARKGRAY,
  55. CACA_COLOR_LIGHTBLUE = CUCUL_LIGHTBLUE,
  56. CACA_COLOR_LIGHTGREEN = CUCUL_LIGHTGREEN,
  57. CACA_COLOR_LIGHTCYAN = CUCUL_LIGHTCYAN,
  58. CACA_COLOR_LIGHTRED = CUCUL_LIGHTRED,
  59. CACA_COLOR_LIGHTMAGENTA = CUCUL_LIGHTMAGENTA,
  60. CACA_COLOR_YELLOW = CUCUL_YELLOW,
  61. CACA_COLOR_WHITE = CUCUL_WHITE,
  62. };
  63. enum caca_feature
  64. {
  65. CACA_BACKGROUND = 0x10,
  66. CACA_BACKGROUND_BLACK = 0x11,
  67. CACA_BACKGROUND_SOLID = 0x12,
  68. #define CACA_BACKGROUND_MIN 0x11
  69. #define CACA_BACKGROUND_MAX 0x12
  70. CACA_ANTIALIASING = 0x20,
  71. CACA_ANTIALIASING_NONE = 0x21,
  72. CACA_ANTIALIASING_PREFILTER = 0x22,
  73. #define CACA_ANTIALIASING_MIN 0x21
  74. #define CACA_ANTIALIASING_MAX 0x22
  75. CACA_DITHERING = 0x30,
  76. CACA_DITHERING_NONE = 0x31,
  77. CACA_DITHERING_ORDERED2 = 0x32,
  78. CACA_DITHERING_ORDERED4 = 0x33,
  79. CACA_DITHERING_ORDERED8 = 0x34,
  80. CACA_DITHERING_RANDOM = 0x35,
  81. #define CACA_DITHERING_MIN 0x31
  82. #define CACA_DITHERING_MAX 0x35
  83. CACA_FEATURE_UNKNOWN = 0xffff
  84. };
  85. /* This enum still exists in libcaca 1.x, thus cannot be redefined */
  86. #define CACA_EVENT_NONE 0x00000000
  87. #define CACA_EVENT_KEY_PRESS 0x01000000
  88. #define CACA_EVENT_KEY_RELEASE 0x02000000
  89. #define CACA_EVENT_MOUSE_PRESS 0x04000000
  90. #define CACA_EVENT_MOUSE_RELEASE 0x08000000
  91. #define CACA_EVENT_MOUSE_MOTION 0x10000000
  92. #define CACA_EVENT_RESIZE 0x20000000
  93. #define CACA_EVENT_ANY 0xff000000
  94. /* Backwards compatibility macros for even older shit */
  95. #define caca_dithering caca_feature
  96. #define caca_set_dithering caca_set_feature
  97. #define caca_get_dithering_name caca_get_feature_name
  98. #define CACA_DITHER_NONE CACA_DITHERING_NONE
  99. #define CACA_DITHER_ORDERED CACA_DITHERING_ORDERED8
  100. #define CACA_DITHER_RANDOM CACA_DITHERING_RANDOM
  101. /* Macros to redefine all the shit */
  102. #define caca_init __caca0_init
  103. #define caca_set_delay(x) caca_set_display_time(__caca0_dp, x)
  104. #define caca_get_feature __caca0_get_feature
  105. #define caca_set_feature __caca0_set_feature
  106. #define caca_get_feature_name __caca0_get_feature_name
  107. #define caca_get_rendertime() caca_get_display_time(__caca0_dp)
  108. #define caca_get_width() cucul_get_canvas_width(__caca0_cv)
  109. #define caca_get_height() cucul_get_canvas_height(__caca0_cv)
  110. #define caca_set_window_title(s) caca_set_display_title(__caca0_dp, s)
  111. #define caca_get_window_width() caca_get_display_width(__caca0_dp)
  112. #define caca_get_window_height() caca_get_display_height(__caca0_dp)
  113. #define caca_refresh() caca_refresh_display(__caca0_dp)
  114. #define caca_end __caca0_end
  115. #define caca_get_event(x) __caca0_get_event(x, 0)
  116. #define caca_wait_event(x) __caca0_get_event(x, -1)
  117. #define caca_get_mouse_x() caca_get_mouse_x(__caca0_dp)
  118. #define caca_get_mouse_y() caca_get_mouse_y(__caca0_dp)
  119. #define caca_set_color(x, y) \
  120. (__caca0_fg = (x), __caca0_bg = (y), cucul_set_color_ansi(__caca0_cv, x, y))
  121. #define caca_get_fg_color() __caca0_fg
  122. #define caca_get_bg_color() __caca0_bg
  123. #define caca_get_color_name __caca0_get_color_name
  124. #define caca_putchar(x, y, c) cucul_put_char(__caca0_cv, x, y, c)
  125. #define caca_putstr(x, y, s) cucul_put_str(__caca0_cv, x, y, s)
  126. #define caca_printf(x, y, f, z...) cucul_printf(__caca0_cv, x, y, f, ##z)
  127. #define caca_clear() cucul_clear_canvas(__caca0_cv)
  128. #define caca_draw_line(x, y, z, t, c) \
  129. cucul_draw_line(__caca0_cv, x, y, z, t, c)
  130. #define caca_draw_polyline(x, y, z, c) \
  131. cucul_draw_polyline(__caca0_cv, x, y, z, c)
  132. #define caca_draw_thin_line(x, y, z, t) \
  133. cucul_draw_thin_line(__caca0_cv, x, y, z, t)
  134. #define caca_draw_thin_polyline(x, y, z) \
  135. cucul_draw_thin_polyline(__caca0_cv, x, y, z)
  136. #define caca_draw_circle(x, y, z, c) \
  137. cucul_draw_circle(__caca0_cv, x, y, z, c)
  138. #define caca_draw_ellipse(x, y, z, t, c) \
  139. cucul_draw_ellipse(__caca0_cv, x, y, z, t, c)
  140. #define caca_draw_thin_ellipse(x, y, z, t) \
  141. cucul_draw_thin_ellipse(__caca0_cv, x, y, z, t)
  142. #define caca_fill_ellipse(x, y, z, t, c) \
  143. cucul_fill_ellipse(__caca0_cv, x, y, z, t, c)
  144. #define caca_draw_box(x, y, z, t, c) \
  145. cucul_draw_box(__caca0_cv, x, y, z, t, c)
  146. #define caca_draw_thin_box(x, y, z, t) \
  147. cucul_draw_thin_box(__caca0_cv, x, y, z, t)
  148. #define caca_fill_box(x, y, z, t, c) \
  149. cucul_fill_box(__caca0_cv, x, y, z, t, c)
  150. #define caca_draw_triangle(x, y, z, t, u, v, c) \
  151. cucul_draw_triangle(__caca0_cv, x, y, z, t, u, v, c)
  152. #define caca_draw_thin_triangle(x, y, z, t, u, v) \
  153. cucul_draw_thin_triangle(__caca0_cv, x, y, z, t, u, v)
  154. #define caca_fill_triangle(x, y, z, t, u, v, c) \
  155. cucul_fill_triangle(__caca0_cv, x, y, z, t, u, v, c)
  156. #define caca_rand(a, b) cucul_rand(a, (b)+1)
  157. #define caca_sqrt __caca0_sqrt
  158. #define caca_sprite cucul_canvas
  159. #define caca_load_sprite __caca0_load_sprite
  160. #define caca_get_sprite_frames(c) 1
  161. #define caca_get_sprite_width(c, f) cucul_get_canvas_width(c)
  162. #define caca_get_sprite_height(c, f) cucul_get_canvas_height(c)
  163. #define caca_get_sprite_dx(c, f) 0
  164. #define caca_get_sprite_dx(c, f) 0
  165. #define caca_draw_sprite(x, y, c, f) cucul_blit(__caca0_cv, x, y, c, NULL)
  166. #define caca_free_sprite cucul_free_canvas
  167. #define caca_bitmap cucul_dither
  168. #define caca_create_bitmap __caca0_create_bitmap
  169. #define caca_set_bitmap_palette cucul_set_dither_palette
  170. #define caca_draw_bitmap(x, y, z, t, b, p) \
  171. cucul_dither_bitmap(__caca0_cv, x, y, z, t, b, p)
  172. #define caca_free_bitmap __caca0_free_bitmap
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176. #endif /* __CACA0_H__ */