Go to the documentation of this file.
15 #ifdef DEBUGGER_ENABLED
236 int AND1(std::pair<uint24_t, uint24_t> operand,
bool invert =
false);
238 int OR1(std::pair<uint24_t, uint24_t> operand,
bool invert =
false);
240 int EOR1(std::pair<uint24_t, uint24_t> operand);
242 int NOT1(std::pair<uint24_t, uint24_t> operand);
244 int MOV1(std::pair<uint24_t, uint24_t> operand,
bool to_carry =
false);
247 int PUSH(uint8_t value);
249 int POP(uint8_t &destination);
256 int TCALL(uint8_t bit);
265 int BRA(int8_t offset);
267 int BEQ(int8_t offset);
269 int BNE(int8_t offset);
271 int BCS(int8_t offset);
273 int BCC(int8_t offset);
275 int BVS(int8_t offset);
277 int BVC(int8_t offset);
279 int BMI(int8_t offset);
281 int BPL(int8_t offset);
283 int BBS(
uint24_t addr, int8_t offset, uint8_t bit);
285 int BBC(
uint24_t addr, int8_t offset, uint8_t bit);
287 int CBNE(
uint24_t addr, int8_t offset,
bool by_x =
false);
289 int DBNZ(int8_t offset,
bool direct_addr =
false);
318 int ASL(
uint24_t operand,
int cycles,
bool accumulator =
false);
320 int LSR(
uint24_t operand,
int cycles,
bool accumulator =
false);
322 int ROL(
uint24_t operand,
int cycles,
bool accumulator =
false);
324 int ROR(
uint24_t operand,
int cycles,
bool accumulator =
false);
331 int INCreg(uint8_t &value);
335 int DECreg(uint8_t &value);
363 int MOV(uint8_t ®From, uint8_t ®To,
bool setFlags =
true);
364 int MOV(uint8_t ®From,
uint24_t memTo,
int cycles,
bool incrementX =
false);
365 int MOV(
uint24_t memFrom, uint8_t ®To,
int cycles,
bool incrementX =
false);
369 APU(
const APU &) =
default;
371 ~APU()
override =
default;
389 [[nodiscard]] std::string
getName()
const override;
407 void update(
unsigned cycles);
412 #ifdef DEBUGGER_ENABLED
uint8_t _getImmediateData()
Get value of the Pointer Counter.
Definition: Operand.cpp:10
uint24_t _getDirectAddrByY()
Get direct page offset and add to it the Y Index Flag.
Definition: Operand.cpp:50
int DAS()
Decimal adjust A for subtraction.
Definition: DecimalCompensation.cpp:22
int CLRV()
Clear Overflow instruction, Set Overflow & Half Carry flags to 0.
Definition: ProgramStatusWord.cpp:27
int ADC(uint24_t operand1, uint24_t operand2, int cycles)
Add operand1 with operand2 and carry.
Definition: 8bitArithmetic.cpp:9
uint24_t _getDirectAddrByX()
Get direct page offset and add to it the X Index Flag.
Definition: Operand.cpp:42
int SBC(uint24_t operand1, uint24_t operand2, int cycles)
Subtract operand1 with operand2 and carry.
Definition: 8bitArithmetic.cpp:36
int BVC(int8_t offset)
Branch if Overflow Flag is set.
Definition: ProgramFlow.cpp:55
int RETI()
Return from interrupt.
Definition: Subroutine.cpp:49
int XCN()
Exchange Nibbles.
Definition: 8bitShiftRotation.cpp:67
uint24_t _getAbsoluteAddrByY()
Get absolute direct page offset and add to it the Y Index Flag.
Definition: Operand.cpp:85
bool b
Break flag.
Definition: APU.hpp:61
int CMP(uint24_t operand1, uint24_t operand2, int cycles)
Compare the two values of the operands and set NZC flags.
Definition: 8bitArithmetic.cpp:63
int PUSH(uint8_t value)
Push a value onto the stack and decrement SP Register.
Definition: Stack.cpp:9
uint24_t _getAbsoluteDirectAddrByY()
Get absolute offset of the direct page and add the Y Index Flag to it.
Definition: Operand.cpp:116
Component
Definition: Components.hpp:9
int ASL(uint24_t operand, int cycles, bool accumulator=false)
Arithmetic Shift Left.
Definition: 8bitShiftRotation.cpp:9
uint8_t port0
Port 0 register.
Definition: APU.hpp:85
InternalRegisters _internalRegisters
Internal registers of the CPU (accessible from the bus via addr $4200 to $421F).
Definition: APU.hpp:143
int RET()
Return from subroutine.
Definition: Subroutine.cpp:42
bool z
Zero flag.
Definition: APU.hpp:55
int MOV1(std::pair< uint24_t, uint24_t > operand, bool to_carry=false)
Either moves the specified bit into carry or moves carry into the specified bit.
Definition: Bit.cpp:74
uint8_t pcl
Definition: APU.hpp:43
uint8_t regmem2
Another Regular Memory register.
Definition: APU.hpp:96
int BBC(uint24_t addr, int8_t offset, uint8_t bit)
Branch if the specified is clear in the address, go to the specified location from the next instructi...
Definition: ProgramFlow.cpp:89
int ANDacc(uint24_t addr, int cycles)
Perform a bitwise AND on the Accumulator flag.
Definition: 8bitLogical.cpp:18
void reset()
This function is executed when the SNES is powered on or the reset button is pushed.
Definition: APU.cpp:170
std::string getName() const override
Get the name of this accessor (used for debug purpose)
Definition: APU.cpp:20
int AND1(std::pair< uint24_t, uint24_t > operand, bool invert=false)
Performs a bitwise AND on the value or inverse value of the specified bit with Carry flag and stores ...
Definition: Bit.cpp:44
uint8_t y
The Y Index register.
Definition: APU.hpp:32
int TCLR1(uint24_t abs)
test clear 1-bit instruction, Test and clear bits with absolute address
Definition: Bit.cpp:35
bool n
Negative flag.
Definition: APU.hpp:67
@ Stopped
Definition: APU.hpp:118
int ROL(uint24_t operand, int cycles, bool accumulator=false)
Rotate Bits Left.
Definition: 8bitShiftRotation.cpp:38
void update(unsigned cycles)
This function execute the instructions received until the maximum number of cycles is reached.
Definition: APU.cpp:799
void _setNZflags(uint8_t value)
Set Negative and Zero flags with value after an instruction.
Definition: APU.cpp:890
int BCS(int8_t offset)
Branch if Carry Flag is set.
Definition: ProgramFlow.cpp:31
uint8_t counter1
Counter-1 register.
Definition: APU.hpp:108
int INCreg(uint8_t &value)
Increment a register.
Definition: 8bitIncrementDecrement.cpp:18
int INC(uint24_t addr, int cycles)
Increment a value at an address.
Definition: 8bitIncrementDecrement.cpp:9
int SBCacc(uint24_t addr, int cycles)
Subtract Accumulator Flag with address and carry.
Definition: 8bitArithmetic.cpp:50
uint24_t _getAbsoluteAddrByX()
Get absolute direct page offset and add to it the X Index Flag.
Definition: Operand.cpp:78
uint8_t regmem1
Regular Memory register.
Definition: APU.hpp:94
bool v
Overflow flag.
Definition: APU.hpp:65
uint8_t sp
The Stack pointer register.
Definition: APU.hpp:38
int ORacc(uint24_t addr, int cycles)
Perform a bitwise OR on the Accumulator flag.
Definition: 8bitLogical.cpp:34
int NOT1(std::pair< uint24_t, uint24_t > operand)
Performs a logical NOT on the value of the specified bit and stores the result.
Definition: Bit.cpp:68
int EOR1(std::pair< uint24_t, uint24_t > operand)
Performs a exclusive OR on the value of the bit specified with Carry flag and stores the result in th...
Definition: Bit.cpp:62
uint24_t _getIndexXAddr()
Get Index X offset.
Definition: Operand.cpp:24
int JMP(uint24_t addr, bool by_x=false)
Jump to the specified location.
Definition: ProgramFlow.cpp:127
uint8_t x
The X index register.
Definition: APU.hpp:24
uint8_t port1
Port 1 register.
Definition: APU.hpp:87
int INCW(uint24_t addr)
Increment a word value.
Definition: 16bitArithmetic.cpp:9
uint8_t counter0
Counter-0 register.
Definition: APU.hpp:106
int CLRC()
Clear Carry instruction, set Carry flag to 0.
Definition: ProgramStatusWord.cpp:9
uint8_t port2
Port 2 register.
Definition: APU.hpp:89
int SETP()
Set Direct Page instruction, Set Direct Page flag to 1.
Definition: ProgramStatusWord.cpp:40
uint8_t read(uint24_t addr) override
Read from the APU ram.
Definition: APU.cpp:129
MemoryMap & operator=(const MemoryMap &)=delete
unsigned uint24_t
Definition: Ints.hpp:10
uint8_t unknown
An undocumented register.
Definition: APU.hpp:76
int STOP()
Stop instruction, halts the processor with STOP mode.
Definition: Standbys.cpp:20
int BEQ(int8_t offset)
Branch if Zero Flag is set.
Definition: ProgramFlow.cpp:15
uint24_t _getAbsoluteAddr()
Get absolute direct page offset.
Definition: Operand.cpp:58
int DIV()
Divide the 16-bit value YA by X, storing the quotient in A and the remainder in Y.
Definition: MultiplicationDivision.cpp:17
int EORacc(uint24_t addr, int cycles)
Perform an Exclusive OR on the Accumulator flag.
Definition: 8bitLogical.cpp:50
uint8_t ctrlreg
Control Register register.
Definition: APU.hpp:79
uint8_t timer2
Timer-2 register.
Definition: APU.hpp:103
int AND(uint24_t operand1, uint24_t operand2, int cycles)
Perform a bitwise AND.
Definition: 8bitLogical.cpp:9
int SLEEP()
Sleep instruction, halts the processor with SLEEP mode.
Definition: Standbys.cpp:14
int CMPreg(uint8_t ®, uint24_t addr, int cycles)
Compare a Register Flag with the value of the operand and set NZC flags.
Definition: 8bitArithmetic.cpp:72
int OR1(std::pair< uint24_t, uint24_t > operand, bool invert=false)
Performs a bitwise OR on the value or inverse value of the specified bit with Carry flag and stores t...
Definition: Bit.cpp:53
bool c
Carry flag.
Definition: APU.hpp:53
void loadFromSPC(Cartridge::Cartridge &cartridge)
Parses rom data to uploads directly into RAM and corresponding registers.
Definition: APU.cpp:819
uint8_t port3
Port 3 register.
Definition: APU.hpp:91
int BNE(int8_t offset)
Branch if Zero Flag is clear.
Definition: ProgramFlow.cpp:23
DSP::DSP _dsp
The DSP component used to produce sound.
Definition: APU.hpp:149
int DECreg(uint8_t &value)
Decrement a register.
Definition: 8bitIncrementDecrement.cpp:34
int NOP()
No Operation instruction, do nothing than delay.
Definition: Standbys.cpp:9
int MUL()
Store the 16-bit value of Y * A into YA.
Definition: MultiplicationDivision.cpp:9
uint24_t _getAbsoluteByXAddr()
_get absolute direct page + X Index offset
Definition: Operand.cpp:66
Component getComponent() const override
Get the component of this accessor (used for debug purpose)
Definition: APU.cpp:25
int CLR1(uint24_t dp, uint8_t bit)
Clear 1-bit instruction, clear a bit in direct page.
Definition: Bit.cpp:18
void _internalWrite(uint24_t addr, uint8_t data)
Write data to the APU ram.
Definition: APU.cpp:70
int ADDW(uint24_t addr)
Add YA with a word value.
Definition: 16bitArithmetic.cpp:33
int DBNZ(int8_t offset, bool direct_addr=false)
Decrement a value then branch to the specified location if the value is not zero.
Definition: ProgramFlow.cpp:109
int SUBW(uint24_t addr)
Subtract YA with a word value.
Definition: 16bitArithmetic.cpp:48
int BCC(int8_t offset)
Branch if Carry Flag is clear.
Definition: ProgramFlow.cpp:39
int CMPW(uint24_t addr)
Compare YA with a word value.
Definition: 16bitArithmetic.cpp:66
int DEC(uint24_t addr, int cycles)
Decrement a value at an address.
Definition: 8bitIncrementDecrement.cpp:25
uint8_t psw
Definition: APU.hpp:69
Ram::Ram Page0
Zero page memory.
Definition: APU.hpp:124
StateMode
Definition: APU.hpp:114
uint24_t _getIndexYAddr()
Get Index Y offset.
Definition: Operand.cpp:33
uint8_t _internalRead(uint24_t addr) const
Read from the APU ram.
Definition: APU.cpp:30
APU(Renderer::IRenderer &renderer)
Definition: APU.cpp:14
int OR(uint24_t operand1, uint24_t operand2, int cycles)
Perform a bitwise OR.
Definition: 8bitLogical.cpp:25
int MOVW(uint24_t addr, bool to_ya=false)
Sets a word value equal to another.
Definition: 16bitDataTransmission.cpp:9
int CALL(uint24_t abs)
Push PC of the next instruction on the stack, then jump to the address at the specified location.
Definition: Subroutine.cpp:10
int SET1(uint24_t dp, uint8_t bit)
Set 1-bit instruction, set a bit in direct page.
Definition: Bit.cpp:10
uint24_t getSize() const override
Get the size of the data. This size can be lower than the mapped data.
Definition: APU.cpp:165
bool isDisabled
Is this APU disabled?
Definition: APU.hpp:374
int LSR(uint24_t operand, int cycles, bool accumulator=false)
Logical Shift Right.
Definition: 8bitShiftRotation.cpp:23
Ram::Ram Page1
Stack space memory.
Definition: APU.hpp:126
Abstract class representing a continuous block of memory.
Definition: AMemory.hpp:18
IPL::IPL IPL
IPL ROM.
Definition: APU.hpp:130
uint16_t ya
Definition: APU.hpp:34
MemoryMap()
Definition: APU.cpp:896
int NOTC()
Complement Carry instruction, invert Carry flag value.
Definition: ProgramStatusWord.cpp:21
int TCALL(uint8_t bit)
Performs a call on one of the 16 vectors in the memory range of $FFC0 to $FFDF.
Definition: Subroutine.cpp:24
Contains the rom's memory/instructions.
Definition: Cartridge.hpp:78
Registers _registers
All the registers of the APU CPU.
Definition: APU.hpp:141
std::string getValueName(uint24_t addr) const override
Get the name of the data at the address.
Definition: DecimalCompensation.cpp:34
APU & operator=(const APU &)=delete
Definition: IRenderer.hpp:15
int EI()
Enable interrupts instruction, Set Zero flag to 1.
Definition: ProgramStatusWord.cpp:46
uint24_t _getAbsoluteDirectByXAddr()
Get absolute offset of the direct page added to the X Index Flag.
Definition: Operand.cpp:104
int SETC()
Set Carry instruction, Set Carry flag to 1.
Definition: ProgramStatusWord.cpp:15
Ram::Ram Memory
Any-use memory.
Definition: APU.hpp:128
int DECW(uint24_t addr)
Decrement a word value.
Definition: 16bitArithmetic.cpp:21
@ Running
Definition: APU.hpp:116
int EOR(uint24_t operand1, uint24_t operand2, int cycles)
Perform an Exclusive OR.
Definition: 8bitLogical.cpp:41
unsigned int _paddingCycles
Keep the number of excess cycles executed to pad the next update.
Definition: APU.hpp:167
int CBNE(uint24_t addr, int8_t offset, bool by_x=false)
Branch if the value at the specified address is not equal to the Accumulator Flag.
Definition: ProgramFlow.cpp:99
uint8_t counter2
Counter-2 register.
Definition: APU.hpp:110
void write(uint24_t addr, uint8_t data) override
Write data to the APU ram.
Definition: APU.cpp:145
bool h
Half carry flag.
Definition: APU.hpp:59
int BRK()
Cause a software interrupt.
Definition: Subroutine.cpp:30
bool p
Direct page flag.
Definition: APU.hpp:63
StateMode _state
Current state of APU CPU.
Definition: APU.hpp:164
int PCALL()
Perform a call in the upper page of memory, read PC Register and add 0xFF00 to it.
Definition: Subroutine.cpp:18
int BBS(uint24_t addr, int8_t offset, uint8_t bit)
Branch if the specified is set in the address, go to the specified location from the next instruction...
Definition: ProgramFlow.cpp:79
uint8_t a
The Accumulator register.
Definition: APU.hpp:30
int CLRP()
Clear Direct Page instruction, Set Direct Page flag to 0.
Definition: ProgramStatusWord.cpp:34
int POP(uint8_t &destination)
Increment SP Register and pop a single value from the stack.
Definition: Stack.cpp:15
int BVS(int8_t offset)
Branch if Overflow Flag is set.
Definition: ProgramFlow.cpp:47
bool i
Interrupt enabled flag.
Definition: APU.hpp:57
uint24_t _getDirectAddr()
Get direct page offset.
Definition: Operand.cpp:15
uint8_t timer1
Timer-1 register.
Definition: APU.hpp:101
int ADCacc(uint24_t addr, int cycles)
!
Definition: 8bitArithmetic.cpp:23
int _executeInstruction()
Execute a single instruction.
Definition: APU.cpp:184
std::pair< uint24_t, uint24_t > _getAbsoluteBit()
Get absolute offset and separate its bits.
Definition: Operand.cpp:92
int DAA()
Decimal adjust A for addition.
Definition: DecimalCompensation.cpp:9
MemoryMap _map
Internal APU memory separated according to their utility.
Definition: APU.hpp:146
Definition: APUDebug.hpp:54
int DI()
Disable interrupts instruction, Set Zero flag to 0.
Definition: ProgramStatusWord.cpp:52
uint16_t pc
Definition: APU.hpp:46
uint8_t pch
Definition: APU.hpp:44
int BRA(int8_t offset)
Branch Always, go to the specified location from the next instruction.
Definition: ProgramFlow.cpp:9
int ROR(uint24_t operand, int cycles, bool accumulator=false)
Rotate Bits Right.
Definition: 8bitShiftRotation.cpp:52
uint8_t dspregAddr
DSP Register Address register.
Definition: APU.hpp:82
int TSET1(uint24_t abs)
test set 1-bit instruction, Test and set bits with absolute address
Definition: Bit.cpp:26
uint8_t timer0
Timer-0 register.
Definition: APU.hpp:99
int BPL(int8_t offset)
Branch if Negative Flag is clear.
Definition: ProgramFlow.cpp:71
int BMI(int8_t offset)
Branch if Negative Flag is set.
Definition: ProgramFlow.cpp:63
int MOV(uint8_t ®From, uint8_t ®To, bool setFlags=true)
Definition: 8bitDataTransmission.cpp:27
@ Sleeping
Definition: APU.hpp:117