Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. /*
  3.  * Author: JohnXenox aka Aleksandr Igorevich.
  4.  *
  5.  * PlayNote_lib1.h
  6. */
  7.  
  8. #ifndef __PlayNote_lib1_h__
  9. #define __PlayNote_lib1_h__
  10.  
  11. static inline int initMemory(void)
  12. {
  13.     int size;
  14.  
  15.     __asm__ __volatile__("int $0x40":"=a"(size):"a"(68),"b"(11));
  16.     return size;
  17. }
  18.  
  19.  
  20. static inline void makeDelay(int time)
  21. {
  22.     __asm__ __volatile__("int $0x40"::"a"(5), "b"(time):"memory");
  23. }
  24.  
  25.  
  26. static inline void *openFile(int *length, const char *path)
  27. {
  28.     int *fd;
  29.  
  30.     __asm__ __volatile__ ("int $0x40":"=a"(fd), "=d"(*length):"a" (68), "b"(27),"c"(path));
  31.  
  32.     return fd;
  33. }
  34.  
  35.  
  36.  
  37. static inline void setCurrentPathToARawFile(char *dst_path, char *src_path, char* file_name)
  38. {
  39.     unsigned offset = 0;
  40.  
  41.     // cleans a dst path if not clean.
  42.     if(dst_path[offset] != 0)
  43.     {
  44.         for(; dst_path[offset] != 0; offset++) dst_path[offset] = 0;
  45.     }
  46.  
  47.     // copys current path into a buffer.
  48.     strcpy(dst_path, src_path);
  49.  
  50.     offset = 0;
  51.  
  52.     // go to the end of a string.
  53.     while(dst_path[offset] != 0) offset++;
  54.  
  55.     // clears all bytes to a character '/'.
  56.     for(; dst_path[offset] != '/'; offset--) dst_path[offset] = 0;
  57.  
  58.     // increments a variable.
  59.     offset++;
  60.  
  61.     // stores a name of a file in a buffer.
  62.     strcpy(dst_path + offset, file_name);
  63. }
  64.  
  65.  
  66.  
  67. void __attribute__ ((noinline)) printfOnADebugBoard(const char *format,...)
  68. {
  69.     va_list ap;
  70.     char log_board[300];
  71.  
  72.     va_start (ap, format);
  73.     tiny_vsnprintf(log_board, sizeof log_board, format, ap);
  74.     va_end(ap);
  75.  
  76.     char *str = log_board;
  77.  
  78.     while(*str) __asm__ __volatile__("int $0x40"::"a"(63), "b"(1), "c"(*str++));
  79. }
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90. #endif
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.