Welcome to Emulationworld

Forum Index | FAQ | New User | Login | Search

Make a New PostPrevious ThreadView All ThreadsNext ThreadShow in Flat Mode*


Subjectnewbie CPU emulator questions Reply to this message
Posted byMr_edward
Posted on05/11/04 02:41 PM



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 :)



-
Entire Thread
Subject  Posted byPosted On
.newbie CPU emulator questions  Mr_edward05/11/04 02:41 PM
.*Re: newbie CPU emulator questions  Bart T.05/11/04 03:42 PM
..*Re: newbie CPU emulator questions  Mr_edward05/12/04 05:57 PM
...*Re: newbie CPU emulator questions  finaldave05/13/04 05:31 PM
....*Re: newbie CPU emulator questions  Mr_edward05/14/04 04:17 PM