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
24 static PVOID FrameBuffer
;
25 static ULONG ScreenWidth
;
26 static ULONG ScreenHeight
;
27 static ULONG BytesPerPixel
;
31 #define CHAR_HEIGHT 16
33 #define TOP_BOTTOM_LINES 0
37 #define MAKE_COLOR(Red, Green, Blue) (0xff000000 | (((Red) & 0xff) << 16) | (((Green) & 0xff) << 8) | ((Blue) & 0xff))
39 BOOLEAN
I2CTransmitByteGetReturn(UCHAR bPicAddressI2cFormat
, UCHAR bDataToWrite
, ULONG
*Return
);
42 XboxVideoOutputChar(UCHAR Char
, unsigned X
, unsigned Y
, ULONG FgColor
, ULONG BgColor
)
50 FontPtr
= XboxFont8x16
+ Char
* 16;
51 Pixel
= (PULONG
) ((char *) FrameBuffer
+ (Y
* CHAR_HEIGHT
+ TOP_BOTTOM_LINES
) * Delta
52 + X
* CHAR_WIDTH
* BytesPerPixel
);
53 for (Line
= 0; Line
< CHAR_HEIGHT
; Line
++)
56 for (Col
= 0; Col
< CHAR_WIDTH
; Col
++)
58 Pixel
[Col
] = (0 != (FontPtr
[Line
] & Mask
) ? FgColor
: BgColor
);
61 Pixel
= (PULONG
) ((char *) Pixel
+ Delta
);
66 XboxVideoAttrToSingleColor(UCHAR Attr
)
70 Intensity
= (0 == (Attr
& 0x08) ? 127 : 255);
73 (0 == (Attr
& 0x04) ? 0 : (Intensity
<< 16)) |
74 (0 == (Attr
& 0x02) ? 0 : (Intensity
<< 8)) |
75 (0 == (Attr
& 0x01) ? 0 : Intensity
);
79 XboxVideoAttrToColors(UCHAR Attr
, ULONG
*FgColor
, ULONG
*BgColor
)
81 *FgColor
= XboxVideoAttrToSingleColor(Attr
& 0xf);
82 *BgColor
= XboxVideoAttrToSingleColor((Attr
>> 4) & 0xf);
86 XboxVideoClearScreenColor(ULONG Color
, BOOLEAN FullScreen
)
91 for (Line
= 0; Line
< ScreenHeight
- (FullScreen
? 0 : 2 * TOP_BOTTOM_LINES
); Line
++)
93 p
= (PULONG
) ((char *) FrameBuffer
+ (Line
+ (FullScreen
? 0 : TOP_BOTTOM_LINES
)) * Delta
);
94 for (Col
= 0; Col
< ScreenWidth
; Col
++)
102 XboxVideoClearScreen(UCHAR Attr
)
104 ULONG FgColor
, BgColor
;
106 XboxVideoAttrToColors(Attr
, &FgColor
, &BgColor
);
108 XboxVideoClearScreenColor(BgColor
, FALSE
);
112 XboxVideoPutChar(int Ch
, UCHAR Attr
, unsigned X
, unsigned Y
)
114 ULONG FgColor
, BgColor
;
116 XboxVideoAttrToColors(Attr
, &FgColor
, &BgColor
);
118 XboxVideoOutputChar(Ch
, X
, Y
, FgColor
, BgColor
);
126 FrameBuffer
= (PVOID
)((ULONG
) XboxMemReserveMemory(FB_SIZE_MB
) | 0xf0000000);
128 if (I2CTransmitByteGetReturn(0x10, 0x04, &AvMode
))
130 if (1 == AvMode
) /* HDTV */
136 /* FIXME Other possible values of AvMode:
154 Delta
= (ScreenWidth
* BytesPerPixel
+ 3) & ~ 0x3;
156 XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE
);
158 /* Tell the nVidia controller about the framebuffer */
159 *((PULONG
) 0xfd600800) = (ULONG
) FrameBuffer
;
163 XboxVideoSetDisplayMode(char *DisplayMode
, BOOLEAN Init
)
165 /* We only have one mode, semi-text */
166 return VideoTextMode
;
170 XboxVideoGetDisplaySize(PULONG Width
, PULONG Height
, PULONG Depth
)
172 *Width
= ScreenWidth
/ CHAR_WIDTH
;
173 *Height
= (ScreenHeight
- 2 * TOP_BOTTOM_LINES
) / CHAR_HEIGHT
;
178 XboxVideoGetBufferSize(VOID
)
180 return (ScreenHeight
- 2 * TOP_BOTTOM_LINES
) / CHAR_HEIGHT
* (ScreenWidth
/ CHAR_WIDTH
) * 2;
184 XboxVideoSetTextCursorPosition(UCHAR X
, UCHAR Y
)
186 /* We don't have a cursor yet */
190 XboxVideoHideShowTextCursor(BOOLEAN Show
)
192 /* We don't have a cursor yet */
196 XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer
)
198 PUCHAR OffScreenBuffer
= (PUCHAR
) Buffer
;
201 for (Line
= 0; Line
< (ScreenHeight
- 2 * TOP_BOTTOM_LINES
) / CHAR_HEIGHT
; Line
++)
203 for (Col
= 0; Col
< ScreenWidth
/ CHAR_WIDTH
; Col
++)
205 XboxVideoPutChar(OffScreenBuffer
[0], OffScreenBuffer
[1], Col
, Line
);
206 OffScreenBuffer
+= 2;
212 XboxVideoIsPaletteFixed(VOID
)
218 XboxVideoSetPaletteColor(UCHAR Color
, UCHAR Red
, UCHAR Green
, UCHAR Blue
)
224 XboxVideoGetPaletteColor(UCHAR Color
, UCHAR
* Red
, UCHAR
* Green
, UCHAR
* Blue
)
238 /* Call PC version */
243 XboxVideoPrepareForReactOS(IN BOOLEAN Setup
)
245 XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE
);