-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorelib.h
More file actions
60 lines (49 loc) · 1.43 KB
/
corelib.h
File metadata and controls
60 lines (49 loc) · 1.43 KB
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
#pragma once
#include <stdint.h>
#include <stddef.h>
#define VIDEO_WIDTH 256
#define VIDEO_HEIGHT 242
#define OVER_WIDTH 2048
#define OVER_HEIGHT 512
// Used by core to log to ui. Frontends are expected to define this.
enum Keys {
BTN_A = 0,
BTN_B,
BTN_Sel,
BTN_Start,
BTN_Up,
BTN_Down,
BTN_Left,
BTN_Right,
BTN_L, // Shoulder buttons
BTN_R,
NUM_KEYS
};
#define EMU_USES_CPP
#ifdef EMU_USES_CPP
#define UNMANGLE extern "C"
#else
#define UNMANGLE
#endif
#define EXPOSE extern "C" __attribute__((visibility("default")))
UNMANGLE void corelib_set_puts(void(*cb)(const char*));
UNMANGLE void set_key(size_t key, char val);
UNMANGLE void init(const uint8_t* data, size_t len);
UNMANGLE const uint8_t *framebuffer();
UNMANGLE void frame();
UNMANGLE void dump_state(const char* save_path);
UNMANGLE void load_state(const char* save_path);
// Interface used by app. App closes fd.
UNMANGLE void save(int fd);
UNMANGLE void load(int fd);
// Returns bytes saved, and writes to dest.
// Dest may be null to calculate size only. returns < 0 on error.
UNMANGLE int save_str(uint8_t* dest, int capacity);
// Loads len bytes from src
UNMANGLE void load_str(int len, const uint8_t* src);
// APU
const int SAMPLE_RATE = 44100;
const int SAMPLES_PER_FRAME = SAMPLE_RATE / 60;
UNMANGLE void apu_tick_60hz();
UNMANGLE void apu_sample_60hz(int16_t *output);
UNMANGLE long apu_sample_variable(int16_t *output, int32_t frames);