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 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 "debug_marker.h"
  31. #include "debug_marker_spr32.h"
  32. BANKREF(power_palettes)
  33. /*
  34. * OCP0: Rocketship (1)
  35. * OCP1: Rocketship (2)
  36. * OCP2: Light
  37. * OCP3: Dark
  38. * OCP4: Shot
  39. * OCP5: Health
  40. * OCP6: Power
  41. * OCP7: Pause
  42. *
  43. * Explosion uses OCP0 to OCP3 at end of game.
  44. * Pause is flipped in-place for animating the pause screen colors.
  45. */
  46. const palette_color_t power_palettes[4] = {
  47. //RGB8( 0, 0, 0), RGB8(240, 0, 0), RGB8(196, 0, 0), RGB8(116, 0, 0)
  48. RGB8( 0, 0, 0), RGB8( 0,240, 0), RGB8( 0,196, 0), RGB8( 0,116, 0)
  49. };
  50. struct sprites metasprites[SPRITE_COUNT] = {
  51. { // SPR_SHIP
  52. .ms = rockshp_spr24_metasprites,
  53. .ms_n = ARR_LEN(rockshp_spr24_metasprites),
  54. .ti = rockshp_spr24_tiles,
  55. .pa = rockshp_spr24_palettes,
  56. .pa_n = rockshp_spr24_PALETTE_COUNT,
  57. .pa_i = OAMF_CGB_PAL0,
  58. .cnt = rockshp_spr24_TILE_COUNT,
  59. .off = TILE_NUM_START,
  60. .bank = BANK(rockshp_spr24),
  61. },
  62. { // SPR_LIGHT
  63. .ms = light_metasprites,
  64. .ms_n = ARR_LEN(light_metasprites),
  65. .ti = light_tiles,
  66. .pa = light_palettes,
  67. .pa_n = light_PALETTE_COUNT,
  68. .pa_i = OAMF_CGB_PAL2,
  69. .cnt = light_TILE_COUNT,
  70. .off = TILE_NUM_START,
  71. .bank = BANK(light),
  72. },
  73. { // SPR_DARK
  74. .ms = dark_metasprites,
  75. .ms_n = ARR_LEN(dark_metasprites),
  76. .ti = dark_tiles,
  77. .pa = dark_palettes,
  78. .pa_n = dark_PALETTE_COUNT,
  79. .pa_i = OAMF_CGB_PAL3,
  80. .cnt = dark_TILE_COUNT,
  81. .off = TILE_NUM_START,
  82. .bank = BANK(dark),
  83. },
  84. { // SPR_SHOT
  85. .ms = shoot_metasprites,
  86. .ms_n = ARR_LEN(shoot_metasprites),
  87. .ti = shoot_tiles,
  88. .pa = shoot_palettes,
  89. .pa_n = shoot_PALETTE_COUNT,
  90. .pa_i = OAMF_CGB_PAL4,
  91. .cnt = shoot_TILE_COUNT,
  92. .off = TILE_NUM_START,
  93. .bank = BANK(shoot),
  94. },
  95. { // SPR_SHOT_LIGHT
  96. .ms = shoot_metasprites,
  97. .ms_n = ARR_LEN(shoot_metasprites),
  98. .ti = shoot_tiles,
  99. .pa = NULL,
  100. .pa_n = shoot_PALETTE_COUNT,
  101. .pa_i = OAMF_CGB_PAL2,
  102. .cnt = shoot_TILE_COUNT,
  103. .off = SPR_SHOT,
  104. .bank = BANK(shoot),
  105. },
  106. { // SPR_SHOT_DARK
  107. .ms = shoot_metasprites,
  108. .ms_n = ARR_LEN(shoot_metasprites),
  109. .ti = shoot_tiles,
  110. .pa = NULL,
  111. .pa_n = shoot_PALETTE_COUNT,
  112. .pa_i = OAMF_CGB_PAL3,
  113. .cnt = shoot_TILE_COUNT,
  114. .off = SPR_SHOT,
  115. .bank = BANK(shoot),
  116. },
  117. { // SPR_HEALTH
  118. .ms = bar_spr8_metasprites,
  119. .ms_n = ARR_LEN(bar_spr8_metasprites),
  120. .ti = bar_spr8_tiles,
  121. .pa = bar_spr8_palettes,
  122. .pa_n = bar_spr8_PALETTE_COUNT,
  123. .pa_i = OAMF_CGB_PAL5,
  124. .cnt = bar_spr8_TILE_COUNT,
  125. .off = TILE_NUM_START,
  126. .bank = BANK(bar_spr8),
  127. },
  128. { // SPR_POWER
  129. .ms = bar_spr8_metasprites,
  130. .ms_n = ARR_LEN(bar_spr8_metasprites),
  131. .ti = bar_spr8_tiles,
  132. .pa = power_palettes,
  133. .pa_n = bar_spr8_PALETTE_COUNT,
  134. .pa_i = OAMF_CGB_PAL6,
  135. .cnt = bar_spr8_TILE_COUNT,
  136. .off = SPR_HEALTH,
  137. .bank = BANK(bar_spr8),
  138. },
  139. { // SPR_EXPL
  140. .ms = expl_spr16_metasprites,
  141. .ms_n = ARR_LEN(expl_spr16_metasprites),
  142. .ti = expl_spr16_tiles,
  143. .pa = expl_spr16_palettes,
  144. .pa_n = expl_spr16_PALETTE_COUNT,
  145. .pa_i = OAMF_CGB_PAL0 | PALETTE_DYNAMIC_LOAD,
  146. .cnt = expl_spr16_TILE_COUNT,
  147. .off = TILE_NUM_START,
  148. .bank = BANK(expl_spr16),
  149. },
  150. { // SPR_PAUSE
  151. .ms = pause_metasprites,
  152. .ms_n = ARR_LEN(pause_metasprites),
  153. .ti = pause_tiles,
  154. .pa = pause_palettes,
  155. .pa_n = pause_PALETTE_COUNT,
  156. .pa_i = OAMF_CGB_PAL7 | PALETTE_DYNAMIC_LOAD_IP,
  157. .cnt = pause_TILE_COUNT,
  158. .off = TILE_NUM_START,
  159. .bank = BANK(pause),
  160. },
  161. { // SPR_DEBUG
  162. .ms = debug_marker_metasprites,
  163. .ms_n = ARR_LEN(debug_marker_metasprites),
  164. .ti = debug_marker_tiles,
  165. .pa = debug_marker_palettes,
  166. .pa_n = debug_marker_PALETTE_COUNT,
  167. .pa_i = OAMF_CGB_PAL7 | PALETTE_DYNAMIC_LOAD_IP,
  168. .cnt = debug_marker_TILE_COUNT,
  169. .off = TILE_NUM_START,
  170. .bank = BANK(debug_marker),
  171. },
  172. { // SPR_DEBUG_LARGE
  173. .ms = debug_marker_spr32_metasprites,
  174. .ms_n = ARR_LEN(debug_marker_spr32_metasprites),
  175. .ti = debug_marker_spr32_tiles,
  176. .pa = debug_marker_spr32_palettes,
  177. .pa_n = debug_marker_spr32_PALETTE_COUNT,
  178. .pa_i = OAMF_CGB_PAL7 | PALETTE_DYNAMIC_LOAD_IP,
  179. .cnt = debug_marker_spr32_TILE_COUNT,
  180. .off = TILE_NUM_START,
  181. .bank = BANK(debug_marker_spr32),
  182. },
  183. };