ndsdump.cpp

来自「一个任天堂掌上游戏机NDS的源代码」· C++ 代码 · 共 43 行

CPP
43
字号
#include <fstream>#include "ndshead.h"inline unsigned intnlpo2(unsigned int x){	if(x&(x-1)) {            // If we're not already a power of 2	        x |= (x >> 1);        	x |= (x >> 2);	        x |= (x >> 4);        	x |= (x >> 8);	        x |= (x >> 16);        	return(x+1);     // Return next power up	}	return x;                // Otherwise, stick with what we have}int main(int argc, char **argv){    if(argc < 2)    {	printf("Usage: ndsdump <file to dump>\n");	return 1;    }    std::ifstream input(argv[1], std::ios::binary);    input.seekg(0, std::ios::end);    u32 ROMsize = input.tellg();    input.seekg(0, std::ios::beg);        u8 *ROM = new u8[nlpo2(ROMsize)];        input.read((char*)ROM, ROMsize);    input.close();        NDShead header(ROM);    header.print();        return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?