You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

259 lines
7.7KB

  1. /* ---------------------------------------------------------------------------|
  2. *
  3. * Distributed under the CC0 public domain license.
  4. * By Alison G. Watson. Attribution is encouraged, though not required.
  5. * See licenses/cc0.txt for more information.
  6. *
  7. * ---------------------------------------------------------------------------|
  8. *
  9. * Drawing functions.
  10. *
  11. * ---------------------------------------------------------------------------|
  12. */
  13. #if defined(GlobalCr)
  14. #if !defined(GlobalCrH)
  15. #define GlobalCrH GlobalCr
  16. #endif
  17. GlobalCr(blue) GlobalCr(green) GlobalCr(grey) GlobalCr(pink) GlobalCr(purple)
  18. GlobalCr(red) GlobalCr(yellow)
  19. GlobalCr(rred) GlobalCr(rdor) GlobalCr(rora) GlobalCr(ryel) GlobalCr(rylg)
  20. GlobalCr(rgrn) GlobalCr(rcya) GlobalCr(rblu) GlobalCr(rind) GlobalCr(rpur)
  21. GlobalCr(rlav) GlobalCr(rpnk) GlobalCr(rhpn)
  22. GlobalCrH(wsela1) GlobalCrH(wsela2) GlobalCrH(wsela3) GlobalCrH(wselas)
  23. GlobalCrH(wselc1) GlobalCrH(wselc2) GlobalCrH(wselc3) GlobalCrH(wselcs)
  24. GlobalCrH(wseld1) GlobalCrH(wseld2) GlobalCrH(wseld3) GlobalCrH(wselds)
  25. GlobalCrH(wseli1) GlobalCrH(wseli2) GlobalCrH(wseli3) GlobalCrH(wselis)
  26. GlobalCrH(wselm1) GlobalCrH(wselm2) GlobalCrH(wselm3) GlobalCrH(wselms)
  27. #undef GlobalCr
  28. #undef GlobalCrH
  29. #else
  30. #define BitArg(x, mask, shift) (((u32)(x) & mask) << shift)
  31. #define SignArg(x, mask) (((u32)(x) & mask) | ((u32)(x) & 0x80000000))
  32. #define XBitArg(x, xa) (SignArg(x, 0x0FFFFFFF) | BitArg(xa, 7, 28))
  33. #define YBitArg(y, ya) (SignArg(y, 0x1FFFFFFF) | BitArg(ya, 3, 29))
  34. #define PrintRectArgs0(x, y) (BitArg(x, 0xffff, 0) | BitArg(y, 0xffff, 16))
  35. #define PrintRectArgs1(w, h) PrintRectArgs0(w, h)
  36. #define PrintRectArgs2(c, a) ((c) | BitArg(a, 0xff, 24))
  37. #define PrintRect(x, y, w, h, c) \
  38. DrawCallI(sm_LR, PrintRectArgs0(x, y), PrintRectArgs1(w, h), \
  39. PrintRectArgs2(c, 0xff))
  40. #define PrintRectA(x, y, w, h, c, a) \
  41. DrawCallI(sm_LR, PrintRectArgs0(x, y), PrintRectArgs1(w, h), \
  42. PrintRectArgs2(c, a))
  43. #define PrintLine(x, y, z, w, c) \
  44. DrawCallI(sm_LL, x, y, z, w, c)
  45. #define PrintSpriteArgs0(x, xa) XBitArg(x, xa)
  46. #define PrintSpriteArgs1(y, ya) YBitArg(y, ya)
  47. #define PrintSpriteArgs2(alpha, flg) (BitArg(alpha, 0xff, 0) | (u32)(flg))
  48. #define PrintSpriteArgs_N(x, xa, y, ya, flg) \
  49. PrintSpriteArgs0(x, xa), \
  50. PrintSpriteArgs1(y, ya), \
  51. PrintSpriteArgs2(0, flg)
  52. #define PrintSpriteArgs_A(x, xa, y, ya, alpha, flg) \
  53. PrintSpriteArgs0(x, xa), \
  54. PrintSpriteArgs1(y, ya), \
  55. PrintSpriteArgs2(k32_to_byte(alpha), 0x400 | (flg))
  56. #define PrintSpriteArgs_F(x, xa, y, ya, num, flg) \
  57. PrintSpriteArgs0(x, xa), \
  58. PrintSpriteArgs1(y, ya), \
  59. PrintSpriteArgs2(num, 0x200 | (flg))
  60. #define PrintSprite(name, x, xa, y, ya) \
  61. DrawCallI(sm_LS, name, PrintSpriteArgs_N(x, xa, y, ya, 0))
  62. #define PrintSpriteA(name, x, xa, y, ya, alpha) \
  63. DrawCallI(sm_LS, name, PrintSpriteArgs_A(x, xa, y, ya, alpha, 0))
  64. #define PrintSpriteF(name, x, xa, y, ya, num) \
  65. DrawCallI(sm_LS, name, PrintSpriteArgs_F(x, xa, y, ya, num, 0))
  66. #define PrintSpriteP(name, x, xa, y, ya) \
  67. DrawCallI(sm_LS, name, PrintSpriteArgs_N(x, xa, y, ya, 0x100))
  68. #define PrintSpriteAP(name, x, xa, y, ya, alpha) \
  69. DrawCallI(sm_LS, name, PrintSpriteArgs_A(x, xa, y, ya, alpha, 0x100))
  70. #define PrintSpriteFP(name, x, xa, y, ya, num) \
  71. DrawCallI(sm_LS, name, PrintSpriteArgs_F(x, xa, y, ya, num, 0x100))
  72. #define PrintSpriteC(name, x, xa, y, ya, c) \
  73. DrawCallI(sm_LS, name, PrintSpriteArgs_N(x, xa, y, ya, 0), c)
  74. #define PrintSpriteAC(name, x, xa, y, ya, alpha, c) \
  75. DrawCallI(sm_LS, name, PrintSpriteArgs_A(x, xa, y, ya, alpha, 0), c)
  76. #define PrintTextFmt(...) StrParamBegin(__VA_ARGS__)
  77. #define PrintTextStr(s) (ACS_BeginPrint(), ACS_PrintString(s))
  78. #define PrintTextChr(s, n) (ACS_BeginPrint(), PrintChars(s, n))
  79. #define PrintTextChS(s) (ACS_BeginPrint(), PrintChrSt(s))
  80. #define PrintTextArgs0(x, xa) XBitArg(x, xa)
  81. #define PrintTextArgs1(y, ya) YBitArg(y, ya)
  82. #define PrintTextArgs2(cr, alpha, flg) (BitArg(cr, 0xff, 0) | \
  83. BitArg(alpha, 0xff, 8) | \
  84. (u32)(flg))
  85. #define PrintTextArgs_N(cr, flg, x, xa, y, ya) \
  86. PrintTextArgs0(x, xa), \
  87. PrintTextArgs1(y, ya), \
  88. PrintTextArgs2(cr, 0, flg)
  89. #define PrintTextArgs_A(cr, flg, x, xa, y, ya, alpha) \
  90. PrintTextArgs0(x, xa), \
  91. PrintTextArgs1(y, ya), \
  92. PrintTextArgs2(cr, k32_to_byte(alpha), (flg) | 0x20000)
  93. #define PrintTextArgs_F(cr, flg, x, xa, y, ya, num) \
  94. PrintTextArgs0(x, xa), \
  95. PrintTextArgs1(y, ya), \
  96. PrintTextArgs2(cr, num, (flg) | 0x10000)
  97. #define PrintTextEnd() ACS_EndStrParam()
  98. #define PrintText_str(s, font, cr, x, xa, y, ya) \
  99. DrawCallI(sm_LT, s, font, PrintTextArgs_N(cr, 0, x, xa, y, ya))
  100. #define PrintTextX_str(s, font, cr, x, xa, y, ya, flg) \
  101. DrawCallI(sm_LT, s, font, PrintTextArgs_N(cr, flg, x, xa, y, ya))
  102. #define PrintTextA_str(s, font, cr, x, xa, y, ya, alpha) \
  103. DrawCallI(sm_LT, s, font, PrintTextArgs_A(cr, 0, x, xa, y, ya, alpha))
  104. #define PrintTextAX_str(s, font, cr, x, xa, y, ya, alpha, flg) \
  105. DrawCallI(sm_LT, s, font, PrintTextArgs_A(cr, flg, x, xa, y, ya, alpha))
  106. #define PrintTextF_str(s, font, cr, x, xa, y, ya, num) \
  107. DrawCallI(sm_LT, s, font, PrintTextArgs_F(cr, 0, x, xa, y, ya, num))
  108. #define PrintTextFX_str(s, font, cr, x, xa, y, ya, num, flg) \
  109. DrawCallI(sm_LT, s, font, PrintTextArgs_F(cr, flg, x, xa, y, ya, num))
  110. #define PrintText(...) PrintText_str (PrintTextEnd(), __VA_ARGS__)
  111. #define PrintTextX(...) PrintTextX_str (PrintTextEnd(), __VA_ARGS__)
  112. #define PrintTextA(...) PrintTextA_str (PrintTextEnd(), __VA_ARGS__)
  113. #define PrintTextAX(...) PrintTextAX_str(PrintTextEnd(), __VA_ARGS__)
  114. #define PrintTextF(...) PrintTextF_str (PrintTextEnd(), __VA_ARGS__)
  115. #define PrintTextFX(...) PrintTextFX_str(PrintTextEnd(), __VA_ARGS__)
  116. #define SetClipArgs0(x, y) (BitArg(x, 0xffff, 0) | BitArg(y, 0xffff, 16))
  117. #define SetClipArgs1(w, h) SetClipArgs0(w, h)
  118. #define SetClip(x, y, w, h) \
  119. DrawCallI(sm_LC, SetClipArgs0(x, y), SetClipArgs1(w, h))
  120. #define SetClipW(x, y, w, h, ww) \
  121. DrawCallI(sm_LC, SetClipArgs0(x, y), SetClipArgs1(w, h), (u32)(ww))
  122. #define ClearClip() \
  123. DrawCallI(sm_LC)
  124. #define SetSize(w, h) \
  125. DrawCallI(sm_LZ, (i32)(w), (i32)(h))
  126. #define SetFadeArgs(num, time, speed, alpha) \
  127. (BitArg(num, 0xff, 0) | \
  128. BitArg(time, 0xff, 8) | \
  129. BitArg(speed, 0xff, 16) | \
  130. BitArg(k32_to_byte(alpha), 0xff, 24))
  131. #define SetFade(n, time, speed) \
  132. DrawCallI(sm_LF, SetFadeArgs(n, time, speed, 1.0))
  133. #define SetFadeA(n, time, speed, alpha) \
  134. DrawCallI(sm_LF, SetFadeArgs(n, time, speed, alpha))
  135. #define CheckFade(n) \
  136. DrawCallI(sm_LX, n)
  137. #define GetFade(n) \
  138. DrawCallI(sm_LY, n)
  139. #define StartSound(...) \
  140. DrawCallI(sm_StartSound, __VA_ARGS__)
  141. #if !ZscOn
  142. enum {
  143. CHANF_LISTENERZ = 8,
  144. CHANF_MAYBE_LOCAL = 16,
  145. CHANF_UI = 32,
  146. CHANF_NOPAUSE = 64,
  147. CHANF_LOOP = 256,
  148. CHANF_NOSTOP = 4096,
  149. CHANF_OVERLAP = 8192,
  150. CHANF_LOCAL = 16384,
  151. };
  152. enum {
  153. ptf_no_utf = 0x40000,
  154. ptf_add = 0x80000,
  155. };
  156. #define Cr(name) globalcolors.name
  157. extern struct globalcolors {
  158. #define GlobalCr(name) i32 name;
  159. #include "m_drawing.h"
  160. } globalcolors;
  161. enum {
  162. #define GlobalCr(name) _gcr_##name,
  163. #define GlobalCrH(name)
  164. #include "m_drawing.h"
  165. _gcr_max,
  166. };
  167. i32 Draw_GetCr(i32 n);
  168. #endif
  169. enum ZscName(FontNum) {
  170. font_misaki_gothic,
  171. font_misaki_mincho,
  172. font_k6x8,
  173. font_jiskan16,
  174. font_num,
  175. };
  176. enum ZscName(Channel) {
  177. lch_auto,
  178. lch_weapon,
  179. lch_voice,
  180. lch_item,
  181. lch_body,
  182. lch_altweapon,
  183. lch_body2,
  184. lch_body3,
  185. lch_dryweapon,
  186. lch_idleweapon,
  187. lch_item2,
  188. lch_reload,
  189. lch_reload2,
  190. lch_reload3,
  191. lch_scope,
  192. lch_voice2,
  193. lch_weapon2,
  194. lch_weapon3,
  195. };
  196. #if !ZscOn
  197. void Draw_Init(void);
  198. #endif
  199. #endif
  200. /* EOF */