GameBoy (Color) port of the GTA San Andreas arcade game Duality
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sprite_data.c 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /*
  2. * sprite_data.c
  3. * Duality
  4. *
  5. * Copyright (C) 2025 Thomas Buck <thomas@xythobuz.de>
  6. *
  7. * Based on examples from gbdk-2020:
  8. * https://github.com/gbdk-2020/gbdk-2020/blob/develop/gbdk-lib/examples/cross-platform/metasprites/src/metasprites.c
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * See <http://www.gnu.org/licenses/>.
  21. */
  22. #include "sprite_data.h"
  23. #include "rockshp_spr24.h"
  24. #include "light.h"
  25. #include "dark.h"
  26. #include "shoot.h"
  27. #include "bar_spr8.h"
  28. #include "expl_spr16.h"
  29. #include "pause.h"
  30. #include "status_spr8.h"
  31. #include "debug_marker.h"
  32. #include "debug_marker_spr32.h"
  33. BANKREF(power_palettes)
  34. /*
  35. * OCP0: Rocketship (1)
  36. * OCP1: Rocketship (2)
  37. * OCP2: Light
  38. * OCP3: Dark
  39. * OCP4: Shot
  40. * OCP5: Health
  41. * OCP6: Power
  42. * OCP7: Pause
  43. *
  44. * Explosion uses OCP0 to OCP3 at end of game.
  45. * Pause is flipped in-place for animating the pause screen colors.
  46. */
  47. const palette_color_t power_palettes[4] = {
  48. //RGB8( 0, 0, 0), RGB8(240, 0, 0), RGB8(196, 0, 0), RGB8(116, 0, 0)
  49. RGB8( 0, 0, 0), RGB8( 0,240, 0), RGB8( 0,196, 0), RGB8( 0,116, 0)
  50. };
  51. struct sprites metasprites[SPRITE_COUNT] = {
  52. { // SPR_SHIP
  53. .ms = rockshp_spr24_metasprites,
  54. .ms_n = ARR_LEN(rockshp_spr24_metasprites),
  55. .ti = rockshp_spr24_tiles,
  56. .pa = rockshp_spr24_palettes,
  57. .pa_n = rockshp_spr24_PALETTE_COUNT,
  58. .pa_i = OAMF_CGB_PAL0,
  59. .cnt = rockshp_spr24_TILE_COUNT,
  60. .off = TILE_NUM_START,
  61. .bank = BANK(rockshp_spr24),
  62. },
  63. { // SPR_LIGHT
  64. .ms = light_metasprites,
  65. .ms_n = ARR_LEN(light_metasprites),
  66. .ti = light_tiles,
  67. .pa = light_palettes,
  68. .pa_n = light_PALETTE_COUNT,
  69. .pa_i = OAMF_CGB_PAL2,
  70. .cnt = light_TILE_COUNT,
  71. .off = TILE_NUM_START,
  72. .bank = BANK(light),
  73. },
  74. { // SPR_DARK
  75. .ms = dark_metasprites,
  76. .ms_n = ARR_LEN(dark_metasprites),
  77. .ti = dark_tiles,
  78. .pa = dark_palettes,
  79. .pa_n = dark_PALETTE_COUNT,
  80. .pa_i = OAMF_CGB_PAL3,
  81. .cnt = dark_TILE_COUNT,
  82. .off = TILE_NUM_START,
  83. .bank = BANK(dark),
  84. },
  85. { // SPR_SHOT
  86. .ms = shoot_metasprites,
  87. .ms_n = ARR_LEN(shoot_metasprites),
  88. .ti = shoot_tiles,
  89. .pa = shoot_palettes,
  90. .pa_n = shoot_PALETTE_COUNT,
  91. .pa_i = OAMF_CGB_PAL4,
  92. .cnt = shoot_TILE_COUNT,
  93. .off = TILE_NUM_START,
  94. .bank = BANK(shoot),
  95. },
  96. { // SPR_SHOT_LIGHT
  97. .ms = shoot_metasprites,
  98. .ms_n = ARR_LEN(shoot_metasprites),
  99. .ti = shoot_tiles,
  100. .pa = NULL,
  101. .pa_n = shoot_PALETTE_COUNT,
  102. .pa_i = OAMF_CGB_PAL2,
  103. .cnt = shoot_TILE_COUNT,
  104. .off = SPR_SHOT,
  105. .bank = BANK(shoot),
  106. },
  107. { // SPR_SHOT_DARK
  108. .ms = shoot_metasprites,
  109. .ms_n = ARR_LEN(shoot_metasprites),
  110. .ti = shoot_tiles,
  111. .pa = NULL,
  112. .pa_n = shoot_PALETTE_COUNT,
  113. .pa_i = OAMF_CGB_PAL3,
  114. .cnt = shoot_TILE_COUNT,
  115. .off = SPR_SHOT,
  116. .bank = BANK(shoot),
  117. },
  118. { // SPR_HEALTH
  119. .ms = bar_spr8_metasprites,
  120. .ms_n = ARR_LEN(bar_spr8_metasprites),
  121. .ti = bar_spr8_tiles,
  122. .pa = bar_spr8_palettes,
  123. .pa_n = bar_spr8_PALETTE_COUNT,
  124. .pa_i = OAMF_CGB_PAL5,
  125. .cnt = bar_spr8_TILE_COUNT,
  126. .off = TILE_NUM_START,
  127. .bank = BANK(bar_spr8),
  128. },
  129. { // SPR_POWER
  130. .ms = bar_spr8_metasprites,
  131. .ms_n = ARR_LEN(bar_spr8_metasprites),
  132. .ti = bar_spr8_tiles,
  133. .pa = power_palettes,
  134. .pa_n = bar_spr8_PALETTE_COUNT,
  135. .pa_i = OAMF_CGB_PAL6,
  136. .cnt = bar_spr8_TILE_COUNT,
  137. .off = SPR_HEALTH,
  138. .bank = BANK(bar_spr8),
  139. },
  140. { // SPR_EXPL
  141. .ms = expl_spr16_metasprites,
  142. .ms_n = ARR_LEN(expl_spr16_metasprites),
  143. .ti = expl_spr16_tiles,
  144. .pa = expl_spr16_palettes,
  145. .pa_n = expl_spr16_PALETTE_COUNT,
  146. .pa_i = OAMF_CGB_PAL7 | PALETTE_DYNAMIC_LOAD_IP,
  147. .cnt = expl_spr16_TILE_COUNT,
  148. .off = TILE_NUM_START,
  149. .bank = BANK(expl_spr16),
  150. },
  151. { // SPR_PAUSE
  152. .ms = pause_metasprites,
  153. .ms_n = ARR_LEN(pause_metasprites),
  154. .ti = pause_tiles,
  155. .pa = pause_palettes,
  156. .pa_n = pause_PALETTE_COUNT,
  157. .pa_i = OAMF_CGB_PAL7 | PALETTE_DYNAMIC_LOAD_IP,
  158. .cnt = pause_TILE_COUNT,
  159. .off = TILE_NUM_START,
  160. .bank = BANK(pause),
  161. },
  162. { // SPR_STATUS_HEALTH
  163. .ms = status_spr8_metasprites,
  164. .ms_n = ARR_LEN(status_spr8_metasprites),
  165. .ti = status_spr8_tiles,
  166. .pa = NULL,
  167. .pa_n = status_spr8_PALETTE_COUNT,
  168. .pa_i = OAMF_CGB_PAL5,
  169. .cnt = status_spr8_TILE_COUNT,
  170. .off = TILE_NUM_START,
  171. .bank = BANK(status_spr8),
  172. },
  173. { // SPR_STATUS_POWER
  174. .ms = status_spr8_metasprites,
  175. .ms_n = ARR_LEN(status_spr8_metasprites),
  176. .ti = status_spr8_tiles,
  177. .pa = NULL,
  178. .pa_n = status_spr8_PALETTE_COUNT,
  179. .pa_i = OAMF_CGB_PAL6,
  180. .cnt = status_spr8_TILE_COUNT,
  181. .off = SPR_STATUS_HEALTH,
  182. .bank = BANK(status_spr8),
  183. },
  184. { // SPR_DEBUG
  185. .ms = debug_marker_metasprites,
  186. .ms_n = ARR_LEN(debug_marker_metasprites),
  187. .ti = debug_marker_tiles,
  188. .pa = debug_marker_palettes,
  189. .pa_n = debug_marker_PALETTE_COUNT,
  190. .pa_i = OAMF_CGB_PAL7 | PALETTE_DYNAMIC_LOAD_IP,
  191. .cnt = debug_marker_TILE_COUNT,
  192. .off = TILE_NUM_START,
  193. .bank = BANK(debug_marker),
  194. },
  195. { // SPR_DEBUG_LARGE
  196. .ms = debug_marker_spr32_metasprites,
  197. .ms_n = ARR_LEN(debug_marker_spr32_metasprites),
  198. .ti = debug_marker_spr32_tiles,
  199. .pa = debug_marker_spr32_palettes,
  200. .pa_n = debug_marker_spr32_PALETTE_COUNT,
  201. .pa_i = OAMF_CGB_PAL7 | PALETTE_DYNAMIC_LOAD_IP,
  202. .cnt = debug_marker_spr32_TILE_COUNT,
  203. .off = TILE_NUM_START,
  204. .bank = BANK(debug_marker_spr32),
  205. },
  206. };