======== HUD Rendering ======== The HUD is rendered using function RenderHud: 802E3D2C/09ED2C. This function reads state to determine which HUD elements to display and calls several other subroutines and makes use of the PrintStr() and PrintInt() functions. ===== Functions ===== ==== Lives ==== RenderHudMarioLives: 802E3744/09E744 PrintStr(0x16, 0xD1, 0x80338380); // "," = Mario PrintStr(0x26, 0xD1, 0x80338384); // "*" = X PrintInt(0x36, 0xD1, 0x80338388, *0x8033b260); // "%d" ==== Coins ==== RenderHudCoins: 802E37A8/09E7A8 PrintStr(0xA8, 0xD1, 0x8033838C); // "+" = coin PrintStr(0xB8, 0xD1, 0x80338390); // "*" = X PrintInt(0xC6, 0xD1, 0x80338394, *0x8033b262); // "%d" ==== Stars ==== RenderHudStars: 802E380C/09E80C int showX = 0; // 0x1F($SP) if ((*0x803316d4 == 1) || (*0x8032d5d4 & 0x8 == 0)) { if (*0x8033b264 < 100) { showX = 1; } PrintStr(0xF2, 0xD1, 0x80338398); // "-" = star if (showX) { PrintStr(0x102, 0xD1, 0x8033839C); // "*" = X } PrintInt(0x102+14*showX, 0xD1, 0x803383A0, *0x8033B264); // "%d" } ==== Health ==== RenderHudHp: 802E3654/09E654 ==== Camera ==== ShowCameraStatus: 802E3B3C/09EB3C ==== Timer ==== RenderHudTimer: 802E395C/09E95C ===== Printing Functions ===== The two commonly used printing functions PrintStr and PrintInt accept null-terminated ASCII strings as input. It then uses a lookup table to determine which letter to display. This table is located in segment 02 alongside the letters. It notably contains missing entries for the letters J,Q,X,Z. ==== PrintStr ==== PrintStr: 802D6554/091554 void PrintStr(int X, int Y, char *string); ==== PrintInt ==== PrintInt: 802D62D8/0912D8 This is more of a generic printf() style function that accepts a format and variable arguments. void PrintInt(int X, int Y, char *format, ...); ===== Lookup Table ===== The lookup table for each of the ASCII characters is located at segment address 0x02007700 (80A856 in extended ROM) and contains entries for each 16x16 RGBA texture. The default table has null entries for J,Q,X,Z and uses some symbols for HUD characters. Before referencing the lookup table, the character in ASCII is converted to an offset within this table by the function at 802D6858/091858. int convertchar(int ascii) { if (ascii >= 0x41 && ascii < 0x5B) { // 'A' <= ascii <= 'Z' return ascii - 0x37; } else if (ascii >= 0x61 && ascii < 0x7B) { // 'a' <= ascii <= 'z' return ascii - 0x57; } else if (ascii >= 0x30 && ascii < 0x3A) { // '0' <= ascii <= '9' return ascii - 0x30; } else { switch (ascii) { case 0x20: return -1; break; // ' ' case 0x21: return 0x24; break; // '!' case 0x23: return 0x25; break; // '#' case 0x3F: return 0x26; break; // '?' case 0x26: return 0x27; break; // '&' case 0x25: return 0x28; break; // '%' case 0x2A: return 0x32; break; // '*' case 0x2B: return 0x33; break; // '+' case 0x2C: return 0x34; break; // ',' case 0x2D: return 0x35; break; // '-' case 0x2E: return 0x36; break; // '.' case 0x2F: return 0x37; break; // '/' } } return -1; } ^ Hex ^ A ^ Index ^ Seg Addr ^ T ^ Hex ^ A ^ Index ^ Seg Addr ^ T ^ Hex ^ A ^ Index ^ Seg Addr ^ T ^ | 20 | | - | - | | 40 | @ | - | - | | 60 | ` | - | - | | | 21 | ! | 24 | 00000000 | | 41 | A | 0A | 02001400 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x01400.png}} | 61 | a | 0A | 02001400 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x01400.png}} | | 22 | " | - | - | | 42 | B | 0B | 02001600 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x01600.png}} | 62 | b | 0B | 02001600 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x01600.png}} | | 23 | # | 25 | 00000000 | | 43 | C | 0C | 02001800 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x01800.png}} | 63 | c | 0C | 02001800 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x01800.png}} | | 24 | $ | - | - | | 44 | D | 0D | 02001A00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x01A00.png}} | 64 | d | 0D | 02001A00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x01A00.png}} | | 25 | % | 28 | 00000000 | | 45 | E | 0E | 02001C00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x01C00.png}} | 65 | e | 0E | 02001C00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x01C00.png}} | | 26 | & | 27 | 00000000 | | 46 | F | 0F | 02001E00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x01E00.png}} | 66 | f | 0F | 02001E00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x01E00.png}} | | 27 | ' | - | - | | 47 | G | 10 | 02002000 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02000.png}} | 67 | g | 10 | 02002000 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02000.png}} | | 28 | ( | - | - | | 48 | H | 11 | 02002200 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02200.png}} | 68 | h | 11 | 02002200 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02200.png}} | | 29 | ) | - | - | | 49 | I | 12 | 02002400 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02400.png}} | 69 | i | 12 | 02002400 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02400.png}} | | 2A | * | 32 | 02004200 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x04200.png}} | 4A | J | 13 | 00000000 | | 6A | j | 13 | 00000000 | | | 2B | + | 33 | 02004400 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x04400.png}} | 4B | K | 14 | 02002600 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02600.png}} | 6B | k | 14 | 02002600 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02600.png}} | | 2C | , | 34 | 02004600 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x04600.png}} | 4C | L | 15 | 02002800 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02800.png}} | 6C | l | 15 | 02002800 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02800.png}} | | 2D | - | 35 | 02004800 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x04800.png}} | 4D | M | 16 | 02002A00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02A00.png}} | 6D | m | 16 | 02002A00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02A00.png}} | | 2E | . | 36 | 00000000 | | 4E | N | 17 | 02002C00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02C00.png}} | 6E | n | 17 | 02002C00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02C00.png}} | | 2F | / | 37 | 00000000 | | 4F | O | 18 | 02002E00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02E00.png}} | 6F | o | 18 | 02002E00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x02E00.png}} | | 30 | 0 | 00 | 02000000 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x00000.png}} | 50 | P | 19 | 02003000 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x03000.png}} | 70 | p | 19 | 02003000 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x03000.png}} | | 31 | 1 | 01 | 02000200 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x00200.png}} | 51 | Q | 1A | 00000000 | | 71 | q | 1A | 00000000 | | | 32 | 2 | 02 | 02000400 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x00400.png}} | 52 | R | 1B | 02003200 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x03200.png}} | 72 | r | 1B | 02003200 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x03200.png}} | | 33 | 3 | 03 | 02000600 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x00600.png}} | 53 | S | 1C | 02003400 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x03400.png}} | 73 | s | 1C | 02003400 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x03400.png}} | | 34 | 4 | 04 | 02000800 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x00800.png}} | 54 | T | 1D | 02003600 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x03600.png}} | 74 | t | 1D | 02003600 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x03600.png}} | | 35 | 5 | 05 | 02000A00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x00A00.png}} | 55 | U | 1E | 02003800 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x03800.png}} | 75 | u | 1E | 02003800 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x03800.png}} | | 36 | 6 | 06 | 02000C00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x00C00.png}} | 56 | V | 1F | 00000000 | | 76 | v | 1F | 00000000 | | | 37 | 7 | 07 | 02000E00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x00E00.png}} | 57 | W | 20 | 02003A00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x03A00.png}} | 77 | w | 20 | 02003A00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x03A00.png}} | | 38 | 8 | 08 | 02001000 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x01000.png}} | 58 | X | 21 | 00000000 | | 78 | x | 21 | 00000000 | | | 39 | 9 | 09 | 02001200 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x01200.png}} | 59 | Y | 22 | 02003C00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x03C00.png}} | 79 | y | 22 | 02003C00 | {{http://queueram.com/n64/sm64/textures/textures/font_graphics.0x03C00.png}} | | 3A | : | - | - | | 5A | Z | 23 | 00000000 | | 7A | z | 23 | 00000000 | | | 3B | ; | - | - | | 5B | [ | - | - | | 7B | { | - | - | | | 3C | < | - | - | | 5C | \ | - | - | | 7C | %%|%% | - | - | | | 3D | = | - | - | | 5D | ] | - | - | | 7D | } | - | - | | | 3E | > | - | - | | 5E | %%^%% | - | - | | 7E | ~ | - | - | | | 3F | ? | 26 | 00000000 | | 5F | _ | - | - | | 7F | | - | - | | ===== References ===== * https://sites.google.com/site/kazemario64/printstr-x-y-string