Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <algorithm>
- unsigned char rom[0x100000];
- int count[256];
- int idx[256];
- char str[] = "hdebcgfa";
- bool cmp(int a, int b)
- {
- return count[a]<count[b];
- }
- int convert(int a)
- {
- int r = 0;
- for (int i=0; i<8; ++i)
- {
- if (a&(1<<(7-i)))
- r|=(1<<(7-(strchr(str,'a'+i)-str)));
- }
- return r;
- }
- char str2[] = "akcdspgoilbjmnhfqret";
- int convert2(int a)
- {
- int r = 0;
- for (int i=0; i<20; ++i)
- {
- if (a&(1<<(19-(strchr(str2,'a'+i)-str2))))
- r|=(1<<(19-i));
- }
- return r;
- }
- int main()
- {
- FILE *f = fopen("Ex-Ranza.bin","rb");
- fread(rom,1,sizeof(rom),f);
- fclose(f);
- for (int i=0; i<sizeof(rom); ++i)
- {
- rom[i] = convert(rom[i]);
- ++count[rom[i]];
- }
- f = fopen("Ex-Ranza__.bin","wb");
- for (int i=0; i<sizeof(rom); ++i)
- {
- unsigned char q = rom[convert2(i)];
- fwrite(&q,1,1,f);
- }
- fclose(f);
- for (int i=0; i<256; ++i)
- idx[i]=i;
- std::sort(idx,idx+256, cmp);
- for (int j=0; j<256; ++j)
- {
- int i = idx[j];
- printf("%02X: %d\n",i,count[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement