|
1 | 1 | package m68k.cpu; |
2 | 2 |
|
3 | 3 | import m68k.cpu.instructions.*; |
| 4 | +import m68k.util.LogHelper; |
| 5 | +import org.slf4j.Logger; |
4 | 6 |
|
5 | 7 | /* |
6 | 8 | // M68k - Java Amiga MachineCore |
|
28 | 30 | */ |
29 | 31 | public class MC68000 extends CpuCore implements InstructionSet |
30 | 32 | { |
31 | | - |
32 | | - public static final boolean ENABLE_PREFETCH = Boolean.valueOf(System.getProperty("68k.enable.prefetch", "false")); |
33 | | - |
34 | | - static { |
35 | | - initProperties(); |
36 | | - } |
37 | | - |
38 | | - private static void initProperties() { |
39 | | - TAS.EMULATE_BROKEN_TAS = Boolean.valueOf(System.getProperty("68k.broken.tas", "false")); |
40 | | - if(TAS.EMULATE_BROKEN_TAS){ |
41 | | - System.out.println("Emulating broken TAS instruction"); |
42 | | - } |
43 | | - DIVU.ACCURATE_DIV_TIMING = Boolean.valueOf(System.getProperty("68k.accurate.div.timing", "false")); |
44 | | - if(DIVU.ACCURATE_DIV_TIMING){ |
45 | | - System.out.println("Using accurate DIVU/S timing"); |
46 | | - } |
47 | | - if(ENABLE_PREFETCH){ |
48 | | - System.out.println("Enable prefetch"); |
49 | | - } |
50 | | - } |
51 | | - |
| 33 | + private final static Logger LOG = LogHelper.getLogger(MC68000.class.getSimpleName()); |
52 | 34 | protected final Instruction[] i_table; |
53 | 35 | protected final Instruction unknown; |
54 | 36 | protected int loaded_ops; |
55 | 37 |
|
56 | | - public MC68000() |
57 | | - { |
| 38 | + protected final CpuConfig cpuConfig; |
| 39 | + |
| 40 | + public MC68000() { |
| 41 | + this(CpuConfig.DEFAULT_CONFIG); |
| 42 | + } |
| 43 | + |
| 44 | + public MC68000(CpuConfig c){ |
| 45 | + cpuConfig = c; |
58 | 46 | i_table = new Instruction[NUM_OPCODES]; |
59 | 47 | unknown = new UNKNOWN(this); |
60 | 48 | for(int i = 0; i < NUM_OPCODES; i++) |
61 | 49 | i_table[i] = unknown; |
62 | 50 | loaded_ops = 0; |
63 | 51 | loadInstructionSet(); |
| 52 | + LOG.info("Using CpuConfig: {}", cpuConfig); |
64 | 53 | } |
65 | 54 |
|
66 | 55 | @Override |
67 | 56 | public int execute() { |
68 | | - if(ENABLE_PREFETCH){ |
| 57 | + if(cpuConfig.enablePrefetch){ |
69 | 58 | return executePrefetch(); |
70 | 59 | } else { |
71 | 60 | return executeNoPrefetch(); |
@@ -95,7 +84,7 @@ private int executeNoPrefetch() { |
95 | 84 |
|
96 | 85 | @Override |
97 | 86 | public int getPrefetchWord(){ |
98 | | - return ENABLE_PREFETCH ? ir : readMemoryWord(reg_pc); |
| 87 | + return cpuConfig.enablePrefetch ? ir : readMemoryWord(reg_pc); |
99 | 88 | } |
100 | 89 |
|
101 | 90 | protected void loadInstructionSet() |
@@ -212,4 +201,9 @@ public Instruction getInstructionAt(int address) |
212 | 201 | int opcode = readMemoryWord(address); |
213 | 202 | return getInstructionFor(opcode); |
214 | 203 | } |
| 204 | + |
| 205 | + @Override |
| 206 | + public CpuConfig getConfig() { |
| 207 | + return cpuConfig; |
| 208 | + } |
215 | 209 | } |
0 commit comments