No Description

custom_specials.c 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /****************************************************************************
  2. * Copyright (C) 2015-2017 by the SotS Team *
  3. * *
  4. * This file is part of Sovereign of the Skies. *
  5. * *
  6. * Sovereign of the Skies is free software: you can redistribute it *
  7. * and/or modify it *
  8. * under the terms of the GNU Lesser General Public License as published *
  9. * by the Free Software Foundation, either version 3 of the License, or *
  10. * (at your option) any later version provided you include a copy of the *
  11. * licence and this header. *
  12. * *
  13. * Sovereign of the Skies is distributed in the hope that it will be *
  14. * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of *
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  16. * GNU Lesser General Public License for more details. *
  17. * *
  18. * You should have received a copy of the GNU Lesser General Public *
  19. * License along with Sovereign of the Skies. *
  20. * If not, see <http://www.gnu.org/licenses/>. *
  21. ****************************************************************************/
  22. /**
  23. * @file custom_specials.c
  24. * @author Sturmvogel
  25. * @date 15 dec 2016
  26. * @brief Special 0x68 implementation to read from LASTRESULT and execute
  27. *
  28. */
  29. /* === INCLUDES === */
  30. #include "camera_move.h"
  31. //#include "cutscene_meteor.h"
  32. #include <config/core.h>
  33. #include <pokeagb/pokeagb.h>
  34. /* === TYPES === */
  35. typedef void (*special_func)();
  36. /* === PROTOTYPES === */
  37. /**
  38. * @brief test routine to switch dns
  39. */
  40. void sp_dns_switch();
  41. /**
  42. * @brief clear some flags at the beginning of the game
  43. */
  44. void sp_init_script();
  45. /**
  46. * @brief callasm to call a var-based routine as defined
  47. */
  48. void sp_special_casm();
  49. /**
  50. * @brief clears some variables at the end of a script
  51. */
  52. void sp_clear_variables();
  53. /**
  54. * @brief generate a random number, store in last result
  55. */
  56. void sp_random_number();
  57. extern void sp_batchmaptile(void);
  58. void get_text_pointer_from_lookup();
  59. void sp_check_tileset();
  60. void sp_set_rival(void);
  61. extern void sp_crystal_fade(void);
  62. extern pchar name_rival_male[5];
  63. extern pchar name_rival_female[5];
  64. /* === STATICS === */
  65. static special_func special_routines[10] = {
  66. NULL, cam_sp_move_camera, sp_init_script, NULL, NULL,
  67. sp_random_number, sp_check_tileset, sp_batchmaptile, sp_crystal_fade, sp_set_rival,
  68. };
  69. /* === IMPLEMENTATIONS === */
  70. void sp_set_rival(void) {
  71. if (saveblock2->gender == GENDER_MALE) {
  72. pstrcpy(&(saveblock1->rival_name[0]), &name_rival_female[0]);
  73. } else {
  74. pstrcpy(&(saveblock1->rival_name[0]), &name_rival_male[0]);
  75. }
  76. }
  77. void sp_init_script() {
  78. for (u16 i = 0x1000; i < 0x1800; ++i)
  79. flag_clear(i);
  80. for (u16 i = 0x5000; i <= 0x5100; ++i)
  81. var_set(i, 0);
  82. }
  83. void sp_special_casm() // special 0x68
  84. {
  85. u16 *var_special = var_access(CALLASM_VAR);
  86. special_routines[*var_special]();
  87. }
  88. void sp_clear_variables() {
  89. (void)var_set(MUGHSOT_1_TABLE, 0);
  90. (void)var_set(MUGHSOT_2_TABLE, 0);
  91. (void)var_set(MUGSHOT_1_X, 0);
  92. (void)var_set(MUGSHOT_2_X, 0);
  93. (void)var_set(MUGSHOT_1_Y, 0);
  94. (void)var_set(MUGSHOT_2_Y, 0);
  95. (void)var_set(TEXT_VAR, 0);
  96. return;
  97. }
  98. void sp_random_number() { var_set(0x800D, (rand() % var_load(0x8000))); }