|
2 | 2 | #include "stdbool.h" |
3 | 3 | #include "save.h" |
4 | 4 |
|
| 5 | +// no support for kana since they're not part of the message charset |
| 6 | +char FILENAME_ENCODING[256] = { |
| 7 | + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '?', '?', '?', '?', '?', '?', |
| 8 | + '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', |
| 9 | + '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', |
| 10 | + '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', |
| 11 | + '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', |
| 12 | + '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', |
| 13 | + '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', |
| 14 | + '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', |
| 15 | + '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', |
| 16 | + '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', |
| 17 | + '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', 'A', 'B', 'C', 'D', 'E', |
| 18 | + 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', |
| 19 | + 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', |
| 20 | + 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ' ', |
| 21 | + '?', '?', '!', ':', '-', '(', ')', '?', '?', ',', '.', '/', '?', '?', '?', '?', |
| 22 | + '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', |
| 23 | +}; |
| 24 | + |
| 25 | +extern uint8_t PLAYER_NAMES[256][8]; |
| 26 | +extern uint8_t PLAYER_NAME_ID; |
| 27 | + |
5 | 28 | // Helper function for adding characters to the decoded message buffer |
6 | 29 | void Message_AddCharacter(MessageContext *msgCtx, void *pFont, uint32_t *pDecodedBufPos, uint32_t *pCharTexIdx, uint8_t charToAdd) { |
7 | 30 | uint32_t decodedBufPosVal = *pDecodedBufPos; |
@@ -43,6 +66,18 @@ void Message_AddString(MessageContext *msgCtx, void *pFont, uint32_t *pDecodedBu |
43 | 66 | } |
44 | 67 | } |
45 | 68 |
|
| 69 | +// Helper function for adding a filename to the decoded message buffer. Filenames use a different character set from other text. |
| 70 | +void Message_AddFileName(MessageContext *msgCtx, void *pFont, uint32_t *pDecodedBufPos, uint32_t *pCharTexIdx, uint8_t *filenameToAdd) { |
| 71 | + int end = 8; |
| 72 | + while (filenameToAdd[end - 1] == 0xDF) { |
| 73 | + // trim trailing space |
| 74 | + end--; |
| 75 | + } |
| 76 | + for (int i = 0; i < end; i++) { |
| 77 | + Message_AddCharacter(msgCtx, pFont, pDecodedBufPos, pCharTexIdx, FILENAME_ENCODING[filenameToAdd[i]]); |
| 78 | + } |
| 79 | +} |
| 80 | + |
46 | 81 | // Hack to add additional text control codes. |
47 | 82 | // If additional codes need to be read after the primary code, increment msgCtx->msgBufPos and index msgRaw |
48 | 83 | // To add a new control code: |
@@ -75,6 +110,12 @@ bool Message_Decode_Additional_Control_Codes(uint8_t currChar, uint32_t *pDecode |
75 | 110 | (*pDecodedBufPos)--; |
76 | 111 | return true; |
77 | 112 | } |
| 113 | + case 0xF2: { |
| 114 | + // Outgoing item filename |
| 115 | + Message_AddFileName(msgCtx, pFont, pDecodedBufPos, pCharTexIdx, PLAYER_NAMES[PLAYER_NAME_ID]); |
| 116 | + (*pDecodedBufPos)--; |
| 117 | + return true; |
| 118 | + } |
78 | 119 | default: { |
79 | 120 | return false; |
80 | 121 | } |
|
0 commit comments