resonance 1.0.1
Loading...
Searching...
No Matches
shiftjis.h File Reference

Go to the source code of this file.

Classes

struct  ShiftJisSymbol
 One ASCII symbol and its full-width Shift-JIS code. More...
struct  ShiftJisRange
 One run of consecutive characters that maps linearly. More...

Functions

char DecodeShiftJisCharacter (const char *pShiftJis)
 Convert one full-width Shift-JIS character back to ASCII.
unsigned short EncodeShiftJisCharacter (unsigned char cAscii)
 Convert one ASCII character to its full-width Shift-JIS code.
void ShiftJisToAscii (const char *pszShiftJis, char *pszAscii)
 Convert Shift-JIS text back to ASCII.
void AsciiToShiftJis (const char *pszAscii, char *pszDest)
 Convert ASCII text to the Shift-JIS bytes icon.sys stores a title as.

Variables

constexpr int kShiftJisSymbolCount = 33
 Punctuation pairs in g_aShiftJisSymbols, one for each printable ASCII symbol.
constexpr int kShiftJisRangeCount = 3
 Runs in g_aShiftJisRanges: the digits, the capital letters, and the small letters.
const ShiftJisSymbol g_aShiftJisSymbols [kShiftJisSymbolCount+1]
 The ASCII punctuation from space to tilde in ASCII order, followed by one zero entry.
const ShiftJisRange g_aShiftJisRanges [kShiftJisRangeCount]
 The digit, capital, and small-letter runs, based at 0x824f, 0x8260, and 0x8281.

Function Documentation

◆ DecodeShiftJisCharacter()

char DecodeShiftJisCharacter ( const char * pShiftJis)

Convert one full-width Shift-JIS character back to ASCII.

A lead byte of 0x82 maps three trail-byte runs back onto the digits and the letters, and the digit run covers one trail byte more than the ten digits. A lead byte of 0x81 is looked up in g_aShiftJisSymbols by its trail byte alone. The title is inferred.

Parameters
pShiftJisThe two bytes of the character.
Returns
The ASCII character, or zero when the character has none.
Ghidra address:
NTSC-U/C: 0x00556750
Ghidra address:
PAL: 0x005978a8

◆ EncodeShiftJisCharacter()

unsigned short EncodeShiftJisCharacter ( unsigned char cAscii)

Convert one ASCII character to its full-width Shift-JIS code.

A code outside space to tilde is reported through the log as bad ASCII code 0xx. The title is inferred.

Parameters
cAsciiThe character.
Returns
The two-byte code, lead byte high, or zero for a character outside the tables.
Ghidra address:
NTSC-U/C: 0x00556818
Ghidra address:
PAL: 0x00597970

◆ ShiftJisToAscii()

void ShiftJisToAscii ( const char * pszShiftJis,
char * pszAscii )

Convert Shift-JIS text back to ASCII.

The source length is halved and every pair converted. The first pair with no ASCII form replaces the whole result with .Kanji.. The shipped program does not call it, and the title is inferred.

Parameters
pszShiftJisThe text to convert.
pszAsciiThe destination, of at least half the source length plus one byte.
Ghidra address:
NTSC-U/C: 0x00556928
Ghidra address:
PAL: 0x00597a80

◆ AsciiToShiftJis()

void AsciiToShiftJis ( const char * pszAscii,
char * pszDest )

Convert ASCII text to the Shift-JIS bytes icon.sys stores a title as.

Every character becomes two bytes, lead byte first, and two zero bytes end the result. SaveFileMCT::BuildIconSys() is its only caller, and the title is inferred from that use and from the .Kanji. fallback of the reverse conversion.

Parameters
pszAsciiThe text to convert.
pszDestThe destination, of at least twice the text length plus two bytes.
Ghidra address:
NTSC-U/C: 0x00556a20
Ghidra address:
PAL: 0x00597b78

Variable Documentation

◆ kShiftJisSymbolCount

int kShiftJisSymbolCount = 33
constexpr

Punctuation pairs in g_aShiftJisSymbols, one for each printable ASCII symbol.

◆ kShiftJisRangeCount

int kShiftJisRangeCount = 3
constexpr

Runs in g_aShiftJisRanges: the digits, the capital letters, and the small letters.

◆ g_aShiftJisSymbols

const ShiftJisSymbol g_aShiftJisSymbols[kShiftJisSymbolCount+1]
extern

The ASCII punctuation from space to tilde in ASCII order, followed by one zero entry.

Ghidra address:
NTSC-U/C: 0x007251a8
Ghidra address:
PAL: 0x00768e48

◆ g_aShiftJisRanges

const ShiftJisRange g_aShiftJisRanges[kShiftJisRangeCount]
extern

The digit, capital, and small-letter runs, based at 0x824f, 0x8260, and 0x8281.

Ghidra address:
NTSC-U/C: 0x00725230
Ghidra address:
PAL: 0x00768ed0