home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 4 / AACD04.ISO / AACD / Programming / envsof20 / source / syntax / debug.c next >
Encoding:
C/C++ Source or Header  |  1999-10-01  |  1.1 KB  |  55 lines

  1. /*
  2.  * debug.c -- Debugging trace routines.
  3.  *
  4.  * Copyright 1999 Thomas Aglassinger and others, see file "forum.txt"
  5.  */
  6.  
  7. #include "defs.h"
  8. #include "debug.h"
  9.  
  10. #ifdef _DCC
  11.  
  12. #include <exec/types.h>
  13. #include <clib/dos_protos.h>
  14. ULONG debugFH = NULL;
  15.  
  16. #else /* _DCC */
  17.  
  18. #include <stdio.h>
  19.  
  20. #endif /* _DCC */
  21.  
  22. Prototype void kputs(char *text);
  23. Prototype void kint(int number);
  24.  
  25.  
  26. // print debugging message; automatically opens a console
  27. // NOTE: The console is never closed, thus keeping a lock and resources.
  28. //       This is ugly, but I don't know how to use kprintf() in DICE.
  29. //       Nevertheless you can close the console window by clicking its
  30. //       close gadget.
  31. void kputs(char *text)
  32. {
  33. #ifdef _DCC
  34.    if (debugFH == NULL) {
  35.       debugFH = Open("con:9999//200/700/Debug/AUTO/INACTIVE/SCREEN*", 1006);
  36.    }
  37.    Write(debugFH, text, strlen(text));
  38. #else
  39.    printf("%s");
  40. #endif
  41. }
  42.  
  43. // display integer in debugging console
  44. void kint(int number)
  45. {
  46.    char *digits3 = "1234";
  47.    digits3[0] = (number / 1000) % 10 + '0';
  48.    digits3[1] = (number / 100) % 10 + '0';
  49.    digits3[2] = (number / 10) % 10 + '0';
  50.    digits3[3] = (number / 1) % 10 + '0';
  51.  
  52.    kputs(digits3);
  53. }
  54.  
  55.