Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/quicknes/nes_emu/Nes_Ppu_Rendering.h
2 views
1
2
// NES PPU emulator graphics rendering
3
4
// Nes_Emu 0.7.0
5
6
#ifndef NES_PPU_RENDERING_H
7
#define NES_PPU_RENDERING_H
8
9
#include "Nes_Ppu_Impl.h"
10
11
class Nes_Ppu_Rendering : public Nes_Ppu_Impl {
12
typedef Nes_Ppu_Impl base;
13
public:
14
Nes_Ppu_Rendering();
15
16
int sprite_limit;
17
18
byte* host_pixels;
19
long host_row_bytes;
20
21
protected:
22
23
long sprite_hit_found; // -1: sprite 0 didn't hit, 0: no hit so far, > 0: y * 341 + x
24
void draw_background( int start, int count );
25
void draw_sprites( int start, int count );
26
27
private:
28
29
void draw_scanlines( int start, int count, byte* pixels, long pitch, int mode );
30
void draw_background_( int count );
31
32
// destination for draw functions; avoids extra parameters
33
byte* scanline_pixels;
34
long scanline_row_bytes;
35
36
// fill/copy
37
void fill_background( int count );
38
void clip_left( int count );
39
void save_left( int count );
40
void restore_left( int count );
41
42
// sprites
43
enum { max_sprites = 64 };
44
byte sprite_scanlines [image_height]; // number of sprites on each scanline
45
void draw_sprites_( int start, int count );
46
bool sprite_hit_possible( int scanline ) const;
47
void check_sprite_hit( int begin, int end );
48
};
49
50
inline Nes_Ppu_Rendering::Nes_Ppu_Rendering()
51
{
52
sprite_limit = 8;
53
host_pixels = NULL;
54
}
55
56
inline void Nes_Ppu_Rendering::draw_sprites( int start, int count )
57
{
58
assert( host_pixels );
59
draw_scanlines( start, count, host_pixels + host_row_bytes * start, host_row_bytes, 2 );
60
}
61
62
#endif
63
64
65