-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sprite.cs
49 lines (47 loc) · 1.53 KB
/
Sprite.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
43
44
45
46
47
48
49
namespace ZarthGB
{
class Sprite
{
private Memory memory;
public int MemoryOffset { get; set; }
public byte Y
{
get => memory[MemoryOffset];
set => memory[MemoryOffset] = value;
}
public byte X
{
get => memory[MemoryOffset+1];
set => memory[MemoryOffset+1] = value;
}
public byte TileNumber
{
get => memory[MemoryOffset+2];
set => memory[MemoryOffset+2] = value;
}
public bool Priority
{
get => (memory[MemoryOffset+3] & (1<<7)) > 0;
set => memory[MemoryOffset+3] = (byte)((memory[MemoryOffset+3] & ~(1<<7)) | (value ? 1<<7 : 0));
}
public bool VFlip
{
get => (memory[MemoryOffset+3] & (1<<6)) > 0;
set => memory[MemoryOffset+3] = (byte)((memory[MemoryOffset+3] & ~(1<<6)) | (value ? 1<<6 : 0));
}
public bool HFlip
{
get => (memory[MemoryOffset+3] & (1<<5)) > 0;
set => memory[MemoryOffset+3] = (byte)((memory[MemoryOffset+3] & ~(1<<5)) | (value ? 1<<5 : 0));
}
public bool Palette
{
get => (memory[MemoryOffset+3] & (1<<4)) > 0;
set => memory[MemoryOffset+3] = (byte)((memory[MemoryOffset+3] & ~(1<<4)) | (value ? 1<<4 : 0));
}
public Sprite(Memory memory)
{
this.memory = memory;
}
}
}