better wii init source organization, add video init for console display

This commit is contained in:
Gered 2016-11-03 20:08:09 -04:00
parent 605f5635e1
commit 5e6dd84736
3 changed files with 70 additions and 12 deletions

54
src/dol_init.c Normal file
View file

@ -0,0 +1,54 @@
#ifdef GEKKO
#include "dol_init.h"
#include <stdio.h>
#include <gccore.h>
#include <fat.h>
#include <debug.h>
static void *xfb = NULL;
static GXRModeObj *rmode = NULL;
void DOL_Init()
{
#ifdef DEBUG_GDB
DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
_break();
#endif
VIDEO_Init();
rmode = VIDEO_GetPreferredMode(NULL);
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
console_init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ);
VIDEO_Configure(rmode);
VIDEO_SetNextFramebuffer(xfb);
VIDEO_SetBlack(FALSE);
VIDEO_Flush();
VIDEO_WaitVSync();
if(rmode->viTVMode & VI_NON_INTERLACE)
{
VIDEO_WaitVSync();
}
// helps ensure TV overscan won't cut off initial console output
printf("\x1b[2;0H");
printf("DOL_Init: Console video init finished.\n");
if (!fatInitDefault())
{
printf("DOL_Init: *** FATAL: fatInitDefault failed.\n");
exit(1);
}
else
{
printf("DOL_Init: fatInitDefault success.\n");
}
}
#endif

11
src/dol_init.h Normal file
View file

@ -0,0 +1,11 @@
#ifndef __DOL_INIT__
#define __DOL_INIT__
#ifdef GEKKO
void DOL_Init();
#endif
#endif

View file

@ -27,9 +27,7 @@
#include "m_argv.h"
#ifdef GEKKO
#include <gccore.h>
#include <fat.h>
#include <debug.h>
#include "dol_init.h"
#endif
//
@ -42,20 +40,15 @@ void D_DoomMain (void);
int main(int argc, char **argv)
{
#ifdef GEKKO
#ifdef DEBUG_GDB
DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
_break();
#endif
fatInitDefault();
#endif
// save arguments
myargc = argc;
myargv = argv;
#ifdef GEKKO
DOL_Init();
#endif
M_FindResponseFile();
// start doom