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