blob: 32285cabb339ca3d4e41482af7126cdee0e064cb (
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
|
#ifndef DEVICE_H
#define DEVICE_H
#include <stdint.h>
#ifdef WITH_GUI
#include <SDL.h>
#endif
struct device_t;
typedef struct device_vtable_t {
uint8_t (*read)( void *obj, uint16_t addr );
void (*write)( void *obj, uint16_t addr, uint8_t data );
#ifdef WITH_GUI
void (*draw)( void *obj, SDL_Renderer *renderer );
#endif
void (*deinit)( void *obj );
} device_vtable_t;
typedef struct device_t {
device_vtable_t const *vtable;
char *name;
} device_t;
void device_init( device_t *device, const char *name );
void device_copy( device_t *to, device_t *from );
uint8_t device_read( void *obj, uint16_t addr );
void device_write( void *obj, uint16_t addr, uint8_t data );
#ifdef WITH_GUI
void device_draw( void *obj, SDL_Renderer *renderer );
#endif
void device_deinit( void *obj );
#endif
|