summaryrefslogtreecommitdiff
path: root/cpu_opcodes.c
diff options
context:
space:
mode:
authorPeter Fors <peter.fors@mindkiller.com>2025-04-28 18:27:17 +0200
committerPeter Fors <peter.fors@mindkiller.com>2025-04-28 18:27:17 +0200
commitc40f7421d8c1ccbe008dbd2191c6642625ae4b83 (patch)
tree9779e0a5cff2adec44897dab43d3838e8e61d3fe /cpu_opcodes.c
parent8a32bcfac621dfcaa6af832228e56713a4af6156 (diff)
before ppu rearrangement and fix of scanline 261
Diffstat (limited to 'cpu_opcodes.c')
-rw-r--r--cpu_opcodes.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/cpu_opcodes.c b/cpu_opcodes.c
index b879015..7e174be 100644
--- a/cpu_opcodes.c
+++ b/cpu_opcodes.c
@@ -1,7 +1,7 @@
// ADC
-
+__attribute__((always_inline, hot))
static inline void adc(struct cpu_state * restrict cpu, uint8_t value) {
#ifdef ENABLE_DECIMAL_MODE
if(cpu->d) {
@@ -407,7 +407,7 @@ static void opcode_brk(struct nes_state * restrict state) {
// BRANCHES
-
+__attribute__((always_inline, hot))
static inline int page_crossed(uint16_t a, uint16_t b) {
return (a & 0xff00) != (b & 0xff00);
}
@@ -583,6 +583,7 @@ static void opcode_sei(struct nes_state * restrict state) {
// CMP
+__attribute__((always_inline, hot))
static inline void cmp(struct cpu_state * restrict cpu, uint8_t value) {
uint8_t result = cpu->a - value;
cpu->c = (cpu->a >= value);
@@ -695,7 +696,7 @@ static void opcode_cmp_absx(struct nes_state * restrict state) {
// CPX
-
+__attribute__((always_inline, hot))
static inline void cpx(struct cpu_state * restrict cpu, uint8_t value) {
uint8_t result = cpu->x - value;
cpu->c = (cpu->x >= value);
@@ -731,7 +732,7 @@ static void opcode_cpx_abs(struct nes_state * restrict state) {
// CPY
-
+__attribute__((always_inline, hot))
static inline void cpy(struct cpu_state * restrict cpu, uint8_t value) {
uint8_t result = cpu->y - value;
cpu->c = (cpu->y >= value);
@@ -1752,7 +1753,7 @@ static void opcode_ror_absx(struct nes_state * restrict state) {
// SBC
-
+__attribute__((always_inline, hot))
static inline void sbc(struct cpu_state * restrict cpu, uint8_t value) {
#ifdef ENABLE_DECIMAL_MODE
if(cpu->d) {
@@ -2123,6 +2124,9 @@ static void opcode_sty_zpx(struct nes_state * restrict state) {
__attribute__((noinline))
static void init_opcode_lut(void) {
+ for(uint32_t i = 0; i < 256; ++i) {
+ opcode_lut[i] = opcode_nop; // make sure erroneous opcodes just do "NOP", this might change in the future!
+ }
opcode_lut[0x00] = opcode_brk;
opcode_lut[0x01] = opcode_ora_indx;
opcode_lut[0x05] = opcode_ora_zp;