-
Notifications
You must be signed in to change notification settings - Fork 0
/
PPU.pxd
135 lines (102 loc) · 3.02 KB
/
PPU.pxd
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
cdef extern from "stdint.h":
ctypedef unsigned char uint8_t
ctypedef unsigned short uint16_t
ctypedef short int16_t
from .Cartridge cimport Cartridge
cdef class Ctrl:
cdef uint8_t nametable_x
cdef uint8_t nametable_y
cdef uint8_t increment_mode
cdef uint8_t pattern_sprite
cdef uint8_t pattern_background
cdef uint8_t sprite_size
cdef uint8_t slave_mode
cdef uint8_t enable_nmi
cdef uint16_t _reg
cdef void update_reg(self)
cdef class Mask:
cdef uint8_t grayscale
cdef uint8_t render_background_left
cdef uint8_t render_sprites_left
cdef uint8_t render_background
cdef uint8_t render_sprites
cdef uint8_t enhance_red
cdef uint8_t enhance_green
cdef uint8_t enhance_blue
cdef uint16_t _reg
cdef void update_reg(self)
cdef class Status:
cdef uint8_t unused
cdef uint8_t sprite_overflow
cdef uint8_t sprite_zero_hit
cdef uint8_t vertical_blank
cdef uint16_t _reg
cdef void update_reg(self)
cdef class Loopy:
cdef uint8_t coarse_x
cdef uint8_t coarse_y
cdef uint8_t nametable_x
cdef uint8_t nametable_y
cdef uint8_t fine_y
cdef uint8_t unused
cdef uint16_t _reg
cdef void update_reg(self)
cdef class PPU:
"""
The PPU has its own internal bus with three memories attached.
The pattern (char) memory which is a part of the cartridge located at
0x0000 to 0x1xFFFF.
Name table memory which stores layout is located in range 0x2000 to 0x3EFF.
Palette memory which stores color information located in range 0x3F00 to
0x3FFF.
"""
cdef Cartridge cartridge
cdef readonly uint8_t[:,:,:] screen
cdef int cycle
cdef int scan_line
cdef Ctrl ctrl
cdef Mask mask
cdef Status status
cdef Loopy loopy_t
cdef Loopy loopy_v
cdef uint8_t fine_x
cdef uint8_t data
cdef uint8_t _address_latch
cdef uint8_t _ppu_data_buffer
cdef public uint8_t nmi
cdef object nametable
cdef uint8_t[:,:] nametable_a
cdef uint8_t[:,:] nametable_b
cdef uint8_t[:] palettes
cdef uint8_t[:,:] colours
cdef uint8_t _v_mirroring
cdef uint8_t _bg_next_tile_id
cdef uint8_t _bg_next_tile_attr
cdef uint8_t _bg_next_tile_lsb
cdef uint8_t _bg_next_tile_msb
cdef uint16_t _bg_shifter_pattern_lo
cdef uint16_t _bg_shifter_pattern_hi
cdef uint16_t _bg_shifter_attr_lo
cdef uint16_t _bg_shifter_attr_hi
cdef public uint8_t end_of_frame
cdef public uint8_t[:] OAM
cdef uint8_t OAM_addr
cdef uint8_t[:] OAM_scanline
cdef uint8_t sprite_count
cdef uint8_t _n_OAM_entry
cdef int16_t _diff
cdef uint8_t[:] sprite_shifter_pattern_lo
cdef uint8_t[:] sprite_shifter_pattern_hi
cdef uint8_t sprite_shifter_pattern_lo_bits
cdef uint8_t sprite_shifter_pattern_hi_bits
cdef uint16_t sprite_shifter_pattern_lo_addr
cdef uint16_t sprite_shifter_pattern_hi_addr
cdef uint8_t sprite_zero_hit_possible
cdef uint8_t rendering_sprite_zero
cdef void _load_bg_shifters(self)
cdef inline uint8_t _flip_byte(self, uint8_t b)
cdef void clock(self)
cdef void ppu_write(self, uint16_t addr, uint8_t data)
cdef uint8_t ppu_read(self, uint16_t addr)
cdef void cpu_write(self, uint16_t addr, uint8_t data)
cdef uint8_t cpu_read(self, uint16_t addr)