Merge pull request #4566 from JosJuice/charset-terminology

Remove incorrect usage of "ASCII" and "ANSI"
This commit is contained in:
Mat M 2016-12-26 15:40:45 -05:00 committed by GitHub
commit 1af9f68240
13 changed files with 67 additions and 58 deletions

View File

@ -1,4 +1,4 @@
The two fonts in this directory (font_ansi.bin and font_sjis.bin) were The two fonts in this directory (font_western.bin and font_japanese.bin) were
generated using gc-font-tool which can be found in the docs/ directory in the generated using gc-font-tool which can be found in the docs/ directory in the
dolphin source code. dolphin source code.

View File

@ -144,8 +144,8 @@ is intended for debugging purposes only.
## Sys Files ## Sys Files
* `totaldb.dsy`: Database of symbols (for devs only) * `totaldb.dsy`: Database of symbols (for devs only)
* `GC/font_ansi.bin`: font dumps * `GC/font_western.bin`: font dumps
* `GC/font_sjis.bin`: font dumps * `GC/font_japanese.bin`: font dumps
* `GC/dsp_coef.bin`: DSP dumps * `GC/dsp_coef.bin`: DSP dumps
* `GC/dsp_rom.bin`: DSP dumps * `GC/dsp_rom.bin`: DSP dumps
* `Wii/clientca.pem`: Wii network certificate * `Wii/clientca.pem`: Wii network certificate

View File

@ -106,8 +106,8 @@
// Sys files // Sys files
#define TOTALDB "totaldb.dsy" #define TOTALDB "totaldb.dsy"
#define FONT_ANSI "font_ansi.bin" #define FONT_WINDOWS_1252 "font_western.bin"
#define FONT_SJIS "font_sjis.bin" #define FONT_SHIFT_JIS "font_japanese.bin"
#define DSP_IROM "dsp_rom.bin" #define DSP_IROM "dsp_rom.bin"
#define DSP_COEF "dsp_coef.bin" #define DSP_COEF "dsp_coef.bin"

View File

@ -101,8 +101,8 @@ CEXIIPL::CEXIIPL() : m_uPosition(0), m_uAddress(0), m_uRWOffset(0), m_FontsLoade
m_bNTSC ? sizeof(iplverNTSC) : sizeof(iplverPAL)); m_bNTSC ? sizeof(iplverNTSC) : sizeof(iplverPAL));
// Load fonts // Load fonts
LoadFontFile((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + FONT_SJIS), 0x1aff00); LoadFontFile((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + FONT_SHIFT_JIS), 0x1aff00);
LoadFontFile((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + FONT_ANSI), 0x1fcf00); LoadFontFile((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + FONT_WINDOWS_1252), 0x1fcf00);
} }
else else
{ {
@ -199,12 +199,12 @@ void CEXIIPL::LoadFontFile(const std::string& filename, u32 offset)
if (!stream) if (!stream)
return; return;
// Official Windows-1252 and SJIS fonts present on the IPL dumps are 0x2575 and 0x4a24d bytes // Official Windows-1252 and Shift JIS fonts present on the IPL dumps are 0x2575 and 0x4a24d
// long respectively, so, determine the size of the font being loaded based on the offset // bytes long respectively, so, determine the size of the font being loaded based on the offset
u64 fontsize = (offset == 0x1aff00) ? 0x4a24d : 0x2575; u64 fontsize = (offset == 0x1aff00) ? 0x4a24d : 0x2575;
INFO_LOG(BOOT, "Found IPL dump, loading %s font from %s", INFO_LOG(BOOT, "Found IPL dump, loading %s font from %s",
((offset == 0x1aff00) ? "SJIS" : "Windows-1252"), (ipl_rom_path).c_str()); ((offset == 0x1aff00) ? "Shift JIS" : "Windows-1252"), (ipl_rom_path).c_str());
stream.Seek(offset, 0); stream.Seek(offset, 0);
stream.ReadBytes(m_pIPL + offset, fontsize); stream.ReadBytes(m_pIPL + offset, fontsize);
@ -374,9 +374,16 @@ void CEXIIPL::TransferByte(u8& _uByte)
if ((position >= 0x001AFF00) && (position <= 0x001FF474) && !m_FontsLoaded) if ((position >= 0x001AFF00) && (position <= 0x001FF474) && !m_FontsLoaded)
{ {
PanicAlertT("Error: Trying to access %s fonts but they are not loaded. " if (position >= 0x001FCF00)
"Games may not show fonts correctly, or crash.", {
(position >= 0x001FCF00) ? "ANSI" : "SJIS"); PanicAlertT("Error: Trying to access Windows-1252 fonts but they are not loaded. "
"Games may not show fonts correctly, or crash.");
}
else
{
PanicAlertT("Error: Trying to access Shift JIS fonts but they are not loaded. "
"Games may not show fonts correctly, or crash.");
}
m_FontsLoaded = true; // Don't be a nag :p m_FontsLoaded = true; // Don't be a nag :p
} }
} }

View File

@ -171,12 +171,12 @@ void CEXIMemoryCard::SetupGciFolder(u16 sizeMb)
country_code = DiscIO::CountrySwitch(game_id.at(3)); country_code = DiscIO::CountrySwitch(game_id.at(3));
CurrentGameId = BE32((u8*)game_id.c_str()); CurrentGameId = BE32((u8*)game_id.c_str());
} }
bool ascii = true; bool shift_jis = false;
std::string strDirectoryName = File::GetUserPath(D_GCUSER_IDX); std::string strDirectoryName = File::GetUserPath(D_GCUSER_IDX);
switch (country_code) switch (country_code)
{ {
case DiscIO::Country::COUNTRY_JAPAN: case DiscIO::Country::COUNTRY_JAPAN:
ascii = false; shift_jis = true;
strDirectoryName += JAP_DIR DIR_SEP; strDirectoryName += JAP_DIR DIR_SEP;
break; break;
case DiscIO::Country::COUNTRY_USA: case DiscIO::Country::COUNTRY_USA:
@ -203,7 +203,7 @@ void CEXIMemoryCard::SetupGciFolder(u16 sizeMb)
if (region == JAP_DIR) if (region == JAP_DIR)
{ {
country_code = DiscIO::Country::COUNTRY_JAPAN; country_code = DiscIO::Country::COUNTRY_JAPAN;
ascii = false; shift_jis = true;
strDirectoryName += JAP_DIR DIR_SEP; strDirectoryName += JAP_DIR DIR_SEP;
break; break;
} }
@ -243,7 +243,7 @@ void CEXIMemoryCard::SetupGciFolder(u16 sizeMb)
} }
memorycard = std::make_unique<GCMemcardDirectory>(strDirectoryName + DIR_SEP, card_index, sizeMb, memorycard = std::make_unique<GCMemcardDirectory>(strDirectoryName + DIR_SEP, card_index, sizeMb,
ascii, country_code, CurrentGameId); shift_jis, country_code, CurrentGameId);
} }
void CEXIMemoryCard::SetupRawMemcard(u16 sizeMb) void CEXIMemoryCard::SetupRawMemcard(u16 sizeMb)

View File

@ -22,7 +22,7 @@ static void ByteSwap(u8* valueA, u8* valueB)
*valueB = tmp; *valueB = tmp;
} }
GCMemcard::GCMemcard(const std::string& filename, bool forceCreation, bool ascii) GCMemcard::GCMemcard(const std::string& filename, bool forceCreation, bool shift_jis)
: m_valid(false), m_fileName(filename) : m_valid(false), m_fileName(filename)
{ {
// Currently there is a string freeze. instead of adding a new message about needing r/w // Currently there is a string freeze. instead of adding a new message about needing r/w
@ -34,9 +34,10 @@ GCMemcard::GCMemcard(const std::string& filename, bool forceCreation, bool ascii
{ {
if (!AskYesNoT("\"%s\" does not exist.\n Create a new 16MB Memcard?", filename.c_str())) if (!AskYesNoT("\"%s\" does not exist.\n Create a new 16MB Memcard?", filename.c_str()))
return; return;
ascii = AskYesNoT("Format as ASCII (NTSC\\PAL)?\nChoose no for Shift JIS (NTSC-J)"); shift_jis =
AskYesNoT("Format as Shift JIS (Japanese)?\nChoose no for Windows-1252 (Western)");
} }
Format(ascii); Format(shift_jis);
return; return;
} }
else else
@ -226,9 +227,9 @@ void GCMemcard::InitDirBatPointers()
} }
} }
bool GCMemcard::IsAsciiEncoding() const bool GCMemcard::IsShiftJIS() const
{ {
return hdr.Encoding == 0; return hdr.Encoding == 1;
} }
bool GCMemcard::Save() bool GCMemcard::Save()
@ -1223,14 +1224,14 @@ u32 GCMemcard::ReadAnimRGBA8(u8 index, u32* buffer, u8* delays) const
return frames; return frames;
} }
bool GCMemcard::Format(u8* card_data, bool ascii, u16 SizeMb) bool GCMemcard::Format(u8* card_data, bool shift_jis, u16 SizeMb)
{ {
if (!card_data) if (!card_data)
return false; return false;
memset(card_data, 0xFF, BLOCK_SIZE * 3); memset(card_data, 0xFF, BLOCK_SIZE * 3);
memset(card_data + BLOCK_SIZE * 3, 0, BLOCK_SIZE * 2); memset(card_data + BLOCK_SIZE * 3, 0, BLOCK_SIZE * 2);
*((Header*)card_data) = Header(SLOT_A, SizeMb, ascii); *((Header*)card_data) = Header(SLOT_A, SizeMb, shift_jis);
*((Directory*)(card_data + BLOCK_SIZE)) = Directory(); *((Directory*)(card_data + BLOCK_SIZE)) = Directory();
*((Directory*)(card_data + BLOCK_SIZE * 2)) = Directory(); *((Directory*)(card_data + BLOCK_SIZE * 2)) = Directory();
@ -1239,7 +1240,7 @@ bool GCMemcard::Format(u8* card_data, bool ascii, u16 SizeMb)
return true; return true;
} }
bool GCMemcard::Format(bool ascii, u16 SizeMb) bool GCMemcard::Format(bool shift_jis, u16 SizeMb)
{ {
memset(&hdr, 0xFF, BLOCK_SIZE); memset(&hdr, 0xFF, BLOCK_SIZE);
memset(&dir, 0xFF, BLOCK_SIZE); memset(&dir, 0xFF, BLOCK_SIZE);
@ -1247,7 +1248,7 @@ bool GCMemcard::Format(bool ascii, u16 SizeMb)
memset(&bat, 0, BLOCK_SIZE); memset(&bat, 0, BLOCK_SIZE);
memset(&bat_backup, 0, BLOCK_SIZE); memset(&bat_backup, 0, BLOCK_SIZE);
hdr = Header(SLOT_A, SizeMb, ascii); hdr = Header(SLOT_A, SizeMb, shift_jis);
dir = dir_backup = Directory(); dir = dir_backup = Directory();
bat = bat_backup = BlockAlloc(SizeMb); bat = bat_backup = BlockAlloc(SizeMb);

View File

@ -126,11 +126,11 @@ struct Header // Offset Size Description
// Nintendo format algorithm. // Nintendo format algorithm.
// Constants are fixed by the GC SDK // Constants are fixed by the GC SDK
// Changing the constants will break memory card support // Changing the constants will break memory card support
Header(int slot = 0, u16 sizeMb = MemCard2043Mb, bool ascii = true) Header(int slot = 0, u16 sizeMb = MemCard2043Mb, bool shift_jis = false)
{ {
memset(this, 0xFF, BLOCK_SIZE); memset(this, 0xFF, BLOCK_SIZE);
*(u16*)SizeMb = BE16(sizeMb); *(u16*)SizeMb = BE16(sizeMb);
Encoding = BE16(ascii ? 0 : 1); Encoding = BE16(shift_jis ? 1 : 0);
u64 rand = CEXIIPL::GetEmulatedTime(CEXIIPL::GC_EPOCH); u64 rand = CEXIIPL::GetEmulatedTime(CEXIIPL::GC_EPOCH);
formatTime = Common::swap64(rand); formatTime = Common::swap64(rand);
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
@ -308,12 +308,12 @@ private:
void InitDirBatPointers(); void InitDirBatPointers();
public: public:
GCMemcard(const std::string& fileName, bool forceCreation = false, bool sjis = false); GCMemcard(const std::string& fileName, bool forceCreation = false, bool shift_jis = false);
bool IsValid() const { return m_valid; } bool IsValid() const { return m_valid; }
bool IsAsciiEncoding() const; bool IsShiftJIS() const;
bool Save(); bool Save();
bool Format(bool ascii = true, u16 SizeMb = MemCard2043Mb); bool Format(bool shift_jis = false, u16 SizeMb = MemCard2043Mb);
static bool Format(u8* card_data, bool ascii = true, u16 SizeMb = MemCard2043Mb); static bool Format(u8* card_data, bool shift_jis = false, u16 SizeMb = MemCard2043Mb);
static s32 FZEROGX_MakeSaveGameValid(Header& cardheader, DEntry& direntry, static s32 FZEROGX_MakeSaveGameValid(Header& cardheader, DEntry& direntry,
std::vector<GCMBlock>& FileBuffer); std::vector<GCMBlock>& FileBuffer);
static s32 PSO_MakeSaveGameValid(Header& cardheader, DEntry& direntry, static s32 PSO_MakeSaveGameValid(Header& cardheader, DEntry& direntry,

View File

@ -146,9 +146,10 @@ int GCMemcardDirectory::LoadGCI(const std::string& fileName, DiscIO::Country car
} }
GCMemcardDirectory::GCMemcardDirectory(const std::string& directory, int slot, u16 sizeMb, GCMemcardDirectory::GCMemcardDirectory(const std::string& directory, int slot, u16 sizeMb,
bool ascii, DiscIO::Country card_region, int gameId) bool shift_jis, DiscIO::Country card_region, int gameId)
: MemoryCardBase(slot, sizeMb), m_GameId(gameId), m_LastBlock(-1), m_hdr(slot, sizeMb, ascii), : MemoryCardBase(slot, sizeMb), m_GameId(gameId), m_LastBlock(-1),
m_bat1(sizeMb), m_saves(0), m_SaveDirectory(directory), m_exiting(false) m_hdr(slot, sizeMb, shift_jis), m_bat1(sizeMb), m_saves(0), m_SaveDirectory(directory),
m_exiting(false)
{ {
// Use existing header data if available // Use existing header data if available
if (File::Exists(m_SaveDirectory + MC_HDR)) if (File::Exists(m_SaveDirectory + MC_HDR))

View File

@ -23,7 +23,7 @@ class GCMemcardDirectory : public MemoryCardBase, NonCopyable
{ {
public: public:
GCMemcardDirectory(const std::string& directory, int slot = 0, u16 sizeMb = MemCard2043Mb, GCMemcardDirectory(const std::string& directory, int slot = 0, u16 sizeMb = MemCard2043Mb,
bool ascii = true, bool shift_jis = false,
DiscIO::Country card_region = DiscIO::Country::COUNTRY_EUROPE, int gameId = 0); DiscIO::Country card_region = DiscIO::Country::COUNTRY_EUROPE, int gameId = 0);
~GCMemcardDirectory(); ~GCMemcardDirectory();
void FlushToFile(); void FlushToFile();

View File

@ -735,7 +735,7 @@ bool CMemcardManager::ReloadMemcard(const std::string& fileName, int card)
std::string title = memoryCard[card]->GetSaveComment1(fileIndex); std::string title = memoryCard[card]->GetSaveComment1(fileIndex);
std::string comment = memoryCard[card]->GetSaveComment2(fileIndex); std::string comment = memoryCard[card]->GetSaveComment2(fileIndex);
auto const string_decoder = memoryCard[card]->IsAsciiEncoding() ? CP1252ToUTF8 : SHIFTJISToUTF8; auto const string_decoder = memoryCard[card]->IsShiftJIS() ? SHIFTJISToUTF8 : CP1252ToUTF8;
wxTitle = StrToWxStr(string_decoder(title)); wxTitle = StrToWxStr(string_decoder(title));
wxComment = StrToWxStr(string_decoder(comment)); wxComment = StrToWxStr(string_decoder(comment));

View File

@ -100,8 +100,8 @@ const int FNT_PIXMAP_WIDTH = 512; // Must be >= CELL_SIZE * CELLS_PER_ROW
// The two types of font which can be generated // The two types of font which can be generated
enum class font_type enum class font_type
{ {
ansi, windows_1252,
sjis, shift_jis,
}; };
#define SEQUENCE_4(x) (x), (x)+1, (x)+2, (x)+3 #define SEQUENCE_4(x) (x), (x)+1, (x)+2, (x)+3
@ -110,8 +110,8 @@ enum class font_type
#define SEQUENCE_32(x) SEQUENCE_16(x), SEQUENCE_16((x)+16) #define SEQUENCE_32(x) SEQUENCE_16(x), SEQUENCE_16((x)+16)
#define SEQUENCE_64(x) SEQUENCE_32(x), SEQUENCE_32((x)+32) #define SEQUENCE_64(x) SEQUENCE_32(x), SEQUENCE_32((x)+32)
// List of unicode codepoints appearing in the ANSI font // List of unicode codepoints appearing in the Windows-1252 font
const uint16_t ansi_font_table[] = const uint16_t windows_1252_font_table[] =
{ {
SEQUENCE_32(0x20), SEQUENCE_32(0x20),
SEQUENCE_64(0x40), SEQUENCE_64(0x40),
@ -124,10 +124,10 @@ const uint16_t ansi_font_table[] =
SEQUENCE_64(0xC0), SEQUENCE_64(0xC0),
}; };
// List of unicode codepoints appearing in the SJIS font // List of unicode codepoints appearing in the Shift JIS font
const uint16_t sjis_font_table[] = const uint16_t shift_jis_font_table[] =
{ {
// Starts at SJIS 0x8740. Any holes are skipped over. // Starts at Shift JIS 0x8740. Any holes are skipped over.
0x3000, 0x3001, 0x3002, 0xFF0C, 0xFF0E, 0x30FB, 0xFF1A, 0xFF1B, 0x3000, 0x3001, 0x3002, 0xFF0C, 0xFF0E, 0x30FB, 0xFF1A, 0xFF1B,
0xFF1F, 0xFF01, 0x309B, 0x309C, 0x00B4, 0xFF40, 0x00A8, 0xFF3E, 0xFF1F, 0xFF01, 0x309B, 0x309C, 0x00B4, 0xFF40, 0x00A8, 0xFF3E,
0xFFE3, 0xFF3F, 0x30FD, 0x30FE, 0x309D, 0x309E, 0x3003, 0x4EDD, 0xFFE3, 0xFF3F, 0x30FD, 0x30FE, 0x309D, 0x309E, 0x3003, 0x4EDD,
@ -1117,9 +1117,9 @@ static std::vector<uint8_t> generate_fnt(
{ {
std::vector<uint8_t> out; std::vector<uint8_t> out;
write_be16(out, type == font_type::ansi ? 0 : 2); write_be16(out, type == font_type::windows_1252 ? 0 : 2);
write_be16(out, type == font_type::ansi ? 0x0020 : 0x8140); write_be16(out, type == font_type::windows_1252 ? 0x0020 : 0x8140);
write_be16(out, type == font_type::ansi ? 0x00FF : 0x9872); write_be16(out, type == font_type::windows_1252 ? 0x00FF : 0x9872);
write_be16(out, 0x20); write_be16(out, 0x20);
write_be16(out, FNT_CELL_SIZE); write_be16(out, FNT_CELL_SIZE);
write_be16(out, 0x00); write_be16(out, 0x00);
@ -1237,15 +1237,15 @@ static std::vector<uint8_t> freetype_to_fnt(const std::vector<uint8_t>& font_buf
const uint16_t* font_table; const uint16_t* font_table;
unsigned font_table_size; unsigned font_table_size;
if (type == font_type::ansi) if (type == font_type::windows_1252)
{ {
font_table = ansi_font_table; font_table = windows_1252_font_table;
font_table_size = sizeof(ansi_font_table) / 2; font_table_size = sizeof(windows_1252_font_table) / 2;
} }
else else
{ {
font_table = sjis_font_table; font_table = shift_jis_font_table;
font_table_size = sizeof(sjis_font_table) / 2; font_table_size = sizeof(shift_jis_font_table) / 2;
} }
// Generate pixmap // Generate pixmap
@ -1268,8 +1268,8 @@ static void usage()
std::cerr << "gc-font-tool <mode> <input> <output>" << std::endl; std::cerr << "gc-font-tool <mode> <input> <output>" << std::endl;
std::cerr << " c = compress using yay0" << std::endl; std::cerr << " c = compress using yay0" << std::endl;
std::cerr << " d = decompress a yay0 file" << std::endl; std::cerr << " d = decompress a yay0 file" << std::endl;
std::cerr << " a = generate an ansi gamecube font file from a true type font" << std::endl; std::cerr << " a = generate a windows-1252 gamecube font file from a true type font" << std::endl;
std::cerr << " s = generate a sjis gamecube font file from a true type font" << std::endl; std::cerr << " s = generate a shift jis gamecube font file from a true type font" << std::endl;
std::cerr << " b = like a, but do not dither the final image" << std::endl; std::cerr << " b = like a, but do not dither the final image" << std::endl;
std::cerr << " t = like s, but do not dither the final image" << std::endl; std::cerr << " t = like s, but do not dither the final image" << std::endl;
std::cerr << " v = generate a bitmap showing the contents of a gamecube font file" << std::endl; std::cerr << " v = generate a bitmap showing the contents of a gamecube font file" << std::endl;
@ -1350,10 +1350,10 @@ int main(int argc, char* argv[])
{ {
case 'c': result = yay0_compress(input); break; case 'c': result = yay0_compress(input); break;
case 'd': result = yay0_decompress(input); break; case 'd': result = yay0_decompress(input); break;
case 'a': result = freetype_to_fnt(input, font_type::ansi, true); break; case 'a': result = freetype_to_fnt(input, font_type::windows_1252, true); break;
case 's': result = freetype_to_fnt(input, font_type::sjis, true); break; case 's': result = freetype_to_fnt(input, font_type::shift_jis, true); break;
case 'b': result = freetype_to_fnt(input, font_type::ansi, false); break; case 'b': result = freetype_to_fnt(input, font_type::windows_1252, false); break;
case 't': result = freetype_to_fnt(input, font_type::sjis, false); break; case 't': result = freetype_to_fnt(input, font_type::shift_jis, false); break;
case 'v': result = fnt_to_bmp(input); break; case 'v': result = fnt_to_bmp(input); break;
default: default:
usage(); usage();