No Description

load_text_special.c 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /****************************************************************************
  2. * Copyright (C) 2015-2016 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 load_text_special.c
  24. * @author Sturmvogel
  25. * @date 05 Jan 2016
  26. * @brief special 0x69 0x6A
  27. *
  28. * Implements a new way to load text for more language compatability and code
  29. * interchangability.
  30. */
  31. /* === INCLUDE === */
  32. #include <types.h>
  33. #include <game_engine.h>
  34. #include <config/core.h>
  35. #include <save_one.h>
  36. /* === PROTOTYPES === */
  37. /**
  38. * @brief load text according to bank, map and text_id
  39. */
  40. void sp_load_text_map();
  41. /**
  42. * @brief load text according to bank, map, person id and text_id
  43. */
  44. void sp_load_text_person();
  45. /* === GLOBALS === */
  46. char* str_invalid_text_ref;
  47. char***** text_lookup_table;
  48. void** loadpointer = (void**)((0x03000EB0 + 0x64));
  49. /* === IMPLEMENTATIONS === */
  50. void sp_load_text_map()
  51. {
  52. u8 bank = sav_one->location.bank;
  53. u8 map = sav_one->location.map;
  54. for(int i = 0; i<=bank;++i)
  55. {
  56. if(text_lookup_table[i] == (char****)(0xDEADBEEF))
  57. {
  58. *loadpointer =str_invalid_text_ref;
  59. return;
  60. }
  61. }
  62. for(int i = 0; i<=map; ++i)
  63. {
  64. if(text_lookup_table[bank][i] == (char***)(0xDEADBEEF))
  65. {
  66. *loadpointer = str_invalid_text_ref;
  67. return;
  68. }
  69. }
  70. if(text_lookup_table[bank][map][0] == (char**)(0xDEADBEEF))
  71. {
  72. *loadpointer = str_invalid_text_ref;
  73. return;
  74. }
  75. u16 text_id = var_get(0x500C);
  76. for(int i = 0; i<= text_id; ++i)
  77. {
  78. if(text_lookup_table[bank][map][0][i] == (char*)(0xDEADBEEF))
  79. {
  80. *loadpointer = str_invalid_text_ref;
  81. return;
  82. }
  83. }
  84. *loadpointer = text_lookup_table[bank][map][0][text_id];
  85. return;
  86. }
  87. void sp_load_text_person()
  88. {
  89. u8 bank = sav_one->location.bank;
  90. u8 map = sav_one->location.map;
  91. for(int i = 0; i<= bank; ++i)
  92. {
  93. if(text_lookup_table[i] == (char****)(0xDEADBEEF))
  94. {
  95. *loadpointer = str_invalid_text_ref;
  96. return;
  97. }
  98. }
  99. for(int i = 0; i<= map; ++i)
  100. {
  101. if(text_lookup_table[bank][i] == (char***) (0xDEADBEEF))
  102. {
  103. *loadpointer = str_invalid_text_ref;
  104. return;
  105. }
  106. }
  107. u16 person_id = var_get(0x800F); // LASTTALKED
  108. for(int i = 0; i<= person_id; ++i)
  109. {
  110. if(text_lookup_table[bank][map][i] == (char**) (0xDEADBEEF))
  111. {
  112. *loadpointer = str_invalid_text_ref;
  113. return;
  114. }
  115. }
  116. u16 text_id = var_get(0x500C); //TEXT_VAR
  117. for(int i = 0; i<= text_id; ++i)
  118. {
  119. if(text_lookup_table[bank][map][person_id][i] == (char*) (0xDEADBEEF))
  120. {
  121. *loadpointer = str_invalid_text_ref;
  122. return;
  123. }
  124. }
  125. *loadpointer = text_lookup_table[bank][map][person_id][text_id];
  126. return;
  127. }