-
Notifications
You must be signed in to change notification settings - Fork 0
/
simak65.c
66 lines (51 loc) · 1.23 KB
/
simak65.c
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* SimAK65 interface
* Copyright A.K. 2018, 2023
*/
#include <stddef.h>
#include "simak65.h"
#include "decoder.h"
#include "addrmode.h"
#include "types.h"
#include "bus.h"
#include "exec.h"
void simak65_step(struct simak65_cpustate *cpu, unsigned int *cycles)
{
unsigned int tcycles = 0;
u8 args[2];
struct opinfo instruction = decode(addrmode_nextpc(cpu));
enum argtype argtype = addrmode_getArgs(cpu, args, instruction.mode, &tcycles);
exec_execute(cpu, instruction.opcode, argtype, args, &tcycles);
if (cycles != NULL)
*cycles += tcycles + 1;
}
void simak65_rst(struct simak65_cpustate *cpu, unsigned int *cycles)
{
unsigned int tcycles = 0;
exec_rst(cpu, &tcycles);
if (cycles != NULL)
*cycles += tcycles;
}
void simak65_nmi(struct simak65_cpustate *cpu, unsigned int *cycles)
{
unsigned int tcycles = 0;
exec_nmi(cpu, &tcycles);
if (cycles != NULL)
*cycles += tcycles;
}
void simak65_irq(struct simak65_cpustate *cpu, unsigned int *cycles)
{
unsigned int tcycles = 0;
exec_irq(cpu, &tcycles);
if (cycles != NULL)
*cycles += tcycles;
}
void simak65_init(struct simak65_cpustate *cpu, const struct simak65_bus *ops)
{
cpu->pc = 0;
cpu->a = 0;
cpu->x = 0;
cpu->y = 0;
cpu->sp = 0;
cpu->flags = 0;
bus_init(ops);
}