-
Notifications
You must be signed in to change notification settings - Fork 1
/
console_internal.h
79 lines (68 loc) · 1.55 KB
/
console_internal.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
#pragma once
#include "console.h"
#include <stdarg.h>
typedef enum console_mode {
CONSOLE_MODE_NORMAL,
CONSOLE_MODE_JUMP,
CONSOLE_MODE_COMMAND,
} console_mode_t;
typedef struct char_buf {
char str[256];
int cursor;
} char_buf_t;
typedef struct console {
core_ref shared_core;
disas_ref shared_disas;
debugger_ref shared_debugger;
event_logger_driver_ref shared_event_logger;
char_buf_t command_buf;
char_buf_t jump_buf;
console_mode_t mode;
uint32_t base;
uint32_t pc_phys;
int view_height;
int view_y;
int middle_y;
char display[256];
bool follow;
int cursor;
int ram_offset_y;
int prev_inspector_state;
bool enable_event_log;
console_pause_reason_t pause_reason;
} console_t;
static inline void char_buf_add(char_buf_t *self, int ch)
{
if (self->cursor < 255) {
self->str[self->cursor++] = ch;
self->str[self->cursor] = '\0';
}
}
static inline void char_buf_reset(char_buf_t *self)
{
self->cursor = 0;
self->str[0] = '\0';
}
static inline char char_buf_last(char_buf_t *self)
{
char ret;
if (self->cursor > 0) {
ret = self->str[self->cursor - 1];
} else {
ret = '\0';
}
return ret;
}
static inline void char_buf_backspace(char_buf_t *self)
{
if (self->cursor > 0) {
self->str[--self->cursor] = '\0';
}
}
static inline void console_display(console_ref self, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vsnprintf(self->display, 256, fmt, args);
va_end(args);
}