Skip to content

Commit

Permalink
builds now...
Browse files Browse the repository at this point in the history
  • Loading branch information
mwillsey committed Feb 8, 2014
1 parent 9ebaf90 commit a5d86e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion 6502.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,9 @@ void ROR (cpu *c, addr a) {

/* jump to another location */
void JMP (cpu *c, addr a) {
c->PC = mem_read(c->mem, a);
byte b = mem_read(c->mem, a);
printf("jumping to %04x\n", b);
c->PC = b;
}

/* jump to subroutine */
Expand Down Expand Up @@ -717,6 +719,10 @@ void cpu_init (cpu *c, memory *mem) {
set_flag(c, 5, 1);
/* set stack pointer */
c->SP = 0xfd;
/* clear registers */
c->A = 0;
c->X = 0;
c->Y = 0;
/* load program counter to address at 0xfffc/d*/
c->PC = ((addr)(mem_read(c->mem, 0xfffd)) << 8) | mem_read(c->mem, 0xfffc);
}
Expand Down
5 changes: 3 additions & 2 deletions nes.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ int main (int argc, char** argv) {
/* fread(nes_cpu.cartidge_lower_bank, sizeof(byte), in_stat.st_size, in); */

/* for the nestest rom */
fread(mem.arr+0x8000-16, sizeof(byte), 0x4000, in);
fread(mem.arr+0xc000-16, sizeof(byte), 0x4000, in);
nes_cpu.PC = 0xc000;

for(int i = 0; i < 10000; i++) {
int i;
for(i = 0; i < 10000; i++) {
cpu_step(&nes_cpu);
}

Expand Down

0 comments on commit a5d86e3

Please sign in to comment.