diff options
| author | Sonicadvance1 <sonicadvance1@gmail.com> | 2010-03-29 09:26:19 +0000 |
|---|---|---|
| committer | Sonicadvance1 <sonicadvance1@gmail.com> | 2010-03-29 09:26:19 +0000 |
| commit | 85a1b2af455157e38a40faa427909f950e9d41d2 (patch) | |
| tree | ab8b482a6330f79d362d74e929f49565cc4d7daf /Source/TestSuite/ASM/source/Init.cpp | |
| parent | a8865d21b32f50b45f48cd1f8e4d1cafc5486585 (diff) | |
This should largely go unnoticed
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5251 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/TestSuite/ASM/source/Init.cpp')
| -rw-r--r-- | Source/TestSuite/ASM/source/Init.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/Source/TestSuite/ASM/source/Init.cpp b/Source/TestSuite/ASM/source/Init.cpp new file mode 100644 index 0000000000..cd2ab852b1 --- /dev/null +++ b/Source/TestSuite/ASM/source/Init.cpp @@ -0,0 +1,80 @@ +#include <stdio.h> +#include <stdlib.h> +#include <gccore.h> +#include <sdcard/wiisd_io.h> +#include <fat.h> +#include <dirent.h> +#include <wiiuse/wpad.h> +#include <unistd.h> +#include <string.h> + +#include "Init.h" + +static void *xfb = NULL; +static GXRModeObj *rmode = NULL; +void die(char *msg) { + if (f!=NULL) fclose(f); + printf(msg); + sleep(5); + fatUnmount("sd"); + __io_wiisd.shutdown(); + exit(0); +} + +void initialise_fat() { + __io_wiisd.startup(); + if (!fatInitDefault()) + die("Unable to initialise FAT subsystem, exiting.\n"); + fatMountSimple("sd", &__io_wiisd); + DIR_ITER *root = diropen("/"); + if (!root) + die("Cannot open root dir, exiting.\n"); + dirclose(root); + if (chdir("/")) + die("Could not change to root directory, exiting.\n"); +} + +void init_crap() { + VIDEO_Init(); + WPAD_Init(); + PAD_Init(); + + // Obtain the preferred video mode from the system + // This will correspond to the settings in the Wii menu + rmode = VIDEO_GetPreferredMode(NULL); + + // Allocate memory for the display in the uncached region + xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); + + // Initialise the console, required for printf + console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); + + // Set up the video registers with the chosen mode + VIDEO_Configure(rmode); + + // Tell the video hardware where our display memory is + VIDEO_SetNextFramebuffer(xfb); + + // Make the display visible + VIDEO_SetBlack(FALSE); + + // Flush the video register changes to the hardware + VIDEO_Flush(); + + // Wait for Video setup to complete + VIDEO_WaitVSync(); + if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); +} + +void end() { + int columns = 0, rows = 0; + CON_GetMetrics(&columns, &rows); + printf("\x1b[%i;0H",rows); + printf("File written... press Home/Start to exit."); + while(1) { + WPAD_ScanPads(); PAD_ScanPads(); + if ((WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) || (PAD_ButtonsDown(0) & PAD_BUTTON_START)) + exit(0); + VIDEO_WaitVSync(); + } +} |
