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

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