-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.h
95 lines (78 loc) · 2.01 KB
/
player.h
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once
#include <stdint.h>
#include "opmplay.h"
#define arrayof(n) (sizeof(n) / sizeof(n[0]))
enum {
PLAY_MODE_LOOP = 0,
PLAY_MODE_SHUFFLE,
PLAY_MODE_SEQUENTIAL,
PLAY_MODE_COUNT,
};
enum {
TOTAL_TUNES = 9,
};
// module selector context
struct module_selector_entry_t {
char *name;
char *author;
char *file;
uint32_t loop_count;
uint8_t *data;
uint32_t raw_size;
uint32_t unpacked_size;
};
struct module_selector_ctx_t {
int cursor;
int sel;
int next_sel;
int timeout;
};
// player context
struct bar_keyofs_t {
int value;
int limit;
int dec;
};
struct player_ctx_t {
opmplay_context_t opm;
opmplay_io_t io;
uint32_t tempo_hz;
uint32_t frames_total;
uint32_t frames_loop;
uint32_t total_modules;
bool preload;
bool paused;
bool run;
bool volume_changed;
int32_t volume;
// unpacked module for lowmem mode
uint8_t* unlz4_module;
// VU meter stuff (later :)
int bars[4 * 18];
bar_keyofs_t bars_keyofs[18];
int bars_offset;
int key[18];
// fadeout
struct {
bool run;
int timeout;
int32_t volume;
int loop_count;
int32_t timeout_mask;
} nextsong;
// play mode
uint32_t playmode;
// text buffer
uint16_t textbuf[80 * 50];
// selector ctx
module_selector_ctx_t selector;
};
// externs
extern player_ctx_t player_ctx;
extern module_selector_entry_t modulelist[TOTAL_TUNES];
bool player_init(bool preload);
void player_callback(void *parm);
void player_update_view();
int player_load_module_idx(player_ctx_t *ctx, int i);
int player_load_module(player_ctx_t *ctx, char *filename);
int player_load_module_packed(player_ctx_t *ctx, void *data, uint32_t size);