aboutsummaryrefslogtreecommitdiff
path: root/fmdsp
diff options
context:
space:
mode:
authorTakamichi Horikawa <takamichiho@gmail.com>2017-01-31 23:09:30 +0900
committerTakamichi Horikawa <takamichiho@gmail.com>2017-01-31 23:09:30 +0900
commit2d187a02033d7980202b44d9f6b4b0a4d185a60b (patch)
treed4963d45c84a2c5cb7705c69bdcc71a40acce107 /fmdsp
parent3dd0c134f0f0d1dcf467897fc23de4e072878dcb (diff)
added color palette support (ctrl-f1 - ctrl-f10)
Diffstat (limited to 'fmdsp')
-rw-r--r--fmdsp/fmdsp.c41
-rw-r--r--fmdsp/fmdsp.h1
-rw-r--r--fmdsp/fmdsp_sprites.h126
3 files changed, 162 insertions, 6 deletions
diff --git a/fmdsp/fmdsp.c b/fmdsp/fmdsp.c
index 1da0adf..4c16f5e 100644
--- a/fmdsp/fmdsp.c
+++ b/fmdsp/fmdsp.c
@@ -46,10 +46,9 @@ static void vramblit_key(uint8_t *vram, int x, int y,
}
void fmdsp_init(struct fmdsp *fmdsp, const struct fmdsp_font *font98) {
- for (int i = 0; i < FMDSP_PALETTE_COLORS; i++) {
- fmdsp->palette[i*3+0] = s_palettes[0][i*3+0];
- fmdsp->palette[i*3+1] = s_palettes[0][i*3+1];
- fmdsp->palette[i*3+2] = s_palettes[0][i*3+2];
+ for (int i = 0; i < FMDSP_PALETTE_COLORS*3; i++) {
+ fmdsp->palette[i] = 0;//s_palettes[0][i];
+ fmdsp->target_palette[i] = s_palettes[0][i];
}
fmdsp->font98 = font98;
}
@@ -181,6 +180,39 @@ void fmdsp_vram_init(struct fmdsp *fmdsp,
}
}
+enum {
+ FADEDELTA = 16
+};
+
+void fmdsp_palette_set(struct fmdsp *fmdsp, int p) {
+ if (p < 0) return;
+ if (p >= PALETTE_NUM) return;
+ for (int i = 0; i < FMDSP_PALETTE_COLORS*3; i++) {
+ fmdsp->target_palette[i] = s_palettes[p][i];
+ }
+}
+
+static void fmdsp_palette_fade(struct fmdsp *fmdsp) {
+ for (int i = 0; i < FMDSP_PALETTE_COLORS*3; i++) {
+ uint8_t p = fmdsp->palette[i];
+ uint8_t t = fmdsp->target_palette[i];
+ if (p < t) {
+ if ((p + FADEDELTA) < t) {
+ p += FADEDELTA;
+ } else {
+ p = t;
+ }
+ } else if (p > t) {
+ if (p > (t + FADEDELTA)) {
+ p -= FADEDELTA;
+ } else {
+ p = t;
+ }
+ }
+ fmdsp->palette[i] = p;
+ }
+}
+
void fmdsp_update(struct fmdsp *fmdsp,
const struct fmdriver_work *work, uint8_t *vram) {
for (int t = 0; t < 10; t++) {
@@ -220,6 +252,7 @@ void fmdsp_update(struct fmdsp *fmdsp,
vramblit_color(vram, BAR_X+BAR_W*(track->ticks>>2), TRACK_H*t+BAR_Y,
s_bar, BAR_W, BAR_H, 7);
}
+ fmdsp_palette_fade(fmdsp);
}
void fmdsp_vrampalette(struct fmdsp *fmdsp, const uint8_t *vram, uint8_t *vram32, int stride) {
diff --git a/fmdsp/fmdsp.h b/fmdsp/fmdsp.h
index a7b245a..f123138 100644
--- a/fmdsp/fmdsp.h
+++ b/fmdsp/fmdsp.h
@@ -32,6 +32,7 @@ void fmdsp_vram_init(struct fmdsp *fmdsp,
void fmdsp_update(struct fmdsp *fmdsp, const struct fmdriver_work *work, uint8_t *vram);
void fmdsp_vrampalette(struct fmdsp *fmdsp, const uint8_t *vram, uint8_t *vram32, int stride);
void fmdsp_font_from_fontrom(uint8_t *font, const uint8_t *fontrom);
+void fmdsp_palette_set(struct fmdsp *fmdsp, int p);
#ifdef __cplusplus
}
#endif
diff --git a/fmdsp/fmdsp_sprites.h b/fmdsp/fmdsp_sprites.h
index 1fe6c13..ded3591 100644
--- a/fmdsp/fmdsp_sprites.h
+++ b/fmdsp/fmdsp_sprites.h
@@ -37,7 +37,22 @@ enum {
PLAYING_H = 9,
};
-static const uint8_t s_palettes[1][FMDSP_PALETTE_COLORS*3] = {
+enum {
+ PALETTE_NUM = 10
+};
+
+#define LCDWR 181
+#define LCDWG 192
+#define LCDWB 12
+#define LCDBR 70
+#define LCDBG 124
+#define LCDBB 108
+#define LCD(C) \
+ (LCDWR*(C)+LCDBR*(255-C))/256, \
+ (LCDWG*(C)+LCDBG*(255-C))/256, \
+ (LCDWB*(C)+LCDBB*(255-C))/256
+
+static const uint8_t s_palettes[PALETTE_NUM][FMDSP_PALETTE_COLORS*3] = {
{
0, 0, 0,
170, 170, 153,
@@ -48,9 +63,116 @@ static const uint8_t s_palettes[1][FMDSP_PALETTE_COLORS*3] = {
136, 255, 68,
51, 51, 238,
0, 187, 255,
- }
+ },
+ {
+ 0, 0, 0,
+ 187, 187, 170,
+ 136, 170, 255,
+ 85, 85, 153,
+ 204, 204, 187,
+ 136, 136, 119,
+ 153, 255, 119,
+ 102, 85, 255,
+ 0, 204, 255,
+ },
+ {
+ 0, 0, 0,
+ 255, 102, 0,
+ 255, 170, 0,
+ 102, 68, 51,
+ 153, 136, 102,
+ 119, 85, 68,
+ 255, 221, 85,
+ 255, 102, 0,
+ 255, 85, 0,
+ },
+ {
+ 0, 0, 0,
+ 170, 170, 153,
+ 170, 153, 255,
+ 85, 51, 102,
+ 204, 204, 187,
+ 102, 102, 85,
+ 119, 255, 34,
+ 136, 68, 221,
+ 0, 187, 255,
+ },
+ {
+ 0, 0, 0,
+ 187, 187, 170,
+ 102, 153, 255,
+ 85, 68, 136,
+ 255, 255, 238,
+ 119, 119, 102,
+ 255, 68, 0,
+ 85, 85, 255,
+ 255, 119, 255,
+ },
+ {
+ 0, 0, 0,
+ 255, 51, 119,
+ 255, 187, 0,
+ 85, 85, 68,
+ 119, 119, 102,
+ 102, 102, 102,
+ 255, 221, 0,
+ 255, 0, 51,
+ 255, 0, 51,
+ },
+ {
+ 102, 170, 238,
+ 0, 17, 136,
+ 0, 51, 136,
+ 153, 221, 255,
+ 153, 221, 255,
+ 119, 187, 255,
+ 0, 51, 136,
+ 34, 102, 187,
+ 0, 85, 204,
+ },
+ {
+ 0, 0, 0,
+ 170, 170, 136,
+ 102, 153, 255,
+ 17, 0, 51,
+ 170, 170, 153,
+ 51, 51, 51,
+ 85, 255, 68,
+ 34, 17, 255,
+ 0, 170, 255,
+ },
+ {
+ LCD(255),
+ LCD(72),
+ LCD(0),
+ LCD(182),
+ LCD(0),
+ LCD(145),
+ LCD(218),
+ LCD(109),
+ LCD(218),
+ },
+ {
+ LCD(255),
+ LCD(72),
+ LCD(0),
+ LCD(182),
+ LCD(145),
+ LCD(145),
+ LCD(0),
+ LCD(109),
+ LCD(0),
+ },
};
+#undef LCDWR
+#undef LCDWG
+#undef LCDWB
+#undef LCDBR
+#undef LCDBG
+#undef LCDBB
+#undef LCD
+
static const uint8_t s_track[TNAME_W*TNAME_H] = {
1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0,