aboutsummaryrefslogtreecommitdiff
path: root/fmdsp/fmdsp.h
blob: 6a9870750ed8b3a17c5a49e18d94860a97f4a917 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef MYON_FMDSP_H_INCLUDED
#define MYON_FMDSP_H_INCLUDED

#include <stdint.h>
#include <stdbool.h>
#include "font.h"
#include "fmdriver/fmdriver.h"
#include "fft/fft.h"

#ifdef __cplusplus
extern "C" {
#endif

struct opna;

enum {
  PC98_W = 640,
  PC98_H = 400
};

enum {
  FMDSP_PALETTE_COLORS = 10
};

enum FMDSP_DISPSTYLE {
  FMDSP_DISPSTYLE_ORIGINAL,
  FMDSP_DISPSTYLE_DEFAULT,
  FMDSP_DISPSTYLE_OPN,
  FMDSP_DISPSTYLE_PPZ8,
  FMDSP_DISPSTYLE_13,
  FMDSP_DISPSTYLE_CNT
};

struct fmdsp {
  uint8_t palette[FMDSP_PALETTE_COLORS*3];
  uint8_t target_palette[FMDSP_PALETTE_COLORS*3];
  const struct fmdsp_font *font98;
  enum FMDSP_DISPSTYLE style;
  bool style_updated;
  bool masked[FMDRIVER_TRACK_NUM];
  uint8_t fftdata[FFTDISPLEN];
  uint8_t fftcnt[FFTDISPLEN];
  uint8_t fftdropdiv[FFTDISPLEN];
  uint64_t framecnt;
  int cpuusage;
  int fps;
};

struct fmdriver_work;
void fmdsp_init(struct fmdsp *fmdsp, const struct fmdsp_font *font);
void fmdsp_vram_init(struct fmdsp *fmdsp,
                     struct fmdriver_work *work,
                     uint8_t *vram);
void fmdsp_update(struct fmdsp *fmdsp, const struct fmdriver_work *work,
                  const struct opna *opna, uint8_t *vram,
                  struct fmplayer_fft_input_data *idata
                 );
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);
void fmdsp_dispstyle_set(struct fmdsp *fmdsp, enum FMDSP_DISPSTYLE style);

typedef void (*fmdsp_vramlookup_type)(uint8_t *vram32,
                                      const uint8_t *vram,
                                      const uint8_t *palette,
                                      int stride);
extern fmdsp_vramlookup_type fmdsp_vramlookup_func;
void fmdsp_vramlookup_c(uint8_t *vram32,
                        const uint8_t *vram,
                        const uint8_t *palette,
                        int stride) __attribute__((hot,optimize(3)));

void fmdsp_vramlookup_neon(uint8_t *, const uint8_t *, const uint8_t *, int);
void fmdsp_vramlookup_ssse3(uint8_t *, const uint8_t *, const uint8_t *, int) __attribute__((hot,optimize(3)));
#ifdef __cplusplus
}
#endif

#endif // MYON_FMDSP_H_INCLUDED