Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/quicknes/nes_emu/Nes_Ppu_Bg.h
2 views
1
while ( true )
2
{
3
while ( count-- )
4
{
5
int attrib = attr_table [addr >> 2 & 0x07];
6
attrib >>= (addr >> 4 & 4) | (addr & 2);
7
unsigned long offset = (attrib & 3) * attrib_factor + this->palette_offset;
8
9
// draw one tile
10
cache_t const* lines = this->get_bg_tile( nametable [addr] + bg_bank );
11
byte* p = pixels;
12
addr++;
13
pixels += 8; // next tile
14
15
if ( !clipped )
16
{
17
// optimal case: no clipping
18
for ( int n = 4; n--; )
19
{
20
unsigned long line = *lines++;
21
((uint32_t*) p) [0] = (line >> 4 & mask) + offset;
22
((uint32_t*) p) [1] = (line & mask) + offset;
23
p += row_bytes;
24
((uint32_t*) p) [0] = (line >> 6 & mask) + offset;
25
((uint32_t*) p) [1] = (line >> 2 & mask) + offset;
26
p += row_bytes;
27
}
28
}
29
else
30
{
31
lines += fine_y >> 1;
32
33
if ( fine_y & 1 )
34
{
35
unsigned long line = *lines++;
36
((uint32_t*) p) [0] = (line >> 6 & mask) + offset;
37
((uint32_t*) p) [1] = (line >> 2 & mask) + offset;
38
p += row_bytes;
39
}
40
41
for ( int n = height >> 1; n--; )
42
{
43
unsigned long line = *lines++;
44
((uint32_t*) p) [0] = (line >> 4 & mask) + offset;
45
((uint32_t*) p) [1] = (line & mask) + offset;
46
p += row_bytes;
47
((uint32_t*) p) [0] = (line >> 6 & mask) + offset;
48
((uint32_t*) p) [1] = (line >> 2 & mask) + offset;
49
p += row_bytes;
50
}
51
52
if ( height & 1 )
53
{
54
unsigned long line = *lines;
55
((uint32_t*) p) [0] = (line >> 4 & mask) + offset;
56
((uint32_t*) p) [1] = (line & mask) + offset;
57
}
58
}
59
}
60
61
count = count2;
62
count2 = 0;
63
addr -= 32;
64
attr_table = attr_table - nametable + nametable2;
65
nametable = nametable2;
66
if ( !count )
67
break;
68
}
69
70