-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsole.h
176 lines (140 loc) · 3.23 KB
/
console.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#ifndef CONSOLE_H
#define CONSOLE_H
#include "types.h"
#include <SDL_keycode.h>
#include "chip.h"
#define STARTING_SCREEN_WIDTH (1360)
#define STARTING_SCREEN_HEIGHT (720)
#define NUM_MESSAGES (256)
typedef struct {
char message[256];
u32 attrib;
} ConsoleMessage;
/**
* Gets the number of columns allocated for the screen
*/
int con_columns();
/**
* Adds a message to the console buffer with the specified attribute
* @param _attrib Attribute to use (see con_setAttrib)
* @param _message String to print
*/
void con_attrMsg(u32 _attrib, char *_message);
/**
* Adds a message to the console buffer
*/
void con_msg(char *_message);
#define con_msgf(f, ...) con_attrMsgf(0x07, f, __VA_ARGS__)
/**
* Adds a ChipError message to the console buffer
*/
void con_error(ChipError _error);
#define con_errorf(f, ...) con_attrMsgf(0x09, f, __VA_ARGS__)
/**
* Adds a warning message to the console buffer
*/
void con_warn(char *_message);
#define con_warnf(f, ...) con_attrMsgf(0x0B, f, __VA_ARGS__)
/**
* Printf's a message to the console buffer with a specific attribute
* @param _attrib Attributes to use (see con_setAttrib)
* @param _format Format string
* @param ... Arguments
*/
void con_attrMsgf(u32 _attrib, char *_format, ...);
/**
* Gets the most recent message
*/
ConsoleMessage *con_getMostRecentMessage();
/**
* Get the next recent message
*/
ConsoleMessage *con_getNextMessage();
/**
* Gets the number of rows allocated for the screen
*/
int con_rows();
/**
* Sets the default color attribute used.
* bits 0-3 = FG Color
* bits 4-6 = BG Color
* bit 7 = Blink
*/
void con_setAttrib(int _attrib);
/**
* Sets the attribute at the specified location
*/
void con_setAttribXY(int _col, int _row, int _attrib);
/**
* Gets the attribute at the specified location
*/
u32 con_getAttribXY(int _col, int _row);
/**
* Moves the cursor to the specified location
*/
void con_gotoXY(int _col, int _row);
/**
* Reports the current X position of the cursor
*/
int con_x();
/**
* Reports the current Y position of the cursor
*/
int con_y();
/**
* Print an unformatted string
*/
void con_print(const char *_string);
/**
* Print an unformatted string with limited length
*/
void con_nprint(const char *_string, int _len);
/**
* Print a string at the specified location
*/
void con_printXY(int _col, int _row, const char *_string);
/**
* Print a formatted string at the specified location
*/
void con_printfXY(int _col, int _row, const char *_format, ...);
/**
* Print a formatted string
*/
void con_printf(const char *_format, ...);
/**
* Draws a horizontal line
*/
void con_hline(int _x1, int _x2, int _y, u8 _char);
/**
* Draws a vertical line
*/
void con_vline(int _x, int _y1, int _y2, u8 _char);
/**
* Prints a single char to the screen
*/
void con_putc(char _char);
/**
* Prints a single char to the screen at col, row
*/
void con_putcXY(int _col, int _row, char _char);
/**
* clears the screen
*/
void con_cls();
/**
* Fills the screen with the attribute and char
*/
void con_fill(int _attrib, char _char);
/**
* Closes the window and cleans up
*/
void con_shutdown();
/**
* Pauses audio playback
*/
void con_pauseAudio();
/**
* Resumes audio playback
*/
void con_resumeAudio();
#endif // ifndef CONSOLE_H