-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.h
49 lines (37 loc) · 1.01 KB
/
core.h
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
#pragma once
#include <ctype.h>
#include <stdint.h>
typedef struct CondFlags{
uint8_t z : 1;
uint8_t s : 1;
uint8_t p : 1;
uint8_t cy : 1;
uint8_t ac : 1;
uint8_t pad : 2;
} CondFlags;
typedef struct CPU_state{
uint8_t a;
uint8_t b;
uint8_t c;
uint8_t d;
uint8_t e;
uint8_t h;
uint8_t l;
uint16_t sp;
uint16_t pc;
uint8_t *memory;
CondFlags flags;
uint8_t int_enable : 1;
} CPU;
void unimplemented(CPU *cpu);
void emulate(CPU *cpu);
unsigned char *regptr(CPU *cpu, uint8_t regcode);
void sub40(CPU *cpu, uint8_t top, uint8_t bot, uint8_t *opcode);
void rtype(CPU *cpu, uint8_t *dest, uint8_t *src, uint8_t top, uint8_t bot);
void control(CPU *cpu, uint8_t top, uint8_t bot, uint8_t *opcode);
uint8_t parity(uint16_t word);
uint8_t parity_limit(uint16_t word, int limit);
void generateInterrupt(CPU *cpu, int intcode);
extern void machine_init();
extern uint8_t MachineIN(uint8_t port, uint8_t cpua);
extern uint8_t MachineOUT(uint8_t port, uint8_t value);