📄 nds specifications.htm
字号:
<TR>
<TD><PRE> Bit Expl.
0-7 Fractional portion (8 bits)
8-26 Integer portion (19 bits)
27 Sign (1 bit)
28-31 Not used
</PRE></TD></TR></TBODY></TABLE>Because values are shifted left by eight,
fractional portions may be specified in steps of 1/256 pixels (this would be
relevant only if the screen is actually rotated or scaled). Normal signed 32bit
values may be written to above registers (the most significant bits will be
ignored and the value will be cut-down to 28bits, but this is no actual problem
because signed values have set all MSBs to the same value).<BR><BR><B>Internal
Reference Point Registers</B><BR>The above reference points are automatically
copied to internal registers during each vblank, specifying the origin for the
first scanline. The internal registers are then incremented by dmx and dmy after
each scanline.<BR>Caution: Writing to a reference point register by software
outside of the Vblank period does immediately copy the new value to the
corresponding internal register, that means: in the current frame, the new value
specifies the origin of the <current> scanline (instead of the topmost
scanline).<BR><BR><B>4000020h - BG2PA - BG2 Rotation/Scaling Parameter A (alias
dx) (W)</B><BR><B>4000022h - BG2PB - BG2 Rotation/Scaling Parameter B (alias
dmx) (W)</B><BR><B>4000024h - BG2PC - BG2 Rotation/Scaling Parameter C (alias
dy) (W)</B><BR><B>4000026h - BG2PD - BG2 Rotation/Scaling Parameter D (alias
dmy) (W)</B><BR>
<TABLE>
<TBODY>
<TR>
<TD><PRE> Bit Expl.
0-7 Fractional portion (8 bits)
8-14 Integer portion (7 bits)
15 Sign (1 bit)
</PRE></TD></TR></TBODY></TABLE>See below for details.<BR><BR><B>400003Xh -
BG3X_L/H, BG3Y_L/H, BG3PA-D - BG3 Rotation/Scaling Parameters</B><BR>Same as
above BG2 Reference Point, and Rotation/Scaling Parameters, for BG3
respectively.<BR><BR><B>dx (PA) and dy (PC)</B><BR>When transforming a
horizontal line, dx and dy specify the resulting gradient and magnification for
that line. For example:<BR>Horizontal line, length=100, dx=1, and dy=1. The
resulting line would be drawn at 45 degrees, f(y)=1/1*x. Note that this would
involve that line is magnified, the new length is SQR(100^2+100^2)=141.42. Yup,
exactly - that's the old a^2 + b^2 = c^2 formula.<BR><BR><B>dmx (PB) and dmy
(PD)</B><BR>These values define the resulting gradient and magnification for
transformation of vertical lines. However, when rotating a square area (which is
surrounded by horizontal and vertical lines), then the desired result should be
usually a rotated <square> area (ie. not a parallelogram, for
example).<BR>Thus, dmx and dmy must be defined in direct relationship to dx and
dy, taking the example above, we'd have to set dmx=-1, and dmy=1,
f(x)=-1/1*y.<BR><BR><B>Area Overflow</B><BR>In result of rotation/scaling it may
often happen that areas outside of the actual BG area become moved into the LCD
viewport. Depending of the Area Overflow bit (BG2CNT and BG3CNT, Bit 13) these
areas may be either displayed (by wrapping the BG area), or may be displayed
transparent.<BR>This works only in BG modes 1 and 2. The area overflow is
ignored in Bitmap modes (BG modes 3-5), the outside of the Bitmaps is always
transparent.<BR><BR>--- more details and confusing or helpful formulas
---<BR><BR><B>The following parameters are required for Rotation/Scaling</B><BR>
<TABLE>
<TBODY>
<TR>
<TD><PRE> Rotation Center X and Y Coordinates (x0,y0)
Rotation Angle (alpha)
Magnification X and Y Values (xMag,yMag)
</PRE></TD></TR></TBODY></TABLE>The display is rotated by 'alpha' degrees around
the center.<BR>The displayed picture is magnified by 'xMag' along x-Axis (Y=y0)
and 'yMag' along y-Axis (X=x0).<BR><BR><B>Calculating Rotation/Scaling
Parameters A-D</B><BR>
<TABLE>
<TBODY>
<TR>
<TD><PRE> A = Cos (alpha) / xMag ;distance moved in direction x, same line
B = Sin (alpha) / xMag ;distance moved in direction x, next line
C = Sin (alpha) / yMag ;distance moved in direction y, same line
D = Cos (alpha) / yMag ;distance moved in direction y, next line
</PRE></TD></TR></TBODY></TABLE><BR><B>Calculating the position of a
rotated/scaled dot</B><BR>Using the following expressions,<BR>
<TABLE>
<TBODY>
<TR>
<TD><PRE> x0,y0 Rotation Center
x1,y1 Old Position of a pixel (before rotation/scaling)
x2,y2 New position of above pixel (after rotation scaling)
A,B,C,D BG2PA-BG2PD Parameters (as calculated above)
</PRE></TD></TR></TBODY></TABLE>the following formula can be used to calculate
x2,y2:<BR>
<TABLE>
<TBODY>
<TR>
<TD><PRE> x2 = A(x1-x0) + B(y1-y0) + x0
y2 = C(x1-x0) + D(y1-y0) + y0
</PRE></TD></TR></TBODY></TABLE><BR><BR>
<TABLE width="100%">
<TBODY>
<TR bgColor=#cccccc>
<TD><A name=lcdiowindowfeature></A><FONT size=+2> LCD I/O Window
Feature</FONT></TD></TR></TBODY></TABLE><BR>The Window Feature may be used to
split the screen into four regions. The BG0-3,OBJ layers and Color Special
Effects can be separately enabled or disabled in each of these
regions.<BR><BR><B>The DISPCNT Register</B><BR>DISPCNT Bits 13-15 are used to
enable Window 0, Window 1, and/or OBJ Window regions, if any of these regions is
enabled then the "Outside of Windows" region is automatically enabled,
too.<BR>DISPCNT Bits 8-12 are kept used as master enable bits for the BG0-3,OBJ
layers, a layer is displayed only if both DISPCNT and WININ/OUT enable bits are
set.<BR><BR><B>4000040h - WIN0H - Window 0 Horizontal Dimensions
(W)</B><BR><B>4000042h - WIN1H - Window 1 Horizontal Dimensions (W)</B><BR>
<TABLE>
<TBODY>
<TR>
<TD><PRE> Bit Expl.
0-7 X2, Rightmost coordinate of window, plus 1
8-15 X1, Leftmost coordinate of window
</PRE></TD></TR></TBODY></TABLE>Garbage values of X2>240 or X1>X2 are
interpreted as X2=240.<BR><BR><B>4000044h - WIN0V - Window 0 Vertical Dimensions
(W)</B><BR><B>4000046h - WIN1V - Window 1 Vertical Dimensions (W)</B><BR>
<TABLE>
<TBODY>
<TR>
<TD><PRE> Bit Expl.
0-7 Y2, Bottom-most coordinate of window, plus 1
8-15 Y1, Top-most coordinate of window
</PRE></TD></TR></TBODY></TABLE>Garbage values of Y2>160 or Y1>Y2 are
interpreted as Y2=160.<BR><BR><B>4000048h - WININ - Control of Inside of
Window(s) (R/W)</B><BR>
<TABLE>
<TBODY>
<TR>
<TD><PRE> Bit Expl.
0-3 Window 0 BG0-BG3 Enable Bits (0=No Display, 1=Display)
4 Window 0 OBJ Enable Bit (0=No Display, 1=Display)
5 Window 0 Color Special Effect (0=Disable, 1=Enable)
6-7 Not used
8-11 Window 1 BG0-BG3 Enable Bits (0=No Display, 1=Display)
12 Window 1 OBJ Enable Bit (0=No Display, 1=Display)
13 Window 1 Color Special Effect (0=Disable, 1=Enable)
14-15 Not used
</PRE></TD></TR></TBODY></TABLE><BR><B>400004Ah - WINOUT - Control of Outside of
Windows & Inside of OBJ Window (R/W)</B><BR>
<TABLE>
<TBODY>
<TR>
<TD><PRE> Bit Expl.
0-3 Outside BG0-BG3 Enable Bits (0=No Display, 1=Display)
4 Outside OBJ Enable Bit (0=No Display, 1=Display)
5 Outside Color Special Effect (0=Disable, 1=Enable)
6-7 Not used
8-11 OBJ Window BG0-BG3 Enable Bits (0=No Display, 1=Display)
12 OBJ Window OBJ Enable Bit (0=No Display, 1=Display)
13 OBJ Window Color Special Effect (0=Disable, 1=Enable)
14-15 Not used
</PRE></TD></TR></TBODY></TABLE><BR><B>The OBJ Window</B><BR>The dimension of
the OBJ Window is specified by OBJs which are having the "OBJ Mode" attribute
being set to "OBJ Window". Any non-transparent dots of any such OBJs are marked
as OBJ Window area. The OBJ itself is not displayed.<BR>The color, palette, and
display priority of these OBJs are ignored. Both DISPCNT Bits 12 and 15 must be
set when defining OBJ Window region(s).<BR><BR><B>Window Priority</B><BR>In case
that more than one window is enabled, and that these windows do overlap, Window
0 is having highest priority, Window 1 medium, and Obj Window lowest priority.
Outside of Window is having zero priority, it is used for all dots which are not
inside of any window region.<BR><BR><BR>
<TABLE width="100%">
<TBODY>
<TR bgColor=#cccccc>
<TD><A name=lcdiomosaicfunction></A><FONT size=+2> LCD I/O Mosaic
Function</FONT></TD></TR></TBODY></TABLE><BR><B>400004Ch - MOSAIC - Mosaic Size
(W)</B><BR>The Mosaic function can be separately enabled/disabled for BG0-BG3 by
BG0CNT-BG3CNT Registers, as well as for each OBJ0-127 by OBJ attributes in OAM
memory. Also, setting all of the bits below to zero effectively disables the
mosaic function.<BR>
<TABLE>
<TBODY>
<TR>
<TD><PRE> Bit Expl.
0-3 BG Mosaic H-Size (minus 1)
4-7 BG Mosaic V-Size (minus 1)
8-11 OBJ Mosaic H-Size (minus 1)
12-15 OBJ Mosaic V-Size (minus 1)
</PRE></TD></TR></TBODY></TABLE>Example: When setting H-Size to 5, then pixels
0-5 of each display row are colorized as pixel 0, pixels 6-11 as pixel 6, pixels
12-17 as pixel 12, and so on.<BR><BR>Normally, a 'mosaic-pixel' is colorized by
the color of the upperleft covered pixel. In many cases it might be more
desireful to use the color of the pixel in the center of the covered area - this
effect may be gained by scrolling the background (or by adjusting the OBJ
position, as far as upper/left rows/columns of OBJ are transparent).<BR><BR><BR>
<TABLE width="100%">
<TBODY>
<TR bgColor=#cccccc>
<TD><A name=lcdiocolorspecialeffects></A><FONT size=+2> LCD I/O Color
Special Effects</FONT></TD></TR></TBODY></TABLE><BR>Two types of Special Effects
are supported: Alpha Blending (Semi-Transparency) allows to combine colors of
two selected surfaces. Brightness Increase/Decrease adjust the brightness of the
selected surface.<BR><BR><B>4000050h - BLDCNT - Color Special Effects Selection
(R/W)</B><BR>
<TABLE>
<TBODY>
<TR>
<TD><PRE> Bit Expl.
0 BG0 1st Target Pixel (Background 0)
1 BG1 1st Target Pixel (Background 1)
2 BG2 1st Target Pixel (Background 2)
3 BG3 1st Target Pixel (Background 3)
4 OBJ 1st Target Pixel (Top-most OBJ pixel)
5 BD 1st Target Pixel (Backdrop)
6-7 Color Special Effect (0-3, see below)
0 = None (Special effects disabled)
1 = Alpha Blending (1st+2nd Target mixed)
2 = Brightness Increase (1st Target becomes whiter)
3 = Brightness Decrease (1st Target becomes blacker)
8 BG0 2nd Target Pixel (Background 0)
9 BG1 2nd Target Pixel (Background 1)
10 BG2 2nd Target Pixel (Background 2)
11 BG3 2nd Target Pixel (Background 3)
12 OBJ 2nd Target Pixel (Top-most OBJ pixel)
13 BD 2nd Target Pixel (Backdrop)
14-15 Not used
</PRE></TD></TR></TBODY></TABLE>Selects the 1st Target layer(s) for special
effects. For Alpha Blending/Semi-Transparency, it does also select the 2nd
Target layer(s), which should have next lower display priority as the 1st
Target.<BR>However, any combinations are possible, including that all layers may
be selected as both 1st+2nd target, in that case the top-most pixel will be used
as 1st target, and the next lower pixel as 2nd target.<BR><BR><B>4000052h -
BLDALPHA - Alpha Blending Coefficients (W)</B><BR>Used for Color Special Effects
Mode 1, and for Semi-Transparent OBJs.<BR>
<TABLE>
<TBODY>
<TR>
<TD><PRE> Bit Expl.
0-4 EVA Coefficient (1st Target) (0..16 = 0/16..16/16, 17..31=16/16)
5-7 Not used
8-12 EVB Coefficient (2nd Target) (0..16 = 0/16..16/16, 17..31=16/16)
13-15 Not used
</PRE></TD></TR></TBODY></TABLE>For this effect, the top-most non-transparent
pixel must be selected as 1st Target, and the next-lower non-transparent pixel
must be selected as 2nd Target, if so - and only if so, then color intensities
of 1st and 2nd Target are mixed together by using the parameters in BLDALPHA
register, for each pixel each R, G, B intensities are calculated separately:<BR>
<TABLE>
<TBODY>
<TR>
<TD><PRE> I = MIN ( 31, I1st*EVA + I2nd*EVB )
</PRE></TD></TR></TBODY></TABLE>Otherwise - for example, if only one target
exists, or if a non-transparent non-2nd-target pixel is moved between the two
targets, or if 2nd target has higher display priority than 1st target - then
only the top-most pixel is displayed (at normal intensity, regardless of
BLDALPHA).<BR><BR><B>4000054h - BLDY - Brightness (Fade-In/Out) Coefficient
(W)</B><BR>Used for Color Special Effects Modes 2 and 3.<BR>
<TABLE>
<TBODY>
<TR>
<TD><PRE> Bit Expl.
0-4 EVY Coefficient (Brightness) (0..16 = 0/16..16/16, 17..31=16/16)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -