-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommon.h
More file actions
67 lines (44 loc) · 1.47 KB
/
Copy pathcommon.h
File metadata and controls
67 lines (44 loc) · 1.47 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
61
62
63
64
65
66
67
#ifndef _COMMON_H_
#define _COMMON_H_
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#ifndef __EMSCRIPTEN__
#include <SDL2/SDL.h>
#else
#include <emscripten.h>
#include <emscripten/html5.h>
#include <SDL.h>
#include <string.h>
#endif
/* switch to enable GPU debug window and debug output*/
#undef DEBUG_BUILD
#define ALWAYS_INLINE __attribute__((always_inline))
#define SCREEN_WIDTH 160
#define SCREEN_HEIGHT 144
#define RENDER_SCALE 2
#define RENDER_WIDTH (SCREEN_WIDTH * RENDER_SCALE)
#define RENDER_HEIGHT (SCREEN_HEIGHT * RENDER_SCALE)
#define SOUND_SAMPLE_RATE 48000
#define CPU_FREQ 4213440 // in HZ
typedef void (*sound_callback_fn)(void *usedata, uint8_t* stream, int len);
typedef void (*key_handler) (int key);
typedef struct rom_mapper_func {
void (*init)(uint8_t *rom, uint64_t filesize);
uint8_t (*read)(uint16_t address);
void (*write)(uint16_t address, uint8_t val);
} rom_mapper_func_t;
void common_init ();
void common_shutdown ();
void println (const char *message, ...);
void printl (const char *message, ...);
void file_load_rom (const char *rom_filename);
void screen_clear (void);
void screen_vsync (void);
void screen_put_pixel (int x, int y, uint8_t r, uint8_t g, uint8_t b);
void audio_send_samples (int16_t* samples, int len);
void keyboard_set_handlers (key_handler key_down, key_handler key_up);
void keyboard_handle_input (SDL_Event *event);
void sound_set_callback(sound_callback_fn callback);
#endif /* _COMMON_H_ */