暫無描述

custom_specials.c 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. extern void sp_batchmaptile(void);
  59. void get_text_pointer_from_lookup();
  60. void sp_check_tileset();
  61. /* === STATICS === */
  62. static callback special_routines[8] = {
  63. met_play,
  64. cam_sp_move_camera,
  65. sp_init_script,
  66. debug_some_test,
  67. sp_dns_switch,
  68. sp_random_number,
  69. sp_check_tileset,
  70. sp_batchmaptile
  71. };
  72. /* === IMPLEMENTATIONS === */
  73. void sp_dns_switch()
  74. {
  75. volatile u8* test_pointer = (u8*) (0x0203FAB0);
  76. *(test_pointer+1) = (*(test_pointer+1) == 3 ? 0 : (*(test_pointer+1)) + 1);
  77. *test_pointer = 1;
  78. }
  79. void sp_init_script()
  80. {
  81. for(u16 i = 0x1000; i < 0x1800; ++i)
  82. {
  83. flag_clear(i);
  84. }
  85. }
  86. void sp_special_casm() //special 0x68
  87. {
  88. u16* var_special = var_access(CALLASM_VAR);
  89. special_routines[*var_special]();
  90. }
  91. void sp_clear_variables()
  92. {
  93. (void) var_set(MUGHSOT_1_TABLE, 0);
  94. (void) var_set(MUGHSOT_2_TABLE, 0);
  95. (void) var_set(MUGSHOT_1_X, 0);
  96. (void) var_set(MUGSHOT_2_X, 0);
  97. (void) var_set(MUGSHOT_1_Y, 0);
  98. (void) var_set(MUGSHOT_2_Y, 0);
  99. (void) var_set(TEXT_VAR, 0);
  100. return;
  101. }
  102. void sp_random_number()
  103. {
  104. var_set(0x800D, (random() % var_get(0x8000)));
  105. }