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

Untitled

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