2012-01-21 22:15:45 +01:00
|
|
|
#include <gccore.h>
|
2012-02-25 23:34:52 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <dirent.h>
|
2012-01-23 16:57:30 +01:00
|
|
|
#include "gc.h"
|
2012-02-25 23:34:52 +01:00
|
|
|
#include "gecko.h"
|
2012-02-27 17:05:10 +01:00
|
|
|
#include "fileOps.h"
|
2012-02-28 19:44:41 +01:00
|
|
|
#include "utils.h"
|
2012-03-05 10:48:13 +01:00
|
|
|
#include "defines.h"
|
2012-01-21 22:15:45 +01:00
|
|
|
|
2012-02-02 23:22:46 +01:00
|
|
|
#define SRAM_ENGLISH 0
|
|
|
|
#define SRAM_GERMAN 1
|
|
|
|
#define SRAM_FRENCH 2
|
|
|
|
#define SRAM_SPANISH 3
|
|
|
|
#define SRAM_ITALIAN 4
|
|
|
|
#define SRAM_DUTCH 5
|
|
|
|
|
2012-01-21 22:15:45 +01:00
|
|
|
syssram* __SYS_LockSram();
|
|
|
|
u32 __SYS_UnlockSram(u32 write);
|
|
|
|
u32 __SYS_SyncSram(void);
|
|
|
|
|
2012-01-23 16:57:30 +01:00
|
|
|
void set_video_mode(int i)
|
2012-01-21 22:15:45 +01:00
|
|
|
{
|
|
|
|
syssram *sram;
|
|
|
|
sram = __SYS_LockSram();
|
2012-01-23 16:57:30 +01:00
|
|
|
void *m_frameBuf;
|
|
|
|
static GXRModeObj *rmode;
|
2012-02-21 18:21:12 +01:00
|
|
|
|
|
|
|
if(VIDEO_HaveComponentCable())
|
|
|
|
sram->flags |= 0x80; //set progressive flag
|
|
|
|
else
|
|
|
|
sram->flags &= 0x7F; //clear progressive flag
|
|
|
|
|
|
|
|
if (!i)
|
2012-01-23 16:57:30 +01:00
|
|
|
{
|
|
|
|
rmode = &TVNtsc480IntDf;
|
2012-02-21 18:01:57 +01:00
|
|
|
sram->flags &= 0xFE; // Clear bit 0 to set the video mode to NTSC
|
|
|
|
sram->ntd &= 0xBF; //clear pal60 flag
|
2012-01-23 16:57:30 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rmode = &TVPal528IntDf;
|
2012-02-21 18:01:57 +01:00
|
|
|
sram->flags |= 0x01; // Set bit 0 to set the video mode to PAL
|
|
|
|
sram->ntd |= 0x40; //set pal60 flag
|
2012-01-23 16:57:30 +01:00
|
|
|
}
|
2012-02-21 18:01:57 +01:00
|
|
|
|
2012-01-21 22:15:45 +01:00
|
|
|
__SYS_UnlockSram(1); // 1 -> write changes
|
|
|
|
while(!__SYS_SyncSram());
|
|
|
|
|
2012-01-23 16:57:30 +01:00
|
|
|
/* Set video mode to PAL or NTSC */
|
2012-02-21 18:01:57 +01:00
|
|
|
*(vu32*)0x800000CC = i;
|
|
|
|
DCFlushRange((void *)(0x800000CC), 1);
|
|
|
|
ICInvalidateRange((void *)(0x800000CC), 1);
|
2012-01-23 16:57:30 +01:00
|
|
|
|
|
|
|
VIDEO_Configure(rmode);
|
|
|
|
m_frameBuf = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
|
|
|
|
|
|
|
|
VIDEO_ClearFrameBuffer(rmode, m_frameBuf, COLOR_BLACK);
|
|
|
|
VIDEO_SetNextFramebuffer(m_frameBuf);
|
2012-02-02 23:22:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 get_wii_language()
|
|
|
|
{
|
|
|
|
switch (CONF_GetLanguage())
|
|
|
|
{
|
|
|
|
case CONF_LANG_GERMAN:
|
|
|
|
return SRAM_GERMAN;
|
|
|
|
case CONF_LANG_FRENCH:
|
|
|
|
return SRAM_FRENCH;
|
|
|
|
case CONF_LANG_SPANISH:
|
|
|
|
return SRAM_SPANISH;
|
|
|
|
case CONF_LANG_ITALIAN:
|
|
|
|
return SRAM_ITALIAN;
|
|
|
|
case CONF_LANG_DUTCH:
|
|
|
|
return SRAM_DUTCH;
|
|
|
|
default:
|
|
|
|
return SRAM_ENGLISH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_language(u8 lang)
|
|
|
|
{
|
|
|
|
if (lang == 0)
|
|
|
|
{
|
|
|
|
lang = get_wii_language();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
lang--;
|
|
|
|
|
|
|
|
syssram *sram;
|
|
|
|
sram = __SYS_LockSram();
|
|
|
|
sram->lang = lang;
|
|
|
|
|
|
|
|
__SYS_UnlockSram(1); // 1 -> write changes
|
|
|
|
while(!__SYS_SyncSram());
|
2012-02-25 23:34:52 +01:00
|
|
|
}
|
|
|
|
|
2012-02-27 17:05:10 +01:00
|
|
|
bool DML_GameIsInstalled(char *discid, const char* partition)
|
2012-02-25 23:34:52 +01:00
|
|
|
{
|
2012-03-05 10:48:13 +01:00
|
|
|
char folder[12];
|
|
|
|
char source[300];
|
|
|
|
snprintf(folder, sizeof(folder), DML_DIR, partition);
|
2012-03-05 11:01:07 +01:00
|
|
|
snprintf(source, sizeof(source), "%s/%s/game.iso", folder, discid);
|
2012-02-25 23:34:52 +01:00
|
|
|
|
2012-03-05 10:48:13 +01:00
|
|
|
FILE *f = fopen(source, "r");
|
2012-02-25 23:34:52 +01:00
|
|
|
if (f)
|
|
|
|
{
|
2012-03-05 10:48:13 +01:00
|
|
|
gprintf("Found on %s: %s\n", partition, source);
|
2012-02-25 23:34:52 +01:00
|
|
|
fclose(f);
|
|
|
|
return true;
|
|
|
|
}
|
2012-03-05 10:48:13 +01:00
|
|
|
gprintf("Not found on %s: %s\n", partition, source);
|
2012-02-25 23:34:52 +01:00
|
|
|
return false;
|
|
|
|
}
|