cpu: re-indent the file

Running text editors in different environments led to some variations
in indentation.
This commit is contained in:
2018-07-09 02:22:16 +00:00
parent 86191c3c09
commit 81f74815d8

View File

@@ -13,7 +13,7 @@
#define SET_BIT(x, idx) do {(x) |= (1 << (idx));} while (0)
#define CLR_BIT(x, idx) do {(x) &= ~(1 << (idx));} while (0)
#define GET_BIT(x, bit) (((x) >> (bit)) & 1)
#define WRITE_BIT(x, idx, bit) \
#define WRITE_BIT(x, idx, bit) \
do {(x) &= (~(1 << (idx)) | ((bit) << (idx)));} while(0)
#define CALC_H_ADD(a, b) ((((a) & 0xf) + ((b) & 0xf)) > 0xf)
@@ -126,30 +126,30 @@ static const unsigned int cb_extra_cycles[256] = { 0 };
/* TODO: optimize macros with temp variables so mem_read() doesn't expand multiple times */
#define INC_8(cpu, reg) \
do { \
(cpu)->nf = 0; \
(cpu)->hf = CALC_H_ADD(reg, 1); \
(reg)++; \
do { \
(cpu)->nf = 0; \
(cpu)->hf = CALC_H_ADD(reg, 1); \
(reg)++; \
(cpu)->zf = (reg) == 0; \
} while (0)
#define DEC_8(cpu, reg) \
do { \
(cpu)->nf = 1; \
(cpu)->hf = CALC_H_SUB(reg, 1); \
(reg)--; \
do { \
(cpu)->nf = 1; \
(cpu)->hf = CALC_H_SUB(reg, 1); \
(reg)--; \
(cpu)->zf = (reg) == 0; \
} while (0)
#define LD_D8(cpu, reg) \
do { \
#define LD_D8(cpu, reg) \
do { \
(reg) = (cpu)->mem_read((cpu), (cpu)->pc++); \
} while (0)
#define LD_D16(cpu, reg) \
do { \
(reg) = (cpu)->mem_read((cpu), (cpu)->pc++); \
(reg) |= (uint16_t) (cpu)->mem_read((cpu), (cpu)->pc++) << 8; \
#define LD_D16(cpu, reg) \
do { \
(reg) = (cpu)->mem_read((cpu), (cpu)->pc++); \
(reg) |= (uint16_t) (cpu)->mem_read((cpu), (cpu)->pc++) << 8; \
} while (0)
#define ADD_8(cpu, dst, src) \
@@ -236,69 +236,69 @@ static const unsigned int cb_extra_cycles[256] = { 0 };
(cpu)->zf = ((dst) == 0); \
} while (0)
#define CP_8(cpu, dst, src) \
do { \
uint8_t _tmp; \
uint8_t _dst = dst; \
uint8_t _src = src; \
(cpu)->nf = 1; \
#define CP_8(cpu, dst, src) \
do { \
uint8_t _tmp; \
uint8_t _dst = dst; \
uint8_t _src = src; \
(cpu)->nf = 1; \
(cpu)->hf = CALC_H_SUB((_dst), (_src)); \
(cpu)->cf = CALC_C_SUB((_dst), (_src)); \
_tmp = (_dst) - (_src); \
(cpu)->zf = ((_tmp) == 0); \
_tmp = (_dst) - (_src); \
(cpu)->zf = ((_tmp) == 0); \
} while (0)
#define JR_8(cpu) \
do { \
val_16 = cpu->mem_read(cpu, cpu->pc++); \
/* sign-extend */ \
val_16 |= GET_BIT(val_16, 7) ? 0xff00 : 0; \
cpu->pc += val_16; \
#define JR_8(cpu) \
do { \
val_16 = cpu->mem_read(cpu, cpu->pc++); \
/* sign-extend */ \
val_16 |= GET_BIT(val_16, 7) ? 0xff00 : 0; \
cpu->pc += val_16; \
} while (0)
/* TODO: In general, check that we pop/push things correctly */
#define POP_16(cpu, dst) \
do { \
(dst) = (cpu)->mem_read((cpu), (cpu)->sp++); \
(dst) |= (uint16_t) (cpu)->mem_read((cpu), (cpu)->sp++) << 8; \
#define POP_16(cpu, dst) \
do { \
(dst) = (cpu)->mem_read((cpu), (cpu)->sp++); \
(dst) |= (uint16_t) (cpu)->mem_read((cpu), (cpu)->sp++) << 8; \
} while (0)
#define PUSH_16(cpu, src) \
do { \
#define PUSH_16(cpu, src) \
do { \
(cpu)->mem_write(cpu, --cpu->sp, src); \
(cpu)->mem_write(cpu, --cpu->sp, src >> 8); \
} while (0)
#define CALL(cpu) \
do { \
uint16_t pc_base; \
cpu->mem_write(cpu, --cpu->sp, cpu->pc); \
cpu->mem_write(cpu, --cpu->sp, cpu->pc >> 8); \
pc_base = cpu->mem_read(cpu, cpu->pc++); \
#define CALL(cpu) \
do { \
uint16_t pc_base; \
cpu->mem_write(cpu, --cpu->sp, cpu->pc); \
cpu->mem_write(cpu, --cpu->sp, cpu->pc >> 8); \
pc_base = cpu->mem_read(cpu, cpu->pc++); \
pc_base |= (uint16_t) cpu->mem_read(cpu, cpu->pc) << 8; \
cpu->pc = pc_base; \
cpu->pc = pc_base; \
} while (0)
#define RET(cpu) \
do { \
(cpu)->pc = 0; \
#define RET(cpu) \
do { \
(cpu)->pc = 0; \
(cpu)->pc |= (uint16_t) (cpu)->mem_read((cpu), (cpu)->sp++) << 8; \
(cpu)->pc |= (cpu)->mem_read((cpu), (cpu)->sp++); \
(cpu)->pc += 2; \
(cpu)->pc |= (cpu)->mem_read((cpu), (cpu)->sp++); \
(cpu)->pc += 2; \
} while (0)
#define RST(cpu, n) \
do { \
#define RST(cpu, n) \
do { \
(cpu)->mem_write((cpu), (cpu)->sp++, (cpu)->pc >> 8); \
(cpu)->mem_write((cpu), (cpu)->sp++, (cpu)->pc); \
(cpu)->pc = (n); \
(cpu)->mem_write((cpu), (cpu)->sp++, (cpu)->pc); \
(cpu)->pc = (n); \
} while (0)
#define BIT(cpu, reg, bit) \
do { \
(cpu)->zf = !GET_BIT(reg, bit); \
(cpu)->nf = 0; \
(cpu)->hf = 1; \
#define BIT(cpu, reg, bit) \
do { \
(cpu)->zf = !GET_BIT(reg, bit); \
(cpu)->nf = 0; \
(cpu)->hf = 1; \
} while (0)
#define RES(reg, bit) \
@@ -311,16 +311,16 @@ static const unsigned int cb_extra_cycles[256] = { 0 };
SET_BIT(reg, bit); \
} while (0)
#define RL(cpu, reg) \
do { \
uint8_t ci = (cpu)->cf; \
uint8_t tmp = reg; \
(cpu)->nf = 0; \
(cpu)->hf = 0; \
(cpu)->cf = GET_BIT(tmp, 7); \
tmp = tmp << 1; \
(tmp) |= ci; \
(cpu)->zf = (tmp) == 0; \
#define RL(cpu, reg) \
do { \
uint8_t ci = (cpu)->cf; \
uint8_t tmp = reg; \
(cpu)->nf = 0; \
(cpu)->hf = 0; \
(cpu)->cf = GET_BIT(tmp, 7); \
tmp = tmp << 1; \
(tmp) |= ci; \
(cpu)->zf = (tmp) == 0; \
} while (0)
int lr35902_cycle(struct lr35902_state *cpu)