Advertisement
tiger717

Tmp (for lowlevel forum)

May 28th, 2011
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.97 KB | None | 0 0
  1. #include "kernel.h"
  2.  
  3. void init(void)
  4. {
  5.     clearscreen(); // Bildschirm löschen
  6.     printf(".....................................\n");
  7.     printf("Halihalo\n");
  8.     printf("nochma\n");
  9. }
  10.  
  11.  
  12. ############################################################
  13.  
  14. #include "video.h"
  15.  
  16. #define videobuffer 2500
  17.  
  18. /*
  19.  * Standard-Ein/Ausgabe
  20.  * Copyright (c) Tobias Markus 2011
  21.  * BUILDSTAMP 28/05/2011
  22.  */
  23.  
  24. // 80 Zeichen 25 Zeilen
  25.  
  26. static unsigned char buffer[videobuffer];
  27. static unsigned char pointerx = 0;
  28. static unsigned char pointery = 0;
  29. static unsigned char pointer;
  30.  
  31. void printf(char hw[])
  32. {
  33.     printreal((unsigned char*) hw);
  34. }
  35.  
  36. void printreal(unsigned char hw[])
  37. {
  38.     int i;
  39.    
  40.     // C-Strings haben ein Nullbyte als Abschluss
  41.     for (i = 0; hw[i] != '\0'; i++) {
  42.         putc(hw[i]);
  43.     }
  44.    
  45.     if ((pointery == 25 && pointerx == 80) || pointery == 26) { wraparound(); pointery = 25; pointerx = 0; }
  46. }
  47.  
  48. void putc(unsigned char output)
  49. {
  50.     getpointer();
  51.    
  52.     if (output != '\n' && output != '\0') {
  53.         // Zeichen in den Buffer kopieren
  54.         buffer[pointer] = (unsigned char) output;
  55.        
  56.         // 0x07 = Hellgrau auf Schwarz
  57.         buffer[pointer + 1] = 0x07;
  58.        
  59.         pointerx++;
  60.     } else if (output == '\n') {
  61.         newline();
  62.     }
  63.    
  64.     if (pointerx == 80) { newline(); }
  65.    
  66.     refresh();
  67. }
  68.  
  69. void refresh()
  70. {
  71.     int i;
  72.     char* video = (char*) 0xb8000;
  73.    
  74.     for (i = 0; i != 2500; i++) {
  75.         video[i] = buffer[i];
  76.     }
  77. }
  78.  
  79. int getpointer()
  80. {
  81.     pointer = ((pointery * 80) + pointerx) * 2;
  82.     return pointer;
  83. }
  84.  
  85. char getcharfrompointer()
  86. {
  87.     getpointer();
  88.     return buffer[pointer];
  89. }
  90.  
  91. void clearscreen()
  92. {
  93.     int i;
  94.     for (i = 0; i != 2000; i++)
  95.     {
  96.         buffer[i] = (int) 0x0;
  97.     }
  98.     refresh();
  99. }
  100.  
  101. void wraparound()
  102. {
  103.     int i,x;
  104.    
  105.     for (i = 0; i != 25; i++)
  106.     {
  107.         for (x = 0; x != 80; x++)
  108.         {
  109.             buffer[((i * 80) + x) * 2] = buffer[((i * 80) + x + 80) * 2];
  110.         }
  111.     }
  112.     for (i = 1920; i != 2000; i++)
  113.     {
  114.         buffer[i] = (int) 0x0;
  115.     }
  116.     refresh();
  117. }
  118.  
  119. void newline()
  120. {
  121.     pointerx = 0;
  122.     pointery++;
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement