|
Hello
I am trying to figure out how an CPU emulator works. Iam trying to write a simple 6502 emulator programmed in c. atm iam trying to load an compile 6502 binary file into an array but i cant get it to work :(. I've tried messing around with the code sniplets in Dan Boris emulator tuturial. I have only been learning c for a little while so it could be my code. anyways iam wondering if anybody can help me out? here is my code : -
#include
int main() {
int memory[0x001f];int i;
FILE *fp;
fp=fopen("LOADTEST.NES","rb");
if (!fp) { printf("Error loading game.rom\n"); return 1; } read(&memory[0x0000],1,0x001F,fp); fclose(fp);
for(i=0; i < 0x001f; i++) { printf("The value at %x is %x\n",i, memory[i]);
}
return 0; }
what i have tried to do is load loadtest.nes into an array then read it out using an for next loop.
Every time it reads the array it comes up with werid hex numbers that are not in the rom?
Sorry for such a silly question but iam quite curious to find out how it works :D
Thanks in advance :)
|