blob: 78f03e8d3763804a07d23f3410863445992999bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#ifndef MOS6502_H
#define MOS6502_H
#include <stdint.h>
#include <stdbool.h>
#define FLAG_C_BIT 0
#define FLAG_Z_BIT 1
#define FLAG_I_BIT 2
#define FLAG_D_BIT 3
#define FLAG_B_BIT 4
#define FLAG_U_BIT 5
#define FLAG_N_BIT 6
#define FLAG_V_BIT 7
#define FLAG_GET(f) ((cpu->flags & (1 << FLAG_##f##_BIT)) >> FLAG_##f##_BIT)
#define FLAG_SET(f, v) (cpu->flags = (cpu->flags & ~(1 << FLAG_##f##_BIT)) | ((v) << FLAG_##f##_BIT))
extern uint8_t bus_read(uint16_t addr, uint8_t cycle);
extern void bus_write(uint16_t addr, uint8_t v, uint8_t cycle);
typedef struct cpu_s {
uint16_t pc;
uint8_t a;
uint8_t x;
uint8_t y;
uint8_t sp;
volatile uint8_t flags;
bool irq;
bool nmi;
bool jammed;
} cpu_t;
void cpu_reset(cpu_t *cpu);
uint8_t cpu_step(cpu_t *cpu);
#endif
|