Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <vector>
- #include <fstream>
- #include <string>
- int main(int argc, char** argv)
- {
- std::vector<unsigned char> ROM;
- std::ifstream f(argv[1], std::ios::binary);
- for(; f.good(); ) ROM.push_back(f.get());
- ROM.erase(ROM.begin(),ROM.begin()+16);
- std::vector<std::string> names(128);
- for(unsigned n=0; n<128; ++n)
- {
- auto addr = [base = 0x8000](unsigned n) { return base + (n&0x3FFF); };
- unsigned pointer = ROM[addr(0xA4F9+n*2)]+ROM[addr(0xA4FA+n*2)]*256;
- for(std::string& name = names[n]; ROM[addr(pointer)] != 5; )
- switch(unsigned char c = ROM[addr(pointer++)])
- {
- case 0xC0 ... 0xD9: name += char(c+'A'-0xC0); break;
- case 0xDA ... 0xF3: name += char(c+'a'-0xDA); break;
- case 0xF4 ... 0xFD: name += char(c+'0'-0xF4); break;
- case 0xB0 ... 0xBD: name += u8R"(*"!?-%.:;&,>#…)"[c-0xB0]; break;
- case 0xFE: name += '$'; break;
- default: name += ' ';
- }
- }
- for(unsigned n=0; n<16; ++n, std::putchar('\n'))
- for(unsigned c=0; c<8; ++c)
- std::printf("%02X:%-12s", n+c*16, names[n + c*16].c_str());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement