summaryrefslogtreecommitdiff
path: root/src/code/z_moji.c
blob: 123608bba40373e6627cdd315eb350e5d65b4159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "global.h"

u32 sFontColorRed = 255;
u32 sFontColorGreen = 255;
u32 sFontColorBlue = 255;
u32 sFontColorAlpha = 255;
s32 D_80120120 = 0;
s32 D_80120124 = 0;

UNK_TYPE D_8015FFC0;
UNK_TYPE D_8015FFC4;

void func_8007B910(u32 red, u32 green, u32 blue, u32 alpha) {
    sFontColorRed = red;
    sFontColorGreen = green;
    sFontColorBlue = blue;
    sFontColorAlpha = alpha;
}

void func_8007B934(s32 arg0, s32 arg1) {
    if (arg0 > 39) {
        D_80120120 = 39 * 8;
    } else if (arg0 < 0) {
        D_80120120 = 0;
    } else {
        D_80120120 = arg0 * 8;
    }

    if (arg1 > 29) {
        D_80120124 = 29 * 8;
    } else if (arg1 < 0) {
        D_80120124 = 0;
    } else {
        D_80120124 = arg1 * 8;
    }
}

void func_8007B9A4(GraphicsContext* gfxCtx, u8 arg1) {
    s32 pad[2];

    OPEN_DISPS(gfxCtx, "../z_moji.c", 86);

    if ((u32)gLetterTLUT & 0xF) {
        osSyncPrintf("moji_tlut --> %X\n", gLetterTLUT);
    }

    if (D_8015FFC0 != (arg1 & 3)) {
        gDPLoadTLUT(POLY_OPA_DISP++, 16, 256, &gLetterTLUT[arg1 & 3]);
        D_8015FFC0 = arg1 & 3;
    }

    gSPTextureRectangle(POLY_OPA_DISP++, D_80120120 << 2, D_80120124 << 2, (D_80120120 + 8) << 2, (D_80120124 + 8) << 2,
                        G_TX_RENDERTILE, (u16)(arg1 & 4) * 64, (u16)(arg1 >> 3) * 256, 1024, 1024);

    CLOSE_DISPS(gfxCtx, "../z_moji.c", 123);
}

void func_8007BBA8(GraphicsContext* gfxCtx, u8* arg1) {
    s32 i;

    OPEN_DISPS(gfxCtx, "../z_moji.c", 137);

    if ((u32)gFontFF & 0xF) {
        osSyncPrintf("font_ff --> %X\n", gFontFF);
    }

    gDPPipeSync(POLY_OPA_DISP++);
    gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sFontColorRed, sFontColorGreen, sFontColorBlue, sFontColorAlpha);

    gDPSetTextureImage(POLY_OPA_DISP++, G_IM_FMT_CI, G_IM_SIZ_16b, 1, (s32)gFontFF);
    gDPSetTile(POLY_OPA_DISP++, G_IM_FMT_CI, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP,
               G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
    gDPLoadSync(POLY_OPA_DISP++);
    gDPLoadBlock(POLY_OPA_DISP++, G_TX_LOADTILE, 0, 0, 511, 2048);
    gDPPipeSync(POLY_OPA_DISP++);
    gDPSetTile(POLY_OPA_DISP++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP,
               G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
    gDPSetTileSize(POLY_OPA_DISP++, G_TX_RENDERTILE, 0, 0, 60, 508);

    D_8015FFC0 = -1;

    for (i = 0; arg1[i] != 0; i++) {
        switch (arg1[i]) {
            case 9:
                D_80120120 = (((D_80120120 / 8) / 8) + 1) * 8 * 8;
                if (D_80120120 >= SCREEN_WIDTH) {
                    D_80120120 = 0;
                    D_80120124 += 8;
                    if (D_80120124 >= SCREEN_HEIGHT) {
                        D_80120124 = 0;
                    }
                }
                break;
            case 10:
            case 13:
                D_80120120 = 0;
                D_80120124 += 8;
                if (D_80120124 >= SCREEN_HEIGHT) {
                    D_80120124 = 0;
                }
                break;
            default:
                func_8007B9A4(gfxCtx, arg1[i]);
                D_80120120 += 8;
        }
    }

    CLOSE_DISPS(gfxCtx, "../z_moji.c", 181);
}