Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 9.89 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. typedef unsigned short uint16_t;
  2. typedef unsigned long uint32_t;
  3.  
  4.  
  5.  
  6. //Macros (used for writing to memory addresses)
  7. #define SET_REG16(x, y) (*((volatile uint16_t*)(x)) = (y))
  8. #define SET_REG32(x, y) (*((volatile uint32_t*)(x)) = (y))
  9. //End of Macros
  10.  
  11. #define BASE_FB_ADDR 0x0FD00000
  12. #define FIRST_LINE_ENDING 0x4FF
  13. #define COLOR 0xFFFF0000
  14.  
  15. void writeA();
  16. void writeB();
  17. void writeC();
  18. void writeD();
  19. void writeE();
  20. void writeF();
  21. void writeG();
  22. void writeH();
  23. void writeI();
  24. void writeJ();
  25. void writeletter(int letter);
  26. void printfb(char *strToConvert);
  27. //void newline();
  28. void writeSpace(int spaces);
  29. void newline();
  30. //uint32_t line_endings[48];
  31.  
  32.  
  33.  
  34. uint32_t i;
  35. unsigned int  curser_location;
  36. unsigned int  line_count;
  37. int fbuffer;
  38. int line_location;
  39. int main() {  //notice main()
  40.        
  41.         fbuffer=BASE_FB_ADDR;
  42.         curser_location=0x0;
  43.         line_count=0x0;
  44.        
  45.        
  46.        
  47.         /*writeA();
  48.         writeB();
  49.         writeC();
  50.         writeD();
  51.         writeE();
  52.         writeF();
  53.         writeG();
  54.         writeH();
  55.         writeI();
  56.         writeJ();
  57.         writeSpace(5);
  58.         writeA();
  59.         writeB();
  60.         writeC();
  61.         writeD();
  62.         writeE();
  63.         writeF();
  64.         writeG();
  65.         writeH();
  66.         writeI();
  67.         writeJ();*/
  68.         printfb("ABCDEFG ABCDEFGHIJ");
  69.         newline();
  70.         printfb("ABCDEFGH ABCDEFGHIJ");
  71.        
  72.        
  73.  
  74.        
  75.        
  76.        
  77. }
  78.  
  79. void printfb(char *strToConvert)
  80. {
  81.         char *p;
  82.         p = strToConvert;
  83.         unsigned int i=0;
  84.         for(i = 0; p[ i ]; i++){
  85.                 int clett=p[i];
  86.                 writeletter(clett);
  87.         }
  88.        
  89. }
  90.  
  91. void writeA() {
  92.        
  93.         //Print Letter A
  94.        
  95.         /*for(i = 0;i < 480; i++) {
  96.          
  97.          if(curser_location + fbuffer + 0x00000A00 == line_endings[i])
  98.          curser_location += 1 + 0x1900;
  99.          
  100.          }
  101.          
  102.          for(i = 0;i < 480; i++) {
  103.          
  104.          if(curser_location + fbuffer + 0x00000A04 == line_endings[i])
  105.          curser_location += 2 + 0x1900;
  106.          
  107.          }
  108.          
  109.          for(i = 0;i < 480; i++) {
  110.          
  111.          if(curser_location + fbuffer + 0x00000A08 == line_endings[i])
  112.          curser_location += 3 + 0x1900;
  113.          
  114.          }
  115.          
  116.          for(i = 0;i < 480; i++) {
  117.          
  118.          if(curser_location + fbuffer + 0x00000A0C == line_endings[i])
  119.          curser_location += 4 + 0x1900;
  120.          
  121.          }*/
  122.        
  123.        
  124.        
  125.         SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
  126.         SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
  127.         SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
  128.         SET_REG32(curser_location + fbuffer + 0x0000050C,COLOR);
  129.         SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
  130.         SET_REG32(curser_location + fbuffer + 0x00000A04,COLOR);
  131.         SET_REG32(curser_location + fbuffer + 0x00000A08,COLOR);
  132.         SET_REG32(curser_location + fbuffer + 0x00000A0C,COLOR);
  133.         SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
  134.         SET_REG32(curser_location + fbuffer + 0x00000F0C,COLOR);
  135.         SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
  136.         SET_REG32(curser_location + fbuffer + 0x0000140C,COLOR);
  137.        
  138.         curser_location += 0x5 * 4;
  139. }
  140. void writeB() {
  141.        
  142.         //Print Letter B
  143.        
  144.         SET_REG32(curser_location + fbuffer + 0x00000000,COLOR);
  145.         SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
  146.         SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
  147.         SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
  148.         SET_REG32(curser_location + fbuffer + 0x0000050C,COLOR);
  149.         SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
  150.         SET_REG32(curser_location + fbuffer + 0x00000A04,COLOR);
  151.         SET_REG32(curser_location + fbuffer + 0x00000A08,COLOR);
  152.         SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
  153.         SET_REG32(curser_location + fbuffer + 0x00000F0C,COLOR);
  154.         SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
  155.         SET_REG32(curser_location + fbuffer + 0x00001404,COLOR);
  156.         SET_REG32(curser_location + fbuffer + 0x00001408,COLOR);
  157.        
  158.         curser_location += 0x5 * 4;
  159. }
  160.  
  161. void writeC() {
  162.        
  163.         SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
  164.         SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
  165.         SET_REG32(curser_location + fbuffer + 0x0000000C,COLOR);
  166.         SET_REG32(curser_location + fbuffer + 0x00000010,COLOR);
  167.         SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
  168.         SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
  169.         SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
  170.         SET_REG32(curser_location + fbuffer + 0x00001404,COLOR);
  171.         SET_REG32(curser_location + fbuffer + 0x00001408,COLOR);
  172.         SET_REG32(curser_location + fbuffer + 0x0000140C,COLOR);
  173.         SET_REG32(curser_location + fbuffer + 0x00001410,COLOR);
  174.         curser_location += 0x6 * 4;
  175.        
  176.        
  177. }
  178.  
  179. void writeD() {
  180.        
  181.         SET_REG32(curser_location + fbuffer + 0x00000000,COLOR);
  182.         SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
  183.         SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
  184.         SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
  185.         SET_REG32(curser_location + fbuffer + 0x0000050C,COLOR);
  186.         SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
  187.         SET_REG32(curser_location + fbuffer + 0x00000A0C,COLOR);
  188.         SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
  189.         SET_REG32(curser_location + fbuffer + 0x00000F0C,COLOR);
  190.         SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
  191.         SET_REG32(curser_location + fbuffer + 0x00001404,COLOR);
  192.         SET_REG32(curser_location + fbuffer + 0x00001408,COLOR);
  193.         curser_location += 0x5 * 4;
  194.        
  195. }
  196.  
  197. void writeE() {
  198.        
  199.         SET_REG32(curser_location + fbuffer + 0x00000000,COLOR);
  200.         SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
  201.         SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
  202.         SET_REG32(curser_location + fbuffer + 0x0000000C,COLOR);
  203.         SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
  204.         SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
  205.         SET_REG32(curser_location + fbuffer + 0x00000A04,COLOR);
  206.         SET_REG32(curser_location + fbuffer + 0x00000A08,COLOR);
  207.         SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
  208.         SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
  209.         SET_REG32(curser_location + fbuffer + 0x00001404,COLOR);
  210.         SET_REG32(curser_location + fbuffer + 0x00001408,COLOR);
  211.         SET_REG32(curser_location + fbuffer + 0x0000140C,COLOR);
  212.         curser_location += 0x5 * 4;
  213.        
  214. }
  215.  
  216. void writeF() {
  217.        
  218.         SET_REG32(curser_location + fbuffer + 0x00000000,COLOR);
  219.         SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
  220.         SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
  221.         SET_REG32(curser_location + fbuffer + 0x0000000C,COLOR);
  222.         SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
  223.         SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
  224.         SET_REG32(curser_location + fbuffer + 0x00000A04,COLOR);
  225.         SET_REG32(curser_location + fbuffer + 0x00000A08,COLOR);
  226.         SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
  227.         SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
  228.        
  229.         curser_location += 0x5 * 4;
  230.        
  231. }
  232.  
  233. void writeG() {
  234.        
  235.         SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
  236.         SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
  237.         SET_REG32(curser_location + fbuffer + 0x0000000C,COLOR);
  238.         SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
  239.         SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
  240.         SET_REG32(curser_location + fbuffer + 0x00000A08,COLOR);
  241.         SET_REG32(curser_location + fbuffer + 0x00000A0C,COLOR);
  242.         SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
  243.         SET_REG32(curser_location + fbuffer + 0x00000F0C,COLOR);
  244.         SET_REG32(curser_location + fbuffer + 0x00001404,COLOR);
  245.         SET_REG32(curser_location + fbuffer + 0x00001408,COLOR);
  246.         SET_REG32(curser_location + fbuffer + 0x0000140C,COLOR);
  247.        
  248.         curser_location += 0x5 * 4;
  249.        
  250. }
  251.  
  252. void writeH() {
  253.        
  254.         SET_REG32(curser_location + fbuffer + 0x00000000,COLOR);
  255.         SET_REG32(curser_location + fbuffer + 0x0000000C,COLOR);
  256.         SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
  257.         SET_REG32(curser_location + fbuffer + 0x0000050C,COLOR);
  258.         SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
  259.         SET_REG32(curser_location + fbuffer + 0x00000A04,COLOR);
  260.         SET_REG32(curser_location + fbuffer + 0x00000A08,COLOR);
  261.         SET_REG32(curser_location + fbuffer + 0x00000A0C,COLOR);
  262.         SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
  263.         SET_REG32(curser_location + fbuffer + 0x00000F0C,COLOR);
  264.         SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
  265.         SET_REG32(curser_location + fbuffer + 0x0000140C,COLOR);
  266.        
  267.        
  268.         curser_location += 0x5 * 4;
  269.        
  270. }
  271.  
  272. void writeI() {
  273.        
  274.         SET_REG32(curser_location + fbuffer + 0x00000000,COLOR);
  275.         SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
  276.         SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
  277.         SET_REG32(curser_location + fbuffer + 0x00000504,COLOR);
  278.         SET_REG32(curser_location + fbuffer + 0x00000A04,COLOR);
  279.         SET_REG32(curser_location + fbuffer + 0x00000F04,COLOR);
  280.         SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
  281.         SET_REG32(curser_location + fbuffer + 0x00001404,COLOR);
  282.         SET_REG32(curser_location + fbuffer + 0x00001408,COLOR);
  283.        
  284.        
  285.         curser_location += 0x4 * 4;
  286.        
  287. }
  288.  
  289. void writeJ() {
  290.        
  291.        
  292.         SET_REG32(curser_location + fbuffer + 0x00000000,COLOR);
  293.         SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
  294.         SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
  295.         SET_REG32(curser_location + fbuffer + 0x0000000C,COLOR);       
  296.         SET_REG32(curser_location + fbuffer + 0x00000010,COLOR);
  297.         SET_REG32(curser_location + fbuffer + 0x00000508,COLOR);
  298.         SET_REG32(curser_location + fbuffer + 0x00000A08,COLOR);
  299.         SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
  300.         SET_REG32(curser_location + fbuffer + 0x00000F08,COLOR);
  301.         SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
  302.         SET_REG32(curser_location + fbuffer + 0x00001404,COLOR);
  303.         curser_location += 0x6 * 4;
  304. }
  305.  
  306. void writeSpace(int spaces) {
  307.        
  308.         curser_location += spaces*4;
  309.        
  310. }
  311.  
  312.  
  313. void writeletter(int letter) {
  314.         unsigned int remain=0x500*line_count;
  315.         if (curser_location==remain) {
  316.                 newline();
  317.         }
  318.        
  319.         if(letter=='A'){
  320.                 writeA();
  321.         }
  322.         if(letter=='B'){
  323.                 writeB();
  324.         }
  325.         if(letter=='C'){
  326.                 writeC();
  327.         }
  328.         if(letter=='D'){
  329.                 writeD();
  330.         }
  331.         if(letter=='E'){
  332.                 writeE();
  333.         }
  334.         if(letter=='F'){
  335.                 writeF();
  336.         }
  337.         if(letter=='G'){
  338.                 writeG();
  339.         }
  340.         if(letter=='H'){
  341.                 writeH();
  342.         }
  343.         if(letter=='I'){
  344.                 writeI();
  345.         }
  346.         if(letter=='J'){
  347.                 writeJ();
  348.         }
  349.         if (letter==' ') {
  350.                 writeSpace(5);
  351.         }
  352.  
  353. }
  354.  
  355. void newline(){
  356.         line_count++;
  357.         fbuffer+=0x4D0*(line_count*4);
  358. }