yaze 0.2.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
ppu_registers.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EMU_VIDEO_PPU_REGISTERS_H
2#define YAZE_APP_EMU_VIDEO_PPU_REGISTERS_H
3
4#include <cstdint>
5
6namespace yaze {
7namespace emu {
8
9constexpr uint16_t INIDISP = 0x2100;
10
11// OAM Size Register ($2101): Controls the size of the object/sprite, the base
12// address, and the name selection for the OAM (Object Attribute Memory).
13constexpr uint16_t OBJSEL = 0x2101;
14
15// OAM Address Register ($2102-$2103): Sets the address for accessing OAM data.
16constexpr uint16_t OAMADDL = 0x2102;
17constexpr uint16_t OAMADDH = 0x2103;
18
19// OAM Data Register ($2104): Holds the data to be written to the OAM at a
20// specified address.
21constexpr uint16_t OAMDATA = 0x2104;
22
23// OAM Data Read Register ($2138): Allows reading data from the OAM.
24
25// Screen Display Register ($2100): Controls screen on/off and brightness.
26
27// Screen Mode Register ($2105): Defines the screen mode and character size for
28// each background layer.
29constexpr uint16_t BGMODE = 0x2105;
30
31// Screen Pixelation Register ($2106): Sets the pixel size and screen
32// designation for the mosaic display.
33constexpr uint16_t MOSAIC = 0x2106;
34
35// BGx VRAM Location Registers ($2107-$210A)
36// Define the location in VRAM where the background screen data is stored.
37constexpr uint16_t BG1SC = 0x2107;
38constexpr uint16_t BG2SC = 0x2108;
39constexpr uint16_t BG3SC = 0x2109;
40constexpr uint16_t BG4SC = 0x210A;
41
42// BGx & BGy VRAM Location Registers ($210B-$210C):
43// Set the base address for BG character data in VRAM.
44constexpr uint16_t BG12NBA = 0x210B;
45constexpr uint16_t BG34NBA = 0x210C;
46
47// BGx Scroll Registers ($210D-$2114): Control the horizontal and vertical
48// scroll values for each background layer.
49constexpr uint16_t BG1HOFS = 0x210D;
50constexpr uint16_t BG1VOFS = 0x210E;
51constexpr uint16_t BG2HOFS = 0x210F;
52constexpr uint16_t BG2VOFS = 0x2110;
53constexpr uint16_t BG3HOFS = 0x2111;
54constexpr uint16_t BG3VOFS = 0x2112;
55constexpr uint16_t BG4HOFS = 0x2113;
56constexpr uint16_t BG4VOFS = 0x2114;
57
58// Video Port Control Register ($2115): Designates the VRAM address increment
59// value.
60constexpr uint16_t VMAIN = 0x2115;
61
62// Video Port Address Register ($2116-$2117): Sets the initial address for
63// reading from or writing to VRAM.
64constexpr uint16_t VMADDL = 0x2116;
65constexpr uint16_t VMADDH = 0x2117;
66
67constexpr uint16_t VMDATAL = 0x2118;
68constexpr uint16_t VMDATAH = 0x2119;
69constexpr uint16_t M7SEL = 0x211A;
70constexpr uint16_t M7A = 0x211B;
71constexpr uint16_t M7B = 0x211C;
72constexpr uint16_t M7C = 0x211D;
73constexpr uint16_t M7D = 0x211E;
74constexpr uint16_t M7X = 0x211F;
75constexpr uint16_t M7Y = 0x2120;
76constexpr uint16_t CGADD = 0x2121;
77constexpr uint16_t CGDATA = 0x2122;
78constexpr uint16_t W12SEL = 0x2123;
79constexpr uint16_t W34SEL = 0x2124;
80constexpr uint16_t WOBJSEL = 0x2125;
81constexpr uint16_t WH0 = 0x2126;
82constexpr uint16_t WH1 = 0x2127;
83constexpr uint16_t WH2 = 0x2128;
84constexpr uint16_t WH3 = 0x2129;
85constexpr uint16_t WBGLOG = 0x212A;
86constexpr uint16_t WOBJLOG = 0x212B;
87constexpr uint16_t TM = 0x212C;
88constexpr uint16_t TS = 0x212D;
89constexpr uint16_t TMW = 0x212E;
90constexpr uint16_t TSW = 0x212F;
91constexpr uint16_t CGWSEL = 0x2130;
92constexpr uint16_t CGADSUB = 0x2131;
93constexpr uint16_t COLDATA = 0x2132;
94constexpr uint16_t SETINI = 0x2133;
95constexpr uint16_t MPYL = 0x2134;
96constexpr uint16_t MPYM = 0x2135;
97constexpr uint16_t MPYH = 0x2136;
98constexpr uint16_t SLHV = 0x2137;
99constexpr uint16_t OAMDATAREAD = 0x2138;
100constexpr uint16_t VMDATALREAD = 0x2139;
101constexpr uint16_t VMDATAHREAD = 0x213A;
102constexpr uint16_t CGDATAREAD = 0x213B;
103constexpr uint16_t OPHCT = 0x213C;
104constexpr uint16_t OPVCT = 0x213D;
105constexpr uint16_t STAT77 = 0x213E;
106constexpr uint16_t STAT78 = 0x213F;
107
108struct INIDISP {
109 uint8_t brightness : 4;
110 uint8_t forced_blanking : 1;
111 uint8_t unused : 3;
112};
113
114struct OBJSEL {
115 uint8_t name_base_address : 2;
117 uint8_t sprite_size : 2;
118 uint8_t unused : 3;
119};
120
121struct OAMADDL {
122 uint8_t address : 8;
123};
124
125struct OAMADDH {
126 uint8_t high_bit : 1;
127 uint8_t priority_rotation : 1;
128 uint8_t unused : 6;
129};
130
131struct OAMDATA {
132 uint8_t data : 8;
133};
134
135struct BGMODE {
136 uint8_t bg_mode : 3;
137 uint8_t bg3_priority : 1;
138 uint8_t tile_size : 4;
139};
140
141struct Mosaic {
142 uint8_t bg_enable : 4;
143 uint8_t mosaic_size : 4;
144};
145
146struct BGSC {
147 BGSC() = default;
148 ~BGSC() = default;
149 explicit BGSC(uint8_t value)
150 : horizontal_tilemap_count(value & 0x01),
151 vertical_tilemap_count((value >> 1) & 0x01),
152 vram_address((value >> 2) & 0x3F) {}
155 uint8_t vram_address : 6;
156};
157
158struct BGNBA {
159 BGNBA() = default;
160 ~BGNBA() = default;
161 explicit BGNBA(uint8_t value)
162 : chr_base_address_2(value & 0x0F),
163 chr_base_address_1((value >> 4) & 0x0F) {}
166};
167
168struct BGHOFS {
169 uint16_t horizontal_scroll : 10;
170 uint8_t unused : 6;
171};
172
173struct BGVOFS {
174 uint16_t vertical_scroll : 10;
175 uint8_t unused : 6;
176};
177
178struct VMAIN {
179 uint8_t increment_size : 2;
180 uint8_t remapping : 2;
182 uint8_t unused : 3;
183};
184
185struct VMADDL {
186 uint8_t address_low : 8;
187};
188
189struct VMADDH {
190 uint8_t address_high : 8;
191};
192
193struct VMDATA {
194 uint8_t data : 8;
195};
196
197struct M7SEL {
198 uint8_t flip_horizontal : 1;
199 uint8_t flip_vertical : 1;
200 uint8_t fill : 1;
201 uint8_t tilemap_repeat : 1;
202 uint8_t unused : 4;
203};
204
205struct M7A {
206 int16_t matrix_a : 16;
207};
208
209struct M7B {
210 int16_t matrix_b : 16;
211};
212
213struct M7C {
214 int16_t matrix_c : 16;
215};
216
217struct M7D {
218 int16_t matrix_d : 16;
219};
220
221struct M7X {
222 uint16_t center_x : 13;
223 uint8_t unused : 3;
224};
225
226struct M7Y {
227 uint16_t center_y : 13;
228 uint8_t unused : 3;
229};
230
231struct CGADD {
232 uint8_t address : 8;
233};
234
235struct CGDATA {
236 uint16_t data : 15;
237 uint8_t unused : 1;
238};
239
240struct W12SEL {
241 uint8_t enable_bg1_a : 1;
242 uint8_t invert_bg1_a : 1;
243 uint8_t enable_bg1_b : 1;
244 uint8_t invert_bg1_b : 1;
245 uint8_t enable_bg2_c : 1;
246 uint8_t invert_bg2_c : 1;
247 uint8_t enable_bg2_d : 1;
248 uint8_t invert_bg2_d : 1;
249};
250
251struct W34SEL {
252 uint8_t enable_bg3_e : 1;
253 uint8_t invert_bg3_e : 1;
254 uint8_t enable_bg3_f : 1;
255 uint8_t invert_bg3_f : 1;
256 uint8_t enable_bg4_g : 1;
257 uint8_t invert_bg4_g : 1;
258 uint8_t enable_bg4_h : 1;
259 uint8_t invert_bg4_h : 1;
260};
261
262struct WOBJSEL {
263 uint8_t enable_obj_i : 1;
264 uint8_t invert_obj_i : 1;
265 uint8_t enable_obj_j : 1;
266 uint8_t invert_obj_j : 1;
267 uint8_t enable_color_k : 1;
268 uint8_t invert_color_k : 1;
269 uint8_t enable_color_l : 1;
270 uint8_t invert_color_l : 1;
271};
272
273struct WH0 {
274 uint8_t left_position : 8;
275};
276
277struct WH1 {
278 uint8_t right_position : 8;
279};
280
281struct WH2 {
282 uint8_t left_position : 8;
283};
284
285struct WH3 {
286 uint8_t right_position : 8;
287};
288
289struct WBGLOG {
290 uint8_t mask_logic_bg4 : 2;
291 uint8_t mask_logic_bg3 : 2;
292 uint8_t mask_logic_bg2 : 2;
293 uint8_t mask_logic_bg1 : 2;
294};
295
296struct WOBJLOG {
297 uint8_t unused : 4;
298 uint8_t mask_logic_color : 2;
299 uint8_t mask_logic_obj : 2;
300};
301
302struct TM {
303 uint8_t enable_layer : 5;
304 uint8_t unused : 3;
305};
306
307struct TS {
308 uint8_t enable_layer : 5;
309 uint8_t unused : 3;
310};
311
312struct TMW {
313 uint8_t enable_window : 5;
314 uint8_t unused : 3;
315};
316
317struct TSW {
318 uint8_t enable_window : 5;
319 uint8_t unused : 3;
320};
321
322struct CGWSEL {
323 uint8_t direct_color : 1;
324 uint8_t fixed_subscreen : 1;
325 uint8_t sub_color_window : 2;
326 uint8_t main_color_window : 2;
327 uint8_t unused : 2;
328};
329
330struct CGADSUB {
331 uint8_t enable_layer : 5;
332 uint8_t backdrop : 1;
333 uint8_t half : 1;
334 uint8_t add_subtract : 1;
335};
336
337struct COLDATA {
338 uint8_t value : 4;
339 uint8_t channel_select : 3;
340 uint8_t unused : 1;
341};
342
343struct SETINI {
344 uint8_t screen_interlace : 1;
345 uint8_t obj_interlace : 1;
346 uint8_t overscan : 1;
347 uint8_t hi_res : 1;
348 uint8_t extbg : 1;
349 uint8_t external_sync : 1;
350 uint8_t unused : 2;
351};
352
353struct MPYL {
355};
356
357struct MPYM {
359};
360
361struct MPYH {
363};
364
365struct SLHV {
366 uint8_t software_latch : 8;
367};
368
370 uint8_t oam_data_read : 8;
371};
372
375};
376
379};
380
382 uint8_t cgram_data_read : 8;
383};
384
385struct OPHCT {
387 uint8_t unused : 7;
388};
389
390struct OPVCT {
392 uint8_t unused : 7;
393};
394
395struct STAT77 {
396 uint8_t ppu1_version : 4;
397 uint8_t master_slave : 1;
399 uint8_t sprite_overflow : 1;
400 uint8_t unused : 1;
401};
402
403struct STAT78 {
404 uint8_t ppu2_version : 4;
405 uint8_t ntsc_pal : 1;
407 uint8_t interlace_field : 1;
408 uint8_t unused : 1;
409};
410
411} // namespace emu
412} // namespace yaze
413
414#endif // YAZE_APP_EMU_VIDEO_PPU_REGISTERS_H
SNES Emulation and debugging tools.
Definition apu.cc:13
constexpr uint16_t BG2VOFS
constexpr uint16_t VMDATAL
constexpr uint16_t BG1VOFS
constexpr uint16_t BG34NBA
constexpr uint16_t BG4VOFS
constexpr uint16_t MOSAIC
constexpr uint16_t BG3VOFS
constexpr uint16_t BG12NBA
constexpr uint16_t BG1SC
constexpr uint16_t VMDATAH
constexpr uint16_t BG2SC
constexpr uint16_t BG1HOFS
constexpr uint16_t BG3SC
constexpr uint16_t BG3HOFS
constexpr uint16_t BG4SC
constexpr uint16_t BG4HOFS
constexpr uint16_t BG2HOFS
Main namespace for the application.
Definition controller.cc:18
uint16_t horizontal_scroll
uint8_t chr_base_address_1
BGNBA(uint8_t value)
~BGNBA()=default
uint8_t chr_base_address_2
uint8_t horizontal_tilemap_count
~BGSC()=default
uint8_t vertical_tilemap_count
BGSC(uint8_t value)
BGSC()=default
uint8_t multiplication_result_high
uint8_t multiplication_result_low
uint8_t multiplication_result_mid
uint8_t name_secondary_select
uint16_t horizontal_counter_output
uint16_t vertical_counter_output
uint8_t sprite_tile_overflow
uint8_t counter_latch_value
uint8_t enable_window
uint8_t enable_layer
uint8_t enable_window
uint8_t enable_layer
uint8_t address_increment_mode
uint8_t left_position
uint8_t right_position
uint8_t left_position
uint8_t right_position