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
);
27 static PVOID FrameBuffer
;
28 static ULONG ScreenWidth
;
29 static ULONG ScreenHeight
;
30 static ULONG BytesPerPixel
;
34 #define CHAR_HEIGHT 16
36 #define TOP_BOTTOM_LINES 0
40 #define MAKE_COLOR(Red, Green, Blue) (0xff000000 | (((Red) & 0xff) << 16) | (((Green) & 0xff) << 8) | ((Blue) & 0xff))
42 BOOLEAN
I2CTransmitByteGetReturn(UCHAR bPicAddressI2cFormat
, UCHAR bDataToWrite
, ULONG
*Return
);
45 XboxVideoOutputChar(UCHAR Char
, unsigned X
, unsigned Y
, ULONG FgColor
, ULONG BgColor
)
53 FontPtr
= XboxFont8x16
+ Char
* 16;
54 Pixel
= (PULONG
) ((char *) FrameBuffer
+ (Y
* CHAR_HEIGHT
+ TOP_BOTTOM_LINES
) * Delta
55 + X
* CHAR_WIDTH
* BytesPerPixel
);
56 for (Line
= 0; Line
< CHAR_HEIGHT
; Line
++)
59 for (Col
= 0; Col
< CHAR_WIDTH
; Col
++)
61 Pixel
[Col
] = (0 != (FontPtr
[Line
] & Mask
) ? FgColor
: BgColor
);
64 Pixel
= (PULONG
) ((char *) Pixel
+ Delta
);
69 XboxVideoAttrToSingleColor(UCHAR Attr
)
73 Intensity
= (0 == (Attr
& 0x08) ? 127 : 255);
76 (0 == (Attr
& 0x04) ? 0 : (Intensity
<< 16)) |
77 (0 == (Attr
& 0x02) ? 0 : (Intensity
<< 8)) |
78 (0 == (Attr
& 0x01) ? 0 : Intensity
);
82 XboxVideoAttrToColors(UCHAR Attr
, ULONG
*FgColor
, ULONG
*BgColor
)
84 *FgColor
= XboxVideoAttrToSingleColor(Attr
& 0xf);
85 *BgColor
= XboxVideoAttrToSingleColor((Attr
>> 4) & 0xf);
89 XboxVideoClearScreenColor(ULONG Color
, BOOLEAN FullScreen
)
94 for (Line
= 0; Line
< ScreenHeight
- (FullScreen
? 0 : 2 * TOP_BOTTOM_LINES
); Line
++)
96 p
= (PULONG
) ((char *) FrameBuffer
+ (Line
+ (FullScreen
? 0 : TOP_BOTTOM_LINES
)) * Delta
);
97 for (Col
= 0; Col
< ScreenWidth
; Col
++)
105 XboxVideoClearScreen(UCHAR Attr
)
107 ULONG FgColor
, BgColor
;
109 XboxVideoAttrToColors(Attr
, &FgColor
, &BgColor
);
111 XboxVideoClearScreenColor(BgColor
, FALSE
);
115 XboxVideoPutChar(int Ch
, UCHAR Attr
, unsigned X
, unsigned Y
)
117 ULONG FgColor
, BgColor
;
119 XboxVideoAttrToColors(Attr
, &FgColor
, &BgColor
);
121 XboxVideoOutputChar(Ch
, X
, Y
, FgColor
, BgColor
);
129 FrameBuffer
= (PVOID
)((ULONG
) XboxMemReserveMemory(FB_SIZE_MB
) | 0xf0000000);
131 if (I2CTransmitByteGetReturn(0x10, 0x04, &AvMode
))
133 if (1 == AvMode
) /* HDTV */
139 /* FIXME Other possible values of AvMode:
157 Delta
= (ScreenWidth
* BytesPerPixel
+ 3) & ~ 0x3;
159 XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE
);
161 /* Tell the nVidia controller about the framebuffer */
162 *((PULONG
) 0xfd600800) = (ULONG
) FrameBuffer
;
166 XboxVideoSetDisplayMode(char *DisplayMode
, BOOLEAN Init
)
168 /* We only have one mode, semi-text */
169 return VideoTextMode
;
173 XboxVideoGetDisplaySize(PULONG Width
, PULONG Height
, PULONG Depth
)
175 *Width
= ScreenWidth
/ CHAR_WIDTH
;
176 *Height
= (ScreenHeight
- 2 * TOP_BOTTOM_LINES
) / CHAR_HEIGHT
;
181 XboxVideoGetBufferSize(VOID
)
183 return (ScreenHeight
- 2 * TOP_BOTTOM_LINES
) / CHAR_HEIGHT
* (ScreenWidth
/ CHAR_WIDTH
) * 2;
187 XboxVideoGetFontsFromFirmware(PULONG RomFontPointers
)
189 TRACE("XboxVideoGetFontsFromFirmware(): UNIMPLEMENTED\n");
193 XboxVideoSetTextCursorPosition(UCHAR X
, UCHAR Y
)
195 /* We don't have a cursor yet */
199 XboxVideoHideShowTextCursor(BOOLEAN Show
)
201 /* We don't have a cursor yet */
205 XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer
)
207 PUCHAR OffScreenBuffer
= (PUCHAR
) Buffer
;
210 for (Line
= 0; Line
< (ScreenHeight
- 2 * TOP_BOTTOM_LINES
) / CHAR_HEIGHT
; Line
++)
212 for (Col
= 0; Col
< ScreenWidth
/ CHAR_WIDTH
; Col
++)
214 XboxVideoPutChar(OffScreenBuffer
[0], OffScreenBuffer
[1], Col
, Line
);
215 OffScreenBuffer
+= 2;
221 XboxVideoIsPaletteFixed(VOID
)
227 XboxVideoSetPaletteColor(UCHAR Color
, UCHAR Red
, UCHAR Green
, UCHAR Blue
)
233 XboxVideoGetPaletteColor(UCHAR Color
, UCHAR
* Red
, UCHAR
* Green
, UCHAR
* Blue
)
247 /* Call PC version */
252 XboxVideoPrepareForReactOS(VOID
)
254 XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE
);
255 XboxVideoHideShowTextCursor(FALSE
);