Guest User

Untitled

a guest
Jul 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. /////////////
  2. vsprintf.c
  3. ////////////
  4.  
  5.  
  6. #ifdef DEBUG
  7. static char ascii(char s) {
  8. if(s < 0x20) return '.';
  9. if(s > 0x7E) return '.';
  10. return s;
  11. }
  12. #endif
  13.  
  14. void hexdump(void *d, int len)
  15. {
  16. #ifdef DEBUG
  17. u8 *data;
  18. int i, off;
  19. data = (u8*)d;
  20. for (off=0; off<len; off += 16)
  21. {
  22. dbgprintf("%08x ",off);
  23. for(i=0; i<16; i++)
  24. if((i+off)>=len)
  25. dbgprintf(" ");
  26. else
  27. dbgprintf("%02x ",data[off+i]);
  28.  
  29. dbgprintf(" ");
  30. for(i=0; i<16; i++)
  31. if((i+off)>=len) dbgprintf(" ");
  32. else dbgprintf("%c",ascii(data[off+i]));
  33. dbgprintf("\n");
  34. }
  35. #endif
  36. }
  37. /////////////////
  38. string.c
  39. //////////////////
  40.  
  41. #ifdef DEBUG
  42. int dbgprintf( const char *fmt, ...)
  43. {
  44.  
  45. if ( (*(vu32*)(HW_EXICTRL) & 1) == 0)
  46. return 0;
  47.  
  48. va_list args;
  49.  
  50. char *buffer = (char*)heap_alloc_aligned( 0, 2048, 32 );
  51.  
  52. va_start(args, fmt);
  53. vsprintf(buffer, fmt, args);
  54. va_end(args);
  55.  
  56. GeckoSendBuffer( buffer );
  57.  
  58. heap_free( 0, buffer );
  59.  
  60. return 1;
  61. }
  62. #endif
  63.  
  64.  
  65. ///////////////////////////
  66. global.h
  67. //////////////////////////
  68.  
  69.  
  70. //#define DEBUG 1
  71. #define false 0
  72. #define true 1
  73.  
  74. #define SHARED_PTR ((void *)0x13600000)
  75. #define SHARED_SIZE (0x18000)
  76.  
  77. #ifdef DEBUG
  78. int dbgprintf( const char *fmt, ...);
  79. #else
  80. #define dbgprintf(...)
  81. #endif
  82. #define debug_printf dbgprintf
  83.  
  84.  
  85. //////////////////////////
Add Comment
Please, Sign In to add comment