summaryrefslogtreecommitdiff
path: root/src/vcpu.h
blob: c85744d91b145743c6176cc73ebaaa6fb9da721f (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
#pragma once

typedef struct VCPU_State {
  // Program Counter (16 bits but only 12 bits used (4096 memory addresses))
  unsigned short PC;

  // Index register (16 bits but only 12 bits used (4096 memory addresses))
  unsigned short I;

  // Stack register (16 bits)
  unsigned short S;

  // General purpose registers (8 bits each)
  // Note last one often used as a flag register
  unsigned char V[16];

  // Delay timer (8 bits)
  unsigned char DT;

  // Sound timer (8 bits)
  unsigned char ST;

  // Intruction (opcode + decoded fields)
  short opcode;
  char X;
  char Y;
  char N;
  char NN;
  short NNN;
} VCPU_State;

void VCPUInit();
void VCPUFetch();
void VCPUDecode();
void VCPUExecute();