2010-06-03 18:37:14 +02:00
|
|
|
#include <gccore.h>
|
2009-12-03 02:06:09 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2009-11-01 00:23:27 +01:00
|
|
|
|
|
|
|
/* init-globals */
|
|
|
|
bool geckoinit = false;
|
2009-12-03 02:06:09 +01:00
|
|
|
bool textVideoInit = false;
|
2009-11-01 00:23:27 +01:00
|
|
|
|
|
|
|
#ifndef NO_DEBUG
|
2009-12-03 02:06:09 +01:00
|
|
|
#include <stdarg.h>
|
2009-11-01 00:23:27 +01:00
|
|
|
|
2009-12-03 02:06:09 +01:00
|
|
|
//using the gprintf from crediar because it is smaller than mine
|
2010-02-09 11:59:55 +01:00
|
|
|
void gprintf( const char *str, ... )
|
|
|
|
{
|
|
|
|
if (!(geckoinit))return;
|
2009-10-20 13:46:55 +02:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
char astr[4096];
|
2009-10-20 13:46:55 +02:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap,str);
|
2009-10-20 13:46:55 +02:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
vsprintf( astr, str, ap );
|
2009-10-20 13:46:55 +02:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
va_end(ap);
|
2009-10-20 13:46:55 +02:00
|
|
|
|
2010-09-16 12:22:24 +02:00
|
|
|
//usb_sendbuffer( 1, astr, strlen(astr) );
|
|
|
|
usb_sendbuffer_safe( 1, astr, strlen(astr) );
|
2010-06-03 18:36:25 +02:00
|
|
|
}
|
2009-10-20 13:46:55 +02:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
bool InitGecko()
|
|
|
|
{
|
|
|
|
u32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1);
|
|
|
|
if (geckoattached)
|
|
|
|
{
|
|
|
|
usb_flush(EXI_CHANNEL_1);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else return false;
|
2009-10-20 13:46:55 +02:00
|
|
|
}
|
|
|
|
|
2010-09-16 12:22:24 +02:00
|
|
|
static char ascii(char s)
|
|
|
|
{
|
|
|
|
if(s < 0x20)
|
|
|
|
return '.';
|
|
|
|
if(s > 0x7E)
|
|
|
|
return '.';
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void hexdump(void *d, int len)
|
|
|
|
{
|
|
|
|
u8 *data;
|
|
|
|
int i, off;
|
|
|
|
data = (u8*)d;
|
|
|
|
|
|
|
|
gprintf("\n 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF");
|
|
|
|
gprintf("\n==== =============================================== ================\n");
|
|
|
|
|
|
|
|
for (off=0; off<len; off += 16)
|
|
|
|
{
|
|
|
|
gprintf("%04x ",off);
|
|
|
|
for(i=0; i<16; i++)
|
|
|
|
if((i+off)>=len)
|
|
|
|
gprintf(" ");
|
|
|
|
else
|
|
|
|
gprintf("%02x ",data[off+i]);
|
|
|
|
|
|
|
|
gprintf(" ");
|
|
|
|
for(i=0; i<16; i++)
|
|
|
|
if((i+off)>=len)
|
|
|
|
gprintf(" ");
|
|
|
|
else
|
|
|
|
gprintf("%c",ascii(data[off+i]));
|
|
|
|
gprintf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-20 13:46:55 +02:00
|
|
|
|
2009-11-01 00:23:27 +01:00
|
|
|
#endif /* NO_DEBUG */
|