-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrunrom.cpp
More file actions
37 lines (30 loc) · 830 Bytes
/
runrom.cpp
File metadata and controls
37 lines (30 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "system.h"
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char**argv)
{
// first we load the rom file
FILE *f= fopen(argv[1], "rb");
if (f==NULL)
{
printf("error: Couldn't open %s\n", argv[1]);
exit(1);
}
//Get the file size and read it into a memory buffer
fseek(f, 0L, SEEK_END);
int fsize = ftell(f);
fseek(f, 0L, SEEK_SET);
unsigned char *buffer = (unsigned char *)malloc(fsize);
fread(buffer, fsize, 1, f);
fclose(f);
// create and init state machine
Famicom * nes = new Famicom(buffer);
/* so this is iterating over the prgrom */
while (nes->getpc() < PRGROMSTART+nes->cart->prgromsize)
{
//printf("%x : %x\n", nes->getpc(), fsize);
nes->emulate6502op();
}
printf("\n\n");
return 0;
}