Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Error in C++ / NES emulator programm

ehguachoehguacho Posts: 2Member
hi! i'm trying to programm a Nintendo NES emulator. i've coded some opcodes (NES uses a 6502 processor) and them worked perfectly. but now i'm trying to allocate a piece of memory and i get this error.

[img=http://i43.tinypic.com/103j4np.jpg]

after the error, a blue line appears on the line "switch(memory[pc])" and i can't figure out why does it happen, i can't find the error. is it inside of the "switch" instruccion or is it in the "pc" (program counter) variable!? what i'm trying to do is to copy a piece of memory from the NES game rom file to the memory (a piece of memory wich should start at 0x8000). please somebody help me! :(

this is the full source code of my programm.
you can download it from here: [link=http://www.mediafire.com/download.php?gngttewd432]http://www.mediafire.com/download.php?gngttewd432[/link]

[code]#include
#include
#include
#include
#include

#define ADDR ((memory[pc + 2] << 8) | memory[pc + 1])
#define PUSH(a) memory[SP + 0x100] = (a); SP--
#define PULL() memory[(++SP) + 0x100]

void main(void)
{
FILE *fp;
unsigned char *memory; // Vector de memoria ROM (PRG Rom)
int i = 0;
unsigned int pc; // Contador de programa
int AR = 0; // Registro A
int XR = 0; // Registro X
int YR = 0; // Registro Y
int C_FLAG = 0; // Carry flag
int S_FLAG = 0; // Sign flag
int Z_FLAG = 0; // Zero flag
int SP = 0xFF; // Puntero a pila
int mirroring; // 0 = Horizontal 1 = Vertical
int trainer, battery;
int ROM_BANKS,VROM_BANKS,CART_SIZE;
int PRGROM_SIZE;

clrscr();

// Carga del archivo

fp = fopen("jumpy.nes","rb");
if(!fp)
{
printf("No se encontro el archivo
");
getch();
exit(1);
}
else printf("Archivo encontrado
");

// Cantidad de bancos de ROM y VROM y tama

Comments

Sign In or Register to comment.