mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-12-24 18:21:50 +01:00
added libdi support
This commit is contained in:
parent
2e2c1d2b26
commit
d21599f529
@ -34,7 +34,7 @@ LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# any extra libraries we wish to link with the project
|
# any extra libraries we wish to link with the project
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
LIBS := -lfat -lwiiuse -lbte -logc -lm -lz -lsamplerate
|
LIBS := -ldi -lfat -lwiiuse -lbte -logc -lm -lz -lsamplerate
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
@ -15,32 +15,31 @@
|
|||||||
* To keep libOGC stable, make sure you call DVD_Init before using
|
* To keep libOGC stable, make sure you call DVD_Init before using
|
||||||
* these functions.
|
* these functions.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
|
#ifdef HW_RVL
|
||||||
|
#include "di/di.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HW_DOL
|
|
||||||
#include "dvd.h"
|
|
||||||
|
|
||||||
u64 DvdMaxOffset = 0x57057C00;
|
#ifndef HW_RVL
|
||||||
|
static u64 DvdMaxOffset = 0x57057C00; /* 1.4 GB max. */
|
||||||
/** DVD I/O Address base **/
|
static vu32* const dvd = (u32*)0xCC006000; /* DVD I/O Address base */
|
||||||
static vu32* const dvd = (u32*)0xCC006000;
|
static u8 *inquiry=(unsigned char *)0x80000004;
|
||||||
static unsigned char *inquiry=(unsigned char *)0x80000004;
|
|
||||||
|
|
||||||
/** Due to lack of memory, we'll use this little 2k keyhole for all DVD operations **/
|
|
||||||
unsigned char DVDreadbuffer[2048] ATTRIBUTE_ALIGN (32);
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include "wdvd.h"
|
static u64 DvdMaxOffset = 0x118244F00LL; /* 4.7 GB max. */
|
||||||
u64 DvdMaxOffset = 0x118244F00LL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* 2k buffer for all DVD operations */
|
||||||
|
u8 DVDreadbuffer[2048] ATTRIBUTE_ALIGN (32);
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* dvd_read
|
* dvd_read
|
||||||
*
|
*
|
||||||
* Read DVD disc sectors
|
* Read DVD disc sectors
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
int dvd_read (void *dst, unsigned int len, u64 offset)
|
u32 dvd_read (void *dst, u32 len, u64 offset)
|
||||||
{
|
{
|
||||||
/*** We only allow 2k reads **/
|
/*** We only allow 2k reads **/
|
||||||
if (len > 2048) return 0;
|
if (len > 2048) return 0;
|
||||||
@ -48,10 +47,10 @@ int dvd_read (void *dst, unsigned int len, u64 offset)
|
|||||||
/*** Let's not read past end of DVD ***/
|
/*** Let's not read past end of DVD ***/
|
||||||
if(offset < DvdMaxOffset)
|
if(offset < DvdMaxOffset)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef HW_DOL
|
|
||||||
unsigned char *buffer = (unsigned char *) (unsigned int) DVDreadbuffer;
|
unsigned char *buffer = (unsigned char *) (unsigned int) DVDreadbuffer;
|
||||||
DCInvalidateRange((void *)buffer, len);
|
DCInvalidateRange((void *)buffer, len);
|
||||||
|
|
||||||
|
#ifndef HW_RVL
|
||||||
dvd[0] = 0x2E;
|
dvd[0] = 0x2E;
|
||||||
dvd[1] = 0;
|
dvd[1] = 0;
|
||||||
dvd[2] = 0xA8000000;
|
dvd[2] = 0xA8000000;
|
||||||
@ -63,46 +62,29 @@ int dvd_read (void *dst, unsigned int len, u64 offset)
|
|||||||
|
|
||||||
/*** Enable reading with DMA ***/
|
/*** Enable reading with DMA ***/
|
||||||
while (dvd[7] & 1);
|
while (dvd[7] & 1);
|
||||||
memcpy (dst, buffer, len);
|
|
||||||
|
|
||||||
/*** Ensure it has completed ***/
|
/*** Ensure it has completed ***/
|
||||||
if (dvd[0] & 0x4) return 0;
|
if (dvd[0] & 0x4) return 0;
|
||||||
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
#elif WII_DVD
|
#else
|
||||||
return WDVD_LowUnencryptedRead((unsigned char **)&dst, len, (u32)(offset >> 2));
|
int ret = DI_ReadDVD(buffer, len , (u32)(offset >> 2));
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
char msg[50];
|
||||||
|
u32 val;
|
||||||
|
DI_GetError(&val);
|
||||||
|
sprintf(msg, "DI Read Error: 0x%08X\n",val);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
memcpy (dst, buffer, len);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* uselessinquiry
|
|
||||||
*
|
|
||||||
* As the name suggests, this function is quite useless.
|
|
||||||
* It's only purpose is to stop any pending DVD interrupts while we use the
|
|
||||||
* memcard interface.
|
|
||||||
*
|
|
||||||
* libOGC tends to foul up if you don't, and sometimes does if you do!
|
|
||||||
****************************************************************************/
|
|
||||||
#ifdef HW_DOL
|
|
||||||
void uselessinquiry ()
|
|
||||||
{
|
|
||||||
dvd[0] = 0;
|
|
||||||
dvd[1] = 0;
|
|
||||||
dvd[2] = 0x12000000;
|
|
||||||
dvd[3] = 0;
|
|
||||||
dvd[4] = 0x20;
|
|
||||||
dvd[5] = 0x80000000;
|
|
||||||
dvd[6] = 0x20;
|
|
||||||
dvd[7] = 1;
|
|
||||||
|
|
||||||
while (dvd[7] & 1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* dvd_motor_off
|
* dvd_motor_off
|
||||||
*
|
*
|
||||||
@ -110,9 +92,9 @@ void uselessinquiry ()
|
|||||||
*
|
*
|
||||||
* This can be used to prevent the Disc from spinning during playtime
|
* This can be used to prevent the Disc from spinning during playtime
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#ifdef HW_DOL
|
|
||||||
void dvd_motor_off( )
|
void dvd_motor_off( )
|
||||||
{
|
{
|
||||||
|
#ifndef HW_RVL
|
||||||
dvd[0] = 0x2e;
|
dvd[0] = 0x2e;
|
||||||
dvd[1] = 0;
|
dvd[1] = 0;
|
||||||
dvd[2] = 0xe3000000;
|
dvd[2] = 0xe3000000;
|
||||||
@ -126,8 +108,35 @@ void dvd_motor_off( )
|
|||||||
/*** PSO Stops blackscreen at reload ***/
|
/*** PSO Stops blackscreen at reload ***/
|
||||||
dvd[0] = 0x14;
|
dvd[0] = 0x14;
|
||||||
dvd[1] = 0;
|
dvd[1] = 0;
|
||||||
}
|
|
||||||
|
#else
|
||||||
|
DI_StopMotor();
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef HW_RVL
|
||||||
|
/****************************************************************************
|
||||||
|
* uselessinquiry
|
||||||
|
*
|
||||||
|
* As the name suggests, this function is quite useless.
|
||||||
|
* It's only purpose is to stop any pending DVD interrupts while we use the
|
||||||
|
* memcard interface.
|
||||||
|
*
|
||||||
|
* libOGC tends to foul up if you don't, and sometimes does if you do!
|
||||||
|
****************************************************************************/
|
||||||
|
void uselessinquiry ()
|
||||||
|
{
|
||||||
|
dvd[0] = 0;
|
||||||
|
dvd[1] = 0;
|
||||||
|
dvd[2] = 0x12000000;
|
||||||
|
dvd[3] = 0;
|
||||||
|
dvd[4] = 0x20;
|
||||||
|
dvd[5] = 0x80000000;
|
||||||
|
dvd[6] = 0x20;
|
||||||
|
dvd[7] = 1;
|
||||||
|
|
||||||
|
while (dvd[7] & 1);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* dvd_drive_detect()
|
* dvd_drive_detect()
|
||||||
@ -135,7 +144,6 @@ void dvd_motor_off( )
|
|||||||
* Detect the DVD Drive Type
|
* Detect the DVD Drive Type
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#ifdef HW_DOL
|
|
||||||
void dvd_drive_detect()
|
void dvd_drive_detect()
|
||||||
{
|
{
|
||||||
dvd[0] = 0x2e;
|
dvd[0] = 0x2e;
|
||||||
|
@ -15,9 +15,15 @@
|
|||||||
* To keep libOGC stable, make sure you call DVD_Init before using
|
* To keep libOGC stable, make sure you call DVD_Init before using
|
||||||
* these functions.
|
* these functions.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
#ifndef _DVD_H_
|
||||||
|
#define _DVD_H_
|
||||||
|
|
||||||
extern int dvd_read (void *dst, unsigned int len, u64 offset);
|
extern u32 dvd_read (void *dst, u32 len, u64 offset);
|
||||||
extern void uselessinquiry ();
|
|
||||||
extern void dvd_motor_off ();
|
extern void dvd_motor_off ();
|
||||||
extern void dvd_drive_detect();
|
|
||||||
|
|
||||||
|
#ifndef HW_RVL
|
||||||
|
extern void uselessinquiry ();
|
||||||
|
extern void dvd_drive_detect();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
* Only partial support is included, in that only the first file within the archive
|
* Only partial support is included, in that only the first file within the archive
|
||||||
* is considered to be a ROM image.
|
* is considered to be a ROM image.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#ifndef _UNZIP_H_
|
#ifndef _FILEIO_H_
|
||||||
#define _UNZIP_H_
|
#define _FILEIO_H_
|
||||||
|
|
||||||
extern int IsZipFile (char *buffer);
|
extern int IsZipFile (char *buffer);
|
||||||
int UnZipDVD (unsigned char *outbuffer, u64 discoffset, int length);
|
int UnZipDVD (unsigned char *outbuffer, u64 discoffset, int length);
|
||||||
|
@ -11,11 +11,14 @@
|
|||||||
*
|
*
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "dvd.h"
|
|
||||||
#include "iso9660.h"
|
#include "iso9660.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
#include "history.h"
|
#include "history.h"
|
||||||
|
#include "dvd.h"
|
||||||
|
#ifdef HW_RVL
|
||||||
|
#include "di/di.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PAGESIZE 12
|
#define PAGESIZE 12
|
||||||
|
|
||||||
@ -31,12 +34,8 @@ static u8 UseSDCARD = 0;
|
|||||||
static u8 UseHistory = 0;
|
static u8 UseHistory = 0;
|
||||||
static int LoadFile (unsigned char *buffer);
|
static int LoadFile (unsigned char *buffer);
|
||||||
|
|
||||||
/* globals */
|
|
||||||
FILE *sdfile;
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* FileSortCallback
|
* FileSortCallback (Marty Disibio)
|
||||||
*
|
*
|
||||||
* Quick sort callback to sort file entries with the following order:
|
* Quick sort callback to sort file entries with the following order:
|
||||||
* .
|
* .
|
||||||
@ -416,10 +415,23 @@ void OpenDVD ()
|
|||||||
|
|
||||||
if (!getpvd())
|
if (!getpvd())
|
||||||
{
|
{
|
||||||
ShowAction("Mounting DVD ... Wait");
|
/* mount DVD */
|
||||||
|
ShowAction("Mounting DVD ... Wait");
|
||||||
|
|
||||||
#ifndef HW_RVL
|
#ifndef HW_RVL
|
||||||
DVD_Mount();
|
DVD_Mount();
|
||||||
#endif
|
#else
|
||||||
|
DI_Mount();
|
||||||
|
while(DI_GetStatus() & DVD_INIT);
|
||||||
|
if (!(DI_GetStatus() & DVD_READY))
|
||||||
|
{
|
||||||
|
char msg[50];
|
||||||
|
sprintf(msg, "DI Status Error: 0x%08X\n",DI_GetStatus());
|
||||||
|
WaitPrompt(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
haveDVDdir = 0;
|
haveDVDdir = 0;
|
||||||
if (!getpvd())
|
if (!getpvd())
|
||||||
{
|
{
|
||||||
@ -494,6 +506,11 @@ int OpenSD ()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* OpenHistory
|
||||||
|
*
|
||||||
|
* Function to load a recent file from SDCARD (Marty Disibio)
|
||||||
|
****************************************************************************/
|
||||||
void OpenHistory()
|
void OpenHistory()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -501,19 +518,15 @@ void OpenHistory()
|
|||||||
UseSDCARD = 1;
|
UseSDCARD = 1;
|
||||||
UseHistory = 1;
|
UseHistory = 1;
|
||||||
|
|
||||||
/* don't mess with SD entries */
|
/* don't mess with other entries */
|
||||||
haveSDdir = 0;
|
haveSDdir = 0;
|
||||||
|
haveDVDdir = 0;
|
||||||
|
|
||||||
/* reinit selector */
|
/* reinit selector */
|
||||||
old_selection = selection = offset = old_offset = 0;
|
old_selection = selection = offset = old_offset = 0;
|
||||||
|
|
||||||
/* Reset SDCARD root directory */
|
/* Recreate the file listing from the history
|
||||||
/* Make this empty because the history */
|
* as if all of the roms were in the same directory. */
|
||||||
/* entry will contain the entire path. */
|
|
||||||
/*sprintf (rootSDdir, "");*/
|
|
||||||
|
|
||||||
/* Recreate the file listing from the history
|
|
||||||
* as if all of the roms were in the same directory. */
|
|
||||||
ShowAction("Reading Files ...");
|
ShowAction("Reading Files ...");
|
||||||
|
|
||||||
maxfiles = 0;
|
maxfiles = 0;
|
||||||
@ -561,6 +574,7 @@ static int LoadFile (unsigned char *buffer)
|
|||||||
u64 discoffset = 0;
|
u64 discoffset = 0;
|
||||||
char readbuffer[2048];
|
char readbuffer[2048];
|
||||||
char fname[MAXPATHLEN];
|
char fname[MAXPATHLEN];
|
||||||
|
FILE *sdfile = NULL;
|
||||||
|
|
||||||
if (rootdirlength == 0) return 0;
|
if (rootdirlength == 0) return 0;
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
* Based on Qoob MP3 Player Font
|
* Based on Qoob MP3 Player Font
|
||||||
* Added IPL font extraction
|
* Added IPL font extraction
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
#ifndef _FONT_H
|
||||||
|
#define _FONT_H
|
||||||
|
|
||||||
extern void init_font(void);
|
extern void init_font(void);
|
||||||
extern void WriteCentre_HL( int y, char *string);
|
extern void WriteCentre_HL( int y, char *string);
|
||||||
@ -21,3 +23,5 @@ extern int fheight;
|
|||||||
extern int font_size[256];
|
extern int font_size[256];
|
||||||
extern u16 back_framewidth;
|
extern u16 back_framewidth;
|
||||||
extern u8 SILENT;
|
extern u8 SILENT;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
* This is not intended as a complete guide to ISO9660.
|
* This is not intended as a complete guide to ISO9660.
|
||||||
* Here I use the bare minimum!
|
* Here I use the bare minimum!
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#ifndef _ISO9660_H
|
#ifndef _ISO9660_H
|
||||||
#define _ISO9660_H
|
#define _ISO9660_H
|
||||||
|
|
||||||
#define MAXJOLIET 256
|
#define MAXJOLIET 256
|
||||||
#define MAXFILES 1000 /** Restrict to 1000 files per dir **/
|
#define MAXFILES 1000 /** Restrict to 1000 files per dir **/
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
*
|
*
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "dvd.h"
|
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "saveicon.h" /*** Nice little icon - thanks brakken! ***/
|
#include "saveicon.h"
|
||||||
|
#ifndef HW_RVL
|
||||||
|
#include "dvd.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <fat.h>
|
#include <fat.h>
|
||||||
#include <sys/dir.h>
|
#include <sys/dir.h>
|
||||||
|
@ -19,12 +19,12 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "gcaram.h"
|
#include "gcaram.h"
|
||||||
#include "dvd.h"
|
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "history.h"
|
#include "history.h"
|
||||||
|
#ifndef HW_RVL
|
||||||
#ifdef WII_DVD
|
#include "dvd.h"
|
||||||
#include "wdvd.h"
|
#else
|
||||||
|
#include "di/di.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
@ -46,6 +46,13 @@ static void load_bios()
|
|||||||
|
|
||||||
/* update BIOS flags */
|
/* update BIOS flags */
|
||||||
config.bios_enabled |= 2;
|
config.bios_enabled |= 2;
|
||||||
|
|
||||||
|
if (config.bios_enabled == 3)
|
||||||
|
{
|
||||||
|
/* initialize system */
|
||||||
|
system_init ();
|
||||||
|
audio_init(48000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_machine()
|
static void init_machine()
|
||||||
@ -53,9 +60,6 @@ static void init_machine()
|
|||||||
/* Allocate cart_rom here */
|
/* Allocate cart_rom here */
|
||||||
cart_rom = memalign(32, 0xA00000);
|
cart_rom = memalign(32, 0xA00000);
|
||||||
|
|
||||||
/* BIOS support */
|
|
||||||
load_bios();
|
|
||||||
|
|
||||||
/* allocate global work bitmap */
|
/* allocate global work bitmap */
|
||||||
memset (&bitmap, 0, sizeof (bitmap));
|
memset (&bitmap, 0, sizeof (bitmap));
|
||||||
bitmap.width = 360;
|
bitmap.width = 360;
|
||||||
@ -73,6 +77,9 @@ static void init_machine()
|
|||||||
/* default system */
|
/* default system */
|
||||||
input.system[0] = SYSTEM_GAMEPAD;
|
input.system[0] = SYSTEM_GAMEPAD;
|
||||||
input.system[1] = SYSTEM_GAMEPAD;
|
input.system[1] = SYSTEM_GAMEPAD;
|
||||||
|
|
||||||
|
/* BIOS support */
|
||||||
|
load_bios();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
@ -96,35 +103,25 @@ int frameticker = 0;
|
|||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
#ifdef HW_RVL
|
||||||
|
/* initialize Wii DVD interface first */
|
||||||
|
DI_Init();
|
||||||
|
#endif
|
||||||
|
|
||||||
u16 usBetweenFrames;
|
u16 usBetweenFrames;
|
||||||
long long now, prev;
|
long long now, prev;
|
||||||
int RenderedFrameCount = 0;
|
int RenderedFrameCount = 0;
|
||||||
int FrameCount = 0;
|
int FrameCount = 0;
|
||||||
|
|
||||||
/* load hacked IOS with full access to DVD interface (WIP) */
|
|
||||||
#ifdef WII_DVD
|
|
||||||
IOS_ReloadIOS(5);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Initialize OGC subsystems */
|
/* Initialize OGC subsystems */
|
||||||
ogc_video__init();
|
ogc_video__init();
|
||||||
ogc_input__init();
|
ogc_input__init();
|
||||||
ogc_audio__init();
|
ogc_audio__init();
|
||||||
|
|
||||||
/* Initialize DVD interface */
|
|
||||||
#ifndef HW_RVL
|
#ifndef HW_RVL
|
||||||
|
/* Initialize GC DVD interface */
|
||||||
DVD_Init ();
|
DVD_Init ();
|
||||||
dvd_drive_detect();
|
dvd_drive_detect();
|
||||||
|
|
||||||
#elif WII_DVD
|
|
||||||
if (WDVD_Init())
|
|
||||||
{
|
|
||||||
if (WDVD_Reset())
|
|
||||||
{
|
|
||||||
u64 id;
|
|
||||||
WDVD_LowReadDiskId(&id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Initialize SDCARD Interface (LibFAT) */
|
/* Initialize SDCARD Interface (LibFAT) */
|
||||||
|
@ -1,160 +0,0 @@
|
|||||||
/*
|
|
||||||
* Wii DVD interface API
|
|
||||||
* Copyright (C) 2008 Jeff Epler <jepler@unpythonic.net>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef WII_DVD
|
|
||||||
#include <ogc/ipc.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ogc/system.h>
|
|
||||||
#include "wdvd.h"
|
|
||||||
|
|
||||||
static int di_fd = -1;
|
|
||||||
static s32 di_hid = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#define DEBUG
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define debug_printf printf
|
|
||||||
#define debug_wait printf
|
|
||||||
#else
|
|
||||||
#define debug_printf(...) ;
|
|
||||||
#define debug_wait(...) ;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool WDVD_Init()
|
|
||||||
{
|
|
||||||
if(di_fd >= 0) return 1;
|
|
||||||
|
|
||||||
di_fd = IOS_Open("/dev/do", 0);
|
|
||||||
if(di_fd < 0) {
|
|
||||||
debug_printf("IOS_Open(/dev/di) failed with code %d\n", di_fd);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
di_hid = iosCreateHeap(0x10000);
|
|
||||||
if(!di_hid) {
|
|
||||||
IOS_Close(di_fd);
|
|
||||||
di_fd = -1;
|
|
||||||
debug_printf("iosCreateHeap(0x20) failed with code %d\n", di_hid);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
debug_printf("fd=%d hid=%d\n", di_fd, di_hid);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WDVD_Reset()
|
|
||||||
{
|
|
||||||
bool result = false;
|
|
||||||
char *inbuf = (char*)iosAlloc(di_hid, 0x20);
|
|
||||||
char *outbuf = (char*)iosAlloc(di_hid, 0x20);
|
|
||||||
if(!inbuf || !outbuf)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
((u32*)inbuf)[0x00] = 0x8A000000;
|
|
||||||
((u32*)inbuf)[0x01] = 1;
|
|
||||||
|
|
||||||
result = IOS_Ioctl( di_fd, 0x8A, inbuf, 0x20, outbuf, 0x20);
|
|
||||||
out:
|
|
||||||
if(outbuf) iosFree(di_hid, outbuf);
|
|
||||||
if(inbuf) iosFree(di_hid, inbuf);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define max(a,b) ((a) > (b) ? (a) : (b))
|
|
||||||
|
|
||||||
unsigned char* ios_command = 0;
|
|
||||||
unsigned char* ios_out = 0;
|
|
||||||
unsigned int ios_outlen = 0;
|
|
||||||
|
|
||||||
void WDVD_AllocCommand()
|
|
||||||
{
|
|
||||||
if (ios_command == 0)
|
|
||||||
ios_command = (unsigned char*)iosAlloc(di_hid, 0x20);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WDVD_AllocOutput(unsigned int length)
|
|
||||||
{
|
|
||||||
if (ios_out == 0 || ios_outlen != length)
|
|
||||||
{
|
|
||||||
if (ios_out)
|
|
||||||
iosFree(di_hid, ios_out);
|
|
||||||
|
|
||||||
ios_out = (unsigned char*)iosAlloc(di_hid, max(length, 0x20));
|
|
||||||
ios_outlen = length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int WDVD_LowUnencryptedRead(unsigned char **poutbuf, u32 len, u32 offset)
|
|
||||||
{
|
|
||||||
WDVD_AllocCommand();
|
|
||||||
WDVD_AllocOutput(len);
|
|
||||||
|
|
||||||
unsigned char* inbuf = ios_command;
|
|
||||||
unsigned char* outbuf = ios_out;
|
|
||||||
|
|
||||||
*poutbuf = ios_out;
|
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
if(!inbuf || !outbuf) { result = -1; goto out; }
|
|
||||||
|
|
||||||
((u32*)inbuf)[0] = 0x8d000000;
|
|
||||||
((u32*)inbuf)[1] = len;
|
|
||||||
((u32*)inbuf)[2] = offset;
|
|
||||||
|
|
||||||
// memset(outbuf, 0x00, len);
|
|
||||||
|
|
||||||
result = IOS_Ioctl(di_fd, 0x8d, inbuf, 0x20, outbuf, len);
|
|
||||||
|
|
||||||
if (result != 1)
|
|
||||||
debug_printf("-> %d\n", result);
|
|
||||||
|
|
||||||
// if(result >= 0) {
|
|
||||||
// memcpy(buf, outbuf, len);
|
|
||||||
// }
|
|
||||||
|
|
||||||
out:
|
|
||||||
//if(outbuf) iosFree(di_hid, outbuf);
|
|
||||||
//if(inbuf) iosFree(di_hid, inbuf);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int WDVD_LowReadDiskId(u64 *id)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
char *inbuf = (char*)iosAlloc(di_hid, 0x20);
|
|
||||||
char *outbuf = (char*)iosAlloc(di_hid, 0x20);
|
|
||||||
if(!inbuf || !outbuf) { result = -1; goto out; }
|
|
||||||
((u32*)inbuf)[0] = 0x70000000;
|
|
||||||
|
|
||||||
*(u64*)outbuf = 0;
|
|
||||||
result = IOS_Ioctl(di_fd, 0x8D, inbuf, 0x20, outbuf, 0x20);
|
|
||||||
|
|
||||||
*id = *(u64*) outbuf;
|
|
||||||
|
|
||||||
out:
|
|
||||||
if(inbuf) iosFree(di_hid, inbuf);
|
|
||||||
if(outbuf) iosFree(di_hid, outbuf);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Wii DVD interface API
|
|
||||||
* Copyright (C) 2008 Jeff Epler <jepler@unpythonic.net>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _WDVD_H_
|
|
||||||
#define _WDVD_H_
|
|
||||||
bool WDVD_Init();
|
|
||||||
bool WDVD_Reset();
|
|
||||||
|
|
||||||
int WDVD_LowUnencryptedRead(unsigned char **outbuf, u32 len, u32 offset);
|
|
||||||
int WDVD_LowReadDiskId(u64 *id);
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue
Block a user