cpu_65c02_asl(self, cpu_65c02_ea_zero_page(self));
break;
case 0x07:
- cpu_65c02_rmb(self, 1, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_rmb(self, 0, cpu_65c02_ea_zero_page(self));
break;
case 0x08:
cpu_65c02_ph(self, self->regs.byte.p);
cpu_65c02_asl(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
break;
case 0x17:
- cpu_65c02_rmb(self, 2, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_rmb(self, 1, cpu_65c02_ea_zero_page(self));
break;
case 0x18:
- cpu_65c02_cl(self, (1 << CPU_65C02_REG_P_BIT_C));
+ cpu_65c02_cl(self, CPU_65C02_REG_P_BIT_C);
break;
case 0x19:
cpu_65c02_ora(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
cpu_65c02_rol(self, cpu_65c02_ea_zero_page(self));
break;
case 0x27:
- cpu_65c02_rmb(self, 4, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_rmb(self, 2, cpu_65c02_ea_zero_page(self));
break;
case 0x28:
cpu_65c02_plp(self);
cpu_65c02_rol(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
break;
case 0x37:
- cpu_65c02_rmb(self, 8, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_rmb(self, 3, cpu_65c02_ea_zero_page(self));
break;
case 0x38:
- cpu_65c02_se(self, (1 << CPU_65C02_REG_P_BIT_C));
+ cpu_65c02_se(self, CPU_65C02_REG_P_BIT_C);
break;
case 0x39:
cpu_65c02_and(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
cpu_65c02_lsr(self, cpu_65c02_ea_zero_page(self));
break;
case 0x47:
- cpu_65c02_rmb(self, 0x10, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_rmb(self, 4, cpu_65c02_ea_zero_page(self));
break;
case 0x48:
cpu_65c02_ph(self, self->regs.byte.a);
cpu_65c02_lsr(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
break;
case 0x57:
- cpu_65c02_rmb(self, 0x20, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_rmb(self, 5, cpu_65c02_ea_zero_page(self));
break;
case 0x58:
- cpu_65c02_cl(self, (1 << CPU_65C02_REG_P_BIT_I));
+ cpu_65c02_cl(self, CPU_65C02_REG_P_BIT_I);
break;
case 0x59:
cpu_65c02_eor(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
cpu_65c02_ror(self, cpu_65c02_ea_zero_page(self));
break;
case 0x67:
- cpu_65c02_rmb(self, 0x40, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_rmb(self, 6, cpu_65c02_ea_zero_page(self));
break;
case 0x68:
cpu_65c02_pl(self, CPU_65C02_EA_A);
cpu_65c02_ror(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
break;
case 0x77:
- cpu_65c02_rmb(self, 0x80, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_rmb(self, 7, cpu_65c02_ea_zero_page(self));
break;
case 0x78:
- cpu_65c02_se(self, (1 << CPU_65C02_REG_P_BIT_I));
+ cpu_65c02_se(self, CPU_65C02_REG_P_BIT_I);
break;
case 0x79:
cpu_65c02_adc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
cpu_65c02_st(self, self->regs.byte.x, cpu_65c02_ea_zero_page(self));
break;
case 0x87:
- cpu_65c02_smb(self, 1, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_smb(self, 0, cpu_65c02_ea_zero_page(self));
break;
case 0x88:
cpu_65c02_dec(self, CPU_65C02_EA_Y);
cpu_65c02_st(self, self->regs.byte.x, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.y));
break;
case 0x97:
- cpu_65c02_smb(self, 2, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_smb(self, 1, cpu_65c02_ea_zero_page(self));
break;
case 0x98:
cpu_65c02_ld(self, CPU_65C02_EA_A, self->regs.byte.y);
cpu_65c02_ld(self, CPU_65C02_EA_X, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self)));
break;
case 0xa7:
- cpu_65c02_smb(self, 4, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_smb(self, 2, cpu_65c02_ea_zero_page(self));
break;
case 0xa8:
cpu_65c02_ld(self, CPU_65C02_EA_Y, self->regs.byte.a);
cpu_65c02_ld(self, CPU_65C02_EA_X, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.y)));
break;
case 0xb7:
- cpu_65c02_smb(self, 8, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_smb(self, 3, cpu_65c02_ea_zero_page(self));
break;
case 0xb8:
- cpu_65c02_cl(self, (1 << CPU_65C02_REG_P_BIT_V));
+ cpu_65c02_cl(self, CPU_65C02_REG_P_BIT_V);
break;
case 0xb9:
cpu_65c02_ld(self, CPU_65C02_EA_A, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
cpu_65c02_dec(self, cpu_65c02_ea_zero_page(self));
break;
case 0xc7:
- cpu_65c02_smb(self, 0x10, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_smb(self, 4, cpu_65c02_ea_zero_page(self));
break;
case 0xc8:
cpu_65c02_inc(self, CPU_65C02_EA_Y);
cpu_65c02_dec(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
break;
case 0xd7:
- cpu_65c02_smb(self, 0x20, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_smb(self, 5, cpu_65c02_ea_zero_page(self));
break;
case 0xd8:
- cpu_65c02_cl(self, (1 << CPU_65C02_REG_P_BIT_D));
+ cpu_65c02_cl(self, CPU_65C02_REG_P_BIT_D);
break;
case 0xd9:
cpu_65c02_cmp(self, self->regs.byte.a, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
cpu_65c02_inc(self, cpu_65c02_ea_zero_page(self));
break;
case 0xe7:
- cpu_65c02_smb(self, 0x40, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_smb(self, 6, cpu_65c02_ea_zero_page(self));
break;
case 0xe8:
cpu_65c02_inc(self, CPU_65C02_EA_X);
cpu_65c02_inc(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
break;
case 0xf7:
- cpu_65c02_smb(self, 0x80, cpu_65c02_ea_zero_page(self));
+ cpu_65c02_smb(self, 7, cpu_65c02_ea_zero_page(self));
break;
case 0xf8:
- cpu_65c02_se(self, (1 << CPU_65C02_REG_P_BIT_D));
+ cpu_65c02_se(self, CPU_65C02_REG_P_BIT_D);
break;
case 0xf9:
cpu_65c02_sbc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
self->regs.bit.df = false;
}
-static ALWAYS_INLINE void cpu_65c02_cl(struct cpu_65c02 *self, int flag) {
- self->regs.byte.p &= ~flag;
+static ALWAYS_INLINE void cpu_65c02_cl(struct cpu_65c02 *self, int n) {
+ self->regs.byte.p &= ~(1 << n);
}
static ALWAYS_INLINE void cpu_65c02_cmp(struct cpu_65c02 *self, int rvalue0, int rvalue1) {
self->regs.byte.p = cpu_65c02_pop_byte(self) | 0x30;
}
-static ALWAYS_INLINE void cpu_65c02_rmb(struct cpu_65c02 *self, int rvalue, int lvalue) {
- int result = cpu_65c02_read_byte(self, lvalue) & ~rvalue;
+static ALWAYS_INLINE void cpu_65c02_rmb(struct cpu_65c02 *self, int n, int lvalue) {
+ int result = cpu_65c02_read_byte(self, lvalue) & ~(1 << n);
++self->cycles;
cpu_65c02_write_byte(self, lvalue, result);
}
self->regs.bit.nf = (result2 >> 7) & 1;
}
-static ALWAYS_INLINE void cpu_65c02_se(struct cpu_65c02 *self, int flag) {
- self->regs.byte.p |= flag;
+static ALWAYS_INLINE void cpu_65c02_se(struct cpu_65c02 *self, int n) {
+ self->regs.byte.p |= 1 << n;
}
-static ALWAYS_INLINE void cpu_65c02_smb(struct cpu_65c02 *self, int rvalue, int lvalue) {
- int result = cpu_65c02_read_byte(self, lvalue) | rvalue;
+static ALWAYS_INLINE void cpu_65c02_smb(struct cpu_65c02 *self, int n, int lvalue) {
+ int result = cpu_65c02_read_byte(self, lvalue) | (1 << n);
++self->cycles;
cpu_65c02_write_byte(self, lvalue, result);
}