-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathxlink.h
103 lines (84 loc) · 3.02 KB
/
xlink.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
95
96
97
98
99
100
101
102
103
#ifndef XLINK_H
#define XLINK_H
#include <stdbool.h>
#if defined(WIN32) || defined(__CYGWIN__)
#if defined(XLINK_LIBRARY_BUILD)
#define IMPORTED
#else
#define IMPORTED __declspec(dllimport)
#endif
#else
#define IMPORTED
#endif
#define XLINK_VERSION 0x10
#define XLINK_SERVER_TYPE_RAM 0x00
#define XLINK_SERVER_TYPE_ROM 0x01
#define XLINK_MACHINE_C64 0x00
#define XLINK_MACHINE_C128 0x01
#define XLINK_SUCCESS 0x00
#define XLINK_ERROR_DEVICE 0x01
#define XLINK_ERROR_LIBUSB 0x02
#define XLINK_ERROR_PARPORT 0x03
#define XLINK_ERROR_SERVER 0x04
#define XLINK_ERROR_FILE 0x05
#define XLINK_ERROR_SERIAL 0x06
#define XLINK_COMMAND_LOAD 0x01
#define XLINK_COMMAND_SAVE 0x02
#define XLINK_COMMAND_POKE 0x03
#define XLINK_COMMAND_PEEK 0x04
#define XLINK_COMMAND_JUMP 0x05
#define XLINK_COMMAND_RUN 0x06
#define XLINK_COMMAND_INJECT 0x07
#define XLINK_COMMAND_PING 0xfd
#define XLINK_COMMAND_IDENTIFY 0xfe
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef struct {
char id[16]; // server identification
uchar version; // high byte major, low byte minor
uchar machine; // XLINK_MACHINE_C64
uchar type; // XLINK_SERVER_TYPE_{RAM|ROM}
ushort start; // server start address
ushort end; // server end address
ushort length; // server code length
ushort memtop; // current top of (lower) memory (0xa000 or 0x8000)
} xlink_server_info_t;
typedef struct {
int code;
char message[512];
} xlink_error_t;
IMPORTED extern xlink_error_t* xlink_error;
/* high level interface */
uchar xlink_version(void);
void xlink_set_debug(bool enabled);
bool xlink_has_device(void);
bool xlink_set_device(char* path);
char* xlink_get_device(void);
bool xlink_ping(void);
bool xlink_reset(void);
bool xlink_ready(void);
bool xlink_identify(xlink_server_info_t* server);
bool xlink_relocate(ushort address);
bool xlink_load(uchar memory, uchar bank, ushort address, uchar* data, uint size);
bool xlink_save(uchar memory, uchar bank, ushort address, uchar* data, uint size);
bool xlink_peek(uchar memory, uchar bank, ushort address, uchar* value);
bool xlink_poke(uchar memory, uchar bank, ushort address, uchar value);
bool xlink_fill(uchar memory, uchar bank, ushort address, uchar value, uint size);
bool xlink_jump(uchar memory, uchar bank, ushort address);
bool xlink_run(void);
/* low level interface */
bool xlink_inject(ushort address, uchar* code, uint size);
void xlink_begin(void);
bool xlink_send(uchar* data, uint size);
bool xlink_send_with_timeout(uchar* data, uint size, uint timeout);
bool xlink_receive(uchar *data, uint size);
bool xlink_receive_with_timeout(uchar* data, uint size, uint timeout);
void xlink_end(void);
#ifdef __cplusplus
}
#endif
#endif // XLINK_H