Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/snes/alt/ppu-performance/window/window.cpp
2 views
1
#ifdef PPU_CPP
2
3
void PPU::LayerWindow::render(bool screen) {
4
uint8 *output;
5
if(screen == 0) {
6
output = main;
7
if(main_enable == false) {
8
memset(output, 0, 256);
9
return;
10
}
11
} else {
12
output = sub;
13
if(sub_enable == false) {
14
memset(output, 0, 256);
15
return;
16
}
17
}
18
19
if(one_enable == false && two_enable == false) {
20
memset(output, 0, 256);
21
return;
22
}
23
24
if(one_enable == true && two_enable == false) {
25
bool set = 1 ^ one_invert, clr = !set;
26
for(unsigned x = 0; x < 256; x++) {
27
output[x] = (x >= ppu.regs.window_one_left && x <= ppu.regs.window_one_right) ? set : clr;
28
}
29
return;
30
}
31
32
if(one_enable == false && two_enable == true) {
33
bool set = 1 ^ two_invert, clr = !set;
34
for(unsigned x = 0; x < 256; x++) {
35
output[x] = (x >= ppu.regs.window_two_left && x <= ppu.regs.window_two_right) ? set : clr;
36
}
37
return;
38
}
39
40
for(unsigned x = 0; x < 256; x++) {
41
bool one_mask = (x >= ppu.regs.window_one_left && x <= ppu.regs.window_one_right) ^ one_invert;
42
bool two_mask = (x >= ppu.regs.window_two_left && x <= ppu.regs.window_two_right) ^ two_invert;
43
switch(mask) {
44
case 0: output[x] = one_mask | two_mask == 1; break;
45
case 1: output[x] = one_mask & two_mask == 1; break;
46
case 2: output[x] = one_mask ^ two_mask == 1; break;
47
case 3: output[x] = one_mask ^ two_mask == 0; break;
48
}
49
}
50
}
51
52
//
53
54
void PPU::ColorWindow::render(bool screen) {
55
uint8 *output = (screen == 0 ? main : sub);
56
bool set = 1, clr = 0;
57
58
switch(screen == 0 ? main_mask : sub_mask) {
59
case 0: memset(output, 1, 256); return; //always
60
case 1: set = 1, clr = 0; break; //inside window only
61
case 2: set = 0, clr = 1; break; //outside window only
62
case 3: memset(output, 0, 256); return; //never
63
}
64
65
if(one_enable == false && two_enable == false) {
66
memset(output, clr, 256);
67
return;
68
}
69
70
if(one_enable == true && two_enable == false) {
71
if(one_invert) { set ^= 1; clr ^= 1; }
72
for(unsigned x = 0; x < 256; x++) {
73
output[x] = (x >= ppu.regs.window_one_left && x <= ppu.regs.window_one_right) ? set : clr;
74
}
75
return;
76
}
77
78
if(one_enable == false && two_enable == true) {
79
if(two_invert) { set ^= 1; clr ^= 1; }
80
for(unsigned x = 0; x < 256; x++) {
81
output[x] = (x >= ppu.regs.window_two_left && x <= ppu.regs.window_two_right) ? set : clr;
82
}
83
return;
84
}
85
86
for(unsigned x = 0; x < 256; x++) {
87
bool one_mask = (x >= ppu.regs.window_one_left && x <= ppu.regs.window_one_right) ^ one_invert;
88
bool two_mask = (x >= ppu.regs.window_two_left && x <= ppu.regs.window_two_right) ^ two_invert;
89
switch(mask) {
90
case 0: output[x] = one_mask | two_mask == 1 ? set : clr; break;
91
case 1: output[x] = one_mask & two_mask == 1 ? set : clr; break;
92
case 2: output[x] = one_mask ^ two_mask == 1 ? set : clr; break;
93
case 3: output[x] = one_mask ^ two_mask == 0 ? set : clr; break;
94
}
95
}
96
}
97
98
#endif
99
100