2013-10-12 20:38:34 +02:00
|
|
|
#include <gccore.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2013-10-21 18:41:01 +02:00
|
|
|
#include <stdarg.h>
|
2013-10-12 20:38:34 +02:00
|
|
|
|
|
|
|
/* init-globals */
|
|
|
|
bool geckoinit = false;
|
|
|
|
bool textVideoInit = false;
|
|
|
|
|
|
|
|
#ifndef NO_DEBUG
|
|
|
|
void gprintf( const char *str, ... )
|
|
|
|
{
|
|
|
|
if (!(geckoinit))return;
|
2015-10-27 09:04:08 +01:00
|
|
|
char astr[4096];
|
|
|
|
int length;
|
2013-10-12 20:38:34 +02:00
|
|
|
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap,str);
|
|
|
|
|
2015-10-27 09:04:08 +01:00
|
|
|
length = vsnprintf(astr, sizeof(astr), str, ap);
|
|
|
|
if (length > 0) usb_sendbuffer_safe(1, astr, length);
|
2013-10-12 20:38:34 +02:00
|
|
|
|
|
|
|
va_end(ap);
|
2014-09-17 21:48:14 +02:00
|
|
|
return;
|
|
|
|
|
2014-02-28 02:44:22 +01:00
|
|
|
}
|
2013-10-12 20:38:34 +02:00
|
|
|
|
|
|
|
void gsenddata(const u8 *data, int length, const char *filename)
|
|
|
|
{
|
|
|
|
if (!(geckoinit))return;
|
|
|
|
|
|
|
|
// First, send a "\x1b[2B]" line (this will tell geckoreader that binary data is comming up next)
|
|
|
|
const char *binary_data = "\x1b[2B]\n";
|
|
|
|
|
|
|
|
usb_sendbuffer_safe(1, binary_data, strlen(binary_data));
|
|
|
|
|
|
|
|
u8 filenamelength = filename == NULL ? 0 : strlen(filename);
|
|
|
|
|
|
|
|
// Send the length
|
|
|
|
usb_sendbuffer_safe(1, (u8 *) &length, 4);
|
|
|
|
usb_sendbuffer_safe(1, (u8 *) &filenamelength, 1);
|
|
|
|
usb_sendbuffer_safe(1, data, length);
|
|
|
|
if (filename != NULL)
|
|
|
|
{
|
|
|
|
usb_sendbuffer_safe(1, filename, strlen(filename));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char ascii(char s) {
|
|
|
|
if(s < 0x20) return '.';
|
|
|
|
if(s > 0x7E) return '.';
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InitGecko()
|
|
|
|
{
|
2015-03-13 09:16:55 +01:00
|
|
|
if(usb_isgeckoalive(EXI_CHANNEL_1))
|
2013-10-12 20:38:34 +02:00
|
|
|
{
|
|
|
|
usb_flush(EXI_CHANNEL_1);
|
2015-03-13 09:16:55 +01:00
|
|
|
geckoinit = true;
|
|
|
|
} else {
|
|
|
|
geckoinit = false;
|
2013-10-12 20:38:34 +02:00
|
|
|
}
|
2015-03-13 09:16:55 +01:00
|
|
|
return geckoinit;
|
2013-10-12 20:38:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* NO_DEBUG */
|