examples: Don't print text when using dual 3D FB mode

When using dual 3D DMA mode the console is setup to use memory in the
middle of SUB background VRAM. This is what holds the text that you can see
on the screen.

When switching to FB mode, the console is never reconfigured (when
switching to regular dual 3D mode it is reconfigured). This means that any
printf will write to the middle of background VRAM, which is used as
framebuffer. This will manifest itself as a blue horizontal line in the
middle of the screen.

This patch fixes the examples to not print text when using FB mode.
This commit is contained in:
Antonio Niño Díaz 2024-02-18 01:42:01 +00:00
parent b00a4f29b8
commit 3af40682cb
2 changed files with 29 additions and 13 deletions

View File

@ -84,6 +84,8 @@ int main(void)
init_all();
bool console = true;
while (1)
{
NE_WaitForVBL(0);
@ -96,14 +98,17 @@ int main(void)
uint32_t keys = keysHeld();
uint32_t kdown = keysDown();
printf("\x1b[0;0H"
"START: Lock CPU until released\n"
"A: Sine effect.\n"
"B: Deactivate effect.\n"
"SELECT: Dual 3D DMA mode\n"
"X: Dual 3D FB mode (no console)\n"
"Y: Dual 3D mode\n"
"Pad: Rotate.\n");
if (console)
{
printf("\x1b[0;0H"
"START: Lock CPU until released\n"
"A: Sine effect.\n"
"B: Deactivate effect.\n"
"SELECT: Dual 3D DMA mode\n"
"X: Dual 3D FB mode (no console)\n"
"Y: Dual 3D mode\n"
"Pad: Rotate.\n");
}
// Lock CPU in an infinite loop to simulate a drop in framerate
while (keys & KEY_START)
@ -147,12 +152,14 @@ int main(void)
NE_InitDual3D();
NE_InitConsole();
init_all();
console = true;
}
if (kdown & KEY_X)
{
NE_SpecialEffectSet(0);
NE_InitDual3D_FB();
init_all();
console = false;
}
if (kdown & KEY_SELECT)
{
@ -160,6 +167,7 @@ int main(void)
NE_InitDual3D_DMA();
NE_InitConsole();
init_all();
console = true;
}
}

View File

@ -73,6 +73,8 @@ int main(void)
uint16_t red = NE_Red;
uint16_t green = NE_Green;
bool console = true;
while (1)
{
NE_WaitForVBL(0);
@ -86,11 +88,14 @@ int main(void)
uint32_t keys = keysHeld();
uint32_t kdown = keysDown();
printf("\x1b[0;0H"
"A: Dual 3D DMA mode\n"
"X: Dual 3D FB mode (no console)\n"
"Y: Dual 3D mode\n"
"Pad: Rotate.\n");
if (console)
{
printf("\x1b[0;0H"
"A: Dual 3D DMA mode\n"
"X: Dual 3D FB mode (no console)\n"
"Y: Dual 3D mode\n"
"Pad: Rotate.\n");
}
// Lock CPU in an infinite loop to simulate a drop in framerate
while (keys & KEY_START)
@ -126,17 +131,20 @@ int main(void)
NE_InitDual3D();
NE_InitConsole();
init_all();
console = true;
}
if (kdown & KEY_X)
{
NE_InitDual3D_FB();
init_all();
console = false;
}
if (kdown & KEY_A)
{
NE_InitDual3D_DMA();
NE_InitConsole();
init_all();
console = true;
}
}