[FREELDR] Add vertical screen scrolling for Xbox with console mode (#2745)

Also turn off debug messages to screen before setting up the CPU (To print a character to the screen on some ports the MMIO access should be executed, so it throws an exception).

CORE-16216
This commit is contained in:
Dmitry Borisov 2020-05-10 22:35:51 +06:00 committed by GitHub
parent a2a24cadae
commit 98c17d3120
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 49 additions and 9 deletions

View file

@ -37,6 +37,7 @@ Pc98PrepareForReactOS(VOID)
Pc98DiskPrepareForReactOS(); Pc98DiskPrepareForReactOS();
Pc98VideoPrepareForReactOS(); Pc98VideoPrepareForReactOS();
DiskStopFloppyMotor(); DiskStopFloppyMotor();
DebugDisableScreenPort();
} }
ULONG ULONG

View file

@ -277,10 +277,6 @@ MachInit(const char *CmdLine)
/* Set LEDs to red before anything is initialized */ /* Set LEDs to red before anything is initialized */
XboxSetLED("rrrr"); XboxSetLED("rrrr");
/* Initialize our stuff */
XboxMemInit();
XboxVideoInit();
/* Setup vtbl */ /* Setup vtbl */
MachVtbl.ConsPutChar = XboxConsPutChar; MachVtbl.ConsPutChar = XboxConsPutChar;
MachVtbl.ConsKbHit = XboxConsKbHit; MachVtbl.ConsKbHit = XboxConsKbHit;
@ -311,6 +307,10 @@ MachInit(const char *CmdLine)
MachVtbl.HwDetect = XboxHwDetect; MachVtbl.HwDetect = XboxHwDetect;
MachVtbl.HwIdle = XboxHwIdle; MachVtbl.HwIdle = XboxHwIdle;
/* Initialize our stuff */
XboxMemInit();
XboxVideoInit();
/* Set LEDs to orange after init */ /* Set LEDs to orange after init */
XboxSetLED("oooo"); XboxSetLED("oooo");
@ -324,6 +324,9 @@ XboxPrepareForReactOS(VOID)
XboxVideoPrepareForReactOS(); XboxVideoPrepareForReactOS();
XboxDiskInit(FALSE); XboxDiskInit(FALSE);
DiskStopFloppyMotor(); DiskStopFloppyMotor();
/* Turn off debug messages to screen */
DebugDisableScreenPort();
} }
/* EOF */ /* EOF */

View file

@ -25,7 +25,17 @@ static unsigned CurrentAttr = 0x0f;
VOID VOID
XboxConsPutChar(int c) XboxConsPutChar(int c)
{ {
ULONG Width, Unused; ULONG Width, Height, Unused;
BOOLEAN NeedScroll;
XboxVideoGetDisplaySize(&Width, &Height, &Unused);
NeedScroll = (CurrentCursorY >= Height);
if (NeedScroll)
{
XboxVideoScrollUp();
--CurrentCursorY;
}
if (c == '\r') if (c == '\r')
{ {
@ -34,7 +44,9 @@ XboxConsPutChar(int c)
else if (c == '\n') else if (c == '\n')
{ {
CurrentCursorX = 0; CurrentCursorX = 0;
CurrentCursorY++;
if (!NeedScroll)
++CurrentCursorY;
} }
else if (c == '\t') else if (c == '\t')
{ {
@ -46,13 +58,11 @@ XboxConsPutChar(int c)
CurrentCursorX++; CurrentCursorX++;
} }
XboxVideoGetDisplaySize(&Width, &Unused, &Unused);
if (CurrentCursorX >= Width) if (CurrentCursorX >= Width)
{ {
CurrentCursorX = 0; CurrentCursorX = 0;
CurrentCursorY++; CurrentCursorY++;
} }
// FIXME: Implement vertical screen scrolling if we are at the end of the screen.
} }
BOOLEAN BOOLEAN

View file

@ -20,8 +20,8 @@
*/ */
#include <freeldr.h> #include <freeldr.h>
#include <debug.h>
#include <debug.h>
DBG_DEFAULT_CHANNEL(UI); DBG_DEFAULT_CHANNEL(UI);
PVOID FrameBuffer; PVOID FrameBuffer;
@ -101,6 +101,24 @@ XboxVideoClearScreenColor(ULONG Color, BOOLEAN FullScreen)
} }
} }
VOID
XboxVideoScrollUp(VOID)
{
ULONG BgColor, Dummy;
ULONG PixelCount = ScreenWidth * CHAR_HEIGHT *
(((ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT) - 1);
PULONG Src = (PULONG)((PUCHAR)FrameBuffer + (CHAR_HEIGHT + TOP_BOTTOM_LINES) * Delta);
PULONG Dst = (PULONG)((PUCHAR)FrameBuffer + TOP_BOTTOM_LINES * Delta);
XboxVideoAttrToColors(ATTR(COLOR_WHITE, COLOR_BLACK), &Dummy, &BgColor);
while (PixelCount--)
*Dst++ = *Src++;
for (PixelCount = 0; PixelCount < ScreenWidth * CHAR_HEIGHT; PixelCount++)
*Dst++ = BgColor;
}
VOID VOID
XboxVideoClearScreen(UCHAR Attr) XboxVideoClearScreen(UCHAR Attr)
{ {

View file

@ -69,6 +69,7 @@ VOID XboxVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue);
VOID XboxVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue); VOID XboxVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue);
VOID XboxVideoSync(VOID); VOID XboxVideoSync(VOID);
VOID XboxVideoPrepareForReactOS(VOID); VOID XboxVideoPrepareForReactOS(VOID);
VOID XboxVideoScrollUp(VOID);
VOID XboxPrepareForReactOS(VOID); VOID XboxPrepareForReactOS(VOID);
VOID XboxMemInit(VOID); VOID XboxMemInit(VOID);

View file

@ -44,6 +44,7 @@
ULONG DbgPrint(const char *Format, ...); ULONG DbgPrint(const char *Format, ...);
VOID DbgPrint2(ULONG Mask, ULONG Level, const char *File, ULONG Line, char *Format, ...); VOID DbgPrint2(ULONG Mask, ULONG Level, const char *File, ULONG Line, char *Format, ...);
VOID DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length); VOID DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length);
VOID DebugDisableScreenPort();
VOID DbgParseDebugChannels(PCHAR Value); VOID DbgParseDebugChannels(PCHAR Value);
#define ERR_LEVEL 0x1 #define ERR_LEVEL 0x1

View file

@ -327,6 +327,12 @@ DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)
} }
} }
VOID
DebugDisableScreenPort(VOID)
{
DebugPort &= ~SCREEN;
}
static BOOLEAN static BOOLEAN
DbgAddDebugChannel(CHAR* channel, CHAR* level, CHAR op) DbgAddDebugChannel(CHAR* channel, CHAR* level, CHAR op)
{ {