Fixed timer increase
This commit is contained in:
@@ -54,6 +54,12 @@ public class Memory
|
||||
setDataFromIndirectAddress(indirectAddress, data);
|
||||
return;
|
||||
}
|
||||
if(address == 0x01) //Reset PrescalerCounter if change on Option or Timer Register
|
||||
{
|
||||
Timer.resetTimeToTimerIncrease();
|
||||
Timer.setCyclesToTimerIncrease(Timer.getCyclesToTimerIncrease() - 1); //Decrease by one to account for
|
||||
// this command execution
|
||||
}
|
||||
if((Arrays.stream(bank0UniqueSpecialRegister).anyMatch(x -> x == address)) && getRegisterBank() == 0)
|
||||
{
|
||||
memory[address] = data;
|
||||
@@ -67,10 +73,6 @@ public class Memory
|
||||
}
|
||||
memory[address] = data;
|
||||
memory[address + 128] = data; //Ensure data is written to both banks to simulate mapping
|
||||
if(address == 0x01) //Reset PrescalerCounter if change on Option or Timer Register
|
||||
{
|
||||
Timer.resetTimeToTimerIncrease();
|
||||
}
|
||||
if(address == 0x2) //Check if PCL is destination
|
||||
{
|
||||
ProgramCounter.loadPc();
|
||||
@@ -84,6 +86,12 @@ public class Memory
|
||||
|
||||
private static void setDataFromIndirectAddress(int address, int data)
|
||||
{
|
||||
if(address == 0x81 || address == 0x01) //Reset PrescalerCounter if change on Option or Timer Register
|
||||
{
|
||||
Timer.resetTimeToTimerIncrease();
|
||||
Timer.setCyclesToTimerIncrease(Timer.getCyclesToTimerIncrease() - 1); //Decrease by one to account for
|
||||
// this command execution
|
||||
}
|
||||
if((Arrays.stream(bank0UniqueSpecialRegister).anyMatch(x -> x == address)) || (Arrays.stream(bank1UniqueSpecialRegister).anyMatch(x -> x == address)))
|
||||
{
|
||||
memory[address] = data;
|
||||
@@ -91,14 +99,6 @@ public class Memory
|
||||
}
|
||||
memory[address % 128] = data; // else: Registers.Registers which are mapped
|
||||
memory[address % 128 + 128] = data; //Ensure data is written to both banks to simulate mapping
|
||||
if(address == 0x81 || address == 0x01) //Reset PrescalerCounter if change on Option or Timer Register
|
||||
{
|
||||
Timer.resetTimeToTimerIncrease();
|
||||
}
|
||||
if(address == 0x2 || address == 0x82) //Check if PCL is destination
|
||||
{
|
||||
ProgramCounter.loadPc();
|
||||
}
|
||||
}
|
||||
|
||||
private static int getRegisterBank()
|
||||
|
||||
@@ -2,6 +2,16 @@ package de.darkress.pic16f84sim.microcontroller;
|
||||
|
||||
public class Timer
|
||||
{
|
||||
public static int getCyclesToTimerIncrease()
|
||||
{
|
||||
return cyclesToTimerIncrease;
|
||||
}
|
||||
|
||||
public static void setCyclesToTimerIncrease(int cyclesToTimerIncrease)
|
||||
{
|
||||
Timer.cyclesToTimerIncrease = cyclesToTimerIncrease;
|
||||
}
|
||||
|
||||
private static int cyclesToTimerIncrease = 1;
|
||||
|
||||
private static boolean timerEnabled()
|
||||
|
||||
Reference in New Issue
Block a user