1 /* $Id: xboxvideo.c 52526 2011-07-03 23:01:39Z rharabien $
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 * Note: much of this code was based on knowledge and/or code developed
20 * by the Xbox Linux group: http://www.xbox-linux.org
25 static PVOID FrameBuffer
;
26 static ULONG ScreenWidth
;
27 static ULONG ScreenHeight
;
28 static ULONG BytesPerPixel
;
32 #define CHAR_HEIGHT 16
34 #define TOP_BOTTOM_LINES 0
38 #define MAKE_COLOR(Red, Green, Blue) (0xff000000 | (((Red) & 0xff) << 16) | (((Green) & 0xff) << 8) | ((Blue) & 0xff))
40 BOOLEAN
I2CTransmitByteGetReturn(UCHAR bPicAddressI2cFormat
, UCHAR bDataToWrite
, ULONG
*Return
);
43 XboxVideoOutputChar(UCHAR Char
, unsigned X
, unsigned Y
, ULONG FgColor
, ULONG BgColor
)
51 FontPtr
= XboxFont8x16
+ Char
* 16;
52 Pixel
= (PULONG
) ((char *) FrameBuffer
+ (Y
* CHAR_HEIGHT
+ TOP_BOTTOM_LINES
) * Delta
53 + X
* CHAR_WIDTH
* BytesPerPixel
);
54 for (Line
= 0; Line
< CHAR_HEIGHT
; Line
++)
57 for (Col
= 0; Col
< CHAR_WIDTH
; Col
++)
59 Pixel
[Col
] = (0 != (FontPtr
[Line
] & Mask
) ? FgColor
: BgColor
);
62 Pixel
= (PULONG
) ((char *) Pixel
+ Delta
);
67 XboxVideoAttrToSingleColor(UCHAR Attr
)
71 Intensity
= (0 == (Attr
& 0x08) ? 127 : 255);
74 (0 == (Attr
& 0x04) ? 0 : (Intensity
<< 16)) |
75 (0 == (Attr
& 0x02) ? 0 : (Intensity
<< 8)) |
76 (0 == (Attr
& 0x01) ? 0 : Intensity
);
80 XboxVideoAttrToColors(UCHAR Attr
, ULONG
*FgColor
, ULONG
*BgColor
)
82 *FgColor
= XboxVideoAttrToSingleColor(Attr
& 0xf);
83 *BgColor
= XboxVideoAttrToSingleColor((Attr
>> 4) & 0xf);
87 XboxVideoClearScreenColor(ULONG Color
, BOOLEAN FullScreen
)
92 for (Line
= 0; Line
< ScreenHeight
- (FullScreen
? 0 : 2 * TOP_BOTTOM_LINES
); Line
++)
94 p
= (PULONG
) ((char *) FrameBuffer
+ (Line
+ (FullScreen
? 0 : TOP_BOTTOM_LINES
)) * Delta
);
95 for (Col
= 0; Col
< ScreenWidth
; Col
++)
103 XboxVideoClearScreen(UCHAR Attr
)
105 ULONG FgColor
, BgColor
;
107 XboxVideoAttrToColors(Attr
, &FgColor
, &BgColor
);
109 XboxVideoClearScreenColor(BgColor
, FALSE
);
113 XboxVideoPutChar(int Ch
, UCHAR Attr
, unsigned X
, unsigned Y
)
115 ULONG FgColor
, BgColor
;
117 XboxVideoAttrToColors(Attr
, &FgColor
, &BgColor
);
119 XboxVideoOutputChar(Ch
, X
, Y
, FgColor
, BgColor
);
127 FrameBuffer
= (PVOID
)((ULONG
) XboxMemReserveMemory(FB_SIZE_MB
) | 0xf0000000);
129 if (I2CTransmitByteGetReturn(0x10, 0x04, &AvMode
))
131 if (1 == AvMode
) /* HDTV */
137 /* FIXME Other possible values of AvMode:
155 Delta
= (ScreenWidth
* BytesPerPixel
+ 3) & ~ 0x3;
157 XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE
);
159 /* Tell the nVidia controller about the framebuffer */
160 *((PULONG
) 0xfd600800) = (ULONG
) FrameBuffer
;
164 XboxVideoSetDisplayMode(char *DisplayMode
, BOOLEAN Init
)
166 /* We only have one mode, semi-text */
167 return VideoTextMode
;
171 XboxVideoGetDisplaySize(PULONG Width
, PULONG Height
, PULONG Depth
)
173 *Width
= ScreenWidth
/ CHAR_WIDTH
;
174 *Height
= (ScreenHeight
- 2 * TOP_BOTTOM_LINES
) / CHAR_HEIGHT
;
179 XboxVideoGetBufferSize(VOID
)
181 return (ScreenHeight
- 2 * TOP_BOTTOM_LINES
) / CHAR_HEIGHT
* (ScreenWidth
/ CHAR_WIDTH
) * 2;
185 XboxVideoSetTextCursorPosition(UCHAR X
, UCHAR Y
)
187 /* We don't have a cursor yet */
191 XboxVideoHideShowTextCursor(BOOLEAN Show
)
193 /* We don't have a cursor yet */
197 XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer
)
199 PUCHAR OffScreenBuffer
= (PUCHAR
) Buffer
;
202 for (Line
= 0; Line
< (ScreenHeight
- 2 * TOP_BOTTOM_LINES
) / CHAR_HEIGHT
; Line
++)
204 for (Col
= 0; Col
< ScreenWidth
/ CHAR_WIDTH
; Col
++)
206 XboxVideoPutChar(OffScreenBuffer
[0], OffScreenBuffer
[1], Col
, Line
);
207 OffScreenBuffer
+= 2;
213 XboxVideoIsPaletteFixed(VOID
)
219 XboxVideoSetPaletteColor(UCHAR Color
, UCHAR Red
, UCHAR Green
, UCHAR Blue
)
225 XboxVideoGetPaletteColor(UCHAR Color
, UCHAR
* Red
, UCHAR
* Green
, UCHAR
* Blue
)
239 /* Call PC version */
244 XboxVideoPrepareForReactOS(IN BOOLEAN Setup
)
246 XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE
);