Subversion Repositories HelenOS

Rev

Rev 1787 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1739 decky 1
#include "font-8x16.h"
2
 
3
#define FB_REG "r8"
4
#define SCAN_REG "r9"
5
 
6
#define ADDR_REG "r10"
7
#define FG_REG "r11"
8
#define BG_REG "r12"
9
 
10
#define FG_COLOR 0xffffffff
11
#define BG_COLOR 0x00000000
12
 
13
#define BPP 4
14
 
15
void print_macro_init(void) {
16
    printf(".macro DEBUG_INIT\n");
17
    printf("#ifdef CONFIG_DEBUG\n");
18
    printf("\tlis %s, %d\n", FG_REG, FG_COLOR >> 16);
19
    printf("\tori %s, %s, %d\n", FG_REG, FG_REG, FG_COLOR & 0xffff);
20
    printf("\t\n");
21
    printf("\tlis %s, %d\n", BG_REG, BG_COLOR >> 16);
22
    printf("\tori %s, %s, %d\n", BG_REG, BG_REG, BG_COLOR & 0xffff);
23
    printf("\t\n");
24
    printf("\tmr %s, %s\n", ADDR_REG, FB_REG);
25
    printf("#endif\n");
26
    printf(".endm\n");
27
}
28
 
29
void print_macro(const char *name) {
30
    printf(".macro DEBUG_%s\n", name);
31
    printf("#ifdef CONFIG_DEBUG\n");
32
 
33
    unsigned int y;
34
    for (y = 0; y < FONT_SCANLINES; y++) {
35
        printf("\t\n");
36
 
37
        if (y > 0)
38
            printf("\tadd %s, %s, %s\n", ADDR_REG, ADDR_REG, SCAN_REG);
39
 
40
        unsigned int i;
41
        for (i = 0; name[i] != 0; i++) {
42
            char c = name[i];
43
 
44
            unsigned int x;
45
            for (x = 0; x < FONT_WIDTH; x++) {
46
                if (((fb_font[c * FONT_SCANLINES + y] >> (FONT_WIDTH - x)) & 1) == 1)
47
                    printf("\tstw %s, %d(%s)\n", FG_REG, (i * FONT_WIDTH + x) * BPP, ADDR_REG);
48
                else
49
                    printf("\tstw %s, %d(%s)\n", BG_REG, (i * FONT_WIDTH + x) * BPP, ADDR_REG);
50
            }
51
        }
52
    }
53
 
54
    printf("#endif\n");
55
    printf(".endm\n");
56
}
57
 
58
int main(int argc, char *argv[]) {
59
    print_macro_init();
60
 
61
    int i;
62
    for (i = 1; i < argc; i++) {
63
        printf("\n");
64
        print_macro(argv[i]);
65
    }
66
 
67
    return 0;
68
}