Skip to content

Commit 4f43f69

Browse files
committed
Changed memoryMap usage to memory.readMemory and memory.writeMemory in Cpu6502.
1 parent c3bea36 commit 4f43f69

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

core/src/main/java/emu/jvic/cpu/Cpu6502.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ public void reset() {
721721
* @param address the address of the word to get.
722722
*/
723723
private int getWordFromMemory(int address) {
724-
return (memoryMap[address].readMemory(address) | ((memoryMap[address + 1].readMemory(address + 1) << 8) & 0xFF00));
724+
return (memory.readMemory(address) | ((memory.readMemory(address + 1) << 8) & 0xFF00));
725725
}
726726

727727
/**
@@ -1385,7 +1385,7 @@ public void emulateCycle() {
13851385

13861386
case EXECUTE_BRANCH:
13871387
// Fetch offset
1388-
inputDataLatch = memoryMap[programCounter].readMemory(programCounter);
1388+
inputDataLatch = memory.readMemory(programCounter);
13891389
programCounter++;
13901390
// Execute the branch test.
13911391
executeInstruction();
@@ -1418,7 +1418,7 @@ public void emulateCycle() {
14181418
displayCurrentInstruction();
14191419
}
14201420
// No interrupts, so proceed to next instruction.
1421-
instructionRegister = memoryMap[programCounter].readMemory(programCounter);
1421+
instructionRegister = memory.readMemory(programCounter);
14221422
programCounter++;
14231423
instructionSteps = INSTRUCTION_DECODE_MATRIX[instructionRegister];
14241424
delayInterruptOneCycle = false;
@@ -1483,23 +1483,23 @@ public void emulateCycle() {
14831483
break;
14841484

14851485
case FETCH_ADH_FFFB:
1486-
effectiveAddressHigh = (memoryMap[0xFFFB].readMemory(0xFFFB) << 8);
1486+
effectiveAddressHigh = (memory.readMemory(0xFFFB) << 8);
14871487
break;
14881488

14891489
case FETCH_ADH_FFFF:
1490-
effectiveAddressHigh = (memoryMap[0xFFFF].readMemory(0xFFFF) << 8);
1490+
effectiveAddressHigh = (memory.readMemory(0xFFFF) << 8);
14911491
break;
14921492

14931493
case FETCH_ADH_PC:
14941494
// Program counter is highly unlikely to be pointing at I/O
1495-
effectiveAddressHigh = (memoryMap[programCounter].readMemory(programCounter) << 8);
1495+
effectiveAddressHigh = (memory.readMemory(programCounter) << 8);
14961496
programCounter++;
14971497
break;
14981498

14991499
case FETCH_ADH_IA:
15001500
// Only used by JMP, so not likely to have IO address involved.
15011501
int indirectAddress = indirectAddressHigh | indirectAddressLow;
1502-
effectiveAddressHigh = (memoryMap[indirectAddress].readMemory(indirectAddress) << 8);
1502+
effectiveAddressHigh = (memory.readMemory(indirectAddress) << 8);
15031503
break;
15041504

15051505
case FETCH_ADL_BAL:
@@ -1509,23 +1509,23 @@ public void emulateCycle() {
15091509
break;
15101510

15111511
case FETCH_ADL_FFFA:
1512-
effectiveAddressLow = memoryMap[0xFFFA].readMemory(0xFFFA);
1512+
effectiveAddressLow = memory.readMemory(0xFFFA);
15131513
break;
15141514

15151515
case FETCH_ADL_FFFE:
1516-
effectiveAddressLow = memoryMap[0xFFFE].readMemory(0xFFFE);
1516+
effectiveAddressLow = memory.readMemory(0xFFFE);
15171517
break;
15181518

15191519
case FETCH_ADL_PC:
15201520
// Program counter is highly unlikely to be pointing at I/O
1521-
effectiveAddressLow = memoryMap[programCounter].readMemory(programCounter);
1521+
effectiveAddressLow = memory.readMemory(programCounter);
15221522
programCounter++;
15231523
break;
15241524

15251525
case FETCH_ADL_IA:
15261526
// Only used by JMP, so not likely to have IO address involved.
15271527
indirectAddress = indirectAddressHigh | indirectAddressLow;
1528-
effectiveAddressLow = memoryMap[indirectAddress].readMemory(indirectAddress);
1528+
effectiveAddressLow = memory.readMemory(indirectAddress);
15291529
indirectAddressLow = ((indirectAddressLow + 1) & 0xFF); // Well known NMOS 6502 bug
15301530
break;
15311531

@@ -1536,7 +1536,7 @@ public void emulateCycle() {
15361536

15371537
case FETCH_BAH_PC:
15381538
// Program counter is highly unlikely to be pointing at I/O
1539-
baseAddressHigh = (memoryMap[programCounter].readMemory(programCounter) << 8);
1539+
baseAddressHigh = (memory.readMemory(programCounter) << 8);
15401540
programCounter++;
15411541
break;
15421542

@@ -1548,7 +1548,7 @@ public void emulateCycle() {
15481548

15491549
case FETCH_BAL_PC:
15501550
// Program counter is highly unlikely to be pointing at I/O
1551-
baseAddressLow = memoryMap[programCounter].readMemory(programCounter);
1551+
baseAddressLow = memory.readMemory(programCounter);
15521552
programCounter++;
15531553
break;
15541554

@@ -1602,7 +1602,7 @@ public void emulateCycle() {
16021602

16031603
case FETCH_DATA_PC:
16041604
// Program counter is highly unlikely to be pointing at I/O
1605-
inputDataLatch = memoryMap[programCounter].readMemory(programCounter);
1605+
inputDataLatch = memory.readMemory(programCounter);
16061606
programCounter++;
16071607
break;
16081608

@@ -1651,7 +1651,7 @@ public void emulateCycle() {
16511651
// IRQ, NMI)
16521652
// TODO: Apparently it does fetch data using PC, but having this here affects
16531653
// the sound. ?!
1654-
// memoryMap[programCounter].readMemory(programCounter);
1654+
// memory.readMemory(programCounter);
16551655
break;
16561656

16571657
case FETCH_DIS_SP:
@@ -1660,19 +1660,19 @@ public void emulateCycle() {
16601660

16611661
case FETCH_IAH_PC:
16621662
// Program counter is highly unlikely to be pointing at I/O
1663-
indirectAddressHigh = (memoryMap[programCounter].readMemory(programCounter) << 8);
1663+
indirectAddressHigh = (memory.readMemory(programCounter) << 8);
16641664
programCounter++;
16651665
break;
16661666

16671667
case FETCH_IAL_PC:
16681668
// Program counter is highly unlikely to be pointing at I/O
1669-
indirectAddressLow = memoryMap[programCounter].readMemory(programCounter);
1669+
indirectAddressLow = memory.readMemory(programCounter);
16701670
programCounter++;
16711671
break;
16721672

16731673
case FETCH_INC_PC:
16741674
// Fetch using PC, discard data, then increment PC.
1675-
memoryMap[programCounter].readMemory(programCounter);
1675+
memory.readMemory(programCounter);
16761676
programCounter++;
16771677
break;
16781678

@@ -1757,7 +1757,7 @@ public void emulateCycle() {
17571757
displayCurrentInstruction();
17581758
}
17591759
// No interrupts, so proceed to next instruction.
1760-
instructionRegister = memoryMap[programCounter].readMemory(programCounter);
1760+
instructionRegister = memory.readMemory(programCounter);
17611761
programCounter++;
17621762
instructionSteps = INSTRUCTION_DECODE_MATRIX[instructionRegister];
17631763
delayInterruptOneCycle = false;

0 commit comments

Comments
 (0)