Browse Source

optimize health and power sprite and use palette swap

Thomas B 2 months ago
parent
commit
7fefdfbe4f
3 changed files with 20 additions and 11 deletions
  1. BIN
      data/health.png
  2. BIN
      data/power.png
  3. 20
    11
      src/sprites.c

BIN
data/health.png View File


BIN
data/power.png View File


+ 20
- 11
src/sprites.c View File

@@ -33,7 +33,6 @@
33 33
 #include "dark.h"
34 34
 #include "shoot.h"
35 35
 #include "health.h"
36
-#include "power.h"
37 36
 
38 37
 // Metasprite tiles are loaded into VRAM starting at tile number 0
39 38
 #define TILE_NUM_START 0
@@ -47,6 +46,12 @@ struct sprites {
47 46
     uint8_t off;
48 47
 };
49 48
 
49
+const palette_color_t power_palettes[4] = {
50
+  //RGB8(  0,  0,  0), RGB8(240,  0,  0), RGB8(196,  0,  0), RGB8(116,  0,  0)
51
+    RGB8(  0,  0,  0), RGB8(  0,240,  0), RGB8(  0,196,  0), RGB8(  0,116,  0)
52
+
53
+};
54
+
50 55
 static struct sprites metasprites[SPRITE_COUNT] = {
51 56
     {
52 57
         .ms = rockshp_0_metasprites,
@@ -100,30 +105,34 @@ static struct sprites metasprites[SPRITE_COUNT] = {
100 105
     }, {
101 106
         .ms = health_metasprites,
102 107
         .ti = health_tiles,
103
-        .pa = health_palettes, // RGB8(239,  0,  0), RGB8(204,  0,  0), RGB8(167,  1,  0), RGB8(116,  0,  0)
108
+        .pa = health_palettes,
104 109
         .pa_i = OAMF_CGB_PAL5,
105 110
         .cnt = health_TILE_COUNT,
106 111
         .off = TILE_NUM_START
107 112
     }, {
108
-        .ms = power_metasprites,
109
-        .ti = power_tiles,
110
-        .pa = power_palettes, // RGB8(  0,236,  0), RGB8(  2,193,  1), RGB8(  5,152,  0), RGB8(  3, 98,  0)
113
+        .ms = health_metasprites,
114
+        .ti = health_tiles,
115
+        .pa = power_palettes,
111 116
         .pa_i = OAMF_CGB_PAL6,
112
-        .cnt = power_TILE_COUNT,
113
-        .off = TILE_NUM_START
117
+        .cnt = health_TILE_COUNT,
118
+        .off = SPR_HEALTH
114 119
     }
115 120
 };
116 121
 
117 122
 void spr_init(void) {
118 123
     uint8_t off = TILE_NUM_START;
119 124
     for (uint8_t i = 0; i < SPRITE_COUNT; i++) {
120
-        metasprites[i].off = off;
121
-        off += metasprites[i].cnt;
122
-
123 125
         if (metasprites[i].pa != NULL) {
124 126
             set_sprite_palette(metasprites[i].pa_i, 1, metasprites[i].pa);
125 127
         }
126
-        set_sprite_data(metasprites[i].off, metasprites[i].cnt, metasprites[i].ti);
128
+
129
+        if (metasprites[i].off == TILE_NUM_START) {
130
+            metasprites[i].off = off;
131
+            off += metasprites[i].cnt;
132
+            set_sprite_data(metasprites[i].off, metasprites[i].cnt, metasprites[i].ti);
133
+        } else {
134
+            metasprites[i].off = metasprites[metasprites[i].off].off;
135
+        }
127 136
     }
128 137
 }
129 138
 

Loading…
Cancel
Save