Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/snes/ppu/sprite/list.cpp
2 views
1
#ifdef PPU_CPP
2
3
void PPU::Sprite::update(unsigned addr, uint8 data) {
4
if(addr < 0x0200) {
5
unsigned n = addr >> 2;
6
addr &= 3;
7
if(addr == 0) {
8
list[n].x = (list[n].x & 0x100) | data;
9
} else if(addr == 1) {
10
list[n].y = data;
11
} else if(addr == 2) {
12
list[n].character = data;
13
} else { //(addr == 3)
14
list[n].vflip = data & 0x80;
15
list[n].hflip = data & 0x40;
16
list[n].priority = (data >> 4) & 3;
17
list[n].palette = (data >> 1) & 7;
18
list[n].nameselect = data & 1;
19
}
20
} else {
21
unsigned n = (addr & 0x1f) << 2;
22
list[n + 0].x = ((data & 0x01) << 8) | (list[n + 0].x & 0xff);
23
list[n + 0].size = data & 0x02;
24
list[n + 1].x = ((data & 0x04) << 6) | (list[n + 1].x & 0xff);
25
list[n + 1].size = data & 0x08;
26
list[n + 2].x = ((data & 0x10) << 4) | (list[n + 2].x & 0xff);
27
list[n + 2].size = data & 0x20;
28
list[n + 3].x = ((data & 0x40) << 2) | (list[n + 3].x & 0xff);
29
list[n + 3].size = data & 0x80;
30
}
31
}
32
33
void PPU::Sprite::synchronize() {
34
for(unsigned n = 0; n < 544; n++) update(n, ppu.oam[n]);
35
}
36
37
unsigned PPU::Sprite::SpriteItem::width() const {
38
if(size == 0) {
39
static unsigned width[] = { 8, 8, 8, 16, 16, 32, 16, 16 };
40
return width[ppu.sprite.regs.base_size];
41
} else {
42
static unsigned width[] = { 16, 32, 64, 32, 64, 64, 32, 32 };
43
return width[ppu.sprite.regs.base_size];
44
}
45
}
46
47
unsigned PPU::Sprite::SpriteItem::height() const {
48
if(size == 0) {
49
if(ppu.sprite.regs.interlace && ppu.sprite.regs.base_size >= 6) return 16;
50
static unsigned height[] = { 8, 8, 8, 16, 16, 32, 32, 32 };
51
return height[ppu.sprite.regs.base_size];
52
} else {
53
static unsigned height[] = { 16, 32, 64, 32, 64, 64, 64, 32 };
54
return height[ppu.sprite.regs.base_size];
55
}
56
}
57
58
#endif
59
60