Sin descripción

custom_specials.c 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 "cutscene_meteor.h"
  31. #include "camera_move.h"
  32. #include <callback.h>
  33. #include <debug.h>
  34. #include <game_engine.h>
  35. #include <config.h>
  36. #include <math.h>
  37. /* === PROTOTYPES === */
  38. /**
  39. * @brief test routine to switch dns
  40. */
  41. void sp_dns_switch();
  42. /**
  43. * @brief clear some flags at the beginning of the game
  44. */
  45. void sp_init_script();
  46. /**
  47. * @brief callasm to call a var-based routine as defined
  48. */
  49. void sp_special_casm();
  50. /**
  51. * @brief clears some variables at the end of a script
  52. */
  53. void sp_clear_variables();
  54. /**
  55. * @brief generate a random number, store in last result
  56. */
  57. void sp_random_number();
  58. void get_text_pointer_from_lookup();
  59. /* === STATICS === */
  60. static callback special_routines[7] = {
  61. met_play,
  62. cam_sp_move_camera,
  63. sp_init_script,
  64. debug_some_test,
  65. sp_dns_switch,
  66. sp_random_number,
  67. };
  68. /* === IMPLEMENTATIONS === */
  69. void sp_dns_switch()
  70. {
  71. volatile u8* test_pointer = (u8*) (0x0203FAB0);
  72. *(test_pointer+1) = (*(test_pointer+1) == 3 ? 0 : (*(test_pointer+1)) + 1);
  73. *test_pointer = 1;
  74. }
  75. void sp_init_script()
  76. {
  77. for(u16 i = 0x1000; i < 0x1800; ++i)
  78. {
  79. flag_clear(i);
  80. }
  81. }
  82. void sp_special_casm() //special 0x68
  83. {
  84. u16* var_special = var_access(CALLASM_VAR);
  85. special_routines[*var_special]();
  86. }
  87. void sp_clear_variables()
  88. {
  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()
  99. {
  100. var_set(0x800D, (__aeabi_uidivmod(random(), var_get(0x8000))));
  101. }