Guest User

Untitled

a guest
Jul 17th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1.  
  2. int GetCharacterIndex(int value)
  3. {
  4. int highbyte = 0x99;
  5. int lowbyte = 0x40;
  6.  
  7. if (value > 0x993F)
  8. {
  9. if ((value & 0xFF) < 0x40)
  10. {
  11. value -= 0x43;
  12. }
  13. highbyte = value >> 8;
  14. lowbyte = value & 0xFF;
  15. if (highbyte >= 0xE0) highbyte -= 0x40;
  16. }
  17.  
  18. highbyte -= 0x99;
  19. if (lowbyte >= 0x80) lowbyte--;
  20. if (lowbyte >= 0x5D) lowbyte--;
  21. lowbyte -= 0x40;
  22.  
  23. return (highbyte * 0xBB) + lowbyte;
  24. }
  25.  
  26. void CreateTable(char* InputName, char* OutputName)
  27. {
  28. FILE* Tbl = fopen(OutputName,"wb");
  29.  
  30. unsigned char* Sjis = NULL;
  31. int SjisAmount = ReadFileToBuffer(InputName,&Sjis) / 2;
  32.  
  33. for (int i = 0x9940; i < 0xFFFF; i++)
  34. {
  35. int index = GetCharacterIndex(i);
  36. if (index < SjisAmount)
  37. {
  38. fprintf(Tbl,"%02X%02X=%c%c\n",i >> 8,i&0xFF,Sjis[index*2+0],Sjis[index*2+1]);
  39. }
  40. }
  41.  
  42. fclose(Tbl);
  43. free(Sjis);
  44. }
Add Comment
Please, Sign In to add comment