Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.

Commit 2abf62e

Browse files
committed
Remove CpuBehavior
We only want to simulate one type of processor in this
1 parent 0d24a9d commit 2abf62e

File tree

2 files changed

+1
-71
lines changed

2 files changed

+1
-71
lines changed

src/main/java/com/loomcom/symon/Cpu.java

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ public class Cpu implements InstructionTable {
5555
public static final int IRQ_VECTOR_L = 0xfffe;
5656
public static final int IRQ_VECTOR_H = 0xffff;
5757

58-
/* Simulated behavior */
59-
private CpuBehavior behavior;
60-
6158
/* The Bus */
6259
private Bus bus;
6360

@@ -67,17 +64,6 @@ public class Cpu implements InstructionTable {
6764
/* CPU Cycles available */
6865
private int cycles = 0;
6966

70-
/**
71-
* Construct a new CPU.
72-
*/
73-
public Cpu() {
74-
this(CpuBehavior.NMOS_WITH_INDIRECT_JMP_BUG);
75-
}
76-
77-
public Cpu(CpuBehavior behavior) {
78-
this.behavior = behavior;
79-
}
80-
8167
/**
8268
* Set the bus reference for this CPU.
8369
*/
@@ -92,14 +78,6 @@ public Bus getBus() {
9278
return bus;
9379
}
9480

95-
public void setBehavior(CpuBehavior behavior) {
96-
this.behavior = behavior;
97-
}
98-
99-
public CpuBehavior getBehavior() {
100-
return behavior;
101-
}
102-
10381
/**
10482
* Reset the CPU to known initial values.
10583
*/
@@ -406,24 +384,13 @@ public void step() throws MemoryAccessException {
406384
case 0x6c: // JMP - Indirect
407385
lo = Utils.address(state.args[0], state.args[1]); // Address of low byte
408386

409-
if (state.args[0] == 0xff && (behavior == CpuBehavior.NMOS_WITH_INDIRECT_JMP_BUG || behavior == CpuBehavior.NMOS_WITH_ROR_BUG)) {
387+
if (state.args[0] == 0xff) {
410388
hi = Utils.address(0x00, state.args[1]);
411389
} else {
412390
hi = lo + 1;
413391
}
414392

415393
state.pc = Utils.address(bus.read(lo), bus.read(hi));
416-
/* TODO: For accuracy, allow a flag to enable broken behavior of early 6502s:
417-
*
418-
* "An original 6502 has does not correctly fetch the target
419-
* address if the indirect vector falls on a page boundary
420-
* (e.g. $xxFF where xx is and value from $00 to $FF). In this
421-
* case fetches the LSB from $xxFF as expected but takes the MSB
422-
* from $xx00. This is fixed in some later chips like the 65SC02
423-
* so for compatibility always ensure the indirect vector is not
424-
* at the end of the page."
425-
* (http://www.obelisk.demon.co.uk/6502/reference.html#JMP)
426-
*/
427394
break;
428395

429396
/** ORA - Logical Inclusive Or ******************************************/

src/main/java/com/loomcom/symon/InstructionTable.java

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,43 +25,6 @@
2525

2626
public interface InstructionTable {
2727

28-
/**
29-
* Enumeration of valid CPU behaviors. These determine what behavior and instruction
30-
* set will be simulated, depending on desired version of 6502.
31-
*
32-
* TODO: As of version 0.6, this is still not used! All CPUs are "idealized" NMOS 6502 only.
33-
*/
34-
enum CpuBehavior {
35-
/**
36-
* The earliest NMOS 6502 includes a bug that causes the ROR instruction
37-
* to behave like an ASL that does not affect the carry bit. This version
38-
* is very rare in the wild.
39-
*
40-
* NB: Does NOT implement "unimplemented" NMOS instructions.
41-
*/
42-
NMOS_WITH_ROR_BUG,
43-
44-
/**
45-
* All NMOS 6502's have a bug with the indirect JMP instruction. If the
46-
*
47-
* NB: Does NOT implement "unimplemented" NMOS instructions.
48-
*/
49-
NMOS_WITH_INDIRECT_JMP_BUG,
50-
51-
/**
52-
* Emulate an NMOS 6502 without the indirect JMP bug. This type of 6502
53-
* does not actually exist in the wild.
54-
*
55-
* NB: Does NOT implement "unimplemented" NMOS instructions.
56-
*/
57-
NMOS_WITHOUT_INDIRECT_JMP_BUG,
58-
59-
/**
60-
* Emulate a CMOS 65C02, with all CMOS instructions and addressing modes.
61-
*/
62-
CMOS
63-
}
64-
6528
/**
6629
* Enumeration of Addressing Modes.
6730
*/

0 commit comments

Comments
 (0)