- char c, pad = ' ';
- int minSize = 0;
- char tmpBuf[34]; // For Integers
- char *p = NULL;
- int isLongLong = 0;
- Uint64 arg;
-
- while((c = *format++) != 0)
- {
- // Non control character
- if( c != '%' ) {
- E9(c);
- continue;
- }
-
- c = *format++;
-
- // Literal %
- if(c == '%') {
- E9('%');
- continue;
- }
-
- // Pointer
- if(c == 'p') {
- Uint ptr = va_arg(*args, Uint);
- E9('*'); E9('0'); E9('x');
- p = tmpBuf;
- itoa(p, ptr, 16, BITS/4, '0');
- goto printString;
- }
-
- // Get Argument
- arg = va_arg(*args, Uint);
-
- // Padding
- if(c == '0') {
- pad = '0';
- c = *format++;
- } else
- pad = ' ';
-
- // Minimum length
- minSize = 1;
- if('1' <= c && c <= '9')
- {
- minSize = 0;
- while('0' <= c && c <= '9')
- {
- minSize *= 10;
- minSize += c - '0';
- c = *format++;
- }
- }
-
- // Long (default)
- isLongLong = 0;
- if(c == 'l') {
- c = *format++;
- if(c == 'l') {
- #if BITS == 32
- arg |= va_arg(*args, Uint);
- #endif
- c = *format++;
- isLongLong = 1;
- }
- }
-
- p = tmpBuf;
- switch (c) {
- case 'd':
- case 'i':
- if( (isLongLong && arg >> 63) || (!isLongLong && arg >> 31) ) {
- E9('-');
- arg = -arg;
- }
- itoa(p, arg, 10, minSize, pad);
- goto printString;
- case 'u':
- itoa(p, arg, 10, minSize, pad);
- goto printString;
- case 'x':
- itoa(p, arg, 16, minSize, pad);
- goto printString;
- case 'o':
- itoa(p, arg, 8, minSize, pad);
- goto printString;
- case 'b':
- itoa(p, arg, 2, minSize, pad);
- goto printString;
-
- case 'B': //Boolean
- if(arg) E9_Str("True");
- else E9_Str("False");
- break;
-
- case 's':
- p = (char*)(Uint)arg;
- printString:
- if(!p) p = "(null)";
- while(*p) E9(*p++);
- break;
-
- default: E9(arg); break;
- }
- }
+ char buf[DEBUG_MAX_LINE_LEN];
+ int len;
+ buf[DEBUG_MAX_LINE_LEN-1] = 0;
+ len = vsnprintf(buf, DEBUG_MAX_LINE_LEN-1, format, args);
+ //if( len < DEBUG_MAX_LINE )
+ // do something
+ Debug_Puts(1, buf);
+ return ;