Advertisement
Benji23245

Untitled

Mar 9th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.59 KB | None | 0 0
  1. // Sonic+Miscellaneous.cpp : Defines the exported functions for the DLL application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "SADXModLoader.h"
  6. #include "functions.h"
  7.  
  8. bool just_untransformed = false;
  9. bool gauge2_lv1 = false;
  10. bool gauge2_lv2 = false;
  11. bool gauge2_full = false;
  12. bool HUD_loaded = false;
  13. //bool sonic_gameplay = false;
  14.  
  15. int Gauge;
  16. int Gauge2;
  17. int test = 0;
  18. int untest = 0;
  19. int OldRingsHUD;
  20. int can_animate_gain = 0;
  21. int can_animate_loss = 0;
  22.  
  23. ////////////////////// HUD //////////////////////////////////////////////////////////////////////////
  24. enum HUDTextureIndex
  25. {
  26. HUD_gauge, HUD_rings, HUD_lives, HUD_score, HUD_timer, HUD_sonic_lv1, HUD_sonic_lv2, HUD_sonic_lv3, HUD_shadow_lv1, HUD_shadow_lv2, HUD_shadow_lv3,
  27. HUD_metal_lv1, HUD_metal_lv2, HUD_metal_lv3, HUD_sonic_life, HUD_tails_life, HUD_knuckles_life, HUD_shadow_life, HUD_amy_life, HUD_gamma_life,
  28. HUD_metalsonic_life, HUD_tailsdoll_life, HUD_metalknuckles_life, HUD_0, HUD_1, HUD_2, HUD_3, HUD_4, HUD_5, HUD_6, HUD_7, HUD_8, HUD_9, HUD_0s_red,
  29. HUD_0s_red_glow, HUD_ring_a, HUD_ring_b, HUD_ring_c, HUD_ring_d, HUD_ring_e, HUD_ring_f, HUD_ring_g, HUD_ring_h
  30. };
  31.  
  32.  
  33.  
  34. static NJS_TEXNAME HUD_TEXNAME[8];
  35. static NJS_TEXLIST HUD_TEXLIST = { arrayptrandlength(HUD_TEXNAME) }; //MY OWN HUD STUFF
  36.  
  37.  
  38. static NJS_TEXANIM HUD_TEXANIM[] = {
  39. // w, h, cx, cy, u1, v1, u2, v2, texid, attr
  40. // u2 and v2 must be 0xFF
  41. { 375, 85, -810, -660, 0, 0, 0xFF, 0xFF, HUD_gauge, 0 },//width and height must be the texture's size
  42. { 314, 55, 44, -170, 0, 0, 0xFF, 0xFF, HUD_rings, 0 },//cx and cy are the position on the screen cx => + or - to go left or right; cy => + or - to go up or down
  43. { 314, 55, 44, -220, 0, 0, 0xFF, 0xFF, HUD_lives, 0 },
  44. { 394, 55, 44, -70, 0, 0, 0xFF, 0xFF, HUD_score, 0 },
  45. { 394, 55, 44, -120, 0, 0, 0xFF, 0xFF, HUD_timer, 0 },
  46. { 75, 25, -1104, -700, 0, 0, 0xFF, 0xFF, HUD_sonic_lv1, 0 },
  47. { 75, 25, -1104, -700, 0, 0, 0xFF, 0xFF, HUD_sonic_lv2, 0 },
  48. { 75, 25, -1104, -700, 0, 0, 0xFF, 0xFF, HUD_sonic_lv3, 0 },
  49. { 75, 25, -1104, -700, 0, 0, 0xFF, 0xFF, HUD_shadow_lv1, 0 },
  50. { 75, 25, -1104, -700, 0, 0, 0xFF, 0xFF, HUD_shadow_lv2, 0 },
  51. { 75, 25, -1104, -700, 0, 0, 0xFF, 0xFF, HUD_shadow_lv3, 0 },
  52. { 75, 25, -1104, -700, 0, 0, 0xFF, 0xFF, HUD_metal_lv1, 0 },
  53. { 75, 25, -1104, -700, 0, 0, 0xFF, 0xFF, HUD_metal_lv2, 0 },
  54. { 75, 25, -1104, -700, 0, 0, 0xFF, 0xFF, HUD_metal_lv3, 0 },
  55. { 75, 75, -110, -205, 0, 0, 0xFF, 0xFF, HUD_sonic_life, 0 },
  56. { 75, 75, -110, -205, 0, 0, 0xFF, 0xFF, HUD_tails_life, 0 },
  57. { 75, 75, -110, -205, 0, 0, 0xFF, 0xFF, HUD_knuckles_life, 0 },
  58. { 75, 75, -110, -205, 0, 0, 0xFF, 0xFF, HUD_shadow_life, 0 },
  59. { 75, 75, -110, -205, 0, 0, 0xFF, 0xFF, HUD_amy_life, 0 },
  60. { 75, 75, -110, -205, 0, 0, 0xFF, 0xFF, HUD_gamma_life, 0 },
  61. { 75, 75, -110, -205, 0, 0, 0xFF, 0xFF, HUD_metalsonic_life, 0 },
  62. { 75, 75, -110, -205, 0, 0, 0xFF, 0xFF, HUD_tailsdoll_life, 0 },
  63. { 75, 75, -110, -205, 0, 0, 0xFF, 0xFF, HUD_metalknuckles_life, 0 }
  64. };
  65.  
  66.  
  67. static NJS_TEXANIM HUD_TEXANIM_NUMBERS_SCORE[] = {
  68.  
  69. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_0, 0 },
  70. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_1, 0 },
  71. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_2, 0 },
  72. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_3, 0 },
  73. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_4, 0 },
  74. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_5, 0 },
  75. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_6, 0 },
  76. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_7, 0 },
  77. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_8, 0 },
  78. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_9, 0 }
  79. };
  80.  
  81. static NJS_TEXANIM HUD_TEXANIM_NUMBERS_TIMER_MINUTES[] = {
  82.  
  83. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_0, 0 },
  84. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_1, 0 },
  85. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_2, 0 },
  86. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_3, 0 },
  87. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_4, 0 },
  88. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_5, 0 },
  89. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_6, 0 },
  90. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_7, 0 },
  91. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_8, 0 },
  92. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_9, 0 }
  93. };
  94.  
  95. static NJS_TEXANIM HUD_TEXANIM_NUMBERS_TIMER_SECONDS[] = {
  96.  
  97. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_0, 0 },
  98. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_1, 0 },
  99. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_2, 0 },
  100. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_3, 0 },
  101. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_4, 0 },
  102. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_5, 0 },
  103. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_6, 0 },
  104. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_7, 0 },
  105. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_8, 0 },
  106. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_9, 0 }
  107. };
  108.  
  109. static NJS_TEXANIM HUD_TEXANIM_NUMBERS_TIMER_FRAMES[] = {
  110.  
  111. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_0, 0 },
  112. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_1, 0 },
  113. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_2, 0 },
  114. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_3, 0 },
  115. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_4, 0 },
  116. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_5, 0 },
  117. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_6, 0 },
  118. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_7, 0 },
  119. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_8, 0 },
  120. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_9, 0 }
  121. };
  122.  
  123. static NJS_TEXANIM HUD_TEXANIM_NUMBERS_RING_ANIM[] = {
  124.  
  125. { 50, 50, -161, -225, 0, 0, 0xFF, 0xFF, HUD_ring_a, 0 },
  126. { 50, 50, -161, -225, 0, 0, 0xFF, 0xFF, HUD_ring_b, 0 },
  127. { 50, 50, -161, -225, 0, 0, 0xFF, 0xFF, HUD_ring_c, 0 },
  128. { 50, 50, -161, -225, 0, 0, 0xFF, 0xFF, HUD_ring_d, 0 },
  129. { 50, 50, -161, -225, 0, 0, 0xFF, 0xFF, HUD_ring_e, 0 },
  130. { 50, 50, -161, -225, 0, 0, 0xFF, 0xFF, HUD_ring_f, 0 },
  131. { 50, 50, -161, -225, 0, 0, 0xFF, 0xFF, HUD_ring_g, 0 },
  132. { 50, 50, -161, -225, 0, 0, 0xFF, 0xFF, HUD_ring_h, 0 }
  133. };
  134.  
  135. static NJS_TEXANIM HUD_TEXANIM_NUMBERS_RINGS[] = {
  136.  
  137. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_0, 0 },
  138. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_1, 0 },
  139. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_2, 0 },
  140. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_3, 0 },
  141. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_4, 0 },
  142. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_5, 0 },
  143. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_6, 0 },
  144. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_7, 0 },
  145. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_8, 0 },
  146. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_9, 0 }
  147. };
  148.  
  149. static NJS_TEXANIM HUD_TEXANIM_NUMBERS_RINGS_0_RED[] = {
  150.  
  151. { 90, 75, -212, -216, 0, 0, 0xFF, 0xFF, HUD_0s_red, 0 },
  152. { 90, 75, -212, -216, 0, 0, 0xFF, 0xFF, HUD_0s_red_glow, 0 }
  153. };
  154.  
  155. static NJS_TEXANIM HUD_TEXANIM_NUMBERS_LIVES[] = {
  156. // w, h, cx, cy, u1, v1, u2, v2, texid, attr
  157. // u2 and v2 must be 0xFF
  158. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_0, 0 },
  159. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_1, 0 },
  160. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_2, 0 },
  161. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_3, 0 },
  162. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_4, 0 },
  163. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_5, 0 }, //18 between 2 numbers
  164. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_6, 0 }, //37 between the doublecoma numbers
  165. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_7, 0 }, //35 between the coma numbers
  166. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_8, 0 },
  167. { 40, 40, -157, -174, 0, 0, 0xFF, 0xFF, HUD_9, 0 } //-158 for ring digit 1; -18 for 2; -18 for 3
  168. };
  169.  
  170.  
  171.  
  172.  
  173. NJS_SPRITE HUD_SPRITE = { { 0.0f, 0.0f, 0.0f }, 1.3f, 1.3f, 0, &HUD_TEXLIST, HUD_TEXANIM };//the three numbers in the brackets are X, Y, and Z position, then X and Y scaling, rotation, texlist, and texanim
  174. //REDO with its own NJS_TEXANIM (that's the big char sel screen pictures) NJS_SPRITE HUD_SPRITE2 = { { 0.0f, 0.0f, 0.0f }, 1.0f, 1.0f, 0, &HUD_TEXLIST, HUD_TEXANIM };
  175. NJS_SPRITE HUD_SPRITE_NUMBERS_SCORE = { { 0.0f, 0.0f, 0.0f }, 1.3f, 1.3f, 0, &HUD_TEXLIST, HUD_TEXANIM_NUMBERS_SCORE };
  176. NJS_SPRITE HUD_SPRITE_NUMBERS_TIMER_MINUTES = { { 0.0f, 0.0f, 0.0f }, 1.3f, 1.3f, 0, &HUD_TEXLIST, HUD_TEXANIM_NUMBERS_TIMER_MINUTES };
  177. NJS_SPRITE HUD_SPRITE_NUMBERS_TIMER_SECONDS = { { 0.0f, 0.0f, 0.0f }, 1.3f, 1.3f, 0, &HUD_TEXLIST, HUD_TEXANIM_NUMBERS_TIMER_SECONDS };
  178. NJS_SPRITE HUD_SPRITE_NUMBERS_TIMER_FRAMES = { { 0.0f, 0.0f, 0.0f }, 1.3f, 1.3f, 0, &HUD_TEXLIST, HUD_TEXANIM_NUMBERS_TIMER_FRAMES };
  179. NJS_SPRITE HUD_SPRITE_NUMBERS_RING_ANIM = { { 0.0f, 0.0f, 0.0f }, 1.0f, 1.0f, 0, &HUD_TEXLIST, HUD_TEXANIM_NUMBERS_RING_ANIM };
  180. NJS_SPRITE HUD_SPRITE_NUMBERS_RINGS = { { 0.0f, 0.0f, 0.0f }, 1.3f, 1.3f, 0, &HUD_TEXLIST, HUD_TEXANIM_NUMBERS_RINGS };
  181. NJS_SPRITE HUD_SPRITE_NUMBERS_RINGS_0_RED = { { 0.0f, 0.0f, 0.0f }, 1.0f, 1.0f, 0, &HUD_TEXLIST, HUD_TEXANIM_NUMBERS_RINGS_0_RED };
  182. NJS_SPRITE HUD_SPRITE_NUMBERS_LIVES = { { 0.0f, 0.0f, 0.0f }, 1.3f, 1.3f, 0, &HUD_TEXLIST, HUD_TEXANIM_NUMBERS_LIVES };
  183.  
  184.  
  185.  
  186.  
  187.  
  188. //Score counter HUD
  189. void HudDisplayScoreSTH06(signed int scoreCount, unsigned __int8 digits, NJS_SPRITE *hud_S)
  190. {
  191. int count_S; // edi
  192. int i_S; // ecx
  193. int max_S; // eax MAPDST
  194.  
  195. count_S = scoreCount;
  196. //if (HideHud >= 0)
  197. //{
  198. if (scoreCount >= 1000000000)
  199. {
  200. count_S = 999999999;
  201. }
  202. i_S = digits;
  203. max_S = 1;
  204. if ((signed int)digits > 0)
  205. {
  206. do
  207. {
  208. max_S *= 10;
  209. --i_S;
  210. } while (i_S);
  211. }
  212. if (count_S > --max_S)
  213. {
  214. count_S = max_S;
  215. }
  216. if (digits >= 9u)
  217. {
  218. njDrawSprite2D_Queue(
  219. hud_S,
  220. count_S / 100000000,
  221. 22046.498,
  222. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  223. QueuedModelFlagsB_SomeTextureThing);
  224. hud_S->p.x = hud_S->p.x + 23.4;
  225. }
  226. if (digits >= 8u)
  227. {
  228. njDrawSprite2D_Queue(
  229. hud_S,
  230. count_S % 100000000 / 10000000,
  231. 22046.498,
  232. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  233. QueuedModelFlagsB_SomeTextureThing);
  234. hud_S->p.x = hud_S->p.x + 23.4;
  235. }
  236. if (digits >= 7u)
  237. {
  238. njDrawSprite2D_Queue(
  239. hud_S,
  240. count_S % 10000000 / 1000000,
  241. 22046.498,
  242. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  243. QueuedModelFlagsB_SomeTextureThing);
  244. hud_S->p.x = hud_S->p.x + 23.4;
  245. }
  246. if (digits >= 6u)
  247. {
  248. njDrawSprite2D_Queue(
  249. hud_S,
  250. count_S % 1000000 / 100000,
  251. 22046.498,
  252. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  253. QueuedModelFlagsB_SomeTextureThing);
  254. hud_S->p.x = hud_S->p.x + 23.4;
  255. }
  256. if (digits >= 5u)
  257. {
  258. njDrawSprite2D_Queue(
  259. hud_S,
  260. count_S % 100000 / 10000,
  261. 22046.498,
  262. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  263. QueuedModelFlagsB_SomeTextureThing);
  264. hud_S->p.x = hud_S->p.x + 23.4;
  265. }
  266. if (digits >= 4u)
  267. {
  268. njDrawSprite2D_Queue(
  269. hud_S,
  270. count_S % 10000 / 1000,
  271. 22046.498,
  272. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  273. QueuedModelFlagsB_SomeTextureThing);
  274. hud_S->p.x = hud_S->p.x + 23.4;
  275. }
  276. if (digits >= 3u)
  277. {
  278. njDrawSprite2D_Queue(
  279. hud_S,
  280. count_S % 1000 / 100,
  281. 22046.498,
  282. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  283. QueuedModelFlagsB_SomeTextureThing);
  284. hud_S->p.x = hud_S->p.x + 23.4;
  285. }
  286. if (digits >= 2u)
  287. {
  288. njDrawSprite2D_Queue(
  289. hud_S,
  290. count_S % 100 / 10,
  291. 22046.496,
  292. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  293. QueuedModelFlagsB_SomeTextureThing);
  294. hud_S->p.x = hud_S->p.x + 23.4;
  295. }
  296. if (digits >= 1u)
  297. {
  298. njDrawSprite2D_Queue(
  299. hud_S,
  300. count_S % 10,
  301. 22046.496,
  302. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  303. QueuedModelFlagsB_SomeTextureThing);
  304. }
  305. //}
  306. }
  307.  
  308.  
  309. //Timer Minutes counter HUD
  310. void HudDisplayMinutesSTH06(signed int minuteCount, unsigned __int8 digits, NJS_SPRITE *hud_TM)
  311. {
  312. int count_TM; // edi
  313. int i_TM; // ecx
  314. int max_TM; // eax MAPDST
  315.  
  316. count_TM = minuteCount;
  317. //if (HideHud >= 0)
  318. //{
  319. if (minuteCount >= 1000)
  320. {
  321. count_TM = 999;
  322. }
  323. i_TM = digits;
  324. max_TM = 1;
  325. if ((signed int)digits > 0)
  326. {
  327. do
  328. {
  329. max_TM *= 10;
  330. --i_TM;
  331. } while (i_TM);
  332. }
  333. if (count_TM > --max_TM)
  334. {
  335. count_TM = max_TM;
  336. }
  337. if (digits >= 3u)
  338. {
  339. njDrawSprite2D_Queue(
  340. hud_TM,
  341. count_TM % 1000 / 100,
  342. 22046.498,
  343. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  344. QueuedModelFlagsB_SomeTextureThing);
  345. hud_TM->p.x = hud_TM->p.x + 23.4;
  346. }
  347. if (digits >= 2u)
  348. {
  349. njDrawSprite2D_Queue(
  350. hud_TM,
  351. count_TM % 100 / 10,
  352. 22046.496,
  353. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  354. QueuedModelFlagsB_SomeTextureThing);
  355. hud_TM->p.x = hud_TM->p.x + 23.4;
  356. }
  357. if (digits >= 1u)
  358. {
  359. njDrawSprite2D_Queue(
  360. hud_TM,
  361. count_TM % 10,
  362. 22046.496,
  363. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  364. QueuedModelFlagsB_SomeTextureThing);
  365. }
  366. //}
  367. }
  368.  
  369.  
  370. //Timer Seconds counter HUD
  371. void HudDisplaySecondsSTH06(signed int secondCount, unsigned __int8 digits, NJS_SPRITE *hud_TS)
  372. {
  373. int count_TS; // edi
  374. int i_TS; // ecx
  375. int max_TS; // eax MAPDST
  376.  
  377. count_TS = secondCount;
  378. //if (HideHud >= 0)
  379. //{
  380. if (secondCount >= 1000)
  381. {
  382. count_TS = 999;
  383. }
  384. i_TS = digits;
  385. max_TS = 1;
  386. if ((signed int)digits > 0)
  387. {
  388. do
  389. {
  390. max_TS *= 10;
  391. --i_TS;
  392. } while (i_TS);
  393. }
  394. if (count_TS > --max_TS)
  395. {
  396. count_TS= max_TS;
  397. }
  398. if (digits >= 3u)
  399. {
  400. njDrawSprite2D_Queue(
  401. hud_TS,
  402. count_TS % 1000 / 100,
  403. 22046.498,
  404. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  405. QueuedModelFlagsB_SomeTextureThing);
  406. hud_TS->p.x = hud_TS->p.x + 23.4;
  407. }
  408. if (digits >= 2u)
  409. {
  410. njDrawSprite2D_Queue(
  411. hud_TS,
  412. count_TS % 100 / 10,
  413. 22046.496,
  414. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  415. QueuedModelFlagsB_SomeTextureThing);
  416. hud_TS->p.x = hud_TS->p.x + 23.4;
  417. }
  418. if (digits >= 1u)
  419. {
  420. njDrawSprite2D_Queue(
  421. hud_TS,
  422. count_TS % 10,
  423. 22046.496,
  424. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  425. QueuedModelFlagsB_SomeTextureThing);
  426. }
  427. //}
  428. }
  429.  
  430.  
  431. //Timer Frames counter HUD
  432. void HudDisplayFramesSTH06(signed int frameCount, unsigned __int8 digits, NJS_SPRITE *hud_TF)
  433. {
  434. int count_TF; // edi
  435. int i_TF; // ecx
  436. int max_TF; // eax MAPDST
  437.  
  438. count_TF = 16.666 * frameCount;
  439. //if (HideHud >= 0)
  440. //{
  441. if (frameCount >= 10000)
  442. {
  443. count_TF = 9999;
  444. }
  445. i_TF = digits;
  446. max_TF = 1;
  447. if ((signed int)digits > 0)
  448. {
  449. do
  450. {
  451. max_TF *= 10;
  452. --i_TF;
  453. } while (i_TF);
  454. }
  455. if (count_TF > --max_TF)
  456. {
  457. count_TF = max_TF;
  458. }
  459. if (digits >= 3u)
  460. {
  461. njDrawSprite2D_Queue(
  462. hud_TF,
  463. count_TF / 100,
  464. 22046.496,
  465. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  466. QueuedModelFlagsB_SomeTextureThing);
  467. hud_TF->p.x = hud_TF->p.x + 23.4;
  468. }
  469. if (digits >= 2u)
  470. {
  471. njDrawSprite2D_Queue(
  472. hud_TF,
  473. count_TF % 100 / 10,
  474. 22046.496,
  475. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  476. QueuedModelFlagsB_SomeTextureThing);
  477. hud_TF->p.x = hud_TF->p.x + 23.4;
  478. }
  479. if (digits >= 1u)
  480. {
  481. njDrawSprite2D_Queue(
  482. hud_TF,
  483. count_TF % 10,
  484. 22046.496,
  485. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  486. QueuedModelFlagsB_SomeTextureThing);
  487. }
  488. //}
  489. }
  490.  
  491.  
  492. //Ring counter HUD
  493. void HudDisplayRingsSTH06(signed int ringCount, unsigned __int8 digits, NJS_SPRITE *hud_R)
  494. {
  495. int count_R; // edi
  496. int i_R; // ecx
  497. int max_R; // eax MAPDST
  498.  
  499. count_R = ringCount;
  500. //if (HideHud >= 0)
  501. //{
  502. if (ringCount >= 100000)
  503. {
  504. count_R = 99999;
  505. }
  506. i_R = digits;
  507. max_R = 1;
  508. if ((signed int)digits > 0)
  509. {
  510. do
  511. {
  512. max_R *= 10;
  513. --i_R;
  514. } while (i_R);
  515. }
  516. if (count_R > --max_R)
  517. {
  518. count_R = max_R;
  519. }
  520. if (digits >= 5u)
  521. {
  522. njDrawSprite2D_Queue(
  523. hud_R,
  524. count_R / 10000,
  525. 22046.5,
  526. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  527. QueuedModelFlagsB_SomeTextureThing);
  528. hud_R->p.x = hud_R->p.x + 23.4;
  529. }
  530. if (digits >= 4u)
  531. {
  532. njDrawSprite2D_Queue(
  533. hud_R,
  534. count_R % 10000 / 1000,
  535. 22046.498,
  536. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  537. QueuedModelFlagsB_SomeTextureThing);
  538. hud_R->p.x = hud_R->p.x + 23.4;
  539. }
  540. if (digits >= 3u)
  541. {
  542. njDrawSprite2D_Queue(
  543. hud_R,
  544. count_R % 1000 / 100,
  545. 22046.498,
  546. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  547. QueuedModelFlagsB_SomeTextureThing);
  548. hud_R->p.x = hud_R->p.x + 23.4;
  549. }
  550. if (digits >= 2u)
  551. {
  552. njDrawSprite2D_Queue(
  553. hud_R,
  554. count_R % 100 / 10,
  555. 22046.496,
  556. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  557. QueuedModelFlagsB_SomeTextureThing);
  558. hud_R->p.x = hud_R->p.x + 23.4;
  559. }
  560. if (digits >= 1u)
  561. {
  562. njDrawSprite2D_Queue(
  563. hud_R,
  564. count_R % 10,
  565. 22046.496,
  566. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  567. QueuedModelFlagsB_SomeTextureThing);
  568. }
  569. //}
  570. }
  571.  
  572.  
  573. //Life counter HUD
  574. void HudDisplayLivesSTH06(signed int lifeCount, unsigned __int8 digits, NJS_SPRITE *hud_L)
  575. {
  576. int count_L; // edi
  577. int i_L; // ecx
  578. int max_L; // eax MAPDST
  579.  
  580. count_L = lifeCount;
  581. //if (HideHud >= 0)
  582. //{
  583. if (lifeCount >= 1000)
  584. {
  585. count_L = 999;
  586. }
  587. i_L = digits;
  588. max_L = 1;
  589. if ((signed int)digits > 0)
  590. {
  591. do
  592. {
  593. max_L *= 10;
  594. --i_L;
  595. } while (i_L);
  596. }
  597. if (count_L > --max_L)
  598. {
  599. count_L = max_L;
  600. }
  601. if (digits >= 3u)
  602. {
  603. njDrawSprite2D_Queue(
  604. hud_L,
  605. count_L % 1000 / 100,
  606. 22046.498,
  607. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  608. QueuedModelFlagsB_SomeTextureThing);
  609. hud_L->p.x = hud_L->p.x + 23.4;
  610. }
  611. if (digits >= 2u)
  612. {
  613. njDrawSprite2D_Queue(
  614. hud_L,
  615. count_L % 100 / 10,
  616. 22046.496,
  617. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  618. QueuedModelFlagsB_SomeTextureThing);
  619. hud_L->p.x = hud_L->p.x + 23.4;
  620. }
  621. if (digits >= 1u)
  622. {
  623. njDrawSprite2D_Queue(
  624. hud_L,
  625. count_L % 10,
  626. 22046.496,
  627. NJD_SPRITE_ALPHA | NJD_SPRITE_COLOR,
  628. QueuedModelFlagsB_SomeTextureThing);
  629. }
  630. //}
  631. }
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640. void MyHudThing()
  641. {
  642. //HUD
  643. if (GameState != 21)
  644. {
  645. if (GetCharacterObject(0))
  646. {
  647. //HudDisplayRingsSTH06(Rings, 3, &hud_sprite);
  648. njDrawSprite2D_Queue(&HUD_SPRITE, HUD_score, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  649. njDrawSprite2D_Queue(&HUD_SPRITE, HUD_timer, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  650. njDrawSprite2D_Queue(&HUD_SPRITE, HUD_rings, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  651. njDrawSprite2D_Queue(&HUD_SPRITE, HUD_lives, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  652. if (GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  653. {
  654. njDrawSprite2D_Queue(&HUD_SPRITE, HUD_gauge, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  655. njDrawSprite2D_Queue(&HUD_SPRITE, HUD_sonic_life, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  656. }
  657. else if (GetCharacterID(0) == Characters_Tails) njDrawSprite2D_Queue(&HUD_SPRITE, HUD_tails_life, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  658. else if (GetCharacterID(0) == Characters_Knuckles) njDrawSprite2D_Queue(&HUD_SPRITE, HUD_knuckles_life, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  659. else if (GetCharacterID(0) == Characters_Amy) njDrawSprite2D_Queue(&HUD_SPRITE, HUD_amy_life, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  660. else if (GetCharacterID(0) == Characters_Gamma) njDrawSprite2D_Queue(&HUD_SPRITE, HUD_gamma_life, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  661. HUD_SPRITE_NUMBERS_RINGS.p.x = 0;
  662. HUD_SPRITE_NUMBERS_RINGS.p.y = 0;
  663. HUD_SPRITE_NUMBERS_RINGS_0_RED.p.x = HUD_SPRITE_NUMBERS_RINGS.p.x;
  664. HUD_SPRITE_NUMBERS_RINGS_0_RED.p.y = HUD_SPRITE_NUMBERS_RINGS.p.y;
  665. HUD_SPRITE_NUMBERS_TIMER_MINUTES.p.x = -34;
  666. HUD_SPRITE_NUMBERS_TIMER_MINUTES.p.y = -65;
  667. HUD_SPRITE_NUMBERS_TIMER_SECONDS.p.x = HUD_SPRITE_NUMBERS_TIMER_MINUTES.p.x + 69;
  668. HUD_SPRITE_NUMBERS_TIMER_SECONDS.p.y = HUD_SPRITE_NUMBERS_TIMER_MINUTES.p.y;
  669. HUD_SPRITE_NUMBERS_TIMER_FRAMES.p.x = HUD_SPRITE_NUMBERS_TIMER_SECONDS.p.x + 71;
  670. HUD_SPRITE_NUMBERS_TIMER_FRAMES.p.y = HUD_SPRITE_NUMBERS_TIMER_MINUTES.p.y;
  671. HUD_SPRITE_NUMBERS_LIVES.p.y = 65;
  672. HUD_SPRITE_NUMBERS_SCORE.p.y = -133;
  673.  
  674. //Ring Counter
  675. if (Rings == 0)
  676. {
  677. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RINGS_0_RED, 0, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  678. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RINGS_0_RED, 1, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  679. }
  680. else if (Rings > 0 && Rings < 1000)
  681. {
  682. HudDisplayRingsSTH06(Rings, 3, &HUD_SPRITE_NUMBERS_RINGS);
  683. }
  684. else if (Rings >= 1000)
  685. {
  686. HudDisplayRingsSTH06(Rings, 4, &HUD_SPRITE_NUMBERS_RINGS);
  687. }
  688.  
  689. //Ring image animation
  690. //if (GameState == 4)
  691. //{
  692. // OldRingsHUD = Rings;
  693. // can_animate = 0;
  694. //}
  695. //if (GameState == 15 || GameState == 16)
  696. //{
  697. if (GetCharacterObject(0))
  698. {
  699. if (Rings - OldRingsHUD > 0)
  700. {
  701. can_animate_loss = 0;
  702. ++can_animate_gain;
  703. if (can_animate_gain == 1)
  704. {
  705. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 1, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  706. }
  707. else if (can_animate_gain == 2)
  708. {
  709. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 2, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  710. }
  711. else if (can_animate_gain == 3)
  712. {
  713. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 3, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  714. }
  715. else if (can_animate_gain == 4)
  716. {
  717. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 4, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  718. }
  719. else if (can_animate_gain == 5)
  720. {
  721. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 5, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  722. }
  723. else if (can_animate_gain == 6)
  724. {
  725. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 6, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  726. }
  727. else if (can_animate_gain == 7)
  728. {
  729. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 7, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  730. OldRingsHUD = Rings;
  731. can_animate_gain = 0;
  732. }
  733. }
  734. else if (Rings - OldRingsHUD < 0)
  735. {
  736. can_animate_gain = 0;
  737. ++can_animate_loss;
  738. if (can_animate_loss == 1)
  739. {
  740. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 7, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  741. }
  742. else if (can_animate_loss == 2)
  743. {
  744. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 6, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  745. }
  746. else if (can_animate_loss == 3)
  747. {
  748. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 5, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  749. }
  750. else if (can_animate_loss == 4)
  751. {
  752. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 4, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  753. }
  754. else if (can_animate_loss == 5)
  755. {
  756. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 3, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  757. }
  758. else if (can_animate_loss == 6)
  759. {
  760. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 2, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  761. }
  762. else if (can_animate_loss == 7)
  763. {
  764. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 1, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  765. OldRingsHUD = Rings;
  766. can_animate_loss = 0;
  767. }
  768. }
  769. else if (OldRingsHUD == Rings)
  770. {
  771. njDrawSprite2D_Queue(&HUD_SPRITE_NUMBERS_RING_ANIM, 0, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  772. }
  773. }
  774. //}
  775.  
  776. //Lives Counter
  777. if (Lives < 10)
  778. {
  779. HUD_SPRITE_NUMBERS_LIVES.p.x = 48.8;
  780. HudDisplayLivesSTH06(Lives, 1, &HUD_SPRITE_NUMBERS_LIVES);
  781. }
  782. else if (Lives >= 10)
  783. {
  784. HUD_SPRITE_NUMBERS_LIVES.p.x = 25.4;
  785. HudDisplayLivesSTH06(Lives, 2, &HUD_SPRITE_NUMBERS_LIVES);
  786. }
  787.  
  788. //Timer Minutes
  789. HudDisplayMinutesSTH06(TimeMinutes, 2, &HUD_SPRITE_NUMBERS_TIMER_MINUTES);
  790.  
  791. //Timer Minutes
  792. HudDisplaySecondsSTH06(TimeSeconds, 2, &HUD_SPRITE_NUMBERS_TIMER_SECONDS);
  793.  
  794. //Score Counter
  795. HudDisplayFramesSTH06(TimeFrames, 3, &HUD_SPRITE_NUMBERS_TIMER_FRAMES);
  796. if (EnemyBonus < 10)
  797. {
  798. HUD_SPRITE_NUMBERS_SCORE.p.x = 153;
  799. HudDisplayScoreSTH06(EnemyBonus, 1, &HUD_SPRITE_NUMBERS_SCORE);
  800. }
  801. else if (EnemyBonus >= 10 && EnemyBonus < 100)
  802. {
  803. HUD_SPRITE_NUMBERS_SCORE.p.x = 129.6;
  804. HudDisplayScoreSTH06(EnemyBonus, 2, &HUD_SPRITE_NUMBERS_SCORE);
  805. }
  806. else if (EnemyBonus >= 100 && EnemyBonus < 1000)
  807. {
  808. HUD_SPRITE_NUMBERS_SCORE.p.x = 106.2;
  809. HudDisplayScoreSTH06(EnemyBonus, 3, &HUD_SPRITE_NUMBERS_SCORE);
  810. }
  811. else if (EnemyBonus >= 1000 && EnemyBonus < 10000)
  812. {
  813. HUD_SPRITE_NUMBERS_SCORE.p.x = 82.8;
  814. HudDisplayScoreSTH06(EnemyBonus, 4, &HUD_SPRITE_NUMBERS_SCORE);
  815. }
  816. else if (EnemyBonus >= 10000 && EnemyBonus < 100000)
  817. {
  818. HUD_SPRITE_NUMBERS_SCORE.p.x = 59.4;
  819. HudDisplayScoreSTH06(EnemyBonus, 5, &HUD_SPRITE_NUMBERS_SCORE);
  820. }
  821. else if (EnemyBonus >= 100000 && EnemyBonus < 1000000)
  822. {
  823. HUD_SPRITE_NUMBERS_SCORE.p.x = 36;
  824. HudDisplayScoreSTH06(EnemyBonus, 6, &HUD_SPRITE_NUMBERS_SCORE);
  825. }
  826. else if (EnemyBonus >= 1000000 && EnemyBonus < 10000000)
  827. {
  828. HUD_SPRITE_NUMBERS_SCORE.p.x = 12.6;
  829. HudDisplayScoreSTH06(EnemyBonus, 7, &HUD_SPRITE_NUMBERS_SCORE);
  830. }
  831. else if (EnemyBonus >= 10000000 && EnemyBonus < 100000000)
  832. {
  833. HUD_SPRITE_NUMBERS_SCORE.p.x = -10.8;
  834. HudDisplayScoreSTH06(EnemyBonus, 8, &HUD_SPRITE_NUMBERS_SCORE);
  835. }
  836. else
  837. {
  838. HUD_SPRITE_NUMBERS_SCORE.p.x = -34.2;
  839. HudDisplayScoreSTH06(EnemyBonus, 9, &HUD_SPRITE_NUMBERS_SCORE);
  840. }
  841. }
  842. }
  843.  
  844. //Character Select HUD
  845. if (GameState == 21)
  846. {
  847. if (GetCharacterObject(0))
  848. {
  849. LoadPVM("HUD", &HUD_TEXLIST);// do better loading (not have it repeat)
  850. //njDrawSprite2D_Queue(&HUD_SPRITE2, char_sel_sonic, -1, NJD_SPRITE_ALPHA, (QueuedModelFlagsB)0);
  851. }
  852. }
  853. }
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  865.  
  866. extern "C"
  867. {
  868. __declspec(dllexport) ModInfo SADXModInfo = { ModLoaderVer };
  869.  
  870.  
  871. __declspec(dllexport) void Init(const char *path, const HelperFunctions &helperFunctions)
  872. {
  873. Sonic_Init(path, helperFunctions);
  874. Miscellaneous_Init(path, helperFunctions);
  875. WriteJump((void*)0x425F90, MyHudThing);
  876. WriteData((char*)0x427F50, (char)0xC3);
  877. }
  878.  
  879.  
  880. etc
  881.  
  882.  
  883. etc
  884.  
  885.  
  886.  
  887. etc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement