- typedef unsigned short uint16_t;
- typedef unsigned long uint32_t;
- //Macros (used for writing to memory addresses)
- #define SET_REG16(x, y) (*((volatile uint16_t*)(x)) = (y))
- #define SET_REG32(x, y) (*((volatile uint32_t*)(x)) = (y))
- //End of Macros
- #define BASE_FB_ADDR 0x0FD00000
- #define FIRST_LINE_ENDING 0x4FF
- #define COLOR 0xFFFF0000
- void writeA();
- void writeB();
- void writeC();
- void writeD();
- void writeE();
- void writeF();
- void writeG();
- void writeH();
- void writeI();
- void writeJ();
- void writeletter(int letter);
- void printfb(char *strToConvert);
- //void newline();
- void writeSpace(int spaces);
- void newline();
- //uint32_t line_endings[48];
- uint32_t i;
- unsigned int curser_location;
- unsigned int line_count;
- int fbuffer;
- int line_location;
- int main() { //notice main()
- fbuffer=BASE_FB_ADDR;
- curser_location=0x0;
- line_count=0x0;
- /*writeA();
- writeB();
- writeC();
- writeD();
- writeE();
- writeF();
- writeG();
- writeH();
- writeI();
- writeJ();
- writeSpace(5);
- writeA();
- writeB();
- writeC();
- writeD();
- writeE();
- writeF();
- writeG();
- writeH();
- writeI();
- writeJ();*/
- printfb("ABCDEFG ABCDEFGHIJ");
- newline();
- printfb("ABCDEFGH ABCDEFGHIJ");
- }
- void printfb(char *strToConvert)
- {
- char *p;
- p = strToConvert;
- unsigned int i=0;
- for(i = 0; p[ i ]; i++){
- int clett=p[i];
- writeletter(clett);
- }
- }
- void writeA() {
- //Print Letter A
- /*for(i = 0;i < 480; i++) {
- if(curser_location + fbuffer + 0x00000A00 == line_endings[i])
- curser_location += 1 + 0x1900;
- }
- for(i = 0;i < 480; i++) {
- if(curser_location + fbuffer + 0x00000A04 == line_endings[i])
- curser_location += 2 + 0x1900;
- }
- for(i = 0;i < 480; i++) {
- if(curser_location + fbuffer + 0x00000A08 == line_endings[i])
- curser_location += 3 + 0x1900;
- }
- for(i = 0;i < 480; i++) {
- if(curser_location + fbuffer + 0x00000A0C == line_endings[i])
- curser_location += 4 + 0x1900;
- }*/
- SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000050C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A04,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A08,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A0C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F0C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000140C,COLOR);
- curser_location += 0x5 * 4;
- }
- void writeB() {
- //Print Letter B
- SET_REG32(curser_location + fbuffer + 0x00000000,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000050C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A04,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A08,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F0C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001404,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001408,COLOR);
- curser_location += 0x5 * 4;
- }
- void writeC() {
- SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000000C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000010,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001404,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001408,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000140C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001410,COLOR);
- curser_location += 0x6 * 4;
- }
- void writeD() {
- SET_REG32(curser_location + fbuffer + 0x00000000,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000050C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A0C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F0C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001404,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001408,COLOR);
- curser_location += 0x5 * 4;
- }
- void writeE() {
- SET_REG32(curser_location + fbuffer + 0x00000000,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000000C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A04,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A08,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001404,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001408,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000140C,COLOR);
- curser_location += 0x5 * 4;
- }
- void writeF() {
- SET_REG32(curser_location + fbuffer + 0x00000000,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000000C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A04,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A08,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
- curser_location += 0x5 * 4;
- }
- void writeG() {
- SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000000C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A08,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A0C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F0C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001404,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001408,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000140C,COLOR);
- curser_location += 0x5 * 4;
- }
- void writeH() {
- SET_REG32(curser_location + fbuffer + 0x00000000,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000000C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000500,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000050C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A04,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A08,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A0C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F0C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000140C,COLOR);
- curser_location += 0x5 * 4;
- }
- void writeI() {
- SET_REG32(curser_location + fbuffer + 0x00000000,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000504,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A04,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F04,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001404,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001408,COLOR);
- curser_location += 0x4 * 4;
- }
- void writeJ() {
- SET_REG32(curser_location + fbuffer + 0x00000000,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000004,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000008,COLOR);
- SET_REG32(curser_location + fbuffer + 0x0000000C,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000010,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000508,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000A08,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F00,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00000F08,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001400,COLOR);
- SET_REG32(curser_location + fbuffer + 0x00001404,COLOR);
- curser_location += 0x6 * 4;
- }
- void writeSpace(int spaces) {
- curser_location += spaces*4;
- }
- void writeletter(int letter) {
- unsigned int remain=0x500*line_count;
- if (curser_location==remain) {
- newline();
- }
- if(letter=='A'){
- writeA();
- }
- if(letter=='B'){
- writeB();
- }
- if(letter=='C'){
- writeC();
- }
- if(letter=='D'){
- writeD();
- }
- if(letter=='E'){
- writeE();
- }
- if(letter=='F'){
- writeF();
- }
- if(letter=='G'){
- writeG();
- }
- if(letter=='H'){
- writeH();
- }
- if(letter=='I'){
- writeI();
- }
- if(letter=='J'){
- writeJ();
- }
- if (letter==' ') {
- writeSpace(5);
- }
- }
- void newline(){
- line_count++;
- fbuffer+=0x4D0*(line_count*4);
- }