PancakeNESEmu
A homebrewed NES Emulator written in C
|
Go to the source code of this file.
Classes | |
struct | CPU |
This structure will be used to represent the state of the Central Processing Unit (CPU) of our emulator. This Virtual CPU emulates a "MOS Technology 6502". More... | |
Macros | |
#define | GET_C_FLAG(x) |
#define | GET_Z_FLAG(x) |
#define | GET_I_FLAG(x) |
#define | GET_D_FLAG(x) |
#define | GET_B_FLAG(x) |
#define | GET_P_FLAG(x) |
#define | GET_V_FLAG(x) |
#define | GET_N_FLAG(x) |
#define | SET_C_FLAG(x) |
#define | SET_Z_FLAG(x) |
#define | SET_I_FLAG(x) |
#define | SET_D_FLAG(x) |
#define | SET_B_FLAG(x) |
#define | SET_P_FLAG(x) |
#define | SET_V_FLAG(x) |
#define | SET_N_FLAG(x) |
#define | SET_ALL_FLAGS(x) |
#define | CLEAR_C_FLAG(x) |
#define | CLEAR_Z_FLAG(x) |
#define | CLEAR_I_FLAG(x) |
#define | CLEAR_D_FLAG(x) |
#define | CLEAR_B_FLAG(x) |
#define | CLEAR_P_FLAG(x) |
#define | CLEAR_V_FLAG(x) |
#define | CLEAR_N_FLAG(x) |
#define | CLEAR_ALL_FLAGS(x) |
#define | indexed_indirect(cpu, addr, offset) |
Macro to access memory by indexed indirect addressing mode. | |
#define | indirect_indexed(cpu, addr, offset) |
Macro to access memory by indirect indexed addressing mode. | |
#define | indirect(cpu, addr) |
Macro to access memory by indirect addressing mode. | |
#define | get_address(cpu) |
Macro to recreate the current address pointed by pc + 1. | |
#define | is_page_crossed(addr, offset) |
Macro to know if we cross a page when doing the instruction. | |
#define | LD_FLAGS_GENERIC(cpu, reg) |
Procedure that flips the correct flags when loading a value in a register. | |
#define | LD_immediate_GENERIC(cpu, reg, d) |
Procedure that loads an immediate (const value) in a register. | |
#define | LD_immediate_ACC(processor, d) |
Procedure that loads an immediate (const value) in the accumulator. | |
#define | LD_immediate_X(processor, d) |
Procedure that loads an immediate (const value) in the X register. | |
#define | LD_immediate_Y(processor, d) |
Procedure that loads an immediate (const value) in the Y register. | |
#define | LD_offset_GENERIC(cpu, reg, addr, offset) |
Procedure that loads a value from memory at address addr+offset to a register. | |
#define | LD_offset_ACC(processor, addr, offset) |
Procedure that loads a value from memory at address addr+offset to the X register. | |
#define | LD_offset_X(processor, addr, offset) |
Procedure that loads a value from memory at address addr+offset to the X register. | |
#define | LD_offset_Y(processor, addr, offset) |
Procedure that loads a value from memory at address addr+offset to the Y register. | |
#define | LD_absolute_GENERIC(cpu, reg, addr) |
Procedure that loads a value from memory at the address adr to a register. | |
#define | LD_absolute_ACC(processor, addr) |
Procedure that loads a value from memory at the address addr to the accumulator. | |
#define | LD_absolute_X(processor, addr) |
Procedure that loads a value from memory at the address addr to the X register. | |
#define | LD_absolute_Y(processor, addr) |
Procedure that loads a value from memory at the address addr to the Y register. | |
#define | LD_indirect_GENERIC(cpu, reg, addr) |
Procedure that loads a value from memory at the address: mem[addr] | mem[addr+1]. | |
#define | LD_indirect_ACC(processor, addr) |
Procedure that lods a value from memory at the address contained in addr|addr+1. (indirection) | |
#define | LD_indirect_X(processor, addr) |
Procedure that lods a value from memory at the address contained in addr|addr+1. (indirection) | |
#define | LD_indirect_Y(processor, addr) |
Procedure that lods a value from memory at the address contained in addr|addr+1. (indirection) | |
#define | DECINC_GENERIC(cpu, reg, op) |
Procedure that increments the register reg. | |
#define | DEC_absolute(processor, addr) |
Procedure that decrement a specific memory location. | |
#define | INC_absolute(processor, addr) |
Procedure that increment a specific memory location. | |
#define | DEC_offset(processor, addr, offset) |
Procedure that decrement a specific memory location. | |
#define | INC_offset(processor, addr, offset) |
Procedure that increment a specific memory location. | |
#define | INC_X(processor) |
Procedure that increments the X register. | |
#define | INC_Y(processor) |
Procedure that increments the Y register. | |
#define | DEC_X(processor) |
Procedure that decrements the X register. | |
#define | DEC_Y(processor) |
Procedure that decrements the Y register. | |
#define | LD_indexed_indirect_ACC(processor, addr, offset) |
Procedure that loads to the accumulator using Indexed Indirect. | |
#define | LD_indirect_indexed_ACC(processor, addr, offset) |
Procedure that loads to the accmulator using Inderect Indexed. | |
#define | STR_absolute_GENERIC(cpu, reg, addr) |
Procedure that store the register reg value to a memory address. | |
#define | STR_absolute_ACC(processor, addr) |
Procedure that store the accumulator value to a memory address. | |
#define | STR_absolute_X(processor, addr) |
Procedure that store the X register value to a memory address. | |
#define | STR_absolute_Y(processor, addr) |
Procedure that store the Y register value to a memory address. | |
#define | STR_offset_GENERIC(cpu, reg, addr, offset) |
Procedure that store the register reg value to a memory address + offset. | |
#define | STR_offset_ACC(processor, addr, offset) |
Procedure that store the accumulator value to a memory address + offset. | |
#define | STR_offset_X(processor, addr, offset) |
Procedure that store the X register value to a memory address + offset. | |
#define | STR_offset_Y(processor, addr, offset) |
Procedure that store the Y register value to a memory address + offset. | |
#define | STR_indirect_indexed_ACC(processor, addr, offset) |
Procedure that store the accumulator value to a memory address using indirect indexed addressing mode. | |
#define | STR_indexed_indirect_ACC(processor, addr, offset) |
Procedure that store the accumulator value to a memory address using indexes indirect addressing mode. | |
#define | TR_GENERIC(cpu, reg1, reg2) |
Procedure that store the value in reg1 in reg2. | |
#define | TR_ACC_X(processor) |
Procedure that store the value in the accumulator in the X register. | |
#define | TR_ACC_Y(processor) |
Procedure that store the value in accumulator in the Y register. | |
#define | TR_X_ACC(processor) |
Procedure that store the value in the X register in the accumulator. | |
#define | TR_Y_ACC(processor) |
Procedure that store the value in the Y register in the accumulator. | |
#define | TR_SP_X(processor) |
Procedure that store the stack pointer in the X register. | |
#define | TR_X_SP(processor) |
Procedure that store the value in the X register in the stack pointer. | |
#define | PUSH_GENERIC(cpu, reg) |
Procedure that push the reg value to the top of the stack. | |
#define | PUSH_immediate(cpu, d) |
Procedure that push an immediate value to the top of the stack. | |
#define | PUSH_ACC(processor) |
Procedure that push the accumulator value to the top of the stack. | |
#define | PUSH_FLAGS(processor) |
Procedure that push the processor flags to the top of the stack. | |
#define | PUSH_PC(processor) |
Procedure that push the program_counter to the top of the stack. | |
#define | PULL_GENERIC(cpu, reg) |
Procedure that pop the top value of the stack and return it to the register reg. | |
#define | PULL_ACC(processor) |
Procedure that pop the top value of the stack and return it to the accumulator. | |
#define | PULL_FLAGS(processor) |
Procedure that pop the top value of the stack and return it to the flags register. | |
#define | PULL_PC(processor) |
Procedure that pop the top value of the stack and return it to the program counter. | |
#define | ADD_immediate(processor, data) |
Procedure that perform a ADD with the carry flag (A,Z,C,N=A+data+C) with an immediate. | |
#define | ADD_absolute(processor, addr) |
Procedure that perform a ADD with the carry flag (A,Z,C,N=A+M+C) with absolute addressing mode. | |
#define | ADD_offset(processor, addr, offset) |
Procedure that perform a ADD with the carry flag (A,Z,C,N=A+M+C) with absolute+offset addressing addressing. | |
#define | ADD_indexed_indirect(processor, addr, offset) |
Procedure that perform a ADD with the carry flag (A,Z,C,N=A+M+C) with indexed indirect addressing mode. | |
#define | ADD_indirect_indexed(processor, addr, offset) |
Procedure that perform a ADD with the carry flag (A,Z,C,N=A+M+C) with indirect indexed. | |
#define | LOGICAL_FLAGS(processor) |
Procedure that performs the test for every bitwise logic operations. | |
#define | AND_immediate(processor, data) |
Procedure that performs a bitwise logic AND (A,Z,N = A & data) | |
#define | AND_absolute(processor, addr) |
Procedure that performs a bitwise logic AND (A,Z,N = A&M) using absolute addressing mode. | |
#define | AND_offset(processor, addr, offset) |
Procedure that performs a bitwise logic AND (A,Z,N = A&M) using offset addressing mode. | |
#define | AND_indexed_indirect(processor, addr, offset) |
Procedure that perform a AND with the carry flag (A,Z,C,N=A+M+C) with indexed indirect addressing mode. | |
#define | AND_indirect_indexed(processor, addr, offset) |
Procedure that perform a AND with the carry flag (A,Z,C,N=A+M+C) with indirect indexed. | |
#define | OR_immediate(processor, data) |
Procedure that performs a bitwise logic OR (A,Z,N = A & data) | |
#define | OR_absolute(processor, addr) |
Procedure that performs a bitwise logic OR (A,Z,N = A&M) using absolute addressing mode. | |
#define | OR_offset(processor, addr, offset) |
Procedure that performs a bitwise logic OR (A,Z,N = A&M) using offset addressing mode. | |
#define | OR_indexed_indirect(processor, addr, offset) |
Procedure that perform a OR with the carry flag (A,Z,C,N=A+M+C) with indexed indirect addressing mode. | |
#define | OR_indirect_indexed(processor, addr, offset) |
Procedure that perform a OR with the carry flag (A,Z,C,N=A+M+C) with indirect indexed. | |
#define | XOR_immediate(processor, data) |
Procedure that performs a bitwise logic XOR (A,Z,N = A & data) | |
#define | XOR_absolute(processor, addr) |
Procedure that performs a bitwise logic XOR (A,Z,N = A&M) using absolute addressing mode. | |
#define | XOR_offset(processor, addr, offset) |
Procedure that performs a bitwise logic XOR (A,Z,N = A&M) using offset addressing mode. | |
#define | XOR_indexed_indirect(processor, addr, offset) |
Procedure that perform a XOR with the carry flag (A,Z,C,N=A+M+C) with indexed indirect addressing mode. | |
#define | XOR_indirect_indexed(processor, addr, offset) |
Procedure that perform a XOR with the carry flag (A,Z,C,N=A+M+C) with indirect indexed. | |
#define | SBC_immediate(processor, data) |
Procedure that perform a substract with the carry flag (A,Z,C,N=A-data-C) with an immediate. | |
#define | SBC_absolute(processor, addr) |
Procedure that perform a SBC with the carry flag (A,Z,C,N=A-M-C) with absolute addressing mode. | |
#define | SBC_offset(processor, addr, offset) |
Procedure that perform a SBC with the carry flag (A,Z,C,N=A-M-C) with offset addressing mode. | |
#define | SBC_indexed_indirect(processor, addr, offset) |
Procedure that perform a SBC with the carry flag (A,Z,C,N=A-M-C) with indexed indirect addressing mode. | |
#define | SBC_indirect_indexed(processor, addr, offset) |
Procedure that perform a SBC with the carry flag (A,Z,C,N=A-M-C) with indirect indexed addressing mode. | |
#define | NO_OPERATION() |
Procedure that litteraly does nothing. | |
#define | BIT_TEST(processor, addr) |
Procedure that performs a BIT test (A & M, N = M7, V = M6) | |
#define | BRANCH_GENERIC_S(processor, flag_mask, offset) |
Procedure that performs a BRANCH instruction for the FLAG. | |
#define | BRANCH_GENERIC_C(processor, flag_mask, offset) |
Procedure that performs a BRANCH instruction for the FLAG. | |
#define | BRANCH_If_Positive(processor, offset) |
Procedure that performs a BPL (branch if positive, if the N flag is clear) | |
#define | BRANCH_Overflow_C(processor, offset) |
Procedure that performs a BVC (branch if overflow clear, if the V flag is clear) | |
#define | BRANCH_Not_Equal(processor, offset) |
Procedure that performs a BNE (if the Z flag is clear) | |
#define | BRANCH_Carry_C(processor, offset) |
Procedure that performs a BCC (if the C flag is clear) | |
#define | BRANCH_If_Minus(processor, offset) |
Procedure that performs a BMI (branch if positive, if the N flag is clear) | |
#define | BRANCH_Overflow_S(processor, offset) |
Procedure that performs a BVS (branch if positive, if the N flag is clear) | |
#define | BRANCH_Equal(processor, offset) |
Procedure that performs a BEQ (branch if positive, if the N flag is clear) | |
#define | BRANCH_Carry_S(processor, offset) |
Procedure that performs a BCS (branch if positive, if the N flag is clear) | |
#define | SHIFT_GENERIC(processor, field, operator, flag_shift_offset, flag_mask) |
Procedure that performs a Bitshift of 1 using a specified operator and placing the overflowing bit inside of the carry flag. | |
#define | SHIFT_LEFT_ACC(processor) |
Procedure that performs a bitshift to the left (ASL operation) on the accumulator and place the 7th bit inside of the Carry flag. | |
#define | SHIFT_RIGHT_ACC(processor) |
Procedure that performs a bitshift to the right (LSR operation) on the accumulator and place the 0th bit inside of the Carry flag. | |
#define | SHIFT_LEFT_absolute(processor, addr) |
Procedure that performs a bitshift to the left (ASL operation) at the address addr and place the 7th bit inside of the Carry flag. | |
#define | SHIFT_RIGHT_absolute(processor, addr) |
Procedure that performs a bitshift to the right (LSR operation) at the address addr and place the 0th bit inside of the Carry flag. | |
#define | SHIFT_LEFT_offset(processor, addr, offset) |
Procedure that performs a bitshift to the left (ASL operation) at the address (addr + offset) and place the 7th bit inside of the Carry flag. | |
#define | SHIFT_RIGHT_offset(processor, addr, offset) |
Procedure that performs a bitshift to the right (LSR operation) at the address (addr + offset) and place the 0th bit inside of the Carry flag. | |
#define | ROTATION_GENERIC(processor, field, operator, store_offset, pop_offset, flag_mask) |
Procedure that performs a Bitshift of 1 using a specified operator and placing the overflowing bit inside of the carry flag. | |
#define | ROTATION_LEFT_ACC(processor) |
Procedure that performs a bit shift with rotation to the left (ROL operation) on the accumulator. Bit 0 is filled with the previous state of the C flag and then the C flag is set to the current value of Bit 7. | |
#define | ROTATION_RIGHT_ACC(processor) |
Procedure that performs a bit shift with rotation to the right (ROR operation) on the accumulator. Bit 7 is filled with the previous state of the C flag and then the C flag is set to the current value of Bit 0. | |
#define | ROTATION_LEFT_absolute(processor, addr) |
Procedure that performs a bit shift with rotation to the left (ROL operation) at the memory address addr. Bit 0 is filled with the previous state of the C flag and then the C flag is set to the current value of Bit 7. | |
#define | ROTATION_RIGHT_absolute(processor, addr) |
Procedure that performs a bit shift with rotation to the right (ROR operation) at the memory address addr. Bit 7 is filled with the previous state of the C flag and then the C flag is set to the current value of Bit 0. | |
#define | ROTATION_LEFT_offset(processor, addr, offset) |
Procedure that performs a bit shift with rotation to the left (ROL operation) at the memory address (addr + offset). Bit 0 is filled with the previous state of the C flag and then the C flag is set to the current value of Bit 7. | |
#define | ROTATION_RIGHT_offset(processor, addr, offset) |
Procedure that performs a bit shift with rotation to the right (ROR operation) at the memory address (addr + offset). Bit 7 is filled with the previous state of the C flag and then the C flag is set to the current value of Bit 0. | |
#define | JUMP_absolute(processor, addr) |
Procedure that sets the program counter to a certain address (JMP instruction) | |
#define | JUMP_indirect(processor, addr) |
Procedure that sets the program counter to a certain indirect address (JMP instruction) | |
#define | GENERIC_IR(processor, vector_start) |
Procedure that performs a generic IR instruction. | |
#define | BREAK(processor) |
Procedure that performs a break instruction (forces an interrupt). | |
#define | IRQ(processor) |
Procedure that performs an interrupt request (when an IRQ is pending). | |
#define | NMI(processor) |
Procedure that performs a non maskable interrupt (when an NMI is pending). | |
#define | RESET(processor) |
Procedure that performs a NES reset interrupt. | |
#define | JUMP_Subroutine(processor, addr) |
Procedure that performs a Jump to a subroutine (JSR instruction) located at the address addr. | |
#define | RETURN_Subroutine(processor) |
Procedure that performs a return from subroutine (RTS instruction) by pulling the top two elements of the stack as the PC (ad then, it increments the PC to prevent some errors) | |
#define | RETURN_Interrupt(processor) |
Procedure that performs a return from interrupt (RTI instruction) by pulling the flags from the top of the stack and then pulling the PC. | |
#define | COMPARE_GENERIC_Immediate(processor, value, register) |
Procedure that performs a CMP operation (Z,C,N = reg - M) with an immediate value. | |
#define | COMPARE_Immediate_ACC(processor, value) |
Procedure that performs a CMP operation (Z,C,N = A - M) with an immediate value. | |
#define | COMPARE_absolute_ACC(processor, addr) |
Procedure that performs a CMP operation (Z, C, N = A - M) with an absolute addressing mode. | |
#define | COMPARE_offset_ACC(processor, addr, offset) |
Procedure that performs a CMP operation (Z, C, N = A - M) with an absolute + offset addressing mode. | |
#define | COMPARE_indexed_indirect_ACC(processor, addr, offset) |
Procedure that performs a CMP operation (Z, C, N = A - M) with an indexed indirect addressing mode. | |
#define | COMPARE_indirect_indexed_ACC(processor, addr, offset) |
Procedure that performs a CMP operation (Z, C, N = A - M) with an indirect indexed addressing mode. | |
#define | COMPARE_Immediate_X(processor, value) |
Procedure that performs a CMP operation (Z, C, N = X - M) with a value addressing mode. | |
#define | COMPARE_absolute_X(processor, addr) |
Procedure that performs a CMP operation (Z, C, N = X - M) with an indirect indexed addressing mode. | |
#define | COMPARE_Immediate_Y(processor, value) |
Procedure that performs a CMP operation (Z, C, N = Y - M) with a value addressing mode. | |
#define | COMPARE_absolute_Y(processor, addr) |
Procedure that performs a CMP operation (Z, C, N = Y - M) with an indirect indexed addressing mode. | |
Functions | |
void | init_cpu (CPU *cpu, memory mem) |
Procedure that initialize the CPU to its boot/reset state. | |
void | reset (CPU *processor) |
Procedure that resets the CPU by using the NES reset routine. | |
void | free_cpu (CPU *cpu) |
Procedure that free the memory used by the CPU and the memory array. | |
void | start_cpu (CPU *cpu) |
Procedure that acts like the reset button of the NES. | |
errcode_t | step_cpu (CPU *cpu) |
Function that step a clock cycle. | |
unsigned char | get_next_instruction (CPU *cpu) |
Function that get the next instruction written in the ROM. | |
errcode_t | execute_instruction (CPU *cpu) |
Function that execute the current instruction in the ROM. | |
void | print_cpu_state (CPU *processor) |
Procedure that displays the current state of the CPU. | |
void | print_stack_state (CPU *cpu) |
Procedure that display the current state of the stack. | |
void | print_stack_expected (memory stack, data start) |
Procedure that display the expected state of the stack. | |
void | print_cpu_expected (data acc, data x, data y, data flags, address pc, data sp) |
Procedure that display the expected state of the CPU. | |
#define ADD_absolute | ( | processor, | |
addr ) |
Procedure that perform a ADD with the carry flag (A,Z,C,N=A+M+C) with absolute addressing mode.
[in,out] | processor | The CPU that performs the ADD with Carry |
[in] | addr | The address of the data to add |
Definition at line 692 of file cpu.h.
Referenced by execute_instruction().
#define ADD_immediate | ( | processor, | |
data ) |
Procedure that perform a ADD with the carry flag (A,Z,C,N=A+data+C) with an immediate.
[in,out] | processor | The CPU that performs the ADD with Carry |
[in] | data | The immediate (a byte) |
Definition at line 662 of file cpu.h.
Referenced by execute_instruction(), and main().
#define ADD_indexed_indirect | ( | processor, | |
addr, | |||
offset ) |
Procedure that perform a ADD with the carry flag (A,Z,C,N=A+M+C) with indexed indirect addressing mode.
[in,out] | processor | The CPU that performs the ADD with Carry |
[in] | addr | The base address |
[in] | offset | The offset (usually X) |
Definition at line 710 of file cpu.h.
Referenced by execute_instruction(), and main().
#define ADD_indirect_indexed | ( | processor, | |
addr, | |||
offset ) |
Procedure that perform a ADD with the carry flag (A,Z,C,N=A+M+C) with indirect indexed.
[in,out] | processor | The CPU that performs the ADD with Carry |
[in] | addr | The base address |
[in] | offset | The offset (usually Y) |
Definition at line 719 of file cpu.h.
Referenced by execute_instruction(), and main().
#define ADD_offset | ( | processor, | |
addr, | |||
offset ) |
Procedure that perform a ADD with the carry flag (A,Z,C,N=A+M+C) with absolute+offset addressing addressing.
[in,out] | processor | The CPU that performs the ADD with Carry |
[in] | addr | The base address |
[in] | offset | The offset from the address |
Definition at line 701 of file cpu.h.
Referenced by execute_instruction(), and main().
#define AND_absolute | ( | processor, | |
addr ) |
Procedure that performs a bitwise logic AND (A,Z,N = A&M) using absolute addressing mode.
[in,out] | processor | The CPU that performs the bitwise logic AND operation |
[in] | addr | The addressing to the data |
Definition at line 755 of file cpu.h.
Referenced by execute_instruction(), and main().
#define AND_immediate | ( | processor, | |
data ) |
Procedure that performs a bitwise logic AND (A,Z,N = A & data)
[in,out] | processor | The CPU that performs the bitwise logic AND operation |
[in] | data | The value to bitwise AND with the accumulator |
Definition at line 744 of file cpu.h.
Referenced by execute_instruction(), and main().
#define AND_indexed_indirect | ( | processor, | |
addr, | |||
offset ) |
Procedure that perform a AND with the carry flag (A,Z,C,N=A+M+C) with indexed indirect addressing mode.
[in,out] | processor | The CPU that performs the ADD with Carry |
[in] | addr | The base address |
[in] | offset | The offset (usually X) |
Definition at line 772 of file cpu.h.
Referenced by execute_instruction(), and main().
#define AND_indirect_indexed | ( | processor, | |
addr, | |||
offset ) |
Procedure that perform a AND with the carry flag (A,Z,C,N=A+M+C) with indirect indexed.
[in,out] | processor | The CPU that performs the ADD with Carry |
[in] | addr | The base address |
[in] | offset | The offset (usually Y) |
Definition at line 781 of file cpu.h.
Referenced by execute_instruction(), and main().
#define AND_offset | ( | processor, | |
addr, | |||
offset ) |
Procedure that performs a bitwise logic AND (A,Z,N = A&M) using offset addressing mode.
[in,out] | processor | The CPU that performs the bitwise logic AND operation |
[in] | addr | The base address |
[in] | offset | The offset from the base address |
Definition at line 763 of file cpu.h.
Referenced by execute_instruction(), and main().
#define BIT_TEST | ( | processor, | |
addr ) |
Procedure that performs a BIT test (A & M, N = M7, V = M6)
[in,out] | processor | The CPU that performs the BIT test |
[in] | addr | The base address (ZP: 2 cycles, Absolute: 3 cycles) |
Definition at line 951 of file cpu.h.
Referenced by execute_instruction(), and main().
#define BRANCH_Carry_C | ( | processor, | |
offset ) |
Procedure that performs a BCC (if the C flag is clear)
[in,out] | processor | The CPU that performs the instruction |
[in] | offset | The offset (a signed byte) which is added to the PC when the condition is true |
Definition at line 1018 of file cpu.h.
Referenced by execute_instruction(), and main().
#define BRANCH_Carry_S | ( | processor, | |
offset ) |
Procedure that performs a BCS (branch if positive, if the N flag is clear)
[in,out] | processor | The CPU that performs the instruction |
[in] | offset | The offset (a signed byte) which is added to the PC when the condition is true |
Definition at line 1046 of file cpu.h.
Referenced by execute_instruction(), and main().
#define BRANCH_Equal | ( | processor, | |
offset ) |
Procedure that performs a BEQ (branch if positive, if the N flag is clear)
[in,out] | processor | The CPU that performs the instruction |
[in] | offset | The offset (a signed byte) which is added to the PC when the condition is true |
Definition at line 1039 of file cpu.h.
Referenced by execute_instruction(), and main().
#define BRANCH_GENERIC_C | ( | processor, | |
flag_mask, | |||
offset ) |
Procedure that performs a BRANCH instruction for the FLAG.
[in,out] | processor | The CPU that performs the Branch instruction |
[in] | flag_mask | The bitmask that isolate the correct flag |
[in] | offset | The offset (a signed byte) which is added to the PC when the FLAG is CLEAR |
Definition at line 985 of file cpu.h.
#define BRANCH_GENERIC_S | ( | processor, | |
flag_mask, | |||
offset ) |
Procedure that performs a BRANCH instruction for the FLAG.
[in,out] | processor | The CPU that performs the Branch instruction |
[in] | flag_mask | The bitmask that isolate the correct flag |
[in] | offset | The offset (a signed byte) which is added to the PC when the FLAG is SET |
Definition at line 973 of file cpu.h.
#define BRANCH_If_Minus | ( | processor, | |
offset ) |
Procedure that performs a BMI (branch if positive, if the N flag is clear)
[in,out] | processor | The CPU that performs the instruction |
[in] | offset | The offset (a signed byte) which is added to the PC when the condition is true |
Definition at line 1025 of file cpu.h.
Referenced by execute_instruction(), and main().
#define BRANCH_If_Positive | ( | processor, | |
offset ) |
Procedure that performs a BPL (branch if positive, if the N flag is clear)
[in,out] | processor | The CPU that performs the instruction |
[in] | offset | The offset (a signed byte) which is added to the PC when the condition is true |
Definition at line 997 of file cpu.h.
Referenced by execute_instruction(), and main().
#define BRANCH_Not_Equal | ( | processor, | |
offset ) |
Procedure that performs a BNE (if the Z flag is clear)
[in,out] | processor | The CPU that performs the instruction |
[in] | offset | The offset (a signed byte) which is added to the PC when the condition is true |
Definition at line 1011 of file cpu.h.
Referenced by execute_instruction(), and main().
#define BRANCH_Overflow_C | ( | processor, | |
offset ) |
Procedure that performs a BVC (branch if overflow clear, if the V flag is clear)
[in,out] | processor | The CPU that performs the instruction |
[in] | offset | The offset (a signed byte) which is added to the PC when the condition is true |
Definition at line 1004 of file cpu.h.
Referenced by execute_instruction(), and main().
#define BRANCH_Overflow_S | ( | processor, | |
offset ) |
Procedure that performs a BVS (branch if positive, if the N flag is clear)
[in,out] | processor | The CPU that performs the instruction |
[in] | offset | The offset (a signed byte) which is added to the PC when the condition is true |
Definition at line 1032 of file cpu.h.
Referenced by execute_instruction(), and main().
#define BREAK | ( | processor | ) |
Procedure that performs a break instruction (forces an interrupt).
[in,out] | processor | The CPU that performs the interrupt |
Definition at line 1232 of file cpu.h.
Referenced by execute_instruction(), and main().
#define CLEAR_ALL_FLAGS | ( | x | ) |
#define CLEAR_B_FLAG | ( | x | ) |
#define CLEAR_C_FLAG | ( | x | ) |
Definition at line 139 of file cpu.h.
Referenced by execute_instruction().
#define CLEAR_D_FLAG | ( | x | ) |
Definition at line 142 of file cpu.h.
Referenced by execute_instruction().
#define CLEAR_I_FLAG | ( | x | ) |
Definition at line 141 of file cpu.h.
Referenced by execute_instruction().
#define CLEAR_N_FLAG | ( | x | ) |
Definition at line 146 of file cpu.h.
Referenced by main().
#define CLEAR_P_FLAG | ( | x | ) |
#define CLEAR_V_FLAG | ( | x | ) |
Definition at line 145 of file cpu.h.
Referenced by execute_instruction().
#define CLEAR_Z_FLAG | ( | x | ) |
Definition at line 140 of file cpu.h.
Referenced by main().
#define COMPARE_absolute_ACC | ( | processor, | |
addr ) |
Procedure that performs a CMP operation (Z, C, N = A - M) with an absolute addressing mode.
[in,out] | processor | The CPU that performs the instruction |
[in] | addr | The base address |
Definition at line 1340 of file cpu.h.
Referenced by execute_instruction().
#define COMPARE_absolute_X | ( | processor, | |
addr ) |
Procedure that performs a CMP operation (Z, C, N = X - M) with an indirect indexed addressing mode.
[in,out] | processor | The CPU that performs the instruction |
[in] | addr | The base address |
Definition at line 1386 of file cpu.h.
Referenced by execute_instruction().
#define COMPARE_absolute_Y | ( | processor, | |
addr ) |
Procedure that performs a CMP operation (Z, C, N = Y - M) with an indirect indexed addressing mode.
[in,out] | processor | The CPU that performs the instruction |
[in] | addr | The base address |
Definition at line 1403 of file cpu.h.
Referenced by execute_instruction().
#define COMPARE_GENERIC_Immediate | ( | processor, | |
value, | |||
register ) |
Procedure that performs a CMP operation (Z,C,N = reg - M) with an immediate value.
[in,out] | processor | The CPU that performs the instruction |
[in] | value | The current value |
[in] | register | The register used for the comparison |
Definition at line 1310 of file cpu.h.
#define COMPARE_Immediate_ACC | ( | processor, | |
value ) |
Procedure that performs a CMP operation (Z,C,N = A - M) with an immediate value.
[in,out] | processor | The CPU that performs the instruction |
[in] | value | The current value |
Definition at line 1332 of file cpu.h.
Referenced by execute_instruction().
#define COMPARE_Immediate_X | ( | processor, | |
value ) |
Procedure that performs a CMP operation (Z, C, N = X - M) with a value addressing mode.
[in,out] | processor | The CPU that performs the instruction |
[in] | value | The immediate value |
Definition at line 1377 of file cpu.h.
Referenced by execute_instruction().
#define COMPARE_Immediate_Y | ( | processor, | |
value ) |
Procedure that performs a CMP operation (Z, C, N = Y - M) with a value addressing mode.
[in,out] | processor | The CPU that performs the instruction |
[in] | value | The immediate value |
Definition at line 1394 of file cpu.h.
Referenced by execute_instruction().
#define COMPARE_indexed_indirect_ACC | ( | processor, | |
addr, | |||
offset ) |
Procedure that performs a CMP operation (Z, C, N = A - M) with an indexed indirect addressing mode.
[in,out] | processor | The CPU that performs the instruction |
[in] | addr | The base address |
[in] | offset | The offset |
Definition at line 1358 of file cpu.h.
Referenced by execute_instruction().
#define COMPARE_indirect_indexed_ACC | ( | processor, | |
addr, | |||
offset ) |
Procedure that performs a CMP operation (Z, C, N = A - M) with an indirect indexed addressing mode.
[in,out] | processor | The CPU that performs the instruction |
[in] | addr | The base address |
[in] | offset | The offset |
Definition at line 1368 of file cpu.h.
Referenced by execute_instruction().
#define COMPARE_offset_ACC | ( | processor, | |
addr, | |||
offset ) |
Procedure that performs a CMP operation (Z, C, N = A - M) with an absolute + offset addressing mode.
[in,out] | processor | The CPU that performs the instruction |
[in] | addr | The base address |
[in] | offset | The offset |
Definition at line 1349 of file cpu.h.
Referenced by execute_instruction().
#define DEC_absolute | ( | processor, | |
addr ) |
Procedure that decrement a specific memory location.
[in,out] | processor | The CPU that performs the decrement |
[in] | addr | The address where we need to decrement |
Definition at line 377 of file cpu.h.
Referenced by execute_instruction().
#define DEC_offset | ( | processor, | |
addr, | |||
offset ) |
Procedure that decrement a specific memory location.
[in,out] | processor | The CPU that performs the decrement |
[in] | addr | The base address |
[in] | offset | The offset from the base address |
Definition at line 392 of file cpu.h.
Referenced by execute_instruction().
#define DEC_X | ( | processor | ) |
Procedure that decrements the X register.
[in,out] | processor | The CPU that contains the X register to decrement |
Definition at line 418 of file cpu.h.
Referenced by execute_instruction(), and main().
#define DEC_Y | ( | processor | ) |
Procedure that decrements the Y register.
[in,out] | processor | The CPU that contains the Y register to decrement |
Definition at line 424 of file cpu.h.
Referenced by execute_instruction(), and main().
#define DECINC_GENERIC | ( | cpu, | |
reg, | |||
op ) |
Procedure that increments the register reg.
[in,out] | cpu | The CPU that holds the register reg |
[in] | reg | The register to increment or decrement |
[in] | op | The increment or decrement operator |
Definition at line 357 of file cpu.h.
#define GENERIC_IR | ( | processor, | |
vector_start ) |
Procedure that performs a generic IR instruction.
[in,out] | processor | The CPU that performs the interrupt |
[in] | vector_start | The first address of the interrupt's vector |
Definition at line 1221 of file cpu.h.
#define get_address | ( | cpu | ) |
Macro to recreate the current address pointed by pc + 1.
[in] | cpu | The CPU that holds the pc |
Definition at line 180 of file cpu.h.
Referenced by execute_instruction(), get_next_instruction(), and start_cpu().
#define GET_B_FLAG | ( | x | ) |
Definition at line 123 of file cpu.h.
Referenced by print_cpu_state(), and printw_cpu_state().
#define GET_C_FLAG | ( | x | ) |
Definition at line 119 of file cpu.h.
Referenced by get_next_instruction(), print_cpu_state(), and printw_cpu_state().
#define GET_D_FLAG | ( | x | ) |
Definition at line 122 of file cpu.h.
Referenced by print_cpu_state(), and printw_cpu_state().
#define GET_I_FLAG | ( | x | ) |
Definition at line 121 of file cpu.h.
Referenced by print_cpu_state(), and printw_cpu_state().
#define GET_N_FLAG | ( | x | ) |
Definition at line 126 of file cpu.h.
Referenced by get_next_instruction(), print_cpu_state(), and printw_cpu_state().
#define GET_P_FLAG | ( | x | ) |
Definition at line 124 of file cpu.h.
Referenced by print_cpu_state(), and printw_cpu_state().
#define GET_V_FLAG | ( | x | ) |
Definition at line 125 of file cpu.h.
Referenced by get_next_instruction(), print_cpu_state(), and printw_cpu_state().
#define GET_Z_FLAG | ( | x | ) |
Definition at line 120 of file cpu.h.
Referenced by get_next_instruction(), print_cpu_state(), and printw_cpu_state().
#define INC_absolute | ( | processor, | |
addr ) |
Procedure that increment a specific memory location.
[in,out] | processor | The CPU that performs the increment |
[in] | addr | The address where we need to increment |
Definition at line 384 of file cpu.h.
Referenced by execute_instruction().
#define INC_offset | ( | processor, | |
addr, | |||
offset ) |
Procedure that increment a specific memory location.
[in,out] | processor | The CPU that performs the increment |
[in] | addr | The base address |
[in] | offset | The offset from the base address |
Definition at line 400 of file cpu.h.
Referenced by execute_instruction().
#define INC_X | ( | processor | ) |
Procedure that increments the X register.
[in,out] | processor | The CPU that contains the X register to increment |
Definition at line 406 of file cpu.h.
Referenced by execute_instruction(), and main().
#define INC_Y | ( | processor | ) |
Procedure that increments the Y register.
[in,out] | processor | The CPU that contains the Y register to increment |
Definition at line 412 of file cpu.h.
Referenced by execute_instruction(), and main().
#define indexed_indirect | ( | cpu, | |
addr, | |||
offset ) |
Macro to access memory by indexed indirect addressing mode.
[in,out] | cpu | The CPU in which the memory field is located |
[in] | addr | The base address (A ZERO PAGE ADDRESS ONLY) |
[in] | offset | The offset (usually X) |
Definition at line 156 of file cpu.h.
Referenced by main().
#define indirect | ( | cpu, | |
addr ) |
#define indirect_indexed | ( | cpu, | |
addr, | |||
offset ) |
Macro to access memory by indirect indexed addressing mode.
[in,out] | cpu | The CPU in which the memory field is located |
[in] | addr | The base address |
[in] | offset | The offset (usually Y) |
Definition at line 165 of file cpu.h.
Referenced by get_next_instruction(), and main().
#define IRQ | ( | processor | ) |
Procedure that performs an interrupt request (when an IRQ is pending).
[in,out] | processor | The CPU that performs the interrupt |
Definition at line 1242 of file cpu.h.
#define is_page_crossed | ( | addr, | |
offset ) |
Macro to know if we cross a page when doing the instruction.
[in] | addr | Base address |
[in] | offset | Offset from base address |
Definition at line 189 of file cpu.h.
Referenced by get_next_instruction().
#define JUMP_absolute | ( | processor, | |
addr ) |
Procedure that sets the program counter to a certain address (JMP instruction)
[in,out] | processor | The CPU that performs the instruction |
[in] | addr | The base address |
Definition at line 1206 of file cpu.h.
Referenced by execute_instruction(), and main().
#define JUMP_indirect | ( | processor, | |
addr ) |
Procedure that sets the program counter to a certain indirect address (JMP instruction)
[in,out] | processor | The CPU that performs the instruction |
[in] | addr | The base address |
Definition at line 1213 of file cpu.h.
Referenced by execute_instruction(), and main().
#define JUMP_Subroutine | ( | processor, | |
addr ) |
Procedure that performs a Jump to a subroutine (JSR instruction) located at the address addr.
[in,out] | processor | The CPU that performs the instruction |
[in] | addr | The address of the subroutine |
Definition at line 1275 of file cpu.h.
Referenced by execute_instruction(), and main().
#define LD_absolute_ACC | ( | processor, | |
addr ) |
Procedure that loads a value from memory at the address addr to the accumulator.
[in,out] | processor | The CPU in which we need to load the data |
[in] | addr | The address that holds the data to load |
Definition at line 303 of file cpu.h.
Referenced by execute_instruction(), and main().
#define LD_absolute_GENERIC | ( | cpu, | |
reg, | |||
addr ) |
Procedure that loads a value from memory at the address adr to a register.
[in,out] | cpu | The CPU that holds the register reg |
[in] | reg | The register in which we need to load the data |
[in] | addr | The address of the data |
#define LD_absolute_X | ( | processor, | |
addr ) |
Procedure that loads a value from memory at the address addr to the X register.
[in,out] | processor | The CPU in which we need to load the data |
[in] | addr | The address that holds the data to load |
Definition at line 310 of file cpu.h.
Referenced by execute_instruction(), and main().
#define LD_absolute_Y | ( | processor, | |
addr ) |
Procedure that loads a value from memory at the address addr to the Y register.
[in,out] | processor | The CPU in which we need to load the data |
[in] | addr | The address that holds the data to load |
Definition at line 317 of file cpu.h.
Referenced by execute_instruction(), and main().
#define LD_FLAGS_GENERIC | ( | cpu, | |
reg ) |
Procedure that flips the correct flags when loading a value in a register.
[in,out] | cpu | The CPU that holds the register reg |
[in] | reg | The register in which the data has been loaded |
Definition at line 196 of file cpu.h.
#define LD_immediate_ACC | ( | processor, | |
d ) |
Procedure that loads an immediate (const value) in the accumulator.
[in,out] | processor | The CPU in which we need to load the data |
[in] | d | the data to load |
Definition at line 237 of file cpu.h.
Referenced by execute_instruction(), and main().
#define LD_immediate_GENERIC | ( | cpu, | |
reg, | |||
d ) |
Procedure that loads an immediate (const value) in a register.
[in,out] | cpu | The CPU that holds the register reg |
[in] | reg | The register in which we need to load the data |
[in] | d | the data to load |
Definition at line 217 of file cpu.h.
#define LD_immediate_X | ( | processor, | |
d ) |
Procedure that loads an immediate (const value) in the X register.
[in,out] | processor | The CPU in which we need to load the data |
[in] | d | the data to load |
Definition at line 244 of file cpu.h.
Referenced by execute_instruction(), and main().
#define LD_immediate_Y | ( | processor, | |
d ) |
Procedure that loads an immediate (const value) in the Y register.
[in,out] | processor | The CPU in which we need to load the data |
[in] | d | the data to load |
Definition at line 251 of file cpu.h.
Referenced by execute_instruction(), and main().
#define LD_indexed_indirect_ACC | ( | processor, | |
addr, | |||
offset ) |
Procedure that loads to the accumulator using Indexed Indirect.
[in,out] | processor | The CPU that holds the accumulator |
[in] | addr | A ZERO PAGE address only ! |
[in] | offset | The offset (usually, the content of X) |
Definition at line 432 of file cpu.h.
Referenced by execute_instruction(), and main().
#define LD_indirect_ACC | ( | processor, | |
addr ) |
Procedure that lods a value from memory at the address contained in addr|addr+1. (indirection)
[in,out] | processor | The CPU in which we need to load the data |
[in] | addr | The base address of the indirection |
Definition at line 333 of file cpu.h.
Referenced by main().
#define LD_indirect_GENERIC | ( | cpu, | |
reg, | |||
addr ) |
Procedure that loads a value from memory at the address: mem[addr] | mem[addr+1].
[in,out] | cpu | The CPU that holds the register reg |
[in] | reg | The register in which we need to load the data |
[in] | addr | The base address of the indirect addressing mode |
#define LD_indirect_indexed_ACC | ( | processor, | |
addr, | |||
offset ) |
Procedure that loads to the accmulator using Inderect Indexed.
[in,out] | processor | The CPU that holds the accumulator |
[in] | addr | A ZERO PAGE address only ! |
[in] | offset | The offset (usually, the content of Y) |
Definition at line 441 of file cpu.h.
Referenced by execute_instruction(), and main().
#define LD_indirect_X | ( | processor, | |
addr ) |
Procedure that lods a value from memory at the address contained in addr|addr+1. (indirection)
[in,out] | processor | The CPU in which we need to load the data |
[in] | addr | The base address of the indirection |
Definition at line 341 of file cpu.h.
Referenced by main().
#define LD_indirect_Y | ( | processor, | |
addr ) |
Procedure that lods a value from memory at the address contained in addr|addr+1. (indirection)
[in,out] | processor | The CPU in which we need to load the data |
[in] | addr | The base address of the indirection |
Definition at line 349 of file cpu.h.
Referenced by main().
#define LD_offset_ACC | ( | processor, | |
addr, | |||
offset ) |
Procedure that loads a value from memory at address addr+offset to the X register.
[in,out] | processor | The CPU in which we need to load the data |
[in] | addr | The base address |
[in] | offset | The offset from the address |
Definition at line 269 of file cpu.h.
Referenced by execute_instruction(), and main().
#define LD_offset_GENERIC | ( | cpu, | |
reg, | |||
addr, | |||
offset ) |
Procedure that loads a value from memory at address addr+offset to a register.
[in,out] | cpu | The CPU that holds the register reg |
[in] | reg | The register in which we need to load the data |
[in] | addr | The base address |
[in] | offset | The offset from the address |
Definition at line 260 of file cpu.h.
#define LD_offset_X | ( | processor, | |
addr, | |||
offset ) |
Procedure that loads a value from memory at address addr+offset to the X register.
[in,out] | processor | The CPU in which we need to load the data |
[in] | addr | The base address |
[in] | offset | The offset from the address |
Definition at line 278 of file cpu.h.
Referenced by execute_instruction(), and main().
#define LD_offset_Y | ( | processor, | |
addr, | |||
offset ) |
Procedure that loads a value from memory at address addr+offset to the Y register.
[in,out] | processor | The CPU in which we need to load the data |
[in] | addr | The base address |
[in] | offset | The offset from the address |
Definition at line 287 of file cpu.h.
Referenced by execute_instruction(), and main().
#define LOGICAL_FLAGS | ( | processor | ) |
Procedure that performs the test for every bitwise logic operations.
[in,out] | processor | The CPU that performed the bitwise operation |
Definition at line 726 of file cpu.h.
#define NMI | ( | processor | ) |
Procedure that performs a non maskable interrupt (when an NMI is pending).
[in,out] | processor | The CPU that performs the interrupt |
Definition at line 1252 of file cpu.h.
#define NO_OPERATION | ( | ) |
#define OR_absolute | ( | processor, | |
addr ) |
Procedure that performs a bitwise logic OR (A,Z,N = A&M) using absolute addressing mode.
[in,out] | processor | The CPU that performs the bitwise logic OR operation |
[in] | addr | The addressing to the data |
Definition at line 800 of file cpu.h.
Referenced by execute_instruction(), and main().
#define OR_immediate | ( | processor, | |
data ) |
Procedure that performs a bitwise logic OR (A,Z,N = A & data)
[in,out] | processor | The CPU that performs the bitwise logic OR operation |
[in] | data | The value to bitwise OR with the accumulator |
Definition at line 789 of file cpu.h.
Referenced by execute_instruction(), and main().
#define OR_indexed_indirect | ( | processor, | |
addr, | |||
offset ) |
Procedure that perform a OR with the carry flag (A,Z,C,N=A+M+C) with indexed indirect addressing mode.
[in,out] | processor | The CPU that performs the OR with Carry |
[in] | addr | The base address |
[in] | offset | The offset (usually X) |
Definition at line 817 of file cpu.h.
Referenced by execute_instruction(), and main().
#define OR_indirect_indexed | ( | processor, | |
addr, | |||
offset ) |
Procedure that perform a OR with the carry flag (A,Z,C,N=A+M+C) with indirect indexed.
[in,out] | processor | The CPU that performs the OR with Carry |
[in] | addr | The base address |
[in] | offset | The offset (usually Y) |
Definition at line 826 of file cpu.h.
Referenced by execute_instruction(), and main().
#define OR_offset | ( | processor, | |
addr, | |||
offset ) |
Procedure that performs a bitwise logic OR (A,Z,N = A&M) using offset addressing mode.
[in,out] | processor | The CPU that performs the bitwise logic OR operation |
[in] | addr | The base address |
[in] | offset | The offset from the base address |
Definition at line 808 of file cpu.h.
Referenced by execute_instruction(), and main().
#define PULL_ACC | ( | processor | ) |
Procedure that pop the top value of the stack and return it to the accumulator.
[in,out] | processor | The CPU holding the accumulator |
Definition at line 636 of file cpu.h.
Referenced by execute_instruction(), and main().
#define PULL_FLAGS | ( | processor | ) |
Procedure that pop the top value of the stack and return it to the flags register.
[in,out] | processor | The CPU holding the flags register |
Definition at line 642 of file cpu.h.
Referenced by execute_instruction(), and main().
#define PULL_GENERIC | ( | cpu, | |
reg ) |
Procedure that pop the top value of the stack and return it to the register reg.
[in,out] | cpu | The CPU holding the register reg |
[in] | reg |
Definition at line 626 of file cpu.h.
#define PULL_PC | ( | processor | ) |
Procedure that pop the top value of the stack and return it to the program counter.
[in,out] | processor | The CPU holding the program counter |
Definition at line 648 of file cpu.h.
Referenced by main().
#define PUSH_ACC | ( | processor | ) |
Procedure that push the accumulator value to the top of the stack.
[in,out] | processor | The CPU holding the accumulator |
Definition at line 603 of file cpu.h.
Referenced by execute_instruction(), and main().
#define PUSH_FLAGS | ( | processor | ) |
Procedure that push the processor flags to the top of the stack.
[in,out] | processor | The CPU holding the flags |
Definition at line 609 of file cpu.h.
Referenced by execute_instruction(), and main().
#define PUSH_GENERIC | ( | cpu, | |
reg ) |
Procedure that push the reg value to the top of the stack.
[in,out] | cpu | The CPU holding the register reg |
[in] | reg | The register holding the value |
Definition at line 582 of file cpu.h.
#define PUSH_immediate | ( | cpu, | |
d ) |
Procedure that push an immediate value to the top of the stack.
[in,out] | cpu | The CPU holding the stack_pointer |
[in] | d | The immediate to push |
Definition at line 593 of file cpu.h.
#define PUSH_PC | ( | processor | ) |
Procedure that push the program_counter to the top of the stack.
[in,out] | processor | The CPU holding the program counter |
Definition at line 615 of file cpu.h.
Referenced by main().
#define RESET | ( | processor | ) |
Procedure that performs a NES reset interrupt.
[in,out] | processor | The CPU that performs the interrupt |
Definition at line 1262 of file cpu.h.
#define RETURN_Interrupt | ( | processor | ) |
Procedure that performs a return from interrupt (RTI instruction) by pulling the flags from the top of the stack and then pulling the PC.
[in,out] | processor | The CPU that performs the instruction |
Definition at line 1298 of file cpu.h.
Referenced by execute_instruction(), and main().
#define RETURN_Subroutine | ( | processor | ) |
Procedure that performs a return from subroutine (RTS instruction) by pulling the top two elements of the stack as the PC (ad then, it increments the PC to prevent some errors)
[in,out] | processor | The CPU that performs the instruction |
Definition at line 1287 of file cpu.h.
Referenced by execute_instruction(), and main().
#define ROTATION_GENERIC | ( | processor, | |
field, | |||
operator, | |||
store_offset, | |||
pop_offset, | |||
flag_mask ) |
Procedure that performs a Bitshift of 1 using a specified operator and placing the overflowing bit inside of the carry flag.
[in,out] | processor | The CPU that performs the instruction |
[in] | field | The field of the structure that is affected by the operation |
[in] | operator | The left or shift operator |
[in] | store_offset | The offset to place correctly the bit inside of the Carry flag |
[in] | pop_offset | The offset to place correctly the bit inside of the field |
[in] | flag_mask | The mask to get the correct bit |
Definition at line 1128 of file cpu.h.
#define ROTATION_LEFT_absolute | ( | processor, | |
addr ) |
Procedure that performs a bit shift with rotation to the left (ROL operation) at the memory address addr. Bit 0 is filled with the previous state of the C flag and then the C flag is set to the current value of Bit 7.
[in,out] | processor | The CPU that performs the instruction |
[in] | addr | The base address |
Definition at line 1166 of file cpu.h.
Referenced by execute_instruction(), and main().
#define ROTATION_LEFT_ACC | ( | processor | ) |
Procedure that performs a bit shift with rotation to the left (ROL operation) on the accumulator. Bit 0 is filled with the previous state of the C flag and then the C flag is set to the current value of Bit 7.
[in,out] | processor | The CPU that performs the instruction |
Definition at line 1149 of file cpu.h.
Referenced by execute_instruction(), and main().
#define ROTATION_LEFT_offset | ( | processor, | |
addr, | |||
offset ) |
Procedure that performs a bit shift with rotation to the left (ROL operation) at the memory address (addr + offset). Bit 0 is filled with the previous state of the C flag and then the C flag is set to the current value of Bit 7.
[in,out] | processor | The CPU that performs the instruction |
[in] | addr | The base address |
[in] | offset | The offset from the base address |
Definition at line 1187 of file cpu.h.
Referenced by execute_instruction(), and main().
#define ROTATION_RIGHT_absolute | ( | processor, | |
addr ) |
Procedure that performs a bit shift with rotation to the right (ROR operation) at the memory address addr. Bit 7 is filled with the previous state of the C flag and then the C flag is set to the current value of Bit 0.
[in,out] | processor | The CPU that performs the instruction |
[in] | addr | The base address |
Definition at line 1176 of file cpu.h.
Referenced by execute_instruction(), and main().
#define ROTATION_RIGHT_ACC | ( | processor | ) |
Procedure that performs a bit shift with rotation to the right (ROR operation) on the accumulator. Bit 7 is filled with the previous state of the C flag and then the C flag is set to the current value of Bit 0.
[in,out] | processor | The CPU that performs the instruction |
Definition at line 1157 of file cpu.h.
Referenced by execute_instruction(), and main().
#define ROTATION_RIGHT_offset | ( | processor, | |
addr, | |||
offset ) |
Procedure that performs a bit shift with rotation to the right (ROR operation) at the memory address (addr + offset). Bit 7 is filled with the previous state of the C flag and then the C flag is set to the current value of Bit 0.
[in,out] | processor | The CPU that performs the instruction |
[in] | addr | The base address |
[in] | offset | The offset from the base address |
Definition at line 1198 of file cpu.h.
Referenced by execute_instruction(), and main().
#define SBC_absolute | ( | processor, | |
addr ) |
Procedure that perform a SBC with the carry flag (A,Z,C,N=A-M-C) with absolute addressing mode.
[in,out] | processor | The CPU that performs the substract with Carry |
[in] | addr | The address of the data to substract |
Definition at line 910 of file cpu.h.
Referenced by execute_instruction(), and main().
#define SBC_immediate | ( | processor, | |
data ) |
Procedure that perform a substract with the carry flag (A,Z,C,N=A-data-C) with an immediate.
[in,out] | processor | The CPU that performs the substract with Carry |
[in] | data | The immediate (a byte) |
Definition at line 880 of file cpu.h.
Referenced by execute_instruction(), and main().
#define SBC_indexed_indirect | ( | processor, | |
addr, | |||
offset ) |
Procedure that perform a SBC with the carry flag (A,Z,C,N=A-M-C) with indexed indirect addressing mode.
[in,out] | processor | The CPU that performs the substract with Carry |
[in] | addr | The base address |
[in] | offset | The offset (usually X) |
Definition at line 928 of file cpu.h.
Referenced by execute_instruction(), and main().
#define SBC_indirect_indexed | ( | processor, | |
addr, | |||
offset ) |
Procedure that perform a SBC with the carry flag (A,Z,C,N=A-M-C) with indirect indexed addressing mode.
[in,out] | processor | The CPU that performs the substract with Carry |
[in] | addr | The base address |
[in] | offset | The offset (usually Y) |
Definition at line 938 of file cpu.h.
Referenced by execute_instruction(), and main().
#define SBC_offset | ( | processor, | |
addr, | |||
offset ) |
Procedure that perform a SBC with the carry flag (A,Z,C,N=A-M-C) with offset addressing mode.
[in,out] | processor | The CPU that performs the substract with Carry |
[in] | addr | The base address |
[in] | offset | The offset from the base address |
Definition at line 919 of file cpu.h.
Referenced by execute_instruction(), and main().
#define SET_B_FLAG | ( | x | ) |
#define SET_C_FLAG | ( | x | ) |
Definition at line 128 of file cpu.h.
Referenced by execute_instruction(), and main().
#define SET_D_FLAG | ( | x | ) |
Definition at line 131 of file cpu.h.
Referenced by execute_instruction().
#define SET_I_FLAG | ( | x | ) |
Definition at line 130 of file cpu.h.
Referenced by execute_instruction().
#define SET_N_FLAG | ( | x | ) |
#define SET_P_FLAG | ( | x | ) |
#define SET_V_FLAG | ( | x | ) |
Definition at line 134 of file cpu.h.
Referenced by main().
#define SET_Z_FLAG | ( | x | ) |
#define SHIFT_GENERIC | ( | processor, | |
field, | |||
operator, | |||
flag_shift_offset, | |||
flag_mask ) |
Procedure that performs a Bitshift of 1 using a specified operator and placing the overflowing bit inside of the carry flag.
[in,out] | processor | The CPU that performs the instruction |
[in] | field | The field of the structure that is affected by the operation |
[in] | operator | The left or shift operator |
[in] | flag_shift_offset | The offset to place correctly the bit inside of the Carry flag |
[in] | flag_mask | The mask to get the correct bit |
Definition at line 1057 of file cpu.h.
#define SHIFT_LEFT_absolute | ( | processor, | |
addr ) |
Procedure that performs a bitshift to the left (ASL operation) at the address addr and place the 7th bit inside of the Carry flag.
[in,out] | processor | The CPU that performs the operation |
[in] | addr | The base address |
Definition at line 1091 of file cpu.h.
Referenced by execute_instruction(), and main().
#define SHIFT_LEFT_ACC | ( | processor | ) |
Procedure that performs a bitshift to the left (ASL operation) on the accumulator and place the 7th bit inside of the Carry flag.
[in,out] | processor | The CPU that performs the operation |
Definition at line 1076 of file cpu.h.
Referenced by execute_instruction(), and main().
#define SHIFT_LEFT_offset | ( | processor, | |
addr, | |||
offset ) |
Procedure that performs a bitshift to the left (ASL operation) at the address (addr + offset) and place the 7th bit inside of the Carry flag.
[in,out] | processor | The CPU that performs the operation |
[in] | addr | The base address |
[in] | offset | The offset from the base address |
Definition at line 1107 of file cpu.h.
Referenced by execute_instruction(), and main().
#define SHIFT_RIGHT_absolute | ( | processor, | |
addr ) |
Procedure that performs a bitshift to the right (LSR operation) at the address addr and place the 0th bit inside of the Carry flag.
[in,out] | processor | The CPU that performs the operation |
[in] | addr | The base address |
Definition at line 1098 of file cpu.h.
Referenced by execute_instruction(), and main().
#define SHIFT_RIGHT_ACC | ( | processor | ) |
Procedure that performs a bitshift to the right (LSR operation) on the accumulator and place the 0th bit inside of the Carry flag.
[in,out] | processor | The CPU that performs the operation |
Definition at line 1083 of file cpu.h.
Referenced by execute_instruction(), and main().
#define SHIFT_RIGHT_offset | ( | processor, | |
addr, | |||
offset ) |
Procedure that performs a bitshift to the right (LSR operation) at the address (addr + offset) and place the 0th bit inside of the Carry flag.
[in,out] | processor | The CPU that performs the operation |
[in] | addr | The base address |
[in] | offset | The offset from the base address |
Definition at line 1116 of file cpu.h.
Referenced by execute_instruction(), and main().
#define STR_absolute_ACC | ( | processor, | |
addr ) |
Procedure that store the accumulator value to a memory address.
[in,out] | processor | The CPU that holds the accumulator |
[in] | addr | The address to the memory |
Definition at line 457 of file cpu.h.
Referenced by execute_instruction(), and main().
#define STR_absolute_GENERIC | ( | cpu, | |
reg, | |||
addr ) |
#define STR_absolute_X | ( | processor, | |
addr ) |
Procedure that store the X register value to a memory address.
[in,out] | processor | The CPU that holds the X register |
[in] | addr | The address to the memory |
Definition at line 464 of file cpu.h.
Referenced by execute_instruction(), and main().
#define STR_absolute_Y | ( | processor, | |
addr ) |
Procedure that store the Y register value to a memory address.
[in,out] | processor | The CPU that holds the Y register |
[in] | addr | The address to the memory |
Definition at line 471 of file cpu.h.
Referenced by execute_instruction(), and main().
#define STR_indexed_indirect_ACC | ( | processor, | |
addr, | |||
offset ) |
Procedure that store the accumulator value to a memory address using indexes indirect addressing mode.
[in,out] | processor | The CPU that holds the accumulator |
[in] | addr | A ZERO PAGE address ! |
[in] | offset | The offset (usually X) |
Definition at line 526 of file cpu.h.
Referenced by execute_instruction(), and main().
#define STR_indirect_indexed_ACC | ( | processor, | |
addr, | |||
offset ) |
Procedure that store the accumulator value to a memory address using indirect indexed addressing mode.
[in,out] | processor | The CPU that holds the accumulator |
[in] | addr | A ZERO PAGE address ! |
[in] | offset | The offset (usually Y) |
Definition at line 516 of file cpu.h.
Referenced by execute_instruction(), and main().
#define STR_offset_ACC | ( | processor, | |
addr, | |||
offset ) |
Procedure that store the accumulator value to a memory address + offset.
[in,out] | processor | The CPU that holds the accumulator |
[in] | addr | The base address |
[in] | offset | The offset from the base address |
Definition at line 488 of file cpu.h.
Referenced by execute_instruction(), and main().
#define STR_offset_GENERIC | ( | cpu, | |
reg, | |||
addr, | |||
offset ) |
Procedure that store the register reg value to a memory address + offset.
[in,out] | cpu | The CPU that holds the register reg |
[in] | reg | The register that stores the value |
[in] | addr | The base address |
[in] | offset | The offset from the base address |
#define STR_offset_X | ( | processor, | |
addr, | |||
offset ) |
Procedure that store the X register value to a memory address + offset.
[in,out] | processor | The CPU that holds the X register |
[in] | addr | The base address |
[in] | offset | The offset from the base address |
Definition at line 497 of file cpu.h.
Referenced by execute_instruction(), and main().
#define STR_offset_Y | ( | processor, | |
addr, | |||
offset ) |
Procedure that store the Y register value to a memory address + offset.
[in,out] | processor | The CPU that holds the Y register |
[in] | addr | The base address |
[in] | offset | The offset from the base address |
Definition at line 506 of file cpu.h.
Referenced by execute_instruction(), and main().
#define TR_ACC_X | ( | processor | ) |
Procedure that store the value in the accumulator in the X register.
[in,out] | processor | The CPU holding both registers |
Definition at line 545 of file cpu.h.
Referenced by execute_instruction(), and main().
#define TR_ACC_Y | ( | processor | ) |
Procedure that store the value in accumulator in the Y register.
[in,out] | processor | The CPU holding both registers |
Definition at line 551 of file cpu.h.
Referenced by execute_instruction(), and main().
#define TR_GENERIC | ( | cpu, | |
reg1, | |||
reg2 ) |
Procedure that store the value in reg1 in reg2.
[in,out] | cpu | The CPU that holds both registers |
[in] | reg1 | The register holding the value |
[in] | reg2 | The register in which we load the value |
Definition at line 535 of file cpu.h.
#define TR_SP_X | ( | processor | ) |
Procedure that store the stack pointer in the X register.
[in,out] | processor | The CPU holding both registers |
Definition at line 569 of file cpu.h.
Referenced by execute_instruction(), and main().
#define TR_X_ACC | ( | processor | ) |
Procedure that store the value in the X register in the accumulator.
[in,out] | processor | The CPU holding both registers |
Definition at line 557 of file cpu.h.
Referenced by execute_instruction(), and main().
#define TR_X_SP | ( | processor | ) |
Procedure that store the value in the X register in the stack pointer.
[in,out] | processor | The CPU holding both registers |
Definition at line 575 of file cpu.h.
Referenced by execute_instruction(), and main().
#define TR_Y_ACC | ( | processor | ) |
Procedure that store the value in the Y register in the accumulator.
[in,out] | processor | The CPU holding both registers |
Definition at line 563 of file cpu.h.
Referenced by execute_instruction(), and main().
#define XOR_absolute | ( | processor, | |
addr ) |
Procedure that performs a bitwise logic XOR (A,Z,N = A&M) using absolute addressing mode.
[in,out] | processor | The CPU that performs the bitwise logic XOR operation |
[in] | addr | The addressing to the data |
Definition at line 845 of file cpu.h.
Referenced by execute_instruction(), and main().
#define XOR_immediate | ( | processor, | |
data ) |
Procedure that performs a bitwise logic XOR (A,Z,N = A & data)
[in,out] | processor | The CPU that performs the bitwise logic OR operation |
[in] | data | The value to bitwise XOR with the accumulator |
Definition at line 834 of file cpu.h.
Referenced by execute_instruction(), and main().
#define XOR_indexed_indirect | ( | processor, | |
addr, | |||
offset ) |
Procedure that perform a XOR with the carry flag (A,Z,C,N=A+M+C) with indexed indirect addressing mode.
[in,out] | processor | The CPU that performs the XOR with Carry |
[in] | addr | The base address |
[in] | offset | The offset (usually X) |
Definition at line 862 of file cpu.h.
Referenced by execute_instruction(), and main().
#define XOR_indirect_indexed | ( | processor, | |
addr, | |||
offset ) |
Procedure that perform a XOR with the carry flag (A,Z,C,N=A+M+C) with indirect indexed.
[in,out] | processor | The CPU that performs the XOR with Carry |
[in] | addr | The base address |
[in] | offset | The offset (usually Y) |
Definition at line 871 of file cpu.h.
Referenced by execute_instruction(), and main().
#define XOR_offset | ( | processor, | |
addr, | |||
offset ) |
Procedure that performs a bitwise logic XOR (A,Z,N = A&M) using offset addressing mode.
[in,out] | processor | The CPU that performs the bitwise logic XOR operation |
[in] | addr | The base address |
[in] | offset | The offset from the base address |
Definition at line 853 of file cpu.h.
Referenced by execute_instruction(), and main().
Function that execute the current instruction in the ROM.
[in,out] | cpu | The CPU that execute the current instruction |
Definition at line 575 of file cpu.c.
References ADC_A, ADC_AX, ADC_AY, ADC_I, ADC_IdX, ADC_IdY, ADC_Z, ADC_ZX, ADD_absolute, ADD_immediate, ADD_indexed_indirect, ADD_indirect_indexed, ADD_offset, AND_A, AND_absolute, AND_AX, AND_AY, AND_I, AND_IdX, AND_IdY, AND_immediate, AND_indexed_indirect, AND_indirect_indexed, AND_offset, AND_Z, AND_ZX, ASL_A, ASL_Ac, ASL_AX, ASL_Z, ASL_ZX, BCC, BCS, BEQ, BIT_A, BIT_TEST, BIT_Z, BMI, BNE, BPL, BRANCH_Carry_C, BRANCH_Carry_S, BRANCH_Equal, BRANCH_If_Minus, BRANCH_If_Positive, BRANCH_Not_Equal, BRANCH_Overflow_C, BRANCH_Overflow_S, BREAK, BRK, BVC, BVS, CLC, CLD, CLEAR_C_FLAG, CLEAR_D_FLAG, CLEAR_I_FLAG, CLEAR_V_FLAG, CLI, CLV, CMP_A, CMP_AX, CMP_AY, CMP_I, CMP_IdX, CMP_IdY, CMP_Z, CMP_ZX, COMPARE_absolute_ACC, COMPARE_absolute_X, COMPARE_absolute_Y, COMPARE_Immediate_ACC, COMPARE_Immediate_X, COMPARE_Immediate_Y, COMPARE_indexed_indirect_ACC, COMPARE_indirect_indexed_ACC, COMPARE_offset_ACC, CPX_A, CPX_I, CPX_Z, CPY_A, CPY_I, CPY_Z, DEC_A, DEC_absolute, DEC_AX, DEC_offset, DEC_X, DEC_Y, DEC_Z, DEC_ZX, DEX, DEY, EOR_A, EOR_AX, EOR_AY, EOR_I, EOR_IdX, EOR_IdY, EOR_Z, EOR_ZX, ERR_ABN_OPCODE, get_address, INC_A, INC_absolute, INC_AX, INC_offset, INC_X, INC_Y, INC_Z, INC_ZX, INX, INY, JMP_A, JMP_Id, JSR, JUMP_absolute, JUMP_indirect, JUMP_Subroutine, LD_absolute_ACC, LD_absolute_X, LD_absolute_Y, LD_immediate_ACC, LD_immediate_X, LD_immediate_Y, LD_indexed_indirect_ACC, LD_indirect_indexed_ACC, LD_offset_ACC, LD_offset_X, LD_offset_Y, LDA_A, LDA_AX, LDA_AY, LDA_I, LDA_IdX, LDA_IdY, LDA_Z, LDA_ZX, LDX_A, LDX_AY, LDX_I, LDX_Z, LDX_ZY, LDY_A, LDY_AX, LDY_I, LDY_Z, LDY_ZX, LSR_A, LSR_Ac, LSR_AX, LSR_Z, LSR_ZX, CPU::mem, NOP, OR_absolute, OR_immediate, OR_indexed_indirect, OR_indirect_indexed, OR_offset, ORA_A, ORA_AX, ORA_AY, ORA_I, ORA_IdX, ORA_IdY, ORA_Z, ORA_ZX, PHA, PHP, PLA, PLP, CPU::program_counter, PULL_ACC, PULL_FLAGS, PUSH_ACC, PUSH_FLAGS, CPU::register_x, CPU::register_y, RETURN_Interrupt, RETURN_Subroutine, ROL_A, ROL_Ac, ROL_AX, ROL_Z, ROL_ZX, ROR_A, ROR_Ac, ROR_AX, ROR_Z, ROR_ZX, ROTATION_LEFT_absolute, ROTATION_LEFT_ACC, ROTATION_LEFT_offset, ROTATION_RIGHT_absolute, ROTATION_RIGHT_ACC, ROTATION_RIGHT_offset, RTI, RTS, SBC_A, SBC_absolute, SBC_AX, SBC_AY, SBC_I, SBC_IdX, SBC_IdY, SBC_immediate, SBC_indexed_indirect, SBC_indirect_indexed, SBC_offset, SBC_Z, SBC_ZX, SEC, SED, SEI, SET_C_FLAG, SET_D_FLAG, SET_I_FLAG, SHIFT_LEFT_absolute, SHIFT_LEFT_ACC, SHIFT_LEFT_offset, SHIFT_RIGHT_absolute, SHIFT_RIGHT_ACC, SHIFT_RIGHT_offset, STA_A, STA_AX, STA_AY, STA_IdX, STA_IdY, STA_Z, STA_ZX, STR_absolute_ACC, STR_absolute_X, STR_absolute_Y, STR_indexed_indirect_ACC, STR_indirect_indexed_ACC, STR_offset_ACC, STR_offset_X, STR_offset_Y, STX_A, STX_Z, STX_ZY, STY_A, STY_Z, STY_ZX, TAX, TAY, TR_ACC_X, TR_ACC_Y, TR_SP_X, TR_X_ACC, TR_X_SP, TR_Y_ACC, TSX, TXA, TXS, TYA, XOR_absolute, XOR_immediate, XOR_indexed_indirect, XOR_indirect_indexed, and XOR_offset.
Referenced by step_cpu().
void free_cpu | ( | CPU * | cpu | ) |
Procedure that free the memory used by the CPU and the memory array.
[in,out] | cpu | The CPU to free and sets the pointer to NULL |
Definition at line 21 of file cpu.c.
References free_memory(), and CPU::mem.
Referenced by main().
unsigned char get_next_instruction | ( | CPU * | cpu | ) |
Function that get the next instruction written in the ROM.
[in] | cpu | The CPU that contains the mem |
Definition at line 32 of file cpu.c.
References ADC_A, ADC_AX, ADC_AY, ADC_I, ADC_IdX, ADC_IdY, ADC_Z, ADC_ZX, AND_A, AND_AX, AND_AY, AND_I, AND_IdX, AND_IdY, AND_Z, AND_ZX, ASL_A, ASL_Ac, ASL_AX, ASL_Z, ASL_ZX, BCC, BCS, BEQ, BIT_A, BMI, BNE, BPL, BRK, BVC, BVS, CLC, CLD, CLI, CLV, CMP_A, CMP_AX, CMP_AY, CMP_I, CMP_IdX, CMP_IdY, CMP_Z, CMP_ZX, CPX_A, CPX_I, CPX_Z, CPY_A, CPY_I, CPY_Z, DEC_A, DEC_AX, DEC_Z, DEC_ZX, DEX, DEY, EOR_A, EOR_AX, EOR_AY, EOR_I, EOR_IdX, EOR_IdY, EOR_Z, EOR_ZX, get_address, GET_C_FLAG, GET_N_FLAG, GET_V_FLAG, GET_Z_FLAG, INC_A, INC_AX, INC_Z, INC_ZX, indirect_indexed, INX, INY, is_page_crossed, JMP_A, JMP_Id, JSR, LDA_A, LDA_AX, LDA_AY, LDA_I, LDA_IdX, LDA_IdY, LDA_Z, LDA_ZX, LDX_A, LDX_AY, LDX_I, LDX_Z, LDX_ZY, LDY_A, LDY_AX, LDY_I, LDY_Z, LDY_ZX, LSR_A, LSR_Ac, LSR_AX, LSR_Z, LSR_ZX, CPU::mem, NOP, ORA_A, ORA_AX, ORA_AY, ORA_I, ORA_IdX, ORA_IdY, ORA_Z, ORA_ZX, PHA, PHP, PLA, PLP, CPU::program_counter, CPU::register_x, CPU::register_y, ROL_A, ROL_Ac, ROL_AX, ROL_Z, ROL_ZX, ROR_A, ROR_Ac, ROR_AX, ROR_Z, ROR_ZX, RTI, RTS, SBC_A, SBC_AX, SBC_AY, SBC_I, SBC_IdX, SBC_IdY, SBC_Z, SBC_ZX, SEC, SED, SEI, STA_A, STA_AX, STA_AY, STA_IdX, STA_IdY, STA_Z, STA_ZX, STX_A, STX_Z, STX_ZY, STY_A, TAX, TAY, TSX, TXA, TXS, and TYA.
Referenced by step_cpu().
Procedure that initialize the CPU to its boot/reset state.
[in,out] | cpu | The CPU to initialize |
[in] | mem | The address to the memory array |
Definition at line 9 of file cpu.c.
References CPU::accumulator, CPU::cache, CPU::cycle_counter, CPU::flags, CPU::mem, CPU::program_counter, CPU::register_x, CPU::register_y, and CPU::stack_pointer.
Referenced by main(), and start_cpu().
Procedure that display the expected state of the CPU.
[in] | acc | The expected state of the accumulator |
[in] | x | The expected state of the X register |
[in] | y | The expected state of the Y register |
[in] | flags | The expected flags |
[in] | pc | The expected program counter |
[in] | sp | The expected Stack pointer |
Definition at line 1235 of file cpu.c.
References BIT_0_MASK, BIT_1_MASK, BIT_2_MASK, BIT_3_MASK, BIT_4_MASK, BIT_5_MASK, BIT_6_MASK, and BIT_7_MASK.
Referenced by main().
void print_cpu_state | ( | CPU * | processor | ) |
Procedure that displays the current state of the CPU.
[in] | processor | The CPU to display |
Definition at line 1210 of file cpu.c.
References CPU::accumulator, CPU::flags, GET_B_FLAG, GET_C_FLAG, GET_D_FLAG, GET_I_FLAG, GET_N_FLAG, GET_P_FLAG, GET_V_FLAG, GET_Z_FLAG, CPU::program_counter, CPU::register_x, CPU::register_y, and CPU::stack_pointer.
Referenced by main().
Procedure that display the expected state of the stack.
[in] | stack | An array representing the expected stack |
[in] | start | The start of the stack |
Definition at line 1282 of file cpu.c.
Referenced by main().
void print_stack_state | ( | CPU * | cpu | ) |
Procedure that display the current state of the stack.
[in] | cpu | The current cpu holding the stack |
Definition at line 1259 of file cpu.c.
References CPU::mem, STACK_END, CPU::stack_pointer, and STACK_START.
Referenced by main().
void reset | ( | CPU * | processor | ) |
void start_cpu | ( | CPU * | cpu | ) |
Procedure that acts like the reset button of the NES.
[in,out] | cpu | The CPU to start/restart |
Definition at line 27 of file cpu.c.
References get_address, init_cpu(), CPU::mem, and CPU::program_counter.
Function that step a clock cycle.
[in,out] | cpu | The CPU to step |
Definition at line 1190 of file cpu.c.
References CPU::cycle_counter, ERR_ABN_OPCODE, execute_instruction(), get_next_instruction(), CPU::mem, memory_mirroring(), and CPU::program_counter.
Referenced by main().