rendered paste body/*
* No actual license.
* However, I disallow you to use this code for ANY purpose, be it in your own applications or redistributing
* it in either binary or source form. ^.^
*/
// Inclusion Check
#ifndef _Inc_Op_
#define _Inc_Op_
// -- Includes --
// C++
#include <cstdlib>
#include <iostream>
// -- Defines --
// Param in Opcode
#define FirstParam RAM->GetMemory(CPU->PC + 1)
#define SecondParam RAM->GetMemory(CPU->PC + 2)
// Different Addressing Modes -- Value
#define _ZeroPage ZeroPageValue(FirstParam)
#define _ZeroPageX ZeroPageValue(FirstParam, CPU->X)
#define _Absolute AbsoluteValue(FirstParam, SecondParam)
#define _AbsoluteX AbsoluteValue(FirstParam, SecondParam, CPU->X)
#define _AbsoluteY AbsoluteValue(FirstParam, SecondParam, CPU->Y)
#define _IndirectX IndirectXValue(FirstParam)
#define _IndirectY IndirectYValue(FirstParam)
// Different Addressing Modes -- Pointer
#define _ZeroPagePtr RAM->GetMemoryPtr(FirstParam);
#define _ZeroPageXPtr RAM->GetMemoryPtr(ZeroPageAddress(FirstParam, CPU->X));
#define _AbsolutePtr RAM->GetMemoryPtr(AbsoluteAddress(FirstParam, SecondParam));
#define _AbsoluteXPtr RAM->GetMemoryPtr(AbsoluteAddress(FirstParam, SecondParam, CPU->X));
#define _AbsoluteYPtr RAM->GetMemoryPtr(AbsoluteAddress(FirstParam, SecondParam, CPU->Y));
#define _IndirectXPtr RAM->GetMemoryPtr(IndirectXAddress(FirstParam));
#define _IndirectYPtr RAM->GetMemoryPtr(IndirectYAddress(FirstParam));
// -- Name Space --
namespace Opcodes
{
// -- Structs --
// -- Variables --
// -- Functions --
// Load / Store
void LDA(unsigned char Mem); // Set Accumulator
void LDX(unsigned char Mem); // Set X
void LDY(unsigned char Mem); // Set Y
void STA(unsigned char* Mem); // Store Accumulator
void STX(unsigned char* Mem); // Store X
void STY(unsigned char* Mem); // Store Y
// Register Transfers
void pop_Tranfer(unsigned char From, unsigned char* To, bool bSetFlags); // All can be done in one function, pseudo-opcode.
// Stack Operations
// TSX/TXS - Can use the Psuedo-Register tranfer function.
void PHA(); // Push Accumulator onto stack
void PHP(); // Push Processor Status onto stack
void PLA(); // Pull Accumulator from stack
void PLP(); // Pull Processor Status from stack
// Logical
void AND(unsigned char Mem); // Logical AND
void EOR(unsigned char Mem); // Logical Exclusive OR
void ORA(unsigned char Mem); // Logical OR
void BIT(unsigned char Mem); // Bittest
// Arithmetic
void ADC(unsigned char Mem); // Add with carry
void SBC(unsigned char Mem); // Subtract with carry
void CMPXY(unsigned char Register, unsigned char Mem); // Join function for CMP/X/Y.
// Increments / Decrements
void INC(unsigned char* Mem); // Joint function for INC/X/Y
void DEC(unsigned char* Mem); // Joint function for DEC/X/Y
// Shifts / Rotates
void ASL(unsigned char* Mem); // Arithmetic Shift Left
void LSR(unsigned char* Mem); // Logical Shift Right
void ROR(unsigned char* Mem); // Rotate Right
void ROL(unsigned char* Mem); // Rotate left
// Jumps & Calls
void JMP(unsigned short Adr); // Jump to Adr
void JSR(unsigned short Adr); // Save PC/Status to flag and jump
void RTS(); // Pull PC/Status from stack
// Branches
void BCC(unsigned char Loc); // Branch if carry flag clear
void BCS(unsigned char Loc); // Branch if carry flag set
void BEQ(unsigned char Loc); // Branch if zero flag set
void BNE(unsigned char Loc); // Branch if zero flag clear
void BMI(unsigned char Loc); // Branch if negative flag set
void BPL(unsigned char Loc); // Branch if negative flag clear
void BVS(unsigned char Loc); // Branch if overflow flag set
void BVC(unsigned char Loc); // Branch if overflow flag clear
// Status Flag Changes
void CLC(); // Clear carry flag
void CLD(); // Clear decimal flag
void CLI(); // Clear interrupt disable flag
void CLV(); // Clear overflow flag
void SEC(); // Set carry flag
void SED(); // Set decimal mode flag
void SEI(); // Set interrupt disable flag
// System Functions
void BRK(); // Force an interrupt
void RTI(); // Return from interupt
// No NOP, as why bother!?
// Other
// Flags
void SetFlags(unsigned char Mem);
// Switch Opcodes
void SwitchOpcodes();
// </Namespace>
}
// Inclusion check
#endif