-
Notifications
You must be signed in to change notification settings - Fork 0
/
CProcessor.cs
42 lines (34 loc) · 1.22 KB
/
CProcessor.cs
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
using System;
using System.Collections.Generic;
using System.Text;
namespace sharpGB
{
public class CProcessor
{
// The registers of the CPU (Z80-wannabe)
public byte A,B,C,D,E,F,H,L;
public ushort SP, PC, HL, OldPC;
// Some instructions determine the behaviour of the CPU
public bool IME; // Turn on/off interrupt handling
public int DIsignaled, EIsignaled; // Instructions DI and EI set these
public bool SkipPCCounting; // Needed for special case if opcode Halt + Disabled interrupts
public bool CPUHalt, CPUStop; // Set by instructions as well
// The four flag register entries
public uint ZeroFlag, SubtractFlag, HalfCarryFlag, CarryFlag;
public void SetFlags(int Z, int S, int H, int C)
{
// Normalize to 0 or 1
if (Z != 0) Z = 1;
if (S != 0) S = 1;
if (H != 0) H = 1;
if (C != 0) C = 1;
ZeroFlag = (uint) Z;
SubtractFlag = (uint)S;
HalfCarryFlag = (uint)H;
CarryFlag = (uint)C;
}
public CProcessor()
{
}
}
}