4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * Note: much of this code was based on knowledge and/or code developed
19 * by the Xbox Linux group: http://www.xbox-linux.org
25 DBG_DEFAULT_CHANNEL(UI
);
28 ULONG FrameBufferSize
;
29 static ULONG ScreenWidth
;
30 static ULONG ScreenHeight
;
31 static ULONG BytesPerPixel
;
35 #define CHAR_HEIGHT 16
37 #define TOP_BOTTOM_LINES 0
41 #define MAKE_COLOR(Red, Green, Blue) (0xff000000 | (((Red) & 0xff) << 16) | (((Green) & 0xff) << 8) | ((Blue) & 0xff))
43 BOOLEAN
I2CTransmitByteGetReturn(UCHAR bPicAddressI2cFormat
, UCHAR bDataToWrite
, ULONG
*Return
);
46 XboxVideoOutputChar(UCHAR Char
, unsigned X
, unsigned Y
, ULONG FgColor
, ULONG BgColor
)
54 FontPtr
= XboxFont8x16
+ Char
* 16;
55 Pixel
= (PULONG
) ((char *) FrameBuffer
+ (Y
* CHAR_HEIGHT
+ TOP_BOTTOM_LINES
) * Delta
56 + X
* CHAR_WIDTH
* BytesPerPixel
);
57 for (Line
= 0; Line
< CHAR_HEIGHT
; Line
++)
60 for (Col
= 0; Col
< CHAR_WIDTH
; Col
++)
62 Pixel
[Col
] = (0 != (FontPtr
[Line
] & Mask
) ? FgColor
: BgColor
);
65 Pixel
= (PULONG
) ((char *) Pixel
+ Delta
);
70 XboxVideoAttrToSingleColor(UCHAR Attr
)
74 Intensity
= (0 == (Attr
& 0x08) ? 127 : 255);
77 (0 == (Attr
& 0x04) ? 0 : (Intensity
<< 16)) |
78 (0 == (Attr
& 0x02) ? 0 : (Intensity
<< 8)) |
79 (0 == (Attr
& 0x01) ? 0 : Intensity
);
83 XboxVideoAttrToColors(UCHAR Attr
, ULONG
*FgColor
, ULONG
*BgColor
)
85 *FgColor
= XboxVideoAttrToSingleColor(Attr
& 0xf);
86 *BgColor
= XboxVideoAttrToSingleColor((Attr
>> 4) & 0xf);
90 XboxVideoClearScreenColor(ULONG Color
, BOOLEAN FullScreen
)
95 for (Line
= 0; Line
< ScreenHeight
- (FullScreen
? 0 : 2 * TOP_BOTTOM_LINES
); Line
++)
97 p
= (PULONG
) ((char *) FrameBuffer
+ (Line
+ (FullScreen
? 0 : TOP_BOTTOM_LINES
)) * Delta
);
98 for (Col
= 0; Col
< ScreenWidth
; Col
++)
106 XboxVideoClearScreen(UCHAR Attr
)
108 ULONG FgColor
, BgColor
;
110 XboxVideoAttrToColors(Attr
, &FgColor
, &BgColor
);
112 XboxVideoClearScreenColor(BgColor
, FALSE
);
116 XboxVideoPutChar(int Ch
, UCHAR Attr
, unsigned X
, unsigned Y
)
118 ULONG FgColor
, BgColor
;
120 XboxVideoAttrToColors(Attr
, &FgColor
, &BgColor
);
122 XboxVideoOutputChar(Ch
, X
, Y
, FgColor
, BgColor
);
130 /* Reuse framebuffer that was set up by firmware */
131 FrameBuffer
= (PVOID
)*((PULONG
) 0xfd600800);
132 /* Verify that framebuffer address is page-aligned */
133 ASSERT((ULONG_PTR
)FrameBuffer
% PAGE_SIZE
== 0);
135 /* FIXME: obtain fb size from firmware somehow (Cromwell reserves high 4 MB of RAM) */
136 FrameBufferSize
= 4 * 1024 * 1024;
138 /* FIXME: don't use SMBus, obtain current video resolution directly from NV2A */
139 if (I2CTransmitByteGetReturn(0x10, 0x04, &AvMode
))
141 if (1 == AvMode
) /* HDTV */
147 /* FIXME Other possible values of AvMode:
165 Delta
= (ScreenWidth
* BytesPerPixel
+ 3) & ~ 0x3;
167 XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE
);
171 XboxVideoSetDisplayMode(char *DisplayMode
, BOOLEAN Init
)
173 /* We only have one mode, semi-text */
174 return VideoTextMode
;
178 XboxVideoGetDisplaySize(PULONG Width
, PULONG Height
, PULONG Depth
)
180 *Width
= ScreenWidth
/ CHAR_WIDTH
;
181 *Height
= (ScreenHeight
- 2 * TOP_BOTTOM_LINES
) / CHAR_HEIGHT
;
186 XboxVideoGetBufferSize(VOID
)
188 return (ScreenHeight
- 2 * TOP_BOTTOM_LINES
) / CHAR_HEIGHT
* (ScreenWidth
/ CHAR_WIDTH
) * 2;
192 XboxVideoGetFontsFromFirmware(PULONG RomFontPointers
)
194 TRACE("XboxVideoGetFontsFromFirmware(): UNIMPLEMENTED\n");
198 XboxVideoSetTextCursorPosition(UCHAR X
, UCHAR Y
)
200 /* We don't have a cursor yet */
204 XboxVideoHideShowTextCursor(BOOLEAN Show
)
206 /* We don't have a cursor yet */
210 XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer
)
212 PUCHAR OffScreenBuffer
= (PUCHAR
) Buffer
;
215 for (Line
= 0; Line
< (ScreenHeight
- 2 * TOP_BOTTOM_LINES
) / CHAR_HEIGHT
; Line
++)
217 for (Col
= 0; Col
< ScreenWidth
/ CHAR_WIDTH
; Col
++)
219 XboxVideoPutChar(OffScreenBuffer
[0], OffScreenBuffer
[1], Col
, Line
);
220 OffScreenBuffer
+= 2;
226 XboxVideoIsPaletteFixed(VOID
)
232 XboxVideoSetPaletteColor(UCHAR Color
, UCHAR Red
, UCHAR Green
, UCHAR Blue
)
238 XboxVideoGetPaletteColor(UCHAR Color
, UCHAR
* Red
, UCHAR
* Green
, UCHAR
* Blue
)
252 /* Call PC version */
257 XboxVideoPrepareForReactOS(VOID
)
259 XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE
);
260 XboxVideoHideShowTextCursor(FALSE
);